26 #define YUILogComponent "qt-ui" 27 #include <yui/YUILog.h> 28 #include <qcheckbox.h> 30 #include <QVBoxLayout> 33 #include <yui/YEvent.h> 36 #include "YQCheckBoxFrame.h" 48 : QGroupBox( (QWidget *) parent->widgetRep() )
49 , YCheckBoxFrame( parent, label, checked)
51 setWidgetRep (
this );
52 QGroupBox::setTitle( fromUTF8( label ) );
53 QGroupBox::setCheckable(
true );
56 connect(
this, &pclass(
this)::toggled,
57 this, &pclass(
this)::stateChanged );
63 YCheckBoxFrame::setLabel( newLabel );
64 QGroupBox::setTitle( fromUTF8( label() ) );
70 return QGroupBox::isChecked();
76 setChecked( newValue );
85 QGroupBox::setEnabled(
true );
86 handleChildrenEnablement(
value() );
90 QGroupBox::setEnabled(
true );
91 YWidget::setChildrenEnabled(
false );
94 YWidget::setEnabled( enabled );
98 void YQCheckBoxFrame::stateChanged(
bool newState )
105 bool YQCheckBoxFrame::event( QEvent *e )
107 bool oldChildEnabled =
true;
109 if ( YCheckBoxFrame::hasChildren() )
110 oldChildEnabled = YCheckBoxFrame::firstChild()->isEnabled();
112 bool oldStatus = QGroupBox::isChecked();
113 bool ret = QGroupBox::event( e );
114 bool newStatus = QGroupBox::isChecked();
116 if ( oldStatus != newStatus )
118 yuiDebug() <<
"Status change of " <<
this <<
" : now " << std::boolalpha << newStatus << endl;
122 handleChildrenEnablement( newStatus );
126 if ( YCheckBoxFrame::hasChildren() )
127 YCheckBoxFrame::firstChild()->setEnabled( oldChildEnabled );
137 if ( event->added() )
145 QGroupBox::childEvent( event );
152 resize ( newWidth, newHeight );
156 QMargins margins = contentsMargins();
157 int newChildWidth = newWidth - margins.left() - margins.right();
158 int newChildHeight = newHeight - margins.bottom() - margins.top();
160 firstChild()->setSize( newChildWidth, newChildHeight );
162 QWidget * qChild = (QWidget *) firstChild()->widgetRep();
163 qChild->move( margins.left(), margins.top() );
170 int preferredWidth = hasChildren() ? firstChild()->preferredWidth() : 0;
171 QMargins margins = contentsMargins();
179 int preferredHeight = hasChildren() ? firstChild()->preferredHeight() : 0;
180 QMargins margins = contentsMargins();
virtual int preferredWidth()
Preferred width of the widget.
virtual void childEvent(QChildEvent *)
Reimplemented from QGroupBox to prevent QGroupBox from disabling children according to the check box ...
virtual bool setKeyboardFocus()
Accept the keyboard focus.
virtual bool value()
Get the status of the CheckBoxFrame's check box.
void sendEvent(YEvent *event)
Widget event handlers (slots) call this when an event occured that should be the answer to a UserInpu...
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
virtual void setValue(bool isChecked)
Check or uncheck the CheckBoxFrame's check box.
YQCheckBoxFrame(YWidget *parent, const std::string &label, bool checked)
Constructor.
virtual void setLabel(const std::string &label)
Change the label text on the CheckBoxFrame.
virtual int preferredHeight()
Preferred height of the widget.
static YQUI * ui()
Access the global Qt-UI.
virtual void setEnabled(bool enabled)
Set enabled / disabled state.