diff --git a/etg/object.py b/etg/object.py index d3388664..cecfff09 100644 --- a/etg/object.py +++ b/etg/object.py @@ -81,24 +81,8 @@ def run(): doc='Deletes the C++ object this Python object is a proxy for.', transferThis=True) # TODO: Check this - # Teach SIP how to convert to specific class types - c.addItem(etgtools.WigCode("""\ - %ConvertToSubClassCode - const wxClassInfo* info = sipCpp->GetClassInfo(); - wxString name = info->GetClassName(); - bool exists = sipFindType(name) != NULL; - while (info && !exists) { - info = info->GetBaseClass1(); - name = info->GetClassName(); - exists = sipFindType(name) != NULL; - } - if (info) - sipType = sipFindType(name); - else - sipType = NULL; - %End - """)) - + + tools.addSipConvertToSubClassCode(c) #----------------------------------------------------------------- tools.doCommonTweaks(module) diff --git a/etg/window.py b/etg/window.py index 57134067..4c69e329 100644 --- a/etg/window.py +++ b/etg/window.py @@ -249,6 +249,7 @@ def run(): ##c.addProperty('GtkWidget GetGtkWidget') tools.fixWindowClass(c) + tools.addSipConvertToSubClassCode(c) # for compatibility with Classic c.addPyMethod('GetPositionTuple', '(self)', 'return self.GetPosition()', deprecated=True) diff --git a/etgtools/tweaker_tools.py b/etgtools/tweaker_tools.py index 6f17ca0d..169466c9 100644 --- a/etgtools/tweaker_tools.py +++ b/etgtools/tweaker_tools.py @@ -275,6 +275,27 @@ def addWindowVirtuals(klass): klass.addItem(extractors.WigCode(txt)) klass.addPublic() + +def addSipConvertToSubClassCode(klass): + """ + Teach SIP how to convert to specific subclass types + """ + klass.addItem(extractors.WigCode("""\ + %ConvertToSubClassCode + const wxClassInfo* info = sipCpp->GetClassInfo(); + wxString name = info->GetClassName(); + bool exists = sipFindType(name) != NULL; + while (info && !exists) { + info = info->GetBaseClass1(); + name = info->GetClassName(); + exists = sipFindType(name) != NULL; + } + if (info) + sipType = sipFindType(name); + else + sipType = NULL; + %End + """)) def getEtgFiles(names):