1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
20 #define y2log_component "qt-ui"
21 #include <ycp/y2log.h>
31 YQFrame::YQFrame( YWidget * parent,
32 const string & initialLabel )
33 : Q3GroupBox( (QWidget *) parent->widgetRep() )
34 , YFrame( parent, initialLabel )
36 setWidgetRep ( this );
37 QGroupBox::setTitle( fromUTF8( label() ) );
47 void YQFrame::setEnabled( bool enabled )
49 QGroupBox::setEnabled( enabled );
50 YWidget::setEnabled( enabled );
55 YQFrame::setSize( int newWidth, int newHeight )
57 resize( newWidth, newHeight );
61 int newChildWidth = max ( 0, newWidth - 2 * frameWidth() - 1 );
62 int newChildHeight = max ( 0, newHeight - frameWidth() - fontMetrics().height() - 1 );
64 firstChild()->setSize( newChildWidth, newChildHeight );
66 QWidget * qChild = (QWidget *) firstChild()->widgetRep();
67 qChild->move( frameWidth(), fontMetrics().height() );
73 YQFrame::setLabel( const string & newLabel )
75 YFrame::setLabel( newLabel );
76 QGroupBox::setTitle( fromUTF8( label() ) );
80 int YQFrame::preferredWidth()
83 int childPreferredWidth = hasChildren() ? firstChild()->preferredWidth() : 0;
85 preferredWidth = max( childPreferredWidth,
86 (10 + fontMetrics().width( title() ) ) );
87 preferredWidth += 2*frameWidth() + 1;
89 return preferredWidth;
93 int YQFrame::preferredHeight()
95 int preferredHeight = hasChildren() ? firstChild()->preferredHeight() : 0;
96 preferredHeight += frameWidth() + fontMetrics().height() + 1;
98 return preferredHeight;
102 #include "YQFrame.moc"