]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/help.h
Document wxBK_HITTEST_XXX values.
[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 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
18 /**
19 @class wxHelpController
20
21 This is a family of classes by which applications may invoke a help viewer
22 to provide on-line help.
23
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.
28
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.
33
34 Most help controller classes actually derive from wxHelpControllerBase and have
35 names of the form wxXXXHelpController or wxHelpControllerXXX.
36 An appropriate class is aliased to the name wxHelpController for each platform, as
37 follows:
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).
43
44 The remaining help controller classes need to be named explicitly by an
45 application that wishes to make use of them.
46
47 The following help controller classes are defined:
48 - wxWinHelpController, for controlling Windows Help.
49 - wxCHMHelpController, for controlling MS HTML Help. To use this, you need to
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
52 because wxWidgets loads necessary DLL at runtime and so it works with all
53 compilers.)
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
56 HTB versions of the help file. For wxMSW only.
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.
61 - wxHtmlHelpController, a sophisticated help controller using wxHTML, in a
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.
69
70 @library{wxbase}
71 @category{help}
72
73 @see wxHtmlHelpController, @ref overview_html
74 */
75 class wxHelpController : public wxHelpControllerBase
76 {
77 public:
78 /**
79 Constructs a help instance object, but does not invoke the help viewer.
80
81 If you provide a window, it will be used by some help controller classes, such as
82 wxCHMHelpController, wxWinHelpController and wxHtmlHelpController, as the
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().
86 */
87 wxHelpController(wxWindow* parentWindow = NULL);
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.
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.
107 */
108 virtual bool DisplayBlock(long blockNo);
109
110 /**
111 If the help viewer is not running, runs it and displays the contents.
112 */
113 virtual bool DisplayContents();
114
115 /**
116 Displays the section as a popup window using a context id.
117 Returns @false if unsuccessful or not implemented.
118 */
119 virtual bool DisplayContextPopup(int contextId);
120
121 /**
122 If the help viewer is not running, runs it and displays the given section.
123
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.
129 */
130 virtual bool DisplaySection(const wxString& section);
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 */
143 virtual bool DisplaySection(int sectionNo);
144
145 /**
146 Displays the text in a popup window, if possible.
147
148 Returns @false if unsuccessful or not implemented.
149 */
150 virtual bool DisplayTextPopup(const wxString& text,
151 const wxPoint& pos);
152
153 /**
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.
164 */
165 virtual wxFrame* GetFrameParameters(wxSize* size = NULL,
166 wxPoint* pos = NULL,
167 bool* newFrameEachTime = NULL);
168
169 /**
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.
173 */
174 virtual wxWindow* GetParentWindow() const;
175
176 //@{
177 /**
178 Initializes the help instance with a help filename, and optionally a server
179 socket number if using wxHelp (now obsolete). Does not invoke the help viewer.
180 This must be called directly after the help instance object is created and
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.
186 */
187 virtual bool Initialize(const wxString& file);
188 virtual bool Initialize(const wxString& file, int server);
189 //@}
190
191 /**
192 If the help viewer is not running, runs it, and searches for sections matching
193 the given keyword. If one match is found, the file is displayed at this section.
194 The optional parameter allows to search the index (wxHELP_SEARCH_INDEX)
195 but this currently is only supported by the wxHtmlHelpController.
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.
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.
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
215 wxHtmlHelpController ignores this call.
216 */
217 virtual bool LoadFile(const wxString& file = wxEmptyString);
218
219 /**
220 Overridable member called when this application's viewer is quit by the user.
221 This does not work for all help controllers.
222 */
223 virtual void OnQuit();
224
225 /**
226 If the viewer is running, quits it by disconnecting.
227 For Windows Help, the viewer will only close if no other application is using it.
228 */
229 virtual bool Quit();
230
231 /**
232 For wxHtmlHelpController, the title is set (with %s indicating the
233 page title) and also the size and position of the frame if the frame is
234 already open. @a newFrameEachTime is ignored.
235
236 For all other help controllers this function has no effect.
237 */
238 virtual void SetFrameParameters(const wxString& title,
239 const wxSize& size,
240 const wxPoint& pos = wxDefaultPosition,
241 bool newFrameEachTime = false);
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 /**
250 Sets detailed viewer information.
251 So far this is only relevant to wxExtHelpController.
252 Some examples of usage:
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
267 */
268 virtual void SetViewer(const wxString& viewer, long flags);
269 };
270