Allow overriding ApplyParentThemeBackground

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26427 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-03-28 17:01:21 +00:00
parent 27b60fafb8
commit d43da70602
4 changed files with 178 additions and 4 deletions

View File

@@ -1559,6 +1559,28 @@ extern wxPyApp *wxPythonApp;
PCLASS::CBNAME(cell, x, y); \ 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); \
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -61,6 +61,7 @@ public:
DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild); DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
DEC_PYCALLBACK_BOOL_(ShouldInheritColours); DEC_PYCALLBACK_BOOL_(ShouldInheritColours);
DEC_PYCALLBACK__COLOUR(ApplyParentThemeBackground);
PYPRIVATE; PYPRIVATE;
}; };
@@ -92,6 +93,7 @@ IMP_PYCALLBACK_VOID_WXWINBASE(wxPyControl, wxControl, AddChild);
IMP_PYCALLBACK_VOID_WXWINBASE(wxPyControl, wxControl, RemoveChild); IMP_PYCALLBACK_VOID_WXWINBASE(wxPyControl, wxControl, RemoveChild);
IMP_PYCALLBACK_BOOL_(wxPyControl, wxControl, ShouldInheritColours); IMP_PYCALLBACK_BOOL_(wxPyControl, wxControl, ShouldInheritColours);
IMP_PYCALLBACK__COLOUR(wxPyControl, wxControl, ApplyParentThemeBackground);
%} %}
// And now the one for SWIG to see // And now the one for SWIG to see
@@ -99,6 +101,7 @@ class wxPyControl : public wxControl
{ {
public: public:
%pythonAppend wxPyControl "self._setOORInfo(self); self._setCallbackInfo(self, PyControl)" %pythonAppend wxPyControl "self._setOORInfo(self); self._setCallbackInfo(self, PyControl)"
%pythonAppend wxPyControl() ""
wxPyControl(wxWindow* parent, const wxWindowID id, wxPyControl(wxWindow* parent, const wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
@@ -107,9 +110,9 @@ public:
const wxValidator& validator=wxDefaultValidator, const wxValidator& validator=wxDefaultValidator,
const wxString& name = wxPyControlNameStr); const wxString& name = wxPyControlNameStr);
%name(PrePyControl) wxPyControl();
void _setCallbackInfo(PyObject* self, PyObject* _class); 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); void base_DoMoveWindow(int x, int y, int width, int height);
@@ -142,6 +145,9 @@ public:
void base_AddChild(wxWindow* child); void base_AddChild(wxWindow* child);
void base_RemoveChild(wxWindow* child); void base_RemoveChild(wxWindow* child);
bool base_ShouldInheritColours();
void base_ApplyParentThemeBackground(const wxColour& c);
}; };

View File

@@ -91,6 +91,7 @@ public:
DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild); DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
DEC_PYCALLBACK_BOOL_(ShouldInheritColours); DEC_PYCALLBACK_BOOL_(ShouldInheritColours);
DEC_PYCALLBACK__COLOUR(ApplyParentThemeBackground);
PYPRIVATE; PYPRIVATE;
}; };
@@ -122,6 +123,8 @@ IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, AddChild);
IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, RemoveChild); IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWindow, wxWindow, RemoveChild);
IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, ShouldInheritColours); IMP_PYCALLBACK_BOOL_(wxPyWindow, wxWindow, ShouldInheritColours);
IMP_PYCALLBACK__COLOUR(wxPyWindow, wxWindow, ApplyParentThemeBackground);
%} %}
// And now the one for SWIG to see // And now the one for SWIG to see
@@ -129,6 +132,7 @@ class wxPyWindow : public wxWindow
{ {
public: public:
%pythonAppend wxPyWindow "self._setOORInfo(self); self._setCallbackInfo(self, PyWindow)" %pythonAppend wxPyWindow "self._setOORInfo(self); self._setCallbackInfo(self, PyWindow)"
%pythonAppend wxPyWindow() ""
wxPyWindow(wxWindow* parent, const wxWindowID id, wxPyWindow(wxWindow* parent, const wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
@@ -136,6 +140,8 @@ public:
long style = 0, long style = 0,
const wxString& name = wxPyPanelNameStr); const wxString& name = wxPyPanelNameStr);
%name(PrePyWindow) wxPyWindow();
void _setCallbackInfo(PyObject* self, PyObject* _class); void _setCallbackInfo(PyObject* self, PyObject* _class);
@@ -169,6 +175,9 @@ public:
void base_AddChild(wxWindow* child); void base_AddChild(wxWindow* child);
void base_RemoveChild(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_VOID_WXWINBASE(RemoveChild);
DEC_PYCALLBACK_BOOL_(ShouldInheritColours); DEC_PYCALLBACK_BOOL_(ShouldInheritColours);
DEC_PYCALLBACK__COLOUR(ApplyParentThemeBackground);
PYPRIVATE; PYPRIVATE;
}; };
@@ -250,6 +260,7 @@ IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, AddChild);
IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, RemoveChild); IMP_PYCALLBACK_VOID_WXWINBASE(wxPyPanel, wxPanel, RemoveChild);
IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, ShouldInheritColours); IMP_PYCALLBACK_BOOL_(wxPyPanel, wxPanel, ShouldInheritColours);
IMP_PYCALLBACK__COLOUR(wxPyPanel, wxPanel, ApplyParentThemeBackground);
%} %}
// And now the one for SWIG to see // And now the one for SWIG to see
@@ -257,6 +268,7 @@ class wxPyPanel : public wxPanel
{ {
public: public:
%pythonAppend wxPyPanel "self._setOORInfo(self); self._setCallbackInfo(self, PyPanel)" %pythonAppend wxPyPanel "self._setOORInfo(self); self._setCallbackInfo(self, PyPanel)"
%pythonAppend wxPyPanel() ""
wxPyPanel(wxWindow* parent, const wxWindowID id, wxPyPanel(wxWindow* parent, const wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
@@ -264,9 +276,9 @@ public:
long style = 0, long style = 0,
const wxString& name = wxPyPanelNameStr); const wxString& name = wxPyPanelNameStr);
%name(PrePyPanel) wxPyPanel();
void _setCallbackInfo(PyObject* self, PyObject* _class); 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); void base_DoMoveWindow(int x, int y, int width, int height);
@@ -299,6 +311,139 @@ public:
void base_AddChild(wxWindow* child); void base_AddChild(wxWindow* child);
void base_RemoveChild(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);
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);
}; };

View File

@@ -105,6 +105,7 @@
%rename(MDIClientWindow) wxMDIClientWindow; %rename(MDIClientWindow) wxMDIClientWindow;
%rename(PyWindow) wxPyWindow; %rename(PyWindow) wxPyWindow;
%rename(PyPanel) wxPyPanel; %rename(PyPanel) wxPyPanel;
%rename(PyScrolledWindow) wxPyScrolledWindow;
%rename(PRINT_MODE_NONE) wxPRINT_MODE_NONE; %rename(PRINT_MODE_NONE) wxPRINT_MODE_NONE;
%rename(PRINT_MODE_PREVIEW) wxPRINT_MODE_PREVIEW; %rename(PRINT_MODE_PREVIEW) wxPRINT_MODE_PREVIEW;
%rename(PRINT_MODE_FILE) wxPRINT_MODE_FILE; %rename(PRINT_MODE_FILE) wxPRINT_MODE_FILE;