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