]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/help.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxHelpController
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxHelpController
12 This is a family of classes by which
13 applications may invoke a help viewer to provide on-line help.
15 A help controller allows an application to display help, at the contents
16 or at a particular topic, and shut the help program down on termination.
17 This avoids proliferation of many instances of the help viewer whenever the
18 user requests a different topic via the application's menus or buttons.
20 Typically, an application will create a help controller instance
21 when it starts, and immediately call @b Initialize
22 to associate a filename with it. The help viewer will only get run, however,
23 just before the first call to display something.
25 Most help controller classes actually derive from wxHelpControllerBase and have
26 names of the form wxXXXHelpController or wxHelpControllerXXX. An
27 appropriate class is aliased to the name wxHelpController for each platform, as
30 On desktop Windows, wxCHMHelpController is used (MS HTML Help).
31 On Windows CE, wxWinceHelpController is used.
32 On all other platforms, wxHtmlHelpController is used if wxHTML is
33 compiled into wxWidgets; otherwise wxExtHelpController is used (for invoking an
37 The remaining help controller classes need to be named
38 explicitly by an application that wishes to make use of them.
40 There are currently the following help controller classes defined:
42 wxWinHelpController, for controlling Windows Help.
43 wxCHMHelpController, for controlling MS HTML Help. To use this, you need to
44 set wxUSE_MS_HTML_HELP
45 to 1 in setup.h and have htmlhelp.h header from Microsoft's HTML Help kit (you
47 VC++ specific htmlhelp.lib because wxWidgets loads necessary DLL at runtime and
49 works with all compilers).
50 wxBestHelpController, for controlling MS HTML Help or, if Microsoft's runtime
52 not available, wxHtmlHelpController. You need to provide
53 @b both CHM and HTB versions of the help file. For 32bit Windows only.
54 wxExtHelpController, for controlling external browsers under Unix.
55 The default browser is Netscape Navigator. The 'help' sample shows its use.
56 wxWinceHelpController, for controlling a simple @c .htm help controller for
57 Windows CE applications.
58 wxHtmlHelpController, a sophisticated help controller using wxHTML(), in
59 a similar style to the Microsoft HTML Help viewer and using some of the same
61 Although it has an API compatible with other help controllers, it has more
62 advanced features, so it is
63 recommended that you use the specific API for this class instead. Note that if
65 use .zip or .htb formats for your books, you
66 must add this line to your application initialization: @c
67 wxFileSystem::AddHandler(new wxArchiveFSHandler);
68 or nothing will be shown in your help window.
74 @see wxHtmlHelpController, wxHTML()
76 class wxHelpController
: public wxObject
80 Constructs a help instance object, but does not invoke the help viewer.
81 If you provide a window, it will be used by some help controller classes, such
83 wxCHMHelpController, wxWinHelpController and wxHtmlHelpController, as the
84 parent for the help window instead of the value of wxApp::GetTopWindow. You can
85 also change the parent window later with
88 wxHelpController(wxWindow
* parentWindow
= NULL
);
91 Destroys the help instance, closing down the viewer if it is running.
96 If the help viewer is not running, runs it and displays the file at the given
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 the @c
102 .hhc file. See @ref overview_helpformat "Help files format".
103 This function is for backward compatibility only, and applications should use
104 @ref displaysection() wxHelpController instead.
106 virtual bool DisplayBlock(long blockNo
);
109 If the help viewer is not running, runs it and displays the
112 virtual bool DisplayContents();
115 Displays the section as a popup window using a context id.
116 Returns @false if unsuccessful or not implemented.
118 virtual bool DisplayContextPopup(int contextId
);
122 If the help viewer is not running, runs it and displays the given section.
123 @e WinHelp, MS HTML Help @a sectionNo is a context id.
124 @e External HTML help: wxExtHelpController implements @a sectionNo as an id in
125 a map file, which is of the form:
127 @e wxHtmlHelpController: @a sectionNo is an identifier as specified in the @c
128 .hhc file. See @ref overview_helpformat "Help files format".
129 See also the help sample for notes on how to specify section numbers for
130 various help file formats.
132 virtual bool DisplaySection(const wxString
& section
);
133 virtual bool DisplaySection(int sectionNo
);
137 Displays the text in a popup window, if possible.
138 Returns @false if unsuccessful or not implemented.
140 virtual bool DisplayTextPopup(const wxString
& text
,
144 wxHtmlHelpController returns the frame, size and position.
145 For all other help controllers, this function does nothing
146 and just returns @NULL.
149 This defaults to "netscape" for wxExtHelpController.
151 This defaults to wxHELP_NETSCAPE for wxExtHelpController, indicating
152 that the viewer is a variant of Netscape Navigator.
154 virtual wxFrame
* GetFrameParameters(const wxSize
* size
= NULL
,
155 const wxPoint
* pos
= NULL
,
156 bool* newFrameEachTime
= NULL
);
159 Returns the window to be used as the parent for the help window. This window is
161 by wxCHMHelpController, wxWinHelpController and wxHtmlHelpController.
163 virtual wxWindow
* GetParentWindow() const;
167 Initializes the help instance with a help filename, and optionally a server
169 number if using wxHelp (now obsolete). Does not invoke the help viewer.
170 This must be called directly after the help instance object is created and
172 any attempts to communicate with the viewer.
173 You may omit the file extension and a suitable one will be chosen. For
174 wxHtmlHelpController, the extensions zip, htb and hhp will be appended while
176 a suitable file. For WinHelp, the hlp extension is appended.
178 virtual bool Initialize(const wxString
& file
);
179 virtual bool Initialize(const wxString
& file
, int server
);
183 If the help viewer is not running, runs it, and searches for sections matching
184 the given keyword. If one match is found, the file is displayed at this
185 section. The optional parameter allows the search the index
186 (wxHELP_SEARCH_INDEX) but this currently only supported by the
187 wxHtmlHelpController.
188 @e WinHelp, MS HTML Help: If more than one match is found,
189 the first topic is displayed.
190 @e External HTML help, simple wxHTML help: If more than one match is found,
191 a choice of topics is displayed.
192 @e wxHtmlHelpController: see wxHtmlHelpController::KeywordSearch.
194 virtual bool KeywordSearch(const wxString
& keyWord
,
195 wxHelpSearchMode mode
= wxHELP_SEARCH_ALL
);
198 If the help viewer is not running, runs it and loads the given file.
199 If the filename is not supplied or is
200 empty, the file specified in @b Initialize is used. If the viewer is
201 already displaying the specified file, it will not be reloaded. This
202 member function may be used before each display call in case the user
203 has opened another file.
204 wxHtmlHelpController ignores this call.
206 virtual bool LoadFile(const wxString
& file
= "");
209 Overridable member called when this application's viewer is quit by the user.
210 This does not work for all help controllers.
212 virtual bool OnQuit();
215 If the viewer is running, quits it by disconnecting.
216 For Windows Help, the viewer will only close if no other application is using
222 For wxHtmlHelpController, the title is set (again with %s indicating the
223 page title) and also the size and position of the frame if the frame is already
224 open. @a newFrameEachTime is ignored.
225 For all other help controllers this function has no effect.
227 virtual void SetFrameParameters(const wxString
& title
,
229 const wxPoint
& pos
= wxDefaultPosition
,
230 bool newFrameEachTime
= false);
233 Sets the window to be used as the parent for the help window. This is used
234 by wxCHMHelpController, wxWinHelpController and wxHtmlHelpController.
236 virtual void SetParentWindow(wxWindow
* parentWindow
);
239 Sets detailed viewer information. So far this is only relevant to
241 Some examples of usage:
243 virtual void SetViewer(const wxString
& viewer
, long flags
);