1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Layout classes
4 // Author: Julian Smart
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 #if defined(__GNUG__) && !defined(__APPLE__)
20 #pragma interface "layout.h"
23 #include "wx/object.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
72 wxIndividualLayoutConstraint();
74 // note that default copy ctor and assignment operators are ok
76 ~wxIndividualLayoutConstraint();
78 void Set(wxRelationship rel
, wxWindowBase
*otherW
, wxEdge otherE
, int val
= 0, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
81 // Sibling relationships
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
);
89 // 'Same edge' alignment
91 void SameAs(wxWindowBase
*otherW
, wxEdge edge
, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
93 // The edge is a percentage of the other window's edge
94 void PercentOf(wxWindowBase
*otherW
, wxEdge wh
, int per
);
97 // Edge has absolute value
99 void Absolute(int val
);
102 // Dimension is unconstrained
104 void Unconstrained() { relationship
= wxUnconstrained
; }
107 // Dimension is 'as is' (use current size settings)
109 void AsIs() { relationship
= wxAsIs
; }
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
; }
128 // Reset constraint if it mentions otherWin
129 bool ResetIfWin(wxWindowBase
*otherW
);
131 // Try to satisfy constraint
132 bool SatisfyConstraint(wxLayoutConstraints
*constraints
, wxWindowBase
*win
);
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;
139 // To be allowed to modify the internal variables
140 friend class wxIndividualLayoutConstraint_Serialize
;
142 // 'This' window is the parent or sibling of otherWin
143 wxWindowBase
*otherWin
;
146 wxRelationship relationship
;
153 DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint
)
156 // ----------------------------------------------------------------------------
157 // wxLayoutConstraints: the complete set of constraints for a window
158 // ----------------------------------------------------------------------------
160 class WXDLLEXPORT wxLayoutConstraints
: public wxObject
164 wxIndividualLayoutConstraint left
;
165 wxIndividualLayoutConstraint top
;
166 wxIndividualLayoutConstraint right
;
167 wxIndividualLayoutConstraint bottom
;
169 wxIndividualLayoutConstraint width
;
170 wxIndividualLayoutConstraint height
;
171 // Centre constraints
172 wxIndividualLayoutConstraint centreX
;
173 wxIndividualLayoutConstraint centreY
;
175 wxLayoutConstraints();
177 // note that default copy ctor and assignment operators are ok
179 ~wxLayoutConstraints();
181 bool SatisfyConstraints(wxWindowBase
*win
, int *noChanges
);
182 bool AreSatisfied() const
184 return left
.GetDone() && top
.GetDone() &&
185 width
.GetDone() && height
.GetDone();
188 DECLARE_DYNAMIC_CLASS(wxLayoutConstraints
)