Roll wxPyMake_wxSizer into wxPyMake_wxObject.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33928 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2005-05-02 23:42:16 +00:00
parent aac71f4f44
commit f3c2a60b95
2 changed files with 18 additions and 20 deletions

View File

@@ -1001,6 +1001,7 @@ void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName) {
PyObject* wxPyMake_wxObject(wxObject* source, bool setThisOwn, bool checkEvtHandler) { PyObject* wxPyMake_wxObject(wxObject* source, bool setThisOwn, bool checkEvtHandler) {
PyObject* target = NULL; PyObject* target = NULL;
bool isEvtHandler = false; bool isEvtHandler = false;
bool isSizer = false;
if (source) { if (source) {
// If it's derived from wxEvtHandler then there may // 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) { if (! target) {
// Otherwise make it the old fashioned way by making a new shadow // Otherwise make it the old fashioned way by making a new shadow
// object and putting this pointer in it. Look up the class // 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); target = wxPyConstructObject((void*)source, name, setThisOwn);
if (target && isEvtHandler) if (target && isEvtHandler)
((wxEvtHandler*)source)->SetClientObject(new wxPyOORClientData(target)); ((wxEvtHandler*)source)->SetClientObject(new wxPyOORClientData(target));
if (target && isSizer)
((wxSizer*)source)->SetClientObject(new wxPyOORClientData(target));
} else { } else {
wxString msg(wxT("wxPython class not found for ")); wxString msg(wxT("wxPython class not found for "));
msg += source->GetClassInfo()->GetClassName(); 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* wxPyMake_wxSizer(wxSizer* source, bool setThisOwn) {
PyObject* target = NULL;
if (source && wxIsKindOf(source, wxSizer)) { return wxPyMake_wxObject(source, setThisOwn);
// 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;
} }
@@ -1187,7 +1185,7 @@ wxPyBlock_t wxPyBeginBlockThreads() {
return blocked; return blocked;
#endif #endif
#else #else
return false; return (wxPyBlock_t)0;
#endif #endif
} }

View File

@@ -374,7 +374,7 @@ MAKE_INT_ARRAY_TYPEMAPS(styles, styles_field)
%typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); } %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxScrolledWindow* { $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); }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------