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