1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQWidgetFactory.cc
15 Author: Stefan Hundhammer <sh@suse.de>
19 #include <QColorGroup>
20 #include "YQWidgetFactory.h"
22 #include "YUIException.h"
23 #include "YQPackageSelectorPlugin.h"
29 YQWidgetFactory::YQWidgetFactory()
35 YQWidgetFactory::~YQWidgetFactory()
48 YQWidgetFactory::createDialog( YDialogType dialogType, YDialogColorMode colorMode )
50 QWidget * qParent = 0;
51 YQDialog * dialog = new YQDialog( qParent, dialogType, colorMode );
52 YUI_CHECK_NEW( dialog );
64 YQWidgetFactory::createLayoutBox( YWidget * parent, YUIDimension dim )
66 YQLayoutBox * layoutBox = new YQLayoutBox( parent, dim );
67 YUI_CHECK_NEW( layoutBox );
75 // Common Leaf Widgets
79 YQWidgetFactory::createPushButton( YWidget * parent, const string & label )
81 YQPushButton * pushButton = new YQPushButton( parent, label );
82 YUI_CHECK_NEW( pushButton );
90 YQWidgetFactory::createLabel( YWidget * parent,
95 YQLabel * label = new YQLabel( parent, text, isHeading, isOutputField );
96 YUI_CHECK_NEW( label );
104 YQWidgetFactory::createInputField( YWidget * parent, const string & label, bool passwordMode )
106 YQInputField * inputField = new YQInputField( parent, label, passwordMode );
107 YUI_CHECK_NEW( inputField );
115 YQWidgetFactory::createCheckBox( YWidget * parent, const string & label, bool isChecked )
117 YQCheckBox * checkBox = new YQCheckBox( parent, label, isChecked );
118 YUI_CHECK_NEW( checkBox );
126 YQWidgetFactory::createRadioButton( YWidget * parent, const string & label, bool isChecked )
128 YQRadioButton * radioButton = new YQRadioButton( parent, label, isChecked );
129 YUI_CHECK_NEW( radioButton );
131 // Register radio button with its button group.
132 // This has to be done after all constructors are done so virtual functions
135 if ( radioButton->buttonGroup() )
136 radioButton->buttonGroup()->addRadioButton( radioButton );
144 YQWidgetFactory::createComboBox( YWidget * parent, const string & label, bool editable )
146 YQComboBox * comboBox = new YQComboBox( parent, label, editable );
147 YUI_CHECK_NEW( comboBox );
155 YQWidgetFactory::createSelectionBox( YWidget * parent, const string & label )
157 YQSelectionBox * selectionBox = new YQSelectionBox( parent, label );
158 YUI_CHECK_NEW( selectionBox );
166 YQWidgetFactory::createTree( YWidget * parent, const string & label )
168 YQTree * tree = new YQTree( parent, label );
169 YUI_CHECK_NEW( tree );
177 YQWidgetFactory::createTable( YWidget * parent, YTableHeader * header )
179 YQTable * table = new YQTable( parent, header );
180 YUI_CHECK_NEW( table );
188 YQWidgetFactory::createProgressBar( YWidget * parent, const string & label, int maxValue )
190 YQProgressBar * progressBar = new YQProgressBar( parent, label, maxValue );
191 YUI_CHECK_NEW( progressBar );
199 YQWidgetFactory::createRichText( YWidget * parent, const string & text, bool plainTextMode )
201 YQRichText * richText = new YQRichText( parent, text, plainTextMode );
202 YUI_CHECK_NEW( richText );
211 // Less Common Leaf Widgets
215 YQWidgetFactory::createIntField( YWidget * parent, const string & label, int minVal, int maxVal, int initialVal )
217 YQIntField * intField = new YQIntField( parent, label, minVal, maxVal, initialVal );
218 YUI_CHECK_NEW( intField );
226 YQWidgetFactory::createMenuButton( YWidget * parent, const string & label )
228 YQMenuButton * menuButton = new YQMenuButton( parent, label );
229 YUI_CHECK_NEW( menuButton );
237 YQWidgetFactory::createMultiLineEdit( YWidget * parent, const string & label )
239 YQMultiLineEdit * multiLineEdit = new YQMultiLineEdit( parent, label );
240 YUI_CHECK_NEW( multiLineEdit );
242 return multiLineEdit;
248 YQWidgetFactory::createImage( YWidget * parent, const string & imageFileName, bool animated )
250 YQImage * image = new YQImage( parent, imageFileName, animated );
251 YUI_CHECK_NEW( image );
258 YQWidgetFactory::createLogView( YWidget * parent, const string & label, int visibleLines, int storedLines )
260 YQLogView * logView = new YQLogView( parent, label, visibleLines, storedLines );
261 YUI_CHECK_NEW( logView );
268 YQMultiSelectionBox *
269 YQWidgetFactory::createMultiSelectionBox( YWidget * parent, const string & label )
271 YQMultiSelectionBox * multiSelectionBox = new YQMultiSelectionBox( parent, label );
272 YUI_CHECK_NEW( multiSelectionBox );
274 return multiSelectionBox;
280 YQWidgetFactory::createPackageSelector( YWidget * parent, long modeFlags )
282 YQUI::ui()->setAutoActivateDialogs( false );
284 YQPackageSelectorPlugin * plugin = YQUI::ui()->packageSelectorPlugin();
287 return plugin->createPackageSelector( parent, modeFlags );
294 YQWidgetFactory::createPkgSpecial( YWidget * , const string & )
296 YUI_THROW( YUIUnsupportedWidgetException( "YQPkgSpecial" ) ); // NCurses only
306 YQWidgetFactory::createSpacing( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t size )
308 YQSpacing * spacing = new YQSpacing( parent, dim, stretchable, size );
309 YUI_CHECK_NEW( spacing );
316 YQWidgetFactory::createEmpty( YWidget * parent )
318 YQEmpty * empty = new YQEmpty( parent );
319 YUI_CHECK_NEW( empty );
327 YQWidgetFactory::createAlignment( YWidget * parent,
328 YAlignmentType horAlignment,
329 YAlignmentType vertAlignment )
331 YQAlignment * alignment = new YQAlignment( parent, horAlignment, vertAlignment );
332 YUI_CHECK_NEW( alignment );
339 YQWidgetFactory::createSquash( YWidget * parent, bool horSquash, bool vertSquash )
341 YQSquash * squash = new YQSquash( parent, horSquash, vertSquash );
342 YUI_CHECK_NEW( squash );
350 YQWidgetFactory::createFrame( YWidget * parent, const string & label )
352 YQFrame * frame = new YQFrame( parent, label );
353 YUI_CHECK_NEW( frame );
361 YQWidgetFactory::createCheckBoxFrame( YWidget * parent, const string & label, bool checked )
363 YQCheckBoxFrame * checkBoxFrame = new YQCheckBoxFrame( parent, label, checked );
364 YUI_CHECK_NEW( checkBoxFrame );
366 return checkBoxFrame;
372 YQWidgetFactory::createRadioButtonGroup( YWidget * parent )
374 YQRadioButtonGroup * radioButtonGroup = new YQRadioButtonGroup( parent );
375 YUI_CHECK_NEW( radioButtonGroup );
377 return radioButtonGroup;
383 YQWidgetFactory::createReplacePoint( YWidget * parent )
385 YQReplacePoint * replacePoint = new YQReplacePoint( parent );
386 YUI_CHECK_NEW( replacePoint );