]>
Commit | Line | Data |
---|---|---|
de5c0ba7 | 1 | ///////////////////////////////////////////////////////////////////////////// |
33b64e6f JS |
2 | // Name: demo.cpp |
3 | // Purpose: wxHelpController demo | |
4 | // Author: Karsten Ballueder | |
de5c0ba7 KB |
5 | // Modified by: |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
33b64e6f JS |
8 | // Copyright: (c) Karsten Ballueder, Julian Smart |
9 | // Licence: wxWindows licence | |
de5c0ba7 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
f96b60aa | 19 | |
de5c0ba7 KB |
20 | // For compilers that support precompilation, includes "wx/wx.h". |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
29ea4a29 | 24 | # pragma hdrstop |
de5c0ba7 KB |
25 | #endif |
26 | ||
27 | // for all others, include the necessary headers (this file is usually all you | |
28 | // need because it includes almost all "standard" wxWindows headers | |
29 | #ifndef WX_PRECOMP | |
29ea4a29 | 30 | # include "wx/wx.h" |
de5c0ba7 KB |
31 | #endif |
32 | ||
7c4a59a8 JS |
33 | # include "wx/image.h" |
34 | # include "wx/help.h" | |
35 | ||
29ea4a29 | 36 | // define this to 1 to use HTML help even under Windows (by default, Windows |
7c4a59a8 | 37 | // version will use WinHelp). |
5da69e38 | 38 | // Please also see samples/html/helpview. |
7c4a59a8 | 39 | |
d22699b5 | 40 | #define USE_HTML_HELP 1 |
7c4a59a8 | 41 | |
f6bcfd97 BP |
42 | // Use old-style HTML help if 1 |
43 | #define USE_OLD_HTML_HELP 0 | |
44 | ||
7c4a59a8 JS |
45 | #if !wxUSE_HTML |
46 | #undef USE_HTML_HELP | |
47 | #define USE_HTML_HELP 0 | |
48 | #endif | |
49 | ||
f96b60aa | 50 | #if USE_HTML_HELP |
7b28757f JS |
51 | #include <wx/filesys.h> |
52 | #include <wx/fs_zip.h> | |
53 | ||
f6bcfd97 | 54 | #if USE_OLD_HTML_HELP |
7b28757f | 55 | #include "wx/generic/helpwxht.h" |
f6bcfd97 BP |
56 | #endif |
57 | ||
7b28757f | 58 | #include "wx/html/helpctrl.h" |
f96b60aa | 59 | #endif |
de5c0ba7 | 60 | |
f6bcfd97 BP |
61 | #if wxUSE_MS_HTML_HELP |
62 | #include "wx/msw/helpchm.h" | |
63 | #endif | |
64 | ||
de5c0ba7 KB |
65 | // ---------------------------------------------------------------------------- |
66 | // ressources | |
67 | // ---------------------------------------------------------------------------- | |
68 | // the application icon | |
55acd85e | 69 | #if defined(__WXGTK__) || defined(__WXMOTIF__) |
de5c0ba7 KB |
70 | #include "mondrian.xpm" |
71 | #endif | |
72 | ||
73 | // ---------------------------------------------------------------------------- | |
74 | // private classes | |
75 | // ---------------------------------------------------------------------------- | |
76 | ||
77 | // Define a new application type, each program should derive a class from wxApp | |
78 | class MyApp : public wxApp | |
79 | { | |
80 | public: | |
81 | // override base class virtuals | |
82 | // ---------------------------- | |
83 | ||
84 | // this one is called on application startup and is a good place for the app | |
85 | // initialization (doing it here and not in the ctor allows to have an error | |
86 | // return: if OnInit() returns false, the application terminates) | |
87 | virtual bool OnInit(); | |
88 | }; | |
89 | ||
90 | // Define a new frame type: this is going to be our main frame | |
91 | class MyFrame : public wxFrame | |
92 | { | |
93 | public: | |
94 | // ctor(s) | |
95 | MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); | |
96 | ||
e66ad5c6 VZ |
97 | wxHelpController& GetHelpController() { return m_help; } |
98 | ||
7c4a59a8 | 99 | #if USE_HTML_HELP |
f6bcfd97 | 100 | #if USE_OLD_HTML_HELP |
7c4a59a8 | 101 | wxHelpControllerHtml& GetHtmlHelpController() { return m_htmlHelp; } |
f6bcfd97 | 102 | #endif |
7b28757f | 103 | wxHtmlHelpController& GetAdvancedHtmlHelpController() { return m_advancedHtmlHelp; } |
7c4a59a8 | 104 | #endif |
f6bcfd97 BP |
105 | #if wxUSE_MS_HTML_HELP |
106 | wxCHMHelpController& GetMSHtmlHelpController() { return m_msHtmlHelp; } | |
107 | #endif | |
7c4a59a8 | 108 | |
de5c0ba7 KB |
109 | // event handlers (these functions should _not_ be virtual) |
110 | void OnQuit(wxCommandEvent& event); | |
111 | void OnHelp(wxCommandEvent& event); | |
7c4a59a8 | 112 | void OnHtmlHelp(wxCommandEvent& event); |
7b28757f | 113 | void OnAdvancedHtmlHelp(wxCommandEvent& event); |
f6bcfd97 | 114 | void OnMSHtmlHelp(wxCommandEvent& event); |
de5c0ba7 | 115 | |
b96340e6 JS |
116 | void OnContextHelp(wxHelpEvent& event); |
117 | void OnShowContextHelp(wxCommandEvent& event); | |
118 | ||
5da69e38 JS |
119 | void ShowHelp(int commandId, wxHelpControllerBase& helpController); |
120 | ||
de5c0ba7 | 121 | private: |
7c4a59a8 JS |
122 | wxHelpController m_help; |
123 | ||
124 | #if USE_HTML_HELP | |
f6bcfd97 | 125 | #if USE_OLD_HTML_HELP |
7c4a59a8 | 126 | wxHelpControllerHtml m_htmlHelp; |
f6bcfd97 | 127 | #endif |
7b28757f | 128 | wxHtmlHelpController m_advancedHtmlHelp; |
7c4a59a8 | 129 | #endif |
f96b60aa | 130 | |
f6bcfd97 BP |
131 | #if wxUSE_MS_HTML_HELP |
132 | wxCHMHelpController m_msHtmlHelp; | |
133 | #endif | |
134 | ||
de5c0ba7 KB |
135 | // any class wishing to process wxWindows events must use this macro |
136 | DECLARE_EVENT_TABLE() | |
137 | }; | |
138 | ||
139 | // ---------------------------------------------------------------------------- | |
140 | // constants | |
141 | // ---------------------------------------------------------------------------- | |
142 | ||
143 | // IDs for the controls and the menu commands | |
144 | enum | |
145 | { | |
146 | // menu items | |
33b64e6f JS |
147 | HelpDemo_Quit = 1, |
148 | HelpDemo_Help_Index, | |
149 | HelpDemo_Help_Classes, | |
150 | HelpDemo_Help_Functions, | |
151 | HelpDemo_Help_Help, | |
7c4a59a8 | 152 | HelpDemo_Help_Search, |
b96340e6 | 153 | HelpDemo_Help_ContextHelp, |
7c4a59a8 JS |
154 | |
155 | HelpDemo_Html_Help_Index, | |
156 | HelpDemo_Html_Help_Classes, | |
157 | HelpDemo_Html_Help_Functions, | |
158 | HelpDemo_Html_Help_Help, | |
159 | HelpDemo_Html_Help_Search, | |
160 | ||
7b28757f JS |
161 | HelpDemo_Advanced_Html_Help_Index, |
162 | HelpDemo_Advanced_Html_Help_Classes, | |
163 | HelpDemo_Advanced_Html_Help_Functions, | |
164 | HelpDemo_Advanced_Html_Help_Help, | |
165 | HelpDemo_Advanced_Html_Help_Search, | |
166 | ||
f6bcfd97 BP |
167 | HelpDemo_MS_Html_Help_Index, |
168 | HelpDemo_MS_Html_Help_Classes, | |
169 | HelpDemo_MS_Html_Help_Functions, | |
170 | HelpDemo_MS_Html_Help_Help, | |
171 | HelpDemo_MS_Html_Help_Search, | |
172 | ||
33b64e6f JS |
173 | HelpDemo_Help_KDE, |
174 | HelpDemo_Help_GNOME, | |
175 | HelpDemo_Help_Netscape, | |
de5c0ba7 | 176 | // controls start here (the numbers are, of course, arbitrary) |
7b28757f | 177 | HelpDemo_Text = 1000, |
de5c0ba7 KB |
178 | }; |
179 | ||
180 | // ---------------------------------------------------------------------------- | |
181 | // event tables and other macros for wxWindows | |
182 | // ---------------------------------------------------------------------------- | |
183 | ||
184 | // the event tables connect the wxWindows events with the functions (event | |
185 | // handlers) which process them. It can be also done at run-time, but for the | |
186 | // simple menu events like this the static method is much simpler. | |
187 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
33b64e6f JS |
188 | EVT_MENU(HelpDemo_Quit, MyFrame::OnQuit) |
189 | EVT_MENU(HelpDemo_Help_Index, MyFrame::OnHelp) | |
190 | EVT_MENU(HelpDemo_Help_Classes, MyFrame::OnHelp) | |
191 | EVT_MENU(HelpDemo_Help_Functions, MyFrame::OnHelp) | |
192 | EVT_MENU(HelpDemo_Help_Help, MyFrame::OnHelp) | |
7c4a59a8 | 193 | EVT_MENU(HelpDemo_Help_Search, MyFrame::OnHelp) |
b96340e6 JS |
194 | EVT_MENU(HelpDemo_Help_ContextHelp, MyFrame::OnShowContextHelp) |
195 | ||
196 | EVT_HELP(-1, MyFrame::OnContextHelp) | |
7c4a59a8 JS |
197 | |
198 | EVT_MENU(HelpDemo_Html_Help_Index, MyFrame::OnHtmlHelp) | |
199 | EVT_MENU(HelpDemo_Html_Help_Classes, MyFrame::OnHtmlHelp) | |
200 | EVT_MENU(HelpDemo_Html_Help_Functions, MyFrame::OnHtmlHelp) | |
201 | EVT_MENU(HelpDemo_Html_Help_Help, MyFrame::OnHtmlHelp) | |
202 | EVT_MENU(HelpDemo_Html_Help_Search, MyFrame::OnHtmlHelp) | |
203 | ||
7b28757f JS |
204 | EVT_MENU(HelpDemo_Advanced_Html_Help_Index, MyFrame::OnAdvancedHtmlHelp) |
205 | EVT_MENU(HelpDemo_Advanced_Html_Help_Classes, MyFrame::OnAdvancedHtmlHelp) | |
206 | EVT_MENU(HelpDemo_Advanced_Html_Help_Functions, MyFrame::OnAdvancedHtmlHelp) | |
207 | EVT_MENU(HelpDemo_Advanced_Html_Help_Help, MyFrame::OnAdvancedHtmlHelp) | |
208 | EVT_MENU(HelpDemo_Advanced_Html_Help_Search, MyFrame::OnAdvancedHtmlHelp) | |
209 | ||
f6bcfd97 BP |
210 | EVT_MENU(HelpDemo_MS_Html_Help_Index, MyFrame::OnMSHtmlHelp) |
211 | EVT_MENU(HelpDemo_MS_Html_Help_Classes, MyFrame::OnMSHtmlHelp) | |
212 | EVT_MENU(HelpDemo_MS_Html_Help_Functions, MyFrame::OnMSHtmlHelp) | |
213 | EVT_MENU(HelpDemo_MS_Html_Help_Help, MyFrame::OnMSHtmlHelp) | |
214 | EVT_MENU(HelpDemo_MS_Html_Help_Search, MyFrame::OnMSHtmlHelp) | |
215 | ||
33b64e6f JS |
216 | EVT_MENU(HelpDemo_Help_KDE, MyFrame::OnHelp) |
217 | EVT_MENU(HelpDemo_Help_GNOME, MyFrame::OnHelp) | |
218 | EVT_MENU(HelpDemo_Help_Netscape, MyFrame::OnHelp) | |
de5c0ba7 KB |
219 | END_EVENT_TABLE() |
220 | ||
221 | // Create a new application object: this macro will allow wxWindows to create | |
222 | // the application object during program execution (it's better than using a | |
223 | // static object for many reasons) and also declares the accessor function | |
224 | // wxGetApp() which will return the reference of the right type (i.e. MyApp and | |
225 | // not wxApp) | |
226 | IMPLEMENT_APP(MyApp) | |
227 | ||
228 | // ============================================================================ | |
229 | // implementation | |
230 | // ============================================================================ | |
231 | ||
232 | // ---------------------------------------------------------------------------- | |
233 | // the application class | |
234 | // ---------------------------------------------------------------------------- | |
235 | ||
236 | // `Main program' equivalent: the program execution "starts" here | |
237 | bool MyApp::OnInit() | |
238 | { | |
7c4a59a8 JS |
239 | #if wxUSE_HTML |
240 | #if wxUSE_GIF | |
241 | // Required for images in the online documentation | |
242 | wxImage::AddHandler(new wxGIFHandler); | |
7b28757f JS |
243 | |
244 | // Required for advanced HTML help | |
245 | #if wxUSE_STREAMS && wxUSE_ZIPSTREAM && wxUSE_ZLIB | |
246 | wxFileSystem::AddHandler(new wxZipFSHandler); | |
247 | #endif | |
248 | ||
7c4a59a8 JS |
249 | #endif |
250 | #endif | |
251 | ||
de5c0ba7 | 252 | // Create the main application window |
33b64e6f | 253 | MyFrame *frame = new MyFrame("HelpDemo wxWindows App", |
de5c0ba7 KB |
254 | wxPoint(50, 50), wxSize(450, 340)); |
255 | ||
de5c0ba7 KB |
256 | frame->Show(TRUE); |
257 | SetTopWindow(frame); | |
258 | ||
e66ad5c6 VZ |
259 | // initialise the help system: this means that we'll use doc.hlp file under |
260 | // Windows and that the HTML docs are in the subdirectory doc for platforms | |
261 | // using HTML help | |
262 | if ( !frame->GetHelpController().Initialize("doc") ) | |
263 | { | |
264 | wxLogError("Cannot initialize the help system, aborting."); | |
265 | ||
266 | return FALSE; | |
267 | } | |
268 | ||
7c4a59a8 | 269 | #if USE_HTML_HELP |
7b28757f | 270 | // initialise the standard HTML help system: this means that the HTML docs are in the |
7c4a59a8 | 271 | // subdirectory doc for platforms using HTML help |
f6bcfd97 | 272 | #if USE_OLD_HTML_HELP |
7c4a59a8 JS |
273 | if ( !frame->GetHtmlHelpController().Initialize("doc") ) |
274 | { | |
275 | wxLogError("Cannot initialize the HTML help system, aborting."); | |
276 | ||
277 | return FALSE; | |
278 | } | |
f6bcfd97 | 279 | #endif |
7b28757f JS |
280 | |
281 | // initialise the advanced HTML help system: this means that the HTML docs are in .htb | |
282 | // (zipped) form | |
283 | if ( !frame->GetAdvancedHtmlHelpController().Initialize("doc") ) | |
284 | { | |
285 | wxLogError("Cannot initialize the advanced HTML help system, aborting."); | |
286 | ||
287 | return FALSE; | |
288 | } | |
7c4a59a8 JS |
289 | #endif |
290 | ||
f6bcfd97 BP |
291 | #if wxUSE_MS_HTML_HELP |
292 | if ( !frame->GetMSHtmlHelpController().Initialize("doc") ) | |
293 | { | |
294 | wxLogError("Cannot initialize the MS HTML help system, aborting."); | |
295 | ||
296 | return FALSE; | |
297 | } | |
298 | #endif | |
299 | ||
de5c0ba7 KB |
300 | return TRUE; |
301 | } | |
302 | ||
303 | // ---------------------------------------------------------------------------- | |
304 | // main frame | |
305 | // ---------------------------------------------------------------------------- | |
306 | ||
307 | // frame constructor | |
308 | MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) | |
309 | : wxFrame((wxFrame *)NULL, -1, title, pos, size) | |
310 | { | |
311 | // set the frame icon | |
312 | SetIcon(wxICON(mondrian)); | |
313 | ||
314 | // create a menu bar | |
315 | wxMenu *menuFile = new wxMenu; | |
316 | ||
33b64e6f JS |
317 | menuFile->Append(HelpDemo_Help_Index, "&Help Index..."); |
318 | menuFile->Append(HelpDemo_Help_Classes, "&Help on Classes..."); | |
319 | menuFile->Append(HelpDemo_Help_Functions, "&Help on Functions..."); | |
b96340e6 | 320 | menuFile->Append(HelpDemo_Help_ContextHelp, "&Context Help..."); |
33b64e6f | 321 | menuFile->Append(HelpDemo_Help_Help, "&About Help Demo..."); |
33b64e6f | 322 | menuFile->Append(HelpDemo_Help_Search, "&Search help..."); |
7c4a59a8 | 323 | #if USE_HTML_HELP |
f6bcfd97 | 324 | #if USE_OLD_HTML_HELP |
7c4a59a8 JS |
325 | menuFile->AppendSeparator(); |
326 | menuFile->Append(HelpDemo_Html_Help_Index, "HTML &Help Index..."); | |
327 | menuFile->Append(HelpDemo_Html_Help_Classes, "HTML &Help on Classes..."); | |
328 | menuFile->Append(HelpDemo_Html_Help_Functions, "HTML &Help on Functions..."); | |
329 | menuFile->Append(HelpDemo_Html_Help_Help, "HTML &About Help Demo..."); | |
7c4a59a8 | 330 | menuFile->Append(HelpDemo_Html_Help_Search, "HTML &Search help..."); |
f6bcfd97 | 331 | #endif |
7b28757f JS |
332 | menuFile->AppendSeparator(); |
333 | menuFile->Append(HelpDemo_Advanced_Html_Help_Index, "Advanced HTML &Help Index..."); | |
334 | menuFile->Append(HelpDemo_Advanced_Html_Help_Classes, "Advanced HTML &Help on Classes..."); | |
335 | menuFile->Append(HelpDemo_Advanced_Html_Help_Functions, "Advanced HTML &Help on Functions..."); | |
336 | menuFile->Append(HelpDemo_Advanced_Html_Help_Help, "Advanced HTML &About Help Demo..."); | |
337 | menuFile->Append(HelpDemo_Advanced_Html_Help_Search, "Advanced HTML &Search help..."); | |
7c4a59a8 JS |
338 | #endif |
339 | ||
f6bcfd97 BP |
340 | #if wxUSE_MS_HTML_HELP |
341 | menuFile->AppendSeparator(); | |
342 | menuFile->Append(HelpDemo_MS_Html_Help_Index, "MS HTML &Help Index..."); | |
343 | menuFile->Append(HelpDemo_MS_Html_Help_Classes, "MS HTML &Help on Classes..."); | |
344 | menuFile->Append(HelpDemo_MS_Html_Help_Functions, "MS HTML &Help on Functions..."); | |
345 | menuFile->Append(HelpDemo_MS_Html_Help_Help, "MS HTML &About Help Demo..."); | |
346 | menuFile->Append(HelpDemo_MS_Html_Help_Search, "MS HTML &Search help..."); | |
347 | #endif | |
348 | ||
29ea4a29 | 349 | #ifndef __WXMSW__ |
e66ad5c6 | 350 | #if !wxUSE_HTML |
de5c0ba7 | 351 | menuFile->AppendSeparator(); |
33b64e6f JS |
352 | menuFile->Append(HelpDemo_Help_KDE, "Use &KDE"); |
353 | menuFile->Append(HelpDemo_Help_GNOME, "Use &GNOME"); | |
354 | menuFile->Append(HelpDemo_Help_Netscape, "Use &Netscape"); | |
29ea4a29 | 355 | #endif |
33b64e6f JS |
356 | #endif |
357 | menuFile->AppendSeparator(); | |
358 | menuFile->Append(HelpDemo_Quit, "E&xit"); | |
de5c0ba7 KB |
359 | |
360 | // now append the freshly created menu to the menu bar... | |
361 | wxMenuBar *menuBar = new wxMenuBar; | |
362 | menuBar->Append(menuFile, "&File"); | |
363 | ||
364 | // ... and attach this menu bar to the frame | |
365 | SetMenuBar(menuBar); | |
366 | ||
367 | // create a status bar just for fun (by default with 1 pane only) | |
368 | CreateStatusBar(); | |
369 | SetStatusText("Welcome to wxWindows!"); | |
370 | ||
371 | // now create some controls | |
372 | ||
373 | // a panel first - if there were several controls, it would allow us to | |
374 | // navigate between them from the keyboard | |
375 | wxPanel *panel = new wxPanel(this, -1, wxPoint(0, 0), wxSize(400, 200)); | |
376 | ||
377 | // and a static control whose parent is the panel | |
378 | (void)new wxStaticText(panel, -1, "Hello, world!", wxPoint(10, 10)); | |
de5c0ba7 KB |
379 | } |
380 | ||
381 | ||
382 | // event handlers | |
383 | ||
384 | void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) | |
385 | { | |
386 | // TRUE is to force the frame to close | |
387 | Close(TRUE); | |
388 | } | |
389 | ||
390 | void MyFrame::OnHelp(wxCommandEvent& event) | |
391 | { | |
5da69e38 JS |
392 | ShowHelp(event.GetId(), m_help); |
393 | } | |
394 | ||
b96340e6 JS |
395 | void MyFrame::OnShowContextHelp(wxCommandEvent& event) |
396 | { | |
397 | // This starts context help mode, then the user | |
398 | // clicks on a window to send a help message | |
399 | wxContextHelp contextHelp(this); | |
400 | } | |
401 | ||
402 | void MyFrame::OnContextHelp(wxHelpEvent& event) | |
403 | { | |
404 | // In a real app, if we didn't recognise this ID, we should call event.Skip() | |
405 | wxString msg; | |
406 | msg.Printf(wxT("We should now display help for window %d"), event.GetId()); | |
407 | wxMessageBox(msg); | |
408 | } | |
409 | ||
5da69e38 JS |
410 | void MyFrame::OnHtmlHelp(wxCommandEvent& event) |
411 | { | |
f6bcfd97 | 412 | #if USE_HTML_HELP && USE_OLD_HTML_HELP |
5da69e38 JS |
413 | ShowHelp(event.GetId(), m_htmlHelp); |
414 | #endif | |
415 | } | |
416 | ||
417 | void MyFrame::OnAdvancedHtmlHelp(wxCommandEvent& event) | |
418 | { | |
419 | #if USE_HTML_HELP | |
420 | ShowHelp(event.GetId(), m_advancedHtmlHelp); | |
421 | #endif | |
422 | } | |
423 | ||
f6bcfd97 BP |
424 | void MyFrame::OnMSHtmlHelp(wxCommandEvent& event) |
425 | { | |
426 | #if wxUSE_MS_HTML_HELP | |
427 | ShowHelp(event.GetId(), m_msHtmlHelp); | |
428 | #endif | |
429 | } | |
430 | ||
431 | /* | |
432 | Notes: ShowHelp uses section ids for displaying particular topics, | |
433 | but you might want to use a unique keyword to display a topic, instead. | |
434 | ||
435 | Section ids are specified as follows for the different formats. | |
436 | ||
437 | WinHelp | |
438 | ||
439 | The [MAP] section specifies the topic to integer id mapping, e.g. | |
440 | ||
441 | [MAP] | |
442 | #define intro 100 | |
443 | #define functions 1 | |
444 | #define classes 2 | |
445 | #define about 3 | |
446 | ||
447 | The identifier name corresponds to the label used for that topic. | |
448 | You could also put these in a .h file and #include it in both the MAP | |
449 | section and your C++ source. | |
450 | ||
451 | Note that Tex2RTF doesn't currently generate the MAP section automatically. | |
452 | ||
453 | MS HTML Help | |
454 | ||
455 | The [MAP] section specifies the HTML filename root to integer id mapping, e.g. | |
456 | ||
457 | [MAP] | |
458 | #define doc1 100 | |
459 | #define doc3 1 | |
460 | #define doc2 2 | |
461 | #define doc4 3 | |
462 | ||
463 | The identifier name corresponds to the HTML filename used for that topic. | |
464 | You could also put these in a .h file and #include it in both the MAP | |
465 | section and your C++ source. | |
466 | ||
467 | Note that Tex2RTF doesn't currently generate the MAP section automatically. | |
468 | ||
469 | Simple wxHTML Help and External HTML Help | |
470 | ||
471 | A wxhelp.map file is used, for example: | |
472 | ||
473 | 0 wx.htm ; wxWindows: Help index; additional keywords like overview | |
474 | 1 wx204.htm ; wxWindows Function Reference | |
475 | 2 wx34.htm ; wxWindows Class Reference | |
476 | ||
477 | Note that Tex2RTF doesn't currently generate the MAP section automatically. | |
478 | ||
479 | Advanced HTML Help | |
480 | ||
481 | An extension to the .hhc file format is used, specifying a new parameter | |
482 | with name="ID": | |
483 | ||
484 | <OBJECT type="text/sitemap"> | |
485 | <param name="Local" value="doc2.htm#classes"> | |
486 | <param name="Name" value="Classes"> | |
487 | <param name="ID" value=2> | |
488 | </OBJECT> | |
489 | ||
490 | Again, this is not generated automatically by Tex2RTF, though it could | |
491 | be added quite easily. | |
492 | ||
493 | Unfortunately adding the ID parameters appears to interfere with MS HTML Help, | |
494 | so you should not try to compile a .chm file from a .hhc file with | |
495 | this extension, or the contents will be messed up. | |
496 | */ | |
497 | ||
5da69e38 JS |
498 | void MyFrame::ShowHelp(int commandId, wxHelpControllerBase& helpController) |
499 | { | |
500 | switch(commandId) | |
de5c0ba7 | 501 | { |
33b64e6f | 502 | case HelpDemo_Help_Classes: |
5da69e38 JS |
503 | case HelpDemo_Html_Help_Classes: |
504 | case HelpDemo_Advanced_Html_Help_Classes: | |
f6bcfd97 | 505 | case HelpDemo_MS_Html_Help_Classes: |
5da69e38 | 506 | helpController.DisplaySection(2); |
f6bcfd97 | 507 | //helpController.DisplaySection("Classes"); // An alternative form for most controllers |
7c4a59a8 | 508 | |
7c4a59a8 | 509 | break; |
5da69e38 | 510 | case HelpDemo_Help_Functions: |
7c4a59a8 | 511 | case HelpDemo_Html_Help_Functions: |
5da69e38 | 512 | case HelpDemo_Advanced_Html_Help_Functions: |
f6bcfd97 | 513 | case HelpDemo_MS_Html_Help_Functions: |
5da69e38 | 514 | helpController.DisplaySection(1); |
f6bcfd97 | 515 | //helpController.DisplaySection("Functions"); // An alternative form for most controllers |
7c4a59a8 | 516 | break; |
5da69e38 | 517 | case HelpDemo_Help_Help: |
7c4a59a8 | 518 | case HelpDemo_Html_Help_Help: |
5da69e38 | 519 | case HelpDemo_Advanced_Html_Help_Help: |
f6bcfd97 | 520 | case HelpDemo_MS_Html_Help_Help: |
5da69e38 | 521 | helpController.DisplaySection(3); |
f6bcfd97 | 522 | //helpController.DisplaySection("About"); // An alternative form for most controllers |
7c4a59a8 JS |
523 | break; |
524 | ||
5da69e38 | 525 | case HelpDemo_Help_Search: |
7c4a59a8 | 526 | case HelpDemo_Html_Help_Search: |
5da69e38 | 527 | case HelpDemo_Advanced_Html_Help_Search: |
f6bcfd97 | 528 | case HelpDemo_MS_Html_Help_Search: |
7c4a59a8 JS |
529 | { |
530 | wxString key = wxGetTextFromUser("Search for?", | |
531 | "Search help for keyword", | |
532 | "", | |
533 | this); | |
534 | if(! key.IsEmpty()) | |
5da69e38 | 535 | helpController.KeywordSearch(key); |
7c4a59a8 JS |
536 | } |
537 | break; | |
5da69e38 JS |
538 | |
539 | case HelpDemo_Help_Index: | |
7c4a59a8 | 540 | case HelpDemo_Html_Help_Index: |
5da69e38 | 541 | case HelpDemo_Advanced_Html_Help_Index: |
f6bcfd97 | 542 | case HelpDemo_MS_Html_Help_Index: |
5da69e38 | 543 | helpController.DisplayContents(); |
7c4a59a8 | 544 | break; |
7c4a59a8 | 545 | |
5da69e38 | 546 | // These three calls are only used by wxExtHelpController |
7b28757f | 547 | |
5da69e38 JS |
548 | case HelpDemo_Help_KDE: |
549 | helpController.SetViewer("kdehelp"); | |
7b28757f | 550 | break; |
5da69e38 JS |
551 | case HelpDemo_Help_GNOME: |
552 | helpController.SetViewer("gnome-help-browser"); | |
7b28757f | 553 | break; |
5da69e38 JS |
554 | case HelpDemo_Help_Netscape: |
555 | helpController.SetViewer("netscape", wxHELP_NETSCAPE); | |
7b28757f JS |
556 | break; |
557 | ||
7b28757f | 558 | default: |
7b28757f JS |
559 | break; |
560 | } | |
7b28757f JS |
561 | } |
562 |