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
7 // Copyright: (c) Mattia Barbon
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
22 #include "wx/filename.h"
24 #if wxUSE_HELP && wxUSE_MS_HTML_HELP \
25 && wxUSE_WXHTML_HELP && !defined(__WXUNIVERSAL__)
27 #include "wx/msw/helpchm.h"
28 #include "wx/html/helpctrl.h"
29 #include "wx/msw/helpbest.h"
31 IMPLEMENT_DYNAMIC_CLASS( wxBestHelpController
, wxHelpControllerBase
)
33 bool wxBestHelpController::Initialize( const wxString
& filename
)
35 // try wxCHMHelpController
36 wxCHMHelpController
* chm
= new wxCHMHelpController(m_parentWindow
);
38 m_helpControllerType
= wxUseChmHelp
;
39 // do not warn upon failure
40 wxLogNull dontWarnOnFailure
;
42 if( chm
->Initialize( GetValidFilename( filename
) ) )
44 m_helpController
= chm
;
45 m_parentWindow
= NULL
;
52 // try wxHtmlHelpController
53 wxHtmlHelpController
*
54 html
= new wxHtmlHelpController(m_style
, m_parentWindow
);
56 m_helpControllerType
= wxUseHtmlHelp
;
57 if( html
->Initialize( GetValidFilename( filename
) ) )
59 m_helpController
= html
;
60 m_parentWindow
= NULL
;
70 wxString
wxBestHelpController::GetValidFilename( const wxString
& filename
) const
72 wxFileName
fn(filename
);
74 switch( m_helpControllerType
)
79 return fn
.GetFullPath();
86 return fn
.GetFullPath();
90 return fn
.GetFullPath();
94 return fn
.GetFullPath();
100 wxFAIL_MSG( wxT("wxBestHelpController: Must call Initialize, first!") );
103 return wxEmptyString
;
107 // wxUSE_HELP && wxUSE_MS_HTML_HELP && wxUSE_WXHTML_HELP