Added parent window parameter to wxHelpController constructor

and added SetParentWindow/GetParentWindow.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36017 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2005-10-26 09:32:10 +00:00
parent b4f9b09cb9
commit 3db5226517
14 changed files with 74 additions and 31 deletions

View File

@@ -22,6 +22,8 @@ All (GUI):
- All book based controls (notebook, treebook etc.) share now the same - All book based controls (notebook, treebook etc.) share now the same
options for orientation (wxBK_TOP, wxBK_DEFAULT, ...) instead of duplicated options for orientation (wxBK_TOP, wxBK_DEFAULT, ...) instead of duplicated
wxLB_TOP, wxNB_TOP, wxCHB_TOP, wxTBK_TOP. wxLB_TOP, wxNB_TOP, wxCHB_TOP, wxTBK_TOP.
- Added parent window parameter to wxHelpController constructor
and added SetParentWindow/GetParentWindow.
wxMSW: wxMSW:

View File

@@ -73,10 +73,15 @@ wxHelpControllerBase\\
\membersection{wxHelpController::wxHelpController}\label{wxhelpcontrollerctor} \membersection{wxHelpController::wxHelpController}\label{wxhelpcontrollerctor}
\func{}{wxHelpController}{\void} \func{}{wxHelpController}{\param{wxWindow*}{ parentWindow = NULL}}
Constructs a help instance object, but does not invoke the help viewer. Constructs a help instance object, but does not invoke the help viewer.
If you provide a window, it will be used by some help controller classes, such as
wxCHMHelpController, wxWinHelpController and wxHtmlHelpController, as the
parent for the help window instead of the value of \helpref{wxApp::GetTopWindow}{wxappgettopwindow}. You can also change the parent window later with
\helpref{wxHelpController::SetParentWindow}{wxhelpcontrollersetparentwindow}.
\membersection{wxHelpController::\destruct{wxHelpController}}\label{wxhelpcontrollerdtor} \membersection{wxHelpController::\destruct{wxHelpController}}\label{wxhelpcontrollerdtor}
\func{}{\destruct{wxHelpController}}{\void} \func{}{\destruct{wxHelpController}}{\void}
@@ -184,6 +189,13 @@ and just returns NULL.
\docparam{flags}{This defaults to wxHELP\_NETSCAPE for wxExtHelpController, indicating \docparam{flags}{This defaults to wxHELP\_NETSCAPE for wxExtHelpController, indicating
that the viewer is a variant of Netscape Navigator.} that the viewer is a variant of Netscape Navigator.}
\membersection{wxHelpController::GetParentWindow}\label{wxhelpcontrollergetparentwindow}
\constfunc{virtual bool}{GetParentWindow}{\void}
Returns the window to be used as the parent for the help window. This window is used
by wxCHMHelpController, wxWinHelpController and wxHtmlHelpController.
\membersection{wxHelpController::KeywordSearch}\label{wxhelpcontrollerkeywordsearch} \membersection{wxHelpController::KeywordSearch}\label{wxhelpcontrollerkeywordsearch}
\func{virtual bool}{KeywordSearch}{\param{const wxString\& }{keyWord}, \param{wxHelpSearchMode }{mode = wxHELP\_SEARCH\_ALL}} \func{virtual bool}{KeywordSearch}{\param{const wxString\& }{keyWord}, \param{wxHelpSearchMode }{mode = wxHELP\_SEARCH\_ALL}}
@@ -235,6 +247,13 @@ open. {\it newFrameEachTime} is ignored.
For all other help controllers this function has no effect. For all other help controllers this function has no effect.
\membersection{wxHelpController::SetParentWindow}\label{wxhelpcontrollersetparentwindow}
\func{virtual void}{SetParentWindow}{\param{wxWindow* }{parentWindow}}
Sets the window to be used as the parent for the help window. This is used
by wxCHMHelpController, wxWinHelpController and wxHtmlHelpController.
\membersection{wxHelpController::SetViewer}\label{wxhelpcontrollersetviewer} \membersection{wxHelpController::SetViewer}\label{wxhelpcontrollersetviewer}
\func{virtual void}{SetViewer}{\param{const wxString\& }{viewer}, \param{long}{ flags}} \func{virtual void}{SetViewer}{\param{const wxString\& }{viewer}, \param{long}{ flags}}

View File

@@ -55,7 +55,7 @@ class WXDLLIMPEXP_ADV wxExtHelpController : public wxHelpControllerBase
{ {
DECLARE_CLASS(wxExtHelpController) DECLARE_CLASS(wxExtHelpController)
public: public:
wxExtHelpController(); wxExtHelpController(wxWindow* parentWindow = NULL);
~wxExtHelpController(); ~wxExtHelpController();
/** Tell it which browser to use. /** Tell it which browser to use.

View File

@@ -35,7 +35,7 @@ enum wxHelpSearchMode
class WXDLLEXPORT wxHelpControllerBase: public wxObject class WXDLLEXPORT wxHelpControllerBase: public wxObject
{ {
public: public:
inline wxHelpControllerBase() {} inline wxHelpControllerBase(wxWindow* parentWindow = NULL) { m_parentWindow = parentWindow; }
inline ~wxHelpControllerBase() {} inline ~wxHelpControllerBase() {}
// Must call this to set the filename and server name. // Must call this to set the filename and server name.
@@ -88,6 +88,14 @@ public:
virtual bool Quit() = 0; virtual bool Quit() = 0;
virtual void OnQuit() {} virtual void OnQuit() {}
/// Set the window that can optionally be used for the help window's parent.
virtual void SetParentWindow(wxWindow* win) { m_parentWindow = win; }
/// Get the window that can optionally be used for the help window's parent.
virtual wxWindow* GetParentWindow() const { return m_parentWindow; }
protected:
wxWindow* m_parentWindow;
private: private:
DECLARE_CLASS(wxHelpControllerBase) DECLARE_CLASS(wxHelpControllerBase)
}; };

View File

@@ -26,7 +26,7 @@ class WXDLLIMPEXP_HTML wxHtmlHelpController : public wxHelpControllerBase // wxE
DECLARE_DYNAMIC_CLASS(wxHtmlHelpController) DECLARE_DYNAMIC_CLASS(wxHtmlHelpController)
public: public:
wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE); wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE, wxWindow* parentWindow = NULL);
virtual ~wxHtmlHelpController(); virtual ~wxHtmlHelpController();
void SetTitleFormat(const wxString& format); void SetTitleFormat(const wxString& format);

View File

@@ -20,8 +20,8 @@
class WXDLLIMPEXP_HTML wxBestHelpController: public wxHelpControllerBase class WXDLLIMPEXP_HTML wxBestHelpController: public wxHelpControllerBase
{ {
public: public:
wxBestHelpController() wxBestHelpController(wxWindow* parentWindow = NULL)
: m_helpControllerType( wxUseNone ), : wxHelpControllerBase( parentWindow ), m_helpControllerType( wxUseNone ),
m_helpController( NULL ) m_helpController( NULL )
{ {
} }
@@ -98,6 +98,12 @@ public:
newFrameEachTime ); newFrameEachTime );
} }
/// Set the window that can optionally be used for the help window's parent.
virtual void SetParentWindow(wxWindow* win) { m_helpController->SetParentWindow(win); }
/// Get the window that can optionally be used for the help window's parent.
virtual wxWindow* GetParentWindow() const { return m_helpController->GetParentWindow(); }
protected: protected:
// Append/change extension if necessary. // Append/change extension if necessary.
wxString GetValidFilename(const wxString& file) const; wxString GetValidFilename(const wxString& file) const;

View File

@@ -19,7 +19,7 @@
class WXDLLEXPORT wxCHMHelpController : public wxHelpControllerBase class WXDLLEXPORT wxCHMHelpController : public wxHelpControllerBase
{ {
public: public:
wxCHMHelpController() { } wxCHMHelpController(wxWindow* parentWindow = NULL): wxHelpControllerBase(parentWindow) { }
virtual ~wxCHMHelpController(); virtual ~wxCHMHelpController();
// Must call this to set the filename // Must call this to set the filename

View File

@@ -23,7 +23,7 @@ class WXDLLEXPORT wxWinHelpController: public wxHelpControllerBase
DECLARE_CLASS(wxWinHelpController) DECLARE_CLASS(wxWinHelpController)
public: public:
wxWinHelpController() {} wxWinHelpController(wxWindow* parentWindow = NULL): wxHelpControllerBase(parentWindow) {}
~wxWinHelpController() {} ~wxWinHelpController() {}
// Must call this to set the filename // Must call this to set the filename

View File

@@ -19,7 +19,7 @@
class WXDLLEXPORT wxWinceHelpController : public wxHelpControllerBase class WXDLLEXPORT wxWinceHelpController : public wxHelpControllerBase
{ {
public: public:
wxWinceHelpController() {} wxWinceHelpController(wxWindow* parentWindow): wxHelpControllerBase(parentWindow) {}
virtual ~wxWinceHelpController() {} virtual ~wxWinceHelpController() {}
// Must call this to set the filename // Must call this to set the filename

View File

@@ -70,7 +70,8 @@ IMPLEMENT_CLASS(wxExtHelpController, wxHelpControllerBase)
and a file mapping numerical Section numbers to relative URLS. and a file mapping numerical Section numbers to relative URLS.
*/ */
wxExtHelpController::wxExtHelpController() wxExtHelpController::wxExtHelpController(wxWindow* parentWindow):
wxHelpControllerBase(parentWindow)
{ {
m_MapList = (wxList*) NULL; m_MapList = (wxList*) NULL;
m_NumOfEntries = 0; m_NumOfEntries = 0;

View File

@@ -43,7 +43,8 @@ FORCE_LINK(wxhtml_chm_support)
IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpController, wxHelpControllerBase) IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpController, wxHelpControllerBase)
wxHtmlHelpController::wxHtmlHelpController(int style) wxHtmlHelpController::wxHtmlHelpController(int style, wxWindow* parentWindow):
wxHelpControllerBase(parentWindow)
{ {
m_helpFrame = NULL; m_helpFrame = NULL;
m_Config = NULL; m_Config = NULL;
@@ -144,7 +145,7 @@ void wxHtmlHelpController::CreateHelpWindow()
if (m_Config) if (m_Config)
m_helpFrame->UseConfig(m_Config, m_ConfigRoot); m_helpFrame->UseConfig(m_Config, m_ConfigRoot);
m_helpFrame->Create(NULL, wxID_HTML_HELPFRAME, wxEmptyString, m_FrameStyle); m_helpFrame->Create(GetParentWindow(), wxID_HTML_HELPFRAME, wxEmptyString, m_FrameStyle);
m_helpFrame->SetTitleFormat(m_titleFormat); m_helpFrame->SetTitleFormat(m_titleFormat);
m_helpFrame->Show(true); m_helpFrame->Show(true);

View File

@@ -35,7 +35,7 @@ IMPLEMENT_DYNAMIC_CLASS( wxBestHelpController, wxHelpControllerBase )
bool wxBestHelpController::Initialize( const wxString& filename ) bool wxBestHelpController::Initialize( const wxString& filename )
{ {
// try wxCHMHelpController // try wxCHMHelpController
wxCHMHelpController* chm = new wxCHMHelpController; wxCHMHelpController* chm = new wxCHMHelpController(m_parentWindow);
m_helpControllerType = wxUseChmHelp; m_helpControllerType = wxUseChmHelp;
// do not warn upon failure // do not warn upon failure
@@ -44,6 +44,7 @@ bool wxBestHelpController::Initialize( const wxString& filename )
if( chm->Initialize( GetValidFilename( filename ) ) ) if( chm->Initialize( GetValidFilename( filename ) ) )
{ {
m_helpController = chm; m_helpController = chm;
m_parentWindow = NULL;
return true; return true;
} }
@@ -51,12 +52,13 @@ bool wxBestHelpController::Initialize( const wxString& filename )
delete chm; delete chm;
// try wxHtmlHelpController // try wxHtmlHelpController
wxHtmlHelpController* html = new wxHtmlHelpController; wxHtmlHelpController* html = new wxHtmlHelpController(wxHF_DEFAULT_STYLE, m_parentWindow);
m_helpControllerType = wxUseHtmlHelp; m_helpControllerType = wxUseHtmlHelp;
if( html->Initialize( GetValidFilename( filename ) ) ) if( html->Initialize( GetValidFilename( filename ) ) )
{ {
m_helpController = html; m_helpController = html;
m_parentWindow = NULL;
return true; return true;
} }

View File

@@ -81,9 +81,11 @@ static void UnloadHtmlHelpLibrary()
} }
} }
static HWND GetSuitableHWND() static HWND GetSuitableHWND(wxCHMHelpController* controller)
{ {
if (wxTheApp->GetTopWindow()) if (controller->GetParentWindow())
return (HWND) controller->GetParentWindow()->GetHWND();
else if (wxTheApp->GetTopWindow())
return (HWND) wxTheApp->GetTopWindow()->GetHWND(); return (HWND) wxTheApp->GetTopWindow()->GetHWND();
else else
return GetDesktopWindow(); return GetDesktopWindow();
@@ -114,7 +116,7 @@ bool wxCHMHelpController::DisplayContents()
wxString str = GetValidFilename(m_helpFile); wxString str = GetValidFilename(m_helpFile);
gs_htmlHelp(GetSuitableHWND(), (const wxChar*) str, HH_DISPLAY_TOPIC, 0L); gs_htmlHelp(GetSuitableHWND(this), (const wxChar*) str, HH_DISPLAY_TOPIC, 0L);
return true; return true;
} }
@@ -129,7 +131,7 @@ bool wxCHMHelpController::DisplaySection(const wxString& section)
bool isFilename = (section.Find(wxT(".htm")) != wxNOT_FOUND); bool isFilename = (section.Find(wxT(".htm")) != wxNOT_FOUND);
if (isFilename) if (isFilename)
gs_htmlHelp(GetSuitableHWND(), (const wxChar*) str, HH_DISPLAY_TOPIC, (DWORD) (const wxChar*) section); gs_htmlHelp(GetSuitableHWND(this), (const wxChar*) str, HH_DISPLAY_TOPIC, (DWORD) (const wxChar*) section);
else else
KeywordSearch(section); KeywordSearch(section);
return true; return true;
@@ -142,7 +144,7 @@ bool wxCHMHelpController::DisplaySection(int section)
wxString str = GetValidFilename(m_helpFile); wxString str = GetValidFilename(m_helpFile);
gs_htmlHelp(GetSuitableHWND(), (const wxChar*) str, HH_HELP_CONTEXT, (DWORD)section); gs_htmlHelp(GetSuitableHWND(this), (const wxChar*) str, HH_HELP_CONTEXT, (DWORD)section);
return true; return true;
} }
@@ -167,7 +169,7 @@ bool wxCHMHelpController::DisplayContextPopup(int contextId)
popup.pszFont = NULL; popup.pszFont = NULL;
popup.pszText = NULL; popup.pszText = NULL;
gs_htmlHelp(GetSuitableHWND(), (const wxChar*) str, HH_DISPLAY_TEXT_POPUP, (DWORD) & popup); gs_htmlHelp(GetSuitableHWND(this), (const wxChar*) str, HH_DISPLAY_TEXT_POPUP, (DWORD) & popup);
return true; return true;
} }
@@ -184,7 +186,7 @@ bool wxCHMHelpController::DisplayTextPopup(const wxString& text, const wxPoint&
popup.pszFont = NULL; popup.pszFont = NULL;
popup.pszText = (const wxChar*) text; popup.pszText = (const wxChar*) text;
gs_htmlHelp(GetSuitableHWND(), NULL, HH_DISPLAY_TEXT_POPUP, (DWORD) & popup); gs_htmlHelp(GetSuitableHWND(this), NULL, HH_DISPLAY_TEXT_POPUP, (DWORD) & popup);
return true; return true;
} }
@@ -210,13 +212,13 @@ bool wxCHMHelpController::KeywordSearch(const wxString& k,
link.pszWindow = NULL ; link.pszWindow = NULL ;
link.fIndexOnFail = TRUE ; link.fIndexOnFail = TRUE ;
gs_htmlHelp(GetSuitableHWND(), (const wxChar*) str, HH_KEYWORD_LOOKUP, (DWORD)& link); gs_htmlHelp(GetSuitableHWND(this), (const wxChar*) str, HH_KEYWORD_LOOKUP, (DWORD)& link);
return true; return true;
} }
bool wxCHMHelpController::Quit() bool wxCHMHelpController::Quit()
{ {
gs_htmlHelp(GetSuitableHWND(), 0, HH_CLOSE_ALL, 0L); gs_htmlHelp(GetSuitableHWND(this), 0, HH_CLOSE_ALL, 0L);
return true; return true;
} }

View File

@@ -33,9 +33,11 @@
#include <string.h> #include <string.h>
static HWND GetSuitableHWND() static HWND GetSuitableHWND(wxWinHelpController* controller)
{ {
if (wxTheApp->GetTopWindow()) if (controller->GetParentWindow())
return (HWND) controller->GetParentWindow()->GetHWND();
else if (wxTheApp->GetTopWindow())
return (HWND) wxTheApp->GetTopWindow()->GetHWND(); return (HWND) wxTheApp->GetTopWindow()->GetHWND();
else else
return GetDesktopWindow(); return GetDesktopWindow();
@@ -63,9 +65,9 @@ bool wxWinHelpController::DisplayContents(void)
wxString str = GetValidFilename(m_helpFile); wxString str = GetValidFilename(m_helpFile);
#if defined(__WIN95__) #if defined(__WIN95__)
return (WinHelp(GetSuitableHWND(), (const wxChar*) str, HELP_FINDER, 0L) != 0); return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_FINDER, 0L) != 0);
#else #else
return (WinHelp(GetSuitableHWND(), (const wxChar*) str, HELP_CONTENTS, 0L) != 0); return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_CONTENTS, 0L) != 0);
#endif #endif
} }
@@ -76,7 +78,7 @@ bool wxWinHelpController::DisplaySection(int section)
wxString str = GetValidFilename(m_helpFile); wxString str = GetValidFilename(m_helpFile);
return (WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), (const wxChar*) str, HELP_CONTEXT, (DWORD)section) != 0); return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_CONTEXT, (DWORD)section) != 0);
} }
bool wxWinHelpController::DisplayContextPopup(int contextId) bool wxWinHelpController::DisplayContextPopup(int contextId)
@@ -85,7 +87,7 @@ bool wxWinHelpController::DisplayContextPopup(int contextId)
wxString str = GetValidFilename(m_helpFile); wxString str = GetValidFilename(m_helpFile);
return (WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), (const wxChar*) str, HELP_CONTEXTPOPUP, (DWORD) contextId) != 0); return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_CONTEXTPOPUP, (DWORD) contextId) != 0);
} }
bool wxWinHelpController::DisplayBlock(long block) bool wxWinHelpController::DisplayBlock(long block)
@@ -101,13 +103,13 @@ bool wxWinHelpController::KeywordSearch(const wxString& k,
wxString str = GetValidFilename(m_helpFile); wxString str = GetValidFilename(m_helpFile);
return (WinHelp(GetSuitableHWND(), (const wxChar*) str, HELP_PARTIALKEY, (DWORD)(const wxChar*) k) != 0); return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_PARTIALKEY, (DWORD)(const wxChar*) k) != 0);
} }
// Can't close the help window explicitly in WinHelp // Can't close the help window explicitly in WinHelp
bool wxWinHelpController::Quit(void) bool wxWinHelpController::Quit(void)
{ {
return (WinHelp(GetSuitableHWND(), 0, HELP_QUIT, 0L) != 0); return (WinHelp(GetSuitableHWND(this), 0, HELP_QUIT, 0L) != 0);
} }
// Append extension if necessary. // Append extension if necessary.