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 //---------------------------------------------------------------------------
52 %{ // C++ version of Python aware wxWindow
53 class wxPyWindow : public wxWindow
55 DECLARE_DYNAMIC_CLASS(wxPyWindow)
57 wxPyWindow() : wxWindow() {}
58 wxPyWindow(wxWindow* parent, const wxWindowID id,
59 const wxPoint& pos = wxDefaultPosition,
60 const wxSize& size = wxDefaultSize,
62 const wxString& name = wxPyPanelNameStr)
63 : wxWindow(parent, id, pos, size, style, name) {}
65 void SetBestSize(const wxSize& size) { wxWindow::SetBestSize(size); }
67 bool DoEraseBackground(wxDC* dc) {
69 return wxWindow::DoEraseBackground(dc->GetHDC());
71 dc->SetBackground(wxBrush(GetBackgroundColour()));
77 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
78 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
79 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
80 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
82 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
83 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
84 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
86 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
87 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
89 DEC_PYCALLBACK__(InitDialog);
90 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
91 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
92 DEC_PYCALLBACK_BOOL_(Validate);
94 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
95 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
96 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
98 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
99 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
101 DEC_PYCALLBACK_BOOL_const(ShouldInheritColours);
102 DEC_PYCALLBACK_VIZATTR_(GetDefaultAttributes);
104 DEC_PYCALLBACK_BOOL_(HasTransparentBackground);
106 DEC_PYCALLBACK_VOID_(OnInternalIdle);
111 IMPLEMENT_DYNAMIC_CLASS(wxPyWindow, wxWindow);
113 IMP_PYCALLBACK_VOID_INT4(wxPyWindow, wxWindow, DoMoveWindow);
114 IMP_PYCALLBACK_VOID_INT5(wxPyWindow, wxWindow, DoSetSize);
115 IMP_PYCALLBACK_VOID_INTINT(wxPyWindow, wxWindow, DoSetClientSize);
116 IMP_PYCALLBACK_VOID_INTINT(wxPyWindow, wxWindow, DoSetVirtualSize);
118 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetSize);
119 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetClientSize);
120 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetPosition);
122 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, DoGetVirtualSize);
123 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, DoGetBestSize);
125 IMP_PYCALLBACK__(wxPyWindow, wxWindow, InitDialog);
126 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, TransferDataFromWindow);
127 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, TransferDataToWindow);
128 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, Validate);
130 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, AcceptsFocus);
131 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, AcceptsFocusFromKeyboard);
132 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, GetMaxSize);
134 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, AddChild);
135 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, RemoveChild);
137 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, ShouldInheritColours);
138 IMP_PYCALLBACK_VIZATTR_(wxPyWindow, wxWindow, GetDefaultAttributes);
140 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, HasTransparentBackground);
142 IMP_PYCALLBACK_VOID_(wxPyWindow, wxWindow, OnInternalIdle);
145 // And now the one for SWIG to see
146 MustHaveApp(wxPyWindow);
147 class wxPyWindow : public wxWindow
150 %pythonAppend wxPyWindow "self._setOORInfo(self); self._setCallbackInfo(self, PyWindow)"
151 %pythonAppend wxPyWindow() ""
153 wxPyWindow(wxWindow* parent, const wxWindowID id=-1,
154 const wxPoint& pos = wxDefaultPosition,
155 const wxSize& size = wxDefaultSize,
157 const wxString& name = wxPyPanelNameStr);
159 %RenameCtor(PrePyWindow, wxPyWindow());
161 void _setCallbackInfo(PyObject* self, PyObject* _class);
163 void SetBestSize(const wxSize& size);
164 bool DoEraseBackground(wxDC* dc);
166 void base_DoMoveWindow(int x, int y, int width, int height);
167 void base_DoSetSize(int x, int y, int width, int height,
168 int sizeFlags = wxSIZE_AUTO);
169 void base_DoSetClientSize(int width, int height);
170 void base_DoSetVirtualSize( int x, int y );
173 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
174 "base_DoGetSize() -> (width, height)");
176 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
177 "base_DoGetClientSize() -> (width, height)");
179 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
180 "base_DoGetPosition() -> (x,y)");
182 wxSize base_DoGetVirtualSize() const;
183 wxSize base_DoGetBestSize() const;
185 void base_InitDialog();
186 bool base_TransferDataToWindow();
187 bool base_TransferDataFromWindow();
188 bool base_Validate();
190 bool base_AcceptsFocus() const;
191 bool base_AcceptsFocusFromKeyboard() const;
192 wxSize base_GetMaxSize() const;
194 void base_AddChild(wxWindow* child);
195 void base_RemoveChild(wxWindow* child);
197 bool base_ShouldInheritColours() const;
198 wxVisualAttributes base_GetDefaultAttributes();
200 void base_OnInternalIdle();
204 //---------------------------------------------------------------------------
205 // Do the same thing for wxControl
207 // ** See _pycontrol.i, it was moved there because of dependency on wxControl
210 //---------------------------------------------------------------------------
213 %{ // C++ version of Python aware wxPanel
214 class wxPyPanel : public wxPanel
216 DECLARE_DYNAMIC_CLASS(wxPyPanel)
218 wxPyPanel() : wxPanel() {}
219 wxPyPanel(wxWindow* parent, const wxWindowID id,
220 const wxPoint& pos = wxDefaultPosition,
221 const wxSize& size = wxDefaultSize,
223 const wxString& name = wxPyPanelNameStr)
224 : wxPanel(parent, id, pos, size, style, name) {}
226 void SetBestSize(const wxSize& size) { wxPanel::SetBestSize(size); }
227 bool DoEraseBackground(wxDC* dc) {
229 return wxWindow::DoEraseBackground(dc->GetHDC());
231 dc->SetBackground(wxBrush(GetBackgroundColour()));
238 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
239 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
240 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
241 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
243 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
244 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
245 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
247 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
248 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
250 DEC_PYCALLBACK__(InitDialog);
251 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
252 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
253 DEC_PYCALLBACK_BOOL_(Validate);
255 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
256 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
257 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
259 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
260 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
262 DEC_PYCALLBACK_BOOL_const(ShouldInheritColours);
263 DEC_PYCALLBACK_VIZATTR_(GetDefaultAttributes);
265 DEC_PYCALLBACK_BOOL_(HasTransparentBackground);
267 DEC_PYCALLBACK_VOID_(OnInternalIdle);
272 IMPLEMENT_DYNAMIC_CLASS(wxPyPanel, wxPanel);
274 IMP_PYCALLBACK_VOID_INT4(wxPyPanel, wxPanel, DoMoveWindow);
275 IMP_PYCALLBACK_VOID_INT5(wxPyPanel, wxPanel, DoSetSize);
276 IMP_PYCALLBACK_VOID_INTINT(wxPyPanel, wxPanel, DoSetClientSize);
277 IMP_PYCALLBACK_VOID_INTINT(wxPyPanel, wxPanel, DoSetVirtualSize);
279 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetSize);
280 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetClientSize);
281 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetPosition);
283 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, DoGetVirtualSize);
284 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, DoGetBestSize);
286 IMP_PYCALLBACK__(wxPyPanel, wxPanel, InitDialog);
287 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, TransferDataFromWindow);
288 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, TransferDataToWindow);
289 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, Validate);
291 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, AcceptsFocus);
292 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, AcceptsFocusFromKeyboard);
293 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, GetMaxSize);
295 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, AddChild);
296 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, RemoveChild);
298 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, ShouldInheritColours);
299 IMP_PYCALLBACK_VIZATTR_(wxPyPanel, wxPanel, GetDefaultAttributes);
301 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, HasTransparentBackground);
303 IMP_PYCALLBACK_VOID_(wxPyPanel, wxPanel, OnInternalIdle);
306 // And now the one for SWIG to see
307 MustHaveApp(wxPyPanel);
308 class wxPyPanel : public wxPanel
311 %pythonAppend wxPyPanel "self._setOORInfo(self); self._setCallbackInfo(self, PyPanel)"
312 %pythonAppend wxPyPanel() ""
314 wxPyPanel(wxWindow* parent, const wxWindowID id=-1,
315 const wxPoint& pos = wxDefaultPosition,
316 const wxSize& size = wxDefaultSize,
318 const wxString& name = wxPyPanelNameStr);
320 %RenameCtor(PrePyPanel, wxPyPanel());
322 void _setCallbackInfo(PyObject* self, PyObject* _class);
324 void SetBestSize(const wxSize& size);
325 bool DoEraseBackground(wxDC* dc);
327 void base_DoMoveWindow(int x, int y, int width, int height);
328 void base_DoSetSize(int x, int y, int width, int height,
329 int sizeFlags = wxSIZE_AUTO);
330 void base_DoSetClientSize(int width, int height);
331 void base_DoSetVirtualSize( int x, int y );
334 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
335 "base_DoGetSize() -> (width, height)");
337 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
338 "base_DoGetClientSize() -> (width, height)");
340 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
341 "base_DoGetPosition() -> (x,y)");
343 wxSize base_DoGetVirtualSize() const;
344 wxSize base_DoGetBestSize() const;
346 void base_InitDialog();
347 bool base_TransferDataToWindow();
348 bool base_TransferDataFromWindow();
349 bool base_Validate();
351 bool base_AcceptsFocus() const;
352 bool base_AcceptsFocusFromKeyboard() const;
353 wxSize base_GetMaxSize() const;
355 void base_AddChild(wxWindow* child);
356 void base_RemoveChild(wxWindow* child);
358 bool base_ShouldInheritColours() const ;
359 wxVisualAttributes base_GetDefaultAttributes();
361 void base_OnInternalIdle();
365 //---------------------------------------------------------------------------
366 // and for wxScrolledWindow
368 %{ // C++ version of Python aware wxScrolledWindow
369 class wxPyScrolledWindow : public wxScrolledWindow
371 DECLARE_DYNAMIC_CLASS(wxPyScrolledWindow)
373 wxPyScrolledWindow() : wxScrolledWindow() {}
374 wxPyScrolledWindow(wxWindow* parent, const wxWindowID id,
375 const wxPoint& pos = wxDefaultPosition,
376 const wxSize& size = wxDefaultSize,
378 const wxString& name = wxPyPanelNameStr)
379 : wxScrolledWindow(parent, id, pos, size, style, name) {}
381 void SetBestSize(const wxSize& size) { wxScrolledWindow::SetBestSize(size); }
382 bool DoEraseBackground(wxDC* dc) {
384 return wxWindow::DoEraseBackground(dc->GetHDC());
386 dc->SetBackground(wxBrush(GetBackgroundColour()));
392 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
393 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
394 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
395 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
397 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
398 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
399 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
401 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
402 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
404 DEC_PYCALLBACK__(InitDialog);
405 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
406 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
407 DEC_PYCALLBACK_BOOL_(Validate);
409 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
410 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
411 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
413 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
414 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
416 DEC_PYCALLBACK_BOOL_const(ShouldInheritColours);
417 DEC_PYCALLBACK_VIZATTR_(GetDefaultAttributes);
419 DEC_PYCALLBACK_BOOL_(HasTransparentBackground);
421 DEC_PYCALLBACK_VOID_(OnInternalIdle);
426 IMPLEMENT_DYNAMIC_CLASS(wxPyScrolledWindow, wxScrolledWindow);
428 IMP_PYCALLBACK_VOID_INT4(wxPyScrolledWindow, wxScrolledWindow, DoMoveWindow);
429 IMP_PYCALLBACK_VOID_INT5(wxPyScrolledWindow, wxScrolledWindow, DoSetSize);
430 IMP_PYCALLBACK_VOID_INTINT(wxPyScrolledWindow, wxScrolledWindow, DoSetClientSize);
431 IMP_PYCALLBACK_VOID_INTINT(wxPyScrolledWindow, wxScrolledWindow, DoSetVirtualSize);
433 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetSize);
434 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetClientSize);
435 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetPosition);
437 IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, DoGetVirtualSize);
438 IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, DoGetBestSize);
440 IMP_PYCALLBACK__(wxPyScrolledWindow, wxScrolledWindow, InitDialog);
441 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, TransferDataFromWindow);
442 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, TransferDataToWindow);
443 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, Validate);
445 IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, AcceptsFocus);
446 IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, AcceptsFocusFromKeyboard);
447 IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, GetMaxSize);
449 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyScrolledWindow, wxScrolledWindow, AddChild);
450 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyScrolledWindow, wxScrolledWindow, RemoveChild);
452 IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, ShouldInheritColours);
453 IMP_PYCALLBACK_VIZATTR_(wxPyScrolledWindow, wxScrolledWindow, GetDefaultAttributes);
455 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, HasTransparentBackground);
457 IMP_PYCALLBACK_VOID_(wxPyScrolledWindow, wxScrolledWindow, OnInternalIdle);
460 // And now the one for SWIG to see
461 MustHaveApp(wxPyScrolledWindow);
462 class wxPyScrolledWindow : public wxScrolledWindow
465 %pythonAppend wxPyScrolledWindow "self._setOORInfo(self); self._setCallbackInfo(self, PyScrolledWindow)"
466 %pythonAppend wxPyScrolledWindow() ""
468 wxPyScrolledWindow(wxWindow* parent, const wxWindowID id=-1,
469 const wxPoint& pos = wxDefaultPosition,
470 const wxSize& size = wxDefaultSize,
472 const wxString& name = wxPyPanelNameStr);
474 %RenameCtor(PrePyScrolledWindow, wxPyScrolledWindow());
476 void _setCallbackInfo(PyObject* self, PyObject* _class);
478 void SetBestSize(const wxSize& size);
479 bool DoEraseBackground(wxDC* dc);
481 void base_DoMoveWindow(int x, int y, int width, int height);
482 void base_DoSetSize(int x, int y, int width, int height,
483 int sizeFlags = wxSIZE_AUTO);
484 void base_DoSetClientSize(int width, int height);
485 void base_DoSetVirtualSize( int x, int y );
488 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
489 "base_DoGetSize() -> (width, height)");
491 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
492 "base_DoGetClientSize() -> (width, height)");
494 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
495 "base_DoGetPosition() -> (x,y)");
497 wxSize base_DoGetVirtualSize() const;
498 wxSize base_DoGetBestSize() const;
500 void base_InitDialog();
501 bool base_TransferDataToWindow();
502 bool base_TransferDataFromWindow();
503 bool base_Validate();
505 bool base_AcceptsFocus() const;
506 bool base_AcceptsFocusFromKeyboard() const;
507 wxSize base_GetMaxSize() const;
509 void base_AddChild(wxWindow* child);
510 void base_RemoveChild(wxWindow* child);
512 bool base_ShouldInheritColours() const;
513 wxVisualAttributes base_GetDefaultAttributes();
515 void base_OnInternalIdle();
520 //---------------------------------------------------------------------------
521 //---------------------------------------------------------------------------