libyui  3.3.2
YAlignment.h
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: YAlignment.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #ifndef YAlignment_h
26 #define YAlignment_h
27 
28 #include "YSingleChildContainerWidget.h"
29 
30 
31 class YAlignmentPrivate;
32 
33 /**
34  * Implementation of all the alignment widgets:
35  *
36  * - Left, Right, HCenter,
37  * - Top, Bottom, VCenter,
38  * - HVCenter
39  * - MinSize, MinWidth, MinHeight
40  **/
42 {
43 protected:
44  /**
45  * Constructor.
46  **/
48  YAlignmentType horAlign,
49  YAlignmentType vertAlign );
50 
51 public:
52  /**
53  * Destructor.
54  **/
55  virtual ~YAlignment();
56 
57  /**
58  * Return a descriptive name of this widget class for logging,
59  * debugging etc.
60  **/
61  virtual const char * widgetClass() const;
62 
63  /**
64  * Return the alignment in the specified dimension.
65  **/
66  YAlignmentType alignment( YUIDimension dim ) const;
67 
68  /**
69  * Return the left margin in pixels, the distance between the left edge of
70  * this alignment and the left edge of the child widget.
71  **/
72  int leftMargin() const;
73 
74  /**
75  * Return the right margin in pixels, the distance between the right edge
76  * of this alignment and the right edge of the child widget.
77  **/
78  int rightMargin() const;
79 
80  /**
81  * Return the top margin in pixels, the distance between the top edge of
82  * this alignment and the top edge of the child widget.
83  **/
84  int topMargin() const;
85 
86  /**
87  * Return the bottom margin in pixels, the distance between the bottom
88  * edge of this alignment and the bottom edge of the child widget.
89  **/
90  int bottomMargin() const;
91 
92  /**
93  * Return the sum of all margins in the specified dimension.
94  **/
95  int totalMargins( YUIDimension dim ) const;
96 
97  /**
98  * Set the left margin in pixels.
99  **/
100  void setLeftMargin( int margin );
101 
102  /**
103  * Set the right margin in pixels.
104  **/
105  void setRightMargin( int margin );
106 
107  /**
108  * Set the top margin in pixels.
109  **/
110  void setTopMargin( int margin );
111 
112  /**
113  * Set the bottom margin in pixels.
114  **/
115  void setBottomMargin( int margin );
116 
117  /**
118  * Return the minimum width of this alignment or 0 if none is set.
119  * preferredWidth() will never return less than this value.
120  **/
121  int minWidth() const;
122 
123  /**
124  * Return the minimum height of this alignment or 0 if none is set.
125  * preferredHeight() will never return less than this value.
126  **/
127  int minHeight() const;
128 
129  /**
130  * Set the minimum width to return for preferredWidth().
131  **/
132  void setMinWidth( int width );
133 
134  /**
135  * Set the minimum height to return for preferredHeight().
136  **/
137  void setMinHeight( int height );
138 
139  /**
140  * Set a background pixmap.
141  *
142  * Derived classes may want to overwrite this.
143  *
144  * This parent method should be called first in the overwritten method to
145  * ensure path expansion is done as specified (prepend the theme path
146  * ("/usr/share/libyui/theme/") if the path doesn't start with "/"
147  * or ".").
148  **/
149  virtual void setBackgroundPixmap( const std::string & pixmapFileName );
150 
151  /**
152  * Return the name of the background pixmap or an empty string, if there
153  * is none.
154  **/
155  std::string backgroundPixmap() const;
156 
157  /**
158  * Add a child widget.
159  *
160  * Reimplemented from YSingleChildContainerWidget to propagate
161  * stretchability down to the single child.
162  **/
163  virtual void addChild( YWidget * child );
164 
165  /**
166  * Move a child widget to a new position.
167  **/
168  virtual void moveChild( YWidget *child, int newx, int newy ) = 0;
169 
170  /**
171  * Return this widget's stretchability.
172  * Reimplemented from YWidget.
173  *
174  * In an aligned dimension the widget is always stretchable.
175  * In an unchanged dimension the widget is stretchable if the
176  * child is stretchable.
177  **/
178  virtual bool stretchable( YUIDimension dim ) const;
179 
180  /**
181  * Preferred width of the widget.
182  *
183  * Reimplemented from YWidget.
184  **/
185  virtual int preferredWidth();
186 
187  /**
188  * Preferred height of the widget.
189  *
190  * Reimplemented from YWidget.
191  **/
192  virtual int preferredHeight();
193 
194  /**
195  * Set the current size and move the child widget according to its
196  * alignment.
197  *
198  * Derived classes should reimplement this, but call this base class
199  * function in their own implementation.
200  **/
201  virtual void setSize( int newWidth, int newHeight );
202 
203 
204 protected:
205 
207 };
208 
209 
210 #endif // YAlignment_h
int minWidth() const
Return the minimum width of this alignment or 0 if none is set.
Definition: YAlignment.cc:147
int minHeight() const
Return the minimum height of this alignment or 0 if none is set.
Definition: YAlignment.cc:153
std::string backgroundPixmap() const
Return the name of the background pixmap or an empty string, if there is none.
Definition: YAlignment.cc:171
virtual bool stretchable(YUIDimension dim) const
Return this widget&#39;s stretchability.
Definition: YAlignment.cc:186
virtual int preferredHeight()
Preferred height of the widget.
Definition: YAlignment.cc:207
virtual void moveChild(YWidget *child, int newx, int newy)=0
Move a child widget to a new position.
YWidget * parent() const
Return this widget&#39;s parent or 0 if it doesn&#39;t have a parent.
Definition: YWidget.cc:269
YAlignment(YWidget *parent, YAlignmentType horAlign, YAlignmentType vertAlign)
Constructor.
Definition: YAlignment.cc:76
virtual void addChild(YWidget *child)
Add a child widget.
Definition: YAlignment.cc:177
void setMinHeight(int height)
Set the minimum height to return for preferredHeight().
Definition: YAlignment.cc:165
virtual void setSize(int newWidth, int newHeight)
Set the current size and move the child widget according to its alignment.
Definition: YAlignment.cc:219
void setMinWidth(int width)
Set the minimum width to return for preferredWidth().
Definition: YAlignment.cc:159
YAlignmentType alignment(YUIDimension dim) const
Return the alignment in the specified dimension.
Definition: YAlignment.cc:93
Container widget class that manages one child.
virtual const char * widgetClass() const
Return a descriptive name of this widget class for logging, debugging etc.
Definition: YAlignment.cc:353
void setRightMargin(int margin)
Set the right margin in pixels.
Definition: YAlignment.cc:129
virtual int preferredWidth()
Preferred width of the widget.
Definition: YAlignment.cc:195
void setBottomMargin(int margin)
Set the bottom margin in pixels.
Definition: YAlignment.cc:141
int topMargin() const
Return the top margin in pixels, the distance between the top edge of this alignment and the top edge...
Definition: YAlignment.cc:111
Implementation of all the alignment widgets:
Definition: YAlignment.h:41
virtual void setBackgroundPixmap(const std::string &pixmapFileName)
Set a background pixmap.
Definition: YAlignment.cc:334
int bottomMargin() const
Return the bottom margin in pixels, the distance between the bottom edge of this alignment and the bo...
Definition: YAlignment.cc:117
void setTopMargin(int margin)
Set the top margin in pixels.
Definition: YAlignment.cc:135
int totalMargins(YUIDimension dim) const
Return the sum of all margins in the specified dimension.
Definition: YAlignment.cc:326
int leftMargin() const
Return the left margin in pixels, the distance between the left edge of this alignment and the left e...
Definition: YAlignment.cc:99
int rightMargin() const
Return the right margin in pixels, the distance between the right edge of this alignment and the righ...
Definition: YAlignment.cc:105
virtual ~YAlignment()
Destructor.
Definition: YAlignment.cc:86
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