| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: helpbest.h |
| 3 | // Purpose: Tries to load MS HTML Help, falls back to wxHTML upon failure |
| 4 | // Author: Mattia Barbon |
| 5 | // Modified by: |
| 6 | // Created: 02/04/2001 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) Mattia Barbon |
| 9 | // Licence: wxWindows licence |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | #ifndef _WX_HELPBEST_H_ |
| 13 | #define _WX_HELPBEST_H_ |
| 14 | |
| 15 | #if wxUSE_HELP && wxUSE_MS_HTML_HELP && defined(__WIN95__) \ |
| 16 | && wxUSE_WXHTML_HELP && !defined(__WXUNIVERSAL__) |
| 17 | |
| 18 | #include "wx/helpbase.h" |
| 19 | |
| 20 | class WXDLLIMPEXP_HTML wxBestHelpController: public wxHelpControllerBase |
| 21 | { |
| 22 | public: |
| 23 | wxBestHelpController() |
| 24 | : m_helpControllerType( wxUseNone ), |
| 25 | m_helpController( NULL ) |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | virtual ~wxBestHelpController() { delete m_helpController; } |
| 30 | |
| 31 | // Must call this to set the filename |
| 32 | virtual bool Initialize(const wxString& file); |
| 33 | virtual bool Initialize(const wxString& file, int WXUNUSED(server) ) { return Initialize( file ); } |
| 34 | |
| 35 | // If file is "", reloads file given in Initialize |
| 36 | virtual bool LoadFile(const wxString& file = wxEmptyString) |
| 37 | { |
| 38 | return m_helpController->LoadFile( GetValidFilename( file ) ); |
| 39 | } |
| 40 | |
| 41 | virtual bool DisplayContents() |
| 42 | { |
| 43 | return m_helpController->DisplayContents(); |
| 44 | } |
| 45 | |
| 46 | virtual bool DisplaySection(int sectionNo) |
| 47 | { |
| 48 | return m_helpController->DisplaySection( sectionNo ); |
| 49 | } |
| 50 | |
| 51 | virtual bool DisplaySection(const wxString& section) |
| 52 | { |
| 53 | return m_helpController->DisplaySection( section ); |
| 54 | } |
| 55 | |
| 56 | virtual bool DisplayBlock(long blockNo) |
| 57 | { |
| 58 | return m_helpController->DisplayBlock( blockNo ); |
| 59 | } |
| 60 | |
| 61 | virtual bool DisplayContextPopup(int contextId) |
| 62 | { |
| 63 | return m_helpController->DisplayContextPopup( contextId ); |
| 64 | } |
| 65 | |
| 66 | virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos) |
| 67 | { |
| 68 | return m_helpController->DisplayTextPopup( text, pos ); |
| 69 | } |
| 70 | |
| 71 | virtual bool KeywordSearch(const wxString& k, |
| 72 | wxHelpSearchMode mode = wxHELP_SEARCH_ALL) |
| 73 | { |
| 74 | return m_helpController->KeywordSearch( k, mode ); |
| 75 | } |
| 76 | |
| 77 | virtual bool Quit() |
| 78 | { |
| 79 | return m_helpController->Quit(); |
| 80 | } |
| 81 | |
| 82 | // Allows one to override the default settings for the help frame. |
| 83 | virtual void SetFrameParameters(const wxString& title, |
| 84 | const wxSize& size, |
| 85 | const wxPoint& pos = wxDefaultPosition, |
| 86 | bool newFrameEachTime = false) |
| 87 | { |
| 88 | m_helpController->SetFrameParameters( title, size, pos, |
| 89 | newFrameEachTime ); |
| 90 | } |
| 91 | |
| 92 | // Obtains the latest settings used by the help frame and the help frame. |
| 93 | virtual wxFrame *GetFrameParameters(wxSize *size = NULL, |
| 94 | wxPoint *pos = NULL, |
| 95 | bool *newFrameEachTime = NULL) |
| 96 | { |
| 97 | return m_helpController->GetFrameParameters( size, pos, |
| 98 | newFrameEachTime ); |
| 99 | } |
| 100 | |
| 101 | protected: |
| 102 | // Append/change extension if necessary. |
| 103 | wxString GetValidFilename(const wxString& file) const; |
| 104 | |
| 105 | protected: |
| 106 | enum HelpControllerType { wxUseNone, wxUseHtmlHelp, wxUseChmHelp }; |
| 107 | |
| 108 | HelpControllerType m_helpControllerType; |
| 109 | wxHelpControllerBase* m_helpController; |
| 110 | |
| 111 | DECLARE_DYNAMIC_CLASS(wxBestHelpController) |
| 112 | DECLARE_NO_COPY_CLASS(wxBestHelpController) |
| 113 | }; |
| 114 | |
| 115 | #endif // wxUSE_HELP && wxUSE_MS_HTML_HELP && defined(__WIN95__) && wxUSE_WXHTML_HELP |
| 116 | |
| 117 | #endif |
| 118 | // _WX_HELPBEST_H_ |