diff --git a/etg/_core.py b/etg/_core.py index af96f0fc..454a2ac5 100644 --- a/etg/_core.py +++ b/etg/_core.py @@ -122,6 +122,8 @@ INCLUDES = [ 'defs', 'accel', 'cursor', 'log', + 'textcompleter', + 'textentry', 'textctrl', 'combobox', 'checkbox', diff --git a/etg/textcompleter.py b/etg/textcompleter.py new file mode 100644 index 00000000..3c531fae --- /dev/null +++ b/etg/textcompleter.py @@ -0,0 +1,52 @@ +#--------------------------------------------------------------------------- +# Name: etg/textcompleter.py +# Author: Robin Dunn +# +# Created: 03-Nov-2011 +# Copyright: (c) 2011 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "textcompleter" # Base name of the file to generate to for this script +DOCSTRING = "" + +# The classes and/or the basename of the Doxygen XML files to be processed by +# this script. +ITEMS = [ "wxTextCompleter", + "wxTextCompleterSimple", + ] + +#--------------------------------------------------------------------------- + +def run(): + # 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('wxTextCompleter') + assert isinstance(c, etgtools.ClassDef) + c.addPrivateCopyCtor() + + c = module.find('wxTextCompleterSimple') + # TODO: Change GetCompletions to return the wxArrayString instead of + # passing it as a parameter? + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/textctrl.py b/etg/textctrl.py index 92b8f469..c2d3db89 100644 --- a/etg/textctrl.py +++ b/etg/textctrl.py @@ -1,6 +1,7 @@ #--------------------------------------------------------------------------- # Name: etg/textctrl.py # Author: Kevin Ollivier +# Robin Dunn # # Created: 9-Sept-2011 # Copyright: (c) 2011 by Kevin Ollivier @@ -17,17 +18,13 @@ DOCSTRING = "" # The classes and/or the basename of the Doxygen XML files to be processed by # this script. -ITEMS = [ 'wxTextCtrl', 'wxTextEntry', 'wxTextCompleter', 'wxTextAttr', ] +ITEMS = [ 'wxTextAttr', 'wxTextCtrl', ] #--------------------------------------------------------------------------- def run(): # Parse the XML file(s) building a collection of Extractor objects module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) - - module.items.append(etgtools.TypedefDef(type='long', name='wxTextPos')) - module.items.append(etgtools.TypedefDef(type='long', name='wxTextCoord')) - etgtools.parseDoxyXML(module, ITEMS) #----------------------------------------------------------------- @@ -35,25 +32,30 @@ def run(): # customizing the generated code and docstrings. c = module.find('wxTextAttr') - for op in c.allItems(): - if 'operator' in op.name: - op.ignore() + assert isinstance(c, etgtools.ClassDef) + c.find('operator=').ignore() - c = module.find('wxTextCompleter') - c.addPrivateCopyCtor() - - c = module.find('wxTextEntry') - c.abstract = True - tools.removeVirtuals(c) c = module.find('wxTextCtrl') - c.find('HitTest').overloads = [] + # Split the HitTest overloads into separately named methods since once + # the output parameters are applied they will have the same function + # signature. + ht1 = c.find('HitTest') + ht2 = ht1.overloads[0] + ht1.overloads = [] + c.insertItemAfter(ht1, ht2) + ht1.pyName = 'HitTestPos' + ht1.find('pos').out = True + ht2.find('row').out = True + ht2.find('col').out = True + + c.find('PositionToXY.x').out = True + c.find('PositionToXY.y').out = True + for op in c.findAll('operator<<'): op.ignore() - assert isinstance(c, etgtools.ClassDef) - tools.fixWindowClass(c) #----------------------------------------------------------------- diff --git a/etg/textentry.py b/etg/textentry.py new file mode 100644 index 00000000..4243d4a8 --- /dev/null +++ b/etg/textentry.py @@ -0,0 +1,50 @@ +#--------------------------------------------------------------------------- +# Name: etg/textentry.py +# Author: Robin Dunn +# +# Created: 03-Nov-2011 +# Copyright: (c) 2011 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "textentry" # Base name of the file to generate to for this script +DOCSTRING = "" + +# The classes and/or the basename of the Doxygen XML files to be processed by +# this script. +ITEMS = [ "wxTextEntry", ] + +#--------------------------------------------------------------------------- + +def run(): + # 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 + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/unittests/test_textctrl.py b/unittests/test_textctrl.py new file mode 100644 index 00000000..cb5c9059 --- /dev/null +++ b/unittests/test_textctrl.py @@ -0,0 +1,100 @@ +import imp_unittest, unittest +import wtc +import wx + +#--------------------------------------------------------------------------- + +class textctrl_Tests(wtc.WidgetTestCase): + + def test_textctrlFlags(self): + wx.TE_NO_VSCROLL + wx.TE_READONLY + wx.TE_MULTILINE + wx.TE_PROCESS_TAB + wx.TE_LEFT + wx.TE_CENTER + wx.TE_RIGHT + wx.TE_CENTRE + wx.TE_RICH + wx.TE_PROCESS_ENTER + wx.TE_PASSWORD + wx.TE_AUTO_URL + wx.TE_NOHIDESEL + wx.TE_DONTWRAP + wx.TE_CHARWRAP + wx.TE_WORDWRAP + wx.TE_BESTWRAP + + + def test_textctrlCtor(self): + t = wx.TextCtrl(self.frame) + t = wx.TextCtrl(self.frame, -1, "Hello") + t = wx.TextCtrl(self.frame, style=wx.TE_READONLY) + t = wx.TextCtrl(self.frame, style=wx.TE_PASSWORD) + t = wx.TextCtrl(self.frame, style=wx.TE_MULTILINE) + + + def test_textctrlDefaultCtor(self): + t = wx.TextCtrl() + t.Create(self.frame) + + + def test_textctrlProperties(self): + t = wx.TextCtrl(self.frame) + + t.DefaultStyle + t.NumberOfLines + t.Hint + t.InsertionPoint + t.LastPosition + t.Margins + t.StringSelection + t.Value + + + def test_textctrlTextAttr(self): + ta = wx.TextAttr() + ta2 = wx.TextAttr(ta) + ta3 = wx.TextAttr('black', 'white', wx.NORMAL_FONT, wx.TEXT_ALIGNMENT_RIGHT) + + def test_textctrlTextAttrProperties(self): + ta = wx.TextAttr() + + ta.Alignment + ta.BackgroundColour + ta.BulletFont + ta.BulletName + ta.BulletNumber + ta.BulletStyle + ta.BulletText + ta.CharacterStyleName + ta.Flags + ta.Font + ta.FontEncoding + ta.FontFaceName + ta.FontFamily + ta.FontSize + ta.FontStyle + ta.FontUnderlined + ta.FontWeight + ta.LeftIndent + ta.LeftSubIndent + ta.LineSpacing + ta.ListStyleName + ta.OutlineLevel + ta.ParagraphSpacingAfter + ta.ParagraphSpacingBefore + ta.ParagraphStyleName + ta.RightIndent + ta.Tabs + ta.TextColour + ta.TextEffectFlags + ta.TextEffects + ta.URL + + +#--------------------------------------------------------------------------- + + +if __name__ == '__main__': + unittest.main()