]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/helpext.h
Added wxExtHelpController: wxHelpController implementation for external
[wxWidgets.git] / include / wx / generic / helpext.h
1 /*-*- c++ -*-********************************************************
2 * exthlp.h - an external help controller for wxWindows *
3 * *
4 * (C) 1998 by Karsten Ballüder (Ballueder@usa.net) *
5 * *
6 * $Id$
7 *******************************************************************/
8 #ifndef WXXHELP_H
9 #define WXXHELP_H
10
11 #if wxUSE_HELP
12
13 #ifdef __GNUG__
14 # pragma interface "wxexthlp.h"
15 #endif
16
17 /// Name for map file.
18 #define WXEXTHELP_MAPFILE "wxhelp.map"
19 /// Path separator.
20 #define WXEXTHELP_SEPARATOR '/'
21 #ifndef WXEXTHELP_DEFAULTBROWSER
22 /// Default browser name.
23 # define WXEXTHELP_DEFAULTBROWSER "kdehelp"
24 /// Is default browse a variant of netscape?
25 # define WXEXTHELP_DEFAULTBROWSER_IS_NETSCAPE false
26 #endif
27 /// Name of environment variable to set help browser.
28 #define WXEXTHELP_ENVVAR_BROWSER "WX_HELPBROWSER"
29 /// Is browser a netscape browser?
30 #define WXEXTHELP_ENVVAR_BROWSERISNETSCAPE "WX_HELPBROWSER_NS"
31 /// Maximum line length in map file.
32 #define WXEXTHELP_BUFLEN 512
33 /// Character introducing comments/documentation field in map file.
34 #define WXEXTHELP_COMMENTCHAR ';'
35
36 class wxExtHelpMapList;
37
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 wxExtHelpController : public wxHelpControllerBase
59 {
60 DECLARE_CLASS(wxExtHelpController)
61 public:
62 wxExtHelpController(void);
63 virtual ~wxExtHelpController(void);
64
65 /** This must be called to tell the controller where to find the
66 documentation.
67 @param file - NOT a filename, but a directory name.
68 @return true on success
69 */
70 virtual bool Initialize(const wxString& file, int WXUNUSED(server))
71 { return Initialize(file); }
72
73 /** This must be called to tell the controller where to find the
74 documentation.
75 @param file - NOT a filename, but a directory name.
76 @return true on success
77 */
78 virtual bool Initialize(const wxString& file);
79
80 /** If file is "", reloads file given in Initialize.
81 @file Name of help directory.
82 @return true on success
83 */
84 virtual bool LoadFile(const wxString& file = "");
85
86 /** Display list of all help entries.
87 @return true on success
88 */
89 virtual bool DisplayContents(void);
90 /** Display help for id sectionNo.
91 @return true on success
92 */
93 virtual bool DisplaySection(int sectionNo);
94 /** Display help for id sectionNo -- identical with DisplaySection().
95 @return true on success
96 */
97 virtual bool DisplayBlock(long blockNo);
98 /** Search comment/documentation fields in map file and present a
99 list to chose from.
100 @key k string to search for, empty string will list all entries
101 @return true on success
102 */
103 virtual bool KeywordSearch(const wxString& k);
104
105 /// does nothing
106 virtual bool Quit(void);
107 /// does nothing
108 virtual void OnQuit(void);
109
110 /** Tell it which browser to use.
111 The Netscape support will check whether Netscape is already
112 running (by looking at the .netscape/lock file in the user's
113 home directory) and tell it to load the page into the existing
114 window.
115 @param browsername The command to call a browser/html viewer.
116 @param isNetscape Set this to TRUE if the browser is some variant of Netscape.
117 */
118 void SetBrowser(wxString const & browsername = WXEXTHELP_DEFAULTBROWSER,
119 bool isNetscape = WXEXTHELP_DEFAULTBROWSER_IS_NETSCAPE);
120 private:
121 /// Filename of currently active map file.
122 wxString m_MapFile;
123 /// How many entries do we have in the map file?
124 int m_NumOfEntries;
125 /// A list containing all id,url,documentation triples.
126 wxExtHelpMapList *m_MapList;
127 /// How to call the html viewer.
128 wxString m_BrowserName;
129 /// Is the viewer a variant of netscape?
130 bool m_BrowserIsNetscape;
131 /// Call the browser using a relative URL.
132 bool CallBrowser(wxString const &);
133 };
134
135 #endif
136 #endif