]>
Commit | Line | Data |
---|---|---|
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 | @class wxHelpController | |
11 | ||
12 | This is a family of classes by which applications may invoke a help viewer | |
13 | to provide on-line help. | |
14 | ||
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. | |
19 | ||
20 | Typically, an application will create a help controller instance when it starts, | |
21 | and immediately call wxHelpController::Initialize to associate a filename with it. | |
22 | The help viewer will only get run, however, just before the first call to | |
23 | display something. | |
24 | ||
25 | Most help controller classes actually derive from wxHelpControllerBase and have | |
26 | names of the form wxXXXHelpController or wxHelpControllerXXX. | |
27 | An appropriate class is aliased to the name wxHelpController for each platform, as | |
28 | follows: | |
29 | - On desktop Windows, wxCHMHelpController is used (MS HTML Help). | |
30 | - On Windows CE, wxWinceHelpController is used. | |
31 | - On all other platforms, wxHtmlHelpController is used if wxHTML is compiled | |
32 | into wxWidgets; otherwise wxExtHelpController is used (for invoking an | |
33 | external browser). | |
34 | ||
35 | The remaining help controller classes need to be named explicitly by an | |
36 | application that wishes to make use of them. | |
37 | ||
38 | The following help controller classes are defined: | |
39 | - wxWinHelpController, for controlling Windows Help. | |
40 | - wxCHMHelpController, for controlling MS HTML Help. To use this, you need to | |
41 | set wxUSE_MS_HTML_HELP to 1 in setup.h and have the htmlhelp.h header from | |
42 | Microsoft's HTML Help kit. (You don't need the VC++-specific htmlhelp.lib | |
43 | because wxWidgets loads necessary DLL at runtime and so it works with all | |
44 | compilers.) | |
45 | - wxBestHelpController, for controlling MS HTML Help or, if Microsoft's runtime | |
46 | is not available, wxHtmlHelpController. You need to provide @b both CHM and | |
47 | HTB versions of the help file. For wxMSW only. | |
48 | - wxExtHelpController, for controlling external browsers under Unix. | |
49 | The default browser is Netscape Navigator. The 'help' sample shows its use. | |
50 | - wxWinceHelpController, for controlling a simple @c .htm help controller for | |
51 | Windows CE applications. | |
52 | - wxHtmlHelpController, a sophisticated help controller using wxHTML, in a | |
53 | similar style to the Microsoft HTML Help viewer and using some of the same | |
54 | files. Although it has an API compatible with other help controllers, it has | |
55 | more advanced features, so it is recommended that you use the specific API | |
56 | for this class instead. Note that if you use .zip or .htb formats for your | |
57 | books, you must add this line to your application initialization: | |
58 | @code wxFileSystem::AddHandler(new wxArchiveFSHandler); @endcode | |
59 | or nothing will be shown in your help window. | |
60 | ||
61 | @library{wxbase} | |
62 | @category{help} | |
63 | ||
64 | @see wxHtmlHelpController, @ref overview_html | |
65 | */ | |
66 | class wxHelpController : public wxHelpControllerBase | |
67 | { | |
68 | public: | |
69 | /** | |
70 | Constructs a help instance object, but does not invoke the help viewer. | |
71 | ||
72 | If you provide a window, it will be used by some help controller classes, such as | |
73 | wxCHMHelpController, wxWinHelpController and wxHtmlHelpController, as the | |
74 | parent for the help window instead of the value of wxApp::GetTopWindow. | |
75 | ||
76 | You can also change the parent window later with SetParentWindow(). | |
77 | */ | |
78 | wxHelpController(wxWindow* parentWindow = NULL); | |
79 | ||
80 | /** | |
81 | Destroys the help instance, closing down the viewer if it is running. | |
82 | */ | |
83 | ~wxHelpController(); | |
84 | ||
85 | /** | |
86 | If the help viewer is not running, runs it and displays the file at the given | |
87 | block number. | |
88 | ||
89 | - @e WinHelp: Refers to the context number. | |
90 | - @e MS HTML Help: Refers to the context number. | |
91 | - @e External HTML help: the same as for DisplaySection(). | |
92 | - @e wxHtmlHelpController: @e sectionNo is an identifier as specified in | |
93 | the @c .hhc file. See @ref overview_html_helpformats. | |
94 | ||
95 | @deprecated | |
96 | This function is for backward compatibility only, and applications | |
97 | should use DisplaySection() instead. | |
98 | */ | |
99 | virtual bool DisplayBlock(long blockNo); | |
100 | ||
101 | /** | |
102 | If the help viewer is not running, runs it and displays the contents. | |
103 | */ | |
104 | virtual bool DisplayContents(); | |
105 | ||
106 | /** | |
107 | Displays the section as a popup window using a context id. | |
108 | Returns @false if unsuccessful or not implemented. | |
109 | */ | |
110 | virtual bool DisplayContextPopup(int contextId); | |
111 | ||
112 | /** | |
113 | If the help viewer is not running, runs it and displays the given section. | |
114 | ||
115 | The interpretation of section differs between help viewers. | |
116 | For most viewers, this call is equivalent to KeywordSearch. | |
117 | For MS HTML Help, wxHTML help and external HTML help, if section has a | |
118 | .htm or .html extension, that HTML file will be displayed; otherwise a | |
119 | keyword search is done. | |
120 | */ | |
121 | virtual bool DisplaySection(const wxString& section); | |
122 | ||
123 | /** | |
124 | If the help viewer is not running, runs it and displays the given section. | |
125 | ||
126 | - @e WinHelp, MS HTML Help @a sectionNo is a context id. | |
127 | - @e External HTML help: wxExtHelpController implements @a sectionNo as | |
128 | an id in a map file, which is of the form: | |
129 | - @e wxHtmlHelpController: @a sectionNo is an identifier as specified in | |
130 | the @c .hhc file. See @ref overview_html_helpformats. | |
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(int sectionNo); | |
135 | ||
136 | /** | |
137 | Displays the text in a popup window, if possible. | |
138 | ||
139 | Returns @false if unsuccessful or not implemented. | |
140 | */ | |
141 | virtual bool DisplayTextPopup(const wxString& text, | |
142 | const wxPoint& pos); | |
143 | ||
144 | /** | |
145 | For wxHtmlHelpController, returns the latest frame size and position | |
146 | settings and whether a new frame is drawn with each invocation. | |
147 | For all other help controllers, this function does nothing and just returns @NULL. | |
148 | ||
149 | @param size | |
150 | The most recent frame size. | |
151 | @param pos | |
152 | The most recent frame position. | |
153 | @param newFrameEachTime | |
154 | @true if a new frame is drawn with each invocation. | |
155 | */ | |
156 | virtual wxFrame* GetFrameParameters(wxSize* size = NULL, | |
157 | wxPoint* pos = NULL, | |
158 | bool* newFrameEachTime = NULL); | |
159 | ||
160 | /** | |
161 | Returns the window to be used as the parent for the help window. | |
162 | This window is used by wxCHMHelpController, wxWinHelpController and | |
163 | 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 number if using wxHelp (now obsolete). Does not invoke the help viewer. | |
171 | This must be called directly after the help instance object is created and | |
172 | before any attempts to communicate with the viewer. | |
173 | ||
174 | You may omit the file extension and a suitable one will be chosen. | |
175 | For wxHtmlHelpController, the extensions zip, htb and hhp will be appended | |
176 | while searching for a suitable file. For WinHelp, the hlp extension is appended. | |
177 | */ | |
178 | virtual bool Initialize(const wxString& file); | |
179 | virtual bool Initialize(const wxString& file, int server); | |
180 | //@} | |
181 | ||
182 | /** | |
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 section. | |
185 | The optional parameter allows the search the index (wxHELP_SEARCH_INDEX) | |
186 | but this currently only supported by the wxHtmlHelpController. | |
187 | ||
188 | - @e WinHelp, MS HTML Help: | |
189 | If more than one match is found, the first topic is displayed. | |
190 | - @e External HTML help, simple wxHTML help: | |
191 | If more than one match is found, a choice of topics is displayed. | |
192 | - @e wxHtmlHelpController: see wxHtmlHelpController::KeywordSearch. | |
193 | */ | |
194 | virtual bool KeywordSearch(const wxString& keyWord, | |
195 | wxHelpSearchMode mode = wxHELP_SEARCH_ALL); | |
196 | ||
197 | /** | |
198 | If the help viewer is not running, runs it and loads the given file. | |
199 | If the filename is not supplied or is empty, the file specified in | |
200 | Initialize() is used. | |
201 | ||
202 | If the viewer is already displaying the specified file, it will not be | |
203 | reloaded. This member function may be used before each display call in | |
204 | case the user has opened another file. | |
205 | ||
206 | wxHtmlHelpController ignores this call. | |
207 | */ | |
208 | virtual bool LoadFile(const wxString& file = wxEmptyString); | |
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 void 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 it. | |
219 | */ | |
220 | virtual bool Quit(); | |
221 | ||
222 | /** | |
223 | For wxHtmlHelpController, the title is set (with %s indicating the | |
224 | page title) and also the size and position of the frame if the frame is | |
225 | already open. @a newFrameEachTime is ignored. | |
226 | ||
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. | |
242 | So far this is only relevant to wxExtHelpController. | |
243 | Some examples of usage: | |
244 | ||
245 | @code | |
246 | m_help.SetViewer("kdehelp"); | |
247 | m_help.SetViewer("gnome-help-browser"); | |
248 | m_help.SetViewer("netscape", wxHELP_NETSCAPE); | |
249 | @endcode | |
250 | ||
251 | @param viewer | |
252 | This defaults to "netscape" for wxExtHelpController. | |
253 | @param flags | |
254 | This defaults to wxHELP_NETSCAPE for wxExtHelpController, indicating | |
255 | that the viewer is a variant of Netscape Navigator. | |
256 | ||
257 | @todo modernize this function with ::wxLaunchDefaultBrowser | |
258 | */ | |
259 | virtual void SetViewer(const wxString& viewer, long flags); | |
260 | }; | |
261 |