]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/sizers.i
Added typemap for wxArrayString
[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 _setOORInfo(PyObject* _self) {
98 self->SetClientObject(new wxPyClientData(_self));
99 }
100 }
101
102 %addmethods {
103 void Destroy() { delete self; }
104
105 void AddWindow(wxWindow *window, 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(window, option, flag, border, data);
110 }
111 void AddSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
112 PyObject* userData=NULL) {
113 wxPyUserData* data = NULL;
114 if (userData) data = new wxPyUserData(userData);
115 self->Add(sizer, option, flag, border, data);
116 }
117 void AddSpacer(int width, int height, int option=0, int flag=0,
118 int border=0, PyObject* userData=NULL) {
119 wxPyUserData* data = NULL;
120 if (userData) data = new wxPyUserData(userData);
121 self->Add(width, height, option, flag, border, data);
122 }
123
124
125 void InsertWindow(int before, wxWindow *window, 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, window, option, flag, border, data);
130 }
131 void InsertSizer(int before, wxSizer *sizer, 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, sizer, option, flag, border, data);
136 }
137 void InsertSpacer(int before, int width, int height, int option=0, int flag=0,
138 int border=0, PyObject* userData=NULL) {
139 wxPyUserData* data = NULL;
140 if (userData) data = new wxPyUserData(userData);
141 self->Insert(before, width, height, option, flag, border, data);
142 }
143
144
145 void PrependWindow(wxWindow *window, 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(window, option, flag, border, data);
150 }
151 void PrependSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
152 PyObject* userData=NULL) {
153 wxPyUserData* data = NULL;
154 if (userData) data = new wxPyUserData(userData);
155 self->Prepend(sizer, option, flag, border, data);
156 }
157 void PrependSpacer(int width, int height, int option=0, int flag=0,
158 int border=0, PyObject* userData=NULL) {
159 wxPyUserData* data = NULL;
160 if (userData) data = new wxPyUserData(userData);
161 self->Prepend(width, height, option, flag, border, data);
162 }
163 }
164
165 %name(RemoveWindow)bool Remove( wxWindow *window );
166 %name(RemoveSizer)bool Remove( wxSizer *sizer );
167 %name(RemovePos)bool Remove( int pos );
168
169
170 %pragma(python) addtoclass = "
171 def Add(self, *args, **kw):
172 if type(args[0]) == type(1):
173 apply(self.AddSpacer, args, kw)
174 elif string.find(args[0].this, 'Sizer') != -1:
175 apply(self.AddSizer, args, kw)
176 else:
177 apply(self.AddWindow, args, kw)
178
179 def Insert(self, *args, **kw):
180 if type(args[1]) == type(1):
181 apply(self.InsertSpacer, args, kw)
182 elif string.find(args[1].this, 'Sizer') != -1:
183 apply(self.InsertSizer, args, kw)
184 else:
185 apply(self.InsertWindow, args, kw)
186
187 def Prepend(self, *args, **kw):
188 if type(args[0]) == type(1):
189 apply(self.PrependSpacer, args, kw)
190 elif string.find(args[0].this, 'Sizer') != -1:
191 apply(self.PrependSizer, args, kw)
192 else:
193 apply(self.PrependWindow, args, kw)
194
195 def Remove(self, *args, **kw):
196 if type(args[0]) == type(1):
197 apply(self.RemovePos, args, kw)
198 elif string.find(args[0].this, 'Sizer') != -1:
199 apply(self.RemoveSizer, args, kw)
200 else:
201 apply(self.RemoveWindow, args, kw)
202
203 def AddMany(self, widgets):
204 for childinfo in widgets:
205 if type(childinfo) != type(()):
206 childinfo = (childinfo, )
207 apply(self.Add, childinfo)
208 "
209
210
211 void SetDimension( int x, int y, int width, int height );
212 void SetMinSize(wxSize size);
213
214 %name(SetItemMinSizeWindow) void SetItemMinSize(wxWindow* window, int width, int height);
215 %name(SetItemMinSizeSizer) void SetItemMinSize(wxSizer* sizer, int width, int height);
216 %name(SetItemMinSizePos) void SetItemMinSize(int pos, int width, int height);
217
218 %pragma(python) addtoclass = "
219 def SetItemMinSize(self, *args):
220 if type(args[0]) == type(1):
221 apply(self.SetItemMinSizePos, args)
222 elif string.find(args[0].this, 'Sizer') != -1:
223 apply(self.SetItemMinSizeSizer, args)
224 else:
225 apply(self.SetItemMinSizeWindow, args)
226 "
227
228 wxSize GetSize();
229 wxPoint GetPosition();
230 wxSize GetMinSize();
231
232 // void RecalcSizes() = 0;
233 // wxSize CalcMin() = 0;
234
235 void Layout();
236
237 void Fit( wxWindow *window );
238 void SetSizeHints( wxWindow *window );
239
240 // wxList& GetChildren();
241 %addmethods {
242 PyObject* GetChildren() {
243 wxList& list = self->GetChildren();
244 return wxPy_ConvertList(&list, "wxSizerItem");
245 }
246 }
247 };
248
249
250 //---------------------------------------------------------------------------
251 // Use this one for deriving Python classes from
252 %{
253 class wxPySizer : public wxSizer {
254 DECLARE_DYNAMIC_CLASS(wxPySizer);
255 public:
256 wxPySizer() : wxSizer() {};
257
258 DEC_PYCALLBACK___pure(RecalcSizes);
259 DEC_PYCALLBACK_wxSize__pure(CalcMin);
260 PYPRIVATE;
261 };
262
263
264 IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
265 IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
266
267 IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
268 %}
269
270
271
272 class wxPySizer : public wxSizer {
273 public:
274 wxPySizer();
275 void _setCallbackInfo(PyObject* self, PyObject* _class);
276 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPySizer)"
277 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
278 };
279
280
281 //---------------------------------------------------------------------------
282
283 class wxBoxSizer : public wxSizer {
284 public:
285 wxBoxSizer(int orient = wxHORIZONTAL);
286 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
287 int GetOrientation();
288 void RecalcSizes();
289 wxSize CalcMin();
290 };
291
292 //---------------------------------------------------------------------------
293
294 class wxStaticBoxSizer : public wxBoxSizer {
295 public:
296 wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL);
297 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
298 wxStaticBox *GetStaticBox();
299 void RecalcSizes();
300 wxSize CalcMin();
301 };
302
303 //---------------------------------------------------------------------------
304
305 class wxNotebookSizer: public wxSizer {
306 public:
307 wxNotebookSizer( wxNotebook *nb );
308 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
309 void RecalcSizes();
310 wxSize CalcMin();
311 wxNotebook *GetNotebook();
312 };
313
314 //---------------------------------------------------------------------------
315
316 class wxGridSizer: public wxSizer
317 {
318 public:
319 wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
320 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
321
322 void RecalcSizes();
323 wxSize CalcMin();
324
325 void SetCols( int cols );
326 void SetRows( int rows );
327 void SetVGap( int gap );
328 void SetHGap( int gap );
329 int GetCols();
330 int GetRows();
331 int GetVGap();
332 int GetHGap();
333 };
334
335 //---------------------------------------------------------------------------
336
337 class wxFlexGridSizer: public wxGridSizer
338 {
339 public:
340 wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
341 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
342
343 void RecalcSizes();
344 wxSize CalcMin();
345
346 void AddGrowableRow( size_t idx );
347 void RemoveGrowableRow( size_t idx );
348 void AddGrowableCol( size_t idx );
349 void RemoveGrowableCol( size_t idx );
350
351 };
352
353 //---------------------------------------------------------------------------