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