void wxPyEventThunker(wxObject*, wxEvent& event);
-HELPEREXPORT PyObject* wxPyConstructObject(void* ptr, char* className);
+HELPEREXPORT PyObject* wxPyConstructObject(void* ptr, const char* className);
HELPEREXPORT bool wxPyRestoreThread();
HELPEREXPORT void wxPySaveThread(bool doSave);
-HELPEREXPORT PyObject* wxPy_ConvertList(wxListBase* list, char* className);
+HELPEREXPORT PyObject* wxPy_ConvertList(wxListBase* list, const char* className);
//----------------------------------------------------------------------
// These are helpers used by the typemaps
private:
PyObject* m_self;
PyObject* m_lastFound;
+ int m_incRef;
};
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+// These classes can be derived from in Python and passed through the event
+// system without loosing anything. They do this by keeping a reference to
+// themselves and some special case handling in wxPyCallback::EventThunker.
+
+
+class wxPyEvtSelfRef {
+public:
+ wxPyEvtSelfRef();
+ ~wxPyEvtSelfRef();
+
+ void SetSelf(PyObject* self, bool clone=FALSE);
+ PyObject* GetSelf() const;
+
+protected:
+ PyObject* m_self;
+ bool m_cloned;
+};
+
+
+class wxPyEvent : public wxEvent, public wxPyEvtSelfRef {
+ DECLARE_DYNAMIC_CLASS(wxPyEvent)
+public:
+ wxPyEvent(int id=0);
+ ~wxPyEvent();
+
+ void CopyObject(wxObject& dest) const;
+};
+
+
+class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef {
+ DECLARE_DYNAMIC_CLASS(wxPyCommandEvent)
+public:
+ wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
+ ~wxPyCommandEvent();
+
+ void CopyObject(wxObject& dest) const;
+};
+
//---------------------------------------------------------------------------
// These macros are used to implement the virtual methods that should
//---------------------------------------------------------------------------
#define PYPRIVATE \
- void _setSelf(PyObject* self, int incref=TRUE) { \
+ void _setSelf(PyObject* self, int incref=1) { \
m_myInst.setSelf(self, incref); \
} \
private: wxPyCallbackHelper m_myInst;