helpctrl.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/html/helpctrl.h
  3. // Purpose: wxHtmlHelpController
  4. // Notes: Based on htmlhelp.cpp, implementing a monolithic
  5. // HTML Help controller class, by Vaclav Slavik
  6. // Author: Harm van der Heijden and Vaclav Slavik
  7. // Copyright: (c) Harm van der Heijden and Vaclav Slavik
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_HELPCTRL_H_
  11. #define _WX_HELPCTRL_H_
  12. #include "wx/defs.h"
  13. #if wxUSE_WXHTML_HELP
  14. #include "wx/helpbase.h"
  15. #include "wx/html/helpfrm.h"
  16. #define wxID_HTML_HELPFRAME (wxID_HIGHEST + 1)
  17. // This style indicates that the window is
  18. // embedded in the application and must not be
  19. // destroyed by the help controller.
  20. #define wxHF_EMBEDDED 0x00008000
  21. // Create a dialog for the help window.
  22. #define wxHF_DIALOG 0x00010000
  23. // Create a frame for the help window.
  24. #define wxHF_FRAME 0x00020000
  25. // Make the dialog modal when displaying help.
  26. #define wxHF_MODAL 0x00040000
  27. class WXDLLIMPEXP_FWD_HTML wxHtmlHelpDialog;
  28. class WXDLLIMPEXP_FWD_HTML wxHtmlHelpWindow;
  29. class WXDLLIMPEXP_FWD_HTML wxHtmlHelpFrame;
  30. class WXDLLIMPEXP_FWD_HTML wxHtmlHelpDialog;
  31. class WXDLLIMPEXP_HTML wxHtmlHelpController : public wxHelpControllerBase // wxEvtHandler
  32. {
  33. DECLARE_DYNAMIC_CLASS(wxHtmlHelpController)
  34. public:
  35. wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE, wxWindow* parentWindow = NULL);
  36. wxHtmlHelpController(wxWindow* parentWindow, int style = wxHF_DEFAULT_STYLE);
  37. virtual ~wxHtmlHelpController();
  38. void SetShouldPreventAppExit(bool enable);
  39. void SetTitleFormat(const wxString& format);
  40. void SetTempDir(const wxString& path) { m_helpData.SetTempDir(path); }
  41. bool AddBook(const wxString& book_url, bool show_wait_msg = false);
  42. bool AddBook(const wxFileName& book_file, bool show_wait_msg = false);
  43. bool Display(const wxString& x);
  44. bool Display(int id);
  45. bool DisplayContents();
  46. bool DisplayIndex();
  47. bool KeywordSearch(const wxString& keyword,
  48. wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
  49. wxHtmlHelpWindow* GetHelpWindow() { return m_helpWindow; }
  50. void SetHelpWindow(wxHtmlHelpWindow* helpWindow);
  51. wxHtmlHelpFrame* GetFrame() { return m_helpFrame; }
  52. wxHtmlHelpDialog* GetDialog() { return m_helpDialog; }
  53. #if wxUSE_CONFIG
  54. void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
  55. // Assigns config object to the Ctrl. This config is then
  56. // used in subsequent calls to Read/WriteCustomization of both help
  57. // Ctrl and it's wxHtmlWindow
  58. virtual void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
  59. virtual void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
  60. #endif // wxUSE_CONFIG
  61. //// Backward compatibility with wxHelpController API
  62. virtual bool Initialize(const wxString& file, int WXUNUSED(server) ) { return Initialize(file); }
  63. virtual bool Initialize(const wxString& file);
  64. virtual void SetViewer(const wxString& WXUNUSED(viewer), long WXUNUSED(flags) = 0) {}
  65. virtual bool LoadFile(const wxString& file = wxT(""));
  66. virtual bool DisplaySection(int sectionNo);
  67. virtual bool DisplaySection(const wxString& section) { return Display(section); }
  68. virtual bool DisplayBlock(long blockNo) { return DisplaySection(blockNo); }
  69. virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos);
  70. virtual void SetFrameParameters(const wxString& titleFormat,
  71. const wxSize& size,
  72. const wxPoint& pos = wxDefaultPosition,
  73. bool newFrameEachTime = false);
  74. /// Obtains the latest settings used by the help frame and the help
  75. /// frame.
  76. virtual wxFrame *GetFrameParameters(wxSize *size = NULL,
  77. wxPoint *pos = NULL,
  78. bool *newFrameEachTime = NULL);
  79. // Get direct access to help data:
  80. wxHtmlHelpData *GetHelpData() { return &m_helpData; }
  81. virtual bool Quit() ;
  82. virtual void OnQuit() {}
  83. void OnCloseFrame(wxCloseEvent& evt);
  84. // Make the help controller's frame 'modal' if
  85. // needed
  86. void MakeModalIfNeeded();
  87. // Find the top-most parent window
  88. wxWindow* FindTopLevelWindow();
  89. protected:
  90. void Init(int style);
  91. virtual wxWindow* CreateHelpWindow();
  92. virtual wxHtmlHelpFrame* CreateHelpFrame(wxHtmlHelpData *data);
  93. virtual wxHtmlHelpDialog* CreateHelpDialog(wxHtmlHelpData *data);
  94. virtual void DestroyHelpWindow();
  95. wxHtmlHelpData m_helpData;
  96. wxHtmlHelpWindow* m_helpWindow;
  97. #if wxUSE_CONFIG
  98. wxConfigBase * m_Config;
  99. wxString m_ConfigRoot;
  100. #endif // wxUSE_CONFIG
  101. wxString m_titleFormat;
  102. int m_FrameStyle;
  103. wxHtmlHelpFrame* m_helpFrame;
  104. wxHtmlHelpDialog* m_helpDialog;
  105. bool m_shouldPreventAppExit;
  106. wxDECLARE_NO_COPY_CLASS(wxHtmlHelpController);
  107. };
  108. /*
  109. * wxHtmlModalHelp
  110. * A convenience class particularly for use on wxMac,
  111. * where you can only show modal dialogs from a modal
  112. * dialog.
  113. *
  114. * Use like this:
  115. *
  116. * wxHtmlModalHelp help(parent, filename, topic);
  117. *
  118. * If topic is empty, the help contents is displayed.
  119. */
  120. class WXDLLIMPEXP_HTML wxHtmlModalHelp
  121. {
  122. public:
  123. wxHtmlModalHelp(wxWindow* parent, const wxString& helpFile, const wxString& topic = wxEmptyString,
  124. int style = wxHF_DEFAULT_STYLE | wxHF_DIALOG | wxHF_MODAL);
  125. };
  126. #endif // wxUSE_WXHTML_HELP
  127. #endif // _WX_HELPCTRL_H_