1 /*-*- c++ -*-********************************************************
2 * helpext.h - an external help controller for wxWidgets *
4 * (C) 1998 by Karsten Ballüder (Ballueder@usa.net) *
5 * License: wxWindows licence *
8 *******************************************************************/
10 #ifndef __WX_HELPEXT_H_
11 #define __WX_HELPEXT_H_
15 #include "wx/helpbase.h"
17 #ifndef WXEXTHELP_DEFAULTBROWSER
18 /// Default browser name.
19 # define WXEXTHELP_DEFAULTBROWSER _T("netscape")
20 /// Is default browse a variant of netscape?
21 # define WXEXTHELP_DEFAULTBROWSER_IS_NETSCAPE true
25 This class implements help via an external browser.
26 It requires the name of a directory containing the documentation
27 and a file mapping numerical Section numbers to relative URLS.
29 The map file contains two or three fields per line:
30 numeric_id relative_URL [; comment/documentation]
32 The numeric_id is the id used to look up the entry in
33 DisplaySection()/DisplayBlock(). The relative_URL is a filename of
34 an html file, relative to the help directory. The optional
35 comment/documentation field (after a ';') is used for keyword
36 searches, so some meaningful text here does not hurt.
37 If the documentation itself contains a ';', only the part before
38 that will be displayed in the listbox, but all of it used for search.
40 Lines starting with ';' will be ignored.
43 class WXDLLIMPEXP_ADV wxExtHelpController
: public wxHelpControllerBase
46 wxExtHelpController(wxWindow
* parentWindow
= NULL
);
47 ~wxExtHelpController();
49 /** Tell it which browser to use.
50 The Netscape support will check whether Netscape is already
51 running (by looking at the .netscape/lock file in the user's
52 home directory) and tell it to load the page into the existing
54 @param browsername The command to call a browser/html viewer.
55 @param isNetscape Set this to true if the browser is some variant of Netscape.
58 void SetBrowser(const wxString
& browsername
= WXEXTHELP_DEFAULTBROWSER
,
59 bool isNetscape
= WXEXTHELP_DEFAULTBROWSER_IS_NETSCAPE
);
61 // Set viewer: new name for SetBrowser
62 virtual void SetViewer(const wxString
& viewer
= WXEXTHELP_DEFAULTBROWSER
, long flags
= wxHELP_NETSCAPE
);
64 /** This must be called to tell the controller where to find the
66 If a locale is set, look in file/localename, i.e.
67 If passed "/usr/local/myapp/help" and the current wxLocale is
68 set to be "de", then look in "/usr/local/myapp/help/de/"
69 first and fall back to "/usr/local/myapp/help" if that
72 @param file - NOT a filename, but a directory name.
73 @return true on success
75 virtual bool Initialize(const wxString
& dir
, int WXUNUSED(server
))
76 { return Initialize(dir
); }
78 /** This must be called to tell the controller where to find the
80 If a locale is set, look in file/localename, i.e.
81 If passed "/usr/local/myapp/help" and the current wxLocale is
82 set to be "de", then look in "/usr/local/myapp/help/de/"
83 first and fall back to "/usr/local/myapp/help" if that
85 @param dir - directory name where to fine the help files
86 @return true on success
88 virtual bool Initialize(const wxString
& dir
);
90 /** If file is "", reloads file given in Initialize.
91 @file Name of help directory.
92 @return true on success
94 virtual bool LoadFile(const wxString
& file
= wxEmptyString
);
96 /** Display list of all help entries.
97 @return true on success
99 virtual bool DisplayContents(void);
100 /** Display help for id sectionNo.
101 @return true on success
103 virtual bool DisplaySection(int sectionNo
);
104 /** Display help for id sectionNo -- identical with DisplaySection().
105 @return true on success
107 virtual bool DisplaySection(const wxString
& section
);
108 /** Display help for URL (using DisplayHelp) or keyword (using KeywordSearch)
109 @return true on success
111 virtual bool DisplayBlock(long blockNo
);
112 /** Search comment/documentation fields in map file and present a
114 @key k string to search for, empty string will list all entries
115 @return true on success
117 virtual bool KeywordSearch(const wxString
& k
,
118 wxHelpSearchMode mode
= wxHELP_SEARCH_ALL
);
121 virtual bool Quit(void);
123 virtual void OnQuit(void);
125 /// Call the browser using a relative URL.
126 virtual bool DisplayHelp(const wxString
&) ;
128 /// Allows one to override the default settings for the help frame.
129 virtual void SetFrameParameters(const wxString
& WXUNUSED(title
),
130 const wxSize
& WXUNUSED(size
),
131 const wxPoint
& WXUNUSED(pos
) = wxDefaultPosition
,
132 bool WXUNUSED(newFrameEachTime
) = false)
134 // does nothing by default
136 /// Obtains the latest settings used by the help frame and the help
138 virtual wxFrame
*GetFrameParameters(wxSize
*WXUNUSED(size
) = NULL
,
139 wxPoint
*WXUNUSED(pos
) = NULL
,
140 bool *WXUNUSED(newFrameEachTime
) = NULL
)
142 return (wxFrame
*) NULL
;// does nothing by default
146 /// Filename of currently active map file.
148 /// How many entries do we have in the map file?
150 /// A list containing all id,url,documentation triples.
154 // parse a single line of the map file (called by LoadFile())
156 // return true if the line was valid or false otherwise
157 bool ParseMapFileLine(const wxString
& line
);
159 /// Deletes the list and all objects.
160 void DeleteList(void);
163 /// How to call the html viewer.
164 wxString m_BrowserName
;
165 /// Is the viewer a variant of netscape?
166 bool m_BrowserIsNetscape
;
168 DECLARE_CLASS(wxExtHelpController
)
173 #endif // __WX_HELPEXT_H_