]>
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 | */ | |
90f011dc | 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 | /** | |
317dfa4b VZ |
200 | Set the parameters of the frame window. |
201 | ||
eae48ea1 VZ |
202 | For wxHtmlHelpController, @a titleFormat specifies the title string |
203 | format (with @c %s being replaced by the actual page title) and @a size | |
204 | and @a position specify the geometry of the frame. | |
9cc56d1f | 205 | |
23324ae1 | 206 | For all other help controllers this function has no effect. |
317dfa4b VZ |
207 | |
208 | Finally, @a newFrameEachTime is always ignored currently. | |
23324ae1 | 209 | */ |
eae48ea1 | 210 | virtual void SetFrameParameters(const wxString& titleFormat, |
4cc4bfaf FM |
211 | const wxSize& size, |
212 | const wxPoint& pos = wxDefaultPosition, | |
213 | bool newFrameEachTime = false); | |
23324ae1 FM |
214 | |
215 | /** | |
216 | Sets the window to be used as the parent for the help window. This is used | |
217 | by wxCHMHelpController, wxWinHelpController and wxHtmlHelpController. | |
218 | */ | |
219 | virtual void SetParentWindow(wxWindow* parentWindow); | |
220 | ||
221 | /** | |
9cc56d1f FM |
222 | Sets detailed viewer information. |
223 | So far this is only relevant to wxExtHelpController. | |
23324ae1 | 224 | Some examples of usage: |
9cc56d1f FM |
225 | |
226 | @code | |
227 | m_help.SetViewer("kdehelp"); | |
228 | m_help.SetViewer("gnome-help-browser"); | |
229 | m_help.SetViewer("netscape", wxHELP_NETSCAPE); | |
230 | @endcode | |
231 | ||
232 | @param viewer | |
233 | This defaults to "netscape" for wxExtHelpController. | |
234 | @param flags | |
235 | This defaults to wxHELP_NETSCAPE for wxExtHelpController, indicating | |
236 | that the viewer is a variant of Netscape Navigator. | |
237 | ||
238 | @todo modernize this function with ::wxLaunchDefaultBrowser | |
23324ae1 | 239 | */ |
3f89cb60 RD |
240 | virtual void SetViewer(const wxString& viewer, long flags=wxHELP_NETSCAPE); |
241 | }; | |
242 | ||
243 | ||
244 | ||
245 | ||
246 | ||
247 | ||
248 | /** | |
249 | @class wxHelpController | |
250 | ||
251 | This is an alias for one of a family of help controller classes which is | |
252 | most appropriate for the current platform. | |
253 | ||
254 | A help controller allows an application to display help, at the contents | |
255 | or at a particular topic, and shut the help program down on termination. | |
256 | This avoids proliferation of many instances of the help viewer whenever the | |
257 | user requests a different topic via the application's menus or buttons. | |
258 | ||
259 | Typically, an application will create a help controller instance when it starts, | |
260 | and immediately call wxHelpController::Initialize to associate a filename with it. | |
261 | The help viewer will only get run, however, just before the first call to | |
262 | display something. | |
263 | ||
264 | Most help controller classes actually derive from wxHelpControllerBase and have | |
265 | names of the form wxXXXHelpController or wxHelpControllerXXX. | |
266 | An appropriate class is aliased to the name wxHelpController for each platform, as | |
267 | follows: | |
268 | - On desktop Windows, wxCHMHelpController is used (MS HTML Help). | |
269 | - On Windows CE, wxWinceHelpController is used. | |
270 | - On all other platforms, wxHtmlHelpController is used if wxHTML is compiled | |
271 | into wxWidgets; otherwise wxExtHelpController is used (for invoking an | |
272 | external browser). | |
273 | ||
274 | The remaining help controller classes need to be named explicitly by an | |
275 | application that wishes to make use of them. | |
276 | ||
277 | The following help controller classes are defined: | |
278 | - wxWinHelpController, for controlling Windows Help. | |
279 | - wxCHMHelpController, for controlling MS HTML Help. To use this, you need to | |
280 | set wxUSE_MS_HTML_HELP to 1 in setup.h and have the htmlhelp.h header from | |
281 | Microsoft's HTML Help kit. (You don't need the VC++-specific htmlhelp.lib | |
282 | because wxWidgets loads necessary DLL at runtime and so it works with all | |
283 | compilers.) | |
284 | - wxBestHelpController, for controlling MS HTML Help or, if Microsoft's runtime | |
285 | is not available, wxHtmlHelpController. You need to provide @b both CHM and | |
286 | HTB versions of the help file. For wxMSW only. | |
287 | - wxExtHelpController, for controlling external browsers under Unix. | |
288 | The default browser is Netscape Navigator. The 'help' sample shows its use. | |
289 | - wxWinceHelpController, for controlling a simple @c .htm help controller for | |
290 | Windows CE applications. | |
291 | - wxHtmlHelpController, a sophisticated help controller using wxHTML, in a | |
292 | similar style to the Microsoft HTML Help viewer and using some of the same | |
293 | files. Although it has an API compatible with other help controllers, it has | |
294 | more advanced features, so it is recommended that you use the specific API | |
295 | for this class instead. Note that if you use .zip or .htb formats for your | |
296 | books, you must add this line to your application initialization: | |
297 | @code wxFileSystem::AddHandler(new wxArchiveFSHandler); @endcode | |
298 | or nothing will be shown in your help window. | |
299 | ||
691a6211 | 300 | @library{wxcore} |
3f89cb60 RD |
301 | @category{help} |
302 | ||
303 | @see wxHtmlHelpController, @ref overview_html | |
304 | */ | |
305 | class wxHelpController : public wxHelpControllerBase | |
306 | { | |
307 | public: | |
308 | /** | |
309 | Constructs a help instance object, but does not invoke the help viewer. | |
310 | ||
311 | If you provide a window, it will be used by some help controller classes, such as | |
312 | wxCHMHelpController, wxWinHelpController and wxHtmlHelpController, as the | |
313 | parent for the help window instead of the value of wxApp::GetTopWindow. | |
314 | ||
315 | You can also change the parent window later with SetParentWindow(). | |
316 | */ | |
317 | wxHelpController(wxWindow* parentWindow = NULL); | |
23324ae1 | 318 | }; |
e54c96f1 | 319 | |
3f89cb60 | 320 |