]> git.saurik.com Git - wxWidgets.git/blame - include/wx/layout.h
Comment-only update
[wxWidgets.git] / include / wx / layout.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
735dec5e
VZ
2// Name: wx/layout.h
3// Purpose: OBSOLETE layout constraint classes, use sizers instead
c801d85f
KB
4// Author: Julian Smart
5// Modified by:
6// Created: 29/01/98
c801d85f 7// Copyright: (c) 1998 Julian Smart
65571936 8// Licence: wxWindows licence
c801d85f
KB
9/////////////////////////////////////////////////////////////////////////////
10
735dec5e
VZ
11#ifndef _WX_LAYOUT_H_
12#define _WX_LAYOUT_H_
c801d85f 13
f03fc89f
VZ
14// ----------------------------------------------------------------------------
15// headers
16// ----------------------------------------------------------------------------
17
59571fc0 18#include "wx/object.h"
c801d85f 19
c801d85f
KB
20// X stupidly defines these in X.h
21#ifdef Above
f03fc89f 22 #undef Above
c801d85f
KB
23#endif
24#ifdef Below
f03fc89f 25 #undef Below
c801d85f
KB
26#endif
27
735dec5e
VZ
28#if wxUSE_CONSTRAINTS
29
f03fc89f
VZ
30// ----------------------------------------------------------------------------
31// forward declrations
32// ----------------------------------------------------------------------------
33
b5dbe15d
VS
34class WXDLLIMPEXP_FWD_CORE wxWindowBase;
35class WXDLLIMPEXP_FWD_CORE wxLayoutConstraints;
f03fc89f
VZ
36
37// ----------------------------------------------------------------------------
38// constants
39// ----------------------------------------------------------------------------
40
c801d85f
KB
41#define wxLAYOUT_DEFAULT_MARGIN 0
42
f03fc89f
VZ
43enum wxEdge
44{
45 wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
46 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY
47};
c801d85f 48
f03fc89f 49enum wxRelationship
c801d85f 50{
f03fc89f
VZ
51 wxUnconstrained = 0,
52 wxAsIs,
53 wxPercentOf,
54 wxAbove,
55 wxBelow,
56 wxLeftOf,
57 wxRightOf,
58 wxSameAs,
59 wxAbsolute
c801d85f
KB
60};
61
f03fc89f
VZ
62// ----------------------------------------------------------------------------
63// wxIndividualLayoutConstraint: a constraint on window position
64// ----------------------------------------------------------------------------
65
53a2db12 66class WXDLLIMPEXP_CORE wxIndividualLayoutConstraint : public wxObject
f03fc89f 67{
f03fc89f
VZ
68public:
69 wxIndividualLayoutConstraint();
59018c74
VZ
70
71 // note that default copy ctor and assignment operators are ok
72
d3c7fc99 73 virtual ~wxIndividualLayoutConstraint(){}
f03fc89f
VZ
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;
22f3361e 134
59018c74
VZ
135protected:
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;
3e6562c1
VZ
149
150 DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint)
f03fc89f
VZ
151};
152
153// ----------------------------------------------------------------------------
154// wxLayoutConstraints: the complete set of constraints for a window
155// ----------------------------------------------------------------------------
156
53a2db12 157class WXDLLIMPEXP_CORE wxLayoutConstraints : public wxObject
f03fc89f 158{
f03fc89f
VZ
159public:
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();
59018c74
VZ
173
174 // note that default copy ctor and assignment operators are ok
175
d3c7fc99 176 virtual ~wxLayoutConstraints(){}
f03fc89f
VZ
177
178 bool SatisfyConstraints(wxWindowBase *win, int *noChanges);
179 bool AreSatisfied() const
180 {
4b7f2165
VZ
181 return left.GetDone() && top.GetDone() &&
182 width.GetDone() && height.GetDone();
f03fc89f 183 }
59018c74
VZ
184
185 DECLARE_DYNAMIC_CLASS(wxLayoutConstraints)
f03fc89f
VZ
186};
187
735dec5e
VZ
188#endif // wxUSE_CONSTRAINTS
189
190#endif // _WX_LAYOUT_H_