1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Layout classes
4 // Author: Julian Smart
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
20 #pragma interface "layout.h"
25 // X stupidly defines these in X.h
33 // ----------------------------------------------------------------------------
34 // forward declrations
35 // ----------------------------------------------------------------------------
37 class WXDLLEXPORT wxWindowBase
;
38 class WXDLLEXPORT wxLayoutConstraints
;
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 #define wxLAYOUT_DEFAULT_MARGIN 0
48 wxLeft
, wxTop
, wxRight
, wxBottom
, wxWidth
, wxHeight
,
49 wxCentre
, wxCenter
= wxCentre
, wxCentreX
, wxCentreY
65 // ----------------------------------------------------------------------------
66 // wxIndividualLayoutConstraint: a constraint on window position
67 // ----------------------------------------------------------------------------
69 class WXDLLEXPORT wxIndividualLayoutConstraint
: public wxObject
71 DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint
)
74 // To be allowed to modify the internal variables
75 friend class wxIndividualLayoutConstraint_Serialize
;
77 // 'This' window is the parent or sibling of otherWin
78 wxWindowBase
*otherWin
;
81 wxRelationship relationship
;
89 wxIndividualLayoutConstraint();
90 ~wxIndividualLayoutConstraint();
92 void Set(wxRelationship rel
, wxWindowBase
*otherW
, wxEdge otherE
, int val
= 0, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
95 // Sibling relationships
97 void LeftOf(wxWindowBase
*sibling
, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
98 void RightOf(wxWindowBase
*sibling
, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
99 void Above(wxWindowBase
*sibling
, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
100 void Below(wxWindowBase
*sibling
, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
103 // 'Same edge' alignment
105 void SameAs(wxWindowBase
*otherW
, wxEdge edge
, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
107 // The edge is a percentage of the other window's edge
108 void PercentOf(wxWindowBase
*otherW
, wxEdge wh
, int per
);
111 // Edge has absolute value
113 void Absolute(int val
);
116 // Dimension is unconstrained
118 void Unconstrained() { relationship
= wxUnconstrained
; }
121 // Dimension is 'as is' (use current size settings)
123 void AsIs() { relationship
= wxAsIs
; }
128 wxWindowBase
*GetOtherWindow() { return otherWin
; }
129 wxEdge
GetMyEdge() const { return myEdge
; }
130 void SetEdge(wxEdge which
) { myEdge
= which
; }
131 void SetValue(int v
) { value
= v
; }
132 int GetMargin() { return margin
; }
133 void SetMargin(int m
) { margin
= m
; }
134 int GetValue() const { return value
; }
135 int GetPercent() const { return percent
; }
136 int GetOtherEdge() const { return otherEdge
; }
137 bool GetDone() const { return done
; }
138 void SetDone(bool d
) { done
= d
; }
139 wxRelationship
GetRelationship() { return relationship
; }
140 void SetRelationship(wxRelationship r
) { relationship
= r
; }
142 // Reset constraint if it mentions otherWin
143 bool ResetIfWin(wxWindowBase
*otherW
);
145 // Try to satisfy constraint
146 bool SatisfyConstraint(wxLayoutConstraints
*constraints
, wxWindowBase
*win
);
148 // Get the value of this edge or dimension, or if this
149 // is not determinable, -1.
150 int GetEdge(wxEdge which
, wxWindowBase
*thisWin
, wxWindowBase
*other
) const;
153 // ----------------------------------------------------------------------------
154 // wxLayoutConstraints: the complete set of constraints for a window
155 // ----------------------------------------------------------------------------
157 class WXDLLEXPORT wxLayoutConstraints
: public wxObject
159 DECLARE_DYNAMIC_CLASS(wxLayoutConstraints
)
163 wxIndividualLayoutConstraint left
;
164 wxIndividualLayoutConstraint top
;
165 wxIndividualLayoutConstraint right
;
166 wxIndividualLayoutConstraint bottom
;
168 wxIndividualLayoutConstraint width
;
169 wxIndividualLayoutConstraint height
;
170 // Centre constraints
171 wxIndividualLayoutConstraint centreX
;
172 wxIndividualLayoutConstraint centreY
;
174 wxLayoutConstraints();
175 ~wxLayoutConstraints();
177 bool SatisfyConstraints(wxWindowBase
*win
, int *noChanges
);
178 bool AreSatisfied() const
180 return left
.GetDone() && top
.GetDone() &&
181 width
.GetDone() && height
.GetDone();