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