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 Insert( int before
, wxWindow
*window
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
126 virtual void Insert( int before
, wxSizer
*sizer
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
127 virtual void Insert( int before
, int width
, int height
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
129 virtual void Prepend( wxWindow
*window
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
130 virtual void Prepend( wxSizer
*sizer
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
131 virtual void Prepend( int width
, int height
, int option
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
);
133 virtual bool Remove( wxWindow
*window
);
134 virtual bool Remove( wxSizer
*sizer
);
135 virtual bool Remove( int pos
);
137 void SetDimension( int x
, int y
, int width
, int height
);
141 wxPoint
GetPosition()
142 { return m_position
; }
144 { return CalcMin(); }
146 virtual void RecalcSizes() = 0;
147 virtual wxSize
CalcMin() = 0;
149 virtual void Layout();
151 void Fit( wxWindow
*window
);
152 void SetSizeHints( wxWindow
*window
);
154 wxList
& GetChildren()
155 { return m_children
; }
162 wxSize
GetMinWindowSize( wxWindow
*window
);
165 //---------------------------------------------------------------------------
167 //---------------------------------------------------------------------------
169 class WXDLLEXPORT wxBoxSizer
: public wxSizer
171 DECLARE_CLASS(wxBoxSizer
);
173 wxBoxSizer( int orient
);
190 //---------------------------------------------------------------------------
192 //---------------------------------------------------------------------------
194 class WXDLLEXPORT wxStaticBoxSizer
: public wxBoxSizer
196 DECLARE_CLASS(wxStaticBoxSizer
);
198 wxStaticBoxSizer( wxStaticBox
*box
, int orient
);
203 wxStaticBox
*GetStaticBox()
204 { return m_staticBox
; }
207 wxStaticBox
*m_staticBox
;
210 //---------------------------------------------------------------------------
212 //---------------------------------------------------------------------------
216 class WXDLLEXPORT wxNotebookSizer
: public wxSizer
218 DECLARE_CLASS(wxNotebookSizer
);
220 wxNotebookSizer( wxNotebook
*nb
);
225 wxNotebook
*GetNotebook()
226 { return m_notebook
; }
229 wxNotebook
*m_notebook
;