2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: html/helpctrl.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxHtmlHelpController
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxHtmlHelpController
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This help controller provides an easy way of displaying HTML help in your
|
2008-10-23 09:55:07 -04:00
|
|
|
application (see @sample{html}, test example).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-23 09:55:07 -04:00
|
|
|
The help system is based on @b books (see wxHtmlHelpController::AddBook).
|
|
|
|
A book is a logical section of documentation (for example "User's Guide" or
|
|
|
|
"Programmer's Guide" or "C++ Reference" or "wxWidgets Reference").
|
|
|
|
The help controller can handle as many books as you want.
|
|
|
|
|
|
|
|
Although this class has an API compatible with other wxWidgets help controllers
|
|
|
|
as documented by wxHelpController, it is recommended that you use the enhanced
|
|
|
|
capabilities of wxHtmlHelpController's API.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxHTML uses Microsoft's HTML Help Workshop project files (.hhp, .hhk, .hhc) as
|
2008-10-23 09:55:07 -04:00
|
|
|
its native format. The file format is described in @ref overview_html_helpformats.
|
|
|
|
The directory @c helpfiles in the @sample{html} contains sample project files.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-23 09:55:07 -04:00
|
|
|
Note that the Microsoft's HTML Help Workshop
|
|
|
|
(http://www.microsoft.com/downloads/details.aspx?FamilyID=00535334-c8a6-452f-9aa0-d597d16580cc)
|
|
|
|
also runs on other platforms using WINE (http://www.winehq.org/) and it can
|
|
|
|
be used to create the .hpp, .hhk and .hhc files through a friendly GUI.
|
|
|
|
The commercial tool HelpBlocks (http://www.helpblocks.com) can also create these files.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxhtml}
|
2008-10-23 09:55:07 -04:00
|
|
|
@category{help,html}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-23 09:55:07 -04:00
|
|
|
@see wxBestHelpController, wxHtmlHelpFrame, wxHtmlHelpDialog,
|
|
|
|
wxHtmlHelpWindow, wxHtmlModalHelp
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxHtmlHelpController
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
2008-10-23 09:55:07 -04:00
|
|
|
|
|
|
|
@param style
|
|
|
|
This is a combination of these flags:
|
|
|
|
- wxHF_TOOLBAR: The help window has a toolbar.
|
|
|
|
- wxHF_FLAT_TOOLBAR: The help window has a toolbar with flat buttons (aka coolbar).
|
|
|
|
- wxHF_CONTENTS: The help window has a contents panel.
|
|
|
|
- wxHF_INDEX: The help window has an index panel.
|
|
|
|
- wxHF_SEARCH: The help window has a search panel.
|
|
|
|
- wxHF_BOOKMARKS: The help window has bookmarks controls.
|
|
|
|
- wxHF_OPEN_FILES: Allows user to open arbitrary HTML document.
|
|
|
|
- wxHF_PRINT: The toolbar contains "print" button.
|
|
|
|
- wxHF_MERGE_BOOKS: The contents pane does not show book nodes.
|
|
|
|
All books are merged together and appear as single book to the user.
|
|
|
|
- wxHF_ICONS_BOOK: All nodes in contents pane have a book icon.
|
|
|
|
This is how Microsoft's HTML help viewer behaves.
|
|
|
|
- wxHF_ICONS_FOLDER: Book nodes in contents pane have a book icon, book's
|
|
|
|
sections have a folder icon. This is the default.
|
|
|
|
- wxHF_ICONS_BOOK_CHAPTER: Both book nodes and nodes of top-level
|
|
|
|
sections of a book (i.e. chapters) have a book icon, all other sections
|
|
|
|
(sections, subsections, ...) have a folder icon.
|
|
|
|
- wxHF_EMBEDDED: Specifies that the help controller controls an embedded
|
|
|
|
window of class wxHtmlHelpWindow that should not be destroyed when
|
|
|
|
the controller is destroyed.
|
|
|
|
- wxHF_DIALOG: Specifies that the help controller should create a
|
|
|
|
dialog containing the help window.
|
|
|
|
- wxHF_FRAME: Specifies that the help controller should create a frame
|
|
|
|
containing the help window.
|
|
|
|
This is the default if neither wxHF_DIALOG nor wxHF_EMBEDDED is specified.
|
|
|
|
- wxHF_MODAL: Specifies that the help controller should create a modal
|
|
|
|
dialog containing the help window (used with the wxHF_DIALOG style).
|
|
|
|
- wxHF_DEFAULT_STYLE: wxHF_TOOLBAR | wxHF_CONTENTS | wxHF_INDEX |
|
|
|
|
wxHF_SEARCH | wxHF_BOOKMARKS | wxHF_PRINT
|
|
|
|
@param parentWindow
|
|
|
|
This is an optional window to be used as the parent for the help window.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE,
|
2008-03-09 08:33:59 -04:00
|
|
|
wxWindow* parentWindow = NULL);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-23 09:55:07 -04:00
|
|
|
Adds a book (i.e. a @ref overview_html_helpformats ".hhp file"; an HTML Help
|
|
|
|
Workshop project file) into the list of loaded books.
|
|
|
|
|
|
|
|
This must be called at least once before displaying any help.
|
|
|
|
@a bookFile or @a bookUrl may be either @c ".hhp" file or a ZIP archive
|
|
|
|
that contains an arbitrary number of @c ".hhp" files in its top-level
|
|
|
|
directory.
|
|
|
|
This ZIP archive must have @c ".zip" or @c ".htb" extension (the latter
|
|
|
|
stands for "HTML book"). In other words,
|
|
|
|
@code
|
2008-03-08 09:43:31 -05:00
|
|
|
AddBook(wxFileName("help.zip"))
|
2008-10-23 09:55:07 -04:00
|
|
|
@endcode
|
2008-03-08 08:52:38 -05:00
|
|
|
is possible and is the recommended way.
|
2008-10-23 09:55:07 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bookFile
|
2008-03-09 08:33:59 -04:00
|
|
|
Help book filename. It is recommended to use this prototype
|
|
|
|
instead of the one taking URL, because it is less error-prone.
|
2008-10-23 09:55:07 -04:00
|
|
|
@param showWaitMsg
|
|
|
|
If @true then a decoration-less window with progress message is displayed.
|
|
|
|
*/
|
2008-11-09 11:46:52 -05:00
|
|
|
bool AddBook(const wxFileName& bookFile, bool showWaitMsg = false);
|
2008-10-23 09:55:07 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Adds a book (i.e. a @ref overview_html_helpformats ".hhp file"; an HTML Help
|
|
|
|
Workshop project file) into the list of loaded books.
|
|
|
|
|
|
|
|
See the other overload for additional info.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bookUrl
|
2008-03-09 08:33:59 -04:00
|
|
|
Help book URL (note that syntax of filename and URL is
|
2008-10-23 09:55:07 -04:00
|
|
|
different on most platforms).
|
|
|
|
@param showWaitMsg
|
|
|
|
If @true then a decoration-less window with progress message is displayed.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-11-09 11:46:52 -05:00
|
|
|
bool AddBook(const wxString& bookUrl, bool showWaitMsg = false);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-23 09:55:07 -04:00
|
|
|
Displays page @a x.
|
|
|
|
This is THE important function - it is used to display the help in application.
|
|
|
|
You can specify the page in many ways:
|
|
|
|
- as direct filename of HTML document
|
|
|
|
- as chapter name (from contents) or as a book name
|
|
|
|
- as some word from index
|
|
|
|
- even as any word (will be searched)
|
|
|
|
|
|
|
|
Looking for the page runs in these steps:
|
|
|
|
-# try to locate file named x (if x is for example "doc/howto.htm")
|
|
|
|
-# try to open starting page of book named x
|
|
|
|
-# try to find x in contents (if x is for example "How To ...")
|
|
|
|
-# try to find x in index (if x is for example "How To ...")
|
|
|
|
-# switch to Search panel and start searching
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-11-09 11:46:52 -05:00
|
|
|
bool Display(const wxString& x);
|
2008-10-23 09:55:07 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
@overload
|
|
|
|
|
|
|
|
This alternative form is used to search help contents by numeric IDs.
|
|
|
|
*/
|
2008-11-09 11:46:52 -05:00
|
|
|
bool Display(int id);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Displays help window and focuses contents panel.
|
|
|
|
*/
|
2008-10-29 11:34:31 -04:00
|
|
|
virtual bool DisplayContents();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Displays help window and focuses index panel.
|
|
|
|
*/
|
2008-10-29 11:34:31 -04:00
|
|
|
bool DisplayIndex();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-23 09:55:07 -04:00
|
|
|
Displays the help window, focuses search panel and starts searching.
|
|
|
|
Returns @true if the keyword was found. Optionally it searches through the
|
|
|
|
index (mode = @c wxHELP_SEARCH_INDEX), default the content
|
|
|
|
(mode = @c wxHELP_SEARCH_ALL).
|
|
|
|
|
|
|
|
@note
|
|
|
|
KeywordSearch() searches only pages listed in @c ".hhc" file(s).
|
|
|
|
You should list all pages in the contents file.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-27 17:26:54 -04:00
|
|
|
virtual bool KeywordSearch(const wxString& keyword,
|
|
|
|
wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Reads the controller's setting (position of window, etc.)
|
|
|
|
*/
|
2008-10-29 11:34:31 -04:00
|
|
|
virtual void ReadCustomization(wxConfigBase* cfg,
|
|
|
|
const wxString& path = wxEmptyString);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the path for storing temporary files - cached binary versions of index and
|
2008-10-23 09:55:07 -04:00
|
|
|
contents files.
|
|
|
|
|
|
|
|
These binary forms are much faster to read. Default value is empty string
|
|
|
|
(empty string means that no cached data are stored). Note that these files
|
|
|
|
are @e not deleted when program exits.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
Once created these cached files will be used in all subsequent executions
|
2008-10-23 09:55:07 -04:00
|
|
|
of your application. If cached files become older than corresponding @c ".hhp"
|
2008-03-08 08:52:38 -05:00
|
|
|
file (e.g. if you regenerate documentation) it will be refreshed.
|
|
|
|
*/
|
|
|
|
void SetTempDir(const wxString& path);
|
|
|
|
|
|
|
|
/**
|
2008-10-23 09:55:07 -04:00
|
|
|
Sets format of title of the frame.
|
|
|
|
Must contain exactly one "%s" (for title of displayed HTML page).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetTitleFormat(const wxString& format);
|
|
|
|
|
|
|
|
/**
|
2008-10-23 09:55:07 -04:00
|
|
|
Associates the @a config object with the controller.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
If there is associated config object, wxHtmlHelpController automatically
|
|
|
|
reads and writes settings (including wxHtmlWindow's settings) when needed.
|
2008-10-23 09:55:07 -04:00
|
|
|
The only thing you must do is create wxConfig object and call UseConfig().
|
|
|
|
|
|
|
|
If you do not use UseConfig(), wxHtmlHelpController will use the default
|
|
|
|
wxConfig object if available (for details see wxConfigBase::Get and
|
2008-03-08 08:52:38 -05:00
|
|
|
wxConfigBase::Set).
|
|
|
|
*/
|
|
|
|
void UseConfig(wxConfigBase* config,
|
|
|
|
const wxString& rootpath = wxEmptyString);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Stores controllers setting (position of window etc.)
|
|
|
|
*/
|
2008-10-29 11:34:31 -04:00
|
|
|
virtual void WriteCustomization(wxConfigBase* cfg,
|
|
|
|
const wxString& path = wxEmptyString);
|
2008-10-29 14:55:57 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/**
|
|
|
|
This protected virtual method may be overridden so that when specifying the
|
|
|
|
@c wxHF_DIALOG style, the controller uses a different dialog.
|
|
|
|
*/
|
|
|
|
virtual wxHtmlHelpDialog* CreateHelpDialog(wxHtmlHelpData* data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
This protected virtual method may be overridden so that the controller
|
|
|
|
uses a different frame.
|
|
|
|
*/
|
|
|
|
virtual wxHtmlHelpFrame* CreateHelpFrame(wxHtmlHelpData* data);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxHtmlModalHelp
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-23 09:55:07 -04:00
|
|
|
This class uses wxHtmlHelpController to display help in a modal dialog.
|
|
|
|
This is useful on platforms such as wxMac where if you display help from a
|
|
|
|
modal dialog, the help window must itself be a modal dialog.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Create objects of this class on the stack, for example:
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@code
|
2008-10-23 09:55:07 -04:00
|
|
|
// The help can be browsed during the lifetime of this object; when the
|
|
|
|
// user quits the help, program execution will continue.
|
2009-01-18 16:46:46 -05:00
|
|
|
wxHtmlModalHelp help(parent, "help", "My topic");
|
2008-03-08 08:52:38 -05:00
|
|
|
@endcode
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxhtml}
|
2008-10-23 09:55:07 -04:00
|
|
|
@category{help,html}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxHtmlModalHelp
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-10-23 09:55:07 -04:00
|
|
|
The ctor.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
is the parent of the dialog.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param helpFile
|
2008-03-09 08:33:59 -04:00
|
|
|
is the HTML help file to show.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param topic
|
2008-03-09 08:33:59 -04:00
|
|
|
is an optional topic. If this is empty, the help contents will be shown.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
is a combination of the flags described in the wxHtmlHelpController
|
2008-10-23 09:55:07 -04:00
|
|
|
documentation.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxHtmlModalHelp(wxWindow* parent, const wxString& helpFile,
|
|
|
|
const wxString& topic = wxEmptyString,
|
|
|
|
int style = wxHF_DEFAULT_STYLE | wxHF_DIALOG | wxHF_MODAL);
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|