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