1 /*-*- c++ -*-********************************************************
2 * helpext.cpp - an external help controller for wxWindows *
4 * (C) 1999 by Karsten Ballüder (Ballueder@usa.net) *
7 *******************************************************************/
9 # pragma implementation "wxexthlp.h"
13 #include "wx/helpbase.h"
14 #include "wx/generic/helpext.h"
15 #include "wx/string.h"
23 IMPLEMENT_CLASS(wxExtHelpController
, wxHTMLHelpControllerBase
)
26 This class implements help via an external browser.
27 It requires the name of a directory containing the documentation
28 and a file mapping numerical Section numbers to relative URLS.
31 wxExtHelpController::wxExtHelpController(void)
33 m_BrowserName
= WXEXTHELP_DEFAULTBROWSER
;
34 m_BrowserIsNetscape
= WXEXTHELP_DEFAULTBROWSER_IS_NETSCAPE
;
36 char *browser
= getenv(WXEXTHELP_ENVVAR_BROWSER
);
39 m_BrowserName
= browser
;
40 browser
= getenv(WXEXTHELP_ENVVAR_BROWSERISNETSCAPE
);
41 m_BrowserIsNetscape
= browser
&& (atoi(browser
) != 0);
47 wxExtHelpController::SetBrowser(wxString
const & browsername
, bool isNetscape
)
49 m_BrowserName
= browsername
;
50 m_BrowserIsNetscape
= isNetscape
;
53 // Set viewer: new, generic name for SetBrowser
54 void wxExtHelpController::SetViewer(const wxString
& viewer
, long flags
)
56 SetBrowser(viewer
, ((flags
& wxHELP_NETSCAPE
) == wxHELP_NETSCAPE
));
60 wxExtHelpController::DisplayHelp(wxString
const &relativeURL
)
62 wxBusyCursor b
; // display a busy cursor
65 if(m_BrowserIsNetscape
) // try re-loading first
68 wxGetHomeDir(&lockfile
);
69 lockfile
<< WXEXTHELP_SEPARATOR
<< ".netscape/lock";
71 if(lstat(lockfile
.c_str(), &statbuf
) == 0)
72 // cannot use wxFileExists, because it's a link pointing to a
73 // non-existing location if(wxFileExists(lockfile))
76 command
<< m_BrowserName
<< " -remote openURL("
77 << "file://" << m_MapFile
78 << WXEXTHELP_SEPARATOR
<< relativeURL
<< ")";
79 success
= wxExecute(command
);
80 if(success
!= 0 ) // returns PID on success
84 command
= m_BrowserName
;
86 << m_MapFile
<< WXEXTHELP_SEPARATOR
<< relativeURL
;
87 return wxExecute(command
) != 0;