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