]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: help.h | |
3 | // Purpose: interface of wxHelpController | |
4 | // Author: wxWidgets team | |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxHelpController | |
11 | ||
12 | This is a family of classes by which | |
13 | applications may invoke a help viewer 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 | |
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. | |
24 | ||
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 | |
28 | follows: | |
29 | ||
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 | |
34 | external | |
35 | browser). | |
36 | ||
37 | The remaining help controller classes need to be named | |
38 | explicitly by an application that wishes to make use of them. | |
39 | ||
40 | There are currently the following help controller classes defined: | |
41 | ||
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 | |
46 | don't need | |
47 | VC++ specific htmlhelp.lib because wxWidgets loads necessary DLL at runtime and | |
48 | so it | |
49 | works with all compilers). | |
50 | wxBestHelpController, for controlling MS HTML Help or, if Microsoft's runtime | |
51 | is | |
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 | |
60 | files. | |
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 | |
64 | you | |
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. | |
69 | ||
70 | ||
71 | @library{wxbase} | |
72 | @category{help} | |
73 | ||
74 | @see wxHtmlHelpController, wxHTML() | |
75 | */ | |
76 | class wxHelpController : public wxObject | |
77 | { | |
78 | public: | |
79 | /** | |
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 | |
82 | as | |
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 | |
86 | SetParentWindow(). | |
87 | */ | |
88 | wxHelpController(wxWindow* parentWindow = NULL); | |
89 | ||
90 | /** | |
91 | Destroys the help instance, closing down the viewer if it is running. | |
92 | */ | |
93 | ~wxHelpController(); | |
94 | ||
95 | /** | |
96 | If the help viewer is not running, runs it and displays the file at the given | |
97 | block number. | |
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. | |
105 | */ | |
106 | virtual bool DisplayBlock(long blockNo); | |
107 | ||
108 | /** | |
109 | If the help viewer is not running, runs it and displays the | |
110 | contents. | |
111 | */ | |
112 | virtual bool DisplayContents(); | |
113 | ||
114 | /** | |
115 | Displays the section as a popup window using a context id. | |
116 | Returns @false if unsuccessful or not implemented. | |
117 | */ | |
118 | virtual bool DisplayContextPopup(int contextId); | |
119 | ||
120 | //@{ | |
121 | /** | |
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: | |
126 | ||
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. | |
131 | */ | |
132 | virtual bool DisplaySection(const wxString& section); | |
133 | virtual bool DisplaySection(int sectionNo); | |
134 | //@} | |
135 | ||
136 | /** | |
137 | Displays the text in a popup window, if possible. | |
138 | Returns @false if unsuccessful or not implemented. | |
139 | */ | |
140 | virtual bool DisplayTextPopup(const wxString& text, | |
141 | const wxPoint& pos); | |
142 | ||
143 | /** | |
144 | wxHtmlHelpController returns the frame, size and position. | |
145 | For all other help controllers, this function does nothing | |
146 | and just returns @NULL. | |
147 | ||
148 | @param viewer | |
149 | This defaults to "netscape" for wxExtHelpController. | |
150 | @param flags | |
151 | This defaults to wxHELP_NETSCAPE for wxExtHelpController, indicating | |
152 | that the viewer is a variant of Netscape Navigator. | |
153 | */ | |
154 | virtual wxFrame* GetFrameParameters(const wxSize* size = NULL, | |
155 | const wxPoint* pos = NULL, | |
156 | bool* newFrameEachTime = NULL); | |
157 | ||
158 | /** | |
159 | Returns the window to be used as the parent for the help window. This window is | |
160 | used | |
161 | by wxCHMHelpController, wxWinHelpController and wxHtmlHelpController. | |
162 | */ | |
163 | virtual wxWindow* GetParentWindow() const; | |
164 | ||
165 | //@{ | |
166 | /** | |
167 | Initializes the help instance with a help filename, and optionally a server | |
168 | socket | |
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 | |
171 | before | |
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 | |
175 | searching for | |
176 | 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 | |
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. | |
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 | |
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. | |
205 | */ | |
206 | virtual bool LoadFile(const wxString& file = ""); | |
207 | ||
208 | /** | |
209 | Overridable member called when this application's viewer is quit by the user. | |
210 | This does not work for all help controllers. | |
211 | */ | |
212 | virtual bool OnQuit(); | |
213 | ||
214 | /** | |
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 | |
217 | it. | |
218 | */ | |
219 | virtual bool Quit(); | |
220 | ||
221 | /** | |
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. | |
226 | */ | |
227 | virtual void SetFrameParameters(const wxString& title, | |
228 | const wxSize& size, | |
229 | const wxPoint& pos = wxDefaultPosition, | |
230 | bool newFrameEachTime = false); | |
231 | ||
232 | /** | |
233 | Sets the window to be used as the parent for the help window. This is used | |
234 | by wxCHMHelpController, wxWinHelpController and wxHtmlHelpController. | |
235 | */ | |
236 | virtual void SetParentWindow(wxWindow* parentWindow); | |
237 | ||
238 | /** | |
239 | Sets detailed viewer information. So far this is only relevant to | |
240 | wxExtHelpController. | |
241 | Some examples of usage: | |
242 | */ | |
243 | virtual void SetViewer(const wxString& viewer, long flags); | |
244 | }; | |
245 |