diff --git a/TODO.txt b/TODO.txt index 5b09f9ac..eab03571 100644 --- a/TODO.txt +++ b/TODO.txt @@ -118,9 +118,7 @@ other dev stuff * Add ETG scripts for these items in _core: * PseudoDC (not actually an ETG script, probably a .sip) - * access - * choicebk * cmdproc * dialup ?? * docmdi ?? @@ -132,7 +130,6 @@ other dev stuff * fontmap * fswatcher * headerctrl - * listbook * metafile * minifram * mousemanager @@ -145,8 +142,6 @@ other dev stuff * renderer * richmsgdlg * textdlg - * toolbook - * treebook * valgen * valnum * valtext diff --git a/etg/_core.py b/etg/_core.py index 3f01d05d..ce7fd741 100644 --- a/etg/_core.py +++ b/etg/_core.py @@ -30,7 +30,7 @@ ITEMS = [ ] # remove it from this list of Includes, and change the MODULE value in the # promoted script to be the same as its NAME. -INCLUDES = [ # core +INCLUDES = [ # base and core stuff 'defs', 'object', 'wxpy_api', @@ -161,6 +161,10 @@ INCLUDES = [ # core 'pickers', 'filectrl', 'combo', + 'choicebk', + 'listbook', + 'toolbook', + 'treebook', # toplevel and dialogs 'nonownedwnd', diff --git a/etg/choicebk.py b/etg/choicebk.py new file mode 100644 index 00000000..1d513423 --- /dev/null +++ b/etg/choicebk.py @@ -0,0 +1,54 @@ +#--------------------------------------------------------------------------- +# Name: etg/choicebk.py +# Author: Robin Dunn +# +# Created: 18-Jun-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "choicebk" # 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 = [ "wxChoicebook", + ] + +#--------------------------------------------------------------------------- + +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('wxChoicebook') + assert isinstance(c, etgtools.ClassDef) + tools.fixWindowClass(c) + tools.fixBookctrlClass(c) + + module.addPyCode("""\ + EVT_CHOICEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, 1 ) + EVT_CHOICEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, 1 ) + """) + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/listbook.py b/etg/listbook.py new file mode 100644 index 00000000..63e57c08 --- /dev/null +++ b/etg/listbook.py @@ -0,0 +1,54 @@ +#--------------------------------------------------------------------------- +# Name: etg/listbook.py +# Author: Robin Dunn +# +# Created: 18-Jun-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "listbook" # 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 = [ "wxListbook", + ] + +#--------------------------------------------------------------------------- + +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('wxListbook') + assert isinstance(c, etgtools.ClassDef) + tools.fixWindowClass(c) + tools.fixBookctrlClass(c) + + module.addPyCode("""\ + EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 ) + EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 ) + """) + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/toolbook.py b/etg/toolbook.py new file mode 100644 index 00000000..286b4415 --- /dev/null +++ b/etg/toolbook.py @@ -0,0 +1,55 @@ +#--------------------------------------------------------------------------- +# Name: etg/toolbook.py +# Author: Robin Dunn +# +# Created: 18-Jun-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "toolbook" # 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 = [ "wxToolbook", + ] + +#--------------------------------------------------------------------------- + +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('wxToolbook') + assert isinstance(c, etgtools.ClassDef) + tools.fixWindowClass(c) + tools.fixBookctrlClass(c) + + module.addPyCode("""\ + EVT_TOOLBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, 1 ) + EVT_TOOLBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, 1 ) + """) + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/treebook.py b/etg/treebook.py new file mode 100644 index 00000000..8f71fcd1 --- /dev/null +++ b/etg/treebook.py @@ -0,0 +1,57 @@ +#--------------------------------------------------------------------------- +# Name: etg/treebook.py +# Author: Robin Dunn +# +# Created: 18-Jun-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "treebook" # 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 = [ "wxTreebook", + ] + +#--------------------------------------------------------------------------- + +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('wxTreebook') + assert isinstance(c, etgtools.ClassDef) + tools.fixWindowClass(c) + tools.fixBookctrlClass(c, True) + + module.addPyCode("""\ + EVT_TREEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, 1 ) + EVT_TREEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, 1) + EVT_TREEBOOK_NODE_COLLAPSED = wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, 1 ) + EVT_TREEBOOK_NODE_EXPANDED = wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED, 1 ) + """) + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etgtools/tweaker_tools.py b/etgtools/tweaker_tools.py index 11c5fa9e..e66a0222 100644 --- a/etgtools/tweaker_tools.py +++ b/etgtools/tweaker_tools.py @@ -186,8 +186,28 @@ def fixSizerClass(klass): if klass.name == 'wxSizer': klass.find('CalcMin').isPureVirtual = True klass.find('RecalcSizes').isPureVirtual = True - + +def fixBookctrlClass(klass, treeBook=False): + """ + Add declarations of the pure virtual methods from the base class. + """ + klass.addItem(extractors.WigCode("""\ + virtual int GetPageImage(size_t nPage) const; + virtual bool SetPageImage(size_t page, int image); + virtual wxString GetPageText(size_t nPage) const; + virtual bool SetPageText(size_t page, const wxString& text); + virtual int SetSelection(size_t page); + virtual int ChangeSelection(size_t page); + """)) + if not treeBook: + klass.addItem(extractors.WigCode("""\ + virtual int GetSelection() const; + virtual bool InsertPage(size_t index, wxWindow * page, const wxString & text, + bool select = false, int imageId = NO_IMAGE); + """)) + + def removeVirtuals(klass): """ Sometimes methods are marked as virtual but probably don't ever need to be diff --git a/unittests/test_choicebk.py b/unittests/test_choicebk.py new file mode 100644 index 00000000..10b004e0 --- /dev/null +++ b/unittests/test_choicebk.py @@ -0,0 +1,37 @@ +import imp_unittest, unittest +import wtc +import wx + +#--------------------------------------------------------------------------- + +class choicebk_Tests(wtc.WidgetTestCase): + + def test_choicebk1(self): + wx.CHB_DEFAULT + wx.CHB_TOP + wx.CHB_BOTTOM + wx.CHB_LEFT + wx.CHB_RIGHT + wx.CHB_ALIGN_MASK + + wx.wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED + wx.wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING + wx.EVT_CHOICEBOOK_PAGE_CHANGED + wx.EVT_CHOICEBOOK_PAGE_CHANGING + + + def test_choicebk2(self): + book = wx.Choicebook() + book.Create(self.frame) + + + def test_choicebk3(self): + book = wx.Choicebook(self.frame) + book.AddPage(wx.Panel(book), 'one') + book.AddPage(wx.Panel(book), 'two') + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main() diff --git a/unittests/test_listbook.py b/unittests/test_listbook.py new file mode 100644 index 00000000..9656fa40 --- /dev/null +++ b/unittests/test_listbook.py @@ -0,0 +1,36 @@ +import imp_unittest, unittest +import wtc +import wx + +#--------------------------------------------------------------------------- + +class listbook_Tests(wtc.WidgetTestCase): + + def test_listbook1(self): + wx.LB_DEFAULT + wx.LB_TOP + wx.LB_BOTTOM + wx.LB_LEFT + wx.LB_RIGHT + wx.LB_ALIGN_MASK + + wx.wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED + wx.wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING + wx.EVT_LISTBOOK_PAGE_CHANGED + wx.EVT_LISTBOOK_PAGE_CHANGING + + + def test_listbook2(self): + book = wx.Listbook() + book.Create(self.frame) + + + def test_listbook3(self): + book = wx.Listbook(self.frame) + book.AddPage(wx.Panel(book), 'one') + book.AddPage(wx.Panel(book), 'two') + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main() diff --git a/unittests/test_toolbook.py b/unittests/test_toolbook.py new file mode 100644 index 00000000..1924f670 --- /dev/null +++ b/unittests/test_toolbook.py @@ -0,0 +1,48 @@ +import imp_unittest, unittest +import wtc +import wx +import os + +toolImgFiles = [os.path.join(os.path.dirname(__file__), 'LB01.png'), + os.path.join(os.path.dirname(__file__), 'LB02.png'), + os.path.join(os.path.dirname(__file__), 'LB03.png'), + os.path.join(os.path.dirname(__file__), 'LB04.png'), + ] + +#--------------------------------------------------------------------------- + +class toolbook_Tests(wtc.WidgetTestCase): + + def test_toolbook1(self): + wx.TBK_BUTTONBAR + wx.TBK_HORZ_LAYOUT + + wx.wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED + wx.wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING + wx.EVT_TOOLBOOK_PAGE_CHANGED + wx.EVT_TOOLBOOK_PAGE_CHANGING + + + def test_toolbook2(self): + book = wx.Toolbook() + book.Create(self.frame) + + + def test_toolbook3(self): + book = wx.Toolbook(self.frame) + + il = wx.ImageList() + for name in toolImgFiles: + il.Add(wx.Bitmap(name)) + book.AssignImageList(il) + + book.AddPage(wx.Panel(book), 'one', imageId=0) + book.AddPage(wx.Panel(book), 'two', imageId=1) + book.AddPage(wx.Panel(book), 'three', imageId=2) + book.AddPage(wx.Panel(book), 'four', imageId=3) + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main() diff --git a/unittests/test_treebook.py b/unittests/test_treebook.py new file mode 100644 index 00000000..a4c805fc --- /dev/null +++ b/unittests/test_treebook.py @@ -0,0 +1,36 @@ +import imp_unittest, unittest +import wtc +import wx + +#--------------------------------------------------------------------------- + +class treebook_Tests(wtc.WidgetTestCase): + + def test_treebook1(self): + wx.wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED + wx.wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING + wx.wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED + wx.wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED + + wx.EVT_TREEBOOK_PAGE_CHANGED + wx.EVT_TREEBOOK_PAGE_CHANGING; + wx.EVT_TREEBOOK_NODE_COLLAPSED; + wx.EVT_TREEBOOK_NODE_EXPANDED; + + + def test_treebook2(self): + book = wx.Treebook() + book.Create(self.frame) + + + def test_treebook3(self): + book = wx.Treebook(self.frame) + book.AddPage(wx.Panel(book), 'one') + book.AddPage(wx.Panel(book), 'two') + book.AddSubPage(wx.Panel(book), 'three') + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main()