]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/help.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxHelpController
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 #define wxHELP_NETSCAPE 1
14 Help search modes for wxHelpController::KeywordSearch().
18 wxHELP_SEARCH_INDEX
, ///< Search the index only.
19 wxHELP_SEARCH_ALL
///< Search all entries.
23 @class wxHelpControllerBase
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.
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.
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
41 @see wxHelpController, wxHtmlHelpController, @ref overview_html
43 class wxHelpControllerBase
: public wxObject
47 Constructs a help instance object, but does not invoke the help viewer.
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.
53 You can also change the parent window later with SetParentWindow().
55 wxHelpControllerBase(wxWindow
* parentWindow
= NULL
);
58 Destroys the help instance, closing down the viewer if it is running.
60 ~wxHelpControllerBase();
63 If the help viewer is not running, runs it and displays the file at the given
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.
73 This function is for backward compatibility only, and applications
74 should use DisplaySection() instead.
76 virtual bool DisplayBlock(long blockNo
) = 0;
79 If the help viewer is not running, runs it and displays the contents.
81 virtual bool DisplayContents() = 0;
84 Displays the section as a popup window using a context id.
85 Returns @false if unsuccessful or not implemented.
87 virtual bool DisplayContextPopup(int contextId
);
90 If the help viewer is not running, runs it and displays the given section.
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.
98 virtual bool DisplaySection(const wxString
& section
);
101 If the help viewer is not running, runs it and displays the given section.
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.
111 virtual bool DisplaySection(int sectionNo
) = 0;;
114 Displays the text in a popup window, if possible.
116 Returns @false if unsuccessful or not implemented.
118 virtual bool DisplayTextPopup(const wxString
& text
,
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.
127 The most recent frame size.
129 The most recent frame position.
130 @param newFrameEachTime
131 @true if a new frame is drawn with each invocation.
133 virtual wxFrame
* GetFrameParameters(wxSize
* size
= NULL
,
135 bool* newFrameEachTime
= NULL
);
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.
142 virtual wxWindow
* GetParentWindow() const;
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.
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.
155 virtual bool Initialize(const wxString
& file
);
156 virtual bool Initialize(const wxString
& file
, int server
);
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.
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.
171 virtual bool KeywordSearch(const wxString
& keyWord
,
172 wxHelpSearchMode mode
= wxHELP_SEARCH_ALL
) = 0;
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.
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.
183 wxHtmlHelpController ignores this call.
185 virtual bool LoadFile(const wxString
& file
= wxEmptyString
) = 0;
188 Overridable member called when this application's viewer is quit by the user.
189 This does not work for all help controllers.
191 virtual void OnQuit();
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.
197 virtual bool Quit() = 0;
200 Set the parameters of the frame window.
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.
206 For all other help controllers this function has no effect.
208 Finally, @a newFrameEachTime is always ignored currently.
210 virtual void SetFrameParameters(const wxString
& titleFormat
,
212 const wxPoint
& pos
= wxDefaultPosition
,
213 bool newFrameEachTime
= false);
216 Sets the window to be used as the parent for the help window. This is used
217 by wxCHMHelpController, wxWinHelpController and wxHtmlHelpController.
219 virtual void SetParentWindow(wxWindow
* parentWindow
);
222 Sets detailed viewer information.
223 So far this is only relevant to wxExtHelpController.
224 Some examples of usage:
227 m_help.SetViewer("kdehelp");
228 m_help.SetViewer("gnome-help-browser");
229 m_help.SetViewer("netscape", wxHELP_NETSCAPE);
233 This defaults to "netscape" for wxExtHelpController.
235 This defaults to wxHELP_NETSCAPE for wxExtHelpController, indicating
236 that the viewer is a variant of Netscape Navigator.
238 @todo modernize this function with ::wxLaunchDefaultBrowser
240 virtual void SetViewer(const wxString
& viewer
, long flags
=wxHELP_NETSCAPE
);
249 @class wxHelpController
251 This is an alias for one of a family of help controller classes which is
252 most appropriate for the current platform.
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.
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
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
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
274 The remaining help controller classes need to be named explicitly by an
275 application that wishes to make use of them.
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
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.
303 @see wxHtmlHelpController, @ref overview_html
305 class wxHelpController
: public wxHelpControllerBase
309 Constructs a help instance object, but does not invoke the help viewer.
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.
315 You can also change the parent window later with SetParentWindow().
317 wxHelpController(wxWindow
* parentWindow
= NULL
);