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