Add wxDatePickerCtrl and wxCalendarCtrl to wx.adv

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71165 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2012-04-10 03:23:46 +00:00
parent 0fc8a04d30
commit 4b4b9a1210
10 changed files with 339 additions and 12 deletions

View File

@@ -131,7 +131,6 @@ other dev stuff
* taskbar
* print (as in print framework classes)
* datectrl
* hyperlink
* pickerbase, clrpicker, filepicker, fontpicker
* filectrl

View File

@@ -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 <wxpy_api.h>')
module.addImport('_core')
module.addPyCode("import core as wx", order=10)
module.addInclude(INCLUDES)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)

82
etg/calctrl.py Normal file
View File

@@ -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()

63
etg/datectrl.py Normal file
View File

@@ -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 <wx/datectrl.h>")
module.addHeaderCode("#include <wx/generic/datectrl.h>")
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()

58
etg/dateevt.py Normal file
View File

@@ -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 <wx/dateevt.h>")
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()

View File

@@ -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

View File

@@ -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
#---------------------------------------------------------------------------

58
unittests/test_calctrl.py Normal file
View File

@@ -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()

View File

@@ -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()

25
unittests/test_dateevt.py Normal file
View File

@@ -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()