+
+class wxPyEvent : public wxCommandEvent {
+ DECLARE_DYNAMIC_CLASS(wxPyEvent)
+public:
+ wxPyEvent(wxEventType commandType = wxEVT_NULL, PyObject* userData = Py_None);
+ ~wxPyEvent();
+
+ void SetUserData(PyObject* userData);
+ PyObject* GetUserData();
+
+private:
+ PyObject* m_userData;
+};
+
+
+
+
+
+//---------------------------------------------------------------------------
+// This class holds an instance of a Python Shadow Class object and assists
+// with looking up and invoking Python callback methods from C++ virtual
+// method redirections. For all classes which have virtuals which should be
+// overridable in wxPython, a new subclass is created that contains a
+// wxPyCallbackList. This list is used to hold references to the Python
+// methods.
+//---------------------------------------------------------------------------
+
+class wxPyCallbackHelper {
+public:
+ wxPyCallbackHelper();
+ ~wxPyCallbackHelper();
+
+ void setSelf(PyObject* self);
+
+ bool findCallback(const wxString& name);
+ int callCallback(PyObject* argTuple);
+ PyObject* callCallbackObj(PyObject* argTuple);
+
+private:
+ PyObject* m_self;
+ PyObject* m_lastFound;
+};
+
+
+
+//---------------------------------------------------------------------------
+// These macros are used to implement the virtual methods that should
+// redirect to a Python method if one exists. The names designate the
+// return type, if any as well as any parameter types.
+//---------------------------------------------------------------------------
+
+#define PYCALLBACK_BOOL_INTINT(PCLASS, CBNAME) \
+ bool CBNAME(int a, int b) { \
+ if (m_myInst.findCallback(#CBNAME)) \
+ return m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \
+ else \
+ return PCLASS::CBNAME(a,b); \
+ } \
+ bool base_##CBNAME(int a, int b) { \
+ return PCLASS::CBNAME(a,b); \
+ }
+
+//---------------------------------------------------------------------------
+
+#define PYCALLBACK_BOOL_INT(PCLASS, CBNAME) \
+ bool CBNAME(int a) { \
+ if (m_myInst.findCallback(#CBNAME)) \
+ return m_myInst.callCallback(Py_BuildValue("(i)",a)); \
+ else \
+ return PCLASS::CBNAME(a); \
+ } \
+ bool base_##CBNAME(int a) { \
+ return PCLASS::CBNAME(a); \
+ }
+
+#define PYCALLBACK_BOOL_INT_pure(PCLASS, CBNAME) \
+ bool CBNAME(int a) { \
+ if (m_myInst.findCallback(#CBNAME)) \
+ return m_myInst.callCallback(Py_BuildValue("(i)",a)); \
+ else return false; \
+ }
+
+
+//---------------------------------------------------------------------------
+
+#define PYCALLBACK__(PCLASS, CBNAME) \
+ void CBNAME() { \
+ if (m_myInst.findCallback(#CBNAME)) \
+ m_myInst.callCallback(Py_BuildValue("()")); \
+ else \
+ PCLASS::CBNAME(); \
+ } \
+ void base_##CBNAME() { \
+ PCLASS::CBNAME(); \
+ }
+
+//---------------------------------------------------------------------------
+
+#define PYPRIVATE \
+ void _setSelf(PyObject* self) { \
+ m_myInst.setSelf(self); \
+ } \
+ private: wxPyCallbackHelper m_myInst;
+
+//---------------------------------------------------------------------------