]> git.saurik.com Git - wxWidgets.git/blame - samples/html/helpview/helpview.cpp
updated setup.h for OpenVMS
[wxWidgets.git] / samples / html / helpview / helpview.cpp
CommitLineData
62877de0 1/////////////////////////////////////////////////////////////////////////////
b86ac1ef 2// Name: helpview.cpp
197ab43d
FM
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
264a1086
JS
12// Please note: see utils/helpview for a more fully-featured
13// standalone help browser.
62877de0 14
62877de0 15// For compilers that support precompilation, includes "wx/wx.h".
92a19c2e 16#include "wx/wxprec.h"
62877de0
VS
17
18#ifdef __BORLANDC__
19#pragma hdrstop
20#endif
21
22// for all others, include the necessary headers (this file is usually all you
be5a51fb 23// need because it includes almost all "standard" wxWidgets headers
62877de0 24#ifndef WX_PRECOMP
67547666 25#include "wx/wx.h"
62877de0
VS
26#endif
27
67547666
GD
28#include "wx/image.h"
29#include "wx/wxhtml.h"
30#include "wx/fs_zip.h"
31#include "wx/log.h"
7414c52c
JS
32#include "wx/filedlg.h"
33
197ab43d 34
62877de0
VS
35// ----------------------------------------------------------------------------
36// private classes
37// ----------------------------------------------------------------------------
38
62877de0
VS
39// Define a new application type, each program should derive a class from wxApp
40class MyApp : public wxApp
41{
197ab43d
FM
42public:
43 // override base class virtuals
44 // ----------------------------
62877de0 45
197ab43d
FM
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)
62877de0 49
197ab43d
FM
50 virtual bool OnInit();
51 virtual int OnExit();
62877de0 52
197ab43d
FM
53private:
54 wxHtmlHelpController *help;
62877de0
VS
55};
56
57
58IMPLEMENT_APP(MyApp)
59
60
61bool MyApp::OnInit()
62{
6adaedf0
JS
63#ifdef __WXMOTIF__
64 delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
65#endif
66
62877de0
VS
67 wxInitAllImageHandlers();
68 wxFileSystem::AddHandler(new wxZipFSHandler);
69
be5a51fb 70 SetVendorName(wxT("wxWidgets"));
197ab43d 71 SetAppName(wxT("wxHTMLHelp"));
5612e524
VS
72 wxConfig::Get(); // create an instance
73
264a1086
JS
74 help = new wxHtmlHelpController;
75
62877de0 76 if (argc < 2) {
4693b20c
MB
77 wxLogError(wxT("Usage : helpview <helpfile> [<more helpfiles>]"));
78 wxLogError(wxT(" helpfile may be .hhp, .zip or .htb"));
348469c2 79 return false;
62877de0
VS
80 }
81
82 for (int i = 1; i < argc; i++)
11d667e7 83 help->AddBook(wxFileName(argv[i]));
62877de0 84
6adaedf0
JS
85#ifdef __WXMOTIF__
86 delete wxLog::SetActiveTarget(new wxLogGui);
87#endif
88
bd45b3e1
VZ
89 help->SetShouldPreventAppExit(true);
90
62877de0
VS
91 help -> DisplayContents();
92
348469c2 93 return true;
62877de0
VS
94}
95
62877de0
VS
96int MyApp::OnExit()
97{
98 delete help;
5612e524 99 delete wxConfig::Set(NULL);
62877de0
VS
100
101 return 0;
102}
103