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