helpfrm.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/html/helpfrm.h
  3. // Purpose: wxHtmlHelpFrame
  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_HELPFRM_H_
  11. #define _WX_HELPFRM_H_
  12. #include "wx/defs.h"
  13. #if wxUSE_WXHTML_HELP
  14. #include "wx/helpbase.h"
  15. #include "wx/html/helpdata.h"
  16. #include "wx/window.h"
  17. #include "wx/frame.h"
  18. #include "wx/config.h"
  19. #include "wx/splitter.h"
  20. #include "wx/notebook.h"
  21. #include "wx/listbox.h"
  22. #include "wx/choice.h"
  23. #include "wx/combobox.h"
  24. #include "wx/checkbox.h"
  25. #include "wx/stattext.h"
  26. #include "wx/html/htmlwin.h"
  27. #include "wx/html/helpwnd.h"
  28. #include "wx/html/htmprint.h"
  29. class WXDLLIMPEXP_FWD_CORE wxButton;
  30. class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
  31. class WXDLLIMPEXP_FWD_CORE wxTreeEvent;
  32. class WXDLLIMPEXP_FWD_CORE wxTreeCtrl;
  33. // style flags for the Help Frame
  34. #define wxHF_TOOLBAR 0x0001
  35. #define wxHF_CONTENTS 0x0002
  36. #define wxHF_INDEX 0x0004
  37. #define wxHF_SEARCH 0x0008
  38. #define wxHF_BOOKMARKS 0x0010
  39. #define wxHF_OPEN_FILES 0x0020
  40. #define wxHF_PRINT 0x0040
  41. #define wxHF_FLAT_TOOLBAR 0x0080
  42. #define wxHF_MERGE_BOOKS 0x0100
  43. #define wxHF_ICONS_BOOK 0x0200
  44. #define wxHF_ICONS_BOOK_CHAPTER 0x0400
  45. #define wxHF_ICONS_FOLDER 0x0000 // this is 0 since it is default
  46. #define wxHF_DEFAULT_STYLE (wxHF_TOOLBAR | wxHF_CONTENTS | \
  47. wxHF_INDEX | wxHF_SEARCH | \
  48. wxHF_BOOKMARKS | wxHF_PRINT)
  49. //compatibility:
  50. #define wxHF_OPENFILES wxHF_OPEN_FILES
  51. #define wxHF_FLATTOOLBAR wxHF_FLAT_TOOLBAR
  52. #define wxHF_DEFAULTSTYLE wxHF_DEFAULT_STYLE
  53. struct wxHtmlHelpMergedIndexItem;
  54. class wxHtmlHelpMergedIndex;
  55. class WXDLLIMPEXP_FWD_CORE wxHelpControllerBase;
  56. class WXDLLIMPEXP_FWD_HTML wxHtmlHelpController;
  57. class WXDLLIMPEXP_FWD_HTML wxHtmlHelpWindow;
  58. class WXDLLIMPEXP_HTML wxHtmlHelpFrame : public wxFrame
  59. {
  60. DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame)
  61. public:
  62. wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); }
  63. wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID,
  64. const wxString& title = wxEmptyString,
  65. int style = wxHF_DEFAULT_STYLE, wxHtmlHelpData* data = NULL
  66. #if wxUSE_CONFIG
  67. , wxConfigBase *config=NULL, const wxString& rootpath = wxEmptyString
  68. #endif // wxUSE_CONFIG
  69. );
  70. bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString,
  71. int style = wxHF_DEFAULT_STYLE
  72. #if wxUSE_CONFIG
  73. , wxConfigBase *config=NULL, const wxString& rootpath = wxEmptyString
  74. #endif // wxUSE_CONFIG
  75. );
  76. virtual ~wxHtmlHelpFrame();
  77. /// Returns the data associated with the window.
  78. wxHtmlHelpData* GetData() { return m_Data; }
  79. /// Returns the help controller associated with the window.
  80. wxHtmlHelpController* GetController() const { return m_helpController; }
  81. /// Sets the help controller associated with the window.
  82. void SetController(wxHtmlHelpController* controller);
  83. /// Returns the help window.
  84. wxHtmlHelpWindow* GetHelpWindow() const { return m_HtmlHelpWin; }
  85. // Sets format of title of the frame. Must contain exactly one "%s"
  86. // (for title of displayed HTML page)
  87. void SetTitleFormat(const wxString& format);
  88. #if wxUSE_CONFIG
  89. // For compatibility
  90. void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
  91. #endif // wxUSE_CONFIG
  92. // Make the help controller's frame 'modal' if
  93. // needed
  94. void AddGrabIfNeeded();
  95. // Override to add custom buttons to the toolbar
  96. virtual void AddToolbarButtons(wxToolBar* WXUNUSED(toolBar), int WXUNUSED(style)) {}
  97. void SetShouldPreventAppExit(bool enable);
  98. // we don't want to prevent the app from closing just because a help window
  99. // remains opened
  100. virtual bool ShouldPreventAppExit() const { return m_shouldPreventAppExit; }
  101. protected:
  102. void Init(wxHtmlHelpData* data = NULL);
  103. void OnCloseWindow(wxCloseEvent& event);
  104. void OnActivate(wxActivateEvent& event);
  105. #ifdef __WXMAC__
  106. void OnClose(wxCommandEvent& event);
  107. void OnAbout(wxCommandEvent& event);
  108. #endif
  109. // Images:
  110. enum {
  111. IMG_Book = 0,
  112. IMG_Folder,
  113. IMG_Page
  114. };
  115. protected:
  116. wxHtmlHelpData* m_Data;
  117. bool m_DataCreated; // m_Data created by frame, or supplied?
  118. wxString m_TitleFormat; // title of the help frame
  119. wxHtmlHelpWindow *m_HtmlHelpWin;
  120. wxHtmlHelpController* m_helpController;
  121. bool m_shouldPreventAppExit;
  122. private:
  123. DECLARE_EVENT_TABLE()
  124. wxDECLARE_NO_COPY_CLASS(wxHtmlHelpFrame);
  125. };
  126. #endif // wxUSE_WXHTML_HELP
  127. #endif