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