]> git.saurik.com Git - wxWidgets.git/blob - include/wx/layout.h
XRC: make wxSplitterWindow's sashpos and minpanesize dimensions.
[wxWidgets.git] / include / wx / layout.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/layout.h
3 // Purpose: OBSOLETE layout constraint classes, use sizers instead
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 29/01/98
7 // Copyright: (c) 1998 Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_LAYOUT_H_
12 #define _WX_LAYOUT_H_
13
14 // ----------------------------------------------------------------------------
15 // headers
16 // ----------------------------------------------------------------------------
17
18 #include "wx/object.h"
19
20 // X stupidly defines these in X.h
21 #ifdef Above
22 #undef Above
23 #endif
24 #ifdef Below
25 #undef Below
26 #endif
27
28 #if wxUSE_CONSTRAINTS
29
30 // ----------------------------------------------------------------------------
31 // forward declrations
32 // ----------------------------------------------------------------------------
33
34 class WXDLLIMPEXP_FWD_CORE wxWindowBase;
35 class WXDLLIMPEXP_FWD_CORE wxLayoutConstraints;
36
37 // ----------------------------------------------------------------------------
38 // constants
39 // ----------------------------------------------------------------------------
40
41 #define wxLAYOUT_DEFAULT_MARGIN 0
42
43 enum wxEdge
44 {
45 wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
46 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY
47 };
48
49 enum wxRelationship
50 {
51 wxUnconstrained = 0,
52 wxAsIs,
53 wxPercentOf,
54 wxAbove,
55 wxBelow,
56 wxLeftOf,
57 wxRightOf,
58 wxSameAs,
59 wxAbsolute
60 };
61
62 // ----------------------------------------------------------------------------
63 // wxIndividualLayoutConstraint: a constraint on window position
64 // ----------------------------------------------------------------------------
65
66 class WXDLLIMPEXP_CORE wxIndividualLayoutConstraint : public wxObject
67 {
68 public:
69 wxIndividualLayoutConstraint();
70
71 // note that default copy ctor and assignment operators are ok
72
73 virtual ~wxIndividualLayoutConstraint(){}
74
75 void Set(wxRelationship rel, wxWindowBase *otherW, wxEdge otherE, int val = 0, int marg = wxLAYOUT_DEFAULT_MARGIN);
76
77 //
78 // Sibling relationships
79 //
80 void LeftOf(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
81 void RightOf(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
82 void Above(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
83 void Below(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
84
85 //
86 // 'Same edge' alignment
87 //
88 void SameAs(wxWindowBase *otherW, wxEdge edge, int marg = wxLAYOUT_DEFAULT_MARGIN);
89
90 // The edge is a percentage of the other window's edge
91 void PercentOf(wxWindowBase *otherW, wxEdge wh, int per);
92
93 //
94 // Edge has absolute value
95 //
96 void Absolute(int val);
97
98 //
99 // Dimension is unconstrained
100 //
101 void Unconstrained() { relationship = wxUnconstrained; }
102
103 //
104 // Dimension is 'as is' (use current size settings)
105 //
106 void AsIs() { relationship = wxAsIs; }
107
108 //
109 // Accessors
110 //
111 wxWindowBase *GetOtherWindow() { return otherWin; }
112 wxEdge GetMyEdge() const { return myEdge; }
113 void SetEdge(wxEdge which) { myEdge = which; }
114 void SetValue(int v) { value = v; }
115 int GetMargin() { return margin; }
116 void SetMargin(int m) { margin = m; }
117 int GetValue() const { return value; }
118 int GetPercent() const { return percent; }
119 int GetOtherEdge() const { return otherEdge; }
120 bool GetDone() const { return done; }
121 void SetDone(bool d) { done = d; }
122 wxRelationship GetRelationship() { return relationship; }
123 void SetRelationship(wxRelationship r) { relationship = r; }
124
125 // Reset constraint if it mentions otherWin
126 bool ResetIfWin(wxWindowBase *otherW);
127
128 // Try to satisfy constraint
129 bool SatisfyConstraint(wxLayoutConstraints *constraints, wxWindowBase *win);
130
131 // Get the value of this edge or dimension, or if this
132 // is not determinable, -1.
133 int GetEdge(wxEdge which, wxWindowBase *thisWin, wxWindowBase *other) const;
134
135 protected:
136 // To be allowed to modify the internal variables
137 friend class wxIndividualLayoutConstraint_Serialize;
138
139 // 'This' window is the parent or sibling of otherWin
140 wxWindowBase *otherWin;
141
142 wxEdge myEdge;
143 wxRelationship relationship;
144 int margin;
145 int value;
146 int percent;
147 wxEdge otherEdge;
148 bool done;
149
150 DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint)
151 };
152
153 // ----------------------------------------------------------------------------
154 // wxLayoutConstraints: the complete set of constraints for a window
155 // ----------------------------------------------------------------------------
156
157 class WXDLLIMPEXP_CORE wxLayoutConstraints : public wxObject
158 {
159 public:
160 // Edge constraints
161 wxIndividualLayoutConstraint left;
162 wxIndividualLayoutConstraint top;
163 wxIndividualLayoutConstraint right;
164 wxIndividualLayoutConstraint bottom;
165 // Size constraints
166 wxIndividualLayoutConstraint width;
167 wxIndividualLayoutConstraint height;
168 // Centre constraints
169 wxIndividualLayoutConstraint centreX;
170 wxIndividualLayoutConstraint centreY;
171
172 wxLayoutConstraints();
173
174 // note that default copy ctor and assignment operators are ok
175
176 virtual ~wxLayoutConstraints(){}
177
178 bool SatisfyConstraints(wxWindowBase *win, int *noChanges);
179 bool AreSatisfied() const
180 {
181 return left.GetDone() && top.GetDone() &&
182 width.GetDone() && height.GetDone();
183 }
184
185 DECLARE_DYNAMIC_CLASS(wxLayoutConstraints)
186 };
187
188 #endif // wxUSE_CONSTRAINTS
189
190 #endif // _WX_LAYOUT_H_