libyui
 
Loading...
Searching...
No Matches
YButtonBox.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: YButtonBox.h
20
21 Author: Stefan Hundhammer <shundhammer@suse.de>
22
23/-*/
24
25#ifndef YButtonBox_h
26#define YButtonBox_h
27
28#include <vector>
29
30#include "YWidget.h"
31#include "YPushButton.h"
32
34class YPushButton;
35
36
41struct YButtonBoxLayoutPolicy
42{
43 YButtonBoxLayoutPolicy()
44 : buttonOrder( YKDEButtonOrder )
45 , equalSizeButtons( false )
46 , addExcessSpaceToHelpButtonExtraMargin( false )
47 {
48 alignment[ YD_HORIZ ] = YAlignCenter;
49 alignment[ YD_VERT ] = YAlignBegin; // Align top
50 }
51
52 YButtonOrder buttonOrder; // YKDEButtonOrder / YGnomeButtonOrder
53 bool equalSizeButtons; // Make all buttons the same size?
54 bool addExcessSpaceToHelpButtonExtraMargin;
55
56 // Alignment for the YButtonBox itself
57 YAlignmentType alignment[ YUIAllDimensions ];
58};
59
60
65struct YButtonBoxMargins
66{
67 YButtonBoxMargins()
68 : left( 0 )
69 , right( 0 )
70 , top( 0 )
71 , bottom( 0 )
72 , spacing( 0 )
73 , helpButtonExtraSpacing( 0 )
74 {}
75
76 int left; // Left of the leftmost button
77 int right; // Right of the rightmost button
78 int top; // Above the hightest button
79 int bottom; // Below the hightest button
80
81 int spacing; // Between buttons
82 int helpButtonExtraSpacing; // Between [Help] and the next button
83}; // (additionally to "spacing"!)
84
85
148class YButtonBox : public YWidget
149{
150 friend class YButtonBoxPrivate;
151
152protected:
157
158public:
159
163 virtual ~YButtonBox();
164
169 virtual const char * widgetClass() const { return "YButtonBox"; }
170
187
192
197
202
206 static void setDefaultMargins( const YButtonBoxMargins & margins );
207
212
219 virtual void setMargins( const YButtonBoxMargins & margins );
220
228
245 virtual void doLayout( int width, int height );
246
251 YPushButton * findButton( YButtonRole role );
252
274 void sanityCheck();
275
296 void setSanityCheckRelaxed( bool relax = true );
297
301 bool sanityCheckRelaxed() const;
302
313 virtual int preferredWidth();
314
324 virtual int preferredHeight();
325
334 virtual void setSize( int newWidth, int newHeight );
335
343 virtual bool stretchable( YUIDimension dimension ) const;
344
345
346protected:
347
359 virtual std::vector<YPushButton *> buttonsByButtonOrder();
360
365 int maxChildSize( YUIDimension dim ) const;
366
370 int totalChildrenWidth() const;
371
377 virtual void moveChild( YWidget * child, int newX, int newY ) = 0;
378
383 int preferredWidth( bool equalSizeButtons );
384
385
386private:
387
389
390 static YButtonBoxLayoutPolicy _layoutPolicy;
391 static YButtonBoxMargins _defaultMargins;
392};
393
394
395#endif // YButtonBox_h
Definition ImplPtr.h:43
bool sanityCheckRelaxed() const
Definition YButtonBox.cc:600
static YButtonBoxLayoutPolicy gnomeLayoutPolicy()
Definition YButtonBox.cc:111
YButtonBoxMargins margins() const
Definition YButtonBox.cc:147
static YButtonBoxLayoutPolicy kdeLayoutPolicy()
Definition YButtonBox.cc:97
virtual ~YButtonBox()
Definition YButtonBox.cc:76
int totalChildrenWidth() const
Definition YButtonBox.cc:545
virtual const char * widgetClass() const
Definition YButtonBox.h:169
YButtonBox(YWidget *parent)
Definition YButtonBox.cc:67
virtual void moveChild(YWidget *child, int newX, int newY)=0
virtual int preferredHeight()
Definition YButtonBox.cc:518
int maxChildSize(YUIDimension dim) const
Definition YButtonBox.cc:529
YPushButton * findButton(YButtonRole role)
Definition YButtonBox.cc:576
virtual void setMargins(const YButtonBoxMargins &margins)
Definition YButtonBox.cc:140
virtual void doLayout(int width, int height)
Definition YButtonBox.cc:162
static YButtonBoxMargins defaultMargins()
Definition YButtonBox.cc:133
virtual int preferredWidth()
Definition YButtonBox.cc:511
virtual std::vector< YPushButton * > buttonsByButtonOrder()
Definition YButtonBox.cc:411
virtual bool stretchable(YUIDimension dimension) const
Definition YButtonBox.cc:561
void sanityCheck()
Definition YButtonBox.cc:607
static void setLayoutPolicy(const YButtonBoxLayoutPolicy &layoutPolicy)
Definition YButtonBox.cc:83
void setSanityCheckRelaxed(bool relax=true)
Definition YButtonBox.cc:593
static YButtonBoxLayoutPolicy layoutPolicy()
Definition YButtonBox.cc:90
virtual void setSize(int newWidth, int newHeight)
Definition YButtonBox.cc:154
static void setDefaultMargins(const YButtonBoxMargins &margins)
Definition YButtonBox.cc:126
Definition YPushButton.h:38
YWidget(YWidget *parent)
Definition YWidget.cc:106
YWidget * parent() const
Definition YWidget.cc:277
Definition YButtonBox.h:42
Definition YButtonBox.h:66
Definition YButtonBox.cc:47