]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/help.h
Fix wrong return value in the changes of r73365.
[wxWidgets.git] / interface / wx / help.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: help.h
3 // Purpose: interface of wxHelpController
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9
10 #define wxHELP_NETSCAPE 1
11
12
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
22 /**
23 @class wxHelpControllerBase
24
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.
27
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.
32
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.
37
38 @library{wxcore}
39 @category{help}
40
41 @see wxHelpController, wxHtmlHelpController, @ref overview_html
42 */
43 class wxHelpControllerBase : public wxObject
44 {
45 public:
46 /**
47 Constructs a help instance object, but does not invoke the help viewer.
48
49 If you provide a window, it will be used by some help controller classes, such as
50 wxCHMHelpController, wxWinHelpController and wxHtmlHelpController, as the
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().
54 */
55 wxHelpControllerBase(wxWindow* parentWindow = NULL);
56
57 /**
58 Destroys the help instance, closing down the viewer if it is running.
59 */
60 ~wxHelpControllerBase();
61
62 /**
63 If the help viewer is not running, runs it and displays the file at the given
64 block number.
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.
75 */
76 virtual bool DisplayBlock(long blockNo) = 0;
77
78 /**
79 If the help viewer is not running, runs it and displays the contents.
80 */
81 virtual bool DisplayContents() = 0;
82
83 /**
84 Displays the section as a popup window using a context id.
85 Returns @false if unsuccessful or not implemented.
86 */
87 virtual bool DisplayContextPopup(int contextId);
88
89 /**
90 If the help viewer is not running, runs it and displays the given section.
91
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.
97 */
98 virtual bool DisplaySection(const wxString& section);
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 */
111 virtual bool DisplaySection(int sectionNo) = 0;
112
113 /**
114 Displays the text in a popup window, if possible.
115
116 Returns @false if unsuccessful or not implemented.
117 */
118 virtual bool DisplayTextPopup(const wxString& text,
119 const wxPoint& pos);
120
121 /**
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.
132 */
133 virtual wxFrame* GetFrameParameters(wxSize* size = NULL,
134 wxPoint* pos = NULL,
135 bool* newFrameEachTime = NULL);
136
137 /**
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.
141 */
142 virtual wxWindow* GetParentWindow() const;
143
144 //@{
145 /**
146 Initializes the help instance with a help filename, and optionally a server
147 socket number if using wxHelp (now obsolete). Does not invoke the help viewer.
148 This must be called directly after the help instance object is created and
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.
154 */
155 virtual bool Initialize(const wxString& file);
156 virtual bool Initialize(const wxString& file, int server);
157 //@}
158
159 /**
160 If the help viewer is not running, runs it, and searches for sections matching
161 the given keyword. If one match is found, the file is displayed at this section.
162 The optional parameter allows to search the index (wxHELP_SEARCH_INDEX)
163 but this currently is only supported by the wxHtmlHelpController.
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.
170 */
171 virtual bool KeywordSearch(const wxString& keyWord,
172 wxHelpSearchMode mode = wxHELP_SEARCH_ALL) = 0;
173
174 /**
175 If the help viewer is not running, runs it and loads the given file.
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
183 wxHtmlHelpController ignores this call.
184 */
185 virtual bool LoadFile(const wxString& file = wxEmptyString) = 0;
186
187 /**
188 Overridable member called when this application's viewer is quit by the user.
189 This does not work for all help controllers.
190 */
191 virtual void OnQuit();
192
193 /**
194 If the viewer is running, quits it by disconnecting.
195 For Windows Help, the viewer will only close if no other application is using it.
196 */
197 virtual bool Quit() = 0;
198
199 /**
200 Set the parameters of the frame window.
201
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.
205
206 For all other help controllers this function has no effect.
207
208 Finally, @a newFrameEachTime is always ignored currently.
209 */
210 virtual void SetFrameParameters(const wxString& titleFormat,
211 const wxSize& size,
212 const wxPoint& pos = wxDefaultPosition,
213 bool newFrameEachTime = false);
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 /**
222 Sets detailed viewer information.
223 So far this is only relevant to wxExtHelpController.
224 Some examples of usage:
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
239 */
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
300 @library{wxcore}
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);
318 };
319
320