]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_constraints.i
bitwise vs. logical operator
[wxWidgets.git] / wxPython / src / _constraints.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _constraints.i
3 // Purpose: SWIG interface defs for the layout constraints
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 3-July-1997
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17
18 %{
19 %}
20
21 //---------------------------------------------------------------------------
22 %newgroup;
23
24
25 enum wxEdge
26 {
27 wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
28 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY
29 };
30
31 enum wxRelationship
32 {
33 wxUnconstrained = 0,
34 wxAsIs,
35 wxPercentOf,
36 wxAbove,
37 wxBelow,
38 wxLeftOf,
39 wxRightOf,
40 wxSameAs,
41 wxAbsolute
42 };
43
44
45 DocStr(wxIndividualLayoutConstraint,
46 "Objects of this class are stored in the `wx.LayoutConstraints` class as
47 one of eight possible constraints that a window can be involved in.
48 You will never need to create an instance of
49 wx.IndividualLayoutConstraint, rather you should create a
50 `wx.LayoutConstraints` instance and use the individual contstraints
51 that it contains.", "
52
53 Constraints are initially set to have the relationship
54 wx.Unconstrained, which means that their values should be calculated
55 by looking at known constraints.
56
57 The Edge specifies the type of edge or dimension of a window.
58
59 Edges
60 ------
61 ================== ==============================================
62 wx.Left The left edge.
63 wx.Top The top edge.
64 wx.Right The right edge.
65 wx.Bottom The bottom edge.
66 wx.CentreX The x-coordinate of the centre of the window.
67 wx.CentreY The y-coordinate of the centre of the window.
68 ================== ==============================================
69
70
71 The Relationship specifies the relationship that this edge or
72 dimension has with another specified edge or dimension. Normally, the
73 user doesn't use these directly because functions such as Below and
74 RightOf are a convenience for using the more general Set function.
75
76 Relationships
77 -------------
78 ================== ==============================================
79 wx.Unconstrained The edge or dimension is unconstrained
80 (the default for edges.)
81 wx.AsIs The edge or dimension is to be taken from the current
82 window position or size (the default for dimensions.)
83 wx.Above The edge should be above another edge.
84 wx.Below The edge should be below another edge.
85 wx.LeftOf The edge should be to the left of another edge.
86 wx.RightOf The edge should be to the right of another edge.
87 wx.SameAs The edge or dimension should be the same as another edge
88 or dimension.
89 wx.PercentOf The edge or dimension should be a percentage of another
90 edge or dimension.
91 wx.Absolute The edge or dimension should be a given absolute value.
92 ================== ==============================================
93
94 :see: `wx.LayoutConstraints`, `wx.Window.SetConstraints`
95 ");
96
97
98 class wxIndividualLayoutConstraint : public wxObject
99 {
100 public:
101 // wxIndividualLayoutConstraint();
102 // ~wxIndividualLayoutConstraint();
103
104 DocDeclStr(
105 void , Set(wxRelationship rel, wxWindow *otherW, wxEdge otherE,
106 int val = 0, int marg = wxLAYOUT_DEFAULT_MARGIN),
107 "Sets the properties of the constraint. Normally called by one of the
108 convenience functions such as Above, RightOf, SameAs.", "");
109
110
111 DocDeclStr(
112 void , LeftOf(wxWindow *sibling, int marg = 0),
113 "Constrains this edge to be to the left of the given window, with an
114 optional margin. Implicitly, this is relative to the left edge of the
115 other window.", "");
116
117 DocDeclStr(
118 void , RightOf(wxWindow *sibling, int marg = 0),
119 "Constrains this edge to be to the right of the given window, with an
120 optional margin. Implicitly, this is relative to the right edge of the
121 other window.", "");
122
123 DocDeclStr(
124 void , Above(wxWindow *sibling, int marg = 0),
125 "Constrains this edge to be above the given window, with an optional
126 margin. Implicitly, this is relative to the top edge of the other
127 window.", "");
128
129 DocDeclStr(
130 void , Below(wxWindow *sibling, int marg = 0),
131 "Constrains this edge to be below the given window, with an optional
132 margin. Implicitly, this is relative to the bottom edge of the other
133 window.", "");
134
135 DocDeclStr(
136 void , SameAs(wxWindow *otherW, wxEdge edge, int marg = 0),
137 "Constrains this edge or dimension to be to the same as the edge of the
138 given window, with an optional margin.", "");
139
140
141 DocDeclStr(
142 void , PercentOf(wxWindow *otherW, wxEdge wh, int per),
143 "Constrains this edge or dimension to be to a percentage of the given
144 window, with an optional margin.", "");
145
146
147 DocDeclStr(
148 void , Absolute(int val),
149 "Constrains this edge or dimension to be the given absolute value.", "");
150
151 DocDeclStr(
152 void , Unconstrained(),
153 "Sets this edge or dimension to be unconstrained, that is, dependent on
154 other edges and dimensions from which this value can be deduced.", "");
155
156
157 DocDeclStr(
158 void , AsIs(),
159 "Sets this edge or constraint to be whatever the window's value is at
160 the moment. If either of the width and height constraints are *as is*,
161 the window will not be resized, but moved instead. This is important
162 when considering panel items which are intended to have a default
163 size, such as a button, which may take its size from the size of the
164 button label.", "");
165
166
167 DocDeclStr(
168 wxWindow *, GetOtherWindow(),
169 "", "");
170
171 DocDeclStr(
172 wxEdge , GetMyEdge() const,
173 "", "");
174
175 DocDeclStr(
176 void , SetEdge(wxEdge which),
177 "", "");
178
179 DocDeclStr(
180 void , SetValue(int v),
181 "", "");
182
183 DocDeclStr(
184 int , GetMargin(),
185 "", "");
186
187 DocDeclStr(
188 void , SetMargin(int m),
189 "", "");
190
191 DocDeclStr(
192 int , GetValue() const,
193 "", "");
194
195 DocDeclStr(
196 int , GetPercent() const,
197 "", "");
198
199 DocDeclStr(
200 int , GetOtherEdge() const,
201 "", "");
202
203 DocDeclStr(
204 bool , GetDone() const,
205 "", "");
206
207 DocDeclStr(
208 void , SetDone(bool d),
209 "", "");
210
211 DocDeclStr(
212 wxRelationship , GetRelationship(),
213 "", "");
214
215 DocDeclStr(
216 void , SetRelationship(wxRelationship r),
217 "", "");
218
219
220 DocDeclStr(
221 bool , ResetIfWin(wxWindow *otherW),
222 "Reset constraint if it mentions otherWin", "");
223
224
225 DocDeclStr(
226 bool , SatisfyConstraint(wxLayoutConstraints *constraints, wxWindow *win),
227 "Try to satisfy constraint", "");
228
229
230 DocDeclStr(
231 int , GetEdge(wxEdge which, wxWindow *thisWin, wxWindow *other) const,
232 "Get the value of this edge or dimension, or if this\n"
233 "is not determinable, -1.", "");
234
235 %property(Done, GetDone, SetDone, doc="See `GetDone` and `SetDone`");
236 %property(Margin, GetMargin, SetMargin, doc="See `GetMargin` and `SetMargin`");
237 %property(MyEdge, GetMyEdge, doc="See `GetMyEdge`");
238 %property(OtherEdge, GetOtherEdge, doc="See `GetOtherEdge`");
239 %property(OtherWindow, GetOtherWindow, doc="See `GetOtherWindow`");
240 %property(Percent, GetPercent, doc="See `GetPercent`");
241 %property(Relationship, GetRelationship, SetRelationship, doc="See `GetRelationship` and `SetRelationship`");
242 %property(Value, GetValue, SetValue, doc="See `GetValue` and `SetValue`");
243
244 };
245
246
247 DocStr(wxLayoutConstraints,
248 "**Note:** constraints are now deprecated and you should use sizers
249 instead.
250
251 Objects of this class can be associated with a window to define its
252 layout constraints, with respect to siblings or its parent.
253
254 The class consists of the following eight constraints of class
255 wx.IndividualLayoutConstraint, some or all of which should be accessed
256 directly to set the appropriate constraints.
257
258 * left: represents the left hand edge of the window
259 * right: represents the right hand edge of the window
260 * top: represents the top edge of the window
261 * bottom: represents the bottom edge of the window
262 * width: represents the width of the window
263 * height: represents the height of the window
264 * centreX: represents the horizontal centre point of the window
265 * centreY: represents the vertical centre point of the window
266
267 Most constraints are initially set to have the relationship
268 wxUnconstrained, which means that their values should be calculated by
269 looking at known constraints. The exceptions are width and height,
270 which are set to wxAsIs to ensure that if the user does not specify a
271 constraint, the existing width and height will be used, to be
272 compatible with panel items which often have take a default size. If
273 the constraint is ``wx.AsIs``, the dimension will not be changed.
274
275 :see: `wx.IndividualLayoutConstraint`, `wx.Window.SetConstraints`
276 ", "");
277
278
279 class wxLayoutConstraints : public wxObject
280 {
281 public:
282 %immutable;
283
284 // Edge constraints
285 wxIndividualLayoutConstraint left;
286 wxIndividualLayoutConstraint top;
287 wxIndividualLayoutConstraint right;
288 wxIndividualLayoutConstraint bottom;
289
290 // Size constraints
291 wxIndividualLayoutConstraint width;
292 wxIndividualLayoutConstraint height;
293
294 // Centre constraints
295 wxIndividualLayoutConstraint centreX;
296 wxIndividualLayoutConstraint centreY;
297
298 %mutable;
299
300 DocCtorStr(
301 wxLayoutConstraints(),
302 "", "");
303
304 ~wxLayoutConstraints();
305
306 DocDeclA(
307 bool, SatisfyConstraints(wxWindow *win, int *OUTPUT),
308 "SatisfyConstraints(Window win) -> (areSatisfied, noChanges)");
309
310 bool AreSatisfied() const;
311 };
312
313 //---------------------------------------------------------------------------