helpchm.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/helpchm.h
  3. // Purpose: Help system: MS HTML Help implementation
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 16/04/2000
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_MSW_HELPCHM_H_
  11. #define _WX_MSW_HELPCHM_H_
  12. #if wxUSE_MS_HTML_HELP
  13. #include "wx/helpbase.h"
  14. class WXDLLIMPEXP_CORE wxCHMHelpController : public wxHelpControllerBase
  15. {
  16. public:
  17. wxCHMHelpController(wxWindow* parentWindow = NULL): wxHelpControllerBase(parentWindow) { }
  18. // Must call this to set the filename
  19. virtual bool Initialize(const wxString& file);
  20. virtual bool Initialize(const wxString& file, int WXUNUSED(server) ) { return Initialize( file ); }
  21. // If file is "", reloads file given in Initialize
  22. virtual bool LoadFile(const wxString& file = wxEmptyString);
  23. virtual bool DisplayContents();
  24. virtual bool DisplaySection(int sectionNo);
  25. virtual bool DisplaySection(const wxString& section);
  26. virtual bool DisplayBlock(long blockNo);
  27. virtual bool DisplayContextPopup(int contextId);
  28. virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos);
  29. virtual bool KeywordSearch(const wxString& k,
  30. wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
  31. virtual bool Quit();
  32. wxString GetHelpFile() const { return m_helpFile; }
  33. // helper of DisplayTextPopup(), also used in wxSimpleHelpProvider::ShowHelp
  34. static bool ShowContextHelpPopup(const wxString& text,
  35. const wxPoint& pos,
  36. wxWindow *window);
  37. protected:
  38. // get the name of the CHM file we use from our m_helpFile
  39. wxString GetValidFilename() const;
  40. // Call HtmlHelp() with the provided parameters (both overloads do the same
  41. // thing but allow to avoid casts in the calling code) and return false
  42. // (but don't crash) if HTML help is unavailable
  43. static bool CallHtmlHelp(wxWindow *win, const wxChar *str,
  44. unsigned cmd, WXWPARAM param);
  45. static bool CallHtmlHelp(wxWindow *win, const wxChar *str,
  46. unsigned cmd, const void *param = NULL)
  47. {
  48. return CallHtmlHelp(win, str, cmd, reinterpret_cast<WXWPARAM>(param));
  49. }
  50. // even simpler wrappers using GetParentWindow() and GetValidFilename() as
  51. // the first 2 HtmlHelp() parameters
  52. bool CallHtmlHelp(unsigned cmd, WXWPARAM param)
  53. {
  54. return CallHtmlHelp(GetParentWindow(), GetValidFilename().t_str(),
  55. cmd, param);
  56. }
  57. bool CallHtmlHelp(unsigned cmd, const void *param = NULL)
  58. {
  59. return CallHtmlHelp(cmd, reinterpret_cast<WXWPARAM>(param));
  60. }
  61. // wrapper around CallHtmlHelp(HH_DISPLAY_TEXT_POPUP): only one of text and
  62. // contextId parameters can be non-NULL/non-zero
  63. static bool DoDisplayTextPopup(const wxChar *text,
  64. const wxPoint& pos,
  65. int contextId,
  66. wxWindow *window);
  67. wxString m_helpFile;
  68. DECLARE_DYNAMIC_CLASS(wxCHMHelpController)
  69. };
  70. #endif // wxUSE_MS_HTML_HELP
  71. #endif // _WX_MSW_HELPCHM_H_