1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQWidgetFactory.cc
15 Author: Stefan Hundhammer <sh@suse.de>
20 #include <QColorGroup>
21 #include "YQWidgetFactory.h"
23 #include "YUIException.h"
24 #include "YQPackageSelectorPlugin.h"
32 YQWidgetFactory::YQWidgetFactory()
38 YQWidgetFactory::~YQWidgetFactory()
51 YQWidgetFactory::createMainDialog()
53 return 0; // FIXME: TO DO
59 YQWidgetFactory::createPopupDialog()
61 return 0; // FIXME: TO DO
72 YQWidgetFactory::createLayoutBox( YWidget * parent, YUIDimension dim )
74 YQLayoutBox * layoutBox = new YQLayoutBox( parent, dim );
75 YUI_CHECK_NEW( layoutBox );
83 // Common Leaf Widgets
87 YQWidgetFactory::createPushButton( YWidget * parent, const string & label )
89 YQPushButton * pushButton = new YQPushButton( parent, label );
90 YUI_CHECK_NEW( pushButton );
98 YQWidgetFactory::createLabel( YWidget * parent,
103 YQLabel * label = new YQLabel( parent, text, isHeading, isOutputField );
104 YUI_CHECK_NEW( label );
112 YQWidgetFactory::createInputField( YWidget * parent, const string & label, bool passwordMode )
114 YQInputField * inputField = new YQInputField( parent, label, passwordMode );
115 YUI_CHECK_NEW( inputField );
123 YQWidgetFactory::createCheckBox( YWidget * parent, const string & label, bool isChecked )
125 YQCheckBox * checkBox = new YQCheckBox( parent, label, isChecked );
126 YUI_CHECK_NEW( checkBox );
134 YQWidgetFactory::createRadioButton( YWidget * parent, const string & label, bool isChecked )
136 YQRadioButton * radioButton = new YQRadioButton( parent, label, isChecked );
137 YUI_CHECK_NEW( radioButton );
139 // Register radio button with its button group.
140 // This has to be done after all constructors are done so virtual functions
143 if ( radioButton->buttonGroup() )
144 radioButton->buttonGroup()->addRadioButton( radioButton );
152 YQWidgetFactory::createComboBox( YWidget * parent, const string & label, bool editable )
154 YQComboBox * comboBox = new YQComboBox( parent, label, editable );
155 YUI_CHECK_NEW( comboBox );
163 YQWidgetFactory::createSelectionBox( YWidget * parent, const string & label )
165 YQSelectionBox * selectionBox = new YQSelectionBox( parent, label );
166 YUI_CHECK_NEW( selectionBox );
174 YQWidgetFactory::createTree( YWidget * parent, const string & label )
176 YQTree * tree = new YQTree( parent, label );
177 YUI_CHECK_NEW( tree );
185 YQWidgetFactory::createTable( YWidget * parent, YTableHeader * header )
187 YQTable * table = new YQTable( parent, header );
188 YUI_CHECK_NEW( table );
196 YQWidgetFactory::createProgressBar( YWidget * parent, const string & label, int maxValue )
198 YQProgressBar * progressBar = new YQProgressBar( parent, label, maxValue );
199 YUI_CHECK_NEW( progressBar );
207 YQWidgetFactory::createRichText( YWidget * parent, const string & text, bool plainTextMode )
209 YQRichText * richText = new YQRichText( parent, text, plainTextMode );
210 YUI_CHECK_NEW( richText );
219 // Less Common Leaf Widgets
223 YQWidgetFactory::createIntField( YWidget * parent, const string & label, int minVal, int maxVal, int initialVal )
225 YQIntField * intField = new YQIntField( parent, label, minVal, maxVal, initialVal );
226 YUI_CHECK_NEW( intField );
234 YQWidgetFactory::createMenuButton( YWidget * parent, const string & label )
236 YQMenuButton * menuButton = new YQMenuButton( parent, label );
237 YUI_CHECK_NEW( menuButton );
245 YQWidgetFactory::createMultiLineEdit( YWidget * parent, const string & label )
247 YQMultiLineEdit * multiLineEdit = new YQMultiLineEdit( parent, label );
248 YUI_CHECK_NEW( multiLineEdit );
250 return multiLineEdit;
256 YQWidgetFactory::createImage( YWidget * parent, const string & imageFileName, bool animated )
258 YQImage * image = new YQImage( parent, imageFileName, animated );
259 YUI_CHECK_NEW( image );
266 YQWidgetFactory::createLogView( YWidget * parent, const string & label, int visibleLines, int storedLines )
268 YQLogView * logView = new YQLogView( parent, label, visibleLines, storedLines );
269 YUI_CHECK_NEW( logView );
276 YQMultiSelectionBox *
277 YQWidgetFactory::createMultiSelectionBox( YWidget * parent, const string & label )
279 YQMultiSelectionBox * multiSelectionBox = new YQMultiSelectionBox( parent, label );
280 YUI_CHECK_NEW( multiSelectionBox );
282 return multiSelectionBox;
288 YQWidgetFactory::createPackageSelector( YWidget * parent, long modeFlags )
290 YQUI::ui()->setAutoActivateDialogs( false );
292 YQPackageSelectorPlugin * plugin = YQUI::ui()->packageSelectorPlugin();
295 return plugin->createPackageSelector( parent, modeFlags );
302 YQWidgetFactory::createPkgSpecial( YWidget * , const string & )
304 YUI_THROW( YUIUnsupportedWidgetException( "YQPkgSpecial" ) ); // NCurses only
314 YQWidgetFactory::createSpacing( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t size )
316 YQSpacing * spacing = new YQSpacing( parent, dim, stretchable, size );
317 YUI_CHECK_NEW( spacing );
324 YQWidgetFactory::createEmpty( YWidget * parent )
326 YQEmpty * empty = new YQEmpty( parent );
327 YUI_CHECK_NEW( empty );
335 YQWidgetFactory::createAlignment( YWidget * parent,
336 YAlignmentType horAlignment,
337 YAlignmentType vertAlignment )
339 YQAlignment * alignment = new YQAlignment( parent, horAlignment, vertAlignment );
340 YUI_CHECK_NEW( alignment );
347 YQWidgetFactory::createSquash( YWidget * parent, bool horSquash, bool vertSquash )
349 YQSquash * squash = new YQSquash( parent, horSquash, vertSquash );
350 YUI_CHECK_NEW( squash );
358 YQWidgetFactory::createFrame( YWidget * parent, const string & label )
360 YQFrame * frame = new YQFrame( parent, label );
361 YUI_CHECK_NEW( frame );
369 YQWidgetFactory::createCheckBoxFrame( YWidget * parent, const string & label, bool checked )
371 YQCheckBoxFrame * checkBoxFrame = new YQCheckBoxFrame( parent, label, checked );
372 YUI_CHECK_NEW( checkBoxFrame );
374 return checkBoxFrame;
380 YQWidgetFactory::createRadioButtonGroup( YWidget * parent )
382 YQRadioButtonGroup * radioButtonGroup = new YQRadioButtonGroup( parent );
383 YUI_CHECK_NEW( radioButtonGroup );
385 return radioButtonGroup;
391 YQWidgetFactory::createReplacePoint( YWidget * parent )
393 YQReplacePoint * replacePoint = new YQReplacePoint( parent );
394 YUI_CHECK_NEW( replacePoint );