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 //---------------------------------------------------------------------------
53 %{ // C++ version of Python aware wxWindow
54 class wxPyWindow : public wxWindow
56 DECLARE_DYNAMIC_CLASS(wxPyWindow)
58 wxPyWindow() : wxWindow() {}
59 wxPyWindow(wxWindow* parent, const wxWindowID id,
60 const wxPoint& pos = wxDefaultPosition,
61 const wxSize& size = wxDefaultSize,
63 const wxString& name = wxPyPanelNameStr)
64 : wxWindow(parent, id, pos, size, style, name) {}
66 void SetBestSize(const wxSize& size) { wxWindow::SetBestSize(size); }
68 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
69 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
70 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
71 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
73 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
74 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
75 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
77 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
78 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
80 DEC_PYCALLBACK__(InitDialog);
81 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
82 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
83 DEC_PYCALLBACK_BOOL_(Validate);
85 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
86 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
87 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
89 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
90 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
92 DEC_PYCALLBACK_BOOL_const(ShouldInheritColours);
93 DEC_PYCALLBACK__COLOUR(ApplyParentThemeBackground);
94 DEC_PYCALLBACK_VIZATTR_(GetDefaultAttributes);
96 DEC_PYCALLBACK_BOOL_(HasTransparentBackground);
101 IMPLEMENT_DYNAMIC_CLASS(wxPyWindow, wxWindow);
103 IMP_PYCALLBACK_VOID_INT4(wxPyWindow, wxWindow, DoMoveWindow);
104 IMP_PYCALLBACK_VOID_INT5(wxPyWindow, wxWindow, DoSetSize);
105 IMP_PYCALLBACK_VOID_INTINT(wxPyWindow, wxWindow, DoSetClientSize);
106 IMP_PYCALLBACK_VOID_INTINT(wxPyWindow, wxWindow, DoSetVirtualSize);
108 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetSize);
109 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetClientSize);
110 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetPosition);
112 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, DoGetVirtualSize);
113 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, DoGetBestSize);
115 IMP_PYCALLBACK__(wxPyWindow, wxWindow, InitDialog);
116 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, TransferDataFromWindow);
117 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, TransferDataToWindow);
118 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, Validate);
120 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, AcceptsFocus);
121 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, AcceptsFocusFromKeyboard);
122 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, GetMaxSize);
124 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, AddChild);
125 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, RemoveChild);
127 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, ShouldInheritColours);
128 IMP_PYCALLBACK__COLOUR(wxPyWindow, wxWindow, ApplyParentThemeBackground);
129 IMP_PYCALLBACK_VIZATTR_(wxPyWindow, wxWindow, GetDefaultAttributes);
131 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, HasTransparentBackground);
134 // And now the one for SWIG to see
135 MustHaveApp(wxPyWindow);
136 class wxPyWindow : public wxWindow
139 %pythonAppend wxPyWindow "self._setOORInfo(self); self._setCallbackInfo(self, PyWindow)"
140 %pythonAppend wxPyWindow() ""
142 wxPyWindow(wxWindow* parent, const wxWindowID id=-1,
143 const wxPoint& pos = wxDefaultPosition,
144 const wxSize& size = wxDefaultSize,
146 const wxString& name = wxPyPanelNameStr);
148 %RenameCtor(PrePyWindow, wxPyWindow());
150 void _setCallbackInfo(PyObject* self, PyObject* _class);
153 void SetBestSize(const wxSize& size);
155 void base_DoMoveWindow(int x, int y, int width, int height);
156 void base_DoSetSize(int x, int y, int width, int height,
157 int sizeFlags = wxSIZE_AUTO);
158 void base_DoSetClientSize(int width, int height);
159 void base_DoSetVirtualSize( int x, int y );
162 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
163 "base_DoGetSize() -> (width, height)");
165 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
166 "base_DoGetClientSize() -> (width, height)");
168 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
169 "base_DoGetPosition() -> (x,y)");
171 wxSize base_DoGetVirtualSize() const;
172 wxSize base_DoGetBestSize() const;
174 void base_InitDialog();
175 bool base_TransferDataToWindow();
176 bool base_TransferDataFromWindow();
177 bool base_Validate();
179 bool base_AcceptsFocus() const;
180 bool base_AcceptsFocusFromKeyboard() const;
181 wxSize base_GetMaxSize() const;
183 void base_AddChild(wxWindow* child);
184 void base_RemoveChild(wxWindow* child);
186 bool base_ShouldInheritColours() const;
187 void base_ApplyParentThemeBackground(const wxColour& c);
188 wxVisualAttributes base_GetDefaultAttributes();
191 //---------------------------------------------------------------------------
192 // Do the same thing for wxControl
194 // ** See _pycontrol.i, it was moved there because of dependency on wxControl
197 //---------------------------------------------------------------------------
200 %{ // C++ version of Python aware wxPanel
201 class wxPyPanel : public wxPanel
203 DECLARE_DYNAMIC_CLASS(wxPyPanel)
205 wxPyPanel() : wxPanel() {}
206 wxPyPanel(wxWindow* parent, const wxWindowID id,
207 const wxPoint& pos = wxDefaultPosition,
208 const wxSize& size = wxDefaultSize,
210 const wxString& name = wxPyPanelNameStr)
211 : wxPanel(parent, id, pos, size, style, name) {}
213 void SetBestSize(const wxSize& size) { wxPanel::SetBestSize(size); }
216 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
217 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
218 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
219 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
221 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
222 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
223 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
225 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
226 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
228 DEC_PYCALLBACK__(InitDialog);
229 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
230 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
231 DEC_PYCALLBACK_BOOL_(Validate);
233 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
234 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
235 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
237 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
238 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
240 DEC_PYCALLBACK_BOOL_const(ShouldInheritColours);
241 DEC_PYCALLBACK__COLOUR(ApplyParentThemeBackground);
242 DEC_PYCALLBACK_VIZATTR_(GetDefaultAttributes);
244 DEC_PYCALLBACK_BOOL_(HasTransparentBackground);
249 IMPLEMENT_DYNAMIC_CLASS(wxPyPanel, wxPanel);
251 IMP_PYCALLBACK_VOID_INT4(wxPyPanel, wxPanel, DoMoveWindow);
252 IMP_PYCALLBACK_VOID_INT5(wxPyPanel, wxPanel, DoSetSize);
253 IMP_PYCALLBACK_VOID_INTINT(wxPyPanel, wxPanel, DoSetClientSize);
254 IMP_PYCALLBACK_VOID_INTINT(wxPyPanel, wxPanel, DoSetVirtualSize);
256 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetSize);
257 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetClientSize);
258 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetPosition);
260 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, DoGetVirtualSize);
261 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, DoGetBestSize);
263 IMP_PYCALLBACK__(wxPyPanel, wxPanel, InitDialog);
264 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, TransferDataFromWindow);
265 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, TransferDataToWindow);
266 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, Validate);
268 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, AcceptsFocus);
269 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, AcceptsFocusFromKeyboard);
270 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, GetMaxSize);
272 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, AddChild);
273 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, RemoveChild);
275 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, ShouldInheritColours);
276 IMP_PYCALLBACK__COLOUR(wxPyPanel, wxPanel, ApplyParentThemeBackground);
277 IMP_PYCALLBACK_VIZATTR_(wxPyPanel, wxPanel, GetDefaultAttributes);
279 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, HasTransparentBackground);
282 // And now the one for SWIG to see
283 MustHaveApp(wxPyPanel);
284 class wxPyPanel : public wxPanel
287 %pythonAppend wxPyPanel "self._setOORInfo(self); self._setCallbackInfo(self, PyPanel)"
288 %pythonAppend wxPyPanel() ""
290 wxPyPanel(wxWindow* parent, const wxWindowID id=-1,
291 const wxPoint& pos = wxDefaultPosition,
292 const wxSize& size = wxDefaultSize,
294 const wxString& name = wxPyPanelNameStr);
296 %RenameCtor(PrePyPanel, wxPyPanel());
298 void _setCallbackInfo(PyObject* self, PyObject* _class);
300 void SetBestSize(const wxSize& size);
302 void base_DoMoveWindow(int x, int y, int width, int height);
303 void base_DoSetSize(int x, int y, int width, int height,
304 int sizeFlags = wxSIZE_AUTO);
305 void base_DoSetClientSize(int width, int height);
306 void base_DoSetVirtualSize( int x, int y );
309 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
310 "base_DoGetSize() -> (width, height)");
312 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
313 "base_DoGetClientSize() -> (width, height)");
315 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
316 "base_DoGetPosition() -> (x,y)");
318 wxSize base_DoGetVirtualSize() const;
319 wxSize base_DoGetBestSize() const;
321 void base_InitDialog();
322 bool base_TransferDataToWindow();
323 bool base_TransferDataFromWindow();
324 bool base_Validate();
326 bool base_AcceptsFocus() const;
327 bool base_AcceptsFocusFromKeyboard() const;
328 wxSize base_GetMaxSize() const;
330 void base_AddChild(wxWindow* child);
331 void base_RemoveChild(wxWindow* child);
333 bool base_ShouldInheritColours() const ;
334 void base_ApplyParentThemeBackground(const wxColour& c);
335 wxVisualAttributes base_GetDefaultAttributes();
338 //---------------------------------------------------------------------------
339 // and for wxScrolledWindow
341 %{ // C++ version of Python aware wxScrolledWindow
342 class wxPyScrolledWindow : public wxScrolledWindow
344 DECLARE_DYNAMIC_CLASS(wxPyScrolledWindow)
346 wxPyScrolledWindow() : wxScrolledWindow() {}
347 wxPyScrolledWindow(wxWindow* parent, const wxWindowID id,
348 const wxPoint& pos = wxDefaultPosition,
349 const wxSize& size = wxDefaultSize,
351 const wxString& name = wxPyPanelNameStr)
352 : wxScrolledWindow(parent, id, pos, size, style, name) {}
354 void SetBestSize(const wxSize& size) { wxScrolledWindow::SetBestSize(size); }
356 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
357 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
358 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
359 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
361 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
362 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
363 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
365 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
366 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
368 DEC_PYCALLBACK__(InitDialog);
369 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
370 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
371 DEC_PYCALLBACK_BOOL_(Validate);
373 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
374 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
375 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
377 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
378 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
380 DEC_PYCALLBACK_BOOL_const(ShouldInheritColours);
381 DEC_PYCALLBACK__COLOUR(ApplyParentThemeBackground);
382 DEC_PYCALLBACK_VIZATTR_(GetDefaultAttributes);
384 DEC_PYCALLBACK_BOOL_(HasTransparentBackground);
389 IMPLEMENT_DYNAMIC_CLASS(wxPyScrolledWindow, wxScrolledWindow);
391 IMP_PYCALLBACK_VOID_INT4(wxPyScrolledWindow, wxScrolledWindow, DoMoveWindow);
392 IMP_PYCALLBACK_VOID_INT5(wxPyScrolledWindow, wxScrolledWindow, DoSetSize);
393 IMP_PYCALLBACK_VOID_INTINT(wxPyScrolledWindow, wxScrolledWindow, DoSetClientSize);
394 IMP_PYCALLBACK_VOID_INTINT(wxPyScrolledWindow, wxScrolledWindow, DoSetVirtualSize);
396 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetSize);
397 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetClientSize);
398 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetPosition);
400 IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, DoGetVirtualSize);
401 IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, DoGetBestSize);
403 IMP_PYCALLBACK__(wxPyScrolledWindow, wxScrolledWindow, InitDialog);
404 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, TransferDataFromWindow);
405 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, TransferDataToWindow);
406 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, Validate);
408 IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, AcceptsFocus);
409 IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, AcceptsFocusFromKeyboard);
410 IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, GetMaxSize);
412 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyScrolledWindow, wxScrolledWindow, AddChild);
413 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyScrolledWindow, wxScrolledWindow, RemoveChild);
415 IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, ShouldInheritColours);
416 IMP_PYCALLBACK__COLOUR(wxPyScrolledWindow, wxScrolledWindow, ApplyParentThemeBackground);
417 IMP_PYCALLBACK_VIZATTR_(wxPyScrolledWindow, wxScrolledWindow, GetDefaultAttributes);
419 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, HasTransparentBackground);
422 // And now the one for SWIG to see
423 MustHaveApp(wxPyScrolledWindow);
424 class wxPyScrolledWindow : public wxScrolledWindow
427 %pythonAppend wxPyScrolledWindow "self._setOORInfo(self); self._setCallbackInfo(self, PyPanel)"
428 %pythonAppend wxPyScrolledWindow() ""
430 wxPyScrolledWindow(wxWindow* parent, const wxWindowID id=-1,
431 const wxPoint& pos = wxDefaultPosition,
432 const wxSize& size = wxDefaultSize,
434 const wxString& name = wxPyPanelNameStr);
436 %RenameCtor(PrePyScrolledWindow, wxPyScrolledWindow());
438 void _setCallbackInfo(PyObject* self, PyObject* _class);
440 void SetBestSize(const wxSize& size);
442 void base_DoMoveWindow(int x, int y, int width, int height);
443 void base_DoSetSize(int x, int y, int width, int height,
444 int sizeFlags = wxSIZE_AUTO);
445 void base_DoSetClientSize(int width, int height);
446 void base_DoSetVirtualSize( int x, int y );
449 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
450 "base_DoGetSize() -> (width, height)");
452 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
453 "base_DoGetClientSize() -> (width, height)");
455 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
456 "base_DoGetPosition() -> (x,y)");
458 wxSize base_DoGetVirtualSize() const;
459 wxSize base_DoGetBestSize() const;
461 void base_InitDialog();
462 bool base_TransferDataToWindow();
463 bool base_TransferDataFromWindow();
464 bool base_Validate();
466 bool base_AcceptsFocus() const;
467 bool base_AcceptsFocusFromKeyboard() const;
468 wxSize base_GetMaxSize() const;
470 void base_AddChild(wxWindow* child);
471 void base_RemoveChild(wxWindow* child);
473 bool base_ShouldInheritColours() const;
474 void base_ApplyParentThemeBackground(const wxColour& c);
475 wxVisualAttributes base_GetDefaultAttributes();
479 //---------------------------------------------------------------------------
480 //---------------------------------------------------------------------------