]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/sizers.i
added visual c++ makefiles
[wxWidgets.git] / wxPython / src / sizers.i
CommitLineData
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"
2f90df85
RD
33
34//---------------------------------------------------------------------------
35
2f90df85 36
9416aa89 37class wxSizerItem : public wxObject {
2f90df85
RD
38public:
39 // No need to ever create one directly in Python...
40
1e4a197e
RD
41 //wxSizerItem( int width, int height, int proportion, int flag, int border, wxObject* userData);
42 //wxSizerItem( wxWindow *window, int proportion, int flag, int border, wxObject* userData );
43 //wxSizerItem( wxSizer *sizer, int proportion, int flag, int border, wxObject* userData );
2f90df85 44
101dd79a 45 void DeleteWindows();
1e4a197e 46 void DetachSizer();
101dd79a 47
2f90df85
RD
48 wxSize GetSize();
49 wxSize CalcMin();
50 void SetDimension( wxPoint pos, wxSize size );
1e4a197e
RD
51
52 wxSize GetMinSize();
53 void SetInitSize( int x, int y );
54
f6bcfd97
BP
55 %name(SetRatioWH) void SetRatio( int width, int height );
56 %name(SetRatioSize) void SetRatio( wxSize size );
57 void SetRatio( float ratio );
58 float GetRatio();
2f90df85
RD
59
60 bool IsWindow();
61 bool IsSizer();
62 bool IsSpacer();
63
1e4a197e
RD
64 void SetProportion( int proportion );
65 int GetProportion();
66 %pragma(python) addtoclass = "SetOption = SetProportion"
67 %pragma(python) addtoclass = "GetOption = GetProportion"
68 void SetFlag( int flag );
69 int GetFlag();
70 void SetBorder( int border );
71 int GetBorder();
72
2f90df85 73 wxWindow *GetWindow();
f6bcfd97 74 void SetWindow( wxWindow *window );
2f90df85 75 wxSizer *GetSizer();
f6bcfd97 76 void SetSizer( wxSizer *sizer );
1e4a197e
RD
77 const wxSize& GetSpacer();
78 void SetSpacer( const wxSize &size );
2f90df85 79
1e4a197e
RD
80 void Show( bool show );
81 bool IsShown();
82
83 wxPoint GetPosition();
9b3d3bc4 84
2f90df85
RD
85 // wxObject* GetUserData();
86 %addmethods {
87 // Assume that the user data is a wxPyUserData object and return the contents
88 PyObject* GetUserData() {
89 wxPyUserData* data = (wxPyUserData*)self->GetUserData();
90 if (data) {
91 Py_INCREF(data->m_obj);
92 return data->m_obj;
93 } else {
94 Py_INCREF(Py_None);
95 return Py_None;
96 }
97 }
98 }
99};
100
101
102//---------------------------------------------------------------------------
103
9416aa89 104class wxSizer : public wxObject {
2f90df85
RD
105public:
106 // wxSizer(); **** abstract, can't instantiate
107 // ~wxSizer();
108
2aab8f16
RD
109 %addmethods {
110 void _setOORInfo(PyObject* _self) {
4acff284 111 self->SetClientObject(new wxPyOORClientData(_self));
2aab8f16
RD
112 }
113 }
114
2f90df85
RD
115 %addmethods {
116 void Destroy() { delete self; }
117
1e4a197e 118 void AddWindow(wxWindow *window, int proportion=0, int flag=0, int border=0,
2f90df85
RD
119 PyObject* userData=NULL) {
120 wxPyUserData* data = NULL;
121 if (userData) data = new wxPyUserData(userData);
1e4a197e 122 self->Add(window, proportion, flag, border, data);
2f90df85 123 }
1e4a197e 124 void AddSizer(wxSizer *sizer, int proportion=0, int flag=0, int border=0,
2f90df85
RD
125 PyObject* userData=NULL) {
126 wxPyUserData* data = NULL;
127 if (userData) data = new wxPyUserData(userData);
1e4a197e 128 self->Add(sizer, proportion, flag, border, data);
2f90df85 129 }
1e4a197e 130 void AddSpacer(int width, int height, int proportion=0, int flag=0,
2f90df85
RD
131 int border=0, PyObject* userData=NULL) {
132 wxPyUserData* data = NULL;
133 if (userData) data = new wxPyUserData(userData);
1e4a197e 134 self->Add(width, height, proportion, flag, border, data);
2f90df85
RD
135 }
136
1e4a197e 137 void InsertWindow(int before, wxWindow *window, int proportion=0, int flag=0,
f6bcfd97
BP
138 int border=0, PyObject* userData=NULL) {
139 wxPyUserData* data = NULL;
140 if (userData) data = new wxPyUserData(userData);
1e4a197e 141 self->Insert(before, window, proportion, flag, border, data);
f6bcfd97 142 }
1e4a197e 143 void InsertSizer(int before, wxSizer *sizer, int proportion=0, int flag=0,
f6bcfd97
BP
144 int border=0, PyObject* userData=NULL) {
145 wxPyUserData* data = NULL;
146 if (userData) data = new wxPyUserData(userData);
1e4a197e 147 self->Insert(before, sizer, proportion, flag, border, data);
f6bcfd97 148 }
1e4a197e 149 void InsertSpacer(int before, int width, int height, int proportion=0, int flag=0,
f6bcfd97
BP
150 int border=0, PyObject* userData=NULL) {
151 wxPyUserData* data = NULL;
152 if (userData) data = new wxPyUserData(userData);
1e4a197e 153 self->Insert(before, width, height, proportion, flag, border, data);
f6bcfd97
BP
154 }
155
156
1e4a197e 157 void PrependWindow(wxWindow *window, int proportion=0, int flag=0, int border=0,
2f90df85
RD
158 PyObject* userData=NULL) {
159 wxPyUserData* data = NULL;
160 if (userData) data = new wxPyUserData(userData);
1e4a197e 161 self->Prepend(window, proportion, flag, border, data);
2f90df85 162 }
1e4a197e 163 void PrependSizer(wxSizer *sizer, int proportion=0, int flag=0, int border=0,
2f90df85
RD
164 PyObject* userData=NULL) {
165 wxPyUserData* data = NULL;
166 if (userData) data = new wxPyUserData(userData);
1e4a197e 167 self->Prepend(sizer, proportion, flag, border, data);
2f90df85 168 }
1e4a197e 169 void PrependSpacer(int width, int height, int proportion=0, int flag=0,
2f90df85
RD
170 int border=0, PyObject* userData=NULL) {
171 wxPyUserData* data = NULL;
172 if (userData) data = new wxPyUserData(userData);
1e4a197e 173 self->Prepend(width, height, proportion, flag, border, data);
2f90df85 174 }
1e4a197e
RD
175
176 // TODO: AddItem, InsertItem, PrependItem
177
2f90df85
RD
178 }
179
1e4a197e 180 %name(RemoveWindow)bool Remove( wxWindow *window ); // TODO: This is DEPRECATED. Should all be removed?
2f90df85
RD
181 %name(RemoveSizer)bool Remove( wxSizer *sizer );
182 %name(RemovePos)bool Remove( int pos );
183
1e4a197e
RD
184 %name(DetachWindow)bool Detach( wxWindow *window );
185 %name(DetachSizer)bool Detach( wxSizer *sizer );
186 %name(DetachPos)bool Detach( int pos );
187
2f90df85
RD
188
189 %pragma(python) addtoclass = "
d1679124 190 def Add(self, *args, **kw):
2f90df85 191 if type(args[0]) == type(1):
d1679124 192 apply(self.AddSpacer, args, kw)
1e4a197e 193 elif isinstance(args[0], wxSizerPtr):
d1679124 194 apply(self.AddSizer, args, kw)
1e4a197e 195 elif isinstance(args[0], wxWindowPtr):
d1679124 196 apply(self.AddWindow, args, kw)
1e4a197e
RD
197 else:
198 raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
2f90df85 199
d1679124 200 def Insert(self, *args, **kw):
c368d904 201 if type(args[1]) == type(1):
d1679124 202 apply(self.InsertSpacer, args, kw)
1e4a197e 203 elif isinstance(args[1], wxSizerPtr):
d1679124 204 apply(self.InsertSizer, args, kw)
1e4a197e 205 elif isinstance(args[1], wxWindowPtr):
d1679124 206 apply(self.InsertWindow, args, kw)
1e4a197e
RD
207 else:
208 raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
f6bcfd97 209
d1679124 210 def Prepend(self, *args, **kw):
2f90df85 211 if type(args[0]) == type(1):
d1679124 212 apply(self.PrependSpacer, args, kw)
1e4a197e 213 elif isinstance(args[0], wxSizerPtr):
d1679124 214 apply(self.PrependSizer, args, kw)
1e4a197e 215 elif isinstance(args[0], wxWindowPtr):
d1679124 216 apply(self.PrependWindow, args, kw)
1e4a197e
RD
217 else:
218 raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
2f90df85 219
d1679124 220 def Remove(self, *args, **kw):
2f90df85 221 if type(args[0]) == type(1):
1e4a197e
RD
222 return apply(self.RemovePos, args, kw)
223 elif isinstance(args[0], wxSizerPtr):
224 return apply(self.RemoveSizer, args, kw)
225 elif isinstance(args[0], wxWindowPtr):
226 return apply(self.RemoveWindow, args, kw)
227 else:
228 raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
229
230 def Detach(self, *args, **kw):
231 if type(args[0]) == type(1):
232 return apply(self.DetachPos, args, kw)
233 elif isinstance(args[0], wxSizerPtr):
234 return apply(self.DetachSizer, args, kw)
235 elif isinstance(args[0], wxWindowPtr):
236 return apply(self.DetachWindow, args, kw)
2f90df85 237 else:
1e4a197e 238 raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
2f90df85
RD
239
240 def AddMany(self, widgets):
241 for childinfo in widgets:
242 if type(childinfo) != type(()):
243 childinfo = (childinfo, )
244 apply(self.Add, childinfo)
245"
246
1e4a197e
RD
247 void Clear( bool delete_windows = false );
248 void DeleteWindows();
2f90df85 249
f6bcfd97
BP
250 void SetMinSize(wxSize size);
251
1e4a197e
RD
252 %name(SetItemMinSizeWindow) void SetItemMinSize(wxWindow* window, wxSize size);
253 %name(SetItemMinSizeSizer) void SetItemMinSize(wxSizer* sizer, wxSize size);
254 %name(SetItemMinSizePos) void SetItemMinSize(int pos, wxSize size);
255 %name(SetItemMinSizeWindowWH) void SetItemMinSize(wxWindow* window, int width, int height);
256 %name(SetItemMinSizeSizerWH) void SetItemMinSize(wxSizer* sizer, int width, int height);
257 %name(SetItemMinSizePosWH) void SetItemMinSize(int pos, int width, int height);
f6bcfd97
BP
258
259 %pragma(python) addtoclass = "
260 def SetItemMinSize(self, *args):
261 if type(args[0]) == type(1):
262 apply(self.SetItemMinSizePos, args)
1e4a197e 263 elif isinstance(args[0], wxSizerPtr):
f6bcfd97 264 apply(self.SetItemMinSizeSizer, args)
1e4a197e 265 elif isinstance(args[0], wxWindowPtr):
f6bcfd97 266 apply(self.SetItemMinSizeWindow, args)
1e4a197e
RD
267 else:
268 raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
269
270 def SetItemMinSizeWH(self, *args):
271 if type(args[0]) == type(1):
272 apply(self.SetItemMinSizePosWH, args)
273 elif isinstance(args[0], wxSizerPtr):
274 apply(self.SetItemMinSizeSizerWH, args)
275 elif isinstance(args[0], wxWindowPtr):
276 apply(self.SetItemMinSizeWindowWH, args)
277 else:
278 raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
f6bcfd97 279 "
2f90df85
RD
280
281 wxSize GetSize();
282 wxPoint GetPosition();
283 wxSize GetMinSize();
284
82550f23
RD
285 %pragma(python) addtoclass = "
286 def GetSizeTuple(self):
287 return self.GetSize().asTuple()
288 def GetPositionTuple(self):
289 return self.GetPosition().asTuple()
290 def GetMinSizeTuple(self):
291 return self.GetMinSize().asTuple()
292 "
293
2f90df85
RD
294 // void RecalcSizes() = 0;
295 // wxSize CalcMin() = 0;
296
297 void Layout();
298
72797a7d 299 wxSize Fit( wxWindow *window );
2a74d141
RD
300 void FitInside( wxWindow *window );
301
2f90df85 302 void SetSizeHints( wxWindow *window );
2a74d141 303 void SetVirtualSizeHints( wxWindow *window );
2f90df85 304
101dd79a 305
2f90df85
RD
306 // wxList& GetChildren();
307 %addmethods {
308 PyObject* GetChildren() {
1e4a197e 309 wxSizerItemList& list = self->GetChildren();
2f90df85
RD
310 return wxPy_ConvertList(&list, "wxSizerItem");
311 }
312 }
1e4a197e
RD
313
314 void SetDimension( int x, int y, int width, int height );
315
316 // Manage whether individual windows or sub-sizers are considered
317 // in the layout calculations or not.
318 %name(ShowWindow)void Show( wxWindow *window, bool show = TRUE );
319 %name(ShowSizer)void Show( wxSizer *sizer, bool show = TRUE );
320 %name(ShowPos)void Show( size_t index, bool show = TRUE );
321 %name(HideWindow)void Hide( wxWindow *window );
322 %name(HideSizer)void Hide( wxSizer *sizer );
323 %name(HidePos)void Hide( size_t index );
324 %name(IsShownWindow)bool IsShown( wxWindow *window );
325 %name(IsShownSizer)bool IsShown( wxSizer *sizer );
326 %name(IsShownPos)bool IsShown( size_t index );
327
328 %pragma(python) addtoclass = "
329 def Show(self, *args):
330 if type(args[0]) == type(1):
331 apply(self.ShowPos, args)
332 elif isinstance(args[0], wxSizerPtr):
333 apply(self.ShowSizer, args)
334 elif isinstance(args[0], wxWindowPtr):
335 apply(self.ShowWindow, args)
336 else:
337 raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
338
339 def Hide(self, *args):
340 if type(args[0]) == type(1):
341 apply(self.HidePos, args)
342 elif isinstance(args[0], wxSizerPtr):
343 apply(self.HideSizer, args)
344 elif isinstance(args[0], wxWindowPtr):
345 apply(self.HideWindow, args)
346 else:
347 raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
348
349 def IsShown(self, *args):
350 if type(args[0]) == type(1):
351 return apply(self.IsShownPos, args)
352 elif isinstance(args[0], wxSizerPtr):
353 return apply(self.IsShownSizer, args)
354 elif isinstance(args[0], wxWindowPtr):
355 return apply(self.IsShownWindow, args)
356 else:
357 raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
358"
359
360 // Recursively call wxWindow::Show () on all sizer items.
361 void ShowItems (bool show);
362
2f90df85
RD
363};
364
365
366//---------------------------------------------------------------------------
367// Use this one for deriving Python classes from
368%{
369class wxPySizer : public wxSizer {
370 DECLARE_DYNAMIC_CLASS(wxPySizer);
371public:
372 wxPySizer() : wxSizer() {};
373
374 DEC_PYCALLBACK___pure(RecalcSizes);
375 DEC_PYCALLBACK_wxSize__pure(CalcMin);
376 PYPRIVATE;
377};
378
379
380IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
381IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
382
383IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
384%}
385
386
387
388class wxPySizer : public wxSizer {
389public:
390 wxPySizer();
0122b7e3
RD
391 void _setCallbackInfo(PyObject* self, PyObject* _class);
392 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPySizer)"
2aab8f16 393 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
2f90df85
RD
394};
395
396
397//---------------------------------------------------------------------------
398
399class wxBoxSizer : public wxSizer {
400public:
401 wxBoxSizer(int orient = wxHORIZONTAL);
2aab8f16 402 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
2f90df85 403 int GetOrientation();
1e4a197e 404 void SetOrientation(int orient);
f6bcfd97
BP
405 void RecalcSizes();
406 wxSize CalcMin();
2f90df85
RD
407};
408
409//---------------------------------------------------------------------------
410
411class wxStaticBoxSizer : public wxBoxSizer {
412public:
413 wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL);
2aab8f16 414 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
2f90df85 415 wxStaticBox *GetStaticBox();
f6bcfd97
BP
416 void RecalcSizes();
417 wxSize CalcMin();
418};
419
420//---------------------------------------------------------------------------
421
422class wxNotebookSizer: public wxSizer {
423public:
424 wxNotebookSizer( wxNotebook *nb );
2aab8f16 425 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
f6bcfd97
BP
426 void RecalcSizes();
427 wxSize CalcMin();
f6bcfd97
BP
428 wxNotebook *GetNotebook();
429};
430
431//---------------------------------------------------------------------------
432
433class wxGridSizer: public wxSizer
434{
435public:
436 wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
2aab8f16 437 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
f6bcfd97
BP
438
439 void RecalcSizes();
440 wxSize CalcMin();
441
442 void SetCols( int cols );
443 void SetRows( int rows );
444 void SetVGap( int gap );
445 void SetHGap( int gap );
446 int GetCols();
447 int GetRows();
448 int GetVGap();
449 int GetHGap();
450};
451
452//---------------------------------------------------------------------------
453
1e4a197e
RD
454enum wxFlexSizerGrowMode
455{
456 // don't resize the cells in non-flexible direction at all
457 wxFLEX_GROWMODE_NONE,
458
459 // uniformly resize only the specified ones (default)
460 wxFLEX_GROWMODE_SPECIFIED,
461
462 // uniformly resize all cells
463 wxFLEX_GROWMODE_ALL
464};
465
466
f6bcfd97
BP
467class wxFlexGridSizer: public wxGridSizer
468{
469public:
470 wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
2aab8f16 471 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
f6bcfd97
BP
472
473 void RecalcSizes();
474 wxSize CalcMin();
475
1e4a197e 476 void AddGrowableRow( size_t idx, int proportion = 0 );
f6bcfd97 477 void RemoveGrowableRow( size_t idx );
1e4a197e 478 void AddGrowableCol( size_t idx, int proportion = 0 );
f6bcfd97
BP
479 void RemoveGrowableCol( size_t idx );
480
1e4a197e
RD
481 // the sizer cells may grow in both directions, not grow at all or only
482 // grow in one direction but not the other
483
484 // the direction may be wxVERTICAL, wxHORIZONTAL or wxBOTH (default)
485 void SetFlexibleDirection(int direction);
486 int GetFlexibleDirection();
487
488 // note that the grow mode only applies to the direction which is not
489 // flexible
490 void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode);
491 wxFlexSizerGrowMode GetNonFlexibleGrowMode();
2f90df85
RD
492};
493
494//---------------------------------------------------------------------------