]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: help.h | |
e54c96f1 | 3 | // Purpose: interface of wxHelpController |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxHelpController | |
7c913512 | 11 | |
23324ae1 FM |
12 | This is a family of classes by which |
13 | applications may invoke a help viewer to provide on-line help. | |
7c913512 | 14 | |
23324ae1 FM |
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. | |
7c913512 | 19 | |
23324ae1 FM |
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. | |
7c913512 | 24 | |
23324ae1 FM |
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: | |
7c913512 | 29 | |
23324ae1 FM |
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). | |
7c913512 | 36 | |
23324ae1 FM |
37 | The remaining help controller classes need to be named |
38 | explicitly by an application that wishes to make use of them. | |
7c913512 | 39 | |
23324ae1 | 40 | There are currently the following help controller classes defined: |
7c913512 | 41 | |
23324ae1 FM |
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. | |
e54c96f1 | 58 | wxHtmlHelpController, a sophisticated help controller using wxHTML(), in |
23324ae1 FM |
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. | |
7c913512 FM |
69 | |
70 | ||
23324ae1 FM |
71 | @library{wxbase} |
72 | @category{help} | |
7c913512 | 73 | |
e54c96f1 | 74 | @see wxHtmlHelpController, wxHTML() |
23324ae1 FM |
75 | */ |
76 | class wxHelpController : public wxObject | |
77 | { | |
78 | public: | |
79 | /** | |
80 | Constructs a help instance object, but does not invoke the help viewer. | |
23324ae1 FM |
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 | |
7c913512 | 85 | also change the parent window later with |
23324ae1 FM |
86 | SetParentWindow(). |
87 | */ | |
4cc4bfaf | 88 | wxHelpController(wxWindow* parentWindow = NULL); |
23324ae1 FM |
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. | |
23324ae1 | 98 | @e WinHelp: Refers to the context number. |
23324ae1 | 99 | @e MS HTML Help: Refers to the context number. |
23324ae1 | 100 | @e External HTML help: the same as for DisplaySection(). |
23324ae1 FM |
101 | @e wxHtmlHelpController: @e sectionNo is an identifier as specified in the @c |
102 | .hhc file. See @ref overview_helpformat "Help files format". | |
23324ae1 FM |
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. | |
23324ae1 FM |
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. | |
4cc4bfaf FM |
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 | |
23324ae1 | 125 | a map file, which is of the form: |
3c4f71cc | 126 | |
4cc4bfaf FM |
127 | @e wxHtmlHelpController: @a sectionNo is an identifier as specified in the @c |
128 | .hhc file. See @ref overview_helpformat "Help files format". | |
23324ae1 FM |
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); | |
7c913512 | 133 | virtual bool DisplaySection(int sectionNo); |
23324ae1 FM |
134 | //@} |
135 | ||
136 | /** | |
137 | Displays the text in a popup window, if possible. | |
23324ae1 FM |
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. | |
23324ae1 FM |
145 | For all other help controllers, this function does nothing |
146 | and just returns @NULL. | |
3c4f71cc | 147 | |
7c913512 | 148 | @param viewer |
4cc4bfaf | 149 | This defaults to "netscape" for wxExtHelpController. |
7c913512 | 150 | @param flags |
4cc4bfaf FM |
151 | This defaults to wxHELP_NETSCAPE for wxExtHelpController, indicating |
152 | that the viewer is a variant of Netscape Navigator. | |
23324ae1 | 153 | */ |
4cc4bfaf FM |
154 | virtual wxFrame* GetFrameParameters(const wxSize* size = NULL, |
155 | const wxPoint* pos = NULL, | |
156 | bool* newFrameEachTime = NULL); | |
23324ae1 FM |
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 | */ | |
328f5751 | 163 | virtual wxWindow* GetParentWindow() const; |
23324ae1 FM |
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. | |
23324ae1 FM |
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); | |
7c913512 | 179 | virtual bool Initialize(const wxString& file, int server); |
23324ae1 FM |
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. | |
7c913512 | 188 | @e WinHelp, MS HTML Help: If more than one match is found, |
23324ae1 | 189 | the first topic is displayed. |
7c913512 | 190 | @e External HTML help, simple wxHTML help: If more than one match is found, |
23324ae1 | 191 | a choice of topics is displayed. |
23324ae1 FM |
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. | |
23324ae1 FM |
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. | |
23324ae1 FM |
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. | |
23324ae1 FM |
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 | |
4cc4bfaf | 224 | open. @a newFrameEachTime is ignored. |
23324ae1 FM |
225 | For all other help controllers this function has no effect. |
226 | */ | |
4cc4bfaf FM |
227 | virtual void SetFrameParameters(const wxString& title, |
228 | const wxSize& size, | |
229 | const wxPoint& pos = wxDefaultPosition, | |
230 | bool newFrameEachTime = false); | |
23324ae1 FM |
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. | |
23324ae1 FM |
241 | Some examples of usage: |
242 | */ | |
243 | virtual void SetViewer(const wxString& viewer, long flags); | |
244 | }; | |
e54c96f1 | 245 |