]>
Commit | Line | Data |
---|---|---|
62877de0 | 1 | ///////////////////////////////////////////////////////////////////////////// |
b86ac1ef | 2 | // Name: helpview.cpp |
197ab43d FM |
3 | // Purpose: wxHtml sample: help browser |
4 | // Author: ? | |
5 | // Modified by: | |
6 | // Created: ? | |
197ab43d FM |
7 | // Copyright: (c) wxWidgets team |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
264a1086 JS |
11 | // Please note: see utils/helpview for a more fully-featured |
12 | // standalone help browser. | |
62877de0 | 13 | |
62877de0 | 14 | // For compilers that support precompilation, includes "wx/wx.h". |
92a19c2e | 15 | #include "wx/wxprec.h" |
62877de0 VS |
16 | |
17 | #ifdef __BORLANDC__ | |
18 | #pragma hdrstop | |
19 | #endif | |
20 | ||
21 | // for all others, include the necessary headers (this file is usually all you | |
be5a51fb | 22 | // need because it includes almost all "standard" wxWidgets headers |
62877de0 | 23 | #ifndef WX_PRECOMP |
67547666 | 24 | #include "wx/wx.h" |
62877de0 VS |
25 | #endif |
26 | ||
67547666 GD |
27 | #include "wx/image.h" |
28 | #include "wx/wxhtml.h" | |
29 | #include "wx/fs_zip.h" | |
30 | #include "wx/log.h" | |
7414c52c JS |
31 | #include "wx/filedlg.h" |
32 | ||
197ab43d | 33 | |
62877de0 VS |
34 | // ---------------------------------------------------------------------------- |
35 | // private classes | |
36 | // ---------------------------------------------------------------------------- | |
37 | ||
62877de0 VS |
38 | // Define a new application type, each program should derive a class from wxApp |
39 | class MyApp : public wxApp | |
40 | { | |
197ab43d FM |
41 | public: |
42 | // override base class virtuals | |
43 | // ---------------------------- | |
62877de0 | 44 | |
197ab43d FM |
45 | // this one is called on application startup and is a good place for the app |
46 | // initialization (doing it here and not in the ctor allows to have an error | |
47 | // return: if OnInit() returns false, the application terminates) | |
62877de0 | 48 | |
197ab43d FM |
49 | virtual bool OnInit(); |
50 | virtual int OnExit(); | |
62877de0 | 51 | |
197ab43d FM |
52 | private: |
53 | wxHtmlHelpController *help; | |
62877de0 VS |
54 | }; |
55 | ||
56 | ||
57 | IMPLEMENT_APP(MyApp) | |
58 | ||
59 | ||
60 | bool MyApp::OnInit() | |
61 | { | |
6adaedf0 JS |
62 | #ifdef __WXMOTIF__ |
63 | delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used | |
64 | #endif | |
65 | ||
62877de0 VS |
66 | wxInitAllImageHandlers(); |
67 | wxFileSystem::AddHandler(new wxZipFSHandler); | |
68 | ||
be5a51fb | 69 | SetVendorName(wxT("wxWidgets")); |
197ab43d | 70 | SetAppName(wxT("wxHTMLHelp")); |
5612e524 VS |
71 | wxConfig::Get(); // create an instance |
72 | ||
264a1086 JS |
73 | help = new wxHtmlHelpController; |
74 | ||
62877de0 | 75 | if (argc < 2) { |
4693b20c MB |
76 | wxLogError(wxT("Usage : helpview <helpfile> [<more helpfiles>]")); |
77 | wxLogError(wxT(" helpfile may be .hhp, .zip or .htb")); | |
348469c2 | 78 | return false; |
62877de0 VS |
79 | } |
80 | ||
81 | for (int i = 1; i < argc; i++) | |
11d667e7 | 82 | help->AddBook(wxFileName(argv[i])); |
62877de0 | 83 | |
6adaedf0 JS |
84 | #ifdef __WXMOTIF__ |
85 | delete wxLog::SetActiveTarget(new wxLogGui); | |
86 | #endif | |
87 | ||
bd45b3e1 VZ |
88 | help->SetShouldPreventAppExit(true); |
89 | ||
62877de0 VS |
90 | help -> DisplayContents(); |
91 | ||
348469c2 | 92 | return true; |
62877de0 VS |
93 | } |
94 | ||
62877de0 VS |
95 | int MyApp::OnExit() |
96 | { | |
97 | delete help; | |
5612e524 | 98 | delete wxConfig::Set(NULL); |
62877de0 VS |
99 | |
100 | return 0; | |
101 | } | |
102 |