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