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