]> git.saurik.com Git - wxWidgets.git/blob - include/wx/layout.h
Make wxr resources work in Unicode mode.
[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 #if defined(__GNUG__) && !defined(__APPLE__)
20 #pragma interface "layout.h"
21 #endif
22
23 #include "wx/object.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 public:
72 wxIndividualLayoutConstraint();
73
74 // note that default copy ctor and assignment operators are ok
75
76 ~wxIndividualLayoutConstraint();
77
78 void Set(wxRelationship rel, wxWindowBase *otherW, wxEdge otherE, int val = 0, int marg = wxLAYOUT_DEFAULT_MARGIN);
79
80 //
81 // Sibling relationships
82 //
83 void LeftOf(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
84 void RightOf(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
85 void Above(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
86 void Below(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
87
88 //
89 // 'Same edge' alignment
90 //
91 void SameAs(wxWindowBase *otherW, wxEdge edge, int marg = wxLAYOUT_DEFAULT_MARGIN);
92
93 // The edge is a percentage of the other window's edge
94 void PercentOf(wxWindowBase *otherW, wxEdge wh, int per);
95
96 //
97 // Edge has absolute value
98 //
99 void Absolute(int val);
100
101 //
102 // Dimension is unconstrained
103 //
104 void Unconstrained() { relationship = wxUnconstrained; }
105
106 //
107 // Dimension is 'as is' (use current size settings)
108 //
109 void AsIs() { relationship = wxAsIs; }
110
111 //
112 // Accessors
113 //
114 wxWindowBase *GetOtherWindow() { return otherWin; }
115 wxEdge GetMyEdge() const { return myEdge; }
116 void SetEdge(wxEdge which) { myEdge = which; }
117 void SetValue(int v) { value = v; }
118 int GetMargin() { return margin; }
119 void SetMargin(int m) { margin = m; }
120 int GetValue() const { return value; }
121 int GetPercent() const { return percent; }
122 int GetOtherEdge() const { return otherEdge; }
123 bool GetDone() const { return done; }
124 void SetDone(bool d) { done = d; }
125 wxRelationship GetRelationship() { return relationship; }
126 void SetRelationship(wxRelationship r) { relationship = r; }
127
128 // Reset constraint if it mentions otherWin
129 bool ResetIfWin(wxWindowBase *otherW);
130
131 // Try to satisfy constraint
132 bool SatisfyConstraint(wxLayoutConstraints *constraints, wxWindowBase *win);
133
134 // Get the value of this edge or dimension, or if this
135 // is not determinable, -1.
136 int GetEdge(wxEdge which, wxWindowBase *thisWin, wxWindowBase *other) const;
137
138 protected:
139 // To be allowed to modify the internal variables
140 friend class wxIndividualLayoutConstraint_Serialize;
141
142 // 'This' window is the parent or sibling of otherWin
143 wxWindowBase *otherWin;
144
145 wxEdge myEdge;
146 wxRelationship relationship;
147 int margin;
148 int value;
149 int percent;
150 wxEdge otherEdge;
151 bool done;
152
153 DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint)
154 };
155
156 // ----------------------------------------------------------------------------
157 // wxLayoutConstraints: the complete set of constraints for a window
158 // ----------------------------------------------------------------------------
159
160 class WXDLLEXPORT wxLayoutConstraints : public wxObject
161 {
162 public:
163 // Edge constraints
164 wxIndividualLayoutConstraint left;
165 wxIndividualLayoutConstraint top;
166 wxIndividualLayoutConstraint right;
167 wxIndividualLayoutConstraint bottom;
168 // Size constraints
169 wxIndividualLayoutConstraint width;
170 wxIndividualLayoutConstraint height;
171 // Centre constraints
172 wxIndividualLayoutConstraint centreX;
173 wxIndividualLayoutConstraint centreY;
174
175 wxLayoutConstraints();
176
177 // note that default copy ctor and assignment operators are ok
178
179 ~wxLayoutConstraints();
180
181 bool SatisfyConstraints(wxWindowBase *win, int *noChanges);
182 bool AreSatisfied() const
183 {
184 return left.GetDone() && top.GetDone() &&
185 width.GetDone() && height.GetDone();
186 }
187
188 DECLARE_DYNAMIC_CLASS(wxLayoutConstraints)
189 };
190
191 #endif
192 // _WX_LAYOUTH__