]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/helpext.h
Licence correction
[wxWidgets.git] / include / wx / generic / helpext.h
1 /*-*- c++ -*-********************************************************
2 * helpext.h - an external help controller for wxWidgets *
3 * *
4 * (C) 1998 by Karsten Ballüder (Ballueder@usa.net) *
5 * License: wxWindows licence *
6 * *
7 * $Id$
8 *******************************************************************/
9
10 #ifndef __WX_HELPEXT_H_
11 #define __WX_HELPEXT_H_
12
13 #if wxUSE_HELP
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 # pragma interface "wxexthlp.h"
17 #endif
18
19 #include "wx/helpbase.h"
20
21 /// Path separator.
22 #ifdef __WXMSW__
23 #define WXEXTHELP_SEPARATOR _T('\\')
24 #elif defined(__WXMAC__)
25 #define WXEXTHELP_SEPARATOR _T(':')
26 #else
27 #define WXEXTHELP_SEPARATOR _T('/')
28 #endif
29
30 class WXDLLIMPEXP_ADV wxExtHelpMapList;
31
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
37 #endif
38
39 /**
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.
43
44 The map file contains two or three fields per line:
45 numeric_id relative_URL [; comment/documentation]
46
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.
54
55 Lines starting with ';' will be ignored.
56 */
57
58 class WXDLLIMPEXP_ADV wxExtHelpController : public wxHelpControllerBase
59 {
60 DECLARE_CLASS(wxExtHelpController)
61 public:
62 wxExtHelpController();
63 ~wxExtHelpController();
64
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
69 window.
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.
72 */
73 // Obsolete form
74 void SetBrowser(const wxString & browsername = WXEXTHELP_DEFAULTBROWSER,
75 bool isNetscape = WXEXTHELP_DEFAULTBROWSER_IS_NETSCAPE);
76
77 // Set viewer: new name for SetBrowser
78 virtual void SetViewer(const wxString& viewer = WXEXTHELP_DEFAULTBROWSER, long flags = wxHELP_NETSCAPE);
79
80 /** This must be called to tell the controller where to find the
81 documentation.
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
86 doesn't exist.
87
88 @param file - NOT a filename, but a directory name.
89 @return true on success
90 */
91 virtual bool Initialize(const wxString& dir, int WXUNUSED(server))
92 { return Initialize(dir); }
93
94 /** This must be called to tell the controller where to find the
95 documentation.
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
100 doesn't exist.
101 @param dir - directory name where to fine the help files
102 @return true on success
103 */
104 virtual bool Initialize(const wxString& dir);
105
106 /** If file is "", reloads file given in Initialize.
107 @file Name of help directory.
108 @return true on success
109 */
110 virtual bool LoadFile(const wxString& file = wxEmptyString);
111
112 /** Display list of all help entries.
113 @return true on success
114 */
115 virtual bool DisplayContents(void);
116 /** Display help for id sectionNo.
117 @return true on success
118 */
119 virtual bool DisplaySection(int sectionNo);
120 /** Display help for id sectionNo -- identical with DisplaySection().
121 @return true on success
122 */
123 virtual bool DisplaySection(const wxString& section);
124 /** Display help for URL (using DisplayHelp) or keyword (using KeywordSearch)
125 @return true on success
126 */
127 virtual bool DisplayBlock(long blockNo);
128 /** Search comment/documentation fields in map file and present a
129 list to chose from.
130 @key k string to search for, empty string will list all entries
131 @return true on success
132 */
133 virtual bool KeywordSearch(const wxString& k,
134 wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
135
136 /// does nothing
137 virtual bool Quit(void);
138 /// does nothing
139 virtual void OnQuit(void);
140
141 /// Call the browser using a relative URL.
142 virtual bool DisplayHelp(const wxString &) ;
143
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)
149 {
150 // does nothing by default
151 }
152 /// Obtains the latest settings used by the help frame and the help
153 /// frame.
154 virtual wxFrame *GetFrameParameters(wxSize *WXUNUSED(size) = NULL,
155 wxPoint *WXUNUSED(pos) = NULL,
156 bool *WXUNUSED(newFrameEachTime) = NULL)
157 {
158 return (wxFrame*) NULL;// does nothing by default
159 }
160
161 protected:
162 /// Filename of currently active map file.
163 wxString m_MapFile;
164 /// How many entries do we have in the map file?
165 int m_NumOfEntries;
166 /// A list containing all id,url,documentation triples.
167 wxList *m_MapList;
168 /// Deletes the list and all objects.
169 void DeleteList(void);
170
171 private:
172 /// How to call the html viewer.
173 wxString m_BrowserName;
174 /// Is the viewer a variant of netscape?
175 bool m_BrowserIsNetscape;
176 };
177
178 #endif // wxUSE_HELP
179
180 #endif // __WX_HELPEXT_H_