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