libyui-qt  2.43.5
 All Classes Functions Variables
YQWidgetFactory.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YQWidgetFactory.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #include <QColorGroup>
26 #define YUILogComponent "qt-ui"
27 #include <yui/YUILog.h>
28 
29 #include "YQWidgetFactory.h"
30 #include "YQApplication.h"
31 #include <yui/YUIException.h>
32 #include "YQPackageSelectorPluginStub.h"
33 #include "YQMainWinDock.h"
34 
35 #include <string>
36 
37 using std::string;
38 
39 
41  : YWidgetFactory()
42 {
43  // NOP
44 }
45 
46 
48 {
49  // NOP
50 }
51 
52 
53 
54 
55 //
56 // Dialogs
57 //
58 
59 YQDialog *
60 YQWidgetFactory::createDialog( YDialogType dialogType, YDialogColorMode colorMode )
61 {
62  YQDialog * dialog = new YQDialog( dialogType, colorMode );
63  YUI_CHECK_NEW( dialog );
64 
65  return dialog;
66 }
67 
68 
69 
70 //
71 // Layout Boxes
72 //
73 
75 YQWidgetFactory::createLayoutBox( YWidget * parent, YUIDimension dim )
76 {
77  YQLayoutBox * layoutBox = new YQLayoutBox( parent, dim );
78  YUI_CHECK_NEW( layoutBox );
79 
80  return layoutBox;
81 }
82 
83 
85 YQWidgetFactory::createButtonBox( YWidget * parent )
86 {
87  YQButtonBox * buttonBox = new YQButtonBox( parent );
88  YUI_CHECK_NEW( buttonBox );
89 
90  return buttonBox;
91 }
92 
93 
94 
95 //
96 // Common Leaf Widgets
97 //
98 
100 YQWidgetFactory::createPushButton( YWidget * parent, const std::string & label )
101 {
102  YQPushButton * pushButton = new YQPushButton( parent, label );
103  YUI_CHECK_NEW( pushButton );
104 
105  return pushButton;
106 }
107 
108 
109 
110 YQLabel *
111 YQWidgetFactory::createLabel( YWidget * parent,
112  const std::string & text,
113  bool isHeading,
114  bool isOutputField )
115 {
116  YQLabel * label = new YQLabel( parent, text, isHeading, isOutputField );
117  YUI_CHECK_NEW( label );
118 
119  return label;
120 }
121 
122 
123 
124 YQInputField *
125 YQWidgetFactory::createInputField( YWidget * parent, const std::string & label, bool passwordMode )
126 {
127  YQInputField * inputField = new YQInputField( parent, label, passwordMode );
128  YUI_CHECK_NEW( inputField );
129 
130  return inputField;
131 }
132 
133 
134 
135 YQCheckBox *
136 YQWidgetFactory::createCheckBox( YWidget * parent, const std::string & label, bool isChecked )
137 {
138  YQCheckBox * checkBox = new YQCheckBox( parent, label, isChecked );
139  YUI_CHECK_NEW( checkBox );
140 
141  return checkBox;
142 }
143 
144 
145 
147 YQWidgetFactory::createRadioButton( YWidget * parent, const std::string & label, bool isChecked )
148 {
149  YQRadioButton * radioButton = new YQRadioButton( parent, label, isChecked );
150  YUI_CHECK_NEW( radioButton );
151 
152  // Register radio button with its button group.
153  // This has to be done after all constructors are done so virtual functions
154  // can be used.
155 
156  if ( radioButton->buttonGroup() )
157  radioButton->buttonGroup()->addRadioButton( radioButton );
158 
159  return radioButton;
160 }
161 
162 
163 
164 YQComboBox *
165 YQWidgetFactory::createComboBox( YWidget * parent, const std::string & label, bool editable )
166 {
167  YQComboBox * comboBox = new YQComboBox( parent, label, editable );
168  YUI_CHECK_NEW( comboBox );
169 
170  return comboBox;
171 }
172 
173 
174 
176 YQWidgetFactory::createSelectionBox( YWidget * parent, const std::string & label )
177 {
178  YQSelectionBox * selectionBox = new YQSelectionBox( parent, label );
179  YUI_CHECK_NEW( selectionBox );
180 
181  return selectionBox;
182 }
183 
184 
185 
186 YQTree *
187 YQWidgetFactory::createTree( YWidget * parent, const std::string & label, bool multiselection, bool recursiveselection )
188 {
189  YQTree * tree = new YQTree( parent, label, multiselection, recursiveselection );
190  YUI_CHECK_NEW( tree );
191 
192  return tree;
193 }
194 
195 
196 
197 YQTable *
198 YQWidgetFactory::createTable( YWidget * parent, YTableHeader * header, bool multiSelection )
199 {
200  YQTable * table = new YQTable( parent, header, multiSelection );
201  YUI_CHECK_NEW( table );
202 
203  return table;
204 }
205 
206 
207 
209 YQWidgetFactory::createProgressBar( YWidget * parent, const std::string & label, int maxValue )
210 {
211  YQProgressBar * progressBar = new YQProgressBar( parent, label, maxValue );
212  YUI_CHECK_NEW( progressBar );
213 
214  return progressBar;
215 }
216 
217 
218 
219 YQRichText *
220 YQWidgetFactory::createRichText( YWidget * parent, const std::string & text, bool plainTextMode )
221 {
222  YQRichText * richText = new YQRichText( parent, text, plainTextMode );
223  YUI_CHECK_NEW( richText );
224 
225  return richText;
226 }
227 
228 
230 YQWidgetFactory::createBusyIndicator( YWidget * parent, const std::string & label, int maxValue )
231 {
232  YQBusyIndicator * busyIndicator = new YQBusyIndicator( parent, label, maxValue );
233  YUI_CHECK_NEW( busyIndicator );
234 
235  return busyIndicator;
236 }
237 
238 
239 
240 
241 //
242 // Less Common Leaf Widgets
243 //
244 
245 YQIntField *
246 YQWidgetFactory::createIntField( YWidget * parent, const std::string & label, int minVal, int maxVal, int initialVal )
247 {
248  YQIntField * intField = new YQIntField( parent, label, minVal, maxVal, initialVal );
249  YUI_CHECK_NEW( intField );
250 
251  return intField;
252 }
253 
254 
255 
256 YQMenuButton *
257 YQWidgetFactory::createMenuButton( YWidget * parent, const std::string & label )
258 {
259  YQMenuButton * menuButton = new YQMenuButton( parent, label );
260  YUI_CHECK_NEW( menuButton );
261 
262  return menuButton;
263 }
264 
265 
266 
268 YQWidgetFactory::createMultiLineEdit( YWidget * parent, const std::string & label )
269 {
270  YQMultiLineEdit * multiLineEdit = new YQMultiLineEdit( parent, label );
271  YUI_CHECK_NEW( multiLineEdit );
272 
273  return multiLineEdit;
274 }
275 
276 
277 
278 YQImage *
279 YQWidgetFactory::createImage( YWidget * parent, const std::string & imageFileName, bool animated )
280 {
281  YQImage * image = new YQImage( parent, imageFileName, animated );
282  YUI_CHECK_NEW( image );
283 
284  return image;
285 }
286 
287 
288 YQLogView *
289 YQWidgetFactory::createLogView( YWidget * parent, const std::string & label, int visibleLines, int storedLines )
290 {
291  YQLogView * logView = new YQLogView( parent, label, visibleLines, storedLines );
292  YUI_CHECK_NEW( logView );
293 
294  return logView;
295 }
296 
297 
298 
300 YQWidgetFactory::createMultiSelectionBox( YWidget * parent, const std::string & label )
301 {
302  YQMultiSelectionBox * multiSelectionBox = new YQMultiSelectionBox( parent, label );
303  YUI_CHECK_NEW( multiSelectionBox );
304 
305  return multiSelectionBox;
306 }
307 
308 YPackageSelector*
309 YQWidgetFactory::createPackageSelector(YWidget* parent, long modeFlags)
310 {
312  YUI_CHECK_PTR( plugin );
313 
314 
315  YPackageSelector * pkgSel = plugin->createPackageSelector( parent, modeFlags );
316  YUI_CHECK_NEW( pkgSel );
317 
318  return pkgSel;
319 }
320 
321 YWidget *
322 YQWidgetFactory::createPkgSpecial( YWidget * , const std::string & )
323 {
324  YUI_THROW( YUIUnsupportedWidgetException( "YQPkgSpecial" ) ); // NCurses only
325  return 0;
326 }
327 
328 
329 //
330 // Layout Helpers
331 //
332 
333 YQSpacing *
334 YQWidgetFactory::createSpacing( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t size )
335 {
336  YQSpacing * spacing = new YQSpacing( parent, dim, stretchable, size );
337  YUI_CHECK_NEW( spacing );
338 
339  return spacing;
340 }
341 
342 
343 YQEmpty *
344 YQWidgetFactory::createEmpty( YWidget * parent )
345 {
346  YQEmpty * empty = new YQEmpty( parent );
347  YUI_CHECK_NEW( empty );
348 
349  return empty;
350 }
351 
352 
353 
354 YQAlignment *
355 YQWidgetFactory::createAlignment( YWidget * parent,
356  YAlignmentType horAlignment,
357  YAlignmentType vertAlignment )
358 {
359  YQAlignment * alignment = new YQAlignment( parent, horAlignment, vertAlignment );
360  YUI_CHECK_NEW( alignment );
361 
362  return alignment;
363 }
364 
365 
366 YQSquash *
367 YQWidgetFactory::createSquash( YWidget * parent, bool horSquash, bool vertSquash )
368 {
369  YQSquash * squash = new YQSquash( parent, horSquash, vertSquash );
370  YUI_CHECK_NEW( squash );
371 
372  return squash;
373 }
374 
375 
376 
377 YQFrame *
378 YQWidgetFactory::createFrame( YWidget * parent, const std::string & label )
379 {
380  YQFrame * frame = new YQFrame( parent, label );
381  YUI_CHECK_NEW( frame );
382 
383  return frame;
384 }
385 
386 
387 
389 YQWidgetFactory::createCheckBoxFrame( YWidget * parent, const std::string & label, bool checked )
390 {
391  YQCheckBoxFrame * checkBoxFrame = new YQCheckBoxFrame( parent, label, checked );
392  YUI_CHECK_NEW( checkBoxFrame );
393 
394  return checkBoxFrame;
395 }
396 
397 
398 
400 YQWidgetFactory::createRadioButtonGroup( YWidget * parent )
401 {
402  YQRadioButtonGroup * radioButtonGroup = new YQRadioButtonGroup( parent );
403  YUI_CHECK_NEW( radioButtonGroup );
404 
405  return radioButtonGroup;
406 }
407 
408 
409 
411 YQWidgetFactory::createReplacePoint( YWidget * parent )
412 {
413  YQReplacePoint * replacePoint = new YQReplacePoint( parent );
414  YUI_CHECK_NEW( replacePoint );
415 
416  return replacePoint;
417 }
418 
419 
420