libyui
3.0.10
|
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: YWidgetFactory.cc 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 #include "YWidgetFactory.h" 00026 #include "YAlignment.h" 00027 #include "YPushButton.h" 00028 #include "YUI.h" 00029 #include "YApplication.h" 00030 00031 00032 YWidgetFactory::YWidgetFactory() 00033 { 00034 // NOP 00035 } 00036 00037 YWidgetFactory::~YWidgetFactory() 00038 { 00039 // NOP 00040 } 00041 00042 00043 YDialog * 00044 YWidgetFactory::createMainDialog( YDialogColorMode colorMode ) 00045 { 00046 return createDialog( YMainDialog, colorMode ); 00047 } 00048 00049 00050 YDialog * 00051 YWidgetFactory::createPopupDialog( YDialogColorMode colorMode ) 00052 { 00053 return createDialog( YPopupDialog, colorMode ); 00054 } 00055 00056 00057 YLayoutBox * 00058 YWidgetFactory::createVBox( YWidget * parent ) 00059 { 00060 return createLayoutBox( parent, YD_VERT ); 00061 } 00062 00063 00064 YLayoutBox * 00065 YWidgetFactory::createHBox( YWidget * parent ) 00066 { 00067 return createLayoutBox( parent, YD_HORIZ ); 00068 } 00069 00070 00071 YSpacing * 00072 YWidgetFactory::createHStretch( YWidget * parent ) 00073 { 00074 return createSpacing( parent, 00075 YD_HORIZ, 00076 true ); // stretchable 00077 } 00078 00079 00080 YSpacing * 00081 YWidgetFactory::createVStretch( YWidget * parent ) 00082 { 00083 return createSpacing( parent, 00084 YD_VERT, 00085 true ); // stretchable 00086 } 00087 00088 00089 YSpacing * 00090 YWidgetFactory::createHSpacing( YWidget * parent, YLayoutSize_t size ) 00091 { 00092 return createSpacing( parent, 00093 YD_HORIZ, 00094 false, // not stretchable 00095 size ); 00096 } 00097 00098 00099 YSpacing * 00100 YWidgetFactory::createVSpacing( YWidget * parent, YLayoutSize_t size ) 00101 { 00102 return createSpacing( parent, 00103 YD_VERT, 00104 false, // not stretchable 00105 size ); 00106 } 00107 00108 00109 YAlignment * 00110 YWidgetFactory::createLeft( YWidget * parent ) 00111 { 00112 return createAlignment( parent, YAlignBegin, YAlignUnchanged ); 00113 } 00114 00115 00116 YAlignment * 00117 YWidgetFactory::createRight( YWidget * parent ) 00118 { 00119 return createAlignment( parent, YAlignEnd, YAlignUnchanged ); 00120 } 00121 00122 00123 YAlignment * 00124 YWidgetFactory::createTop( YWidget * parent ) 00125 { 00126 return createAlignment( parent, YAlignUnchanged, YAlignBegin ); 00127 } 00128 00129 00130 YAlignment * 00131 YWidgetFactory::createBottom( YWidget * parent ) 00132 { 00133 return createAlignment( parent, YAlignUnchanged, YAlignEnd ); 00134 } 00135 00136 00137 YAlignment * 00138 YWidgetFactory::createHCenter( YWidget * parent ) 00139 { 00140 return createAlignment( parent, YAlignCenter, YAlignUnchanged ); 00141 } 00142 00143 00144 YAlignment * 00145 YWidgetFactory::createVCenter( YWidget * parent ) 00146 { 00147 return createAlignment( parent, YAlignUnchanged, YAlignCenter ); 00148 } 00149 00150 00151 YAlignment * 00152 YWidgetFactory::createHVCenter( YWidget * parent ) 00153 { 00154 return createAlignment( parent, YAlignCenter, YAlignCenter ); 00155 } 00156 00157 00158 YAlignment * 00159 YWidgetFactory::createMarginBox( YWidget * parent, YLayoutSize_t horMargin, YLayoutSize_t vertMargin ) 00160 { 00161 return createMarginBox( parent, 00162 horMargin, horMargin, 00163 vertMargin, vertMargin ); 00164 } 00165 00166 00167 00168 YAlignment * 00169 YWidgetFactory::createMarginBox( YWidget * parent, 00170 YLayoutSize_t leftMargin, YLayoutSize_t rightMargin, 00171 YLayoutSize_t topMargin, YLayoutSize_t bottomMargin ) 00172 { 00173 YAlignment * alignment = createAlignment( parent, YAlignUnchanged, YAlignUnchanged ); 00174 00175 alignment->setLeftMargin ( YUI::app()->deviceUnits( YD_HORIZ, leftMargin ) ); 00176 alignment->setRightMargin ( YUI::app()->deviceUnits( YD_HORIZ, rightMargin ) ); 00177 alignment->setTopMargin ( YUI::app()->deviceUnits( YD_VERT, topMargin ) ); 00178 alignment->setBottomMargin( YUI::app()->deviceUnits( YD_VERT, bottomMargin ) ); 00179 00180 return alignment; 00181 } 00182 00183 00184 YAlignment * 00185 YWidgetFactory::createMinWidth( YWidget * parent, YLayoutSize_t minWidth ) 00186 { 00187 return createMinSize( parent, minWidth, 0 ); 00188 } 00189 00190 00191 YAlignment * 00192 YWidgetFactory::createMinHeight( YWidget * parent, YLayoutSize_t minHeight ) 00193 { 00194 return createMinSize( parent, 0, minHeight ); 00195 } 00196 00197 00198 YAlignment * 00199 YWidgetFactory::createMinSize( YWidget * parent, YLayoutSize_t minWidth, YLayoutSize_t minHeight ) 00200 { 00201 YAlignment * alignment = createAlignment( parent, YAlignUnchanged, YAlignUnchanged ); 00202 00203 alignment->setMinWidth ( YUI::app()->deviceUnits( YD_HORIZ, minWidth ) ); 00204 alignment->setMinHeight( YUI::app()->deviceUnits( YD_VERT, minHeight ) ); 00205 00206 return alignment; 00207 } 00208 00209 00210 YSquash * 00211 YWidgetFactory::createHSquash( YWidget * parent ) 00212 { 00213 return createSquash( parent, true, false ); 00214 } 00215 00216 00217 YSquash * 00218 YWidgetFactory::createVSquash( YWidget * parent ) 00219 { 00220 return createSquash( parent, false, true ); 00221 } 00222 00223 00224 YSquash * 00225 YWidgetFactory::createHVSquash( YWidget * parent ) 00226 { 00227 return createSquash( parent, true, true ); 00228 } 00229 00230 00231 YPushButton * 00232 YWidgetFactory::createIconButton( YWidget * parent, 00233 const std::string & iconName, 00234 const std::string & fallbackTextLabel ) 00235 { 00236 YPushButton * button = createPushButton( parent, fallbackTextLabel ); 00237 button->setIcon( iconName ); 00238 00239 return button; 00240 } 00241 00242 00243 YLabel * 00244 YWidgetFactory::createHeading( YWidget * parent, const std::string & text ) 00245 { 00246 return createLabel( parent, 00247 text, 00248 true, // isHeading 00249 false ); // isOutputField 00250 } 00251 00252 00253 YLabel * 00254 YWidgetFactory::createOutputField( YWidget * parent, const std::string & text ) 00255 { 00256 return createLabel( parent, 00257 text, 00258 false, // isHeading 00259 true); // isOutputField 00260 } 00261 00262 00263 YInputField * 00264 YWidgetFactory::createPasswordField( YWidget * parent, const std::string & label ) 00265 { 00266 return createInputField( parent, 00267 label, 00268 true ); // passwordMode 00269 }