From fbda53cbe49d2da0b0cd5fa9ee49977c00eea697 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 1 Nov 2012 22:50:37 +0000 Subject: [PATCH] Add wxHtml classes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@72851 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- etg/_html.py | 73 ++++++++++++++++++++++++++++++++++++++++ etg/htmlcell.py | 57 +++++++++++++++++++++++++++++++ etg/htmlfilt.py | 47 ++++++++++++++++++++++++++ etg/htmlpars.py | 59 ++++++++++++++++++++++++++++++++ etg/htmlprint.py | 55 ++++++++++++++++++++++++++++++ etg/htmltag.py | 49 +++++++++++++++++++++++++++ etg/htmlwin.py | 83 ++++++++++++++++++++++++++++++++++++++++++++++ etg/htmlwinpars.py | 48 +++++++++++++++++++++++++++ setup.py | 15 +++++++++ wscript | 20 +++++++++++ 10 files changed, 506 insertions(+) create mode 100644 etg/_html.py create mode 100644 etg/htmlcell.py create mode 100644 etg/htmlfilt.py create mode 100644 etg/htmlpars.py create mode 100644 etg/htmlprint.py create mode 100644 etg/htmltag.py create mode 100644 etg/htmlwin.py create mode 100644 etg/htmlwinpars.py diff --git a/etg/_html.py b/etg/_html.py new file mode 100644 index 00000000..b95ad457 --- /dev/null +++ b/etg/_html.py @@ -0,0 +1,73 @@ +#--------------------------------------------------------------------------- +# Name: etg/_html.py +# Author: Robin Dunn +# +# Created: 27-Oct-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools +from etgtools import PyFunctionDef, PyCodeDef, PyPropertyDef + +PACKAGE = "wx" +MODULE = "_html" +NAME = "_html" # 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 = [ ] + + +# The list of other ETG scripts and back-end generator modules that are +# included as part of this module. These should all be items that are put in +# the wxWidgets "adv" library in a multi-lib build. +INCLUDES = [ + 'htmlcell', + 'htmlfilt', + 'htmltag', + 'htmlpars', + 'htmlwin', + 'htmlprint', + #'htmlwinpars', + ] + + +# Separate the list into those that are generated from ETG scripts and the +# rest. These lists can be used from the build scripts to get a list of +# sources and/or additional dependencies when building this extension module. +ETGFILES = ['etg/%s.py' % NAME] + tools.getEtgFiles(INCLUDES) +DEPENDS = tools.getNonEtgFiles(INCLUDES) +OTHERDEPS = [ ] + + +#--------------------------------------------------------------------------- + +def run(): + # Parse the XML file(s) building a collection of Extractor objects + module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) + etgtools.parseDoxyXML(module, ITEMS) + module.check4unittest = False + + #----------------------------------------------------------------- + # Tweak the parsed meta objects in the module object as needed for + # customizing the generated code and docstrings. + + module.addHeaderCode('#include ') + module.addImport('_core') + module.addPyCode("import wx", order=10) + module.addInclude(INCLUDES) + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + run() diff --git a/etg/htmlcell.py b/etg/htmlcell.py new file mode 100644 index 00000000..73dbaedd --- /dev/null +++ b/etg/htmlcell.py @@ -0,0 +1,57 @@ +#--------------------------------------------------------------------------- +# Name: etg/htmlcell.py +# Author: Robin Dunn +# +# Created: 27-Oct-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_html" +NAME = "htmlcell" # 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 = [ "wxHtmlSelection", + "wxHtmlRenderingState", + "wxHtmlRenderingStyle", + "wxHtmlRenderingInfo", + "wxHtmlCell", + "wxHtmlContainerCell", + "wxHtmlLinkInfo", + "wxHtmlColourCell", + "wxHtmlWidgetCell", + ] + +#--------------------------------------------------------------------------- + +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('wxHtmlCell') + assert isinstance(c, etgtools.ClassDef) + c.addPrivateCopyCtor() + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/htmlfilt.py b/etg/htmlfilt.py new file mode 100644 index 00000000..6481b9c2 --- /dev/null +++ b/etg/htmlfilt.py @@ -0,0 +1,47 @@ +#--------------------------------------------------------------------------- +# Name: etg/htmlfilt.py +# Author: Robin Dunn +# +# Created: 27-Oct-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_html" +NAME = "htmlfilt" # 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 = [ "wxHtmlFilter", + + ] + +#--------------------------------------------------------------------------- + +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('') + #assert isinstance(c, etgtools.ClassDef) + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/htmlpars.py b/etg/htmlpars.py new file mode 100644 index 00000000..f7897beb --- /dev/null +++ b/etg/htmlpars.py @@ -0,0 +1,59 @@ +#--------------------------------------------------------------------------- +# Name: etg/htmlpars.py +# Author: Robin Dunn +# +# Created: 29-Oct-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_html" +NAME = "htmlpars" # 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 = [ "wxHtmlTagHandler", + "wxHtmlParser", + ] + +#--------------------------------------------------------------------------- + +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('wxHtmlTagHandler') + assert isinstance(c, etgtools.ClassDef) + c.addPrivateCopyCtor() + c.find('ParseInner').ignore(False) + c.find('ParseInnerSource').ignore(False) + + + c = module.find('wxHtmlParser') + c.addPrivateCopyCtor() + c.abstract = True + c.find('AddTag').ignore(False) + c.find('AddWord').ignore() + c.find('DoParsing').findOverload('const_iterator').ignore() + + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/htmlprint.py b/etg/htmlprint.py new file mode 100644 index 00000000..3a1df144 --- /dev/null +++ b/etg/htmlprint.py @@ -0,0 +1,55 @@ +#--------------------------------------------------------------------------- +# Name: etg/htmlprint.py +# Author: Robin Dunn +# +# Created: 29-Oct-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_html" +NAME = "htmlprint" # 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 = [ "wxHtmlDCRenderer", + "wxHtmlEasyPrinting", + "wxHtmlPrintout", + ] + +#--------------------------------------------------------------------------- + +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('wxHtmlDCRenderer') + assert isinstance(c, etgtools.ClassDef) + c.addPrivateCopyCtor() + + c = module.find('wxHtmlEasyPrinting') + c.addPrivateCopyCtor() + + c = module.find('wxHtmlPrintout') + c.addPrivateCopyCtor() + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/htmltag.py b/etg/htmltag.py new file mode 100644 index 00000000..29e8e946 --- /dev/null +++ b/etg/htmltag.py @@ -0,0 +1,49 @@ +#--------------------------------------------------------------------------- +# Name: etg/htmltag.py +# Author: Robin Dunn +# +# Created: 29-Oct-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_html" +NAME = "htmltag" # 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 = [ "wxHtmlTag", + + ] + +#--------------------------------------------------------------------------- + +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('wxHtmlTag') + assert isinstance(c, etgtools.ClassDef) + c.addPrivateCopyCtor() + + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/htmlwin.py b/etg/htmlwin.py new file mode 100644 index 00000000..3964ec8c --- /dev/null +++ b/etg/htmlwin.py @@ -0,0 +1,83 @@ +#--------------------------------------------------------------------------- +# Name: etg/htmlwin.py +# Author: Robin Dunn +# +# Created: 29-Oct-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_html" +NAME = "htmlwin" # 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 = [ "wxHtmlWindowInterface", + "wxHtmlWindow", + "wxHtmlLinkEvent", + "wxHtmlCellEvent", + ] + +#--------------------------------------------------------------------------- + +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('wxHtmlWindow') + assert isinstance(c, etgtools.ClassDef) + tools.fixWindowClass(c) + c.bases = ['wxScrolledWindow'] + + c.find('OnCellClicked').ignore(False) + c.find('OnCellMouseHover').ignore(False) + + # Pure virtuals inherited from wxHtmlWindowInterface + c.addItem(etgtools.WigCode("""\ + virtual void SetHTMLWindowTitle(const wxString& title); + virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link); + virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type, + const wxString& url, + wxString *redirect) const; + virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell, + const wxPoint& pos) const; + virtual wxWindow* GetHTMLWindow(); + virtual wxColour GetHTMLBackgroundColour() const; + virtual void SetHTMLBackgroundColour(const wxColour& clr); + virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg); + virtual void SetHTMLStatusText(const wxString& text); + virtual wxCursor GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor type) const; + """)) + + c = module.find('wxHtmlLinkEvent') + tools.fixEventClass(c) + + c = module.find('wxHtmlCellEvent') + tools.fixEventClass(c) + + module.addPyCode("""\ + EVT_HTML_CELL_CLICKED = wx.PyEventBinder( wxEVT_COMMAND_HTML_CELL_CLICKED, 1 ) + EVT_HTML_CELL_HOVER = wx.PyEventBinder( wxEVT_COMMAND_HTML_CELL_HOVER, 1 ) + EVT_HTML_LINK_CLICKED = wx.PyEventBinder( wxEVT_COMMAND_HTML_LINK_CLICKED, 1 ) + """) + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/htmlwinpars.py b/etg/htmlwinpars.py new file mode 100644 index 00000000..11bfd702 --- /dev/null +++ b/etg/htmlwinpars.py @@ -0,0 +1,48 @@ +#--------------------------------------------------------------------------- +# Name: etg/htmlwinpars.py +# Author: Robin Dunn +# +# Created: 29-Oct-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_html" +NAME = "htmlwinpars" # 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 = [ "wxHtmlWinParser", + "wxHtmlTagsModule", + ] + +#--------------------------------------------------------------------------- + +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('wxHtmlWinParser') + assert isinstance(c, etgtools.ClassDef) + + c.find('GetEncodingConverter').ignore() + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/setup.py b/setup.py index 88dd102b..27afa6cd 100644 --- a/setup.py +++ b/setup.py @@ -199,6 +199,21 @@ extensions.append(ext) cfg.CLEANUP.append(opj(cfg.PKGDIR, 'stc.py')) +etg = loadETG('etg/_html.py') +etgDepends = etg.DEPENDS + etg.OTHERDEPS +ext = Extension('_html', getEtgSipCppFiles(etg), + depends = getEtgSipHeaders(etg), + include_dirs = cfg.includes, + define_macros = cfg.defines, + library_dirs = cfg.libdirs, + libraries = cfg.libs + cfg.makeLibName('html', True), + extra_compile_args = cfg.cflags, + extra_link_args = cfg.lflags, + ) +extensions.append(ext) +cfg.CLEANUP.append(opj(cfg.PKGDIR, 'html.py')) + + #---------------------------------------------------------------------- if __name__ == '__main__': diff --git a/wscript b/wscript index 4cbd1a28..e9e7894a 100644 --- a/wscript +++ b/wscript @@ -84,6 +84,11 @@ def configure(conf): _copyEnvGroup(conf.env, '_WX', '_WXSTC') conf.env.LIB_WXSTC += cfg.makeLibName('stc') + _copyEnvGroup(conf.env, '_WX', '_WXHTML') + conf.env.LIB_WXHTML += cfg.makeLibName('html') + + + # tweak the PYEXT compile and link flags if making a --debug build if conf.env.debug: for listname in ['CFLAGS_PYEXT', 'CXXFLAGS_PYEXT']: @@ -125,6 +130,11 @@ def configure(conf): args='--cxxflags --libs %score,net' % libname, uselib_store='WXSTC', mandatory=True) + conf.check_cfg(path=conf.options.wx_config, package='', + args='--cxxflags --libs html,core,net', + uselib_store='WXHTML', mandatory=True) + + # NOTE: This assumes that if the platform is not win32 (from # the test above) and not darwin then we must be using the # GTK2 port of wxWidgets. If we ever support other ports then @@ -276,6 +286,16 @@ def build(bld): makeExtCopyRule(bld, '_stc') + etg = loadETG('etg/_html.py') + adv = bld( + features = 'c cxx cxxshlib pyext', + target = makeTargetName(bld, '_html'), + source = getEtgSipCppFiles(etg) + rc, + uselib = 'WXHTML WXPY', + ) + makeExtCopyRule(bld, '_html') + + #-----------------------------------------------------------------------------