]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: html/helpctrl.h | |
e54c96f1 | 3 | // Purpose: interface of wxHtmlHelpController |
23324ae1 | 4 | // Author: wxWidgets team |
526954c5 | 5 | // Licence: wxWindows licence |
23324ae1 FM |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
90f011dc RD |
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 | ||
23324ae1 FM |
26 | /** |
27 | @class wxHtmlHelpController | |
7c913512 | 28 | |
23324ae1 | 29 | This help controller provides an easy way of displaying HTML help in your |
c87f263e | 30 | application (see @sample{html}, test example). |
7c913512 | 31 | |
c87f263e FM |
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. | |
7c913512 | 40 | |
23324ae1 | 41 | wxHTML uses Microsoft's HTML Help Workshop project files (.hhp, .hhk, .hhc) as |
c87f263e FM |
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. | |
7c913512 | 44 | |
c87f263e FM |
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. | |
7c913512 | 50 | |
23324ae1 | 51 | @library{wxhtml} |
c87f263e | 52 | @category{help,html} |
7c913512 | 53 | |
c87f263e FM |
54 | @see wxBestHelpController, wxHtmlHelpFrame, wxHtmlHelpDialog, |
55 | wxHtmlHelpWindow, wxHtmlModalHelp | |
23324ae1 | 56 | */ |
848a90b1 | 57 | class wxHtmlHelpController : public wxHelpControllerBase |
23324ae1 FM |
58 | { |
59 | public: | |
60 | /** | |
61 | Constructor. | |
c87f263e FM |
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. | |
23324ae1 FM |
96 | */ |
97 | wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE, | |
4cc4bfaf | 98 | wxWindow* parentWindow = NULL); |
895c1bc0 RD |
99 | wxHtmlHelpController(wxWindow* parentWindow, int style = wxHF_DEFAULT_STYLE); |
100 | ||
23324ae1 | 101 | |
23324ae1 | 102 | /** |
c87f263e FM |
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 | |
7c913512 | 113 | AddBook(wxFileName("help.zip")) |
c87f263e | 114 | @endcode |
23324ae1 | 115 | is possible and is the recommended way. |
c87f263e | 116 | |
7c913512 | 117 | @param bookFile |
4cc4bfaf FM |
118 | Help book filename. It is recommended to use this prototype |
119 | instead of the one taking URL, because it is less error-prone. | |
c87f263e FM |
120 | @param showWaitMsg |
121 | If @true then a decoration-less window with progress message is displayed. | |
122 | */ | |
a44f3b5a | 123 | bool AddBook(const wxFileName& bookFile, bool showWaitMsg = false); |
c87f263e FM |
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 | ||
7c913512 | 131 | @param bookUrl |
4cc4bfaf | 132 | Help book URL (note that syntax of filename and URL is |
c87f263e FM |
133 | different on most platforms). |
134 | @param showWaitMsg | |
135 | If @true then a decoration-less window with progress message is displayed. | |
23324ae1 | 136 | */ |
a44f3b5a | 137 | bool AddBook(const wxString& bookUrl, bool showWaitMsg = false); |
23324ae1 | 138 | |
23324ae1 | 139 | /** |
c87f263e FM |
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 | |
23324ae1 | 154 | */ |
a44f3b5a | 155 | bool Display(const wxString& x); |
c87f263e FM |
156 | |
157 | /** | |
158 | @overload | |
159 | ||
160 | This alternative form is used to search help contents by numeric IDs. | |
161 | */ | |
a44f3b5a | 162 | bool Display(int id); |
23324ae1 FM |
163 | |
164 | /** | |
165 | Displays help window and focuses contents panel. | |
166 | */ | |
5267aefd | 167 | virtual bool DisplayContents(); |
23324ae1 FM |
168 | |
169 | /** | |
170 | Displays help window and focuses index panel. | |
171 | */ | |
5267aefd | 172 | bool DisplayIndex(); |
23324ae1 FM |
173 | |
174 | /** | |
c87f263e FM |
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. | |
23324ae1 | 183 | */ |
fadc2df6 FM |
184 | virtual bool KeywordSearch(const wxString& keyword, |
185 | wxHelpSearchMode mode = wxHELP_SEARCH_ALL); | |
23324ae1 FM |
186 | |
187 | /** | |
188 | Reads the controller's setting (position of window, etc.) | |
189 | */ | |
5267aefd FM |
190 | virtual void ReadCustomization(wxConfigBase* cfg, |
191 | const wxString& path = wxEmptyString); | |
23324ae1 | 192 | |
bd45b3e1 VZ |
193 | /** |
194 | Sets whether the help frame should prevent application from exiting | |
195 | if it's the only remaining top level window. | |
196 | ||
f54c646f | 197 | @param enable |
bd45b3e1 VZ |
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 | ||
23324ae1 FM |
208 | /** |
209 | Sets the path for storing temporary files - cached binary versions of index and | |
c87f263e FM |
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 | ||
7c913512 | 216 | Once created these cached files will be used in all subsequent executions |
c87f263e | 217 | of your application. If cached files become older than corresponding @c ".hhp" |
23324ae1 FM |
218 | file (e.g. if you regenerate documentation) it will be refreshed. |
219 | */ | |
220 | void SetTempDir(const wxString& path); | |
221 | ||
222 | /** | |
c87f263e FM |
223 | Sets format of title of the frame. |
224 | Must contain exactly one "%s" (for title of displayed HTML page). | |
23324ae1 FM |
225 | */ |
226 | void SetTitleFormat(const wxString& format); | |
227 | ||
228 | /** | |
c87f263e FM |
229 | Associates the @a config object with the controller. |
230 | ||
23324ae1 FM |
231 | If there is associated config object, wxHtmlHelpController automatically |
232 | reads and writes settings (including wxHtmlWindow's settings) when needed. | |
c87f263e FM |
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 | |
23324ae1 FM |
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 | */ | |
5267aefd FM |
245 | virtual void WriteCustomization(wxConfigBase* cfg, |
246 | const wxString& path = wxEmptyString); | |
5e6e278d | 247 | |
90f011dc RD |
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 | ||
5e6e278d FM |
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); | |
23324ae1 FM |
286 | }; |
287 | ||
288 | ||
e54c96f1 | 289 | |
23324ae1 FM |
290 | /** |
291 | @class wxHtmlModalHelp | |
7c913512 | 292 | |
c87f263e FM |
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. | |
7c913512 | 296 | |
23324ae1 | 297 | Create objects of this class on the stack, for example: |
7c913512 | 298 | |
23324ae1 | 299 | @code |
c87f263e FM |
300 | // The help can be browsed during the lifetime of this object; when the |
301 | // user quits the help, program execution will continue. | |
f8ebb70d | 302 | wxHtmlModalHelp help(parent, "help", "My topic"); |
23324ae1 | 303 | @endcode |
7c913512 | 304 | |
23324ae1 | 305 | @library{wxhtml} |
c87f263e | 306 | @category{help,html} |
23324ae1 | 307 | */ |
7c913512 | 308 | class wxHtmlModalHelp |
23324ae1 FM |
309 | { |
310 | public: | |
311 | /** | |
c87f263e FM |
312 | The ctor. |
313 | ||
7c913512 | 314 | @param parent |
4cc4bfaf | 315 | is the parent of the dialog. |
7c913512 | 316 | @param helpFile |
4cc4bfaf | 317 | is the HTML help file to show. |
7c913512 | 318 | @param topic |
4cc4bfaf | 319 | is an optional topic. If this is empty, the help contents will be shown. |
7c913512 | 320 | @param style |
4cc4bfaf | 321 | is a combination of the flags described in the wxHtmlHelpController |
c87f263e | 322 | documentation. |
23324ae1 FM |
323 | */ |
324 | wxHtmlModalHelp(wxWindow* parent, const wxString& helpFile, | |
325 | const wxString& topic = wxEmptyString, | |
326 | int style = wxHF_DEFAULT_STYLE | wxHF_DIALOG | wxHF_MODAL); | |
327 | }; | |
e54c96f1 | 328 |