Пример #1
0
def parseAndTweakModule():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING, False)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxTextEntry')
    assert isinstance(c, etgtools.ClassDef)
    c.abstract = True
    tools.removeVirtuals(c)

    c.find('GetSelection.from').out = True
    c.find('GetSelection.to').out = True
    c.find('GetRange.from').name = 'from_'
    c.find('GetRange.to').name = 'to_'
    c.find('Remove.from').name = 'from_'
    c.find('Remove.to').name = 'to_'
    c.find('Replace.from').name = 'from_'
    c.find('Replace.to').name = 'to_'
    c.find('SetSelection.from').name = 'from_'
    c.find('SetSelection.to').name = 'to_'
    c.find('AutoComplete').findOverload('wxTextCompleter').find(
        'completer').transfer = True

    # Re-enable virtualness for (Can)Cut/Copy/Paste/Undo/Redo
    tools.fixTextClipboardMethods(c)

    return module
Пример #2
0
def parseAndTweakModule():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxComboBox')
    assert isinstance(c, etgtools.ClassDef)
    tools.fixWindowClass(c)

    tools.fixTextClipboardMethods(c)

    c.find('wxComboBox').findOverload('wxString choices').ignore()
    c.find('wxComboBox').findOverload('wxArrayString').find(
        'choices').default = 'wxArrayString()'
    c.find('wxComboBox').findOverload('wxArrayString').find(
        'value').default = 'wxEmptyString'

    c.find('Create').findOverload('wxString choices').ignore()
    c.find('Create').findOverload('wxArrayString').find(
        'choices').default = 'wxArrayString()'
    c.find('Create').findOverload('wxArrayString').find(
        'value').default = 'wxEmptyString'

    # When the from,to are set as output parameters the overloaded methods
    # will be ambiguous, so let's give this one a new name.
    m = c.find('GetSelection').renameOverload('long *from, long *to',
                                              'GetTextSelection')
    m.find('from').out = True
    m.find('to').out = True

    # For SetSelection we want to keep the existing method since it is
    # inherited from base classes and has no ambiguities, so just add a new
    # method for SetTextSelection instead of renaming.
    orig = c.find('SetSelection').findOverload('from')
    orig.find('from').name = 'from_'
    orig.find('to').name = 'to_'
    m = etgtools.CppMethodDef.FromMethod(orig)
    m.overloads = []
    m.name = 'SetTextSelection'
    m.argsString = '(long from_, long to_)'
    m.body = "self->SetSelection(from_, to_);"
    c.insertItemAfter(c.find('SetSelection'), m)

    # The docs say to not use this one.
    c.find('IsEmpty').ignore()

    c.addPyCode(
        "ComboBox.SetMark = wx.deprecated(ComboBox.SetTextSelection, 'Use SetTextSelection instead.')"
    )
    c.addPyCode(
        "ComboBox.GetMark = wx.deprecated(ComboBox.GetTextSelection, 'Use GetTextSelection instead.')"
    )

    module.addGlobalStr('wxComboBoxNameStr', c)
    return module
Пример #3
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxComboBox')
    assert isinstance(c, etgtools.ClassDef)
    tools.fixWindowClass(c)

    tools.fixTextClipboardMethods(c)

    c.find('wxComboBox').findOverload('wxString choices').ignore()
    c.find('wxComboBox').findOverload('wxArrayString').find('choices').default = 'wxArrayString()'
    c.find('wxComboBox').findOverload('wxArrayString').find('value').default = 'wxEmptyString'

    c.find('Create').findOverload('wxString choices').ignore()
    c.find('Create').findOverload('wxArrayString').find('choices').default = 'wxArrayString()'
    c.find('Create').findOverload('wxArrayString').find('value').default = 'wxEmptyString'

    # When the from,to are set as output parameters the overloaded methods
    # will be ambiguous, so let's give this one a new name.
    m = c.find('GetSelection').renameOverload('long *from, long *to', 'GetTextSelection')
    m.find('from').out = True
    m.find('to').out = True

    # For SetSelection we want to keep the existing method since it is
    # inherited from base classes and has no ambiguities, so just add a new
    # method for SetTextSelection instead of renaming.
    orig = c.find('SetSelection').findOverload('from')
    orig.find('from').name = 'from_'
    orig.find('to').name = 'to_'
    m = etgtools.CppMethodDef.FromMethod(orig)
    m.overloads = []
    m.name = 'SetTextSelection'
    m.argsString = '(long from_, long to_)'
    m.body = "self->SetSelection(from_, to_);"
    c.insertItemAfter(c.find('SetSelection'), m)


    # The docs say to not use this one.
    c.find('IsEmpty').ignore()

    c.addPyCode("ComboBox.SetMark = wx.deprecated(ComboBox.SetTextSelection, 'Use SetTextSelection instead.')")
    c.addPyCode("ComboBox.GetMark = wx.deprecated(ComboBox.GetTextSelection, 'Use GetTextSelection instead.')")

    module.addGlobalStr('wxComboBoxNameStr', c)

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Пример #4
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    #-----------------------------------------------------------------
    # ignore some macros since most of this set are not simple numbers
    for item in module.items:
        if item.name.startswith('wxRICHTEXT_DEFAULT'):
            item.ignore()

    #-----------------------------------------------------------------
    c = module.find('wxRichTextContextMenuPropertiesInfo')
    assert isinstance(c, etgtools.ClassDef)
    tools.ignoreConstOverloads(c)

    #-----------------------------------------------------------------
    c = module.find('wxRichTextCtrl')
    tools.fixWindowClass(c)
    c.bases = ['wxControl'
               ]  # wxTextCtrlIface, wxScrollHelper are also bases...
    c.find('GetSelection').findOverload('from').ignore()
    tools.ignoreConstOverloads(c)

    c.find('PositionToXY.x').out = True
    c.find('PositionToXY.y').out = True

    c.find('HitTest.pos').out = True
    c.find('HitTest.col').out = True
    c.find('HitTest.row').out = True
    c.find('HitTest').renameOverload('row', 'HitTestXY')

    c.find('GetRange.from').name = 'from_'
    c.find('GetRange.to').name = 'to_'
    c.find('Remove.from').name = 'from_'
    c.find('Remove.to').name = 'to_'
    c.find('Replace.from').name = 'from_'
    c.find('Replace.to').name = 'to_'
    c.find('SetSelection.from').name = 'from_'
    c.find('SetSelection.to').name = 'to_'

    c.find('SetListStyle.def').name = 'styleDef'
    c.find('ApplyStyle.def').name = 'styleDef'

    tools.fixTextClipboardMethods(c)

    c.addPyMethod('GetDefaultStyle',
                  '(self)',
                  'return self.GetDefaultStyleEx()',
                  deprecated='Use GetDefaultStyleEx instead')

    # Make sure that all the methods from wxTextEntry are included. This is
    # needed because we are pretending that this class only derives from
    # wxControl but the real C++ class also derives from wxTextCtrlIface
    # which derives from wxTextEntryBase.
    import textentry
    mod = textentry.parseAndTweakModule()
    klass = mod.find('wxTextEntry')
    items = [
        item for item in klass.items if isinstance(item, etgtools.MethodDef)
        and not item.isCtor and not item.isDtor and not c.findItem(item.name)
    ]
    c.items.extend(items)

    # TODO: What about the wxScrollHelper base class

    #-----------------------------------------------------------------
    c = module.find('wxRichTextEvent')
    tools.fixEventClass(c)

    module.addPyCode("""\
        EVT_RICHTEXT_LEFT_CLICK = wx.PyEventBinder(wxEVT_RICHTEXT_LEFT_CLICK)
        EVT_RICHTEXT_RIGHT_CLICK = wx.PyEventBinder(wxEVT_RICHTEXT_RIGHT_CLICK)
        EVT_RICHTEXT_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_RICHTEXT_MIDDLE_CLICK)
        EVT_RICHTEXT_LEFT_DCLICK = wx.PyEventBinder(wxEVT_RICHTEXT_LEFT_DCLICK)
        EVT_RICHTEXT_RETURN = wx.PyEventBinder(wxEVT_RICHTEXT_RETURN)
        EVT_RICHTEXT_CHARACTER = wx.PyEventBinder(wxEVT_RICHTEXT_CHARACTER)
        EVT_RICHTEXT_DELETE = wx.PyEventBinder(wxEVT_RICHTEXT_DELETE)

        EVT_RICHTEXT_STYLESHEET_CHANGING = wx.PyEventBinder(wxEVT_RICHTEXT_STYLESHEET_CHANGING)
        EVT_RICHTEXT_STYLESHEET_CHANGED = wx.PyEventBinder(wxEVT_RICHTEXT_STYLESHEET_CHANGED)
        EVT_RICHTEXT_STYLESHEET_REPLACING = wx.PyEventBinder(wxEVT_RICHTEXT_STYLESHEET_REPLACING)
        EVT_RICHTEXT_STYLESHEET_REPLACED = wx.PyEventBinder(wxEVT_RICHTEXT_STYLESHEET_REPLACED)

        EVT_RICHTEXT_CONTENT_INSERTED = wx.PyEventBinder(wxEVT_RICHTEXT_CONTENT_INSERTED)
        EVT_RICHTEXT_CONTENT_DELETED = wx.PyEventBinder(wxEVT_RICHTEXT_CONTENT_DELETED)
        EVT_RICHTEXT_STYLE_CHANGED = wx.PyEventBinder(wxEVT_RICHTEXT_STYLE_CHANGED)
        EVT_RICHTEXT_STYLE_CHANGED = wx.PyEventBinder(wxEVT_RICHTEXT_PROPERTIES_CHANGED)
        EVT_RICHTEXT_SELECTION_CHANGED = wx.PyEventBinder(wxEVT_RICHTEXT_SELECTION_CHANGED)
        EVT_RICHTEXT_BUFFER_RESET = wx.PyEventBinder(wxEVT_RICHTEXT_BUFFER_RESET)
        EVT_RICHTEXT_FOCUS_OBJECT_CHANGED = wx.PyEventBinder(wxEVT_RICHTEXT_FOCUS_OBJECT_CHANGED)
        """)

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Пример #5
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.


    #-----------------------------------------------------------------
    # ignore some macros since most of this set are not simple numbers
    for item in module.items:
        if item.name.startswith('wxRICHTEXT_DEFAULT'):
            item.ignore()


    #-----------------------------------------------------------------
    c = module.find('wxRichTextContextMenuPropertiesInfo')
    assert isinstance(c, etgtools.ClassDef)
    tools.ignoreConstOverloads(c)



    #-----------------------------------------------------------------
    c = module.find('wxRichTextCtrl')
    tools.fixWindowClass(c)
    c.bases = ['wxControl']  # wxTextCtrlIface, wxScrollHelper are also bases...
    c.find('GetSelection').findOverload('from').ignore()
    tools.ignoreConstOverloads(c)

    c.find('PositionToXY.x').out = True
    c.find('PositionToXY.y').out = True

    c.find('HitTest.pos').out = True
    c.find('HitTest.col').out = True
    c.find('HitTest.row').out = True
    c.find('HitTest').renameOverload('row', 'HitTestXY')

    c.find('GetRange.from').name = 'from_'
    c.find('GetRange.to').name = 'to_'
    c.find('Remove.from').name = 'from_'
    c.find('Remove.to').name = 'to_'
    c.find('Replace.from').name = 'from_'
    c.find('Replace.to').name = 'to_'
    c.find('SetSelection.from').name = 'from_'
    c.find('SetSelection.to').name = 'to_'

    c.find('SetListStyle.def').name = 'styleDef'
    c.find('ApplyStyle.def').name = 'styleDef'

    tools.fixTextClipboardMethods(c)

    c.addPyMethod('GetDefaultStyle', '(self)', 'return self.GetDefaultStyleEx()',
                  deprecated='Use GetDefaultStyleEx instead')


    # Make sure that all the methods from wxTextEntry are included. This is
    # needed because we are pretending that this class only derives from
    # wxControl but the real C++ class also derives from wxTextCtrlIface
    # which derives from wxTextEntryBase.
    import textentry
    mod = textentry.parseAndTweakModule()
    klass = mod.find('wxTextEntry')
    items = [item for item in klass.items if isinstance(item, etgtools.MethodDef) and
                                             not item.isCtor and
                                             not item.isDtor and
                                             not c.findItem(item.name)]
    c.items.extend(items)

    # TODO: What about the wxScrollHelper base class


    #-----------------------------------------------------------------
    c = module.find('wxRichTextEvent')
    tools.fixEventClass(c)

    module.addPyCode("""\
        EVT_RICHTEXT_LEFT_CLICK = wx.PyEventBinder(wxEVT_RICHTEXT_LEFT_CLICK)
        EVT_RICHTEXT_RIGHT_CLICK = wx.PyEventBinder(wxEVT_RICHTEXT_RIGHT_CLICK)
        EVT_RICHTEXT_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_RICHTEXT_MIDDLE_CLICK)
        EVT_RICHTEXT_LEFT_DCLICK = wx.PyEventBinder(wxEVT_RICHTEXT_LEFT_DCLICK)
        EVT_RICHTEXT_RETURN = wx.PyEventBinder(wxEVT_RICHTEXT_RETURN)
        EVT_RICHTEXT_CHARACTER = wx.PyEventBinder(wxEVT_RICHTEXT_CHARACTER)
        EVT_RICHTEXT_DELETE = wx.PyEventBinder(wxEVT_RICHTEXT_DELETE)

        EVT_RICHTEXT_STYLESHEET_CHANGING = wx.PyEventBinder(wxEVT_RICHTEXT_STYLESHEET_CHANGING)
        EVT_RICHTEXT_STYLESHEET_CHANGED = wx.PyEventBinder(wxEVT_RICHTEXT_STYLESHEET_CHANGED)
        EVT_RICHTEXT_STYLESHEET_REPLACING = wx.PyEventBinder(wxEVT_RICHTEXT_STYLESHEET_REPLACING)
        EVT_RICHTEXT_STYLESHEET_REPLACED = wx.PyEventBinder(wxEVT_RICHTEXT_STYLESHEET_REPLACED)

        EVT_RICHTEXT_CONTENT_INSERTED = wx.PyEventBinder(wxEVT_RICHTEXT_CONTENT_INSERTED)
        EVT_RICHTEXT_CONTENT_DELETED = wx.PyEventBinder(wxEVT_RICHTEXT_CONTENT_DELETED)
        EVT_RICHTEXT_STYLE_CHANGED = wx.PyEventBinder(wxEVT_RICHTEXT_STYLE_CHANGED)
        EVT_RICHTEXT_STYLE_CHANGED = wx.PyEventBinder(wxEVT_RICHTEXT_PROPERTIES_CHANGED)
        EVT_RICHTEXT_SELECTION_CHANGED = wx.PyEventBinder(wxEVT_RICHTEXT_SELECTION_CHANGED)
        EVT_RICHTEXT_BUFFER_RESET = wx.PyEventBinder(wxEVT_RICHTEXT_BUFFER_RESET)
        EVT_RICHTEXT_FOCUS_OBJECT_CHANGED = wx.PyEventBinder(wxEVT_RICHTEXT_FOCUS_OBJECT_CHANGED)
        """);

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)