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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 # pragma interface "wxexthlp.h"
19 #include "wx/helpbase.h"
23 #define WXEXTHELP_SEPARATOR _T('\\')
24 #elif defined(__WXMAC__)
25 #define WXEXTHELP_SEPARATOR _T(':')
27 #define WXEXTHELP_SEPARATOR _T('/')
30 class WXDLLIMPEXP_ADV wxExtHelpMapList
;
32 #ifndef WXEXTHELP_DEFAULTBROWSER
33 /// Default browser name.
34 # define WXEXTHELP_DEFAULTBROWSER _T("netscape")
35 /// Is default browse a variant of netscape?
36 # define WXEXTHELP_DEFAULTBROWSER_IS_NETSCAPE true
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 WXDLLIMPEXP_ADV wxExtHelpController
: public wxHelpControllerBase
60 DECLARE_CLASS(wxExtHelpController
)
62 wxExtHelpController();
63 ~wxExtHelpController();
65 /** Tell it which browser to use.
66 The Netscape support will check whether Netscape is already
67 running (by looking at the .netscape/lock file in the user's
68 home directory) and tell it to load the page into the existing
70 @param browsername The command to call a browser/html viewer.
71 @param isNetscape Set this to true if the browser is some variant of Netscape.
74 void SetBrowser(const wxString
& browsername
= WXEXTHELP_DEFAULTBROWSER
,
75 bool isNetscape
= WXEXTHELP_DEFAULTBROWSER_IS_NETSCAPE
);
77 // Set viewer: new name for SetBrowser
78 virtual void SetViewer(const wxString
& viewer
= WXEXTHELP_DEFAULTBROWSER
, long flags
= wxHELP_NETSCAPE
);
80 /** This must be called to tell the controller where to find the
82 If a locale is set, look in file/localename, i.e.
83 If passed "/usr/local/myapp/help" and the current wxLocale is
84 set to be "de", then look in "/usr/local/myapp/help/de/"
85 first and fall back to "/usr/local/myapp/help" if that
88 @param file - NOT a filename, but a directory name.
89 @return true on success
91 virtual bool Initialize(const wxString
& dir
, int WXUNUSED(server
))
92 { return Initialize(dir
); }
94 /** This must be called to tell the controller where to find the
96 If a locale is set, look in file/localename, i.e.
97 If passed "/usr/local/myapp/help" and the current wxLocale is
98 set to be "de", then look in "/usr/local/myapp/help/de/"
99 first and fall back to "/usr/local/myapp/help" if that
101 @param dir - directory name where to fine the help files
102 @return true on success
104 virtual bool Initialize(const wxString
& dir
);
106 /** If file is "", reloads file given in Initialize.
107 @file Name of help directory.
108 @return true on success
110 virtual bool LoadFile(const wxString
& file
= wxEmptyString
);
112 /** Display list of all help entries.
113 @return true on success
115 virtual bool DisplayContents(void);
116 /** Display help for id sectionNo.
117 @return true on success
119 virtual bool DisplaySection(int sectionNo
);
120 /** Display help for id sectionNo -- identical with DisplaySection().
121 @return true on success
123 virtual bool DisplaySection(const wxString
& section
);
124 /** Display help for URL (using DisplayHelp) or keyword (using KeywordSearch)
125 @return true on success
127 virtual bool DisplayBlock(long blockNo
);
128 /** Search comment/documentation fields in map file and present a
130 @key k string to search for, empty string will list all entries
131 @return true on success
133 virtual bool KeywordSearch(const wxString
& k
,
134 wxHelpSearchMode mode
= wxHELP_SEARCH_ALL
);
137 virtual bool Quit(void);
139 virtual void OnQuit(void);
141 /// Call the browser using a relative URL.
142 virtual bool DisplayHelp(const wxString
&) ;
144 /// Allows one to override the default settings for the help frame.
145 virtual void SetFrameParameters(const wxString
& WXUNUSED(title
),
146 const wxSize
& WXUNUSED(size
),
147 const wxPoint
& WXUNUSED(pos
) = wxDefaultPosition
,
148 bool WXUNUSED(newFrameEachTime
) = false)
150 // does nothing by default
152 /// Obtains the latest settings used by the help frame and the help
154 virtual wxFrame
*GetFrameParameters(wxSize
*WXUNUSED(size
) = NULL
,
155 wxPoint
*WXUNUSED(pos
) = NULL
,
156 bool *WXUNUSED(newFrameEachTime
) = NULL
)
158 return (wxFrame
*) NULL
;// does nothing by default
162 /// Filename of currently active map file.
164 /// How many entries do we have in the map file?
166 /// A list containing all id,url,documentation triples.
168 /// Deletes the list and all objects.
169 void DeleteList(void);
172 /// How to call the html viewer.
173 wxString m_BrowserName
;
174 /// Is the viewer a variant of netscape?
175 bool m_BrowserIsNetscape
;
180 #endif // __WX_HELPEXT_H_