Merge pull request #1538 from wxWidgets/help-controller

Add wx.HtmlController and wx.msw.CHMHelpController
This commit is contained in:
Robin Dunn
2020-03-02 18:27:29 -08:00
committed by GitHub
5 changed files with 72 additions and 16 deletions

View File

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

View File

@@ -1572,6 +1572,7 @@
"HeaderCtrlSimple":"wx.",
"HeaderSortIconType":"wx.",
"Height":"wx.",
"HelpController":"wx.",
"HelpControllerBase":"wx.",
"HelpControllerHelpProvider":"wx.",
"HelpEvent":"wx.",

View File

@@ -31,6 +31,7 @@ ITEMS = []
INCLUDES = [
'axbase',
'helpchm',
]
# Separate the list into those that are generated from ETG scripts and the

View File

@@ -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 for the platform.
""",
body="""\
try:
if 'wxMSW' in wx.PlatformInfo:
from .msw import CHMHelpController as ControllerClass
else:
from .html import HtmlHelpController as ControllerClass
except ImportError:
from .adv import ExtHelpController as ControllerClass
#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)
""")

46
src/helpchm.sip Normal file
View File

@@ -0,0 +1,46 @@
//--------------------------------------------------------------------------
// 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
//--------------------------------------------------------------------------
// 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
{
%TypeHeaderCode
#include <wx/msw/helpchm.h>
%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);
};