]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/helphtml.h
Added wxHelpControllerHtml, derived from wxHtmlHelpControllerBase. API like
[wxWidgets.git] / include / wx / generic / helphtml.h
1 /*-*- c++ -*-********************************************************
2 * helphtml.h - base class for html based help controllers *
3 * *
4 * (C) 1999 by Karsten Ballüder (Ballueder@usa.net) *
5 * *
6 * $Id$
7 *******************************************************************/
8
9 #ifndef __WX_HELPHTML_H_
10 #define __WX_HELPHTML_H_
11
12 #if wxUSE_HELP
13
14 #ifdef __GNUG__
15 # pragma interface "helphtml.h"
16 #endif
17
18 #include "wx/helpbase.h"
19
20 /// Name for map file.
21 #define WXEXTHELP_MAPFILE "wxhelp.map"
22 /// Path separator.
23 #ifdef __WXMSW__
24 #define WXEXTHELP_SEPARATOR '\\'
25 #else
26 #define WXEXTHELP_SEPARATOR '/'
27 #endif
28 /// Maximum line length in map file.
29 #define WXEXTHELP_BUFLEN 512
30 /// Character introducing comments/documentation field in map file.
31 #define WXEXTHELP_COMMENTCHAR ';'
32
33 class WXDLLEXPORT wxExtHelpMapList;
34
35
36 /**
37 This class is the base class for all html help implementations.
38 It requires the name of a directory containing the documentation
39 and a file mapping numerical Section numbers to relative URLS.
40
41 The map file contains two or three fields per line:
42 numeric_id relative_URL [; comment/documentation]
43
44 The numeric_id is the id used to look up the entry in
45 DisplaySection()/DisplayBlock(). The relative_URL is a filename of
46 an html file, relative to the help directory. The optional
47 comment/documentation field (after a ';') is used for keyword
48 searches, so some meaningful text here does not hurt.
49 If the documentation itself contains a ';', only the part before
50 that will be displayed in the listbox, but all of it used for search.
51
52 Lines starting with ';' will be ignored.
53 */
54
55 class WXDLLEXPORT wxHTMLHelpControllerBase : public wxHelpControllerBase
56 {
57 DECLARE_ABSTRACT_CLASS(wxHTMLHelpControllerBase)
58 public:
59 wxHTMLHelpControllerBase(void);
60 virtual ~wxHTMLHelpControllerBase(void);
61
62 /** This must be called to tell the controller where to find the
63 documentation.
64 If a locale is set, look in file/localename, i.e.
65 If passed "/usr/local/myapp/help" and the current wxLocale is
66 set to be "de", then look in "/usr/local/myapp/help/de/"
67 first and fall back to "/usr/local/myapp/help" if that
68 doesn't exist.
69
70 @param file - NOT a filename, but a directory name.
71 @return true on success
72 */
73 virtual bool Initialize(const wxString& dir, int WXUNUSED(server))
74 { return Initialize(dir); }
75
76 /** This must be called to tell the controller where to find the
77 documentation.
78 If a locale is set, look in file/localename, i.e.
79 If passed "/usr/local/myapp/help" and the current wxLocale is
80 set to be "de", then look in "/usr/local/myapp/help/de/"
81 first and fall back to "/usr/local/myapp/help" if that
82 doesn't exist.
83 @param dir - directory name where to fine the help files
84 @return true on success
85 */
86 virtual bool Initialize(const wxString& dir);
87
88 /** If file is "", reloads file given in Initialize.
89 @file Name of help directory.
90 @return true on success
91 */
92 virtual bool LoadFile(const wxString& file = "");
93
94 /** Display list of all help entries.
95 @return true on success
96 */
97 virtual bool DisplayContents(void);
98 /** Display help for id sectionNo.
99 @return true on success
100 */
101 virtual bool DisplaySection(int sectionNo);
102 /** Display help for id sectionNo -- identical with DisplaySection().
103 @return true on success
104 */
105 virtual bool DisplayBlock(long blockNo);
106 /** Search comment/documentation fields in map file and present a
107 list to chose from.
108 @key k string to search for, empty string will list all entries
109 @return true on success
110 */
111 virtual bool KeywordSearch(const wxString& k);
112
113 /// does nothing
114 virtual bool Quit(void);
115 /// does nothing
116 virtual void OnQuit(void);
117
118 /// Call the browser using a relative URL.
119 virtual bool DisplayHelp(wxString const &) = 0;
120
121 /// Allows one to override the default settings for the help frame.
122 virtual void SetFrameParameters(const wxString &title,
123 const wxSize &size,
124 const wxPoint &pos = wxDefaultPosition,
125 bool newFrameEachTime = FALSE)
126 {
127 // does nothing by default
128 }
129 /// Obtains the latest settings used by the help frame.
130 virtual void GetFrameParameters(wxSize *size = NULL,
131 wxPoint *pos = NULL,
132 bool *newFrameEachTime = NULL)
133 {
134 // does nothing by default
135 }
136
137 protected:
138 /// Filename of currently active map file.
139 wxString m_MapFile;
140 /// How many entries do we have in the map file?
141 int m_NumOfEntries;
142 /// A list containing all id,url,documentation triples.
143 wxList *m_MapList;
144 /// Deletes the list and all objects.
145 void DeleteList(void);
146 };
147
148 #endif // wxUSE_HELP
149
150 #endif // __WX_HELPHTML_H_