]> git.saurik.com Git - wxWidgets.git/blame - include/wx/layout.h
Wrappers for *ToText
[wxWidgets.git] / include / wx / layout.h
CommitLineData
c801d85f
KB
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
65571936 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_LAYOUTH__
13#define _WX_LAYOUTH__
c801d85f 14
f03fc89f
VZ
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
12028905 19#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
f03fc89f 20 #pragma interface "layout.h"
c801d85f
KB
21#endif
22
59571fc0 23#include "wx/object.h"
c801d85f 24
c801d85f
KB
25// X stupidly defines these in X.h
26#ifdef Above
f03fc89f 27 #undef Above
c801d85f
KB
28#endif
29#ifdef Below
f03fc89f 30 #undef Below
c801d85f
KB
31#endif
32
f03fc89f
VZ
33// ----------------------------------------------------------------------------
34// forward declrations
35// ----------------------------------------------------------------------------
36
37class WXDLLEXPORT wxWindowBase;
38class WXDLLEXPORT wxLayoutConstraints;
39
40// ----------------------------------------------------------------------------
41// constants
42// ----------------------------------------------------------------------------
43
c801d85f
KB
44#define wxLAYOUT_DEFAULT_MARGIN 0
45
f03fc89f
VZ
46enum wxEdge
47{
48 wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
49 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY
50};
c801d85f 51
f03fc89f 52enum wxRelationship
c801d85f 53{
f03fc89f
VZ
54 wxUnconstrained = 0,
55 wxAsIs,
56 wxPercentOf,
57 wxAbove,
58 wxBelow,
59 wxLeftOf,
60 wxRightOf,
61 wxSameAs,
62 wxAbsolute
c801d85f
KB
63};
64
f03fc89f
VZ
65// ----------------------------------------------------------------------------
66// wxIndividualLayoutConstraint: a constraint on window position
67// ----------------------------------------------------------------------------
68
69class WXDLLEXPORT wxIndividualLayoutConstraint : public wxObject
70{
f03fc89f
VZ
71public:
72 wxIndividualLayoutConstraint();
59018c74
VZ
73
74 // note that default copy ctor and assignment operators are ok
75
f03fc89f
VZ
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;
22f3361e 137
59018c74
VZ
138protected:
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;
3e6562c1
VZ
152
153 DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint)
f03fc89f
VZ
154};
155
156// ----------------------------------------------------------------------------
157// wxLayoutConstraints: the complete set of constraints for a window
158// ----------------------------------------------------------------------------
159
160class WXDLLEXPORT wxLayoutConstraints : public wxObject
161{
f03fc89f
VZ
162public:
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();
59018c74
VZ
176
177 // note that default copy ctor and assignment operators are ok
178
f03fc89f
VZ
179 ~wxLayoutConstraints();
180
181 bool SatisfyConstraints(wxWindowBase *win, int *noChanges);
182 bool AreSatisfied() const
183 {
4b7f2165
VZ
184 return left.GetDone() && top.GetDone() &&
185 width.GetDone() && height.GetDone();
f03fc89f 186 }
59018c74
VZ
187
188 DECLARE_DYNAMIC_CLASS(wxLayoutConstraints)
f03fc89f
VZ
189};
190
c801d85f 191#endif
34138703 192 // _WX_LAYOUTH__