From 434365ec00792df9e977d283a5496891e96d045d Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 2 Mar 2020 15:11:14 -0800 Subject: [PATCH 1/5] Add CHMHelpController, and a wx.HelpController factory function --- docs/sphinx/itemToModuleMap.json | 1 + etg/_msw.py | 1 + etg/help.py | 37 ++++++++++++++++------------ src/helpchm.sip | 42 ++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 src/helpchm.sip diff --git a/docs/sphinx/itemToModuleMap.json b/docs/sphinx/itemToModuleMap.json index c53aaeef..fba9c104 100644 --- a/docs/sphinx/itemToModuleMap.json +++ b/docs/sphinx/itemToModuleMap.json @@ -1572,6 +1572,7 @@ "HeaderCtrlSimple":"wx.", "HeaderSortIconType":"wx.", "Height":"wx.", +"HelpController":"wx.", "HelpControllerBase":"wx.", "HelpControllerHelpProvider":"wx.", "HelpEvent":"wx.", diff --git a/etg/_msw.py b/etg/_msw.py index 900cd17b..efe6799d 100644 --- a/etg/_msw.py +++ b/etg/_msw.py @@ -31,6 +31,7 @@ ITEMS = [] INCLUDES = [ 'axbase', + 'helpchm', ] # Separate the list into those that are generated from ETG scripts and the diff --git a/etg/help.py b/etg/help.py index ec5bfacb..764a05b0 100644 --- a/etg/help.py +++ b/etg/help.py @@ -44,24 +44,29 @@ def run(): # NOTE: Since wxHelpController is an alias for wxHtmlHelpController on # Mac and GTK, and since we don't want to force the wx.core extension # module to link to the wxHTML library, then we won't provide a wrapper - # for the wxHelpController 'class'. Later on when we've got all the help - # controller classes that we'll want then we can add a wxHelpController - # or factory of our own in Python code. + # for the wxHelpController 'class' here. + # + # Instead we'll add a Python factory function that accomplishes the same + # thing. Basically it just provides a help controller instance that is the + # best for the platform. + module.addPyFunction('HelpController', '(parentWindow=None)', + doc="""\ + Rather than being an alias for some class, the Python version of + ``HelpController`` is a factory function that creates and returns an + instance of the best Help Controller is returned to the caller. + """, + body="""\ + try: + if 'wxMSW' in wx.PlatformInfo: + import wx.msw.wxCHMHelpController as ControllerClass + else: + import wx.html.HtmlHelpController as ControllerClass + except ImportError: + ControllerClass = wx.ExtHelpController - #c = module.find('wxHelpController') - #c.mustHaveApp() - #c.addPrivateCopyCtor() - ## Add pure virtuals with implemenations here - #c.addItem(etgtools.WigCode("""\ - #virtual bool DisplayBlock(long blockNo); - #virtual bool DisplayContents(); - #virtual bool DisplaySection(int sectionNo); - #virtual bool KeywordSearch(const wxString& keyWord, - # wxHelpSearchMode mode = wxHELP_SEARCH_ALL); - #virtual bool LoadFile(const wxString& file = wxEmptyString); - #virtual bool Quit(); - #""")) + return ControllerClass(parentWindow) + """) diff --git a/src/helpchm.sip b/src/helpchm.sip new file mode 100644 index 00000000..13a71d6d --- /dev/null +++ b/src/helpchm.sip @@ -0,0 +1,42 @@ +//-------------------------------------------------------------------------- +// Name: helpchm.sip +// Purpose: SIP wrapper details for wxCHMHelpController +// +// Author: Robin Dunn +// +// Created: 02-March-2020 +// Copyright: (c) 2020 by Total Control Software +// Licence: wxWindows license +//-------------------------------------------------------------------------- + + + +class wxCHMHelpController : public wxHelpControllerBase +{ + %TypeHeaderCode + #include + %End + +public: + wxCHMHelpController(wxWindow* parentWindow = NULL); + + virtual bool Initialize(const wxString& file); + + virtual bool LoadFile(const wxString& file = wxEmptyString); + virtual bool DisplayContents(); + virtual bool DisplaySection(int sectionNo); + virtual bool DisplaySection(const wxString& section); + virtual bool DisplayBlock(long blockNo); + virtual bool DisplayContextPopup(int contextId); + virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos); + virtual bool KeywordSearch(const wxString& k, + wxHelpSearchMode mode = wxHELP_SEARCH_ALL); + virtual bool Quit(); + + wxString GetHelpFile() const; + + static bool ShowContextHelpPopup(const wxString& text, + const wxPoint& pos, + wxWindow *window); + +}; From 06a7a065f9de3118cc97cde38f88e62535398016 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 2 Mar 2020 15:23:51 -0800 Subject: [PATCH 2/5] fix imports --- etg/help.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etg/help.py b/etg/help.py index 764a05b0..d44de24a 100644 --- a/etg/help.py +++ b/etg/help.py @@ -59,11 +59,11 @@ def run(): body="""\ try: if 'wxMSW' in wx.PlatformInfo: - import wx.msw.wxCHMHelpController as ControllerClass + from .msw import CHMHelpController as ControllerClass else: - import wx.html.HtmlHelpController as ControllerClass + from .html import HtmlHelpController as ControllerClass except ImportError: - ControllerClass = wx.ExtHelpController + from .adv import ExtHelpController as ControllerClass return ControllerClass(parentWindow) """) From b0b2063224b6a4c4c4b2fbdc9da4fbaa8bafbe39 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 2 Mar 2020 15:56:40 -0800 Subject: [PATCH 3/5] Add changelog entry --- CHANGES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index d56fff53..f2c43d01 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -85,6 +85,9 @@ New and improved in this release: * Fixed issues in PlotCanvas around displaying and using scrollbars. (#1428) +* Added wx.msw.CHMHelpController, and also a wx.HelpController factory function + that creates an instance of the best Help Controller for the platform. (#1536) + From 55d3fd4e7080a9e4dd3f0e64f4df1a1f2fe3661c Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 2 Mar 2020 16:01:42 -0800 Subject: [PATCH 4/5] Explain why wxCHMHelpController is in src instead of etg. --- src/helpchm.sip | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/helpchm.sip b/src/helpchm.sip index 13a71d6d..28cc1368 100644 --- a/src/helpchm.sip +++ b/src/helpchm.sip @@ -10,6 +10,11 @@ //-------------------------------------------------------------------------- +// NOTE: This class is defined here instead of an etg file because it is not +// documented in the wxWidgets interface files. However since it implements the +// same API as all the other help controller classes then I think it's an okay +// workaround for now. + class wxCHMHelpController : public wxHelpControllerBase { @@ -38,5 +43,4 @@ public: static bool ShowContextHelpPopup(const wxString& text, const wxPoint& pos, wxWindow *window); - }; From 12cce4000c9af283b9fe012eee6d75eeb1ef3925 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 2 Mar 2020 16:06:24 -0800 Subject: [PATCH 5/5] Fix doctring --- etg/help.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etg/help.py b/etg/help.py index d44de24a..60c33b53 100644 --- a/etg/help.py +++ b/etg/help.py @@ -54,7 +54,7 @@ def run(): doc="""\ Rather than being an alias for some class, the Python version of ``HelpController`` is a factory function that creates and returns an - instance of the best Help Controller is returned to the caller. + instance of the best Help Controller for the platform. """, body="""\ try: