libyui-qt  2.56.2
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 <shundhammer@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 
254 YQMenuBar *
255 YQWidgetFactory::createMenuBar( YWidget * parent )
256 {
257  YQMenuBar * menuBar = new YQMenuBar( parent );
258  YUI_CHECK_NEW( menuBar );
259 
260  return menuBar;
261 }
262 
263 
265 YQWidgetFactory::createMultiLineEdit( YWidget * parent, const string & label )
266 {
267  YQMultiLineEdit * multiLineEdit = new YQMultiLineEdit( parent, label );
268  YUI_CHECK_NEW( multiLineEdit );
269 
270  return multiLineEdit;
271 }
272 
273 
274 YQImage *
275 YQWidgetFactory::createImage( YWidget * parent, const string & imageFileName, bool animated )
276 {
277  YQImage * image = new YQImage( parent, imageFileName, animated );
278  YUI_CHECK_NEW( image );
279 
280  return image;
281 }
282 
283 YQLogView *
284 YQWidgetFactory::createLogView( YWidget * parent, const string & label, int visibleLines, int storedLines )
285 {
286  YQLogView * logView = new YQLogView( parent, label, visibleLines, storedLines );
287  YUI_CHECK_NEW( logView );
288 
289  return logView;
290 }
291 
292 
294 YQWidgetFactory::createMultiSelectionBox( YWidget * parent, const string & label )
295 {
296  YQMultiSelectionBox * multiSelectionBox = new YQMultiSelectionBox( parent, label );
297  YUI_CHECK_NEW( multiSelectionBox );
298 
299  return multiSelectionBox;
300 }
301 
302 
303 YPackageSelector*
304 YQWidgetFactory::createPackageSelector(YWidget* parent, long modeFlags)
305 {
307  YUI_CHECK_PTR( plugin );
308 
309 
310  YPackageSelector * pkgSel = plugin->createPackageSelector( parent, modeFlags );
311  YUI_CHECK_NEW( pkgSel );
312 
313  return pkgSel;
314 }
315 
316 YWidget *
317 YQWidgetFactory::createPkgSpecial( YWidget * , const string & )
318 {
319  YUI_THROW( YUIUnsupportedWidgetException( "YQPkgSpecial" ) ); // NCurses only
320  return 0;
321 }
322 
323 
324 //
325 // Layout Helpers
326 //
327 
328 YQSpacing *
329 YQWidgetFactory::createSpacing( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t size )
330 {
331  YQSpacing * spacing = new YQSpacing( parent, dim, stretchable, size );
332  YUI_CHECK_NEW( spacing );
333 
334  return spacing;
335 }
336 
337 
338 YQEmpty *
339 YQWidgetFactory::createEmpty( YWidget * parent )
340 {
341  YQEmpty * empty = new YQEmpty( parent );
342  YUI_CHECK_NEW( empty );
343 
344  return empty;
345 }
346 
347 
348 YQAlignment *
349 YQWidgetFactory::createAlignment( YWidget * parent,
350  YAlignmentType horAlignment,
351  YAlignmentType vertAlignment )
352 {
353  YQAlignment * alignment = new YQAlignment( parent, horAlignment, vertAlignment );
354  YUI_CHECK_NEW( alignment );
355 
356  return alignment;
357 }
358 
359 
360 YQSquash *
361 YQWidgetFactory::createSquash( YWidget * parent, bool horSquash, bool vertSquash )
362 {
363  YQSquash * squash = new YQSquash( parent, horSquash, vertSquash );
364  YUI_CHECK_NEW( squash );
365 
366  return squash;
367 }
368 
369 
370 YQFrame *
371 YQWidgetFactory::createFrame( YWidget * parent, const string & label )
372 {
373  YQFrame * frame = new YQFrame( parent, label );
374  YUI_CHECK_NEW( frame );
375 
376  return frame;
377 }
378 
379 
381 YQWidgetFactory::createCheckBoxFrame( YWidget * parent, const string & label, bool checked )
382 {
383  YQCheckBoxFrame * checkBoxFrame = new YQCheckBoxFrame( parent, label, checked );
384  YUI_CHECK_NEW( checkBoxFrame );
385 
386  return checkBoxFrame;
387 }
388 
389 
390 
392 YQWidgetFactory::createRadioButtonGroup( YWidget * parent )
393 {
394  YQRadioButtonGroup * radioButtonGroup = new YQRadioButtonGroup( parent );
395  YUI_CHECK_NEW( radioButtonGroup );
396 
397  return radioButtonGroup;
398 }
399 
400 
402 YQWidgetFactory::createReplacePoint( YWidget * parent )
403 {
404  YQReplacePoint * replacePoint = new YQReplacePoint( parent );
405  YUI_CHECK_NEW( replacePoint );
406 
407  return replacePoint;
408 }
409 
410 
412 YQWidgetFactory::createItemSelector( YWidget * parent, bool enforceSingleSelection )
413 {
414  YQItemSelector * selector = new YQItemSelector( parent, enforceSingleSelection );
415  YUI_CHECK_NEW( selector );
416 
417  return selector;
418 }
419 
420 
422 YQWidgetFactory::createCustomStatusItemSelector( YWidget * parent,
423  const YItemCustomStatusVector & customStates )
424 {
425  YQCustomStatusItemSelector * selector = new YQCustomStatusItemSelector( parent, customStates );
426  YUI_CHECK_NEW( selector );
427 
428  return selector;
429 }
YQIntField
Definition: YQIntField.h:40
YQCustomStatusItemSelector
ItemSelector widget with support for custom status values, not just 0 or 1.
Definition: YQCustomStatusItemSelector.h:42
YQInputField
Definition: YQInputField.h:44
YQFrame
Definition: YQFrame.h:36
YQSquash
Definition: YQSquash.h:36
YQWidgetFactory::~YQWidgetFactory
virtual ~YQWidgetFactory()
Destructor.
Definition: YQWidgetFactory.cc:46
YQMultiSelectionBox
Definition: YQMultiSelectionBox.h:39
YQMultiLineEdit
MultiLineEdit - an input area for multi-line text.
Definition: YQMultiLineEdit.h:40
YQDialog
Definition: YQDialog.h:43
YQRadioButton
Definition: YQRadioButton.h:36
YQButtonBox
Definition: YQButtonBox.h:34
YQCheckBox
Definition: YQCheckBox.h:33
YQTree
Definition: YQTree.h:39
YQItemSelector
Definition: YQItemSelector.h:43
YQPushButton
Definition: YQPushButton.h:35
YQApplication::packageSelectorPlugin
static YQPackageSelectorPluginStub * packageSelectorPlugin()
Return the package selector plugin singleton or creates it (including loading the plugin lib) if it d...
Definition: YQApplication.cc:737
YQMenuButton
Definition: YQMenuButton.h:38
YQSelectionBox
Definition: YQSelectionBox.h:40
YQComboBox
Definition: YQComboBox.h:38
YQSpacing
Definition: YQSpacing.h:33
YQAlignment
Definition: YQAlignment.h:36
YQLayoutBox
Definition: YQLayoutBox.h:35
YQTable
Definition: YQTable.h:39
YQLabel
Definition: YQLabel.h:34
YQRadioButtonGroup
Definition: YQRadioButtonGroup.h:33
YQWidgetFactory::YQWidgetFactory
YQWidgetFactory()
Constructor.
Definition: YQWidgetFactory.cc:39
YQEmpty
Definition: YQEmpty.h:33
YQImage
Definition: YQImage.h:37
YQMenuBar
Definition: YQMenuBar.h:38
YQBusyIndicator
Definition: YQBusyIndicator.h:40
YQLogView
Definition: YQLogView.h:40
YQPackageSelectorPluginStub::createPackageSelector
virtual YPackageSelector * createPackageSelector(YWidget *parent, long modeFlags)
Create a package selector.
Definition: YQPackageSelectorPluginStub.cc:62
YQCheckBoxFrame
Definition: YQCheckBoxFrame.h:37
YQPackageSelectorPluginStub
Definition: YQPackageSelectorPluginStub.h:44
YQProgressBar
Definition: YQProgressBar.h:39
YQReplacePoint
Definition: YQReplacePoint.h:36
YQRichText
Definition: YQRichText.h:40