helpbest.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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
  5. // Modified by:
  6. // Created: 02/04/2001
  7. // Copyright: (c) Mattia Barbon
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_HELPBEST_H_
  11. #define _WX_HELPBEST_H_
  12. #if wxUSE_HELP && wxUSE_MS_HTML_HELP \
  13. && wxUSE_WXHTML_HELP && !defined(__WXUNIVERSAL__)
  14. #include "wx/helpbase.h"
  15. #include "wx/html/helpfrm.h" // for wxHF_DEFAULT_STYLE
  16. class WXDLLIMPEXP_HTML wxBestHelpController: public wxHelpControllerBase
  17. {
  18. public:
  19. wxBestHelpController(wxWindow* parentWindow = NULL,
  20. int style = wxHF_DEFAULT_STYLE)
  21. : wxHelpControllerBase(parentWindow),
  22. m_helpControllerType(wxUseNone),
  23. m_helpController(NULL),
  24. m_style(style)
  25. {
  26. }
  27. virtual ~wxBestHelpController() { delete m_helpController; }
  28. // Must call this to set the filename
  29. virtual bool Initialize(const wxString& file);
  30. virtual bool Initialize(const wxString& file, int WXUNUSED(server) ) { return Initialize( file ); }
  31. // If file is "", reloads file given in Initialize
  32. virtual bool LoadFile(const wxString& file = wxEmptyString)
  33. {
  34. return m_helpController->LoadFile( GetValidFilename( file ) );
  35. }
  36. virtual bool DisplayContents()
  37. {
  38. return m_helpController->DisplayContents();
  39. }
  40. virtual bool DisplaySection(int sectionNo)
  41. {
  42. return m_helpController->DisplaySection( sectionNo );
  43. }
  44. virtual bool DisplaySection(const wxString& section)
  45. {
  46. return m_helpController->DisplaySection( section );
  47. }
  48. virtual bool DisplayBlock(long blockNo)
  49. {
  50. return m_helpController->DisplayBlock( blockNo );
  51. }
  52. virtual bool DisplayContextPopup(int contextId)
  53. {
  54. return m_helpController->DisplayContextPopup( contextId );
  55. }
  56. virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos)
  57. {
  58. return m_helpController->DisplayTextPopup( text, pos );
  59. }
  60. virtual bool KeywordSearch(const wxString& k,
  61. wxHelpSearchMode mode = wxHELP_SEARCH_ALL)
  62. {
  63. return m_helpController->KeywordSearch( k, mode );
  64. }
  65. virtual bool Quit()
  66. {
  67. return m_helpController->Quit();
  68. }
  69. // Allows one to override the default settings for the help frame.
  70. virtual void SetFrameParameters(const wxString& title,
  71. const wxSize& size,
  72. const wxPoint& pos = wxDefaultPosition,
  73. bool newFrameEachTime = false)
  74. {
  75. m_helpController->SetFrameParameters( title, size, pos,
  76. newFrameEachTime );
  77. }
  78. // Obtains the latest settings used by the help frame and the help frame.
  79. virtual wxFrame *GetFrameParameters(wxSize *size = NULL,
  80. wxPoint *pos = NULL,
  81. bool *newFrameEachTime = NULL)
  82. {
  83. return m_helpController->GetFrameParameters( size, pos,
  84. newFrameEachTime );
  85. }
  86. /// Set the window that can optionally be used for the help window's parent.
  87. virtual void SetParentWindow(wxWindow* win) { m_helpController->SetParentWindow(win); }
  88. /// Get the window that can optionally be used for the help window's parent.
  89. virtual wxWindow* GetParentWindow() const { return m_helpController->GetParentWindow(); }
  90. protected:
  91. // Append/change extension if necessary.
  92. wxString GetValidFilename(const wxString& file) const;
  93. protected:
  94. enum HelpControllerType { wxUseNone, wxUseHtmlHelp, wxUseChmHelp };
  95. HelpControllerType m_helpControllerType;
  96. wxHelpControllerBase* m_helpController;
  97. int m_style;
  98. DECLARE_DYNAMIC_CLASS(wxBestHelpController)
  99. wxDECLARE_NO_COPY_CLASS(wxBestHelpController);
  100. };
  101. #endif // wxUSE_HELP && wxUSE_MS_HTML_HELP && wxUSE_WXHTML_HELP
  102. #endif
  103. // _WX_HELPBEST_H_