libyui
YLayoutBox.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: YLayoutBox.h
20 
21  Author: Stefan Hundhammer <shundhammer@suse.de>
22 
23 /-*/
24 
25 #ifndef YLayoutBox_h
26 #define YLayoutBox_h
27 
28 #include <vector>
29 #include "YWidget.h"
30 
31 
32 class YLayoutBoxPrivate;
33 
37 class YLayoutBox : public YWidget
38 {
39 public:
40  typedef std::vector<int> sizeVector;
41  typedef std::vector<int> posVector;
42 
43 protected:
49  YLayoutBox( YWidget * parent, YUIDimension dim );
50 
51 public:
55  virtual ~YLayoutBox();
56 
61  virtual const char * widgetClass() const;
62 
67  YUIDimension primary() const;
68 
72  YUIDimension secondary() const;
73 
77  bool debugLayout() const;
78 
82  void setDebugLayout( bool deb = true );
83 
89  virtual int preferredSize( YUIDimension dim );
90 
96  virtual int preferredWidth();
97 
103  virtual int preferredHeight();
104 
114  virtual void setSize( int newWidth, int newHeight );
115 
124  virtual bool stretchable( YUIDimension dimension ) const;
125 
131  virtual void moveChild( YWidget * child, int newX, int newY ) = 0;
132 
137  static bool isLayoutStretch( YWidget * child, YUIDimension dimension );
138 
139 protected:
140 
144  int childrenTotalWeight( YUIDimension dimension );
145 
150  int childrenMaxPreferredSize( YUIDimension dimension );
151 
156  int totalNonWeightedChildrenPreferredSize( YUIDimension dimension );
157 
161  int countNonWeightedChildren( YUIDimension dimension );
162 
167  int countStretchableChildren( YUIDimension dimension );
168 
174  int countLayoutStretchChildren( YUIDimension dimension );
175 
184 
189  void calcPrimaryGeometry ( int newSize,
190  sizeVector & childSize,
191  posVector & childPos );
192 
197  void calcSecondaryGeometry ( int newSize,
198  sizeVector & childSize,
199  posVector & childPos );
200 
208  void doResize( sizeVector & width,
209  sizeVector & height,
210  posVector & x_pos,
211  posVector & y_pos );
212 
213 
214 private:
215 
217 };
218 
219 
220 typedef YLayoutBox YVBox;
221 typedef YLayoutBox YHBox;
222 
223 
224 #endif // YLayoutBox_h
int childrenTotalWeight(YUIDimension dimension)
Definition: YLayoutBox.cc:243
virtual void moveChild(YWidget *child, int newX, int newY)=0
virtual bool stretchable(YUIDimension dimension) const
Definition: YLayoutBox.cc:345
static bool isLayoutStretch(YWidget *child, YUIDimension dimension)
Definition: YLayoutBox.cc:329
Definition: YLayoutBox.h:37
bool debugLayout() const
Definition: YLayoutBox.cc:92
virtual int preferredWidth()
Definition: YLayoutBox.cc:155
YUIDimension secondary() const
Definition: YLayoutBox.cc:85
void calcPrimaryGeometry(int newSize, sizeVector &childSize, posVector &childPos)
Definition: YLayoutBox.cc:394
void calcSecondaryGeometry(int newSize, sizeVector &childSize, posVector &childPos)
Definition: YLayoutBox.cc:690
void setDebugLayout(bool deb=true)
Definition: YLayoutBox.cc:98
virtual void setSize(int newWidth, int newHeight)
Definition: YLayoutBox.cc:361
void doResize(sizeVector &width, sizeVector &height, posVector &x_pos, posVector &y_pos)
Definition: YLayoutBox.cc:742
YWidget * parent() const
Definition: YWidget.cc:271
int countNonWeightedChildren(YUIDimension dimension)
Definition: YLayoutBox.cc:276
int totalNonWeightedChildrenPreferredSize(YUIDimension dimension)
Definition: YLayoutBox.cc:259
virtual int preferredSize(YUIDimension dim)
Definition: YLayoutBox.cc:107
virtual int preferredHeight()
Definition: YLayoutBox.cc:161
YLayoutBox(YWidget *parent, YUIDimension dim)
Definition: YLayoutBox.cc:62
Definition: YLayoutBox.cc:39
int countStretchableChildren(YUIDimension dimension)
Definition: YLayoutBox.cc:293
YWidget * findDominatingChild()
Definition: YLayoutBox.cc:181
virtual const char * widgetClass() const
Definition: YLayoutBox.cc:771
Definition: YWidget.h:54
int childrenMaxPreferredSize(YUIDimension dimension)
Definition: YLayoutBox.cc:227
int countLayoutStretchChildren(YUIDimension dimension)
Definition: YLayoutBox.cc:311
YUIDimension primary() const
Definition: YLayoutBox.cc:78
virtual ~YLayoutBox()
Definition: YLayoutBox.cc:71