libyui  3.2.1
YWidgetFactory.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: YWidgetFactory.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #include "YWidgetFactory.h"
26 #include "YAlignment.h"
27 #include "YPushButton.h"
28 #include "YUI.h"
29 #include "YApplication.h"
30 
31 
33 {
34  // NOP
35 }
36 
38 {
39  // NOP
40 }
41 
42 
43 YDialog *
44 YWidgetFactory::createMainDialog( YDialogColorMode colorMode )
45 {
46  return createDialog( YMainDialog, colorMode );
47 }
48 
49 
50 YDialog *
51 YWidgetFactory::createPopupDialog( YDialogColorMode colorMode )
52 {
53  return createDialog( YPopupDialog, colorMode );
54 }
55 
56 
57 YLayoutBox *
58 YWidgetFactory::createVBox( YWidget * parent )
59 {
60  return createLayoutBox( parent, YD_VERT );
61 }
62 
63 
64 YLayoutBox *
65 YWidgetFactory::createHBox( YWidget * parent )
66 {
67  return createLayoutBox( parent, YD_HORIZ );
68 }
69 
70 
71 YSpacing *
72 YWidgetFactory::createHStretch( YWidget * parent )
73 {
74  return createSpacing( parent,
75  YD_HORIZ,
76  true ); // stretchable
77 }
78 
79 
80 YSpacing *
81 YWidgetFactory::createVStretch( YWidget * parent )
82 {
83  return createSpacing( parent,
84  YD_VERT,
85  true ); // stretchable
86 }
87 
88 
89 YSpacing *
90 YWidgetFactory::createHSpacing( YWidget * parent, YLayoutSize_t size )
91 {
92  return createSpacing( parent,
93  YD_HORIZ,
94  false, // not stretchable
95  size );
96 }
97 
98 
99 YSpacing *
100 YWidgetFactory::createVSpacing( YWidget * parent, YLayoutSize_t size )
101 {
102  return createSpacing( parent,
103  YD_VERT,
104  false, // not stretchable
105  size );
106 }
107 
108 
109 YAlignment *
110 YWidgetFactory::createLeft( YWidget * parent )
111 {
112  return createAlignment( parent, YAlignBegin, YAlignUnchanged );
113 }
114 
115 
116 YAlignment *
117 YWidgetFactory::createRight( YWidget * parent )
118 {
119  return createAlignment( parent, YAlignEnd, YAlignUnchanged );
120 }
121 
122 
123 YAlignment *
124 YWidgetFactory::createTop( YWidget * parent )
125 {
126  return createAlignment( parent, YAlignUnchanged, YAlignBegin );
127 }
128 
129 
130 YAlignment *
131 YWidgetFactory::createBottom( YWidget * parent )
132 {
133  return createAlignment( parent, YAlignUnchanged, YAlignEnd );
134 }
135 
136 
137 YAlignment *
138 YWidgetFactory::createHCenter( YWidget * parent )
139 {
140  return createAlignment( parent, YAlignCenter, YAlignUnchanged );
141 }
142 
143 
144 YAlignment *
145 YWidgetFactory::createVCenter( YWidget * parent )
146 {
147  return createAlignment( parent, YAlignUnchanged, YAlignCenter );
148 }
149 
150 
151 YAlignment *
152 YWidgetFactory::createHVCenter( YWidget * parent )
153 {
154  return createAlignment( parent, YAlignCenter, YAlignCenter );
155 }
156 
157 
158 YAlignment *
159 YWidgetFactory::createMarginBox( YWidget * parent, YLayoutSize_t horMargin, YLayoutSize_t vertMargin )
160 {
161  return createMarginBox( parent,
162  horMargin, horMargin,
163  vertMargin, vertMargin );
164 }
165 
166 
167 
168 YAlignment *
169 YWidgetFactory::createMarginBox( YWidget * parent,
170  YLayoutSize_t leftMargin, YLayoutSize_t rightMargin,
171  YLayoutSize_t topMargin, YLayoutSize_t bottomMargin )
172 {
173  YAlignment * alignment = createAlignment( parent, YAlignUnchanged, YAlignUnchanged );
174 
175  alignment->setLeftMargin ( YUI::app()->deviceUnits( YD_HORIZ, leftMargin ) );
176  alignment->setRightMargin ( YUI::app()->deviceUnits( YD_HORIZ, rightMargin ) );
177  alignment->setTopMargin ( YUI::app()->deviceUnits( YD_VERT, topMargin ) );
178  alignment->setBottomMargin( YUI::app()->deviceUnits( YD_VERT, bottomMargin ) );
179 
180  return alignment;
181 }
182 
183 
184 YAlignment *
185 YWidgetFactory::createMinWidth( YWidget * parent, YLayoutSize_t minWidth )
186 {
187  return createMinSize( parent, minWidth, 0 );
188 }
189 
190 
191 YAlignment *
192 YWidgetFactory::createMinHeight( YWidget * parent, YLayoutSize_t minHeight )
193 {
194  return createMinSize( parent, 0, minHeight );
195 }
196 
197 
198 YAlignment *
199 YWidgetFactory::createMinSize( YWidget * parent, YLayoutSize_t minWidth, YLayoutSize_t minHeight )
200 {
201  YAlignment * alignment = createAlignment( parent, YAlignUnchanged, YAlignUnchanged );
202 
203  alignment->setMinWidth ( YUI::app()->deviceUnits( YD_HORIZ, minWidth ) );
204  alignment->setMinHeight( YUI::app()->deviceUnits( YD_VERT, minHeight ) );
205 
206  return alignment;
207 }
208 
209 
210 YSquash *
211 YWidgetFactory::createHSquash( YWidget * parent )
212 {
213  return createSquash( parent, true, false );
214 }
215 
216 
217 YSquash *
218 YWidgetFactory::createVSquash( YWidget * parent )
219 {
220  return createSquash( parent, false, true );
221 }
222 
223 
224 YSquash *
225 YWidgetFactory::createHVSquash( YWidget * parent )
226 {
227  return createSquash( parent, true, true );
228 }
229 
230 
231 YPushButton *
232 YWidgetFactory::createIconButton( YWidget * parent,
233  const std::string & iconName,
234  const std::string & fallbackTextLabel )
235 {
236  YPushButton * button = createPushButton( parent, fallbackTextLabel );
237  button->setIcon( iconName );
238 
239  return button;
240 }
241 
242 
243 YLabel *
244 YWidgetFactory::createHeading( YWidget * parent, const std::string & text )
245 {
246  return createLabel( parent,
247  text,
248  true, // isHeading
249  false ); // isOutputField
250 }
251 
252 
253 YLabel *
254 YWidgetFactory::createOutputField( YWidget * parent, const std::string & text )
255 {
256  return createLabel( parent,
257  text,
258  false, // isHeading
259  true); // isOutputField
260 }
261 
262 
263 YInputField *
264 YWidgetFactory::createPasswordField( YWidget * parent, const std::string & label )
265 {
266  return createInputField( parent,
267  label,
268  true ); // passwordMode
269 }
YWidgetFactory()
Constructor.
Implementation of the Label, Heading and OutputField widgets.
Definition: YLabel.h:38
virtual ~YWidgetFactory()
Destructor.
HSquash, VSquash HVSquash:
Definition: YSquash.h:41
void setMinHeight(int height)
Set the minimum height to return for preferredHeight().
Definition: YAlignment.cc:165
void setMinWidth(int width)
Set the minimum width to return for preferredWidth().
Definition: YAlignment.cc:159
void setRightMargin(int margin)
Set the right margin in pixels.
Definition: YAlignment.cc:129
void setBottomMargin(int margin)
Set the bottom margin in pixels.
Definition: YAlignment.cc:141
Implementation of all the alignment widgets:
Definition: YAlignment.h:41
virtual void setIcon(const std::string &iconName)
Set this button's icon from an icon file in the UI's default icon directory.
Definition: YPushButton.h:74
HSpacing, VSpacing, HStretch, VStretch.
Definition: YSpacing.h:37
void setTopMargin(int margin)
Set the top margin in pixels.
Definition: YAlignment.cc:135
static YApplication * app()
Return the global YApplication object.
Definition: YUI.cc:156
InputField: General purpose one line input field for entering text and other data.
Definition: YInputField.h:46
Abstract base class of all UI widgets.
Definition: YWidget.h:54
void setLeftMargin(int margin)
Set the left margin in pixels.
Definition: YAlignment.cc:123