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 //---------------------------------------------------------------------------
36 class wxPyUserData : public wxObject {
38 wxPyUserData(PyObject* obj) { m_obj = obj; Py_INCREF(m_obj); }
40 bool doSave = wxPyRestoreThread();
42 wxPySaveThread(doSave);
48 //---------------------------------------------------------------------------
52 // No need to ever create one directly in Python...
54 //wxSizerItem( int width, int height, int option, int flag, int border, wxObject* userData);
55 //wxSizerItem( wxWindow *window, int option, int flag, int border, wxObject* userData );
56 //wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxObject* userData );
60 void SetDimension( wxPoint pos, wxSize size );
66 wxWindow *GetWindow();
72 // wxObject* GetUserData();
74 // Assume that the user data is a wxPyUserData object and return the contents
75 PyObject* GetUserData() {
76 wxPyUserData* data = (wxPyUserData*)self->GetUserData();
78 Py_INCREF(data->m_obj);
89 //---------------------------------------------------------------------------
93 // wxSizer(); **** abstract, can't instantiate
97 void Destroy() { delete self; }
99 void AddWindow(wxWindow *window, int option=0, int flag=0, int border=0,
100 PyObject* userData=NULL) {
101 wxPyUserData* data = NULL;
102 if (userData) data = new wxPyUserData(userData);
103 self->Add(window, option, flag, border, data);
106 void AddSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
107 PyObject* userData=NULL) {
108 wxPyUserData* data = NULL;
109 if (userData) data = new wxPyUserData(userData);
110 self->Add(sizer, option, flag, border, data);
113 void AddSpacer(int width, int height, int option=0, int flag=0,
114 int border=0, PyObject* userData=NULL) {
115 wxPyUserData* data = NULL;
116 if (userData) data = new wxPyUserData(userData);
117 self->Add(width, height, option, flag, border, data);
121 void PrependWindow(wxWindow *window, int option=0, int flag=0, int border=0,
122 PyObject* userData=NULL) {
123 wxPyUserData* data = NULL;
124 if (userData) data = new wxPyUserData(userData);
125 self->Prepend(window, option, flag, border, data);
128 void PrependSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
129 PyObject* userData=NULL) {
130 wxPyUserData* data = NULL;
131 if (userData) data = new wxPyUserData(userData);
132 self->Prepend(sizer, option, flag, border, data);
135 void PrependSpacer(int width, int height, int option=0, int flag=0,
136 int border=0, PyObject* userData=NULL) {
137 wxPyUserData* data = NULL;
138 if (userData) data = new wxPyUserData(userData);
139 self->Prepend(width, height, option, flag, border, data);
143 %name(RemoveWindow)bool Remove( wxWindow *window );
144 %name(RemoveSizer)bool Remove( wxSizer *sizer );
145 %name(RemovePos)bool Remove( int pos );
148 %pragma(python) addtoclass = "
149 def Add(self, *args):
150 if type(args[0]) == type(1):
151 apply(self.AddSpacer, args)
152 elif string.find(args[0].this, 'Sizer') != -1:
153 apply(self.AddSizer, args)
155 apply(self.AddWindow, args)
157 def Prepend(self, *args):
158 if type(args[0]) == type(1):
159 apply(self.PrependSpacer, args)
160 elif string.find(args[0].this, 'Sizer') != -1:
161 apply(self.PrependSizer, args)
163 apply(self.PrependWindow, args)
165 def Remove(self, *args):
166 if type(args[0]) == type(1):
167 apply(self.RemovePos, args)
168 elif string.find(args[0].this, 'Sizer') != -1:
169 apply(self.RemoveSizer, args)
171 apply(self.RemoveWindow, args)
173 def AddMany(self, widgets):
174 for childinfo in widgets:
175 if type(childinfo) != type(()):
176 childinfo = (childinfo, )
177 apply(self.Add, childinfo)
181 void SetDimension( int x, int y, int width, int height );
184 wxPoint GetPosition();
187 // void RecalcSizes() = 0;
188 // wxSize CalcMin() = 0;
192 void Fit( wxWindow *window );
193 void SetSizeHints( wxWindow *window );
195 // wxList& GetChildren();
197 PyObject* GetChildren() {
198 wxList& list = self->GetChildren();
199 return wxPy_ConvertList(&list, "wxSizerItem");
205 //---------------------------------------------------------------------------
206 // Use this one for deriving Python classes from
208 class wxPySizer : public wxSizer {
209 DECLARE_DYNAMIC_CLASS(wxPySizer);
211 wxPySizer() : wxSizer() {};
213 DEC_PYCALLBACK___pure(RecalcSizes);
214 DEC_PYCALLBACK_wxSize__pure(CalcMin);
219 IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
220 IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
222 IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
227 class wxPySizer : public wxSizer {
230 void _setSelf(PyObject* self);
231 %pragma(python) addtomethod = "__init__:self._setSelf(self)"
235 //---------------------------------------------------------------------------
237 class wxBoxSizer : public wxSizer {
239 wxBoxSizer(int orient = wxHORIZONTAL);
240 int GetOrientation();
243 //---------------------------------------------------------------------------
245 class wxStaticBoxSizer : public wxBoxSizer {
247 wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL);
248 wxStaticBox *GetStaticBox();
251 //---------------------------------------------------------------------------