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