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 //---------------------------------------------------------------------------
35 class wxStaticBoxSizer
;
37 //---------------------------------------------------------------------------
39 //---------------------------------------------------------------------------
41 class WXDLLEXPORT wxSizerItem
: public wxObject
43 DECLARE_CLASS(wxSizerItem
);
46 wxSizerItem( int width
, int height
, int option
, int flag
, int border
, wxObject
* userData
);
49 wxSizerItem( wxWindow
*window
, int option
, int flag
, int border
, wxObject
* userData
);
52 wxSizerItem( wxSizer
*sizer
, int option
, int flag
, int border
, wxObject
* userData
);
56 virtual wxSize
GetSize();
57 virtual wxSize
CalcMin();
58 virtual void SetDimension( wxPoint pos
, wxSize size
);
60 void SetRatio( int width
, int height
)
61 // if either of dimensions is zero, ratio is assumed to be 1
62 // to avoid "divide by zero" errors
63 { m_ratio
= (width
&& height
) ? ((float) width
/ (float) height
) : 1; }
64 void SetRatio( wxSize size
)
65 { m_ratio
= (size
.x
&& size
.y
) ? ((float) size
.x
/ (float) size
.y
) : 1; }
66 void SetRatio( float ratio
) { m_ratio
= ratio
; }
67 float GetRatio() const { return m_ratio
; }
73 void SetInitSize( int x
, int y
)
74 { m_minSize
.x
= x
; m_minSize
.y
= y
; }
75 void SetOption( int option
)
76 { m_option
= option
; }
77 void SetFlag( int flag
)
79 void SetBorder( int border
)
80 { m_border
= border
; }
82 wxWindow
*GetWindow() const
84 wxSizer
*GetSizer() const
92 wxObject
* GetUserData()
93 { return m_userData
; }
103 // als: aspect ratio can always be calculated from m_size,
104 // but this would cause precision loss when the window
105 // is shrinked. it is safer to preserve initial value.
107 wxObject
*m_userData
;
110 //---------------------------------------------------------------------------
112 //---------------------------------------------------------------------------
114 class WXDLLEXPORT wxSizer
: public wxObject
116 DECLARE_CLASS(wxSizer
);
121 virtual void Add( wxWindow
*window
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
122 virtual void Add( wxSizer
*sizer
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
123 virtual void Add( int width
, int height
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
125 virtual void Prepend( wxWindow
*window
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
126 virtual void Prepend( wxSizer
*sizer
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
127 virtual void Prepend( int width
, int height
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
129 virtual bool Remove( wxWindow
*window
);
130 virtual bool Remove( wxSizer
*sizer
);
131 virtual bool Remove( int pos
);
133 void SetDimension( int x
, int y
, int width
, int height
);
137 wxPoint
GetPosition()
138 { return m_position
; }
140 { return CalcMin(); }
142 virtual void RecalcSizes() = 0;
143 virtual wxSize
CalcMin() = 0;
145 virtual void Layout();
147 void Fit( wxWindow
*window
);
148 void SetSizeHints( wxWindow
*window
);
150 wxList
& GetChildren()
151 { return m_children
; }
158 wxSize
GetMinWindowSize( wxWindow
*window
);
161 //---------------------------------------------------------------------------
163 //---------------------------------------------------------------------------
165 class WXDLLEXPORT wxBoxSizer
: public wxSizer
167 DECLARE_CLASS(wxBoxSizer
);
169 wxBoxSizer( int orient
);
186 //---------------------------------------------------------------------------
188 //---------------------------------------------------------------------------
190 class WXDLLEXPORT wxStaticBoxSizer
: public wxBoxSizer
192 DECLARE_CLASS(wxStaticBoxSizer
);
194 wxStaticBoxSizer( wxStaticBox
*box
, int orient
);
199 wxStaticBox
*GetStaticBox()
200 { return m_staticBox
; }
203 wxStaticBox
*m_staticBox
;
206 //---------------------------------------------------------------------------
208 //---------------------------------------------------------------------------
212 class WXDLLEXPORT wxNotebookSizer
: public wxSizer
214 DECLARE_CLASS(wxNotebookSizer
);
216 wxNotebookSizer( wxNotebook
*nb
);
221 wxNotebook
*GetNotebook()
222 { return m_notebook
; }
225 wxNotebook
*m_notebook
;