1999-10-31 22:02:03 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2011-08-09 11:25:09 +00:00
|
|
|
// Name: helpview.cpp
|
2009-02-08 01:20:35 +00:00
|
|
|
// Purpose: wxHtml sample: help browser
|
|
|
|
// Author: ?
|
|
|
|
// Modified by:
|
|
|
|
// Created: ?
|
|
|
|
// Copyright: (c) wxWidgets team
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2002-07-09 10:38:51 +00:00
|
|
|
// Please note: see utils/helpview for a more fully-featured
|
|
|
|
// standalone help browser.
|
1999-10-31 22:02:03 +00:00
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
2001-10-30 13:33:34 +00:00
|
|
|
#include "wx/wxprec.h"
|
1999-10-31 22:02:03 +00:00
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// for all others, include the necessary headers (this file is usually all you
|
2004-05-25 11:20:37 +00:00
|
|
|
// need because it includes almost all "standard" wxWidgets headers
|
1999-10-31 22:02:03 +00:00
|
|
|
#ifndef WX_PRECOMP
|
2002-01-13 17:41:56 +00:00
|
|
|
#include "wx/wx.h"
|
1999-10-31 22:02:03 +00:00
|
|
|
#endif
|
|
|
|
|
2002-01-13 17:41:56 +00:00
|
|
|
#include "wx/image.h"
|
|
|
|
#include "wx/wxhtml.h"
|
|
|
|
#include "wx/fs_zip.h"
|
|
|
|
#include "wx/log.h"
|
2002-07-07 21:48:30 +00:00
|
|
|
#include "wx/filedlg.h"
|
|
|
|
|
2009-02-08 01:20:35 +00:00
|
|
|
|
1999-10-31 22:02:03 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// private classes
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Define a new application type, each program should derive a class from wxApp
|
|
|
|
class MyApp : public wxApp
|
|
|
|
{
|
2009-02-08 01:20:35 +00:00
|
|
|
public:
|
|
|
|
// override base class virtuals
|
|
|
|
// ----------------------------
|
1999-10-31 22:02:03 +00:00
|
|
|
|
2009-02-08 01:20:35 +00:00
|
|
|
// this one is called on application startup and is a good place for the app
|
|
|
|
// initialization (doing it here and not in the ctor allows to have an error
|
|
|
|
// return: if OnInit() returns false, the application terminates)
|
1999-10-31 22:02:03 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool OnInit() wxOVERRIDE;
|
|
|
|
virtual int OnExit() wxOVERRIDE;
|
1999-10-31 22:02:03 +00:00
|
|
|
|
2009-02-08 01:20:35 +00:00
|
|
|
private:
|
|
|
|
wxHtmlHelpController *help;
|
1999-10-31 22:02:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-04-23 11:49:01 +00:00
|
|
|
wxIMPLEMENT_APP(MyApp);
|
1999-10-31 22:02:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool MyApp::OnInit()
|
|
|
|
{
|
1999-11-08 14:53:39 +00:00
|
|
|
#ifdef __WXMOTIF__
|
|
|
|
delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
|
|
|
|
#endif
|
|
|
|
|
1999-10-31 22:02:03 +00:00
|
|
|
wxInitAllImageHandlers();
|
|
|
|
wxFileSystem::AddHandler(new wxZipFSHandler);
|
|
|
|
|
2004-05-25 11:20:37 +00:00
|
|
|
SetVendorName(wxT("wxWidgets"));
|
2009-02-08 01:20:35 +00:00
|
|
|
SetAppName(wxT("wxHTMLHelp"));
|
2000-01-17 17:18:53 +00:00
|
|
|
wxConfig::Get(); // create an instance
|
|
|
|
|
2002-07-09 10:38:51 +00:00
|
|
|
help = new wxHtmlHelpController;
|
|
|
|
|
1999-10-31 22:02:03 +00:00
|
|
|
if (argc < 2) {
|
2001-09-21 20:21:44 +00:00
|
|
|
wxLogError(wxT("Usage : helpview <helpfile> [<more helpfiles>]"));
|
|
|
|
wxLogError(wxT(" helpfile may be .hhp, .zip or .htb"));
|
2004-05-21 11:29:38 +00:00
|
|
|
return false;
|
1999-10-31 22:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 1; i < argc; i++)
|
2002-12-08 20:30:56 +00:00
|
|
|
help->AddBook(wxFileName(argv[i]));
|
1999-10-31 22:02:03 +00:00
|
|
|
|
1999-11-08 14:53:39 +00:00
|
|
|
#ifdef __WXMOTIF__
|
|
|
|
delete wxLog::SetActiveTarget(new wxLogGui);
|
|
|
|
#endif
|
|
|
|
|
2011-03-18 09:16:14 +00:00
|
|
|
help->SetShouldPreventAppExit(true);
|
|
|
|
|
1999-10-31 22:02:03 +00:00
|
|
|
help -> DisplayContents();
|
|
|
|
|
2004-05-21 11:29:38 +00:00
|
|
|
return true;
|
1999-10-31 22:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int MyApp::OnExit()
|
|
|
|
{
|
|
|
|
delete help;
|
2000-01-17 17:18:53 +00:00
|
|
|
delete wxConfig::Set(NULL);
|
1999-10-31 22:02:03 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|