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