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