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