1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: OBSOLETE layout constraint classes, use sizers instead
4 // Author: Julian Smart
7 // Copyright: (c) 1998 Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 #include "wx/object.h"
20 // X stupidly defines these in X.h
30 // ----------------------------------------------------------------------------
31 // forward declrations
32 // ----------------------------------------------------------------------------
34 class WXDLLIMPEXP_FWD_CORE wxWindowBase
;
35 class WXDLLIMPEXP_FWD_CORE wxLayoutConstraints
;
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 #define wxLAYOUT_DEFAULT_MARGIN 0
45 wxLeft
, wxTop
, wxRight
, wxBottom
, wxWidth
, wxHeight
,
46 wxCentre
, wxCenter
= wxCentre
, wxCentreX
, wxCentreY
62 // ----------------------------------------------------------------------------
63 // wxIndividualLayoutConstraint: a constraint on window position
64 // ----------------------------------------------------------------------------
66 class WXDLLIMPEXP_CORE wxIndividualLayoutConstraint
: public wxObject
69 wxIndividualLayoutConstraint();
71 // note that default copy ctor and assignment operators are ok
73 virtual ~wxIndividualLayoutConstraint(){}
75 void Set(wxRelationship rel
, wxWindowBase
*otherW
, wxEdge otherE
, int val
= 0, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
78 // Sibling relationships
80 void LeftOf(wxWindowBase
*sibling
, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
81 void RightOf(wxWindowBase
*sibling
, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
82 void Above(wxWindowBase
*sibling
, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
83 void Below(wxWindowBase
*sibling
, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
86 // 'Same edge' alignment
88 void SameAs(wxWindowBase
*otherW
, wxEdge edge
, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
90 // The edge is a percentage of the other window's edge
91 void PercentOf(wxWindowBase
*otherW
, wxEdge wh
, int per
);
94 // Edge has absolute value
96 void Absolute(int val
);
99 // Dimension is unconstrained
101 void Unconstrained() { relationship
= wxUnconstrained
; }
104 // Dimension is 'as is' (use current size settings)
106 void AsIs() { relationship
= wxAsIs
; }
111 wxWindowBase
*GetOtherWindow() { return otherWin
; }
112 wxEdge
GetMyEdge() const { return myEdge
; }
113 void SetEdge(wxEdge which
) { myEdge
= which
; }
114 void SetValue(int v
) { value
= v
; }
115 int GetMargin() { return margin
; }
116 void SetMargin(int m
) { margin
= m
; }
117 int GetValue() const { return value
; }
118 int GetPercent() const { return percent
; }
119 int GetOtherEdge() const { return otherEdge
; }
120 bool GetDone() const { return done
; }
121 void SetDone(bool d
) { done
= d
; }
122 wxRelationship
GetRelationship() { return relationship
; }
123 void SetRelationship(wxRelationship r
) { relationship
= r
; }
125 // Reset constraint if it mentions otherWin
126 bool ResetIfWin(wxWindowBase
*otherW
);
128 // Try to satisfy constraint
129 bool SatisfyConstraint(wxLayoutConstraints
*constraints
, wxWindowBase
*win
);
131 // Get the value of this edge or dimension, or if this
132 // is not determinable, -1.
133 int GetEdge(wxEdge which
, wxWindowBase
*thisWin
, wxWindowBase
*other
) const;
136 // To be allowed to modify the internal variables
137 friend class wxIndividualLayoutConstraint_Serialize
;
139 // 'This' window is the parent or sibling of otherWin
140 wxWindowBase
*otherWin
;
143 wxRelationship relationship
;
150 DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint
)
153 // ----------------------------------------------------------------------------
154 // wxLayoutConstraints: the complete set of constraints for a window
155 // ----------------------------------------------------------------------------
157 class WXDLLIMPEXP_CORE wxLayoutConstraints
: public wxObject
161 wxIndividualLayoutConstraint left
;
162 wxIndividualLayoutConstraint top
;
163 wxIndividualLayoutConstraint right
;
164 wxIndividualLayoutConstraint bottom
;
166 wxIndividualLayoutConstraint width
;
167 wxIndividualLayoutConstraint height
;
168 // Centre constraints
169 wxIndividualLayoutConstraint centreX
;
170 wxIndividualLayoutConstraint centreY
;
172 wxLayoutConstraints();
174 // note that default copy ctor and assignment operators are ok
176 virtual ~wxLayoutConstraints(){}
178 bool SatisfyConstraints(wxWindowBase
*win
, int *noChanges
);
179 bool AreSatisfied() const
181 return left
.GetDone() && top
.GetDone() &&
182 width
.GetDone() && height
.GetDone();
185 DECLARE_DYNAMIC_CLASS(wxLayoutConstraints
)
188 #endif // wxUSE_CONSTRAINTS
190 #endif // _WX_LAYOUT_H_