]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/wxPython/src/helpers.h
Some updates and fixes
[wxWidgets.git] / utils / wxPython / src / helpers.h
index bcf992aca611297670f173c2060c09ab553d876e..ae0d93b672eed1a931325312f3e4507732a23399 100644 (file)
@@ -70,6 +70,20 @@ HELPEREXPORT PyObject* wxPyConstructObject(void* ptr, const char* className);
 HELPEREXPORT bool wxPyRestoreThread();
 HELPEREXPORT void wxPySaveThread(bool doSave);
 HELPEREXPORT PyObject* wxPy_ConvertList(wxListBase* list, const char* className);
+HELPEREXPORT long wxPyGetWinHandle(wxWindow* win);
+
+//----------------------------------------------------------------------
+
+class wxPyUserData : public wxObject {
+public:
+    wxPyUserData(PyObject* obj) { m_obj = obj; Py_INCREF(m_obj); }
+    ~wxPyUserData() {
+        bool doSave = wxPyRestoreThread();
+        Py_DECREF(m_obj);
+        wxPySaveThread(doSave);
+    }
+    PyObject* m_obj;
+};
 
 //----------------------------------------------------------------------
 // These are helpers used by the typemaps
@@ -122,19 +136,6 @@ public:
     PyObject*   m_func;
 };
 
-//---------------------------------------------------------------------------
-
-//  class wxPyMenu : public wxMenu {
-//  public:
-//      wxPyMenu(const wxString& title = "", PyObject* func=NULL);
-//      ~wxPyMenu();
-
-//  private:
-//      static void MenuCallback(wxMenu& menu, wxCommandEvent& evt);
-//      PyObject*   func;
-//  };
-
-
 //---------------------------------------------------------------------------
 
 class wxPyTimer : public wxTimer {
@@ -179,14 +180,15 @@ 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.
+// These Event 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 {
@@ -230,7 +232,7 @@ public:
 //---------------------------------------------------------------------------
 
 #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;
@@ -311,7 +313,7 @@ public:
         bool doSave = wxPyRestoreThread();                              \
         if (m_myInst.findCallback(#CBNAME))                             \
             rval = m_myInst.callCallback(Py_BuildValue("(i)",a));       \
-        else rval = false;                                              \
+        else rval = FALSE;                                              \
         wxPySaveThread(doSave);                                         \
         return rval;                                                    \
     }
@@ -739,7 +741,7 @@ public:
 
 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME)                     \
     bool CLASS::CBNAME(const wxHtmlTag& a)  {                                   \
-        bool rval = false;                                                      \
+        bool rval = FALSE;                                                      \
         bool doSave = wxPyRestoreThread();                                      \
         if (m_myInst.findCallback(#CBNAME))                                     \
             rval = m_myInst.callCallback(Py_BuildValue("(O)",                   \