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);
99 IMPLEMENT_DYNAMIC_CLASS(wxPyWindow, wxWindow);
101 IMP_PYCALLBACK_VOID_INT4(wxPyWindow, wxWindow, DoMoveWindow);
102 IMP_PYCALLBACK_VOID_INT5(wxPyWindow, wxWindow, DoSetSize);
103 IMP_PYCALLBACK_VOID_INTINT(wxPyWindow, wxWindow, DoSetClientSize);
104 IMP_PYCALLBACK_VOID_INTINT(wxPyWindow, wxWindow, DoSetVirtualSize);
106 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetSize);
107 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetClientSize);
108 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetPosition);
110 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, DoGetVirtualSize);
111 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, DoGetBestSize);
113 IMP_PYCALLBACK__(wxPyWindow, wxWindow, InitDialog);
114 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, TransferDataFromWindow);
115 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, TransferDataToWindow);
116 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, Validate);
118 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, AcceptsFocus);
119 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, AcceptsFocusFromKeyboard);
120 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, GetMaxSize);
122 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, AddChild);
123 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, RemoveChild);
125 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, ShouldInheritColours);
126 IMP_PYCALLBACK__COLOUR(wxPyWindow, wxWindow, ApplyParentThemeBackground);
127 IMP_PYCALLBACK_VIZATTR_(wxPyWindow, wxWindow, GetDefaultAttributes);
131 // And now the one for SWIG to see
132 MustHaveApp(wxPyWindow);
133 class wxPyWindow : public wxWindow
136 %pythonAppend wxPyWindow "self._setOORInfo(self); self._setCallbackInfo(self, PyWindow)"
137 %pythonAppend wxPyWindow() ""
139 wxPyWindow(wxWindow* parent, const wxWindowID id,
140 const wxPoint& pos = wxDefaultPosition,
141 const wxSize& size = wxDefaultSize,
143 const wxString& name = wxPyPanelNameStr);
145 %name(PrePyWindow) wxPyWindow();
147 void _setCallbackInfo(PyObject* self, PyObject* _class);
150 void SetBestSize(const wxSize& size);
152 void base_DoMoveWindow(int x, int y, int width, int height);
153 void base_DoSetSize(int x, int y, int width, int height,
154 int sizeFlags = wxSIZE_AUTO);
155 void base_DoSetClientSize(int width, int height);
156 void base_DoSetVirtualSize( int x, int y );
159 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
160 "base_DoGetSize() -> (width, height)");
162 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
163 "base_DoGetClientSize() -> (width, height)");
165 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
166 "base_DoGetPosition() -> (x,y)");
168 wxSize base_DoGetVirtualSize() const;
169 wxSize base_DoGetBestSize() const;
171 void base_InitDialog();
172 bool base_TransferDataToWindow();
173 bool base_TransferDataFromWindow();
174 bool base_Validate();
176 bool base_AcceptsFocus() const;
177 bool base_AcceptsFocusFromKeyboard() const;
178 wxSize base_GetMaxSize() const;
180 void base_AddChild(wxWindow* child);
181 void base_RemoveChild(wxWindow* child);
183 bool base_ShouldInheritColours() const;
184 void base_ApplyParentThemeBackground(const wxColour& c);
185 wxVisualAttributes base_GetDefaultAttributes();
188 //---------------------------------------------------------------------------
189 // Do the same thing for wxControl
191 // ** See _pycontrol.i, it was moved there because of dependency on wxControl
194 //---------------------------------------------------------------------------
197 %{ // C++ version of Python aware wxPanel
198 class wxPyPanel : public wxPanel
200 DECLARE_DYNAMIC_CLASS(wxPyPanel)
202 wxPyPanel() : wxPanel() {}
203 wxPyPanel(wxWindow* parent, const wxWindowID id,
204 const wxPoint& pos = wxDefaultPosition,
205 const wxSize& size = wxDefaultSize,
207 const wxString& name = wxPyPanelNameStr)
208 : wxPanel(parent, id, pos, size, style, name) {}
210 void SetBestSize(const wxSize& size) { wxPanel::SetBestSize(size); }
213 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
214 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
215 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
216 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
218 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
219 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
220 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
222 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
223 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
225 DEC_PYCALLBACK__(InitDialog);
226 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
227 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
228 DEC_PYCALLBACK_BOOL_(Validate);
230 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
231 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
232 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
234 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
235 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
237 DEC_PYCALLBACK_BOOL_const(ShouldInheritColours);
238 DEC_PYCALLBACK__COLOUR(ApplyParentThemeBackground);
239 DEC_PYCALLBACK_VIZATTR_(GetDefaultAttributes);
244 IMPLEMENT_DYNAMIC_CLASS(wxPyPanel, wxPanel);
246 IMP_PYCALLBACK_VOID_INT4(wxPyPanel, wxPanel, DoMoveWindow);
247 IMP_PYCALLBACK_VOID_INT5(wxPyPanel, wxPanel, DoSetSize);
248 IMP_PYCALLBACK_VOID_INTINT(wxPyPanel, wxPanel, DoSetClientSize);
249 IMP_PYCALLBACK_VOID_INTINT(wxPyPanel, wxPanel, DoSetVirtualSize);
251 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetSize);
252 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetClientSize);
253 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetPosition);
255 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, DoGetVirtualSize);
256 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, DoGetBestSize);
258 IMP_PYCALLBACK__(wxPyPanel, wxPanel, InitDialog);
259 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, TransferDataFromWindow);
260 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, TransferDataToWindow);
261 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, Validate);
263 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, AcceptsFocus);
264 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, AcceptsFocusFromKeyboard);
265 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, GetMaxSize);
267 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, AddChild);
268 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, RemoveChild);
270 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, ShouldInheritColours);
271 IMP_PYCALLBACK__COLOUR(wxPyPanel, wxPanel, ApplyParentThemeBackground);
272 IMP_PYCALLBACK_VIZATTR_(wxPyPanel, wxPanel, GetDefaultAttributes);
276 // And now the one for SWIG to see
277 MustHaveApp(wxPyPanel);
278 class wxPyPanel : public wxPanel
281 %pythonAppend wxPyPanel "self._setOORInfo(self); self._setCallbackInfo(self, PyPanel)"
282 %pythonAppend wxPyPanel() ""
284 wxPyPanel(wxWindow* parent, const wxWindowID id,
285 const wxPoint& pos = wxDefaultPosition,
286 const wxSize& size = wxDefaultSize,
288 const wxString& name = wxPyPanelNameStr);
290 %name(PrePyPanel) wxPyPanel();
292 void _setCallbackInfo(PyObject* self, PyObject* _class);
294 void SetBestSize(const wxSize& size);
296 void base_DoMoveWindow(int x, int y, int width, int height);
297 void base_DoSetSize(int x, int y, int width, int height,
298 int sizeFlags = wxSIZE_AUTO);
299 void base_DoSetClientSize(int width, int height);
300 void base_DoSetVirtualSize( int x, int y );
303 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
304 "base_DoGetSize() -> (width, height)");
306 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
307 "base_DoGetClientSize() -> (width, height)");
309 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
310 "base_DoGetPosition() -> (x,y)");
312 wxSize base_DoGetVirtualSize() const;
313 wxSize base_DoGetBestSize() const;
315 void base_InitDialog();
316 bool base_TransferDataToWindow();
317 bool base_TransferDataFromWindow();
318 bool base_Validate();
320 bool base_AcceptsFocus() const;
321 bool base_AcceptsFocusFromKeyboard() const;
322 wxSize base_GetMaxSize() const;
324 void base_AddChild(wxWindow* child);
325 void base_RemoveChild(wxWindow* child);
327 bool base_ShouldInheritColours() const ;
328 void base_ApplyParentThemeBackground(const wxColour& c);
329 wxVisualAttributes base_GetDefaultAttributes();
332 //---------------------------------------------------------------------------
333 // and for wxScrolledWindow
335 %{ // C++ version of Python aware wxScrolledWindow
336 class wxPyScrolledWindow : public wxScrolledWindow
338 DECLARE_DYNAMIC_CLASS(wxPyScrolledWindow)
340 wxPyScrolledWindow() : wxScrolledWindow() {}
341 wxPyScrolledWindow(wxWindow* parent, const wxWindowID id,
342 const wxPoint& pos = wxDefaultPosition,
343 const wxSize& size = wxDefaultSize,
345 const wxString& name = wxPyPanelNameStr)
346 : wxScrolledWindow(parent, id, pos, size, style, name) {}
348 void SetBestSize(const wxSize& size) { wxScrolledWindow::SetBestSize(size); }
350 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
351 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
352 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
353 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
355 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
356 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
357 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
359 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
360 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
362 DEC_PYCALLBACK__(InitDialog);
363 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
364 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
365 DEC_PYCALLBACK_BOOL_(Validate);
367 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
368 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
369 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
371 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
372 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
374 DEC_PYCALLBACK_BOOL_const(ShouldInheritColours);
375 DEC_PYCALLBACK__COLOUR(ApplyParentThemeBackground);
376 DEC_PYCALLBACK_VIZATTR_(GetDefaultAttributes);
381 IMPLEMENT_DYNAMIC_CLASS(wxPyScrolledWindow, wxScrolledWindow);
383 IMP_PYCALLBACK_VOID_INT4(wxPyScrolledWindow, wxScrolledWindow, DoMoveWindow);
384 IMP_PYCALLBACK_VOID_INT5(wxPyScrolledWindow, wxScrolledWindow, DoSetSize);
385 IMP_PYCALLBACK_VOID_INTINT(wxPyScrolledWindow, wxScrolledWindow, DoSetClientSize);
386 IMP_PYCALLBACK_VOID_INTINT(wxPyScrolledWindow, wxScrolledWindow, DoSetVirtualSize);
388 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetSize);
389 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetClientSize);
390 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetPosition);
392 IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, DoGetVirtualSize);
393 IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, DoGetBestSize);
395 IMP_PYCALLBACK__(wxPyScrolledWindow, wxScrolledWindow, InitDialog);
396 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, TransferDataFromWindow);
397 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, TransferDataToWindow);
398 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, Validate);
400 IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, AcceptsFocus);
401 IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, AcceptsFocusFromKeyboard);
402 IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, GetMaxSize);
404 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyScrolledWindow, wxScrolledWindow, AddChild);
405 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyScrolledWindow, wxScrolledWindow, RemoveChild);
407 IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, ShouldInheritColours);
408 IMP_PYCALLBACK__COLOUR(wxPyScrolledWindow, wxScrolledWindow, ApplyParentThemeBackground);
409 IMP_PYCALLBACK_VIZATTR_(wxPyScrolledWindow, wxScrolledWindow, GetDefaultAttributes);
413 // And now the one for SWIG to see
414 MustHaveApp(wxPyScrolledWindow);
415 class wxPyScrolledWindow : public wxScrolledWindow
418 %pythonAppend wxPyScrolledWindow "self._setOORInfo(self); self._setCallbackInfo(self, PyPanel)"
419 %pythonAppend wxPyScrolledWindow() ""
421 wxPyScrolledWindow(wxWindow* parent, const wxWindowID id,
422 const wxPoint& pos = wxDefaultPosition,
423 const wxSize& size = wxDefaultSize,
425 const wxString& name = wxPyPanelNameStr);
427 %name(PrePyScrolledWindow) wxPyScrolledWindow();
429 void _setCallbackInfo(PyObject* self, PyObject* _class);
431 void SetBestSize(const wxSize& size);
433 void base_DoMoveWindow(int x, int y, int width, int height);
434 void base_DoSetSize(int x, int y, int width, int height,
435 int sizeFlags = wxSIZE_AUTO);
436 void base_DoSetClientSize(int width, int height);
437 void base_DoSetVirtualSize( int x, int y );
440 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
441 "base_DoGetSize() -> (width, height)");
443 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
444 "base_DoGetClientSize() -> (width, height)");
446 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
447 "base_DoGetPosition() -> (x,y)");
449 wxSize base_DoGetVirtualSize() const;
450 wxSize base_DoGetBestSize() const;
452 void base_InitDialog();
453 bool base_TransferDataToWindow();
454 bool base_TransferDataFromWindow();
455 bool base_Validate();
457 bool base_AcceptsFocus() const;
458 bool base_AcceptsFocusFromKeyboard() const;
459 wxSize base_GetMaxSize() const;
461 void base_AddChild(wxWindow* child);
462 void base_RemoveChild(wxWindow* child);
464 bool base_ShouldInheritColours() const;
465 void base_ApplyParentThemeBackground(const wxColour& c);
466 wxVisualAttributes base_GetDefaultAttributes();
470 //---------------------------------------------------------------------------
471 //---------------------------------------------------------------------------