1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/helpbest.cpp
3 // Purpose: Tries to load MS HTML Help, falls back to wxHTML upon failure
4 // Author: Mattia Barbon
8 // Copyright: (c) Mattia Barbon
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
23 #include "wx/filename.h"
25 #if wxUSE_HELP && wxUSE_MS_HTML_HELP \
26 && wxUSE_WXHTML_HELP && !defined(__WXUNIVERSAL__)
28 #include "wx/msw/helpchm.h"
29 #include "wx/html/helpctrl.h"
30 #include "wx/msw/helpbest.h"
32 IMPLEMENT_DYNAMIC_CLASS( wxBestHelpController
, wxHelpControllerBase
)
34 bool wxBestHelpController::Initialize( const wxString
& filename
)
36 // try wxCHMHelpController
37 wxCHMHelpController
* chm
= new wxCHMHelpController(m_parentWindow
);
39 m_helpControllerType
= wxUseChmHelp
;
40 // do not warn upon failure
41 wxLogNull dontWarnOnFailure
;
43 if( chm
->Initialize( GetValidFilename( filename
) ) )
45 m_helpController
= chm
;
46 m_parentWindow
= NULL
;
53 // try wxHtmlHelpController
54 wxHtmlHelpController
*
55 html
= new wxHtmlHelpController(m_style
, m_parentWindow
);
57 m_helpControllerType
= wxUseHtmlHelp
;
58 if( html
->Initialize( GetValidFilename( filename
) ) )
60 m_helpController
= html
;
61 m_parentWindow
= NULL
;
71 wxString
wxBestHelpController::GetValidFilename( const wxString
& filename
) const
73 wxFileName
fn(filename
);
75 switch( m_helpControllerType
)
80 return fn
.GetFullPath();
87 return fn
.GetFullPath();
91 return fn
.GetFullPath();
95 return fn
.GetFullPath();
101 wxFAIL_MSG( wxT("wxBestHelpController: Must call Initialize, first!") );
104 return wxEmptyString
;
108 // wxUSE_HELP && wxUSE_MS_HTML_HELP && wxUSE_WXHTML_HELP