libyui-qt
2.43.5
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YQWidgetFactory.cc 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 #include <QColorGroup> 00026 #define YUILogComponent "qt-ui" 00027 #include <yui/YUILog.h> 00028 00029 #include "YQWidgetFactory.h" 00030 #include "YQApplication.h" 00031 #include <yui/YUIException.h> 00032 #include "YQPackageSelectorPluginStub.h" 00033 #include "YQMainWinDock.h" 00034 00035 #include <string> 00036 00037 using std::string; 00038 00039 00040 YQWidgetFactory::YQWidgetFactory() 00041 : YWidgetFactory() 00042 { 00043 // NOP 00044 } 00045 00046 00047 YQWidgetFactory::~YQWidgetFactory() 00048 { 00049 // NOP 00050 } 00051 00052 00053 00054 00055 // 00056 // Dialogs 00057 // 00058 00059 YQDialog * 00060 YQWidgetFactory::createDialog( YDialogType dialogType, YDialogColorMode colorMode ) 00061 { 00062 YQDialog * dialog = new YQDialog( dialogType, colorMode ); 00063 YUI_CHECK_NEW( dialog ); 00064 00065 return dialog; 00066 } 00067 00068 00069 00070 // 00071 // Layout Boxes 00072 // 00073 00074 YQLayoutBox * 00075 YQWidgetFactory::createLayoutBox( YWidget * parent, YUIDimension dim ) 00076 { 00077 YQLayoutBox * layoutBox = new YQLayoutBox( parent, dim ); 00078 YUI_CHECK_NEW( layoutBox ); 00079 00080 return layoutBox; 00081 } 00082 00083 00084 YQButtonBox * 00085 YQWidgetFactory::createButtonBox( YWidget * parent ) 00086 { 00087 YQButtonBox * buttonBox = new YQButtonBox( parent ); 00088 YUI_CHECK_NEW( buttonBox ); 00089 00090 return buttonBox; 00091 } 00092 00093 00094 00095 // 00096 // Common Leaf Widgets 00097 // 00098 00099 YQPushButton * 00100 YQWidgetFactory::createPushButton( YWidget * parent, const std::string & label ) 00101 { 00102 YQPushButton * pushButton = new YQPushButton( parent, label ); 00103 YUI_CHECK_NEW( pushButton ); 00104 00105 return pushButton; 00106 } 00107 00108 00109 00110 YQLabel * 00111 YQWidgetFactory::createLabel( YWidget * parent, 00112 const std::string & text, 00113 bool isHeading, 00114 bool isOutputField ) 00115 { 00116 YQLabel * label = new YQLabel( parent, text, isHeading, isOutputField ); 00117 YUI_CHECK_NEW( label ); 00118 00119 return label; 00120 } 00121 00122 00123 00124 YQInputField * 00125 YQWidgetFactory::createInputField( YWidget * parent, const std::string & label, bool passwordMode ) 00126 { 00127 YQInputField * inputField = new YQInputField( parent, label, passwordMode ); 00128 YUI_CHECK_NEW( inputField ); 00129 00130 return inputField; 00131 } 00132 00133 00134 00135 YQCheckBox * 00136 YQWidgetFactory::createCheckBox( YWidget * parent, const std::string & label, bool isChecked ) 00137 { 00138 YQCheckBox * checkBox = new YQCheckBox( parent, label, isChecked ); 00139 YUI_CHECK_NEW( checkBox ); 00140 00141 return checkBox; 00142 } 00143 00144 00145 00146 YQRadioButton * 00147 YQWidgetFactory::createRadioButton( YWidget * parent, const std::string & label, bool isChecked ) 00148 { 00149 YQRadioButton * radioButton = new YQRadioButton( parent, label, isChecked ); 00150 YUI_CHECK_NEW( radioButton ); 00151 00152 // Register radio button with its button group. 00153 // This has to be done after all constructors are done so virtual functions 00154 // can be used. 00155 00156 if ( radioButton->buttonGroup() ) 00157 radioButton->buttonGroup()->addRadioButton( radioButton ); 00158 00159 return radioButton; 00160 } 00161 00162 00163 00164 YQComboBox * 00165 YQWidgetFactory::createComboBox( YWidget * parent, const std::string & label, bool editable ) 00166 { 00167 YQComboBox * comboBox = new YQComboBox( parent, label, editable ); 00168 YUI_CHECK_NEW( comboBox ); 00169 00170 return comboBox; 00171 } 00172 00173 00174 00175 YQSelectionBox * 00176 YQWidgetFactory::createSelectionBox( YWidget * parent, const std::string & label ) 00177 { 00178 YQSelectionBox * selectionBox = new YQSelectionBox( parent, label ); 00179 YUI_CHECK_NEW( selectionBox ); 00180 00181 return selectionBox; 00182 } 00183 00184 00185 00186 YQTree * 00187 YQWidgetFactory::createTree( YWidget * parent, const std::string & label, bool multiselection, bool recursiveselection ) 00188 { 00189 YQTree * tree = new YQTree( parent, label, multiselection, recursiveselection ); 00190 YUI_CHECK_NEW( tree ); 00191 00192 return tree; 00193 } 00194 00195 00196 00197 YQTable * 00198 YQWidgetFactory::createTable( YWidget * parent, YTableHeader * header, bool multiSelection ) 00199 { 00200 YQTable * table = new YQTable( parent, header, multiSelection ); 00201 YUI_CHECK_NEW( table ); 00202 00203 return table; 00204 } 00205 00206 00207 00208 YQProgressBar * 00209 YQWidgetFactory::createProgressBar( YWidget * parent, const std::string & label, int maxValue ) 00210 { 00211 YQProgressBar * progressBar = new YQProgressBar( parent, label, maxValue ); 00212 YUI_CHECK_NEW( progressBar ); 00213 00214 return progressBar; 00215 } 00216 00217 00218 00219 YQRichText * 00220 YQWidgetFactory::createRichText( YWidget * parent, const std::string & text, bool plainTextMode ) 00221 { 00222 YQRichText * richText = new YQRichText( parent, text, plainTextMode ); 00223 YUI_CHECK_NEW( richText ); 00224 00225 return richText; 00226 } 00227 00228 00229 YQBusyIndicator * 00230 YQWidgetFactory::createBusyIndicator( YWidget * parent, const std::string & label, int maxValue ) 00231 { 00232 YQBusyIndicator * busyIndicator = new YQBusyIndicator( parent, label, maxValue ); 00233 YUI_CHECK_NEW( busyIndicator ); 00234 00235 return busyIndicator; 00236 } 00237 00238 00239 00240 00241 // 00242 // Less Common Leaf Widgets 00243 // 00244 00245 YQIntField * 00246 YQWidgetFactory::createIntField( YWidget * parent, const std::string & label, int minVal, int maxVal, int initialVal ) 00247 { 00248 YQIntField * intField = new YQIntField( parent, label, minVal, maxVal, initialVal ); 00249 YUI_CHECK_NEW( intField ); 00250 00251 return intField; 00252 } 00253 00254 00255 00256 YQMenuButton * 00257 YQWidgetFactory::createMenuButton( YWidget * parent, const std::string & label ) 00258 { 00259 YQMenuButton * menuButton = new YQMenuButton( parent, label ); 00260 YUI_CHECK_NEW( menuButton ); 00261 00262 return menuButton; 00263 } 00264 00265 00266 00267 YQMultiLineEdit * 00268 YQWidgetFactory::createMultiLineEdit( YWidget * parent, const std::string & label ) 00269 { 00270 YQMultiLineEdit * multiLineEdit = new YQMultiLineEdit( parent, label ); 00271 YUI_CHECK_NEW( multiLineEdit ); 00272 00273 return multiLineEdit; 00274 } 00275 00276 00277 00278 YQImage * 00279 YQWidgetFactory::createImage( YWidget * parent, const std::string & imageFileName, bool animated ) 00280 { 00281 YQImage * image = new YQImage( parent, imageFileName, animated ); 00282 YUI_CHECK_NEW( image ); 00283 00284 return image; 00285 } 00286 00287 00288 YQLogView * 00289 YQWidgetFactory::createLogView( YWidget * parent, const std::string & label, int visibleLines, int storedLines ) 00290 { 00291 YQLogView * logView = new YQLogView( parent, label, visibleLines, storedLines ); 00292 YUI_CHECK_NEW( logView ); 00293 00294 return logView; 00295 } 00296 00297 00298 00299 YQMultiSelectionBox * 00300 YQWidgetFactory::createMultiSelectionBox( YWidget * parent, const std::string & label ) 00301 { 00302 YQMultiSelectionBox * multiSelectionBox = new YQMultiSelectionBox( parent, label ); 00303 YUI_CHECK_NEW( multiSelectionBox ); 00304 00305 return multiSelectionBox; 00306 } 00307 00308 YPackageSelector* 00309 YQWidgetFactory::createPackageSelector(YWidget* parent, long modeFlags) 00310 { 00311 YQPackageSelectorPluginStub * plugin = YQApplication::packageSelectorPlugin(); 00312 YUI_CHECK_PTR( plugin ); 00313 00314 00315 YPackageSelector * pkgSel = plugin->createPackageSelector( parent, modeFlags ); 00316 YUI_CHECK_NEW( pkgSel ); 00317 00318 return pkgSel; 00319 } 00320 00321 YWidget * 00322 YQWidgetFactory::createPkgSpecial( YWidget * , const std::string & ) 00323 { 00324 YUI_THROW( YUIUnsupportedWidgetException( "YQPkgSpecial" ) ); // NCurses only 00325 return 0; 00326 } 00327 00328 00329 // 00330 // Layout Helpers 00331 // 00332 00333 YQSpacing * 00334 YQWidgetFactory::createSpacing( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t size ) 00335 { 00336 YQSpacing * spacing = new YQSpacing( parent, dim, stretchable, size ); 00337 YUI_CHECK_NEW( spacing ); 00338 00339 return spacing; 00340 } 00341 00342 00343 YQEmpty * 00344 YQWidgetFactory::createEmpty( YWidget * parent ) 00345 { 00346 YQEmpty * empty = new YQEmpty( parent ); 00347 YUI_CHECK_NEW( empty ); 00348 00349 return empty; 00350 } 00351 00352 00353 00354 YQAlignment * 00355 YQWidgetFactory::createAlignment( YWidget * parent, 00356 YAlignmentType horAlignment, 00357 YAlignmentType vertAlignment ) 00358 { 00359 YQAlignment * alignment = new YQAlignment( parent, horAlignment, vertAlignment ); 00360 YUI_CHECK_NEW( alignment ); 00361 00362 return alignment; 00363 } 00364 00365 00366 YQSquash * 00367 YQWidgetFactory::createSquash( YWidget * parent, bool horSquash, bool vertSquash ) 00368 { 00369 YQSquash * squash = new YQSquash( parent, horSquash, vertSquash ); 00370 YUI_CHECK_NEW( squash ); 00371 00372 return squash; 00373 } 00374 00375 00376 00377 YQFrame * 00378 YQWidgetFactory::createFrame( YWidget * parent, const std::string & label ) 00379 { 00380 YQFrame * frame = new YQFrame( parent, label ); 00381 YUI_CHECK_NEW( frame ); 00382 00383 return frame; 00384 } 00385 00386 00387 00388 YQCheckBoxFrame * 00389 YQWidgetFactory::createCheckBoxFrame( YWidget * parent, const std::string & label, bool checked ) 00390 { 00391 YQCheckBoxFrame * checkBoxFrame = new YQCheckBoxFrame( parent, label, checked ); 00392 YUI_CHECK_NEW( checkBoxFrame ); 00393 00394 return checkBoxFrame; 00395 } 00396 00397 00398 00399 YQRadioButtonGroup * 00400 YQWidgetFactory::createRadioButtonGroup( YWidget * parent ) 00401 { 00402 YQRadioButtonGroup * radioButtonGroup = new YQRadioButtonGroup( parent ); 00403 YUI_CHECK_NEW( radioButtonGroup ); 00404 00405 return radioButtonGroup; 00406 } 00407 00408 00409 00410 YQReplacePoint * 00411 YQWidgetFactory::createReplacePoint( YWidget * parent ) 00412 { 00413 YQReplacePoint * replacePoint = new YQReplacePoint( parent ); 00414 YUI_CHECK_NEW( replacePoint ); 00415 00416 return replacePoint; 00417 } 00418 00419 00420