]> git.saurik.com Git - wxWidgets.git/blame - src/msw/helpbest.cpp
create the DIBs in correct (and not down up) line order
[wxWidgets.git] / src / msw / helpbest.cpp
CommitLineData
3d285623
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: helpbest.cpp
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
7// RCS-ID: $Id$
8// Copyright: (c) Mattia Barbon
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "helpbest.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
24#include "wx/defs.h"
25#endif
26
27#include "wx/filefn.h"
9fcaaedd 28#include "wx/log.h"
3d285623
VS
29
30#if wxUSE_HELP && wxUSE_MS_HTML_HELP && defined(__WIN95__) && wxUSE_WXHTML_HELP
31#include "wx/msw/helpchm.h"
32#include "wx/html/helpctrl.h"
33#include "wx/msw/helpbest.h"
34
4e352a3f 35IMPLEMENT_DYNAMIC_CLASS( wxBestHelpController, wxHelpControllerBase )
3d285623
VS
36
37bool wxBestHelpController::Initialize( const wxString& filename )
38{
39 // try wxCHMHelpController
40 wxCHMHelpController* chm = new wxCHMHelpController;
41
42 m_helpControllerType = wxUseChmHelp;
43 // do not warn upon failure
44 wxLogNull dontWarnOnFailure;
45
46 if( chm->Initialize( GetValidFilename( filename ) ) )
47 {
48 m_helpController = chm;
49 return TRUE;
50 }
51
52 // failed
53 delete chm;
54
55 // try wxHtmlHelpController
56 wxHtmlHelpController* html = new wxHtmlHelpController;
57
58 m_helpControllerType = wxUseHtmlHelp;
59 if( html->Initialize( GetValidFilename( filename ) ) )
60 {
61 m_helpController = html;
62 return TRUE;
63 }
64
65 // failed
66 delete html;
67
68 return FALSE;
69}
70
71wxString wxBestHelpController::GetValidFilename( const wxString& filename ) const
72{
73 wxString tmp = filename;
74 ::wxStripExtension( tmp );
75
76 switch( m_helpControllerType )
77 {
c34bed14 78 case wxUseChmHelp:
2b5f62a0
VZ
79 if( ::wxFileExists( tmp + wxT(".chm") ) )
80 return tmp + wxT(".chm");
c34bed14
VZ
81
82 return filename;
83
84 case wxUseHtmlHelp:
2b5f62a0
VZ
85 if( ::wxFileExists( tmp + wxT(".htb") ) )
86 return tmp + wxT(".htb");
87 if( ::wxFileExists( tmp + wxT(".zip") ) )
88 return tmp + wxT(".zip");
89 if( ::wxFileExists( tmp + wxT(".hhp") ) )
90 return tmp + wxT(".hhp");
c34bed14
VZ
91
92 return filename;
93
94 default:
95 // we CAN'T get here
96 wxFAIL_MSG( wxT("wxBestHelpController: Must call Initialize, first!") );
3d285623 97 }
ac92c7e9
VZ
98
99 return wxEmptyString;
3d285623
VS
100}
101
102#endif
103 // wxUSE_HELP && wxUSE_MS_HTML_HELP && defined(__WIN95__) && wxUSE_WXHTML_HELP