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