1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Layout classes
4 // Author: Julian Smart
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 #include "wx/object.h"
21 // X stupidly defines these in X.h
29 // ----------------------------------------------------------------------------
30 // forward declrations
31 // ----------------------------------------------------------------------------
33 class WXDLLEXPORT wxWindowBase
;
34 class WXDLLEXPORT wxLayoutConstraints
;
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 #define wxLAYOUT_DEFAULT_MARGIN 0
44 wxLeft
, wxTop
, wxRight
, wxBottom
, wxWidth
, wxHeight
,
45 wxCentre
, wxCenter
= wxCentre
, wxCentreX
, wxCentreY
61 // ----------------------------------------------------------------------------
62 // wxIndividualLayoutConstraint: a constraint on window position
63 // ----------------------------------------------------------------------------
65 class WXDLLEXPORT wxIndividualLayoutConstraint
: public wxObject
68 wxIndividualLayoutConstraint();
70 // note that default copy ctor and assignment operators are ok
72 ~wxIndividualLayoutConstraint(){}
74 void Set(wxRelationship rel
, wxWindowBase
*otherW
, wxEdge otherE
, int val
= 0, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
77 // Sibling relationships
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
);
85 // 'Same edge' alignment
87 void SameAs(wxWindowBase
*otherW
, wxEdge edge
, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
89 // The edge is a percentage of the other window's edge
90 void PercentOf(wxWindowBase
*otherW
, wxEdge wh
, int per
);
93 // Edge has absolute value
95 void Absolute(int val
);
98 // Dimension is unconstrained
100 void Unconstrained() { relationship
= wxUnconstrained
; }
103 // Dimension is 'as is' (use current size settings)
105 void AsIs() { relationship
= wxAsIs
; }
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
; }
124 // Reset constraint if it mentions otherWin
125 bool ResetIfWin(wxWindowBase
*otherW
);
127 // Try to satisfy constraint
128 bool SatisfyConstraint(wxLayoutConstraints
*constraints
, wxWindowBase
*win
);
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;
135 // To be allowed to modify the internal variables
136 friend class wxIndividualLayoutConstraint_Serialize
;
138 // 'This' window is the parent or sibling of otherWin
139 wxWindowBase
*otherWin
;
142 wxRelationship relationship
;
149 DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint
)
152 // ----------------------------------------------------------------------------
153 // wxLayoutConstraints: the complete set of constraints for a window
154 // ----------------------------------------------------------------------------
156 class WXDLLEXPORT wxLayoutConstraints
: public wxObject
160 wxIndividualLayoutConstraint left
;
161 wxIndividualLayoutConstraint top
;
162 wxIndividualLayoutConstraint right
;
163 wxIndividualLayoutConstraint bottom
;
165 wxIndividualLayoutConstraint width
;
166 wxIndividualLayoutConstraint height
;
167 // Centre constraints
168 wxIndividualLayoutConstraint centreX
;
169 wxIndividualLayoutConstraint centreY
;
171 wxLayoutConstraints();
173 // note that default copy ctor and assignment operators are ok
175 ~wxLayoutConstraints(){}
177 bool SatisfyConstraints(wxWindowBase
*win
, int *noChanges
);
178 bool AreSatisfied() const
180 return left
.GetDone() && top
.GetDone() &&
181 width
.GetDone() && height
.GetDone();
184 DECLARE_DYNAMIC_CLASS(wxLayoutConstraints
)