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 wxWindow
*GetWindow() const
75 wxSizer
*GetSizer() const
83 wxObject
* GetUserData()
84 { return m_userData
; }
94 // als: aspect ratio can always be calculated from m_size,
95 // but this would cause precision loss when the window
96 // is shrinked. it is safer to preserve initial value.
101 //---------------------------------------------------------------------------
103 //---------------------------------------------------------------------------
105 class WXDLLEXPORT wxSizer
: public wxObject
107 DECLARE_CLASS(wxSizer
);
112 virtual void Add( wxWindow
*window
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
113 virtual void Add( wxSizer
*sizer
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
114 virtual void Add( int width
, int height
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
116 virtual void Prepend( wxWindow
*window
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
117 virtual void Prepend( wxSizer
*sizer
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
118 virtual void Prepend( int width
, int height
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
120 virtual bool Remove( wxWindow
*window
);
121 virtual bool Remove( wxSizer
*sizer
);
122 virtual bool Remove( int pos
);
124 void SetDimension( int x
, int y
, int width
, int height
);
128 wxPoint
GetPosition()
129 { return m_position
; }
131 { return CalcMin(); }
133 virtual void RecalcSizes() = 0;
134 virtual wxSize
CalcMin() = 0;
136 virtual void Layout();
138 void Fit( wxWindow
*window
);
139 void SetSizeHints( wxWindow
*window
);
141 wxList
& GetChildren()
142 { return m_children
; }
149 wxSize
GetMinWindowSize( wxWindow
*window
);
152 //---------------------------------------------------------------------------
154 //---------------------------------------------------------------------------
156 class WXDLLEXPORT wxBoxSizer
: public wxSizer
158 DECLARE_CLASS(wxBoxSizer
);
160 wxBoxSizer( int orient
);
177 //---------------------------------------------------------------------------
179 //---------------------------------------------------------------------------
181 class WXDLLEXPORT wxStaticBoxSizer
: public wxBoxSizer
183 DECLARE_CLASS(wxStaticBoxSizer
);
185 wxStaticBoxSizer( wxStaticBox
*box
, int orient
);
190 wxStaticBox
*GetStaticBox()
191 { return m_staticBox
; }
194 wxStaticBox
*m_staticBox
;
197 //---------------------------------------------------------------------------
199 //---------------------------------------------------------------------------
203 class WXDLLEXPORT wxNotebookSizer
: public wxSizer
205 DECLARE_CLASS(wxNotebookSizer
);
207 wxNotebookSizer( wxNotebook
*nb
);
212 wxNotebook
*GetNotebook()
213 { return m_notebook
; }
216 wxNotebook
*m_notebook
;