]>
Commit | Line | Data |
---|---|---|
2f90df85 RD |
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$ | |
f0261a72 | 9 | // Copyright: (c) 1999 by Total Control Software |
2f90df85 RD |
10 | // Licence: wxWindows license |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | %module sizers | |
14 | ||
15 | %{ | |
16 | #include "helpers.h" | |
9416aa89 RD |
17 | |
18 | #include <wx/notebook.h> | |
2f90df85 RD |
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 | ||
2f90df85 | 37 | |
9416aa89 | 38 | class wxSizerItem : public wxObject { |
2f90df85 RD |
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 | ||
101dd79a RD |
46 | void DeleteWindows(); |
47 | ||
09f3d4e6 | 48 | wxPoint GetPosition(); |
2f90df85 RD |
49 | wxSize GetSize(); |
50 | wxSize CalcMin(); | |
51 | void SetDimension( wxPoint pos, wxSize size ); | |
f6bcfd97 BP |
52 | %name(SetRatioWH) void SetRatio( int width, int height ); |
53 | %name(SetRatioSize) void SetRatio( wxSize size ); | |
54 | void SetRatio( float ratio ); | |
55 | float GetRatio(); | |
2f90df85 RD |
56 | |
57 | bool IsWindow(); | |
58 | bool IsSizer(); | |
59 | bool IsSpacer(); | |
60 | ||
61 | wxWindow *GetWindow(); | |
f6bcfd97 | 62 | void SetWindow( wxWindow *window ); |
2f90df85 | 63 | wxSizer *GetSizer(); |
f6bcfd97 | 64 | void SetSizer( wxSizer *sizer ); |
2f90df85 RD |
65 | int GetOption(); |
66 | int GetFlag(); | |
67 | int GetBorder(); | |
68 | ||
9b3d3bc4 RD |
69 | void SetInitSize( int x, int y ); |
70 | void SetOption( int option ); | |
71 | void SetFlag( int flag ); | |
72 | void SetBorder( int border ); | |
73 | ||
2f90df85 RD |
74 | // wxObject* GetUserData(); |
75 | %addmethods { | |
76 | // Assume that the user data is a wxPyUserData object and return the contents | |
77 | PyObject* GetUserData() { | |
78 | wxPyUserData* data = (wxPyUserData*)self->GetUserData(); | |
79 | if (data) { | |
80 | Py_INCREF(data->m_obj); | |
81 | return data->m_obj; | |
82 | } else { | |
83 | Py_INCREF(Py_None); | |
84 | return Py_None; | |
85 | } | |
86 | } | |
87 | } | |
88 | }; | |
89 | ||
90 | ||
91 | //--------------------------------------------------------------------------- | |
92 | ||
9416aa89 | 93 | class wxSizer : public wxObject { |
2f90df85 RD |
94 | public: |
95 | // wxSizer(); **** abstract, can't instantiate | |
96 | // ~wxSizer(); | |
97 | ||
2aab8f16 RD |
98 | %addmethods { |
99 | void _setOORInfo(PyObject* _self) { | |
4acff284 | 100 | self->SetClientObject(new wxPyOORClientData(_self)); |
2aab8f16 RD |
101 | } |
102 | } | |
103 | ||
2f90df85 RD |
104 | %addmethods { |
105 | void Destroy() { delete self; } | |
106 | ||
107 | void AddWindow(wxWindow *window, int option=0, int flag=0, int border=0, | |
108 | PyObject* userData=NULL) { | |
109 | wxPyUserData* data = NULL; | |
110 | if (userData) data = new wxPyUserData(userData); | |
111 | self->Add(window, option, flag, border, data); | |
112 | } | |
2f90df85 RD |
113 | void AddSizer(wxSizer *sizer, int option=0, int flag=0, int border=0, |
114 | PyObject* userData=NULL) { | |
115 | wxPyUserData* data = NULL; | |
116 | if (userData) data = new wxPyUserData(userData); | |
117 | self->Add(sizer, option, flag, border, data); | |
118 | } | |
2f90df85 RD |
119 | void AddSpacer(int width, int height, 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->Add(width, height, option, flag, border, data); | |
124 | } | |
125 | ||
126 | ||
f6bcfd97 BP |
127 | void InsertWindow(int before, wxWindow *window, int option=0, int flag=0, |
128 | int border=0, PyObject* userData=NULL) { | |
129 | wxPyUserData* data = NULL; | |
130 | if (userData) data = new wxPyUserData(userData); | |
131 | self->Insert(before, window, option, flag, border, data); | |
132 | } | |
133 | void InsertSizer(int before, wxSizer *sizer, int option=0, int flag=0, | |
134 | int border=0, PyObject* userData=NULL) { | |
135 | wxPyUserData* data = NULL; | |
136 | if (userData) data = new wxPyUserData(userData); | |
137 | self->Insert(before, sizer, option, flag, border, data); | |
138 | } | |
139 | void InsertSpacer(int before, int width, int height, int option=0, int flag=0, | |
140 | int border=0, PyObject* userData=NULL) { | |
141 | wxPyUserData* data = NULL; | |
142 | if (userData) data = new wxPyUserData(userData); | |
143 | self->Insert(before, width, height, option, flag, border, data); | |
144 | } | |
145 | ||
146 | ||
2f90df85 RD |
147 | void PrependWindow(wxWindow *window, int option=0, int flag=0, int border=0, |
148 | PyObject* userData=NULL) { | |
149 | wxPyUserData* data = NULL; | |
150 | if (userData) data = new wxPyUserData(userData); | |
151 | self->Prepend(window, option, flag, border, data); | |
152 | } | |
2f90df85 RD |
153 | void PrependSizer(wxSizer *sizer, int option=0, int flag=0, int border=0, |
154 | PyObject* userData=NULL) { | |
155 | wxPyUserData* data = NULL; | |
156 | if (userData) data = new wxPyUserData(userData); | |
157 | self->Prepend(sizer, option, flag, border, data); | |
158 | } | |
2f90df85 RD |
159 | void PrependSpacer(int width, int height, int option=0, int flag=0, |
160 | int border=0, PyObject* userData=NULL) { | |
161 | wxPyUserData* data = NULL; | |
162 | if (userData) data = new wxPyUserData(userData); | |
163 | self->Prepend(width, height, option, flag, border, data); | |
164 | } | |
165 | } | |
166 | ||
167 | %name(RemoveWindow)bool Remove( wxWindow *window ); | |
168 | %name(RemoveSizer)bool Remove( wxSizer *sizer ); | |
169 | %name(RemovePos)bool Remove( int pos ); | |
170 | ||
171 | ||
172 | %pragma(python) addtoclass = " | |
d1679124 | 173 | def Add(self, *args, **kw): |
2f90df85 | 174 | if type(args[0]) == type(1): |
d1679124 | 175 | apply(self.AddSpacer, args, kw) |
2f90df85 | 176 | elif string.find(args[0].this, 'Sizer') != -1: |
d1679124 | 177 | apply(self.AddSizer, args, kw) |
2f90df85 | 178 | else: |
d1679124 | 179 | apply(self.AddWindow, args, kw) |
2f90df85 | 180 | |
d1679124 | 181 | def Insert(self, *args, **kw): |
c368d904 | 182 | if type(args[1]) == type(1): |
d1679124 | 183 | apply(self.InsertSpacer, args, kw) |
c368d904 | 184 | elif string.find(args[1].this, 'Sizer') != -1: |
d1679124 | 185 | apply(self.InsertSizer, args, kw) |
f6bcfd97 | 186 | else: |
d1679124 | 187 | apply(self.InsertWindow, args, kw) |
f6bcfd97 | 188 | |
d1679124 | 189 | def Prepend(self, *args, **kw): |
2f90df85 | 190 | if type(args[0]) == type(1): |
d1679124 | 191 | apply(self.PrependSpacer, args, kw) |
2f90df85 | 192 | elif string.find(args[0].this, 'Sizer') != -1: |
d1679124 | 193 | apply(self.PrependSizer, args, kw) |
2f90df85 | 194 | else: |
d1679124 | 195 | apply(self.PrependWindow, args, kw) |
2f90df85 | 196 | |
d1679124 | 197 | def Remove(self, *args, **kw): |
2f90df85 | 198 | if type(args[0]) == type(1): |
d1679124 | 199 | apply(self.RemovePos, args, kw) |
2f90df85 | 200 | elif string.find(args[0].this, 'Sizer') != -1: |
d1679124 | 201 | apply(self.RemoveSizer, args, kw) |
2f90df85 | 202 | else: |
d1679124 | 203 | apply(self.RemoveWindow, args, kw) |
2f90df85 RD |
204 | |
205 | def AddMany(self, widgets): | |
206 | for childinfo in widgets: | |
207 | if type(childinfo) != type(()): | |
208 | childinfo = (childinfo, ) | |
209 | apply(self.Add, childinfo) | |
210 | " | |
211 | ||
212 | ||
213 | void SetDimension( int x, int y, int width, int height ); | |
f6bcfd97 BP |
214 | void SetMinSize(wxSize size); |
215 | ||
216 | %name(SetItemMinSizeWindow) void SetItemMinSize(wxWindow* window, int width, int height); | |
217 | %name(SetItemMinSizeSizer) void SetItemMinSize(wxSizer* sizer, int width, int height); | |
218 | %name(SetItemMinSizePos) void SetItemMinSize(int pos, int width, int height); | |
219 | ||
220 | %pragma(python) addtoclass = " | |
221 | def SetItemMinSize(self, *args): | |
222 | if type(args[0]) == type(1): | |
223 | apply(self.SetItemMinSizePos, args) | |
224 | elif string.find(args[0].this, 'Sizer') != -1: | |
225 | apply(self.SetItemMinSizeSizer, args) | |
226 | else: | |
227 | apply(self.SetItemMinSizeWindow, args) | |
228 | " | |
2f90df85 RD |
229 | |
230 | wxSize GetSize(); | |
231 | wxPoint GetPosition(); | |
232 | wxSize GetMinSize(); | |
233 | ||
82550f23 RD |
234 | %pragma(python) addtoclass = " |
235 | def GetSizeTuple(self): | |
236 | return self.GetSize().asTuple() | |
237 | def GetPositionTuple(self): | |
238 | return self.GetPosition().asTuple() | |
239 | def GetMinSizeTuple(self): | |
240 | return self.GetMinSize().asTuple() | |
241 | " | |
242 | ||
2f90df85 RD |
243 | // void RecalcSizes() = 0; |
244 | // wxSize CalcMin() = 0; | |
245 | ||
246 | void Layout(); | |
247 | ||
248 | void Fit( wxWindow *window ); | |
249 | void SetSizeHints( wxWindow *window ); | |
250 | ||
101dd79a RD |
251 | void Clear( bool delete_windows=FALSE ); |
252 | void DeleteWindows(); | |
253 | ||
254 | ||
2f90df85 RD |
255 | // wxList& GetChildren(); |
256 | %addmethods { | |
257 | PyObject* GetChildren() { | |
258 | wxList& list = self->GetChildren(); | |
259 | return wxPy_ConvertList(&list, "wxSizerItem"); | |
260 | } | |
261 | } | |
262 | }; | |
263 | ||
264 | ||
265 | //--------------------------------------------------------------------------- | |
266 | // Use this one for deriving Python classes from | |
267 | %{ | |
268 | class wxPySizer : public wxSizer { | |
269 | DECLARE_DYNAMIC_CLASS(wxPySizer); | |
270 | public: | |
271 | wxPySizer() : wxSizer() {}; | |
272 | ||
273 | DEC_PYCALLBACK___pure(RecalcSizes); | |
274 | DEC_PYCALLBACK_wxSize__pure(CalcMin); | |
275 | PYPRIVATE; | |
276 | }; | |
277 | ||
278 | ||
279 | IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes); | |
280 | IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin); | |
281 | ||
282 | IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer); | |
283 | %} | |
284 | ||
285 | ||
286 | ||
287 | class wxPySizer : public wxSizer { | |
288 | public: | |
289 | wxPySizer(); | |
0122b7e3 RD |
290 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
291 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPySizer)" | |
2aab8f16 | 292 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
2f90df85 RD |
293 | }; |
294 | ||
295 | ||
296 | //--------------------------------------------------------------------------- | |
297 | ||
298 | class wxBoxSizer : public wxSizer { | |
299 | public: | |
300 | wxBoxSizer(int orient = wxHORIZONTAL); | |
2aab8f16 | 301 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
2f90df85 | 302 | int GetOrientation(); |
f6bcfd97 BP |
303 | void RecalcSizes(); |
304 | wxSize CalcMin(); | |
2f90df85 RD |
305 | }; |
306 | ||
307 | //--------------------------------------------------------------------------- | |
308 | ||
309 | class wxStaticBoxSizer : public wxBoxSizer { | |
310 | public: | |
311 | wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL); | |
2aab8f16 | 312 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
2f90df85 | 313 | wxStaticBox *GetStaticBox(); |
f6bcfd97 BP |
314 | void RecalcSizes(); |
315 | wxSize CalcMin(); | |
316 | }; | |
317 | ||
318 | //--------------------------------------------------------------------------- | |
319 | ||
320 | class wxNotebookSizer: public wxSizer { | |
321 | public: | |
322 | wxNotebookSizer( wxNotebook *nb ); | |
2aab8f16 | 323 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
324 | void RecalcSizes(); |
325 | wxSize CalcMin(); | |
f6bcfd97 BP |
326 | wxNotebook *GetNotebook(); |
327 | }; | |
328 | ||
329 | //--------------------------------------------------------------------------- | |
330 | ||
331 | class wxGridSizer: public wxSizer | |
332 | { | |
333 | public: | |
334 | wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ); | |
2aab8f16 | 335 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
336 | |
337 | void RecalcSizes(); | |
338 | wxSize CalcMin(); | |
339 | ||
340 | void SetCols( int cols ); | |
341 | void SetRows( int rows ); | |
342 | void SetVGap( int gap ); | |
343 | void SetHGap( int gap ); | |
344 | int GetCols(); | |
345 | int GetRows(); | |
346 | int GetVGap(); | |
347 | int GetHGap(); | |
348 | }; | |
349 | ||
350 | //--------------------------------------------------------------------------- | |
351 | ||
352 | class wxFlexGridSizer: public wxGridSizer | |
353 | { | |
354 | public: | |
355 | wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ); | |
2aab8f16 | 356 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
357 | |
358 | void RecalcSizes(); | |
359 | wxSize CalcMin(); | |
360 | ||
361 | void AddGrowableRow( size_t idx ); | |
362 | void RemoveGrowableRow( size_t idx ); | |
363 | void AddGrowableCol( size_t idx ); | |
364 | void RemoveGrowableCol( size_t idx ); | |
365 | ||
2f90df85 RD |
366 | }; |
367 | ||
368 | //--------------------------------------------------------------------------- |