]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/sizers.i
fixed clip rect when logical coords != device ones
[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 wxSize GetSize();
47 wxSize CalcMin();
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 );
52 float GetRatio();
53
54 bool IsWindow();
55 bool IsSizer();
56 bool IsSpacer();
57
58 wxWindow *GetWindow();
59 void SetWindow( wxWindow *window );
60 wxSizer *GetSizer();
61 void SetSizer( wxSizer *sizer );
62 int GetOption();
63 int GetFlag();
64 int GetBorder();
65
66 void SetInitSize( int x, int y );
67 void SetOption( int option );
68 void SetFlag( int flag );
69 void SetBorder( int border );
70
71 // wxObject* GetUserData();
72 %addmethods {
73 // Assume that the user data is a wxPyUserData object and return the contents
74 PyObject* GetUserData() {
75 wxPyUserData* data = (wxPyUserData*)self->GetUserData();
76 if (data) {
77 Py_INCREF(data->m_obj);
78 return data->m_obj;
79 } else {
80 Py_INCREF(Py_None);
81 return Py_None;
82 }
83 }
84 }
85 };
86
87
88 //---------------------------------------------------------------------------
89
90 class wxSizer : public wxObject {
91 public:
92 // wxSizer(); **** abstract, can't instantiate
93 // ~wxSizer();
94
95 %addmethods {
96 void Destroy() { delete self; }
97
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);
103 }
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);
109 }
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);
115 }
116
117
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);
123 }
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);
129 }
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);
135 }
136
137
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);
143 }
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);
149 }
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);
155 }
156 }
157
158 %name(RemoveWindow)bool Remove( wxWindow *window );
159 %name(RemoveSizer)bool Remove( wxSizer *sizer );
160 %name(RemovePos)bool Remove( int pos );
161
162
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)
169 else:
170 apply(self.AddWindow, args, kw)
171
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)
177 else:
178 apply(self.InsertWindow, args, kw)
179
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)
185 else:
186 apply(self.PrependWindow, args, kw)
187
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)
193 else:
194 apply(self.RemoveWindow, args, kw)
195
196 def AddMany(self, widgets):
197 for childinfo in widgets:
198 if type(childinfo) != type(()):
199 childinfo = (childinfo, )
200 apply(self.Add, childinfo)
201 "
202
203
204 void SetDimension( int x, int y, int width, int height );
205 void SetMinSize(wxSize size);
206
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);
210
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)
217 else:
218 apply(self.SetItemMinSizeWindow, args)
219 "
220
221 wxSize GetSize();
222 wxPoint GetPosition();
223 wxSize GetMinSize();
224
225 // void RecalcSizes() = 0;
226 // wxSize CalcMin() = 0;
227
228 void Layout();
229
230 void Fit( wxWindow *window );
231 void SetSizeHints( wxWindow *window );
232
233 // wxList& GetChildren();
234 %addmethods {
235 PyObject* GetChildren() {
236 wxList& list = self->GetChildren();
237 return wxPy_ConvertList(&list, "wxSizerItem");
238 }
239 }
240 };
241
242
243 //---------------------------------------------------------------------------
244 // Use this one for deriving Python classes from
245 %{
246 class wxPySizer : public wxSizer {
247 DECLARE_DYNAMIC_CLASS(wxPySizer);
248 public:
249 wxPySizer() : wxSizer() {};
250
251 DEC_PYCALLBACK___pure(RecalcSizes);
252 DEC_PYCALLBACK_wxSize__pure(CalcMin);
253 PYPRIVATE;
254 };
255
256
257 IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
258 IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
259
260 IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
261 %}
262
263
264
265 class wxPySizer : public wxSizer {
266 public:
267 wxPySizer();
268 void _setSelf(PyObject* self, PyObject* _class);
269 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPySizer)"
270 };
271
272
273 //---------------------------------------------------------------------------
274
275 class wxBoxSizer : public wxSizer {
276 public:
277 wxBoxSizer(int orient = wxHORIZONTAL);
278 int GetOrientation();
279 void RecalcSizes();
280 wxSize CalcMin();
281 };
282
283 //---------------------------------------------------------------------------
284
285 class wxStaticBoxSizer : public wxBoxSizer {
286 public:
287 wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL);
288 wxStaticBox *GetStaticBox();
289 void RecalcSizes();
290 wxSize CalcMin();
291 };
292
293 //---------------------------------------------------------------------------
294
295 class wxNotebookSizer: public wxSizer {
296 public:
297 wxNotebookSizer( wxNotebook *nb );
298
299 void RecalcSizes();
300 wxSize CalcMin();
301
302 wxNotebook *GetNotebook();
303 };
304
305 //---------------------------------------------------------------------------
306
307 class wxGridSizer: public wxSizer
308 {
309 public:
310 wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
311
312 void RecalcSizes();
313 wxSize CalcMin();
314
315 void SetCols( int cols );
316 void SetRows( int rows );
317 void SetVGap( int gap );
318 void SetHGap( int gap );
319 int GetCols();
320 int GetRows();
321 int GetVGap();
322 int GetHGap();
323 };
324
325 //---------------------------------------------------------------------------
326
327 class wxFlexGridSizer: public wxGridSizer
328 {
329 public:
330 wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
331
332 void RecalcSizes();
333 wxSize CalcMin();
334
335 void AddGrowableRow( size_t idx );
336 void RemoveGrowableRow( size_t idx );
337 void AddGrowableCol( size_t idx );
338 void RemoveGrowableCol( size_t idx );
339
340 };
341
342 //---------------------------------------------------------------------------