1 /////////////////////////////////////////////////////////////////////////////
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/filefn.h"
26 #if wxUSE_HELP && wxUSE_MS_HTML_HELP && defined(__WIN95__) \
27 && wxUSE_WXHTML_HELP && !defined(__WXUNIVERSAL__)
29 #include "wx/msw/helpchm.h"
30 #include "wx/html/helpctrl.h"
31 #include "wx/msw/helpbest.h"
33 IMPLEMENT_DYNAMIC_CLASS( wxBestHelpController
, wxHelpControllerBase
)
35 bool wxBestHelpController::Initialize( const wxString
& filename
)
37 // try wxCHMHelpController
38 wxCHMHelpController
* chm
= new wxCHMHelpController
;
40 m_helpControllerType
= wxUseChmHelp
;
41 // do not warn upon failure
42 wxLogNull dontWarnOnFailure
;
44 if( chm
->Initialize( GetValidFilename( filename
) ) )
46 m_helpController
= chm
;
53 // try wxHtmlHelpController
54 wxHtmlHelpController
* html
= new wxHtmlHelpController
;
56 m_helpControllerType
= wxUseHtmlHelp
;
57 if( html
->Initialize( GetValidFilename( filename
) ) )
59 m_helpController
= html
;
69 wxString
wxBestHelpController::GetValidFilename( const wxString
& filename
) const
71 wxString tmp
= filename
;
72 ::wxStripExtension( tmp
);
74 switch( m_helpControllerType
)
77 if( ::wxFileExists( tmp
+ wxT(".chm") ) )
78 return tmp
+ wxT(".chm");
83 if( ::wxFileExists( tmp
+ wxT(".htb") ) )
84 return tmp
+ wxT(".htb");
85 if( ::wxFileExists( tmp
+ wxT(".zip") ) )
86 return tmp
+ wxT(".zip");
87 if( ::wxFileExists( tmp
+ wxT(".hhp") ) )
88 return tmp
+ wxT(".hhp");
94 wxFAIL_MSG( wxT("wxBestHelpController: Must call Initialize, first!") );
101 // wxUSE_HELP && wxUSE_MS_HTML_HELP && defined(__WIN95__) && wxUSE_WXHTML_HELP