1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions of the wxSizer family of classes
7 // Created: 18-Sept-1999
9 // Copyright: (c) 1999 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/notebook.h>
21 //----------------------------------------------------------------------
24 %include my_typemaps.i
26 // Import some definitions of other classes, etc.
32 %pragma(python) code = "import wx"
33 %pragma(python) code = "import string"
35 //---------------------------------------------------------------------------
38 class wxSizerItem : public wxObject {
40 // No need to ever create one directly in Python...
42 //wxSizerItem( int width, int height, int option, int flag, int border, wxObject* userData);
43 //wxSizerItem( wxWindow *window, int option, int flag, int border, wxObject* userData );
44 //wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxObject* userData );
48 void SetDimension( wxPoint pos, wxSize size );
49 %name(SetRatioWH) void SetRatio( int width, int height );
50 %name(SetRatioSize) void SetRatio( wxSize size );
51 void SetRatio( float ratio );
58 wxWindow *GetWindow();
59 void SetWindow( wxWindow *window );
61 void SetSizer( wxSizer *sizer );
66 void SetInitSize( int x, int y );
67 void SetOption( int option );
68 void SetFlag( int flag );
69 void SetBorder( int border );
71 // wxObject* GetUserData();
73 // Assume that the user data is a wxPyUserData object and return the contents
74 PyObject* GetUserData() {
75 wxPyUserData* data = (wxPyUserData*)self->GetUserData();
77 Py_INCREF(data->m_obj);
88 //---------------------------------------------------------------------------
90 class wxSizer : public wxObject {
92 // wxSizer(); **** abstract, can't instantiate
96 void Destroy() { delete self; }
98 void AddWindow(wxWindow *window, int option=0, int flag=0, int border=0,
99 PyObject* userData=NULL) {
100 wxPyUserData* data = NULL;
101 if (userData) data = new wxPyUserData(userData);
102 self->Add(window, option, flag, border, data);
104 void AddSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
105 PyObject* userData=NULL) {
106 wxPyUserData* data = NULL;
107 if (userData) data = new wxPyUserData(userData);
108 self->Add(sizer, option, flag, border, data);
110 void AddSpacer(int width, int height, int option=0, int flag=0,
111 int border=0, PyObject* userData=NULL) {
112 wxPyUserData* data = NULL;
113 if (userData) data = new wxPyUserData(userData);
114 self->Add(width, height, option, flag, border, data);
118 void InsertWindow(int before, wxWindow *window, int option=0, int flag=0,
119 int border=0, PyObject* userData=NULL) {
120 wxPyUserData* data = NULL;
121 if (userData) data = new wxPyUserData(userData);
122 self->Insert(before, window, option, flag, border, data);
124 void InsertSizer(int before, wxSizer *sizer, int option=0, int flag=0,
125 int border=0, PyObject* userData=NULL) {
126 wxPyUserData* data = NULL;
127 if (userData) data = new wxPyUserData(userData);
128 self->Insert(before, sizer, option, flag, border, data);
130 void InsertSpacer(int before, int width, int height, int option=0, int flag=0,
131 int border=0, PyObject* userData=NULL) {
132 wxPyUserData* data = NULL;
133 if (userData) data = new wxPyUserData(userData);
134 self->Insert(before, width, height, option, flag, border, data);
138 void PrependWindow(wxWindow *window, int option=0, int flag=0, int border=0,
139 PyObject* userData=NULL) {
140 wxPyUserData* data = NULL;
141 if (userData) data = new wxPyUserData(userData);
142 self->Prepend(window, option, flag, border, data);
144 void PrependSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
145 PyObject* userData=NULL) {
146 wxPyUserData* data = NULL;
147 if (userData) data = new wxPyUserData(userData);
148 self->Prepend(sizer, option, flag, border, data);
150 void PrependSpacer(int width, int height, int option=0, int flag=0,
151 int border=0, PyObject* userData=NULL) {
152 wxPyUserData* data = NULL;
153 if (userData) data = new wxPyUserData(userData);
154 self->Prepend(width, height, option, flag, border, data);
158 %name(RemoveWindow)bool Remove( wxWindow *window );
159 %name(RemoveSizer)bool Remove( wxSizer *sizer );
160 %name(RemovePos)bool Remove( int pos );
163 %pragma(python) addtoclass = "
164 def Add(self, *args, **kw):
165 if type(args[0]) == type(1):
166 apply(self.AddSpacer, args, kw)
167 elif string.find(args[0].this, 'Sizer') != -1:
168 apply(self.AddSizer, args, kw)
170 apply(self.AddWindow, args, kw)
172 def Insert(self, *args, **kw):
173 if type(args[1]) == type(1):
174 apply(self.InsertSpacer, args, kw)
175 elif string.find(args[1].this, 'Sizer') != -1:
176 apply(self.InsertSizer, args, kw)
178 apply(self.InsertWindow, args, kw)
180 def Prepend(self, *args, **kw):
181 if type(args[0]) == type(1):
182 apply(self.PrependSpacer, args, kw)
183 elif string.find(args[0].this, 'Sizer') != -1:
184 apply(self.PrependSizer, args, kw)
186 apply(self.PrependWindow, args, kw)
188 def Remove(self, *args, **kw):
189 if type(args[0]) == type(1):
190 apply(self.RemovePos, args, kw)
191 elif string.find(args[0].this, 'Sizer') != -1:
192 apply(self.RemoveSizer, args, kw)
194 apply(self.RemoveWindow, args, kw)
196 def AddMany(self, widgets):
197 for childinfo in widgets:
198 if type(childinfo) != type(()):
199 childinfo = (childinfo, )
200 apply(self.Add, childinfo)
204 void SetDimension( int x, int y, int width, int height );
205 void SetMinSize(wxSize size);
207 %name(SetItemMinSizeWindow) void SetItemMinSize(wxWindow* window, int width, int height);
208 %name(SetItemMinSizeSizer) void SetItemMinSize(wxSizer* sizer, int width, int height);
209 %name(SetItemMinSizePos) void SetItemMinSize(int pos, int width, int height);
211 %pragma(python) addtoclass = "
212 def SetItemMinSize(self, *args):
213 if type(args[0]) == type(1):
214 apply(self.SetItemMinSizePos, args)
215 elif string.find(args[0].this, 'Sizer') != -1:
216 apply(self.SetItemMinSizeSizer, args)
218 apply(self.SetItemMinSizeWindow, args)
222 wxPoint GetPosition();
225 // void RecalcSizes() = 0;
226 // wxSize CalcMin() = 0;
230 void Fit( wxWindow *window );
231 void SetSizeHints( wxWindow *window );
233 // wxList& GetChildren();
235 PyObject* GetChildren() {
236 wxList& list = self->GetChildren();
237 return wxPy_ConvertList(&list, "wxSizerItem");
243 //---------------------------------------------------------------------------
244 // Use this one for deriving Python classes from
246 class wxPySizer : public wxSizer {
247 DECLARE_DYNAMIC_CLASS(wxPySizer);
249 wxPySizer() : wxSizer() {};
251 DEC_PYCALLBACK___pure(RecalcSizes);
252 DEC_PYCALLBACK_wxSize__pure(CalcMin);
257 IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
258 IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
260 IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
265 class wxPySizer : public wxSizer {
268 void _setSelf(PyObject* self, PyObject* _class);
269 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPySizer)"
273 //---------------------------------------------------------------------------
275 class wxBoxSizer : public wxSizer {
277 wxBoxSizer(int orient = wxHORIZONTAL);
278 int GetOrientation();
283 //---------------------------------------------------------------------------
285 class wxStaticBoxSizer : public wxBoxSizer {
287 wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL);
288 wxStaticBox *GetStaticBox();
293 //---------------------------------------------------------------------------
295 class wxNotebookSizer: public wxSizer {
297 wxNotebookSizer( wxNotebook *nb );
302 wxNotebook *GetNotebook();
305 //---------------------------------------------------------------------------
307 class wxGridSizer: public wxSizer
310 wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
315 void SetCols( int cols );
316 void SetRows( int rows );
317 void SetVGap( int gap );
318 void SetHGap( int gap );
325 //---------------------------------------------------------------------------
327 class wxFlexGridSizer: public wxGridSizer
330 wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
335 void AddGrowableRow( size_t idx );
336 void RemoveGrowableRow( size_t idx );
337 void AddGrowableCol( size_t idx );
338 void RemoveGrowableCol( size_t idx );
342 //---------------------------------------------------------------------------