Allow opening ToC and index in wxCHMHelpController

Use special values of DisplaySection() and KeywordSearch() parameters to
open the table of contents (if section is -1) or search page (if the
keyword to search for is empty) when using CHM help controller.

This is less discoverable than having separate Display{TOC,Search}()
methods, but avoids introducing special API that couldn't be implemented
in the other wxHelpController implementations.

Closes #18445.
This commit is contained in:
Andreas Falkenhahn
2019-07-24 11:29:06 +02:00
committed by Vadim Zeitlin
parent 9eb4c8ee2b
commit 79724b1710
2 changed files with 36 additions and 11 deletions

View File

@@ -100,6 +100,7 @@ public:
If the help viewer is not running, runs it and displays the given section.
- @e WinHelp, MS HTML Help @a sectionNo is a context id.
- @e MS HTML Help: Pass -1 in @a sectionNo to display the index.
- @e External HTML help: wxExtHelpController implements @a sectionNo as
an id in a map file, which is of the form:
- @e wxHtmlHelpController: @a sectionNo is an identifier as specified in
@@ -161,6 +162,7 @@ public:
- @e WinHelp, MS HTML Help:
If more than one match is found, the first topic is displayed.
- @e MS HTML Help: Pass an empty string to display the search page.
- @e External HTML help, simple wxHTML help:
If more than one match is found, a choice of topics is displayed.
- @e wxHtmlHelpController: see wxHtmlHelpController::KeywordSearch.

View File

@@ -113,7 +113,7 @@ bool wxCHMHelpController::DisplayContents()
if (m_helpFile.IsEmpty())
return false;
return CallHtmlHelp(HH_DISPLAY_TOPIC);
return CallHtmlHelp(HH_DISPLAY_TOC);
}
// Use topic or HTML filename
@@ -138,6 +138,12 @@ bool wxCHMHelpController::DisplaySection(int section)
if (m_helpFile.IsEmpty())
return false;
// Treat -1 as a special context number that displays the index
if (section == -1)
{
return CallHtmlHelp(HH_DISPLAY_INDEX);
}
return CallHtmlHelp(HH_HELP_CONTEXT, section);
}
@@ -197,17 +203,34 @@ bool wxCHMHelpController::KeywordSearch(const wxString& k,
if (m_helpFile.IsEmpty())
return false;
HH_AKLINK link;
link.cbStruct = sizeof(HH_AKLINK);
link.fReserved = FALSE;
link.pszKeywords = k.t_str();
link.pszUrl = NULL;
link.pszMsgText = NULL;
link.pszMsgTitle = NULL;
link.pszWindow = NULL;
link.fIndexOnFail = TRUE;
if (k.IsEmpty())
{
HH_FTS_QUERY oQuery;
oQuery.cbStruct = sizeof(HH_FTS_QUERY);
oQuery.fStemmedSearch = 0;
oQuery.fTitleOnly = 0;
oQuery.fUniCodeStrings = 0;
oQuery.iProximity = 0;
oQuery.pszSearchQuery = TEXT("");
oQuery.pszWindow = TEXT("");
oQuery.fExecute = 1;
return CallHtmlHelp(HH_KEYWORD_LOOKUP, &link);
return CallHtmlHelp(HH_DISPLAY_SEARCH, &oQuery);
}
else
{
HH_AKLINK link;
link.cbStruct = sizeof(HH_AKLINK);
link.fReserved = FALSE;
link.pszKeywords = k.t_str();
link.pszUrl = NULL;
link.pszMsgText = NULL;
link.pszMsgTitle = NULL;
link.pszWindow = NULL;
link.fIndexOnFail = TRUE;
return CallHtmlHelp(HH_KEYWORD_LOOKUP, &link);
}
}
bool wxCHMHelpController::Quit()