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);
109 IMPLEMENT_DYNAMIC_CLASS(wxPyWindow, wxWindow);
111 IMP_PYCALLBACK_VOID_INT4(wxPyWindow, wxWindow, DoMoveWindow);
112 IMP_PYCALLBACK_VOID_INT5(wxPyWindow, wxWindow, DoSetSize);
113 IMP_PYCALLBACK_VOID_INTINT(wxPyWindow, wxWindow, DoSetClientSize);
114 IMP_PYCALLBACK_VOID_INTINT(wxPyWindow, wxWindow, DoSetVirtualSize);
116 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetSize);
117 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetClientSize);
118 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWindow, wxWindow, DoGetPosition);
120 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, DoGetVirtualSize);
121 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, DoGetBestSize);
123 IMP_PYCALLBACK__(wxPyWindow, wxWindow, InitDialog);
124 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, TransferDataFromWindow);
125 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, TransferDataToWindow);
126 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, Validate);
128 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, AcceptsFocus);
129 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, AcceptsFocusFromKeyboard);
130 IMP_PYCALLBACK_SIZE_const(wxPyWindow, wxWindow, GetMaxSize);
132 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, AddChild);
133 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, RemoveChild);
135 IMP_PYCALLBACK_BOOL_const(wxPyWindow, wxWindow, ShouldInheritColours);
136 IMP_PYCALLBACK_VIZATTR_(wxPyWindow, wxWindow, GetDefaultAttributes);
138 IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, HasTransparentBackground);
141 // And now the one for SWIG to see
142 MustHaveApp(wxPyWindow);
143 class wxPyWindow : public wxWindow
146 %pythonAppend wxPyWindow "self._setOORInfo(self); self._setCallbackInfo(self, PyWindow)"
147 %pythonAppend wxPyWindow() ""
149 wxPyWindow(wxWindow* parent, const wxWindowID id=-1,
150 const wxPoint& pos = wxDefaultPosition,
151 const wxSize& size = wxDefaultSize,
153 const wxString& name = wxPyPanelNameStr);
155 %RenameCtor(PrePyWindow, wxPyWindow());
157 void _setCallbackInfo(PyObject* self, PyObject* _class);
159 void SetBestSize(const wxSize& size);
160 bool DoEraseBackground(wxDC* dc);
162 void base_DoMoveWindow(int x, int y, int width, int height);
163 void base_DoSetSize(int x, int y, int width, int height,
164 int sizeFlags = wxSIZE_AUTO);
165 void base_DoSetClientSize(int width, int height);
166 void base_DoSetVirtualSize( int x, int y );
169 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
170 "base_DoGetSize() -> (width, height)");
172 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
173 "base_DoGetClientSize() -> (width, height)");
175 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
176 "base_DoGetPosition() -> (x,y)");
178 wxSize base_DoGetVirtualSize() const;
179 wxSize base_DoGetBestSize() const;
181 void base_InitDialog();
182 bool base_TransferDataToWindow();
183 bool base_TransferDataFromWindow();
184 bool base_Validate();
186 bool base_AcceptsFocus() const;
187 bool base_AcceptsFocusFromKeyboard() const;
188 wxSize base_GetMaxSize() const;
190 void base_AddChild(wxWindow* child);
191 void base_RemoveChild(wxWindow* child);
193 bool base_ShouldInheritColours() const;
194 wxVisualAttributes base_GetDefaultAttributes();
197 //---------------------------------------------------------------------------
198 // Do the same thing for wxControl
200 // ** See _pycontrol.i, it was moved there because of dependency on wxControl
203 //---------------------------------------------------------------------------
206 %{ // C++ version of Python aware wxPanel
207 class wxPyPanel : public wxPanel
209 DECLARE_DYNAMIC_CLASS(wxPyPanel)
211 wxPyPanel() : wxPanel() {}
212 wxPyPanel(wxWindow* parent, const wxWindowID id,
213 const wxPoint& pos = wxDefaultPosition,
214 const wxSize& size = wxDefaultSize,
216 const wxString& name = wxPyPanelNameStr)
217 : wxPanel(parent, id, pos, size, style, name) {}
219 void SetBestSize(const wxSize& size) { wxPanel::SetBestSize(size); }
220 bool DoEraseBackground(wxDC* dc) {
222 return wxWindow::DoEraseBackground(dc->GetHDC());
224 dc->SetBackground(wxBrush(GetBackgroundColour()));
231 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
232 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
233 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
234 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
236 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
237 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
238 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
240 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
241 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
243 DEC_PYCALLBACK__(InitDialog);
244 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
245 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
246 DEC_PYCALLBACK_BOOL_(Validate);
248 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
249 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
250 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
252 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
253 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
255 DEC_PYCALLBACK_BOOL_const(ShouldInheritColours);
256 DEC_PYCALLBACK_VIZATTR_(GetDefaultAttributes);
258 DEC_PYCALLBACK_BOOL_(HasTransparentBackground);
263 IMPLEMENT_DYNAMIC_CLASS(wxPyPanel, wxPanel);
265 IMP_PYCALLBACK_VOID_INT4(wxPyPanel, wxPanel, DoMoveWindow);
266 IMP_PYCALLBACK_VOID_INT5(wxPyPanel, wxPanel, DoSetSize);
267 IMP_PYCALLBACK_VOID_INTINT(wxPyPanel, wxPanel, DoSetClientSize);
268 IMP_PYCALLBACK_VOID_INTINT(wxPyPanel, wxPanel, DoSetVirtualSize);
270 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetSize);
271 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetClientSize);
272 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyPanel, wxPanel, DoGetPosition);
274 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, DoGetVirtualSize);
275 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, DoGetBestSize);
277 IMP_PYCALLBACK__(wxPyPanel, wxPanel, InitDialog);
278 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, TransferDataFromWindow);
279 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, TransferDataToWindow);
280 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, Validate);
282 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, AcceptsFocus);
283 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, AcceptsFocusFromKeyboard);
284 IMP_PYCALLBACK_SIZE_const(wxPyPanel, wxPanel, GetMaxSize);
286 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, AddChild);
287 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, RemoveChild);
289 IMP_PYCALLBACK_BOOL_const(wxPyPanel, wxPanel, ShouldInheritColours);
290 IMP_PYCALLBACK_VIZATTR_(wxPyPanel, wxPanel, GetDefaultAttributes);
292 IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, HasTransparentBackground);
295 // And now the one for SWIG to see
296 MustHaveApp(wxPyPanel);
297 class wxPyPanel : public wxPanel
300 %pythonAppend wxPyPanel "self._setOORInfo(self); self._setCallbackInfo(self, PyPanel)"
301 %pythonAppend wxPyPanel() ""
303 wxPyPanel(wxWindow* parent, const wxWindowID id=-1,
304 const wxPoint& pos = wxDefaultPosition,
305 const wxSize& size = wxDefaultSize,
307 const wxString& name = wxPyPanelNameStr);
309 %RenameCtor(PrePyPanel, wxPyPanel());
311 void _setCallbackInfo(PyObject* self, PyObject* _class);
313 void SetBestSize(const wxSize& size);
314 bool DoEraseBackground(wxDC* dc);
316 void base_DoMoveWindow(int x, int y, int width, int height);
317 void base_DoSetSize(int x, int y, int width, int height,
318 int sizeFlags = wxSIZE_AUTO);
319 void base_DoSetClientSize(int width, int height);
320 void base_DoSetVirtualSize( int x, int y );
323 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
324 "base_DoGetSize() -> (width, height)");
326 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
327 "base_DoGetClientSize() -> (width, height)");
329 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
330 "base_DoGetPosition() -> (x,y)");
332 wxSize base_DoGetVirtualSize() const;
333 wxSize base_DoGetBestSize() const;
335 void base_InitDialog();
336 bool base_TransferDataToWindow();
337 bool base_TransferDataFromWindow();
338 bool base_Validate();
340 bool base_AcceptsFocus() const;
341 bool base_AcceptsFocusFromKeyboard() const;
342 wxSize base_GetMaxSize() const;
344 void base_AddChild(wxWindow* child);
345 void base_RemoveChild(wxWindow* child);
347 bool base_ShouldInheritColours() const ;
348 wxVisualAttributes base_GetDefaultAttributes();
351 //---------------------------------------------------------------------------
352 // and for wxScrolledWindow
354 %{ // C++ version of Python aware wxScrolledWindow
355 class wxPyScrolledWindow : public wxScrolledWindow
357 DECLARE_DYNAMIC_CLASS(wxPyScrolledWindow)
359 wxPyScrolledWindow() : wxScrolledWindow() {}
360 wxPyScrolledWindow(wxWindow* parent, const wxWindowID id,
361 const wxPoint& pos = wxDefaultPosition,
362 const wxSize& size = wxDefaultSize,
364 const wxString& name = wxPyPanelNameStr)
365 : wxScrolledWindow(parent, id, pos, size, style, name) {}
367 void SetBestSize(const wxSize& size) { wxScrolledWindow::SetBestSize(size); }
368 bool DoEraseBackground(wxDC* dc) {
370 return wxWindow::DoEraseBackground(dc->GetHDC());
372 dc->SetBackground(wxBrush(GetBackgroundColour()));
378 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
379 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
380 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
381 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
383 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
384 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
385 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
387 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
388 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
390 DEC_PYCALLBACK__(InitDialog);
391 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
392 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
393 DEC_PYCALLBACK_BOOL_(Validate);
395 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
396 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
397 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
399 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
400 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
402 DEC_PYCALLBACK_BOOL_const(ShouldInheritColours);
403 DEC_PYCALLBACK_VIZATTR_(GetDefaultAttributes);
405 DEC_PYCALLBACK_BOOL_(HasTransparentBackground);
410 IMPLEMENT_DYNAMIC_CLASS(wxPyScrolledWindow, wxScrolledWindow);
412 IMP_PYCALLBACK_VOID_INT4(wxPyScrolledWindow, wxScrolledWindow, DoMoveWindow);
413 IMP_PYCALLBACK_VOID_INT5(wxPyScrolledWindow, wxScrolledWindow, DoSetSize);
414 IMP_PYCALLBACK_VOID_INTINT(wxPyScrolledWindow, wxScrolledWindow, DoSetClientSize);
415 IMP_PYCALLBACK_VOID_INTINT(wxPyScrolledWindow, wxScrolledWindow, DoSetVirtualSize);
417 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetSize);
418 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetClientSize);
419 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetPosition);
421 IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, DoGetVirtualSize);
422 IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, DoGetBestSize);
424 IMP_PYCALLBACK__(wxPyScrolledWindow, wxScrolledWindow, InitDialog);
425 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, TransferDataFromWindow);
426 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, TransferDataToWindow);
427 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, Validate);
429 IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, AcceptsFocus);
430 IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, AcceptsFocusFromKeyboard);
431 IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, GetMaxSize);
433 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyScrolledWindow, wxScrolledWindow, AddChild);
434 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyScrolledWindow, wxScrolledWindow, RemoveChild);
436 IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, ShouldInheritColours);
437 IMP_PYCALLBACK_VIZATTR_(wxPyScrolledWindow, wxScrolledWindow, GetDefaultAttributes);
439 IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, HasTransparentBackground);
442 // And now the one for SWIG to see
443 MustHaveApp(wxPyScrolledWindow);
444 class wxPyScrolledWindow : public wxScrolledWindow
447 %pythonAppend wxPyScrolledWindow "self._setOORInfo(self); self._setCallbackInfo(self, PyPanel)"
448 %pythonAppend wxPyScrolledWindow() ""
450 wxPyScrolledWindow(wxWindow* parent, const wxWindowID id=-1,
451 const wxPoint& pos = wxDefaultPosition,
452 const wxSize& size = wxDefaultSize,
454 const wxString& name = wxPyPanelNameStr);
456 %RenameCtor(PrePyScrolledWindow, wxPyScrolledWindow());
458 void _setCallbackInfo(PyObject* self, PyObject* _class);
460 void SetBestSize(const wxSize& size);
461 bool DoEraseBackground(wxDC* dc);
463 void base_DoMoveWindow(int x, int y, int width, int height);
464 void base_DoSetSize(int x, int y, int width, int height,
465 int sizeFlags = wxSIZE_AUTO);
466 void base_DoSetClientSize(int width, int height);
467 void base_DoSetVirtualSize( int x, int y );
470 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
471 "base_DoGetSize() -> (width, height)");
473 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
474 "base_DoGetClientSize() -> (width, height)");
476 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
477 "base_DoGetPosition() -> (x,y)");
479 wxSize base_DoGetVirtualSize() const;
480 wxSize base_DoGetBestSize() const;
482 void base_InitDialog();
483 bool base_TransferDataToWindow();
484 bool base_TransferDataFromWindow();
485 bool base_Validate();
487 bool base_AcceptsFocus() const;
488 bool base_AcceptsFocusFromKeyboard() const;
489 wxSize base_GetMaxSize() const;
491 void base_AddChild(wxWindow* child);
492 void base_RemoveChild(wxWindow* child);
494 bool base_ShouldInheritColours() const;
495 wxVisualAttributes base_GetDefaultAttributes();
499 //---------------------------------------------------------------------------
500 //---------------------------------------------------------------------------