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" 47 : QGroupBox( (QWidget *) parent->widgetRep() )
48 , YCheckBoxFrame( parent, label, checked)
50 setWidgetRep (
this );
51 QGroupBox::setTitle( fromUTF8( label ) );
52 QGroupBox::setCheckable(
true );
55 connect(
this, &pclass(
this)::toggled,
56 this, &pclass(
this)::stateChanged );
62 YCheckBoxFrame::setLabel( newLabel );
63 QGroupBox::setTitle( fromUTF8( label() ) );
69 return QGroupBox::isChecked();
75 setChecked( newValue );
84 QGroupBox::setEnabled(
true );
85 handleChildrenEnablement(
value() );
89 QGroupBox::setEnabled(
true );
90 YWidget::setChildrenEnabled(
false );
93 YWidget::setEnabled( enabled );
97 void YQCheckBoxFrame::stateChanged(
bool newState )
104 bool YQCheckBoxFrame::event( QEvent *e )
106 bool oldChildEnabled =
true;
108 if ( YCheckBoxFrame::hasChildren() )
109 oldChildEnabled = YCheckBoxFrame::firstChild()->isEnabled();
111 bool oldStatus = QGroupBox::isChecked();
112 bool ret = QGroupBox::event( e );
113 bool newStatus = QGroupBox::isChecked();
115 if ( oldStatus != newStatus )
117 yuiDebug() <<
"Status change of " <<
this <<
" : now " << std::boolalpha << newStatus << endl;
121 handleChildrenEnablement( newStatus );
125 if ( YCheckBoxFrame::hasChildren() )
126 YCheckBoxFrame::firstChild()->setEnabled( oldChildEnabled );
136 if ( event->added() )
144 QGroupBox::childEvent( event );
151 resize ( newWidth, newHeight );
155 QMargins margins = contentsMargins();
156 int newChildWidth = newWidth - margins.left() - margins.right();
157 int newChildHeight = newHeight - margins.bottom() - margins.top();
159 firstChild()->setSize( newChildWidth, newChildHeight );
161 QWidget * qChild = (QWidget *) firstChild()->widgetRep();
162 qChild->move( margins.left(), margins.top() );
169 int preferredWidth = hasChildren() ? firstChild()->preferredWidth() : 0;
170 QMargins margins = contentsMargins();
178 int preferredHeight = hasChildren() ? firstChild()->preferredHeight() : 0;
179 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.