1 /*-*- c++ -*-********************************************************
2 * exthlp.h - an external help controller for wxWindows *
4 * (C) 1998 by Karsten Ballüder (Ballueder@usa.net) *
7 *******************************************************************/
14 # pragma interface "wxexthlp.h"
17 /// Name for map file.
18 #define WXEXTHELP_MAPFILE "wxhelp.map"
20 #define WXEXTHELP_SEPARATOR '/'
21 #ifndef WXEXTHELP_DEFAULTBROWSER
22 /// Default browser name.
23 # define WXEXTHELP_DEFAULTBROWSER "kdehelp"
24 /// Is default browse a variant of netscape?
25 # define WXEXTHELP_DEFAULTBROWSER_IS_NETSCAPE false
27 /// Name of environment variable to set help browser.
28 #define WXEXTHELP_ENVVAR_BROWSER "WX_HELPBROWSER"
29 /// Is browser a netscape browser?
30 #define WXEXTHELP_ENVVAR_BROWSERISNETSCAPE "WX_HELPBROWSER_NS"
31 /// Maximum line length in map file.
32 #define WXEXTHELP_BUFLEN 512
33 /// Character introducing comments/documentation field in map file.
34 #define WXEXTHELP_COMMENTCHAR ';'
36 class wxExtHelpMapList
;
40 This class implements help via an external browser.
41 It requires the name of a directory containing the documentation
42 and a file mapping numerical Section numbers to relative URLS.
44 The map file contains two or three fields per line:
45 numeric_id relative_URL [; comment/documentation]
47 The numeric_id is the id used to look up the entry in
48 DisplaySection()/DisplayBlock(). The relative_URL is a filename of
49 an html file, relative to the help directory. The optional
50 comment/documentation field (after a ';') is used for keyword
51 searches, so some meaningful text here does not hurt.
52 If the documentation itself contains a ';', only the part before
53 that will be displayed in the listbox, but all of it used for search.
55 Lines starting with ';' will be ignored.
58 class wxExtHelpController
: public wxHelpControllerBase
60 DECLARE_CLASS(wxExtHelpController
)
62 wxExtHelpController(void);
63 virtual ~wxExtHelpController(void);
65 /** This must be called to tell the controller where to find the
67 @param file - NOT a filename, but a directory name.
68 @return true on success
70 virtual bool Initialize(const wxString
& file
, int WXUNUSED(server
))
71 { return Initialize(file
); }
73 /** This must be called to tell the controller where to find the
75 @param file - NOT a filename, but a directory name.
76 @return true on success
78 virtual bool Initialize(const wxString
& file
);
80 /** If file is "", reloads file given in Initialize.
81 @file Name of help directory.
82 @return true on success
84 virtual bool LoadFile(const wxString
& file
= "");
86 /** Display list of all help entries.
87 @return true on success
89 virtual bool DisplayContents(void);
90 /** Display help for id sectionNo.
91 @return true on success
93 virtual bool DisplaySection(int sectionNo
);
94 /** Display help for id sectionNo -- identical with DisplaySection().
95 @return true on success
97 virtual bool DisplayBlock(long blockNo
);
98 /** Search comment/documentation fields in map file and present a
100 @key k string to search for, empty string will list all entries
101 @return true on success
103 virtual bool KeywordSearch(const wxString
& k
);
106 virtual bool Quit(void);
108 virtual void OnQuit(void);
110 /** Tell it which browser to use.
111 The Netscape support will check whether Netscape is already
112 running (by looking at the .netscape/lock file in the user's
113 home directory) and tell it to load the page into the existing
115 @param browsername The command to call a browser/html viewer.
116 @param isNetscape Set this to TRUE if the browser is some variant of Netscape.
118 void SetBrowser(wxString
const & browsername
= WXEXTHELP_DEFAULTBROWSER
,
119 bool isNetscape
= WXEXTHELP_DEFAULTBROWSER_IS_NETSCAPE
);
121 /// Filename of currently active map file.
123 /// How many entries do we have in the map file?
125 /// A list containing all id,url,documentation triples.
126 wxExtHelpMapList
*m_MapList
;
127 /// How to call the html viewer.
128 wxString m_BrowserName
;
129 /// Is the viewer a variant of netscape?
130 bool m_BrowserIsNetscape
;
131 /// Call the browser using a relative URL.
132 bool CallBrowser(wxString
const &);