]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/sizers.i
An incorrect patch to SWIG caused incorrect generated code. Fixed and regenerated.
[wxWidgets.git] / wxPython / src / sizers.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: sizers.i
3 // Purpose: SWIG definitions of the wxSizer family of classes
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 18-Sept-1999
8 // RCS-ID: $Id$
9 // Copyright: (c) 1999 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %module sizers
14
15 %{
16 #include "helpers.h"
17
18 #include <wx/notebook.h>
19 %}
20
21 //----------------------------------------------------------------------
22
23 %include typemaps.i
24 %include my_typemaps.i
25
26 // Import some definitions of other classes, etc.
27 %import _defs.i
28 %import misc.i
29 %import windows.i
30 %import controls.i
31
32 %pragma(python) code = "import wx"
33 %pragma(python) code = "import string"
34
35 //---------------------------------------------------------------------------
36
37
38 class wxSizerItem : public wxObject {
39 public:
40 // No need to ever create one directly in Python...
41
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 );
45
46 wxPoint GetPosition();
47 wxSize GetSize();
48 wxSize CalcMin();
49 void SetDimension( wxPoint pos, wxSize size );
50 %name(SetRatioWH) void SetRatio( int width, int height );
51 %name(SetRatioSize) void SetRatio( wxSize size );
52 void SetRatio( float ratio );
53 float GetRatio();
54
55 bool IsWindow();
56 bool IsSizer();
57 bool IsSpacer();
58
59 wxWindow *GetWindow();
60 void SetWindow( wxWindow *window );
61 wxSizer *GetSizer();
62 void SetSizer( wxSizer *sizer );
63 int GetOption();
64 int GetFlag();
65 int GetBorder();
66
67 void SetInitSize( int x, int y );
68 void SetOption( int option );
69 void SetFlag( int flag );
70 void SetBorder( int border );
71
72 // wxObject* GetUserData();
73 %addmethods {
74 // Assume that the user data is a wxPyUserData object and return the contents
75 PyObject* GetUserData() {
76 wxPyUserData* data = (wxPyUserData*)self->GetUserData();
77 if (data) {
78 Py_INCREF(data->m_obj);
79 return data->m_obj;
80 } else {
81 Py_INCREF(Py_None);
82 return Py_None;
83 }
84 }
85 }
86 };
87
88
89 //---------------------------------------------------------------------------
90
91 class wxSizer : public wxObject {
92 public:
93 // wxSizer(); **** abstract, can't instantiate
94 // ~wxSizer();
95
96 %addmethods {
97 void Destroy() { delete self; }
98
99 void AddWindow(wxWindow *window, int option=0, int flag=0, int border=0,
100 PyObject* userData=NULL) {
101 wxPyUserData* data = NULL;
102 if (userData) data = new wxPyUserData(userData);
103 self->Add(window, option, flag, border, data);
104 }
105 void AddSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
106 PyObject* userData=NULL) {
107 wxPyUserData* data = NULL;
108 if (userData) data = new wxPyUserData(userData);
109 self->Add(sizer, option, flag, border, data);
110 }
111 void AddSpacer(int width, int height, int option=0, int flag=0,
112 int border=0, PyObject* userData=NULL) {
113 wxPyUserData* data = NULL;
114 if (userData) data = new wxPyUserData(userData);
115 self->Add(width, height, option, flag, border, data);
116 }
117
118
119 void InsertWindow(int before, wxWindow *window, int option=0, int flag=0,
120 int border=0, PyObject* userData=NULL) {
121 wxPyUserData* data = NULL;
122 if (userData) data = new wxPyUserData(userData);
123 self->Insert(before, window, option, flag, border, data);
124 }
125 void InsertSizer(int before, wxSizer *sizer, int option=0, int flag=0,
126 int border=0, PyObject* userData=NULL) {
127 wxPyUserData* data = NULL;
128 if (userData) data = new wxPyUserData(userData);
129 self->Insert(before, sizer, option, flag, border, data);
130 }
131 void InsertSpacer(int before, int width, int height, int option=0, int flag=0,
132 int border=0, PyObject* userData=NULL) {
133 wxPyUserData* data = NULL;
134 if (userData) data = new wxPyUserData(userData);
135 self->Insert(before, width, height, option, flag, border, data);
136 }
137
138
139 void PrependWindow(wxWindow *window, int option=0, int flag=0, int border=0,
140 PyObject* userData=NULL) {
141 wxPyUserData* data = NULL;
142 if (userData) data = new wxPyUserData(userData);
143 self->Prepend(window, option, flag, border, data);
144 }
145 void PrependSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
146 PyObject* userData=NULL) {
147 wxPyUserData* data = NULL;
148 if (userData) data = new wxPyUserData(userData);
149 self->Prepend(sizer, option, flag, border, data);
150 }
151 void PrependSpacer(int width, int height, int option=0, int flag=0,
152 int border=0, PyObject* userData=NULL) {
153 wxPyUserData* data = NULL;
154 if (userData) data = new wxPyUserData(userData);
155 self->Prepend(width, height, option, flag, border, data);
156 }
157 }
158
159 %name(RemoveWindow)bool Remove( wxWindow *window );
160 %name(RemoveSizer)bool Remove( wxSizer *sizer );
161 %name(RemovePos)bool Remove( int pos );
162
163
164 %pragma(python) addtoclass = "
165 def Add(self, *args, **kw):
166 if type(args[0]) == type(1):
167 apply(self.AddSpacer, args, kw)
168 elif string.find(args[0].this, 'Sizer') != -1:
169 apply(self.AddSizer, args, kw)
170 else:
171 apply(self.AddWindow, args, kw)
172
173 def Insert(self, *args, **kw):
174 if type(args[1]) == type(1):
175 apply(self.InsertSpacer, args, kw)
176 elif string.find(args[1].this, 'Sizer') != -1:
177 apply(self.InsertSizer, args, kw)
178 else:
179 apply(self.InsertWindow, args, kw)
180
181 def Prepend(self, *args, **kw):
182 if type(args[0]) == type(1):
183 apply(self.PrependSpacer, args, kw)
184 elif string.find(args[0].this, 'Sizer') != -1:
185 apply(self.PrependSizer, args, kw)
186 else:
187 apply(self.PrependWindow, args, kw)
188
189 def Remove(self, *args, **kw):
190 if type(args[0]) == type(1):
191 apply(self.RemovePos, args, kw)
192 elif string.find(args[0].this, 'Sizer') != -1:
193 apply(self.RemoveSizer, args, kw)
194 else:
195 apply(self.RemoveWindow, args, kw)
196
197 def AddMany(self, widgets):
198 for childinfo in widgets:
199 if type(childinfo) != type(()):
200 childinfo = (childinfo, )
201 apply(self.Add, childinfo)
202 "
203
204
205 void SetDimension( int x, int y, int width, int height );
206 void SetMinSize(wxSize size);
207
208 %name(SetItemMinSizeWindow) void SetItemMinSize(wxWindow* window, int width, int height);
209 %name(SetItemMinSizeSizer) void SetItemMinSize(wxSizer* sizer, int width, int height);
210 %name(SetItemMinSizePos) void SetItemMinSize(int pos, int width, int height);
211
212 %pragma(python) addtoclass = "
213 def SetItemMinSize(self, *args):
214 if type(args[0]) == type(1):
215 apply(self.SetItemMinSizePos, args)
216 elif string.find(args[0].this, 'Sizer') != -1:
217 apply(self.SetItemMinSizeSizer, args)
218 else:
219 apply(self.SetItemMinSizeWindow, args)
220 "
221
222 wxSize GetSize();
223 wxPoint GetPosition();
224 wxSize GetMinSize();
225
226 // void RecalcSizes() = 0;
227 // wxSize CalcMin() = 0;
228
229 void Layout();
230
231 void Fit( wxWindow *window );
232 void SetSizeHints( wxWindow *window );
233
234 // wxList& GetChildren();
235 %addmethods {
236 PyObject* GetChildren() {
237 wxList& list = self->GetChildren();
238 return wxPy_ConvertList(&list, "wxSizerItem");
239 }
240 }
241 };
242
243
244 //---------------------------------------------------------------------------
245 // Use this one for deriving Python classes from
246 %{
247 class wxPySizer : public wxSizer {
248 DECLARE_DYNAMIC_CLASS(wxPySizer);
249 public:
250 wxPySizer() : wxSizer() {};
251
252 DEC_PYCALLBACK___pure(RecalcSizes);
253 DEC_PYCALLBACK_wxSize__pure(CalcMin);
254 PYPRIVATE;
255 };
256
257
258 IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
259 IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
260
261 IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
262 %}
263
264
265
266 class wxPySizer : public wxSizer {
267 public:
268 wxPySizer();
269 void _setCallbackInfo(PyObject* self, PyObject* _class);
270 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPySizer)"
271 };
272
273
274 //---------------------------------------------------------------------------
275
276 class wxBoxSizer : public wxSizer {
277 public:
278 wxBoxSizer(int orient = wxHORIZONTAL);
279 int GetOrientation();
280 void RecalcSizes();
281 wxSize CalcMin();
282 };
283
284 //---------------------------------------------------------------------------
285
286 class wxStaticBoxSizer : public wxBoxSizer {
287 public:
288 wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL);
289 wxStaticBox *GetStaticBox();
290 void RecalcSizes();
291 wxSize CalcMin();
292 };
293
294 //---------------------------------------------------------------------------
295
296 class wxNotebookSizer: public wxSizer {
297 public:
298 wxNotebookSizer( wxNotebook *nb );
299
300 void RecalcSizes();
301 wxSize CalcMin();
302
303 wxNotebook *GetNotebook();
304 };
305
306 //---------------------------------------------------------------------------
307
308 class wxGridSizer: public wxSizer
309 {
310 public:
311 wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
312
313 void RecalcSizes();
314 wxSize CalcMin();
315
316 void SetCols( int cols );
317 void SetRows( int rows );
318 void SetVGap( int gap );
319 void SetHGap( int gap );
320 int GetCols();
321 int GetRows();
322 int GetVGap();
323 int GetHGap();
324 };
325
326 //---------------------------------------------------------------------------
327
328 class wxFlexGridSizer: public wxGridSizer
329 {
330 public:
331 wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
332
333 void RecalcSizes();
334 wxSize CalcMin();
335
336 void AddGrowableRow( size_t idx );
337 void RemoveGrowableRow( size_t idx );
338 void AddGrowableCol( size_t idx );
339 void RemoveGrowableCol( size_t idx );
340
341 };
342
343 //---------------------------------------------------------------------------