From d43da706022922ceb9535b638d4cd9d06cc8a388 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sun, 28 Mar 2004 17:01:21 +0000 Subject: [PATCH] Allow overriding ApplyParentThemeBackground git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26427 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/include/wx/wxPython/wxPython_int.h | 22 +++ wxPython/src/_pycontrol.i | 10 +- wxPython/src/_pywindows.i | 149 +++++++++++++++++++- wxPython/src/_windows_rename.i | 1 + 4 files changed, 178 insertions(+), 4 deletions(-) diff --git a/wxPython/include/wx/wxPython/wxPython_int.h b/wxPython/include/wx/wxPython/wxPython_int.h index c3d62ee9b4..86626a626c 100644 --- a/wxPython/include/wx/wxPython/wxPython_int.h +++ b/wxPython/include/wx/wxPython/wxPython_int.h @@ -1559,6 +1559,28 @@ extern wxPyApp *wxPythonApp; PCLASS::CBNAME(cell, x, y); \ } +//--------------------------------------------------------------------------- + +#define DEC_PYCALLBACK__COLOUR(CBNAME) \ + void CBNAME(const wxColour& c); \ + void base_##CBNAME(const wxColour& c) + +#define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \ + void CLASS::CBNAME(const wxColour& c) { \ + bool found; \ + bool blocked = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \ + wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \ + Py_DECREF(obj); \ + } \ + wxPyEndBlockThreads(blocked); \ + if (! found) \ + PCLASS::CBNAME(c); \ + } \ + void CLASS::base_##CBNAME(const wxColour& c) { \ + PCLASS::CBNAME(c); \ + } //--------------------------------------------------------------------------- diff --git a/wxPython/src/_pycontrol.i b/wxPython/src/_pycontrol.i index 2037153d70..11d65af865 100644 --- a/wxPython/src/_pycontrol.i +++ b/wxPython/src/_pycontrol.i @@ -61,6 +61,7 @@ public: DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild); DEC_PYCALLBACK_BOOL_(ShouldInheritColours); + DEC_PYCALLBACK__COLOUR(ApplyParentThemeBackground); PYPRIVATE; }; @@ -92,6 +93,7 @@ IMP_PYCALLBACK_VOID_WXWINBASE(wxPyControl, wxControl, AddChild); IMP_PYCALLBACK_VOID_WXWINBASE(wxPyControl, wxControl, RemoveChild); IMP_PYCALLBACK_BOOL_(wxPyControl, wxControl, ShouldInheritColours); +IMP_PYCALLBACK__COLOUR(wxPyControl, wxControl, ApplyParentThemeBackground); %} // And now the one for SWIG to see @@ -99,6 +101,7 @@ class wxPyControl : public wxControl { public: %pythonAppend wxPyControl "self._setOORInfo(self); self._setCallbackInfo(self, PyControl)" + %pythonAppend wxPyControl() "" wxPyControl(wxWindow* parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, @@ -107,9 +110,9 @@ public: const wxValidator& validator=wxDefaultValidator, const wxString& name = wxPyControlNameStr); + %name(PrePyControl) wxPyControl(); + void _setCallbackInfo(PyObject* self, PyObject* _class); - %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyControl)" - %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" void base_DoMoveWindow(int x, int y, int width, int height); @@ -142,6 +145,9 @@ public: void base_AddChild(wxWindow* child); void base_RemoveChild(wxWindow* child); + + bool base_ShouldInheritColours(); + void base_ApplyParentThemeBackground(const wxColour& c); }; diff --git a/wxPython/src/_pywindows.i b/wxPython/src/_pywindows.i index 9592dfa288..d6c60712df 100644 --- a/wxPython/src/_pywindows.i +++ b/wxPython/src/_pywindows.i @@ -91,6 +91,7 @@ public: DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild); DEC_PYCALLBACK_BOOL_(ShouldInheritColours); + DEC_PYCALLBACK__COLOUR(ApplyParentThemeBackground); PYPRIVATE; }; @@ -122,6 +123,8 @@ IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, AddChild); IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, RemoveChild); IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, ShouldInheritColours); +IMP_PYCALLBACK__COLOUR(wxPyWindow, wxWindow, ApplyParentThemeBackground); + %} // And now the one for SWIG to see @@ -129,6 +132,7 @@ class wxPyWindow : public wxWindow { public: %pythonAppend wxPyWindow "self._setOORInfo(self); self._setCallbackInfo(self, PyWindow)" + %pythonAppend wxPyWindow() "" wxPyWindow(wxWindow* parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, @@ -136,6 +140,8 @@ public: long style = 0, const wxString& name = wxPyPanelNameStr); + %name(PrePyWindow) wxPyWindow(); + void _setCallbackInfo(PyObject* self, PyObject* _class); @@ -169,6 +175,9 @@ public: void base_AddChild(wxWindow* child); void base_RemoveChild(wxWindow* child); + + bool base_ShouldInheritColours(); + void base_ApplyParentThemeBackground(const wxColour& c); }; //--------------------------------------------------------------------------- @@ -219,6 +228,7 @@ public: DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild); DEC_PYCALLBACK_BOOL_(ShouldInheritColours); + DEC_PYCALLBACK__COLOUR(ApplyParentThemeBackground); PYPRIVATE; }; @@ -250,6 +260,7 @@ IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, AddChild); IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, RemoveChild); IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, ShouldInheritColours); +IMP_PYCALLBACK__COLOUR(wxPyPanel, wxPanel, ApplyParentThemeBackground); %} // And now the one for SWIG to see @@ -257,6 +268,7 @@ class wxPyPanel : public wxPanel { public: %pythonAppend wxPyPanel "self._setOORInfo(self); self._setCallbackInfo(self, PyPanel)" + %pythonAppend wxPyPanel() "" wxPyPanel(wxWindow* parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, @@ -264,9 +276,139 @@ public: long style = 0, const wxString& name = wxPyPanelNameStr); + %name(PrePyPanel) wxPyPanel(); + + void _setCallbackInfo(PyObject* self, PyObject* _class); + + + void base_DoMoveWindow(int x, int y, int width, int height); + void base_DoSetSize(int x, int y, int width, int height, + int sizeFlags = wxSIZE_AUTO); + void base_DoSetClientSize(int width, int height); + void base_DoSetVirtualSize( int x, int y ); + + DocDeclA( + void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const, + "base_DoGetSize() -> (width, height)"); + DocDeclA( + void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const, + "base_DoGetClientSize() -> (width, height)"); + DocDeclA( + void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const, + "base_DoGetPosition() -> (x,y)"); + + wxSize base_DoGetVirtualSize() const; + wxSize base_DoGetBestSize() const; + + void base_InitDialog(); + bool base_TransferDataToWindow(); + bool base_TransferDataFromWindow(); + bool base_Validate(); + + bool base_AcceptsFocus() const; + bool base_AcceptsFocusFromKeyboard() const; + wxSize base_GetMaxSize() const; + + void base_AddChild(wxWindow* child); + void base_RemoveChild(wxWindow* child); + + bool base_ShouldInheritColours(); + void base_ApplyParentThemeBackground(const wxColour& c); +}; + +//--------------------------------------------------------------------------- +// and for wxScrolledWindow + +%{ // C++ version of Python aware wxScrolledWindow +class wxPyScrolledWindow : public wxScrolledWindow +{ + DECLARE_DYNAMIC_CLASS(wxPyScrolledWindow) +public: + wxPyScrolledWindow() : wxScrolledWindow() {} + wxPyScrolledWindow(wxWindow* parent, const wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxPyPanelNameStr) + : wxScrolledWindow(parent, id, pos, size, style, name) {} + + + DEC_PYCALLBACK_VOID_INT4(DoMoveWindow); + DEC_PYCALLBACK_VOID_INT5(DoSetSize); + DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize); + DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize); + + DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize); + DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize); + DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition); + + DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize); + DEC_PYCALLBACK_SIZE_const(DoGetBestSize); + + DEC_PYCALLBACK__(InitDialog); + DEC_PYCALLBACK_BOOL_(TransferDataFromWindow); + DEC_PYCALLBACK_BOOL_(TransferDataToWindow); + DEC_PYCALLBACK_BOOL_(Validate); + + DEC_PYCALLBACK_BOOL_const(AcceptsFocus); + DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard); + DEC_PYCALLBACK_SIZE_const(GetMaxSize); + + DEC_PYCALLBACK_VOID_WXWINBASE(AddChild); + DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild); + + DEC_PYCALLBACK_BOOL_(ShouldInheritColours); + DEC_PYCALLBACK__COLOUR(ApplyParentThemeBackground); + + PYPRIVATE; +}; + +IMPLEMENT_DYNAMIC_CLASS(wxPyScrolledWindow, wxScrolledWindow); + +IMP_PYCALLBACK_VOID_INT4(wxPyScrolledWindow, wxScrolledWindow, DoMoveWindow); +IMP_PYCALLBACK_VOID_INT5(wxPyScrolledWindow, wxScrolledWindow, DoSetSize); +IMP_PYCALLBACK_VOID_INTINT(wxPyScrolledWindow, wxScrolledWindow, DoSetClientSize); +IMP_PYCALLBACK_VOID_INTINT(wxPyScrolledWindow, wxScrolledWindow, DoSetVirtualSize); + +IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetSize); +IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetClientSize); +IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyScrolledWindow, wxScrolledWindow, DoGetPosition); + +IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, DoGetVirtualSize); +IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, DoGetBestSize); + +IMP_PYCALLBACK__(wxPyScrolledWindow, wxScrolledWindow, InitDialog); +IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, TransferDataFromWindow); +IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, TransferDataToWindow); +IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, Validate); + +IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, AcceptsFocus); +IMP_PYCALLBACK_BOOL_const(wxPyScrolledWindow, wxScrolledWindow, AcceptsFocusFromKeyboard); +IMP_PYCALLBACK_SIZE_const(wxPyScrolledWindow, wxScrolledWindow, GetMaxSize); + +IMP_PYCALLBACK_VOID_WXWINBASE(wxPyScrolledWindow, wxScrolledWindow, AddChild); +IMP_PYCALLBACK_VOID_WXWINBASE(wxPyScrolledWindow, wxScrolledWindow, RemoveChild); + +IMP_PYCALLBACK_BOOL_(wxPyScrolledWindow, wxScrolledWindow, ShouldInheritColours); +IMP_PYCALLBACK__COLOUR(wxPyScrolledWindow, wxScrolledWindow, ApplyParentThemeBackground); +%} + +// And now the one for SWIG to see +class wxPyScrolledWindow : public wxScrolledWindow +{ +public: + %pythonAppend wxPyScrolledWindow "self._setOORInfo(self); self._setCallbackInfo(self, PyPanel)" + %pythonAppend wxPyScrolledWindow() "" + + wxPyScrolledWindow(wxWindow* parent, const wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxPyPanelNameStr); + + %name(PrePyScrolledWindow) wxPyScrolledWindow(); + void _setCallbackInfo(PyObject* self, PyObject* _class); - %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyPanel)" - %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" void base_DoMoveWindow(int x, int y, int width, int height); @@ -299,6 +441,9 @@ public: void base_AddChild(wxWindow* child); void base_RemoveChild(wxWindow* child); + + bool base_ShouldInheritColours(); + void base_ApplyParentThemeBackground(const wxColour& c); }; diff --git a/wxPython/src/_windows_rename.i b/wxPython/src/_windows_rename.i index f68235f3ed..ceff5000ed 100644 --- a/wxPython/src/_windows_rename.i +++ b/wxPython/src/_windows_rename.i @@ -105,6 +105,7 @@ %rename(MDIClientWindow) wxMDIClientWindow; %rename(PyWindow) wxPyWindow; %rename(PyPanel) wxPyPanel; +%rename(PyScrolledWindow) wxPyScrolledWindow; %rename(PRINT_MODE_NONE) wxPRINT_MODE_NONE; %rename(PRINT_MODE_PREVIEW) wxPRINT_MODE_PREVIEW; %rename(PRINT_MODE_FILE) wxPRINT_MODE_FILE; -- 2.45.2