1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQWidgetFactory.cc
15 Author: Stefan Hundhammer <sh@suse.de>
20 #include "YQWidgetFactory.h"
22 #include "YUIException.h"
23 #include "YQPackageSelectorPlugin.h"
31 YQWidgetFactory::YQWidgetFactory()
37 YQWidgetFactory::~YQWidgetFactory()
50 YQWidgetFactory::createMainDialog()
52 return 0; // FIXME: TO DO
58 YQWidgetFactory::createPopupDialog()
60 return 0; // FIXME: TO DO
71 YQWidgetFactory::createLayoutBox( YWidget * parent, YUIDimension dim )
73 YQLayoutBox * layoutBox = new YQLayoutBox( parent, dim );
74 YUI_CHECK_NEW( layoutBox );
82 // Common Leaf Widgets
86 YQWidgetFactory::createPushButton( YWidget * parent, const string & label )
88 YQPushButton * pushButton = new YQPushButton( parent, label );
89 YUI_CHECK_NEW( pushButton );
97 YQWidgetFactory::createLabel( YWidget * parent,
102 YQLabel * label = new YQLabel( parent, text, isHeading, isOutputField );
103 YUI_CHECK_NEW( label );
111 YQWidgetFactory::createInputField( YWidget * parent, const string & label, bool passwordMode )
113 YQInputField * inputField = new YQInputField( parent, label, passwordMode );
114 YUI_CHECK_NEW( inputField );
122 YQWidgetFactory::createCheckBox( YWidget * parent, const string & label, bool isChecked )
124 YQCheckBox * checkBox = new YQCheckBox( parent, label, isChecked );
125 YUI_CHECK_NEW( checkBox );
133 YQWidgetFactory::createRadioButton( YWidget * parent, const string & label, bool isChecked )
135 YQRadioButton * radioButton = new YQRadioButton( parent, label, isChecked );
136 YUI_CHECK_NEW( radioButton );
138 // Register radio button with its button group.
139 // This has to be done after all constructors are done so virtual functions
142 if ( radioButton->buttonGroup() )
143 radioButton->buttonGroup()->addRadioButton( radioButton );
151 YQWidgetFactory::createComboBox( YWidget * parent, const string & label, bool editable )
153 YQComboBox * comboBox = new YQComboBox( parent, label, editable );
154 YUI_CHECK_NEW( comboBox );
162 YQWidgetFactory::createSelectionBox( YWidget * parent, const string & label )
164 YQSelectionBox * selectionBox = new YQSelectionBox( parent, label );
165 YUI_CHECK_NEW( selectionBox );
173 YQWidgetFactory::createTree( YWidget * parent, const string & label )
175 YQTree * tree = new YQTree( parent, label );
176 YUI_CHECK_NEW( tree );
184 YQWidgetFactory::createTable( YWidget * parent, YTableHeader * header )
186 YQTable * table = new YQTable( parent, header );
187 YUI_CHECK_NEW( table );
195 YQWidgetFactory::createProgressBar( YWidget * parent, const string & label, int maxValue )
197 YQProgressBar * progressBar = new YQProgressBar( parent, label, maxValue );
198 YUI_CHECK_NEW( progressBar );
206 YQWidgetFactory::createRichText( YWidget * parent, const string & text, bool plainTextMode )
208 YQRichText * richText = new YQRichText( parent, text, plainTextMode );
209 YUI_CHECK_NEW( richText );
218 // Less Common Leaf Widgets
222 YQWidgetFactory::createIntField( YWidget * parent, const string & label, int minVal, int maxVal, int initialVal )
224 YQIntField * intField = new YQIntField( parent, label, minVal, maxVal, initialVal );
225 YUI_CHECK_NEW( intField );
233 YQWidgetFactory::createMenuButton( YWidget * parent, const string & label )
235 YQMenuButton * menuButton = new YQMenuButton( parent, label );
236 YUI_CHECK_NEW( menuButton );
244 YQWidgetFactory::createMultiLineEdit( YWidget * parent, const string & label )
246 YQMultiLineEdit * multiLineEdit = new YQMultiLineEdit( parent, label );
247 YUI_CHECK_NEW( multiLineEdit );
249 return multiLineEdit;
255 YQWidgetFactory::createImage( YWidget * parent, const string & imageFileName, bool animated )
257 YQImage * image = new YQImage( parent, imageFileName, animated );
258 YUI_CHECK_NEW( image );
265 YQWidgetFactory::createLogView( YWidget * parent, const string & label, int visibleLines, int storedLines )
267 YQLogView * logView = new YQLogView( parent, label, visibleLines, storedLines );
268 YUI_CHECK_NEW( logView );
275 YQMultiSelectionBox *
276 YQWidgetFactory::createMultiSelectionBox( YWidget * parent, const string & label )
278 YQMultiSelectionBox * multiSelectionBox = new YQMultiSelectionBox( parent, label );
279 YUI_CHECK_NEW( multiSelectionBox );
281 return multiSelectionBox;
287 YQWidgetFactory::createPackageSelector( YWidget * parent, long modeFlags )
289 YQUI::ui()->setAutoActivateDialogs( false );
291 YQPackageSelectorPlugin * plugin = YQUI::ui()->packageSelectorPlugin();
294 return plugin->createPackageSelector( parent, modeFlags );
301 YQWidgetFactory::createPkgSpecial( YWidget * , const string & )
303 YUI_THROW( YUIUnsupportedWidgetException( "YQPkgSpecial" ) ); // NCurses only
313 YQWidgetFactory::createSpacing( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t size )
315 YQSpacing * spacing = new YQSpacing( parent, dim, stretchable, size );
316 YUI_CHECK_NEW( spacing );
323 YQWidgetFactory::createEmpty( YWidget * parent )
325 YQEmpty * empty = new YQEmpty( parent );
326 YUI_CHECK_NEW( empty );
334 YQWidgetFactory::createAlignment( YWidget * parent,
335 YAlignmentType horAlignment,
336 YAlignmentType vertAlignment )
338 YQAlignment * alignment = new YQAlignment( parent, horAlignment, vertAlignment );
339 YUI_CHECK_NEW( alignment );
346 YQWidgetFactory::createSquash( YWidget * parent, bool horSquash, bool vertSquash )
348 YQSquash * squash = new YQSquash( parent, horSquash, vertSquash );
349 YUI_CHECK_NEW( squash );
357 YQWidgetFactory::createFrame( YWidget * parent, const string & label )
359 YQFrame * frame = new YQFrame( parent, label );
360 YUI_CHECK_NEW( frame );
368 YQWidgetFactory::createCheckBoxFrame( YWidget * parent, const string & label, bool checked )
370 YQCheckBoxFrame * checkBoxFrame = new YQCheckBoxFrame( parent, label, checked );
371 YUI_CHECK_NEW( checkBoxFrame );
373 return checkBoxFrame;
379 YQWidgetFactory::createRadioButtonGroup( YWidget * parent )
381 YQRadioButtonGroup * radioButtonGroup = new YQRadioButtonGroup( parent );
382 YUI_CHECK_NEW( radioButtonGroup );
384 return radioButtonGroup;
390 YQWidgetFactory::createReplacePoint( YWidget * parent )
392 YQReplacePoint * replacePoint = new YQReplacePoint( parent );
393 YUI_CHECK_NEW( replacePoint );