]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: help.h | |
e54c96f1 | 3 | // Purpose: interface of wxHelpController |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxHelpController | |
7c913512 | 11 | |
9cc56d1f FM |
12 | This is a family of classes by which applications may invoke a help viewer |
13 | to provide on-line help. | |
7c913512 | 14 | |
23324ae1 FM |
15 | A help controller allows an application to display help, at the contents |
16 | or at a particular topic, and shut the help program down on termination. | |
17 | This avoids proliferation of many instances of the help viewer whenever the | |
18 | user requests a different topic via the application's menus or buttons. | |
7c913512 | 19 | |
9cc56d1f FM |
20 | Typically, an application will create a help controller instance when it starts, |
21 | and immediately call wxHelpController::Initialize to associate a filename with it. | |
22 | The help viewer will only get run, however, just before the first call to | |
23 | display something. | |
7c913512 | 24 | |
23324ae1 | 25 | Most help controller classes actually derive from wxHelpControllerBase and have |
9cc56d1f FM |
26 | names of the form wxXXXHelpController or wxHelpControllerXXX. |
27 | An appropriate class is aliased to the name wxHelpController for each platform, as | |
23324ae1 | 28 | follows: |
9cc56d1f FM |
29 | - On desktop Windows, wxCHMHelpController is used (MS HTML Help). |
30 | - On Windows CE, wxWinceHelpController is used. | |
31 | - On all other platforms, wxHtmlHelpController is used if wxHTML is compiled | |
32 | into wxWidgets; otherwise wxExtHelpController is used (for invoking an | |
33 | external browser). | |
7c913512 | 34 | |
9cc56d1f FM |
35 | The remaining help controller classes need to be named explicitly by an |
36 | application that wishes to make use of them. | |
7c913512 | 37 | |
23324ae1 | 38 | There are currently the following help controller classes defined: |
9cc56d1f FM |
39 | - wxWinHelpController, for controlling Windows Help. |
40 | - wxCHMHelpController, for controlling MS HTML Help. To use this, you need to | |
41 | set wxUSE_MS_HTML_HELP to 1 in setup.h and have htmlhelp.h header from | |
42 | Microsoft's HTML Help kit (you don't need VC++ specific htmlhelp.lib | |
43 | because wxWidgets loads necessary DLL at runtime and so it works with all | |
44 | compilers). | |
45 | - wxBestHelpController, for controlling MS HTML Help or, if Microsoft's runtime | |
46 | is not available, wxHtmlHelpController. You need to provide @b both CHM and | |
47 | HTB versions of the help file. For 32bit Windows only. | |
48 | - wxExtHelpController, for controlling external browsers under Unix. | |
49 | The default browser is Netscape Navigator. The 'help' sample shows its use. | |
50 | - wxWinceHelpController, for controlling a simple @c .htm help controller for | |
51 | Windows CE applications. | |
52 | - wxHtmlHelpController, a sophisticated help controller using wxHTML(), in a | |
53 | similar style to the Microsoft HTML Help viewer and using some of the same | |
54 | files. Although it has an API compatible with other help controllers, it has | |
55 | more advanced features, so it is recommended that you use the specific API | |
56 | for this class instead. Note that if you use .zip or .htb formats for your | |
57 | books, you must add this line to your application initialization: | |
58 | @code wxFileSystem::AddHandler(new wxArchiveFSHandler); @endcode | |
59 | or nothing will be shown in your help window. | |
7c913512 | 60 | |
23324ae1 FM |
61 | @library{wxbase} |
62 | @category{help} | |
7c913512 | 63 | |
9cc56d1f | 64 | @see wxHtmlHelpController, @ref overview_html |
23324ae1 | 65 | */ |
9cc56d1f | 66 | class wxHelpController : public wxHelpControllerBase |
23324ae1 FM |
67 | { |
68 | public: | |
69 | /** | |
70 | Constructs a help instance object, but does not invoke the help viewer. | |
9cc56d1f FM |
71 | |
72 | If you provide a window, it will be used by some help controller classes, such as | |
23324ae1 | 73 | wxCHMHelpController, wxWinHelpController and wxHtmlHelpController, as the |
9cc56d1f FM |
74 | parent for the help window instead of the value of wxApp::GetTopWindow. |
75 | ||
76 | You can also change the parent window later with SetParentWindow(). | |
23324ae1 | 77 | */ |
4cc4bfaf | 78 | wxHelpController(wxWindow* parentWindow = NULL); |
23324ae1 FM |
79 | |
80 | /** | |
81 | Destroys the help instance, closing down the viewer if it is running. | |
82 | */ | |
83 | ~wxHelpController(); | |
84 | ||
85 | /** | |
86 | If the help viewer is not running, runs it and displays the file at the given | |
87 | block number. | |
9cc56d1f FM |
88 | |
89 | - @e WinHelp: Refers to the context number. | |
90 | - @e MS HTML Help: Refers to the context number. | |
91 | - @e External HTML help: the same as for DisplaySection(). | |
92 | - @e wxHtmlHelpController: @e sectionNo is an identifier as specified in | |
93 | the @c .hhc file. See @ref overview_html_helpformats. | |
94 | ||
95 | @deprecated | |
96 | This function is for backward compatibility only, and applications | |
97 | should use DisplaySection() instead. | |
23324ae1 FM |
98 | */ |
99 | virtual bool DisplayBlock(long blockNo); | |
100 | ||
101 | /** | |
9cc56d1f | 102 | If the help viewer is not running, runs it and displays the contents. |
23324ae1 FM |
103 | */ |
104 | virtual bool DisplayContents(); | |
105 | ||
106 | /** | |
107 | Displays the section as a popup window using a context id. | |
23324ae1 FM |
108 | Returns @false if unsuccessful or not implemented. |
109 | */ | |
110 | virtual bool DisplayContextPopup(int contextId); | |
111 | ||
23324ae1 FM |
112 | /** |
113 | If the help viewer is not running, runs it and displays the given section. | |
3c4f71cc | 114 | |
9cc56d1f FM |
115 | The interpretation of section differs between help viewers. |
116 | For most viewers, this call is equivalent to KeywordSearch. | |
117 | For MS HTML Help, wxHTML help and external HTML help, if section has a | |
118 | .htm or .html extension, that HTML file will be displayed; otherwise a | |
119 | keyword search is done. | |
23324ae1 FM |
120 | */ |
121 | virtual bool DisplaySection(const wxString& section); | |
9cc56d1f FM |
122 | |
123 | /** | |
124 | If the help viewer is not running, runs it and displays the given section. | |
125 | ||
126 | - @e WinHelp, MS HTML Help @a sectionNo is a context id. | |
127 | - @e External HTML help: wxExtHelpController implements @a sectionNo as | |
128 | an id in a map file, which is of the form: | |
129 | - @e wxHtmlHelpController: @a sectionNo is an identifier as specified in | |
130 | the @c .hhc file. See @ref overview_html_helpformats. | |
131 | See also the help sample for notes on how to specify section numbers for | |
132 | various help file formats. | |
133 | */ | |
7c913512 | 134 | virtual bool DisplaySection(int sectionNo); |
23324ae1 FM |
135 | |
136 | /** | |
137 | Displays the text in a popup window, if possible. | |
9cc56d1f | 138 | |
23324ae1 FM |
139 | Returns @false if unsuccessful or not implemented. |
140 | */ | |
141 | virtual bool DisplayTextPopup(const wxString& text, | |
142 | const wxPoint& pos); | |
143 | ||
144 | /** | |
145 | wxHtmlHelpController returns the frame, size and position. | |
9cc56d1f FM |
146 | For all other help controllers, this function does nothing and just |
147 | returns @NULL. | |
23324ae1 | 148 | */ |
4cc4bfaf FM |
149 | virtual wxFrame* GetFrameParameters(const wxSize* size = NULL, |
150 | const wxPoint* pos = NULL, | |
151 | bool* newFrameEachTime = NULL); | |
23324ae1 FM |
152 | |
153 | /** | |
9cc56d1f FM |
154 | Returns the window to be used as the parent for the help window. |
155 | This window is used by wxCHMHelpController, wxWinHelpController and | |
156 | wxHtmlHelpController. | |
23324ae1 | 157 | */ |
328f5751 | 158 | virtual wxWindow* GetParentWindow() const; |
23324ae1 FM |
159 | |
160 | //@{ | |
161 | /** | |
162 | Initializes the help instance with a help filename, and optionally a server | |
9cc56d1f | 163 | socket number if using wxHelp (now obsolete). Does not invoke the help viewer. |
23324ae1 | 164 | This must be called directly after the help instance object is created and |
9cc56d1f FM |
165 | before any attempts to communicate with the viewer. |
166 | ||
167 | You may omit the file extension and a suitable one will be chosen. | |
168 | For wxHtmlHelpController, the extensions zip, htb and hhp will be appended | |
169 | while searching for a suitable file. For WinHelp, the hlp extension is appended. | |
23324ae1 FM |
170 | */ |
171 | virtual bool Initialize(const wxString& file); | |
7c913512 | 172 | virtual bool Initialize(const wxString& file, int server); |
23324ae1 FM |
173 | //@} |
174 | ||
175 | /** | |
176 | If the help viewer is not running, runs it, and searches for sections matching | |
9cc56d1f FM |
177 | the given keyword. If one match is found, the file is displayed at this section. |
178 | The optional parameter allows the search the index (wxHELP_SEARCH_INDEX) | |
179 | but this currently only supported by the wxHtmlHelpController. | |
180 | ||
181 | - @e WinHelp, MS HTML Help: | |
182 | If more than one match is found, the first topic is displayed. | |
183 | - @e External HTML help, simple wxHTML help: | |
184 | If more than one match is found, a choice of topics is displayed. | |
185 | - @e wxHtmlHelpController: see wxHtmlHelpController::KeywordSearch. | |
23324ae1 FM |
186 | */ |
187 | virtual bool KeywordSearch(const wxString& keyWord, | |
188 | wxHelpSearchMode mode = wxHELP_SEARCH_ALL); | |
189 | ||
190 | /** | |
191 | If the help viewer is not running, runs it and loads the given file. | |
9cc56d1f FM |
192 | If the filename is not supplied or is empty, the file specified in |
193 | Initialize() is used. | |
194 | ||
195 | If the viewer is already displaying the specified file, it will not be | |
196 | reloaded. This member function may be used before each display call in | |
197 | case the user has opened another file. | |
198 | ||
23324ae1 FM |
199 | wxHtmlHelpController ignores this call. |
200 | */ | |
201 | virtual bool LoadFile(const wxString& file = ""); | |
202 | ||
203 | /** | |
204 | Overridable member called when this application's viewer is quit by the user. | |
23324ae1 FM |
205 | This does not work for all help controllers. |
206 | */ | |
207 | virtual bool OnQuit(); | |
208 | ||
209 | /** | |
210 | If the viewer is running, quits it by disconnecting. | |
9cc56d1f | 211 | For Windows Help, the viewer will only close if no other application is using it. |
23324ae1 FM |
212 | */ |
213 | virtual bool Quit(); | |
214 | ||
215 | /** | |
216 | For wxHtmlHelpController, the title is set (again with %s indicating the | |
9cc56d1f FM |
217 | page title) and also the size and position of the frame if the frame is |
218 | already open. @a newFrameEachTime is ignored. | |
219 | ||
23324ae1 FM |
220 | For all other help controllers this function has no effect. |
221 | */ | |
4cc4bfaf FM |
222 | virtual void SetFrameParameters(const wxString& title, |
223 | const wxSize& size, | |
224 | const wxPoint& pos = wxDefaultPosition, | |
225 | bool newFrameEachTime = false); | |
23324ae1 FM |
226 | |
227 | /** | |
228 | Sets the window to be used as the parent for the help window. This is used | |
229 | by wxCHMHelpController, wxWinHelpController and wxHtmlHelpController. | |
230 | */ | |
231 | virtual void SetParentWindow(wxWindow* parentWindow); | |
232 | ||
233 | /** | |
9cc56d1f FM |
234 | Sets detailed viewer information. |
235 | So far this is only relevant to wxExtHelpController. | |
23324ae1 | 236 | Some examples of usage: |
9cc56d1f FM |
237 | |
238 | @code | |
239 | m_help.SetViewer("kdehelp"); | |
240 | m_help.SetViewer("gnome-help-browser"); | |
241 | m_help.SetViewer("netscape", wxHELP_NETSCAPE); | |
242 | @endcode | |
243 | ||
244 | @param viewer | |
245 | This defaults to "netscape" for wxExtHelpController. | |
246 | @param flags | |
247 | This defaults to wxHELP_NETSCAPE for wxExtHelpController, indicating | |
248 | that the viewer is a variant of Netscape Navigator. | |
249 | ||
250 | @todo modernize this function with ::wxLaunchDefaultBrowser | |
23324ae1 FM |
251 | */ |
252 | virtual void SetViewer(const wxString& viewer, long flags); | |
253 | }; | |
e54c96f1 | 254 |