]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: html/helpctrl.h | |
3 | // Purpose: interface of wxHtmlHelpController | |
4 | // Author: wxWidgets team | |
5 | // Licence: wxWindows licence | |
6 | ///////////////////////////////////////////////////////////////////////////// | |
7 | ||
8 | #define wxID_HTML_HELPFRAME (wxID_HIGHEST + 1) | |
9 | ||
10 | /// This style indicates that the window is | |
11 | /// embedded in the application and must not be | |
12 | /// destroyed by the help controller. | |
13 | #define wxHF_EMBEDDED 0x00008000 | |
14 | ||
15 | /// Create a dialog for the help window. | |
16 | #define wxHF_DIALOG 0x00010000 | |
17 | ||
18 | /// Create a frame for the help window. | |
19 | #define wxHF_FRAME 0x00020000 | |
20 | ||
21 | /// Make the dialog modal when displaying help. | |
22 | #define wxHF_MODAL 0x00040000 | |
23 | ||
24 | ||
25 | ||
26 | /** | |
27 | @class wxHtmlHelpController | |
28 | ||
29 | This help controller provides an easy way of displaying HTML help in your | |
30 | application (see @sample{html}, test example). | |
31 | ||
32 | The help system is based on @b books (see wxHtmlHelpController::AddBook). | |
33 | A book is a logical section of documentation (for example "User's Guide" or | |
34 | "Programmer's Guide" or "C++ Reference" or "wxWidgets Reference"). | |
35 | The help controller can handle as many books as you want. | |
36 | ||
37 | Although this class has an API compatible with other wxWidgets help controllers | |
38 | as documented by wxHelpController, it is recommended that you use the enhanced | |
39 | capabilities of wxHtmlHelpController's API. | |
40 | ||
41 | wxHTML uses Microsoft's HTML Help Workshop project files (.hhp, .hhk, .hhc) as | |
42 | its native format. The file format is described in @ref overview_html_helpformats. | |
43 | The directory @c helpfiles in the @sample{html} contains sample project files. | |
44 | ||
45 | Note that the Microsoft's HTML Help Workshop | |
46 | (http://www.microsoft.com/downloads/details.aspx?FamilyID=00535334-c8a6-452f-9aa0-d597d16580cc) | |
47 | also runs on other platforms using WINE (http://www.winehq.org/) and it can | |
48 | be used to create the .hpp, .hhk and .hhc files through a friendly GUI. | |
49 | The commercial tool HelpBlocks (http://www.helpblocks.com) can also create these files. | |
50 | ||
51 | @library{wxhtml} | |
52 | @category{help,html} | |
53 | ||
54 | @see wxBestHelpController, wxHtmlHelpFrame, wxHtmlHelpDialog, | |
55 | wxHtmlHelpWindow, wxHtmlModalHelp | |
56 | */ | |
57 | class wxHtmlHelpController : public wxHelpControllerBase | |
58 | { | |
59 | public: | |
60 | /** | |
61 | Constructor. | |
62 | ||
63 | @param style | |
64 | This is a combination of these flags: | |
65 | - wxHF_TOOLBAR: The help window has a toolbar. | |
66 | - wxHF_FLAT_TOOLBAR: The help window has a toolbar with flat buttons (aka coolbar). | |
67 | - wxHF_CONTENTS: The help window has a contents panel. | |
68 | - wxHF_INDEX: The help window has an index panel. | |
69 | - wxHF_SEARCH: The help window has a search panel. | |
70 | - wxHF_BOOKMARKS: The help window has bookmarks controls. | |
71 | - wxHF_OPEN_FILES: Allows user to open arbitrary HTML document. | |
72 | - wxHF_PRINT: The toolbar contains "print" button. | |
73 | - wxHF_MERGE_BOOKS: The contents pane does not show book nodes. | |
74 | All books are merged together and appear as single book to the user. | |
75 | - wxHF_ICONS_BOOK: All nodes in contents pane have a book icon. | |
76 | This is how Microsoft's HTML help viewer behaves. | |
77 | - wxHF_ICONS_FOLDER: Book nodes in contents pane have a book icon, book's | |
78 | sections have a folder icon. This is the default. | |
79 | - wxHF_ICONS_BOOK_CHAPTER: Both book nodes and nodes of top-level | |
80 | sections of a book (i.e. chapters) have a book icon, all other sections | |
81 | (sections, subsections, ...) have a folder icon. | |
82 | - wxHF_EMBEDDED: Specifies that the help controller controls an embedded | |
83 | window of class wxHtmlHelpWindow that should not be destroyed when | |
84 | the controller is destroyed. | |
85 | - wxHF_DIALOG: Specifies that the help controller should create a | |
86 | dialog containing the help window. | |
87 | - wxHF_FRAME: Specifies that the help controller should create a frame | |
88 | containing the help window. | |
89 | This is the default if neither wxHF_DIALOG nor wxHF_EMBEDDED is specified. | |
90 | - wxHF_MODAL: Specifies that the help controller should create a modal | |
91 | dialog containing the help window (used with the wxHF_DIALOG style). | |
92 | - wxHF_DEFAULT_STYLE: wxHF_TOOLBAR | wxHF_CONTENTS | wxHF_INDEX | | |
93 | wxHF_SEARCH | wxHF_BOOKMARKS | wxHF_PRINT | |
94 | @param parentWindow | |
95 | This is an optional window to be used as the parent for the help window. | |
96 | */ | |
97 | wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE, | |
98 | wxWindow* parentWindow = NULL); | |
99 | wxHtmlHelpController(wxWindow* parentWindow, int style = wxHF_DEFAULT_STYLE); | |
100 | ||
101 | ||
102 | /** | |
103 | Adds a book (i.e. a @ref overview_html_helpformats ".hhp file"; an HTML Help | |
104 | Workshop project file) into the list of loaded books. | |
105 | ||
106 | This must be called at least once before displaying any help. | |
107 | @a bookFile or @a bookUrl may be either @c ".hhp" file or a ZIP archive | |
108 | that contains an arbitrary number of @c ".hhp" files in its top-level | |
109 | directory. | |
110 | This ZIP archive must have @c ".zip" or @c ".htb" extension (the latter | |
111 | stands for "HTML book"). In other words, | |
112 | @code | |
113 | AddBook(wxFileName("help.zip")) | |
114 | @endcode | |
115 | is possible and is the recommended way. | |
116 | ||
117 | @param bookFile | |
118 | Help book filename. It is recommended to use this prototype | |
119 | instead of the one taking URL, because it is less error-prone. | |
120 | @param showWaitMsg | |
121 | If @true then a decoration-less window with progress message is displayed. | |
122 | */ | |
123 | bool AddBook(const wxFileName& bookFile, bool showWaitMsg = false); | |
124 | ||
125 | /** | |
126 | Adds a book (i.e. a @ref overview_html_helpformats ".hhp file"; an HTML Help | |
127 | Workshop project file) into the list of loaded books. | |
128 | ||
129 | See the other overload for additional info. | |
130 | ||
131 | @param bookUrl | |
132 | Help book URL (note that syntax of filename and URL is | |
133 | different on most platforms). | |
134 | @param showWaitMsg | |
135 | If @true then a decoration-less window with progress message is displayed. | |
136 | */ | |
137 | bool AddBook(const wxString& bookUrl, bool showWaitMsg = false); | |
138 | ||
139 | /** | |
140 | Displays page @a x. | |
141 | This is THE important function - it is used to display the help in application. | |
142 | You can specify the page in many ways: | |
143 | - as direct filename of HTML document | |
144 | - as chapter name (from contents) or as a book name | |
145 | - as some word from index | |
146 | - even as any word (will be searched) | |
147 | ||
148 | Looking for the page runs in these steps: | |
149 | -# try to locate file named x (if x is for example "doc/howto.htm") | |
150 | -# try to open starting page of book named x | |
151 | -# try to find x in contents (if x is for example "How To ...") | |
152 | -# try to find x in index (if x is for example "How To ...") | |
153 | -# switch to Search panel and start searching | |
154 | */ | |
155 | bool Display(const wxString& x); | |
156 | ||
157 | /** | |
158 | @overload | |
159 | ||
160 | This alternative form is used to search help contents by numeric IDs. | |
161 | */ | |
162 | bool Display(int id); | |
163 | ||
164 | /** | |
165 | Displays help window and focuses contents panel. | |
166 | */ | |
167 | virtual bool DisplayContents(); | |
168 | ||
169 | /** | |
170 | Displays help window and focuses index panel. | |
171 | */ | |
172 | bool DisplayIndex(); | |
173 | ||
174 | /** | |
175 | Displays the help window, focuses search panel and starts searching. | |
176 | Returns @true if the keyword was found. Optionally it searches through the | |
177 | index (mode = @c wxHELP_SEARCH_INDEX), default the content | |
178 | (mode = @c wxHELP_SEARCH_ALL). | |
179 | ||
180 | @note | |
181 | KeywordSearch() searches only pages listed in @c ".hhc" file(s). | |
182 | You should list all pages in the contents file. | |
183 | */ | |
184 | virtual bool KeywordSearch(const wxString& keyword, | |
185 | wxHelpSearchMode mode = wxHELP_SEARCH_ALL); | |
186 | ||
187 | /** | |
188 | Reads the controller's setting (position of window, etc.) | |
189 | */ | |
190 | virtual void ReadCustomization(wxConfigBase* cfg, | |
191 | const wxString& path = wxEmptyString); | |
192 | ||
193 | /** | |
194 | Sets whether the help frame should prevent application from exiting | |
195 | if it's the only remaining top level window. | |
196 | ||
197 | @param enable | |
198 | If @true, the application will not quit unless the help frame is | |
199 | closed. Default is @false, i.e. the application does exit if only | |
200 | the help window remains opened. | |
201 | ||
202 | @see wxApp::SetExitOnFrameDelete() | |
203 | ||
204 | @since 2.9.2 | |
205 | */ | |
206 | void SetShouldPreventAppExit(bool enable); | |
207 | ||
208 | /** | |
209 | Sets the path for storing temporary files - cached binary versions of index and | |
210 | contents files. | |
211 | ||
212 | These binary forms are much faster to read. Default value is empty string | |
213 | (empty string means that no cached data are stored). Note that these files | |
214 | are @e not deleted when program exits. | |
215 | ||
216 | Once created these cached files will be used in all subsequent executions | |
217 | of your application. If cached files become older than corresponding @c ".hhp" | |
218 | file (e.g. if you regenerate documentation) it will be refreshed. | |
219 | */ | |
220 | void SetTempDir(const wxString& path); | |
221 | ||
222 | /** | |
223 | Sets format of title of the frame. | |
224 | Must contain exactly one "%s" (for title of displayed HTML page). | |
225 | */ | |
226 | void SetTitleFormat(const wxString& format); | |
227 | ||
228 | /** | |
229 | Associates the @a config object with the controller. | |
230 | ||
231 | If there is associated config object, wxHtmlHelpController automatically | |
232 | reads and writes settings (including wxHtmlWindow's settings) when needed. | |
233 | The only thing you must do is create wxConfig object and call UseConfig(). | |
234 | ||
235 | If you do not use UseConfig(), wxHtmlHelpController will use the default | |
236 | wxConfig object if available (for details see wxConfigBase::Get and | |
237 | wxConfigBase::Set). | |
238 | */ | |
239 | void UseConfig(wxConfigBase* config, | |
240 | const wxString& rootpath = wxEmptyString); | |
241 | ||
242 | /** | |
243 | Stores controllers setting (position of window etc.) | |
244 | */ | |
245 | virtual void WriteCustomization(wxConfigBase* cfg, | |
246 | const wxString& path = wxEmptyString); | |
247 | ||
248 | /** | |
249 | Get the current help window | |
250 | */ | |
251 | wxHtmlHelpWindow* GetHelpWindow(); | |
252 | ||
253 | /** | |
254 | Set the help window to be managed by this controller. This makes it | |
255 | possible to have a help window that might not be in a wxHtmlHelpFrame or | |
256 | dialog but is embedded in some other window in the application. Be sure | |
257 | to use the wxHF_EMBEDDED style in this case. | |
258 | */ | |
259 | void SetHelpWindow(wxHtmlHelpWindow* helpWindow); | |
260 | ||
261 | /** | |
262 | Returns the current help frame. (May be NULL.) | |
263 | */ | |
264 | wxHtmlHelpFrame* GetFrame(); | |
265 | ||
266 | /** | |
267 | Returns the current help dialog. (May be NULL.) | |
268 | */ | |
269 | wxHtmlHelpDialog* GetDialog(); | |
270 | ||
271 | ||
272 | ||
273 | protected: | |
274 | ||
275 | /** | |
276 | This protected virtual method may be overridden so that when specifying the | |
277 | @c wxHF_DIALOG style, the controller uses a different dialog. | |
278 | */ | |
279 | virtual wxHtmlHelpDialog* CreateHelpDialog(wxHtmlHelpData* data); | |
280 | ||
281 | /** | |
282 | This protected virtual method may be overridden so that the controller | |
283 | uses a different frame. | |
284 | */ | |
285 | virtual wxHtmlHelpFrame* CreateHelpFrame(wxHtmlHelpData* data); | |
286 | }; | |
287 | ||
288 | ||
289 | ||
290 | /** | |
291 | @class wxHtmlModalHelp | |
292 | ||
293 | This class uses wxHtmlHelpController to display help in a modal dialog. | |
294 | This is useful on platforms such as wxMac where if you display help from a | |
295 | modal dialog, the help window must itself be a modal dialog. | |
296 | ||
297 | Create objects of this class on the stack, for example: | |
298 | ||
299 | @code | |
300 | // The help can be browsed during the lifetime of this object; when the | |
301 | // user quits the help, program execution will continue. | |
302 | wxHtmlModalHelp help(parent, "help", "My topic"); | |
303 | @endcode | |
304 | ||
305 | @library{wxhtml} | |
306 | @category{help,html} | |
307 | */ | |
308 | class wxHtmlModalHelp | |
309 | { | |
310 | public: | |
311 | /** | |
312 | The ctor. | |
313 | ||
314 | @param parent | |
315 | is the parent of the dialog. | |
316 | @param helpFile | |
317 | is the HTML help file to show. | |
318 | @param topic | |
319 | is an optional topic. If this is empty, the help contents will be shown. | |
320 | @param style | |
321 | is a combination of the flags described in the wxHtmlHelpController | |
322 | documentation. | |
323 | */ | |
324 | wxHtmlModalHelp(wxWindow* parent, const wxString& helpFile, | |
325 | const wxString& topic = wxEmptyString, | |
326 | int style = wxHF_DEFAULT_STYLE | wxHF_DIALOG | wxHF_MODAL); | |
327 | }; | |
328 |