1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for wxPyWindow, and etc. These classes support
4 // overriding many of wxWindow's virtual methods in Python derived
9 // Created: 2-June-1998
11 // Copyright: (c) 2003 by Total Control Software
12 // Licence: wxWindows license
13 /////////////////////////////////////////////////////////////////////////////
18 //---------------------------------------------------------------------------
21 // TODO: Redo these with SWIG directors?
23 // TODO: Which (if any?) of these should be done also???
37 // GetClientAreaOrigin
40 // SetBackgroundColour
44 // SetForegroundColour
46 // SetVirtualSizeHints
50 // TODO: Virtualize ShouldInheritColours
52 //---------------------------------------------------------------------------
55 %{ // C++ version of Python aware wxWindow
56 class wxPyWindow : public wxWindow
58 DECLARE_DYNAMIC_CLASS(wxPyWindow)
60 wxPyWindow() : wxWindow() {}
61 wxPyWindow(wxWindow* parent, const wxWindowID id,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize,
65 const wxString& name = wxPyPanelNameStr)
66 : wxWindow(parent, id, pos, size, style, name) {}
69 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
70 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
71 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
72 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
74 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
75 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
76 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
78 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
79 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
81 DEC_PYCALLBACK__(InitDialog);
82 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
83 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
84 DEC_PYCALLBACK_BOOL_(Validate);
86 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
87 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
88 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
90 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
91 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
96 IMPLEMENT_DYNAMIC_CLASS(wxPyWindow, wxWindow);
98 IMP_PYCALLBACK_VOID_INT4(wxPyWindow, wxWindow, DoMoveWindow);
99 IMP_PYCALLBACK_VOID_INT5(wxPyWindow, wxWindow, DoSetSize);
100 IMP_PYCALLBACK_VOID_INTINT(wxPyWindow, wxWindow, DoSetClientSize);
101 IMP_PYCALLBACK_VOID_INTINT(wxPyWindow, wxWindow, DoSetVirtualSize);
103 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetSize);
104 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetClientSize);
105 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetPosition);
107 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, DoGetVirtualSize);
108 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, DoGetBestSize);
110 IMP_PYCALLBACK__(wxPyWindow, wxWindow, InitDialog);
111 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, TransferDataFromWindow);
112 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, TransferDataToWindow);
113 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, Validate);
115 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, AcceptsFocus);
116 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, AcceptsFocusFromKeyboard);
117 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, GetMaxSize);
119 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, AddChild);
120 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, RemoveChild);
124 // And now the one for SWIG to see
125 class wxPyWindow : public wxWindow
128 %addtofunc wxPyWindow "self._setOORInfo(self); self._setCallbackInfo(self, PyWindow)"
130 wxPyWindow(wxWindow* parent, const wxWindowID id,
131 const wxPoint& pos = wxDefaultPosition,
132 const wxSize& size = wxDefaultSize,
134 const wxString& name = wxPyPanelNameStr);
136 void _setCallbackInfo(PyObject* self, PyObject* _class);
139 void base_DoMoveWindow(int x, int y, int width, int height);
140 void base_DoSetSize(int x, int y, int width, int height,
141 int sizeFlags = wxSIZE_AUTO);
142 void base_DoSetClientSize(int width, int height);
143 void base_DoSetVirtualSize( int x, int y );
145 void base_DoGetSize( int *OUTPUT, int *OUTPUT ) const;
146 void base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const;
147 void base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const;
149 wxSize base_DoGetVirtualSize() const;
150 wxSize base_DoGetBestSize() const;
152 void base_InitDialog();
153 bool base_TransferDataToWindow();
154 bool base_TransferDataFromWindow();
155 bool base_Validate();
157 bool base_AcceptsFocus() const;
158 bool base_AcceptsFocusFromKeyboard() const;
159 wxSize base_GetMaxSize() const;
161 void base_AddChild(wxWindow* child);
162 void base_RemoveChild(wxWindow* child);
165 //---------------------------------------------------------------------------
166 // Do the same thing for wxControl
168 // ** See _pycontrol.i, it was moved there because of dependency on wxControl
171 //---------------------------------------------------------------------------
174 %{ // C++ version of Python aware wxPanel
175 class wxPyPanel : public wxPanel
177 DECLARE_DYNAMIC_CLASS(wxPyPanel)
179 wxPyPanel() : wxPanel() {}
180 wxPyPanel(wxWindow* parent, const wxWindowID id,
181 const wxPoint& pos = wxDefaultPosition,
182 const wxSize& size = wxDefaultSize,
184 const wxString& name = wxPyPanelNameStr)
185 : wxPanel(parent, id, pos, size, style, name) {}
188 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
189 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
190 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
191 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
193 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
194 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
195 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
197 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
198 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
200 DEC_PYCALLBACK__(InitDialog);
201 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
202 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
203 DEC_PYCALLBACK_BOOL_(Validate);
205 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
206 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
207 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
209 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
210 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
215 IMPLEMENT_DYNAMIC_CLASS(wxPyPanel, wxPanel);
217 IMP_PYCALLBACK_VOID_INT4(wxPyPanel, wxPanel, DoMoveWindow);
218 IMP_PYCALLBACK_VOID_INT5(wxPyPanel, wxPanel, DoSetSize);
219 IMP_PYCALLBACK_VOID_INTINT(wxPyPanel, wxPanel, DoSetClientSize);
220 IMP_PYCALLBACK_VOID_INTINT(wxPyPanel, wxPanel, DoSetVirtualSize);
222 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetSize);
223 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetClientSize);
224 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetPosition);
226 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, DoGetVirtualSize);
227 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, DoGetBestSize);
229 IMP_PYCALLBACK__(wxPyPanel, wxPanel, InitDialog);
230 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, TransferDataFromWindow);
231 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, TransferDataToWindow);
232 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, Validate);
234 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, AcceptsFocus);
235 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, AcceptsFocusFromKeyboard);
236 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, GetMaxSize);
238 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, AddChild);
239 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, RemoveChild);
243 // And now the one for SWIG to see
244 class wxPyPanel : public wxPanel
247 %addtofunc wxPyPanel "self._setOORInfo(self); self._setCallbackInfo(self, PyPanel)"
249 wxPyPanel(wxWindow* parent, const wxWindowID id,
250 const wxPoint& pos = wxDefaultPosition,
251 const wxSize& size = wxDefaultSize,
253 const wxString& name = wxPyPanelNameStr);
255 void _setCallbackInfo(PyObject* self, PyObject* _class);
256 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyPanel)"
257 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
260 void base_DoMoveWindow(int x, int y, int width, int height);
261 void base_DoSetSize(int x, int y, int width, int height,
262 int sizeFlags = wxSIZE_AUTO);
263 void base_DoSetClientSize(int width, int height);
264 void base_DoSetVirtualSize( int x, int y );
266 void base_DoGetSize( int *OUTPUT, int *OUTPUT ) const;
267 void base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const;
268 void base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const;
270 wxSize base_DoGetVirtualSize() const;
271 wxSize base_DoGetBestSize() const;
273 void base_InitDialog();
274 bool base_TransferDataToWindow();
275 bool base_TransferDataFromWindow();
276 bool base_Validate();
278 bool base_AcceptsFocus() const;
279 bool base_AcceptsFocusFromKeyboard() const;
280 wxSize base_GetMaxSize() const;
282 void base_AddChild(wxWindow* child);
283 void base_RemoveChild(wxWindow* child);
287 //---------------------------------------------------------------------------
288 //---------------------------------------------------------------------------