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