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 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "helpbest.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/filefn.h"
29 #if wxUSE_HELP && wxUSE_MS_HTML_HELP && defined(__WIN95__) && wxUSE_WXHTML_HELP
30 #include "wx/msw/helpchm.h"
31 #include "wx/html/helpctrl.h"
32 #include "wx/msw/helpbest.h"
34 IMPLEMENT_DYNAMIC_CLASS( wxBestHelpController
, wxHelpControllerBase
);
36 bool wxBestHelpController::Initialize( const wxString
& filename
)
38 // try wxCHMHelpController
39 wxCHMHelpController
* chm
= new wxCHMHelpController
;
41 m_helpControllerType
= wxUseChmHelp
;
42 // do not warn upon failure
43 wxLogNull dontWarnOnFailure
;
45 if( chm
->Initialize( GetValidFilename( filename
) ) )
47 m_helpController
= chm
;
54 // try wxHtmlHelpController
55 wxHtmlHelpController
* html
= new wxHtmlHelpController
;
57 m_helpControllerType
= wxUseHtmlHelp
;
58 if( html
->Initialize( GetValidFilename( filename
) ) )
60 m_helpController
= html
;
70 wxString
wxBestHelpController::GetValidFilename( const wxString
& filename
) const
72 wxString tmp
= filename
;
73 ::wxStripExtension( tmp
);
75 switch( m_helpControllerType
)
78 if( ::wxFileExists( tmp
+ ".chm" ) )
84 if( ::wxFileExists( tmp
+ ".htb" ) )
86 if( ::wxFileExists( tmp
+ ".zip" ) )
88 if( ::wxFileExists( tmp
+ ".hhp" ) )
95 wxFAIL_MSG( wxT("wxBestHelpController: Must call Initialize, first!") );
102 // wxUSE_HELP && wxUSE_MS_HTML_HELP && defined(__WIN95__) && wxUSE_WXHTML_HELP