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