1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions of the wxSizer family of classes
7 // Created: 18-Sept-1999
9 // Copyright: (c) 1999 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
19 //----------------------------------------------------------------------
22 %include my_typemaps.i
24 // Import some definitions of other classes, etc.
30 %pragma(python) code = "import wx"
31 %pragma(python) code = "import string"
33 //---------------------------------------------------------------------------
38 // No need to ever create one directly in Python...
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 );
46 void SetDimension( wxPoint pos, wxSize size );
52 wxWindow *GetWindow();
58 void SetInitSize( int x, int y );
59 void SetOption( int option );
60 void SetFlag( int flag );
61 void SetBorder( int border );
63 // wxObject* GetUserData();
65 // Assume that the user data is a wxPyUserData object and return the contents
66 PyObject* GetUserData() {
67 wxPyUserData* data = (wxPyUserData*)self->GetUserData();
69 Py_INCREF(data->m_obj);
80 //---------------------------------------------------------------------------
84 // wxSizer(); **** abstract, can't instantiate
88 void Destroy() { delete self; }
90 void AddWindow(wxWindow *window, int option=0, int flag=0, int border=0,
91 PyObject* userData=NULL) {
92 wxPyUserData* data = NULL;
93 if (userData) data = new wxPyUserData(userData);
94 self->Add(window, option, flag, border, data);
97 void AddSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
98 PyObject* userData=NULL) {
99 wxPyUserData* data = NULL;
100 if (userData) data = new wxPyUserData(userData);
101 self->Add(sizer, option, flag, border, data);
104 void AddSpacer(int width, int height, int option=0, int flag=0,
105 int border=0, PyObject* userData=NULL) {
106 wxPyUserData* data = NULL;
107 if (userData) data = new wxPyUserData(userData);
108 self->Add(width, height, option, flag, border, data);
112 void PrependWindow(wxWindow *window, int option=0, int flag=0, int border=0,
113 PyObject* userData=NULL) {
114 wxPyUserData* data = NULL;
115 if (userData) data = new wxPyUserData(userData);
116 self->Prepend(window, option, flag, border, data);
119 void PrependSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
120 PyObject* userData=NULL) {
121 wxPyUserData* data = NULL;
122 if (userData) data = new wxPyUserData(userData);
123 self->Prepend(sizer, option, flag, border, data);
126 void PrependSpacer(int width, int height, int option=0, int flag=0,
127 int border=0, PyObject* userData=NULL) {
128 wxPyUserData* data = NULL;
129 if (userData) data = new wxPyUserData(userData);
130 self->Prepend(width, height, option, flag, border, data);
134 %name(RemoveWindow)bool Remove( wxWindow *window );
135 %name(RemoveSizer)bool Remove( wxSizer *sizer );
136 %name(RemovePos)bool Remove( int pos );
139 %pragma(python) addtoclass = "
140 def Add(self, *args):
141 if type(args[0]) == type(1):
142 apply(self.AddSpacer, args)
143 elif string.find(args[0].this, 'Sizer') != -1:
144 apply(self.AddSizer, args)
146 apply(self.AddWindow, args)
148 def Prepend(self, *args):
149 if type(args[0]) == type(1):
150 apply(self.PrependSpacer, args)
151 elif string.find(args[0].this, 'Sizer') != -1:
152 apply(self.PrependSizer, args)
154 apply(self.PrependWindow, args)
156 def Remove(self, *args):
157 if type(args[0]) == type(1):
158 apply(self.RemovePos, args)
159 elif string.find(args[0].this, 'Sizer') != -1:
160 apply(self.RemoveSizer, args)
162 apply(self.RemoveWindow, args)
164 def AddMany(self, widgets):
165 for childinfo in widgets:
166 if type(childinfo) != type(()):
167 childinfo = (childinfo, )
168 apply(self.Add, childinfo)
172 void SetDimension( int x, int y, int width, int height );
175 wxPoint GetPosition();
178 // void RecalcSizes() = 0;
179 // wxSize CalcMin() = 0;
183 void Fit( wxWindow *window );
184 void SetSizeHints( wxWindow *window );
186 // wxList& GetChildren();
188 PyObject* GetChildren() {
189 wxList& list = self->GetChildren();
190 return wxPy_ConvertList(&list, "wxSizerItem");
196 //---------------------------------------------------------------------------
197 // Use this one for deriving Python classes from
199 class wxPySizer : public wxSizer {
200 DECLARE_DYNAMIC_CLASS(wxPySizer);
202 wxPySizer() : wxSizer() {};
204 DEC_PYCALLBACK___pure(RecalcSizes);
205 DEC_PYCALLBACK_wxSize__pure(CalcMin);
210 IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
211 IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
213 IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
218 class wxPySizer : public wxSizer {
221 void _setSelf(PyObject* self);
222 %pragma(python) addtomethod = "__init__:self._setSelf(self)"
226 //---------------------------------------------------------------------------
228 class wxBoxSizer : public wxSizer {
230 wxBoxSizer(int orient = wxHORIZONTAL);
231 int GetOrientation();
234 //---------------------------------------------------------------------------
236 class wxStaticBoxSizer : public wxBoxSizer {
238 wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL);
239 wxStaticBox *GetStaticBox();
242 //---------------------------------------------------------------------------