diff --git a/TODO.txt b/TODO.txt index 037409ec..94c7aa94 100644 --- a/TODO.txt +++ b/TODO.txt @@ -131,7 +131,6 @@ other dev stuff * taskbar * print (as in print framework classes) - * datectrl * hyperlink * pickerbase, clrpicker, filepicker, fontpicker * filectrl diff --git a/etg/_adv.py b/etg/_adv.py index 87a19985..14e476c2 100644 --- a/etg/_adv.py +++ b/etg/_adv.py @@ -28,16 +28,17 @@ INCLUDES = [ 'aboutdlg', 'helpext', 'commandlinkbutton', + 'dateevt', + 'datectrl', + 'calctrl', + # TODOs - - # These modules are also in the C++ adv lib and so should included be here: + # These modules are also in the C++ adv lib and so should be included here: # #'animate', #'bannerwindow', #'bmpcbox', - #'calctrl', - #'datectrl', - #'dateevt', #'editlbox', #'hyperlink', #'joystick', @@ -83,9 +84,10 @@ def run(): module.addHeaderCode('#include ') module.addImport('_core') + module.addPyCode("import core as wx", order=10) module.addInclude(INCLUDES) - + #----------------------------------------------------------------- tools.doCommonTweaks(module) tools.runGenerators(module) diff --git a/etg/calctrl.py b/etg/calctrl.py new file mode 100644 index 00000000..55e13a7c --- /dev/null +++ b/etg/calctrl.py @@ -0,0 +1,82 @@ +#--------------------------------------------------------------------------- +# Name: etg/calctrl.py +# Author: Robin Dunn +# +# Created: 09-Apr-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_adv" +NAME = "calctrl" # 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 = [ "wxCalendarEvent", + "wxCalendarDateAttr", + "wxCalendarCtrl", + ] + +#--------------------------------------------------------------------------- + +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('wxCalendarEvent') + assert isinstance(c, etgtools.ClassDef) + tools.fixEventClass(c) + + c.addPyCode("""\ + EVT_CALENDAR = wx.PyEventBinder( wxEVT_CALENDAR_DOUBLECLICKED, 1) + EVT_CALENDAR_SEL_CHANGED = wx.PyEventBinder( wxEVT_CALENDAR_SEL_CHANGED, 1) + EVT_CALENDAR_WEEKDAY_CLICKED = wx.PyEventBinder( wxEVT_CALENDAR_WEEKDAY_CLICKED, 1) + EVT_CALENDAR_PAGE_CHANGED = wx.PyEventBinder( wxEVT_CALENDAR_PAGE_CHANGED, 1) + """) + # These are deprecated... + # EVT_CALENDAR_DAY = wx.PyEventBinder( wxEVT_CALENDAR_DAY_CHANGED, 1) + # EVT_CALENDAR_MONTH = wx.PyEventBinder( wxEVT_CALENDAR_MONTH_CHANGED, 1) + # EVT_CALENDAR_YEAR = wx.PyEventBinder( wxEVT_CALENDAR_YEAR_CHANGED, 1) + # """) + + + cc = module.find('wxCalendarCtrl') + gcc = tools.copyClassDef(cc, 'wxGenericCalendarCtrl') + module.insertItemAfter(cc, gcc) + + for c in [cc, gcc]: + tools.fixWindowClass(c) + c.find('GetDateRange.lowerdate').out = True + c.find('GetDateRange.upperdate').out = True + c.find('HitTest.date').out = True + c.find('HitTest.wd').out = True + c.find('SetAttr.attr').transfer = True + + c.addPyCode("""\ + CalendarCtrl.PyGetDate = wx.deprecated(CalendarCtrl.GetDate) + CalendarCtrl.PySetDate = wx.deprecated(CalendarCtrl.SetDate) + CalendarCtrl.PySetDateRange = wx.deprecated(CalendarCtrl.SetDateRange) + """) + + + module.addGlobalStr('wxCalendarNameStr', cc) + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/datectrl.py b/etg/datectrl.py new file mode 100644 index 00000000..962883fb --- /dev/null +++ b/etg/datectrl.py @@ -0,0 +1,63 @@ +#--------------------------------------------------------------------------- +# Name: etg/datectrl.py +# Author: Robin Dunn +# +# Created: 09-Apr-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + + +PACKAGE = "wx" +MODULE = "_adv" +NAME = "datectrl" # 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 = [ "wxDatePickerCtrl", + ] + +#--------------------------------------------------------------------------- + +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. + + module.addHeaderCode("#include ") + module.addHeaderCode("#include ") + + dpc = module.find('wxDatePickerCtrl') + assert isinstance(dpc, etgtools.ClassDef) + + # Make a copy and call it wxDatePickerCtrlGeneric so we can generate + # wrappers for both classes + gdpc = tools.copyClassDef(dpc, 'wxDatePickerCtrlGeneric') + assert isinstance(gdpc, etgtools.ClassDef) + module.insertItemAfter(dpc, gdpc) + # and give it a new Python name to match Classic + gdpc.pyName = 'GenericDatePickerCtrl' + + # now back to our regular tweaking + for c in [dpc, gdpc]: + tools.fixWindowClass(c) + c.find('GetRange.dt1').out = True + c.find('GetRange.dt2').out = True + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/dateevt.py b/etg/dateevt.py new file mode 100644 index 00000000..d4132afc --- /dev/null +++ b/etg/dateevt.py @@ -0,0 +1,58 @@ +#--------------------------------------------------------------------------- +# Name: etg/dateevt.py +# Author: Robin Dunn +# +# Created: 09-Apr-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_adv" +NAME = "dateevt" # 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 = [ "wxDateEvent", + ] + +#--------------------------------------------------------------------------- + +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. + + module.addHeaderCode("#include ") + + c = module.find('wxDateEvent') + assert isinstance(c, etgtools.ClassDef) + tools.fixEventClass(c) + + c.addPyCode("""\ + EVT_DATE_CHANGED = wx.PyEventBinder( wxEVT_DATE_CHANGED, 1 ) + EVT_TIME_CHANGED = wx.PyEventBinder( wxEVT_TIME_CHANGED, 1 ) + """) + + c.addPyCode("""\ + DateEvent.PyGetDate = wx.deprecated(DateEvent.GetDate) + DateEvent.PySetDate = wx.deprecated(DateEvent.SetDate) + """) + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/dragimag.py b/etg/dragimag.py index deaf1d41..1853105c 100644 --- a/etg/dragimag.py +++ b/etg/dragimag.py @@ -9,7 +9,6 @@ import etgtools import etgtools.tweaker_tools as tools -import copy PACKAGE = "wx" MODULE = "_core" @@ -36,11 +35,7 @@ def run(): assert isinstance(di, etgtools.ClassDef) # make a copy and rename it to 'wxGenericDragImage' - gdi = copy.deepcopy(di) - assert isinstance(gdi, etgtools.ClassDef) - gdi.name = 'wxGenericDragImage' - for ctor in gdi.find('wxDragImage').all(): - ctor.name = 'wxGenericDragImage' + gdi = tools.copyClassDef(di, 'wxGenericDragImage') module.insertItemAfter(di, gdi) # now add some tweaks for wxDragImage diff --git a/etgtools/tweaker_tools.py b/etgtools/tweaker_tools.py index f3ed2d69..6f17ca0d 100644 --- a/etgtools/tweaker_tools.py +++ b/etgtools/tweaker_tools.py @@ -14,6 +14,8 @@ stage of the ETG scripts. import extractors import sys, os +import copy + magicMethods = { 'operator!=' : '__ne__', @@ -328,6 +330,21 @@ def changeTypeNames(module, oldName, newName, skipTypedef=False): item.type = item.type.replace(oldName, newName) + +def copyClassDef(klass, newName): + """ + Make a copy of a class object and give it a new name. + """ + oldName = klass.name + klass = copy.deepcopy(klass) + assert isinstance(klass, extractors.ClassDef) + klass.name = newName + for ctor in klass.find(oldName).all(): + ctor.name = newName + if klass.findItem('~'+oldName): + klass.find('~'+oldName).name = '~'+newName + return klass + #--------------------------------------------------------------------------- diff --git a/unittests/test_calctrl.py b/unittests/test_calctrl.py new file mode 100644 index 00000000..b105bad3 --- /dev/null +++ b/unittests/test_calctrl.py @@ -0,0 +1,58 @@ +import imp_unittest, unittest +import wtc +import wx +import wx.adv + +#--------------------------------------------------------------------------- + +class calctrl_Tests(wtc.WidgetTestCase): + + def test_calctrl1(self): + evt = wx.adv.CalendarEvent() + attr = wx.adv.CalendarDateAttr() + + wx.adv.CAL_SUNDAY_FIRST + wx.adv.CAL_MONDAY_FIRST + wx.adv.CAL_SHOW_HOLIDAYS + wx.adv.CAL_NO_YEAR_CHANGE + wx.adv.CAL_NO_MONTH_CHANGE + wx.adv.CAL_SEQUENTIAL_MONTH_SELECTION + wx.adv.CAL_SHOW_SURROUNDING_WEEKS + wx.adv.CAL_SHOW_WEEK_NUMBERS + + wx.adv.CAL_HITTEST_NOWHERE + wx.adv.CAL_HITTEST_HEADER + wx.adv.CAL_HITTEST_DAY + wx.adv.CAL_HITTEST_INCMONTH + wx.adv.CAL_HITTEST_DECMONTH + wx.adv.CAL_HITTEST_SURROUNDING_WEEK + wx.adv.CAL_HITTEST_WEEK + + wx.adv.CAL_BORDER_NONE + wx.adv.CAL_BORDER_SQUARE + wx.adv.CAL_BORDER_ROUND + + + def test_calctrl2(self): + cal = wx.adv.CalendarCtrl(self.frame, date=wx.DateTime.Today()) + + + def test_calctrl3(self): + cal = wx.adv.CalendarCtrl() + cal.Create(self.frame, date=wx.DateTime.Today()) + + + def test_genericcalctrl2(self): + cal = wx.adv.GenericCalendarCtrl(self.frame, date=wx.DateTime.Today()) + + + def test_genericcalctrl3(self): + cal = wx.adv.GenericCalendarCtrl() + cal.Create(self.frame, date=wx.DateTime.Today()) + + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main() diff --git a/unittests/test_datectrl.py b/unittests/test_datectrl.py new file mode 100644 index 00000000..e3518a27 --- /dev/null +++ b/unittests/test_datectrl.py @@ -0,0 +1,28 @@ +import imp_unittest, unittest +import wtc +import wx +import wx.adv + +#--------------------------------------------------------------------------- + +class datectrl_Tests(wtc.WidgetTestCase): + + def test_datectrl1(self): + dp = wx.adv.DatePickerCtrl(self.frame, dt=wx.DateTime.Now()) + + def test_datectrl2(self): + dp = wx.adv.DatePickerCtrl() + dp.Create(self.frame, dt=wx.DateTime.Now()) + + def test_genericdatectrl1(self): + dp = wx.adv.GenericDatePickerCtrl(self.frame, dt=wx.DateTime.Now()) + + def test_genericdatectrl2(self): + dp = wx.adv.GenericDatePickerCtrl() + dp.Create(self.frame, dt=wx.DateTime.Now()) + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main() diff --git a/unittests/test_dateevt.py b/unittests/test_dateevt.py new file mode 100644 index 00000000..f04d4bad --- /dev/null +++ b/unittests/test_dateevt.py @@ -0,0 +1,25 @@ +import imp_unittest, unittest +import wtc +import wx +import wx.adv + +#--------------------------------------------------------------------------- + +class dateevt_Tests(wtc.WidgetTestCase): + + def test_dateevt1(self): + evt = wx.adv.DateEvent() + evt.GetDate() + evt.Date + + def test_dateevt2(self): + wx.adv.wxEVT_DATE_CHANGED + wx.adv.wxEVT_TIME_CHANGED + wx.adv.EVT_DATE_CHANGED + wx.adv.EVT_TIME_CHANGED + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main()