1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: OBSOLETE layout constraint classes, use sizers instead
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
31 // ----------------------------------------------------------------------------
32 // forward declrations
33 // ----------------------------------------------------------------------------
35 class WXDLLEXPORT wxWindowBase
;
36 class WXDLLEXPORT wxLayoutConstraints
;
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 #define wxLAYOUT_DEFAULT_MARGIN 0
46 wxLeft
, wxTop
, wxRight
, wxBottom
, wxWidth
, wxHeight
,
47 wxCentre
, wxCenter
= wxCentre
, wxCentreX
, wxCentreY
63 // ----------------------------------------------------------------------------
64 // wxIndividualLayoutConstraint: a constraint on window position
65 // ----------------------------------------------------------------------------
67 class WXDLLEXPORT wxIndividualLayoutConstraint
: public wxObject
70 wxIndividualLayoutConstraint();
72 // note that default copy ctor and assignment operators are ok
74 virtual ~wxIndividualLayoutConstraint(){}
76 void Set(wxRelationship rel
, wxWindowBase
*otherW
, wxEdge otherE
, int val
= 0, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
79 // Sibling relationships
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
);
87 // 'Same edge' alignment
89 void SameAs(wxWindowBase
*otherW
, wxEdge edge
, int marg
= wxLAYOUT_DEFAULT_MARGIN
);
91 // The edge is a percentage of the other window's edge
92 void PercentOf(wxWindowBase
*otherW
, wxEdge wh
, int per
);
95 // Edge has absolute value
97 void Absolute(int val
);
100 // Dimension is unconstrained
102 void Unconstrained() { relationship
= wxUnconstrained
; }
105 // Dimension is 'as is' (use current size settings)
107 void AsIs() { relationship
= wxAsIs
; }
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
; }
126 // Reset constraint if it mentions otherWin
127 bool ResetIfWin(wxWindowBase
*otherW
);
129 // Try to satisfy constraint
130 bool SatisfyConstraint(wxLayoutConstraints
*constraints
, wxWindowBase
*win
);
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;
137 // To be allowed to modify the internal variables
138 friend class wxIndividualLayoutConstraint_Serialize
;
140 // 'This' window is the parent or sibling of otherWin
141 wxWindowBase
*otherWin
;
144 wxRelationship relationship
;
151 DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint
)
154 // ----------------------------------------------------------------------------
155 // wxLayoutConstraints: the complete set of constraints for a window
156 // ----------------------------------------------------------------------------
158 class WXDLLEXPORT wxLayoutConstraints
: public wxObject
162 wxIndividualLayoutConstraint left
;
163 wxIndividualLayoutConstraint top
;
164 wxIndividualLayoutConstraint right
;
165 wxIndividualLayoutConstraint bottom
;
167 wxIndividualLayoutConstraint width
;
168 wxIndividualLayoutConstraint height
;
169 // Centre constraints
170 wxIndividualLayoutConstraint centreX
;
171 wxIndividualLayoutConstraint centreY
;
173 wxLayoutConstraints();
175 // note that default copy ctor and assignment operators are ok
177 virtual ~wxLayoutConstraints(){}
179 bool SatisfyConstraints(wxWindowBase
*win
, int *noChanges
);
180 bool AreSatisfied() const
182 return left
.GetDone() && top
.GetDone() &&
183 width
.GetDone() && height
.GetDone();
186 DECLARE_DYNAMIC_CLASS(wxLayoutConstraints
)
189 #endif // wxUSE_CONSTRAINTS
191 #endif // _WX_LAYOUT_H_