applied Otto Wyss' patch to extend wxHelpController::KeywordSearch with mode argument (modified to the point of reimplementation)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23450 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2003-09-09 17:29:11 +00:00
parent 69efd83d47
commit 69b5cec2b0
18 changed files with 126 additions and 57 deletions

View File

@ -184,10 +184,13 @@ that the viewer is a variant of Netscape Navigator.}
\membersection{wxHelpController::KeywordSearch}\label{wxhelpcontrollerkeywordsearch}
\func{virtual bool}{KeywordSearch}{\param{const wxString\& }{keyWord}}
\func{virtual bool}{KeywordSearch}{\param{const wxString\& }{keyWord}, \param{wxHelpSearchMode }{mode = wxHELP\_SEARCH\_ALL}}
If the help viewer is not running, runs it, and searches for sections matching the given keyword. If one
match is found, the file is displayed at this section.
If the help viewer is not running, runs it, and searches for sections matching
the given keyword. If one match is found, the file is displayed at this
section. The optional parameter allows the search the index
(wxHELP\_SEARCH\_INDEX) but this currently only supported by the
wxHtmlHelpController.
{\it WinHelp, MS HTML Help:} If more than one match is found,
the first topic is displayed.

View File

@ -163,10 +163,11 @@ Displays help window and focuses index panel.
\membersection{wxHtmlHelpController::KeywordSearch}\label{wxhtmlhelpcontrollerkeywordsearch}
\func{bool}{KeywordSearch}{\param{const wxString\& }{keyword}}
\func{bool}{KeywordSearch}{\param{const wxString\& }{keyword}, \param{wxHelpSearchMode }{mode = wxHELP\_SEARCH\_ALL}}
Displays help window, focuses search panel and starts searching.
Returns true if the keyword was found.
Displays help window, focuses search panel and starts searching. Returns true
if the keyword was found. Optionally it searches through the index (mode =
wxHELP\_SEARCH\_INDEX), default the content (mode = wxHELP\_SEARCH\_ALL).
{\bf Important:} KeywordSearch searches only pages listed in .hhc file(s).
You should list all pages in the contents file.

View File

@ -121,9 +121,10 @@ Return wxHtmlHelpData object.
\membersection{wxHtmlHelpFrame::KeywordSearch}\label{wxhtmlhelpframekeywordsearch}
\func{bool}{KeywordSearch}{\param{const wxString\& }{keyword}}
\func{bool}{KeywordSearch}{\param{const wxString\& }{keyword}, \param{wxHelpSearchMode }{mode = wxHELP\_SEARCH\_ALL}}
Search for given keyword.
Search for given keyword. Optionally it searches through the index (mode =
wxHELP\_SEARCH\_INDEX), default the content (mode = wxHELP\_SEARCH\_ALL).
\membersection{wxHtmlHelpFrame::ReadCustomization}\label{wxhtmlhelpframereadcustomization}

View File

@ -28,6 +28,13 @@
// Flags for SetViewer
#define wxHELP_NETSCAPE 1
// Search modes:
enum wxHelpSearchMode
{
wxHELP_SEARCH_INDEX,
wxHELP_SEARCH_ALL
};
// Defines the API for help controllers
class WXDLLEXPORT wxHelpControllerBase: public wxObject
{
@ -63,7 +70,8 @@ public:
// may override this for more specific behaviour.
virtual bool DisplaySection(const wxString& section) { return KeywordSearch(section); }
virtual bool DisplayBlock(long blockNo) = 0;
virtual bool KeywordSearch(const wxString& k) = 0;
virtual bool KeywordSearch(const wxString& k,
wxHelpSearchMode mode = wxHELP_SEARCH_ALL) = 0;
/// Allows one to override the default settings for the help frame.
virtual void SetFrameParameters(const wxString& WXUNUSED(title),
const wxSize& WXUNUSED(size),

View File

@ -20,8 +20,8 @@
#if wxUSE_WXHTML_HELP
#include "wx/html/helpfrm.h"
#include "wx/helpbase.h"
#include "wx/html/helpfrm.h"
#define wxID_HTML_HELPFRAME (wxID_HIGHEST + 1)
@ -42,7 +42,8 @@ public:
bool Display(int id);
bool DisplayContents();
bool DisplayIndex();
bool KeywordSearch(const wxString& keyword);
bool KeywordSearch(const wxString& keyword,
wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
wxHtmlHelpFrame* GetFrame() { return m_helpFrame; }
void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);

View File

@ -20,6 +20,7 @@
#if wxUSE_WXHTML_HELP
#include "wx/helpbase.h"
#include "wx/html/helpdata.h"
#include "wx/window.h"
#include "wx/frame.h"
@ -120,7 +121,8 @@ public:
// * word may be pretended by + or -
// (+ : page must contain the word ; - : page can't contain the word)
// * if there is no + or - before the word, + is default
bool KeywordSearch(const wxString& keyword);
bool KeywordSearch(const wxString& keyword,
wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString)
{

View File

@ -37,7 +37,8 @@ class WXDLLEXPORT wxXXXXHelpController: public wxHelpControllerBase
virtual bool DisplayContents();
virtual bool DisplaySection(int sectionNo);
virtual bool DisplayBlock(long blockNo);
virtual bool KeywordSearch(const wxString& k);
virtual bool KeywordSearch(const wxString& k,
wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
virtual bool Quit();
virtual void OnQuit();

View File

@ -70,9 +70,10 @@ public:
return m_helpController->DisplayTextPopup( text, pos );
}
virtual bool KeywordSearch(const wxString& k)
virtual bool KeywordSearch(const wxString& k,
wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
{
return m_helpController->KeywordSearch( k );
return m_helpController->KeywordSearch( k, mode );
}
virtual bool Quit()

View File

@ -37,7 +37,8 @@ public:
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);
virtual bool KeywordSearch(const wxString& k,
wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
virtual bool Quit();
wxString GetHelpFile() const { return m_helpFile; }

View File

@ -39,7 +39,8 @@ public:
virtual bool DisplaySection(int sectionNo);
virtual bool DisplayBlock(long blockNo);
virtual bool DisplayContextPopup(int contextId);
virtual bool KeywordSearch(const wxString& k);
virtual bool KeywordSearch(const wxString& k,
wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
virtual bool Quit();
inline wxString GetHelpFile() const { return m_helpFile; }

View File

@ -34,7 +34,8 @@ class WXDLLEXPORT wxWinHelpController: public wxHelpControllerBase
virtual bool DisplayContents();
virtual bool DisplaySection(int sectionNo);
virtual bool DisplayBlock(long blockNo);
virtual bool KeywordSearch(const wxString& k);
virtual bool KeywordSearch(const wxString& k,
wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
virtual bool Quit();
virtual void OnQuit();

View File

@ -319,10 +319,11 @@ bool wxHtmlHelpController::DisplayIndex()
return success;
}
bool wxHtmlHelpController::KeywordSearch(const wxString& keyword)
bool wxHtmlHelpController::KeywordSearch(const wxString& keyword,
wxHelpSearchMode mode)
{
CreateHelpWindow();
bool success = m_helpFrame->KeywordSearch(keyword);
bool success = m_helpFrame->KeywordSearch(keyword, mode);
AddGrabIfNeeded();
return success;
}

View File

@ -657,12 +657,23 @@ bool wxHtmlHelpFrame::DisplayIndex()
bool wxHtmlHelpFrame::KeywordSearch(const wxString& keyword)
bool wxHtmlHelpFrame::KeywordSearch(const wxString& keyword,
wxHelpSearchMode mode)
{
if (! (m_SearchList && m_SearchButton && m_SearchText && m_SearchChoice))
return FALSE;
if (mode == wxHELP_SEARCH_ALL)
{
if ( !(m_SearchList &&
m_SearchButton && m_SearchText && m_SearchChoice) )
return false;
}
else if (mode == wxHELP_SEARCH_INDEX)
{
if ( !(m_IndexList &&
m_IndexButton && m_IndexButtonAll && m_IndexText) )
return false;
}
int foundcnt = 0, curi;
int foundcnt = 0;
wxString foundstr;
wxString book = wxEmptyString;
@ -672,41 +683,71 @@ bool wxHtmlHelpFrame::KeywordSearch(const wxString& keyword)
m_HtmlWin->Show(TRUE);
m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
}
m_NavigNotebook->SetSelection(m_SearchPage);
m_SearchList->Clear();
m_SearchText->SetValue(keyword);
m_SearchButton->Enable(FALSE);
if (m_SearchChoice->GetSelection() != 0)
book = m_SearchChoice->GetStringSelection();
wxHtmlSearchStatus status(m_Data, keyword,
m_SearchCaseSensitive->GetValue(), m_SearchWholeWords->GetValue(),
book);
wxProgressDialog progress(_("Searching..."), _("No matching page found yet"),
status.GetMaxIndex(), this,
wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE);
while (status.IsActive())
if (mode == wxHELP_SEARCH_ALL)
{
curi = status.GetCurIndex();
if (curi % 32 == 0 && progress.Update(curi) == FALSE)
break;
if (status.Search())
m_NavigNotebook->SetSelection(m_SearchPage);
m_SearchList->Clear();
m_SearchText->SetValue(keyword);
m_SearchButton->Enable(false);
if (m_SearchChoice->GetSelection() != 0)
book = m_SearchChoice->GetStringSelection();
wxHtmlSearchStatus status(m_Data, keyword,
m_SearchCaseSensitive->GetValue(),
m_SearchWholeWords->GetValue(),
book);
wxProgressDialog progress(_("Searching..."),
_("No matching page found yet"),
status.GetMaxIndex(), this,
wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE);
int curi;
while (status.IsActive())
{
foundstr.Printf(_("Found %i matches"), ++foundcnt);
progress.Update(status.GetCurIndex(), foundstr);
m_SearchList->Append(status.GetName(), status.GetContentsItem());
curi = status.GetCurIndex();
if (curi % 32 == 0 && progress.Update(curi) == FALSE)
break;
if (status.Search())
{
foundstr.Printf(_("Found %i matches"), ++foundcnt);
progress.Update(status.GetCurIndex(), foundstr);
m_SearchList->Append(status.GetName(), status.GetContentsItem());
}
}
m_SearchButton->Enable(TRUE);
m_SearchText->SetSelection(0, keyword.Length());
m_SearchText->SetFocus();
}
else if (mode == wxHELP_SEARCH_INDEX)
{
m_NavigNotebook->SetSelection(m_IndexPage);
m_IndexList->Clear();
m_IndexButton->Enable(false);
m_IndexButtonAll->Enable(false);
m_IndexText->SetValue(keyword);
wxCommandEvent dummy;
OnIndexFind(dummy); // what a hack...
m_IndexButton->Enable(true);
m_IndexButtonAll->Enable(true);
foundcnt = m_IndexList->GetCount();
}
m_SearchButton->Enable(TRUE);
m_SearchText->SetSelection(0, keyword.Length());
m_SearchText->SetFocus();
if (foundcnt)
{
wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList->GetClientData(0);
wxHtmlContentsItem *it;
if (mode == wxHELP_SEARCH_ALL)
{
it = (wxHtmlContentsItem*) m_SearchList->GetClientData(0);
}
else if (mode == wxHELP_SEARCH_INDEX)
{
it = (wxHtmlContentsItem*) m_IndexList->GetClientData(0);
}
if (it)
{
m_HtmlWin->LoadPage(it->GetFullPath());
@ -1489,7 +1530,8 @@ void wxHtmlHelpFrame::OnSearch(wxCommandEvent& WXUNUSED(event))
{
wxString sr = m_SearchText->GetLineText(0);
if (sr != wxEmptyString) KeywordSearch(sr);
if (!sr.empty())
KeywordSearch(sr, wxHELP_SEARCH_ALL);
}
void wxHtmlHelpFrame::OnBookmarksSel(wxCommandEvent& WXUNUSED(event))

View File

@ -62,7 +62,8 @@ bool wxXXXXHelpController::DisplayBlock(long block)
return FALSE;
}
bool wxXXXXHelpController::KeywordSearch(const wxString& k)
bool wxXXXXHelpController::KeywordSearch(const wxString& k,
wxHelpSearchMode WXUNUSED(mode))
{
if (m_helpFile == "") return FALSE;

View File

@ -62,7 +62,8 @@ bool wxXXXXHelpController::DisplayBlock(long block)
return FALSE;
}
bool wxXXXXHelpController::KeywordSearch(const wxString& k)
bool wxXXXXHelpController::KeywordSearch(const wxString& k,
wxHelpSearchMode WXUNUSED(mode))
{
if (m_helpFile == "") return FALSE;

View File

@ -197,7 +197,8 @@ bool wxCHMHelpController::DisplayBlock(long block)
return DisplaySection(block);
}
bool wxCHMHelpController::KeywordSearch(const wxString& k)
bool wxCHMHelpController::KeywordSearch(const wxString& k,
wxHelpSearchMode WXUNUSED(mode))
{
if (m_helpFile.IsEmpty()) return FALSE;

View File

@ -98,7 +98,8 @@ bool wxWinHelpController::DisplayBlock(long block)
return TRUE;
}
bool wxWinHelpController::KeywordSearch(const wxString& k)
bool wxWinHelpController::KeywordSearch(const wxString& k,
wxHelpSearchMode WXUNUSED(mode))
{
if (m_helpFile.IsEmpty()) return FALSE;

View File

@ -108,7 +108,8 @@ bool wxWinHelpController::DisplayBlock(long block)
return FALSE;
}
bool wxWinHelpController::KeywordSearch(const wxString& k)
bool wxWinHelpController::KeywordSearch(const wxString& k,
wxHelpSearchMode WXUNUSED(mode))
{
if (m_helpFile == "") return FALSE;