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