]> git.saurik.com Git - wxWidgets.git/blame - src/msw/helpbest.cpp
Forgot header with OSX prefix
[wxWidgets.git] / src / msw / helpbest.cpp
CommitLineData
3d285623 1/////////////////////////////////////////////////////////////////////////////
a71d815b 2// Name: src/msw/helpbest.cpp
3d285623
VS
3// Purpose: Tries to load MS HTML Help, falls back to wxHTML upon failure
4// Author: Mattia Barbon
5// Modified by:
6// Created: 02/04/2001
7// RCS-ID: $Id$
8// Copyright: (c) Mattia Barbon
59af881e 9// Licence: wxWindows licence
3d285623
VS
10/////////////////////////////////////////////////////////////////////////////
11
3d285623
VS
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16#pragma hdrstop
17#endif
18
19#ifndef WX_PRECOMP
7520f3da 20 #include "wx/log.h"
3d285623
VS
21#endif
22
6ad43fc3 23#include "wx/filename.h"
3d285623 24
a71d815b 25#if wxUSE_HELP && wxUSE_MS_HTML_HELP \
62cdd7d3
MB
26 && wxUSE_WXHTML_HELP && !defined(__WXUNIVERSAL__)
27
3d285623
VS
28#include "wx/msw/helpchm.h"
29#include "wx/html/helpctrl.h"
30#include "wx/msw/helpbest.h"
31
4e352a3f 32IMPLEMENT_DYNAMIC_CLASS( wxBestHelpController, wxHelpControllerBase )
3d285623
VS
33
34bool wxBestHelpController::Initialize( const wxString& filename )
35{
36 // try wxCHMHelpController
3db52265 37 wxCHMHelpController* chm = new wxCHMHelpController(m_parentWindow);
3d285623
VS
38
39 m_helpControllerType = wxUseChmHelp;
40 // do not warn upon failure
41 wxLogNull dontWarnOnFailure;
42
43 if( chm->Initialize( GetValidFilename( filename ) ) )
44 {
45 m_helpController = chm;
3db52265 46 m_parentWindow = NULL;
59af881e 47 return true;
3d285623
VS
48 }
49
50 // failed
51 delete chm;
52
53 // try wxHtmlHelpController
1c756ac8
VZ
54 wxHtmlHelpController *
55 html = new wxHtmlHelpController(m_style, m_parentWindow);
3d285623
VS
56
57 m_helpControllerType = wxUseHtmlHelp;
58 if( html->Initialize( GetValidFilename( filename ) ) )
59 {
60 m_helpController = html;
3db52265 61 m_parentWindow = NULL;
59af881e 62 return true;
3d285623
VS
63 }
64
65 // failed
66 delete html;
67
59af881e 68 return false;
3d285623
VS
69}
70
71wxString wxBestHelpController::GetValidFilename( const wxString& filename ) const
72{
6ad43fc3 73 wxFileName fn(filename);
3d285623
VS
74
75 switch( m_helpControllerType )
76 {
c34bed14 77 case wxUseChmHelp:
6ad43fc3
FM
78 fn.SetExt("chm");
79 if( fn.FileExists() )
80 return fn.GetFullPath();
c34bed14
VZ
81
82 return filename;
83
84 case wxUseHtmlHelp:
6ad43fc3
FM
85 fn.SetExt("htb");
86 if( fn.FileExists() )
87 return fn.GetFullPath();
88
89 fn.SetExt("zip");
90 if( fn.FileExists() )
91 return fn.GetFullPath();
92
93 fn.SetExt("hhp");
94 if( fn.FileExists() )
95 return fn.GetFullPath();
c34bed14
VZ
96
97 return filename;
98
99 default:
100 // we CAN'T get here
101 wxFAIL_MSG( wxT("wxBestHelpController: Must call Initialize, first!") );
3d285623 102 }
ac92c7e9
VZ
103
104 return wxEmptyString;
3d285623
VS
105}
106
107#endif
a71d815b 108 // wxUSE_HELP && wxUSE_MS_HTML_HELP && wxUSE_WXHTML_HELP