1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/helpbest.h
3 // Purpose: Tries to load MS HTML Help, falls back to wxHTML upon failure
4 // Author: Mattia Barbon
8 // Copyright: (c) Mattia Barbon
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_HELPBEST_H_
13 #define _WX_HELPBEST_H_
15 #if wxUSE_HELP && wxUSE_MS_HTML_HELP \
16 && wxUSE_WXHTML_HELP && !defined(__WXUNIVERSAL__)
18 #include "wx/helpbase.h"
19 #include "wx/html/helpfrm.h" // for wxHF_DEFAULT_STYLE
21 class WXDLLIMPEXP_HTML wxBestHelpController
: public wxHelpControllerBase
24 wxBestHelpController(wxWindow
* parentWindow
= NULL
,
25 int style
= wxHF_DEFAULT_STYLE
)
26 : wxHelpControllerBase(parentWindow
),
27 m_helpControllerType(wxUseNone
),
28 m_helpController(NULL
),
33 virtual ~wxBestHelpController() { delete m_helpController
; }
35 // Must call this to set the filename
36 virtual bool Initialize(const wxString
& file
);
37 virtual bool Initialize(const wxString
& file
, int WXUNUSED(server
) ) { return Initialize( file
); }
39 // If file is "", reloads file given in Initialize
40 virtual bool LoadFile(const wxString
& file
= wxEmptyString
)
42 return m_helpController
->LoadFile( GetValidFilename( file
) );
45 virtual bool DisplayContents()
47 return m_helpController
->DisplayContents();
50 virtual bool DisplaySection(int sectionNo
)
52 return m_helpController
->DisplaySection( sectionNo
);
55 virtual bool DisplaySection(const wxString
& section
)
57 return m_helpController
->DisplaySection( section
);
60 virtual bool DisplayBlock(long blockNo
)
62 return m_helpController
->DisplayBlock( blockNo
);
65 virtual bool DisplayContextPopup(int contextId
)
67 return m_helpController
->DisplayContextPopup( contextId
);
70 virtual bool DisplayTextPopup(const wxString
& text
, const wxPoint
& pos
)
72 return m_helpController
->DisplayTextPopup( text
, pos
);
75 virtual bool KeywordSearch(const wxString
& k
,
76 wxHelpSearchMode mode
= wxHELP_SEARCH_ALL
)
78 return m_helpController
->KeywordSearch( k
, mode
);
83 return m_helpController
->Quit();
86 // Allows one to override the default settings for the help frame.
87 virtual void SetFrameParameters(const wxString
& title
,
89 const wxPoint
& pos
= wxDefaultPosition
,
90 bool newFrameEachTime
= false)
92 m_helpController
->SetFrameParameters( title
, size
, pos
,
96 // Obtains the latest settings used by the help frame and the help frame.
97 virtual wxFrame
*GetFrameParameters(wxSize
*size
= NULL
,
99 bool *newFrameEachTime
= NULL
)
101 return m_helpController
->GetFrameParameters( size
, pos
,
105 /// Set the window that can optionally be used for the help window's parent.
106 virtual void SetParentWindow(wxWindow
* win
) { m_helpController
->SetParentWindow(win
); }
108 /// Get the window that can optionally be used for the help window's parent.
109 virtual wxWindow
* GetParentWindow() const { return m_helpController
->GetParentWindow(); }
112 // Append/change extension if necessary.
113 wxString
GetValidFilename(const wxString
& file
) const;
116 enum HelpControllerType
{ wxUseNone
, wxUseHtmlHelp
, wxUseChmHelp
};
118 HelpControllerType m_helpControllerType
;
119 wxHelpControllerBase
* m_helpController
;
122 DECLARE_DYNAMIC_CLASS(wxBestHelpController
)
123 wxDECLARE_NO_COPY_CLASS(wxBestHelpController
);
126 #endif // wxUSE_HELP && wxUSE_MS_HTML_HELP && wxUSE_WXHTML_HELP