1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: provide wxSizer class for layouting
4 // Author: Robert Roebling and Robin Dunn
8 // Copyright: (c) Robin Dunn, Dirk Holtwick and Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "sizer.h"
21 #include "wx/window.h"
23 #include "wx/dialog.h"
25 //---------------------------------------------------------------------------
27 //---------------------------------------------------------------------------
34 class wxStaticBoxSizer
;
36 //---------------------------------------------------------------------------
38 //---------------------------------------------------------------------------
40 class WXDLLEXPORT wxSizerItem
: public wxObject
42 DECLARE_CLASS(wxSizerItem
);
45 wxSizerItem( int width
, int height
, int option
, int flag
, int border
, wxObject
* userData
);
48 wxSizerItem( wxWindow
*window
, int option
, int flag
, int border
, wxObject
* userData
);
51 wxSizerItem( wxSizer
*sizer
, int option
, int flag
, int border
, wxObject
* userData
);
55 virtual wxSize
GetSize();
56 virtual wxSize
CalcMin();
57 virtual void SetDimension( wxPoint pos
, wxSize size
);
59 void SetRatio( int width
, int height
)
60 // if either of dimensions is zero, ratio is assumed to be 1
61 // to avoid "divide by zero" errors
62 { m_ratio
= (width
&& height
) ? ((float) width
/ (float) height
) : 1; }
63 void SetRatio( wxSize size
)
64 { m_ratio
= (size
.x
&& size
.y
) ? ((float) size
.x
/ (float) size
.y
) : 1; }
65 void SetRatio( float ratio
) { m_ratio
= ratio
; }
66 float GetRatio() const { return m_ratio
; }
72 wxWindow
*GetWindow() const
74 wxSizer
*GetSizer() const
82 wxObject
* GetUserData()
83 { return m_userData
; }
93 // als: aspect ratio can always be calculated from m_size,
94 // but this would cause precision loss when the window
95 // is shrinked. it is safer to preserve initial value.
100 //---------------------------------------------------------------------------
102 //---------------------------------------------------------------------------
104 class WXDLLEXPORT wxSizer
: public wxObject
106 DECLARE_CLASS(wxSizer
);
111 virtual void Add( wxWindow
*window
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
112 virtual void Add( wxSizer
*sizer
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
113 virtual void Add( int width
, int height
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
115 virtual void Prepend( wxWindow
*window
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
116 virtual void Prepend( wxSizer
*sizer
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
117 virtual void Prepend( int width
, int height
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
119 virtual bool Remove( wxWindow
*window
);
120 virtual bool Remove( wxSizer
*sizer
);
121 virtual bool Remove( int pos
);
123 void SetDimension( int x
, int y
, int width
, int height
);
127 wxPoint
GetPosition()
128 { return m_position
; }
130 { return CalcMin(); }
132 virtual void RecalcSizes() = 0;
133 virtual wxSize
CalcMin() = 0;
135 virtual void Layout();
137 void Fit( wxWindow
*window
);
138 void SetSizeHints( wxWindow
*window
);
140 wxList
& GetChildren()
141 { return m_children
; }
148 wxSize
GetMinWindowSize( wxWindow
*window
);
151 //---------------------------------------------------------------------------
153 //---------------------------------------------------------------------------
155 class WXDLLEXPORT wxBoxSizer
: public wxSizer
157 DECLARE_CLASS(wxBoxSizer
);
159 wxBoxSizer( int orient
);
176 //---------------------------------------------------------------------------
178 //---------------------------------------------------------------------------
180 class WXDLLEXPORT wxStaticBoxSizer
: public wxBoxSizer
182 DECLARE_CLASS(wxStaticBoxSizer
);
184 wxStaticBoxSizer( wxStaticBox
*box
, int orient
);
189 wxStaticBox
*GetStaticBox()
190 { return m_staticBox
; }
193 wxStaticBox
*m_staticBox
;