]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/helpext.h
Test commit to verify cvs speed.
[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 #include "wx/helpbase.h"
16
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
22 #endif
23
24 /**
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.
28
29 The map file contains two or three fields per line:
30 numeric_id relative_URL [; comment/documentation]
31
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.
39
40 Lines starting with ';' will be ignored.
41 */
42
43 class WXDLLIMPEXP_ADV wxExtHelpController : public wxHelpControllerBase
44 {
45 public:
46 wxExtHelpController(wxWindow* parentWindow = NULL);
47 ~wxExtHelpController();
48
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
53 window.
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.
56 */
57 // Obsolete form
58 void SetBrowser(const wxString & browsername = WXEXTHELP_DEFAULTBROWSER,
59 bool isNetscape = WXEXTHELP_DEFAULTBROWSER_IS_NETSCAPE);
60
61 // Set viewer: new name for SetBrowser
62 virtual void SetViewer(const wxString& viewer = WXEXTHELP_DEFAULTBROWSER, long flags = wxHELP_NETSCAPE);
63
64 /** This must be called to tell the controller where to find the
65 documentation.
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
70 doesn't exist.
71
72 @param file - NOT a filename, but a directory name.
73 @return true on success
74 */
75 virtual bool Initialize(const wxString& dir, int WXUNUSED(server))
76 { return Initialize(dir); }
77
78 /** This must be called to tell the controller where to find the
79 documentation.
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
84 doesn't exist.
85 @param dir - directory name where to fine the help files
86 @return true on success
87 */
88 virtual bool Initialize(const wxString& dir);
89
90 /** If file is "", reloads file given in Initialize.
91 @file Name of help directory.
92 @return true on success
93 */
94 virtual bool LoadFile(const wxString& file = wxEmptyString);
95
96 /** Display list of all help entries.
97 @return true on success
98 */
99 virtual bool DisplayContents(void);
100 /** Display help for id sectionNo.
101 @return true on success
102 */
103 virtual bool DisplaySection(int sectionNo);
104 /** Display help for id sectionNo -- identical with DisplaySection().
105 @return true on success
106 */
107 virtual bool DisplaySection(const wxString& section);
108 /** Display help for URL (using DisplayHelp) or keyword (using KeywordSearch)
109 @return true on success
110 */
111 virtual bool DisplayBlock(long blockNo);
112 /** Search comment/documentation fields in map file and present a
113 list to chose from.
114 @key k string to search for, empty string will list all entries
115 @return true on success
116 */
117 virtual bool KeywordSearch(const wxString& k,
118 wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
119
120 /// does nothing
121 virtual bool Quit(void);
122 /// does nothing
123 virtual void OnQuit(void);
124
125 /// Call the browser using a relative URL.
126 virtual bool DisplayHelp(const wxString &) ;
127
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)
133 {
134 // does nothing by default
135 }
136 /// Obtains the latest settings used by the help frame and the help
137 /// frame.
138 virtual wxFrame *GetFrameParameters(wxSize *WXUNUSED(size) = NULL,
139 wxPoint *WXUNUSED(pos) = NULL,
140 bool *WXUNUSED(newFrameEachTime) = NULL)
141 {
142 return (wxFrame*) NULL;// does nothing by default
143 }
144
145 protected:
146 /// Filename of currently active map file.
147 wxString m_MapFile;
148 /// How many entries do we have in the map file?
149 int m_NumOfEntries;
150 /// A list containing all id,url,documentation triples.
151 wxList *m_MapList;
152
153 private:
154 // parse a single line of the map file (called by LoadFile())
155 //
156 // return true if the line was valid or false otherwise
157 bool ParseMapFileLine(const wxString& line);
158
159 /// Deletes the list and all objects.
160 void DeleteList(void);
161
162
163 /// How to call the html viewer.
164 wxString m_BrowserName;
165 /// Is the viewer a variant of netscape?
166 bool m_BrowserIsNetscape;
167
168 DECLARE_CLASS(wxExtHelpController)
169 };
170
171 #endif // wxUSE_HELP
172
173 #endif // __WX_HELPEXT_H_