From d4a9e5c407d527f4a347274740bc2f2a91a3efdc Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sat, 30 Jun 2012 21:01:23 +0000 Subject: [PATCH] Added wx.HeaderCtrl and related classes, although it is currently disabled due to a bug in sip. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71903 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- TODO.txt | 1 - etg/_core.py | 1 + etg/headerctrl.py | 107 +++++++++++++++++++++++++++++++++++ unittests/test_headerctrl.py | 16 ++++++ 4 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 etg/headerctrl.py create mode 100644 unittests/test_headerctrl.py diff --git a/TODO.txt b/TODO.txt index abf29fc3..02b6a6a5 100644 --- a/TODO.txt +++ b/TODO.txt @@ -125,7 +125,6 @@ other dev stuff * docview ?? * filehistory * fswatcher - * headerctrl * msgout * palette ? * persist ? diff --git a/etg/_core.py b/etg/_core.py index ee6177d1..88dcfc65 100644 --- a/etg/_core.py +++ b/etg/_core.py @@ -146,6 +146,7 @@ INCLUDES = [ # base and core stuff 'checklst', 'gauge', 'headercol', + #'headerctrl', waiting on fix for a sip bug... 'srchctrl', 'radiobox', 'radiobut', diff --git a/etg/headerctrl.py b/etg/headerctrl.py new file mode 100644 index 00000000..602c6127 --- /dev/null +++ b/etg/headerctrl.py @@ -0,0 +1,107 @@ +#--------------------------------------------------------------------------- +# Name: etg/headerctrl.py +# Author: Robin Dunn +# +# Created: 29-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 = "headerctrl" # 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 = [ "wxHeaderCtrl", + "wxHeaderCtrlSimple", + "wxHeaderCtrlEvent", + ] + +#--------------------------------------------------------------------------- + +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('wxHeaderCtrl') + assert isinstance(c, etgtools.ClassDef) + tools.fixWindowClass(c) + + module.addGlobalStr('wxHeaderCtrlNameStr', c) + module.addHeaderCode('#include ') + + # Uningnore the protected virtuals that are indended to be overridden in + # derived classes. + for name in ['GetColumn', 'UpdateColumnVisibility', 'UpdateColumnsOrder', + 'UpdateColumnWidthToFit', 'OnColumnCountChanging']: + c.find(name).ignore(False) + c.find(name).isVirtual = True + c.find('GetColumn').isPureVirtual = True + c.find('GetColumn')._virtualCatcherCode = """\ + PyObject *resObj = sipCallMethod(0,sipMethod,"u",idx); + sipIsErr = (!resObj || sipParseResult(0,sipMethod,resObj,"H1",sipType_wxHeaderColumn,&sipRes) < 0); + if (sipIsErr) + PyErr_Print(); + Py_XDECREF(resObj); + if (sipIsErr) + return *(new wxHeaderColumnSimple("")); + """ + + #------------------------------------------------------- + c = module.find('wxHeaderCtrlSimple') + tools.fixWindowClass(c) + + # Uningnore the protected virtuals that are indended to be overridden in + # derived classes. + c.find('GetBestFittingWidth').ignore(False) + c.find('GetBestFittingWidth').isVirtual = True + + # indicate the the base class virtuals have implementations here + c.addItem(etgtools.WigCode("""\ + virtual const wxHeaderColumn& GetColumn(unsigned int idx) const; + virtual void UpdateColumnVisibility(unsigned int idx, bool show); + virtual void UpdateColumnsOrder(const wxArrayInt& order); + virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle); + virtual void OnColumnCountChanging(unsigned int count); + """, protection='protected')) + + + #------------------------------------------------------- + c = module.find('wxHeaderCtrlEvent') + tools.fixEventClass(c) + + module.addPyCode("""\ + EVT_HEADER_CLICK = wx.PyEventBinder( wxEVT_COMMAND_HEADER_CLICK ) + EVT_HEADER_RIGHT_CLICK = wx.PyEventBinder( wxEVT_COMMAND_HEADER_RIGHT_CLICK ) + EVT_HEADER_MIDDLE_CLICK = wx.PyEventBinder( wxEVT_COMMAND_HEADER_MIDDLE_CLICK ) + EVT_HEADER_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_HEADER_DCLICK ) + EVT_HEADER_RIGHT_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_HEADER_RIGHT_DCLICK ) + EVT_HEADER_MIDDLE_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_HEADER_MIDDLE_DCLICK ) + EVT_HEADER_SEPARATOR_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_HEADER_SEPARATOR_DCLICK ) + EVT_HEADER_BEGIN_RESIZE = wx.PyEventBinder( wxEVT_COMMAND_HEADER_BEGIN_RESIZE ) + EVT_HEADER_RESIZING = wx.PyEventBinder( wxEVT_COMMAND_HEADER_RESIZING ) + EVT_HEADER_END_RESIZE = wx.PyEventBinder( wxEVT_COMMAND_HEADER_END_RESIZE ) + EVT_HEADER_BEGIN_REORDER = wx.PyEventBinder( wxEVT_COMMAND_HEADER_BEGIN_REORDER ) + EVT_HEADER_END_REORDER = wx.PyEventBinder( wxEVT_COMMAND_HEADER_END_REORDER ) + EVT_HEADER_DRAGGING_CANCELLED = wx.PyEventBinder( wxEVT_COMMAND_HEADER_DRAGGING_CANCELLED ) + """) + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/unittests/test_headerctrl.py b/unittests/test_headerctrl.py new file mode 100644 index 00000000..32c72a30 --- /dev/null +++ b/unittests/test_headerctrl.py @@ -0,0 +1,16 @@ +import imp_unittest, unittest +import wtc +import wx + +#--------------------------------------------------------------------------- + +class headerctrl_Tests(wtc.WidgetTestCase): + + # TODO: Remove this test and add real ones. + def test_headerctrl1(self): + self.fail("Unit tests for headerctrl not implemented yet.") + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main()