Add wx.Choicebook, wx.Listbook, wx.Toolbook and wx.Treebook

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71813 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2012-06-20 17:10:42 +00:00
parent cb545458a8
commit f0924fce36
11 changed files with 403 additions and 7 deletions

View File

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

View File

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

54
etg/choicebk.py Normal file
View File

@@ -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 <wx/choicebk.h>')
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()

54
etg/listbook.py Normal file
View File

@@ -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 <wx/listbook.h>')
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()

55
etg/toolbook.py Normal file
View File

@@ -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 <wx/toolbook.h>')
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()

57
etg/treebook.py Normal file
View File

@@ -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 <wx/treebook.h>')
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()

View File

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

View File

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

View File

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

View File

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

View File

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