libyui-qt  2.46.13
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 std::string & label )
100 {
101  YQPushButton * pushButton = new YQPushButton( parent, label );
102  YUI_CHECK_NEW( pushButton );
103 
104  return pushButton;
105 }
106 
107 
108 
109 YQLabel *
110 YQWidgetFactory::createLabel( YWidget * parent,
111  const std::string & text,
112  bool isHeading,
113  bool isOutputField )
114 {
115  YQLabel * label = new YQLabel( parent, text, isHeading, isOutputField );
116  YUI_CHECK_NEW( label );
117 
118  return label;
119 }
120 
121 
122 
123 YQInputField *
124 YQWidgetFactory::createInputField( YWidget * parent, const std::string & label, bool passwordMode )
125 {
126  YQInputField * inputField = new YQInputField( parent, label, passwordMode );
127  YUI_CHECK_NEW( inputField );
128 
129  return inputField;
130 }
131 
132 
133 
134 YQCheckBox *
135 YQWidgetFactory::createCheckBox( YWidget * parent, const std::string & label, bool isChecked )
136 {
137  YQCheckBox * checkBox = new YQCheckBox( parent, label, isChecked );
138  YUI_CHECK_NEW( checkBox );
139 
140  return checkBox;
141 }
142 
143 
144 
146 YQWidgetFactory::createRadioButton( YWidget * parent, const std::string & label, bool isChecked )
147 {
148  YQRadioButton * radioButton = new YQRadioButton( parent, label, isChecked );
149  YUI_CHECK_NEW( radioButton );
150 
151  // Register radio button with its button group.
152  // This has to be done after all constructors are done so virtual functions
153  // can be used.
154 
155  if ( radioButton->buttonGroup() )
156  radioButton->buttonGroup()->addRadioButton( radioButton );
157 
158  return radioButton;
159 }
160 
161 
162 
163 YQComboBox *
164 YQWidgetFactory::createComboBox( YWidget * parent, const std::string & label, bool editable )
165 {
166  YQComboBox * comboBox = new YQComboBox( parent, label, editable );
167  YUI_CHECK_NEW( comboBox );
168 
169  return comboBox;
170 }
171 
172 
173 
175 YQWidgetFactory::createSelectionBox( YWidget * parent, const std::string & label )
176 {
177  YQSelectionBox * selectionBox = new YQSelectionBox( parent, label );
178  YUI_CHECK_NEW( selectionBox );
179 
180  return selectionBox;
181 }
182 
183 
184 
185 YQTree *
186 YQWidgetFactory::createTree( YWidget * parent, const std::string & label, bool multiselection, bool recursiveselection )
187 {
188  YQTree * tree = new YQTree( parent, label, multiselection, recursiveselection );
189  YUI_CHECK_NEW( tree );
190 
191  return tree;
192 }
193 
194 
195 
196 YQTable *
197 YQWidgetFactory::createTable( YWidget * parent, YTableHeader * header, bool multiSelection )
198 {
199  YQTable * table = new YQTable( parent, header, multiSelection );
200  YUI_CHECK_NEW( table );
201 
202  return table;
203 }
204 
205 
206 
208 YQWidgetFactory::createProgressBar( YWidget * parent, const std::string & label, int maxValue )
209 {
210  YQProgressBar * progressBar = new YQProgressBar( parent, label, maxValue );
211  YUI_CHECK_NEW( progressBar );
212 
213  return progressBar;
214 }
215 
216 
217 
218 YQRichText *
219 YQWidgetFactory::createRichText( YWidget * parent, const std::string & text, bool plainTextMode )
220 {
221  YQRichText * richText = new YQRichText( parent, text, plainTextMode );
222  YUI_CHECK_NEW( richText );
223 
224  return richText;
225 }
226 
227 
229 YQWidgetFactory::createBusyIndicator( YWidget * parent, const std::string & label, int maxValue )
230 {
231  YQBusyIndicator * busyIndicator = new YQBusyIndicator( parent, label, maxValue );
232  YUI_CHECK_NEW( busyIndicator );
233 
234  return busyIndicator;
235 }
236 
237 
238 
239 
240 //
241 // Less Common Leaf Widgets
242 //
243 
244 YQIntField *
245 YQWidgetFactory::createIntField( YWidget * parent, const std::string & label, int minVal, int maxVal, int initialVal )
246 {
247  YQIntField * intField = new YQIntField( parent, label, minVal, maxVal, initialVal );
248  YUI_CHECK_NEW( intField );
249 
250  return intField;
251 }
252 
253 
254 
255 YQMenuButton *
256 YQWidgetFactory::createMenuButton( YWidget * parent, const std::string & label )
257 {
258  YQMenuButton * menuButton = new YQMenuButton( parent, label );
259  YUI_CHECK_NEW( menuButton );
260 
261  return menuButton;
262 }
263 
264 
265 
267 YQWidgetFactory::createMultiLineEdit( YWidget * parent, const std::string & label )
268 {
269  YQMultiLineEdit * multiLineEdit = new YQMultiLineEdit( parent, label );
270  YUI_CHECK_NEW( multiLineEdit );
271 
272  return multiLineEdit;
273 }
274 
275 
276 
277 YQImage *
278 YQWidgetFactory::createImage( YWidget * parent, const std::string & imageFileName, bool animated )
279 {
280  YQImage * image = new YQImage( parent, imageFileName, animated );
281  YUI_CHECK_NEW( image );
282 
283  return image;
284 }
285 
286 
287 YQLogView *
288 YQWidgetFactory::createLogView( YWidget * parent, const std::string & label, int visibleLines, int storedLines )
289 {
290  YQLogView * logView = new YQLogView( parent, label, visibleLines, storedLines );
291  YUI_CHECK_NEW( logView );
292 
293  return logView;
294 }
295 
296 
297 
299 YQWidgetFactory::createMultiSelectionBox( YWidget * parent, const std::string & label )
300 {
301  YQMultiSelectionBox * multiSelectionBox = new YQMultiSelectionBox( parent, label );
302  YUI_CHECK_NEW( multiSelectionBox );
303 
304  return multiSelectionBox;
305 }
306 
307 YPackageSelector*
308 YQWidgetFactory::createPackageSelector(YWidget* parent, long modeFlags)
309 {
311  YUI_CHECK_PTR( plugin );
312 
313 
314  YPackageSelector * pkgSel = plugin->createPackageSelector( parent, modeFlags );
315  YUI_CHECK_NEW( pkgSel );
316 
317  return pkgSel;
318 }
319 
320 YWidget *
321 YQWidgetFactory::createPkgSpecial( YWidget * , const std::string & )
322 {
323  YUI_THROW( YUIUnsupportedWidgetException( "YQPkgSpecial" ) ); // NCurses only
324  return 0;
325 }
326 
327 
328 //
329 // Layout Helpers
330 //
331 
332 YQSpacing *
333 YQWidgetFactory::createSpacing( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t size )
334 {
335  YQSpacing * spacing = new YQSpacing( parent, dim, stretchable, size );
336  YUI_CHECK_NEW( spacing );
337 
338  return spacing;
339 }
340 
341 
342 YQEmpty *
343 YQWidgetFactory::createEmpty( YWidget * parent )
344 {
345  YQEmpty * empty = new YQEmpty( parent );
346  YUI_CHECK_NEW( empty );
347 
348  return empty;
349 }
350 
351 
352 
353 YQAlignment *
354 YQWidgetFactory::createAlignment( YWidget * parent,
355  YAlignmentType horAlignment,
356  YAlignmentType vertAlignment )
357 {
358  YQAlignment * alignment = new YQAlignment( parent, horAlignment, vertAlignment );
359  YUI_CHECK_NEW( alignment );
360 
361  return alignment;
362 }
363 
364 
365 YQSquash *
366 YQWidgetFactory::createSquash( YWidget * parent, bool horSquash, bool vertSquash )
367 {
368  YQSquash * squash = new YQSquash( parent, horSquash, vertSquash );
369  YUI_CHECK_NEW( squash );
370 
371  return squash;
372 }
373 
374 
375 
376 YQFrame *
377 YQWidgetFactory::createFrame( YWidget * parent, const std::string & label )
378 {
379  YQFrame * frame = new YQFrame( parent, label );
380  YUI_CHECK_NEW( frame );
381 
382  return frame;
383 }
384 
385 
386 
388 YQWidgetFactory::createCheckBoxFrame( YWidget * parent, const std::string & label, bool checked )
389 {
390  YQCheckBoxFrame * checkBoxFrame = new YQCheckBoxFrame( parent, label, checked );
391  YUI_CHECK_NEW( checkBoxFrame );
392 
393  return checkBoxFrame;
394 }
395 
396 
397 
399 YQWidgetFactory::createRadioButtonGroup( YWidget * parent )
400 {
401  YQRadioButtonGroup * radioButtonGroup = new YQRadioButtonGroup( parent );
402  YUI_CHECK_NEW( radioButtonGroup );
403 
404  return radioButtonGroup;
405 }
406 
407 
408 
410 YQWidgetFactory::createReplacePoint( YWidget * parent )
411 {
412  YQReplacePoint * replacePoint = new YQReplacePoint( parent );
413  YUI_CHECK_NEW( replacePoint );
414 
415  return replacePoint;
416 }
417 
418 
419 
MultiLineEdit - an input area for multi-line text.
YQWidgetFactory()
Constructor.
Definition: YQTree.h:38
virtual YPackageSelector * createPackageSelector(YWidget *parent, long modeFlags)
Create a package selector.
static YQPackageSelectorPluginStub * packageSelectorPlugin()
Return the package selector plugin singleton or creates it (including loading the plugin lib) if it d...
virtual ~YQWidgetFactory()
Destructor.