]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/helpext.h
Source cleaning: whitespaces, tabs, -1/wxID_ANY/wxNOT_FOUND/wxDefaultCoord, TRUE...
[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 * *
6 * $Id$
7 *******************************************************************/
8
9 #ifndef __WX_HELPEXT_H_
10 #define __WX_HELPEXT_H_
11
12 #if wxUSE_HELP
13
14 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
15 # pragma interface "wxexthlp.h"
16 #endif
17
18 #include "wx/helpbase.h"
19
20 /// Path separator.
21 #ifdef __WXMSW__
22 #define WXEXTHELP_SEPARATOR _T('\\')
23 #elif defined(__WXMAC__)
24 #define WXEXTHELP_SEPARATOR _T(':')
25 #else
26 #define WXEXTHELP_SEPARATOR _T('/')
27 #endif
28
29 class WXDLLIMPEXP_ADV wxExtHelpMapList;
30
31 #ifndef WXEXTHELP_DEFAULTBROWSER
32 /// Default browser name.
33 # define WXEXTHELP_DEFAULTBROWSER _T("netscape")
34 /// Is default browse a variant of netscape?
35 # define WXEXTHELP_DEFAULTBROWSER_IS_NETSCAPE true
36 #endif
37
38 /**
39 This class implements help via an external browser.
40 It requires the name of a directory containing the documentation
41 and a file mapping numerical Section numbers to relative URLS.
42
43 The map file contains two or three fields per line:
44 numeric_id relative_URL [; comment/documentation]
45
46 The numeric_id is the id used to look up the entry in
47 DisplaySection()/DisplayBlock(). The relative_URL is a filename of
48 an html file, relative to the help directory. The optional
49 comment/documentation field (after a ';') is used for keyword
50 searches, so some meaningful text here does not hurt.
51 If the documentation itself contains a ';', only the part before
52 that will be displayed in the listbox, but all of it used for search.
53
54 Lines starting with ';' will be ignored.
55 */
56
57 class WXDLLIMPEXP_ADV wxExtHelpController : public wxHelpControllerBase
58 {
59 DECLARE_CLASS(wxExtHelpController)
60 public:
61 wxExtHelpController();
62 ~wxExtHelpController();
63
64 /** Tell it which browser to use.
65 The Netscape support will check whether Netscape is already
66 running (by looking at the .netscape/lock file in the user's
67 home directory) and tell it to load the page into the existing
68 window.
69 @param browsername The command to call a browser/html viewer.
70 @param isNetscape Set this to true if the browser is some variant of Netscape.
71 */
72 // Obsolete form
73 void SetBrowser(const wxString & browsername = WXEXTHELP_DEFAULTBROWSER,
74 bool isNetscape = WXEXTHELP_DEFAULTBROWSER_IS_NETSCAPE);
75
76 // Set viewer: new name for SetBrowser
77 virtual void SetViewer(const wxString& viewer = WXEXTHELP_DEFAULTBROWSER, long flags = wxHELP_NETSCAPE);
78
79 /** This must be called to tell the controller where to find the
80 documentation.
81 If a locale is set, look in file/localename, i.e.
82 If passed "/usr/local/myapp/help" and the current wxLocale is
83 set to be "de", then look in "/usr/local/myapp/help/de/"
84 first and fall back to "/usr/local/myapp/help" if that
85 doesn't exist.
86
87 @param file - NOT a filename, but a directory name.
88 @return true on success
89 */
90 virtual bool Initialize(const wxString& dir, int WXUNUSED(server))
91 { return Initialize(dir); }
92
93 /** This must be called to tell the controller where to find the
94 documentation.
95 If a locale is set, look in file/localename, i.e.
96 If passed "/usr/local/myapp/help" and the current wxLocale is
97 set to be "de", then look in "/usr/local/myapp/help/de/"
98 first and fall back to "/usr/local/myapp/help" if that
99 doesn't exist.
100 @param dir - directory name where to fine the help files
101 @return true on success
102 */
103 virtual bool Initialize(const wxString& dir);
104
105 /** If file is "", reloads file given in Initialize.
106 @file Name of help directory.
107 @return true on success
108 */
109 virtual bool LoadFile(const wxString& file = wxEmptyString);
110
111 /** Display list of all help entries.
112 @return true on success
113 */
114 virtual bool DisplayContents(void);
115 /** Display help for id sectionNo.
116 @return true on success
117 */
118 virtual bool DisplaySection(int sectionNo);
119 /** Display help for id sectionNo -- identical with DisplaySection().
120 @return true on success
121 */
122 virtual bool DisplaySection(const wxString& section);
123 /** Display help for URL (using DisplayHelp) or keyword (using KeywordSearch)
124 @return true on success
125 */
126 virtual bool DisplayBlock(long blockNo);
127 /** Search comment/documentation fields in map file and present a
128 list to chose from.
129 @key k string to search for, empty string will list all entries
130 @return true on success
131 */
132 virtual bool KeywordSearch(const wxString& k,
133 wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
134
135 /// does nothing
136 virtual bool Quit(void);
137 /// does nothing
138 virtual void OnQuit(void);
139
140 /// Call the browser using a relative URL.
141 virtual bool DisplayHelp(const wxString &) ;
142
143 /// Allows one to override the default settings for the help frame.
144 virtual void SetFrameParameters(const wxString& WXUNUSED(title),
145 const wxSize& WXUNUSED(size),
146 const wxPoint& WXUNUSED(pos) = wxDefaultPosition,
147 bool WXUNUSED(newFrameEachTime) = false)
148 {
149 // does nothing by default
150 }
151 /// Obtains the latest settings used by the help frame and the help
152 /// frame.
153 virtual wxFrame *GetFrameParameters(wxSize *WXUNUSED(size) = NULL,
154 wxPoint *WXUNUSED(pos) = NULL,
155 bool *WXUNUSED(newFrameEachTime) = NULL)
156 {
157 return (wxFrame*) NULL;// does nothing by default
158 }
159
160 protected:
161 /// Filename of currently active map file.
162 wxString m_MapFile;
163 /// How many entries do we have in the map file?
164 int m_NumOfEntries;
165 /// A list containing all id,url,documentation triples.
166 wxList *m_MapList;
167 /// Deletes the list and all objects.
168 void DeleteList(void);
169
170 private:
171 /// How to call the html viewer.
172 wxString m_BrowserName;
173 /// Is the viewer a variant of netscape?
174 bool m_BrowserIsNetscape;
175 };
176
177 #endif // wxUSE_HELP
178
179 #endif // __WX_HELPEXT_H_