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