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