]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/sizers.i
it is now possible to add custom buttons into wxHtmlHelpFrame's toolbar
[wxWidgets.git] / utils / 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"
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
2f90df85
RD
35
36class wxSizerItem {
37public:
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
48 bool IsWindow();
49 bool IsSizer();
50 bool IsSpacer();
51
52 wxWindow *GetWindow();
53 wxSizer *GetSizer();
54 int GetOption();
55 int GetFlag();
56 int GetBorder();
57
9b3d3bc4
RD
58 void SetInitSize( int x, int y );
59 void SetOption( int option );
60 void SetFlag( int flag );
61 void SetBorder( int border );
62
2f90df85
RD
63 // wxObject* GetUserData();
64 %addmethods {
65 // Assume that the user data is a wxPyUserData object and return the contents
66 PyObject* GetUserData() {
67 wxPyUserData* data = (wxPyUserData*)self->GetUserData();
68 if (data) {
69 Py_INCREF(data->m_obj);
70 return data->m_obj;
71 } else {
72 Py_INCREF(Py_None);
73 return Py_None;
74 }
75 }
76 }
77};
78
79
80//---------------------------------------------------------------------------
81
82class wxSizer {
83public:
84 // wxSizer(); **** abstract, can't instantiate
85 // ~wxSizer();
86
87 %addmethods {
88 void Destroy() { delete self; }
89
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);
95 }
96
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);
102 }
103
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);
109 }
110
111
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);
117 }
118
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);
124 }
125
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);
131 }
132 }
133
134 %name(RemoveWindow)bool Remove( wxWindow *window );
135 %name(RemoveSizer)bool Remove( wxSizer *sizer );
136 %name(RemovePos)bool Remove( int pos );
137
138
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)
145 else:
146 apply(self.AddWindow, args)
147
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)
153 else:
154 apply(self.PrependWindow, args)
155
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)
161 else:
162 apply(self.RemoveWindow, args)
163
164 def AddMany(self, widgets):
165 for childinfo in widgets:
166 if type(childinfo) != type(()):
167 childinfo = (childinfo, )
168 apply(self.Add, childinfo)
169"
170
171
172 void SetDimension( int x, int y, int width, int height );
173
174 wxSize GetSize();
175 wxPoint GetPosition();
176 wxSize GetMinSize();
177
178 // void RecalcSizes() = 0;
179 // wxSize CalcMin() = 0;
180
181 void Layout();
182
183 void Fit( wxWindow *window );
184 void SetSizeHints( wxWindow *window );
185
186 // wxList& GetChildren();
187 %addmethods {
188 PyObject* GetChildren() {
189 wxList& list = self->GetChildren();
190 return wxPy_ConvertList(&list, "wxSizerItem");
191 }
192 }
193};
194
195
196//---------------------------------------------------------------------------
197// Use this one for deriving Python classes from
198%{
199class wxPySizer : public wxSizer {
200 DECLARE_DYNAMIC_CLASS(wxPySizer);
201public:
202 wxPySizer() : wxSizer() {};
203
204 DEC_PYCALLBACK___pure(RecalcSizes);
205 DEC_PYCALLBACK_wxSize__pure(CalcMin);
206 PYPRIVATE;
207};
208
209
210IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
211IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
212
213IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
214%}
215
216
217
218class wxPySizer : public wxSizer {
219public:
220 wxPySizer();
221 void _setSelf(PyObject* self);
222 %pragma(python) addtomethod = "__init__:self._setSelf(self)"
223};
224
225
226//---------------------------------------------------------------------------
227
228class wxBoxSizer : public wxSizer {
229public:
230 wxBoxSizer(int orient = wxHORIZONTAL);
231 int GetOrientation();
232};
233
234//---------------------------------------------------------------------------
235
236class wxStaticBoxSizer : public wxBoxSizer {
237public:
238 wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL);
239 wxStaticBox *GetStaticBox();
240};
241
242//---------------------------------------------------------------------------