Roll wxPyMake_wxSizer into wxPyMake_wxObject.
authorRobin Dunn <robin@alldunn.com>
Mon, 2 May 2005 23:42:16 +0000 (23:42 +0000)
committerRobin Dunn <robin@alldunn.com>
Mon, 2 May 2005 23:42:16 +0000 (23:42 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33928 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/src/helpers.cpp
wxPython/src/my_typemaps.i

index 9b0c4c79ab464a8958c385fe96c68dae4644981a..96bed66402b31c42c768dfce589867c2762152a7 100644 (file)
@@ -1001,6 +1001,7 @@ void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName) {
 PyObject*  wxPyMake_wxObject(wxObject* source, bool setThisOwn, bool checkEvtHandler) {
     PyObject* target = NULL;
     bool      isEvtHandler = false;
+    bool      isSizer = false;
 
     if (source) {
         // If it's derived from wxEvtHandler then there may
@@ -1017,6 +1018,18 @@ PyObject*  wxPyMake_wxObject(wxObject* source, bool setThisOwn, bool checkEvtHan
             }
         }
 
+        // Also check for wxSizer
+        if (!target && wxIsKindOf(source, wxSizer)) {
+            isSizer = true;
+            wxSizer* sz = (wxSizer*)source;
+            wxPyOORClientData* data = (wxPyOORClientData*)sz->GetClientObject();
+            if (data) {
+                target = data->m_obj;
+                if (target)
+                    Py_INCREF(target);
+            }
+        }
+        
         if (! target) {
             // Otherwise make it the old fashioned way by making a new shadow
             // object and putting this pointer in it.  Look up the class
@@ -1034,6 +1047,8 @@ PyObject*  wxPyMake_wxObject(wxObject* source, bool setThisOwn, bool checkEvtHan
                 target = wxPyConstructObject((void*)source, name, setThisOwn);
                 if (target && isEvtHandler)
                     ((wxEvtHandler*)source)->SetClientObject(new wxPyOORClientData(target));
+                if (target && isSizer)
+                    ((wxSizer*)source)->SetClientObject(new wxPyOORClientData(target));
             } else {
                 wxString msg(wxT("wxPython class not found for "));
                 msg += source->GetClassInfo()->GetClassName();
@@ -1049,25 +1064,8 @@ PyObject*  wxPyMake_wxObject(wxObject* source, bool setThisOwn, bool checkEvtHan
 
 
 PyObject*  wxPyMake_wxSizer(wxSizer* source, bool setThisOwn) {
-    PyObject* target = NULL;
 
-    if (source && wxIsKindOf(source, wxSizer)) {
-        // If it's derived from wxSizer then there may already be a pointer to
-        // a Python object that we can use in the OOR data.
-        wxSizer* sz = (wxSizer*)source;
-        wxPyOORClientData* data = (wxPyOORClientData*)sz->GetClientObject();
-        if (data) {
-            target = data->m_obj;
-            if (target)
-                Py_INCREF(target);
-        }
-    }
-    if (! target) {
-        target = wxPyMake_wxObject(source, setThisOwn, false);
-        if (target != Py_None)
-            ((wxSizer*)source)->SetClientObject(new wxPyOORClientData(target));
-    }
-    return target;
+    return wxPyMake_wxObject(source, setThisOwn);
 }
 
 
@@ -1187,7 +1185,7 @@ wxPyBlock_t wxPyBeginBlockThreads() {
     return blocked;
 #endif
 #else
-    return false;
+    return (wxPyBlock_t)0;
 #endif
 }
 
index 46d7bfb7d2e48d4f49c3ed8a7644ff41eb96ea3e..4e9707a3b11397fb7b5cd0c333420439a3c7cf70 100644 (file)
@@ -374,7 +374,7 @@ MAKE_INT_ARRAY_TYPEMAPS(styles, styles_field)
 %typemap(out) wxDialog*                 { $result = wxPyMake_wxObject($1, $owner); }
 %typemap(out) wxScrolledWindow*         { $result = wxPyMake_wxObject($1, $owner); }
 
-%typemap(out) wxSizer*                  { $result = wxPyMake_wxSizer($1, $owner); }
+%typemap(out) wxSizer*                  { $result = wxPyMake_wxObject($1, $owner); }
 
 
 //---------------------------------------------------------------------------