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. 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 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 - @e External HTML help: wxExtHelpController implements @a sectionNo as
an id in a map file, which is of the form: an id in a map file, which is of the form:
- @e wxHtmlHelpController: @a sectionNo is an identifier as specified in - @e wxHtmlHelpController: @a sectionNo is an identifier as specified in
@@ -161,6 +162,7 @@ public:
- @e WinHelp, MS HTML Help: - @e WinHelp, MS HTML Help:
If more than one match is found, the first topic is displayed. 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: - @e External HTML help, simple wxHTML help:
If more than one match is found, a choice of topics is displayed. If more than one match is found, a choice of topics is displayed.
- @e wxHtmlHelpController: see wxHtmlHelpController::KeywordSearch. - @e wxHtmlHelpController: see wxHtmlHelpController::KeywordSearch.

View File

@@ -113,7 +113,7 @@ bool wxCHMHelpController::DisplayContents()
if (m_helpFile.IsEmpty()) if (m_helpFile.IsEmpty())
return false; return false;
return CallHtmlHelp(HH_DISPLAY_TOPIC); return CallHtmlHelp(HH_DISPLAY_TOC);
} }
// Use topic or HTML filename // Use topic or HTML filename
@@ -138,6 +138,12 @@ bool wxCHMHelpController::DisplaySection(int section)
if (m_helpFile.IsEmpty()) if (m_helpFile.IsEmpty())
return false; 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); return CallHtmlHelp(HH_HELP_CONTEXT, section);
} }
@@ -197,17 +203,34 @@ bool wxCHMHelpController::KeywordSearch(const wxString& k,
if (m_helpFile.IsEmpty()) if (m_helpFile.IsEmpty())
return false; return false;
HH_AKLINK link; if (k.IsEmpty())
link.cbStruct = sizeof(HH_AKLINK); {
link.fReserved = FALSE; HH_FTS_QUERY oQuery;
link.pszKeywords = k.t_str(); oQuery.cbStruct = sizeof(HH_FTS_QUERY);
link.pszUrl = NULL; oQuery.fStemmedSearch = 0;
link.pszMsgText = NULL; oQuery.fTitleOnly = 0;
link.pszMsgTitle = NULL; oQuery.fUniCodeStrings = 0;
link.pszWindow = NULL; oQuery.iProximity = 0;
link.fIndexOnFail = TRUE; 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() bool wxCHMHelpController::Quit()