]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQWidgetFactory.cc
picking up branches/tmp/sh/qt4-port/, merging it with trunk
[duncan/yast2-qt4.git] / src / YQWidgetFactory.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:         YQWidgetFactory.cc
14
15   Author:       Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #include "YQWidgetFactory.h"
21 #include "YQUI.h"
22 #include "YUIException.h"
23 #include "YQPackageSelectorPlugin.h"
24
25 #include <string>
26
27
28 using std::string;
29
30
31 YQWidgetFactory::YQWidgetFactory()
32     : YWidgetFactory()
33 {
34     // NOP
35 }
36
37 YQWidgetFactory::~YQWidgetFactory()
38 {
39     // NOP
40 }
41
42
43
44
45 //
46 // Dialogs
47 //
48
49 YQDialog *
50 YQWidgetFactory::createMainDialog()
51 {
52     return 0; // FIXME: TO DO
53 }
54
55
56
57 YQDialog *
58 YQWidgetFactory::createPopupDialog()
59 {
60     return 0; // FIXME: TO DO
61 }
62
63
64
65
66 //
67 // Layout Boxes
68 //
69
70 YQLayoutBox *
71 YQWidgetFactory::createLayoutBox( YWidget * parent, YUIDimension dim )
72 {
73     YQLayoutBox * layoutBox = new YQLayoutBox( parent, dim );
74     YUI_CHECK_NEW( layoutBox );
75
76     return layoutBox;
77 }
78
79
80
81 //
82 // Common Leaf Widgets
83 //
84
85 YQPushButton *
86 YQWidgetFactory::createPushButton( YWidget * parent, const string & label )
87 {
88     YQPushButton * pushButton = new YQPushButton( parent, label );
89     YUI_CHECK_NEW( pushButton );
90
91     return pushButton;
92 }
93
94
95
96 YQLabel *
97 YQWidgetFactory::createLabel( YWidget *         parent,
98                               const string &    text,
99                               bool              isHeading,
100                               bool              isOutputField )
101 {
102     YQLabel * label = new YQLabel( parent, text, isHeading, isOutputField );
103     YUI_CHECK_NEW( label );
104
105     return label;
106 }
107
108
109
110 YQInputField *
111 YQWidgetFactory::createInputField( YWidget * parent, const string & label, bool passwordMode )
112 {
113     YQInputField * inputField = new YQInputField( parent, label, passwordMode );
114     YUI_CHECK_NEW( inputField );
115
116     return inputField;
117 }
118
119
120
121 YQCheckBox *
122 YQWidgetFactory::createCheckBox( YWidget * parent, const string & label, bool isChecked )
123 {
124     YQCheckBox * checkBox = new YQCheckBox( parent, label, isChecked );
125     YUI_CHECK_NEW( checkBox );
126
127     return checkBox;
128 }
129
130
131
132 YQRadioButton *
133 YQWidgetFactory::createRadioButton( YWidget * parent, const string & label, bool isChecked )
134 {
135     YQRadioButton * radioButton = new YQRadioButton( parent, label, isChecked );
136     YUI_CHECK_NEW( radioButton );
137
138     // Register radio button with its button group.
139     // This has to be done after all constructors are done so virtual functions
140     // can be used.
141
142     if ( radioButton->buttonGroup() )
143         radioButton->buttonGroup()->addRadioButton( radioButton );
144
145     return radioButton;
146 }
147
148
149
150 YQComboBox *
151 YQWidgetFactory::createComboBox( YWidget * parent, const string & label, bool editable  )
152 {
153     YQComboBox * comboBox = new YQComboBox( parent, label, editable );
154     YUI_CHECK_NEW( comboBox );
155
156     return comboBox;
157 }
158
159
160
161 YQSelectionBox *
162 YQWidgetFactory::createSelectionBox( YWidget * parent, const string & label )
163 {
164     YQSelectionBox * selectionBox = new YQSelectionBox( parent, label );
165     YUI_CHECK_NEW( selectionBox );
166
167     return selectionBox;
168 }
169
170
171
172 YQTree *
173 YQWidgetFactory::createTree( YWidget * parent, const string & label )
174 {
175     YQTree * tree = new YQTree( parent, label );
176     YUI_CHECK_NEW( tree );
177
178     return tree;
179 }
180
181
182
183 YQTable *
184 YQWidgetFactory::createTable( YWidget * parent, YTableHeader * header )
185 {
186     YQTable * table = new YQTable( parent, header );
187     YUI_CHECK_NEW( table );
188
189     return table;
190 }
191
192
193
194 YQProgressBar *
195 YQWidgetFactory::createProgressBar( YWidget * parent, const string & label, int maxValue )
196 {
197     YQProgressBar * progressBar = new YQProgressBar( parent, label, maxValue );
198     YUI_CHECK_NEW( progressBar );
199
200     return progressBar;
201 }
202
203
204
205 YQRichText *
206 YQWidgetFactory::createRichText( YWidget * parent, const string & text, bool plainTextMode )
207 {
208     YQRichText * richText = new YQRichText( parent, text, plainTextMode );
209     YUI_CHECK_NEW( richText );
210
211     return richText;
212 }
213
214
215
216
217 //
218 // Less Common Leaf Widgets
219 //
220
221 YQIntField *
222 YQWidgetFactory::createIntField( YWidget * parent, const string & label, int minVal, int maxVal, int initialVal )
223 {
224     YQIntField * intField = new YQIntField( parent, label, minVal, maxVal, initialVal );
225     YUI_CHECK_NEW( intField );
226     
227     return intField;
228 }
229
230
231
232 YQMenuButton *
233 YQWidgetFactory::createMenuButton( YWidget * parent, const string & label )
234 {
235     YQMenuButton * menuButton = new YQMenuButton( parent, label );
236     YUI_CHECK_NEW( menuButton );
237
238     return menuButton;
239 }
240
241
242
243 YQMultiLineEdit *
244 YQWidgetFactory::createMultiLineEdit( YWidget * parent, const string & label )
245 {
246     YQMultiLineEdit * multiLineEdit = new YQMultiLineEdit( parent, label );
247     YUI_CHECK_NEW( multiLineEdit );
248
249     return multiLineEdit;
250 }
251
252
253
254 YQImage *
255 YQWidgetFactory::createImage( YWidget * parent, const string & imageFileName, bool animated )
256 {
257     YQImage * image = new YQImage( parent, imageFileName, animated );
258     YUI_CHECK_NEW( image );
259
260     return image;
261 }
262
263
264 YQLogView *
265 YQWidgetFactory::createLogView( YWidget * parent, const string & label, int visibleLines, int storedLines )
266 {
267     YQLogView * logView = new YQLogView( parent, label, visibleLines, storedLines );
268     YUI_CHECK_NEW( logView );
269
270     return logView;
271 }
272
273
274
275 YQMultiSelectionBox *
276 YQWidgetFactory::createMultiSelectionBox( YWidget * parent, const string & label )
277 {
278     YQMultiSelectionBox * multiSelectionBox = new YQMultiSelectionBox( parent, label );
279     YUI_CHECK_NEW( multiSelectionBox );
280
281     return multiSelectionBox;
282 }
283
284
285
286 YQPackageSelector *
287 YQWidgetFactory::createPackageSelector( YWidget * parent, long modeFlags )
288 {
289     YQUI::ui()->setAutoActivateDialogs( false );
290
291     YQPackageSelectorPlugin * plugin = YQUI::ui()->packageSelectorPlugin();
292
293     if ( plugin )
294         return plugin->createPackageSelector( parent, modeFlags );
295     else
296         return 0;
297 }
298
299
300 YWidget *
301 YQWidgetFactory::createPkgSpecial( YWidget * , const string & )
302 {
303     YUI_THROW( YUIUnsupportedWidgetException( "YQPkgSpecial" ) ); // NCurses only
304     return 0;
305 }
306
307
308 //
309 // Layout Helpers
310 //
311
312 YQSpacing *
313 YQWidgetFactory::createSpacing( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t size )
314 {
315     YQSpacing * spacing = new YQSpacing( parent, dim, stretchable, size );
316     YUI_CHECK_NEW( spacing );
317
318     return spacing;
319 }
320
321
322 YQEmpty *
323 YQWidgetFactory::createEmpty( YWidget * parent )
324 {
325     YQEmpty * empty = new YQEmpty( parent );
326     YUI_CHECK_NEW( empty );
327
328     return empty;
329 }
330
331
332
333 YQAlignment *
334 YQWidgetFactory::createAlignment( YWidget *      parent,
335                                   YAlignmentType horAlignment,
336                                   YAlignmentType vertAlignment )
337 {
338     YQAlignment * alignment = new YQAlignment( parent, horAlignment, vertAlignment );
339     YUI_CHECK_NEW( alignment );
340
341     return alignment;
342 }
343
344
345 YQSquash *
346 YQWidgetFactory::createSquash( YWidget * parent, bool horSquash, bool vertSquash )
347 {
348     YQSquash * squash = new YQSquash( parent, horSquash, vertSquash );
349     YUI_CHECK_NEW( squash );
350
351     return squash;
352 }
353
354
355
356 YQFrame *
357 YQWidgetFactory::createFrame( YWidget * parent, const string & label )
358 {
359     YQFrame * frame = new YQFrame( parent, label );
360     YUI_CHECK_NEW( frame );
361
362     return frame;
363 }
364
365
366
367 YQCheckBoxFrame *
368 YQWidgetFactory::createCheckBoxFrame( YWidget * parent, const string & label, bool checked )
369 {
370     YQCheckBoxFrame * checkBoxFrame = new YQCheckBoxFrame( parent, label, checked );
371     YUI_CHECK_NEW( checkBoxFrame );
372
373     return checkBoxFrame;
374 }
375
376
377
378 YQRadioButtonGroup *
379 YQWidgetFactory::createRadioButtonGroup( YWidget * parent )
380 {
381     YQRadioButtonGroup * radioButtonGroup = new YQRadioButtonGroup( parent );
382     YUI_CHECK_NEW( radioButtonGroup );
383
384     return radioButtonGroup;
385 }
386
387
388
389 YQReplacePoint *
390 YQWidgetFactory::createReplacePoint( YWidget * parent )
391 {
392     YQReplacePoint * replacePoint = new YQReplacePoint( parent );
393     YUI_CHECK_NEW( replacePoint );
394
395     return replacePoint;
396 }
397
398
399