]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/wxPython/src/helpers.h
Made db.h compile (removed this wxODBC_ONLY_FARWRD_XXXXXX),
[wxWidgets.git] / utils / wxPython / src / helpers.h
index 9540e728e40bde414d38c480ea6df47fd8370e0d..57f670fb19cdff62cad4c4aea17f05f395b9a0f0 100644 (file)
@@ -66,10 +66,10 @@ PyObject* __wxSetDictionary(PyObject*, PyObject* args);
 
 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
@@ -179,9 +179,50 @@ public:
 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
@@ -190,7 +231,7 @@ private:
 //---------------------------------------------------------------------------
 
 #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;