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