X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fd512ba2864a4ddf82ef70caf7a5b107d34906c8..4326f7b7b26b255ed657dffdce4fa8a459c07a36:/wxPython/contrib/xrc/xrc.i diff --git a/wxPython/contrib/xrc/xrc.i b/wxPython/contrib/xrc/xrc.i index 037e1eb214..f2be7c4107 100644 --- a/wxPython/contrib/xrc/xrc.i +++ b/wxPython/contrib/xrc/xrc.i @@ -16,7 +16,7 @@ %{ #include "wxPython.h" #include "pyistream.h" -#include "wx/xrc/xml.h" +#include "wx/xml/xml.h" #include "wx/xrc/xmlres.h" #include #include @@ -48,6 +48,9 @@ static const wxString wxPyIconString(wxT("icon")); static const wxString wxPyFontString(wxT("font")); %} + +class wxPyXmlSubclassFactory; + //--------------------------------------------------------------------------- enum wxXmlResourceFlags @@ -128,6 +131,12 @@ public: // Removes all handlers void ClearHandlers(); + // Registers subclasses factory for use in XRC. This function is not meant + // for public use, please see the comment above wxXmlSubclassFactory + // definition. + static void AddSubclassFactory(wxPyXmlSubclassFactory *factory); + + // Loads menu from resource. Returns NULL on failure. wxMenu *LoadMenu(const wxString& name); @@ -199,6 +208,9 @@ public: // Returns flags, which may be a bitlist of wxXRC_USE_LOCALE and wxXRC_NO_SUBCLASSING. int GetFlags(); + // Set flags after construction. + void SetFlags(int flags) { m_flags = flags; } + }; //---------------------------------------------------------------------- @@ -215,6 +227,31 @@ XMLCTRL = XRCCTRL " //---------------------------------------------------------------------- +// wxXmlSubclassFactory + + +%{ +class wxPyXmlSubclassFactory : public wxXmlSubclassFactory +{ +public: + wxPyXmlSubclassFactory() {} + DEC_PYCALLBACK_OBJECT_STRING_pure(Create); + PYPRIVATE; +}; + +IMP_PYCALLBACK_OBJECT_STRING_pure(wxPyXmlSubclassFactory, wxXmlSubclassFactory, Create); +%} + + +%name(wxXmlSubclassFactory)class wxPyXmlSubclassFactory { +public: + wxPyXmlSubclassFactory(); + + void _setCallbackInfo(PyObject* self, PyObject* _class); + %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxXmlSubclassFactory)" +}; + + //---------------------------------------------------------------------- // In order to provide wrappers for wxXmlResourceHandler we need to also // provide the classes for representing and parsing XML. @@ -374,6 +411,13 @@ public: return self->GetEncoding(); #endif } + void SetEncoding(const wxString& enc) { + #if wxUSE_UNICODE + // do nothing + #else + self->SetEncoding(enc); + #endif + } } }; @@ -396,34 +440,6 @@ public: DEC_PYCALLBACK_OBJECT__pure(DoCreateResource); DEC_PYCALLBACK_BOOL_NODE_pure(CanHandle); -// wxObject* DoCreateResource() { -// wxObject* rv = NULL; -// wxPyBeginBlockThreads(); -// if (wxPyCBH_findCallback(m_myInst, "DoCreateResource")) { -// PyObject* ro; -// ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); -// if (ro) { -// SWIG_GetPtrObj(ro, (void **)&rv, "_wxObject_p"); -// Py_DECREF(ro); -// } -// } -// wxPyEndBlockThreads(); -// return rv; -// } - -// bool CanHandle(wxXmlNode* a) { -// bool rv=FALSE; -// wxPyBeginBlockThreads(); -// if (wxPyCBH_findCallback(m_myInst, "CanHandle")) { -// PyObject* obj = wxPyConstructObject((void*)a, "wxXmlNode", 0); -// rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); -// Py_DECREF(obj); -// } -// wxPyEndBlockThreads(); -// return rv; -// } - - // accessors for protected members @@ -661,9 +677,6 @@ public: %init %{ - wxClassInfo::CleanUpClasses(); - wxClassInfo::InitializeClasses(); - wxXmlInitResourceModule(); wxXmlResource::Get()->InitAllHandlers();