wxWidgets: wxHtmlHelpController Class Reference

| Version: 3.2.2

Public Member Functions | Protected Member Functions | List of all members
wxHtmlHelpController Class Reference
Class List by Category » Help | Class List by Category » HTML

`#include <wx/html/helpctrl.h>`

Inheritance diagram for wxHtmlHelpController:
[legend]

## Detailed Description

This help controller provides an easy way of displaying HTML help in your application (see HTML Sample, test example).

The help system is based on 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.

wxHTML uses Microsoft's HTML Help Workshop project files (.hhp, .hhk, .hhc) as its native format. The file format is described in Help Files Format. The directory `helpfiles` in the HTML Sample contains sample project files.

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.

##

Library: wxHTML
Category: Help, HTML

See also
  wxBestHelpController, wxHtmlHelpFrame, wxHtmlHelpDialog, wxHtmlHelpWindow, wxHtmlModalHelp

## Public Member Functions
| wxHtmlHelpController (int style=wxHF_DEFAULT_STYLE, wxWindow *parentWindow=NULL)
| Constructor. More...
| wxHtmlHelpController (wxWindow *parentWindow, int style=wxHF_DEFAULT_STYLE)
bool | AddBook (const wxFileName &bookFile, bool showWaitMsg=false)
| Adds a book (i.e. More...
bool | AddBook (const wxString &bookUrl, bool showWaitMsg=false)
| Adds a book (i.e. More...
bool | Display (const wxString &x)
| Displays page x. More...
bool | Display (int id)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This alternative form is used to search help contents by numeric IDs. More...
virtual bool | DisplayContents ()
| Displays help window and focuses contents panel. More...
bool | DisplayIndex ()
| Displays help window and focuses index panel. More...
virtual bool | KeywordSearch (const wxString &keyword, wxHelpSearchMode mode=wxHELP_SEARCH_ALL)
| Displays the help window, focuses search panel and starts searching. More...
virtual void | ReadCustomization (wxConfigBase *cfg, const wxString &path=wxEmptyString)
| Reads the controller's setting (position of window, etc.) More...
void | SetShouldPreventAppExit (bool enable)
| Sets whether the help frame should prevent application from exiting if it's the only remaining top level window. More...
void | SetTempDir (const wxString &path)
| Sets the path for storing temporary files - cached binary versions of index and contents files. More...
void | SetTitleFormat (const wxString &format)
| Sets format of title of the frame. More...
void | UseConfig (wxConfigBase *config, const wxString &rootpath=wxEmptyString)
| Associates the config object with the controller. More...
virtual void | WriteCustomization (wxConfigBase *cfg, const wxString &path=wxEmptyString)
| Stores controllers setting (position of window etc.) More...
wxHtmlHelpWindow * | GetHelpWindow ()
| Get the current help window. More...
void | SetHelpWindow (wxHtmlHelpWindow *helpWindow)
| Set the help window to be managed by this controller. More...
wxHtmlHelpFrame * | GetFrame ()
| Returns the current help frame. More...
wxHtmlHelpDialog * | GetDialog ()
| Returns the current help dialog. More...
Public Member Functions inherited from wxHelpControllerBase
| wxHelpControllerBase (wxWindow *parentWindow=NULL)
| Constructs a help instance object, but does not invoke the help viewer. More...
| ~wxHelpControllerBase ()
| Destroys the help instance, closing down the viewer if it is running. More...
virtual bool | DisplayBlock (long blockNo)=0
| If the help viewer is not running, runs it and displays the file at the given block number. More...
virtual bool | DisplayContextPopup (int contextId)
| Displays the section as a popup window using a context id. More...
virtual bool | DisplaySection (const wxString &section)
| If the help viewer is not running, runs it and displays the given section. More...
virtual bool | DisplaySection (int sectionNo)=0
| If the help viewer is not running, runs it and displays the given section. More...
virtual bool | DisplayTextPopup (const wxString &text, const wxPoint &pos)
| Displays the text in a popup window, if possible. More...
virtual wxFrame * | GetFrameParameters (wxSize *size=NULL, wxPoint *pos=NULL, bool *newFrameEachTime=NULL)
| For wxHtmlHelpController, returns the latest frame size and position settings and whether a new frame is drawn with each invocation. More...
virtual wxWindow * | GetParentWindow () const
| Returns the window to be used as the parent for the help window. More...
virtual bool | Initialize (const wxString &file)
| Initializes the help instance with a help filename. More...
virtual bool | LoadFile (const wxString &file=wxEmptyString)=0
| If the help viewer is not running, runs it and loads the given file. More...
virtual void | OnQuit ()
| Overridable member called when this application's viewer is quit by the user. More...
virtual bool | Quit ()=0
| If the viewer is running, quits it by disconnecting. More...
virtual void | SetFrameParameters (const wxString &titleFormat, const wxSize &size, const wxPoint &pos=wxDefaultPosition, bool newFrameEachTime=false)
| Set the parameters of the frame window. More...
virtual void | SetParentWindow (wxWindow *parentWindow)
| Sets the window to be used as the parent for the help window. More...
virtual void | SetViewer (const wxString &viewer, long flags=wxHELP_NETSCAPE)
| Sets detailed viewer information. More...
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data. More...
| wxObject (const wxObject &other)
| Copy ctor. More...
virtual | ~wxObject ()
| Destructor. More...
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More...
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More...
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class. More...
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj. More...
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone. More...
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer. More...
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data. More...
void | UnShare ()
| This is the same of AllocExclusive() but this method is public. More...
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...

## Protected Member Functions
virtual wxHtmlHelpDialog * | CreateHelpDialog (wxHtmlHelpData *data)
| This protected virtual method may be overridden so that when specifying the `wxHF_DIALOG` style, the controller uses a different dialog. More...
virtual wxHtmlHelpFrame * | CreateHelpFrame (wxHtmlHelpData *data)
| This protected virtual method may be overridden so that the controller uses a different frame. More...
Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object. More...
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More...
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More...

## Additional Inherited Members
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data. More...

## Constructor & Destructor Documentation

## ◆ wxHtmlHelpController() [1/2]

wxHtmlHelpController::wxHtmlHelpController | ( | int | style = `wxHF_DEFAULT_STYLE`,
|  | wxWindow * | parentWindow = `NULL`
| ) |  |

Constructor.

Parameters

  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
  parentWindow | This is an optional window to be used as the parent for the help window.

## ◆ wxHtmlHelpController() [2/2]

wxHtmlHelpController::wxHtmlHelpController | ( | wxWindow * | parentWindow,
|  | int | style = `wxHF_DEFAULT_STYLE`
| ) |  |

## Member Function Documentation

## ◆ AddBook() [1/2]

bool wxHtmlHelpController::AddBook | ( | const wxFileName & | bookFile,
|  | bool | showWaitMsg = `false`
| ) |  |

Adds a book (i.e.

a .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. bookFile or bookUrl may be either `".hhp"` file or a ZIP archive that contains an arbitrary number of `".hhp"` files in its top-level directory. This ZIP archive must have `".zip"` or `".htb"` extension (the latter stands for "HTML book"). In other words,

AddBook(wxFileName("help.zip"))
wxFileName
wxFileName encapsulates a file name.
Definition: filename.h:343
wxHtmlHelpController::AddBook
bool AddBook(const wxFileName &bookFile, bool showWaitMsg=false)
Adds a book (i.e.

is possible and is the recommended way.

Parameters

  bookFile | Help book filename. It is recommended to use this prototype instead of the one taking URL, because it is less error-prone.
  showWaitMsg | If true then a decoration-less window with progress message is displayed.

## ◆ AddBook() [2/2]

bool wxHtmlHelpController::AddBook | ( | const wxString & | bookUrl,
|  | bool | showWaitMsg = `false`
| ) |  |

Adds a book (i.e.

a .hhp file; an HTML Help Workshop project file) into the list of loaded books.

See the other overload for additional info.

Parameters

  bookUrl | Help book URL (note that syntax of filename and URL is different on most platforms).
  showWaitMsg | If true then a decoration-less window with progress message is displayed.

## ◆ CreateHelpDialog()

virtual wxHtmlHelpDialog* wxHtmlHelpController::CreateHelpDialog | ( | wxHtmlHelpData * | data | ) |
| protectedvirtual

This protected virtual method may be overridden so that when specifying the `wxHF_DIALOG` style, the controller uses a different dialog.

## ◆ CreateHelpFrame()

virtual wxHtmlHelpFrame* wxHtmlHelpController::CreateHelpFrame | ( | wxHtmlHelpData * | data | ) |
| protectedvirtual

This protected virtual method may be overridden so that the controller uses a different frame.

## ◆ Display() [1/2]

bool wxHtmlHelpController::Display | ( | const wxString & | x | ) |

Displays page 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:

1. try to locate file named x (if x is for example "doc/howto.htm")
2. try to open starting page of book named x
3. try to find x in contents (if x is for example "How To ...")
4. try to find x in index (if x is for example "How To ...")
5. switch to Search panel and start searching

## ◆ Display() [2/2]

bool wxHtmlHelpController::Display | ( | int | id | ) |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This alternative form is used to search help contents by numeric IDs.

## ◆ DisplayContents()

virtual bool wxHtmlHelpController::DisplayContents | ( |  | ) |
| virtual

Displays help window and focuses contents panel.

Implements wxHelpControllerBase.

## ◆ DisplayIndex()

bool wxHtmlHelpController::DisplayIndex | ( |  | ) |

Displays help window and focuses index panel.

## ◆ GetDialog()

wxHtmlHelpDialog* wxHtmlHelpController::GetDialog | ( |  | ) |

Returns the current help dialog.

(May be NULL.)

## ◆ GetFrame()

wxHtmlHelpFrame* wxHtmlHelpController::GetFrame | ( |  | ) |

Returns the current help frame.

(May be NULL.)

## ◆ GetHelpWindow()

wxHtmlHelpWindow* wxHtmlHelpController::GetHelpWindow | ( |  | ) |

Get the current help window.

## ◆ KeywordSearch()

virtual bool wxHtmlHelpController::KeywordSearch | ( | const wxString & | keyword,
|  | wxHelpSearchMode | mode = `wxHELP_SEARCH_ALL`
| ) |  |
| virtual

Displays the help window, focuses search panel and starts searching.

Returns true if the keyword was found. Optionally it searches through the index (mode = `wxHELP_SEARCH_INDEX`), default the content (mode = `wxHELP_SEARCH_ALL`).

Note
  KeywordSearch() searches only pages listed in `".hhc"` file(s). You should list all pages in the contents file.

Implements wxHelpControllerBase.

## ◆ ReadCustomization()

virtual void wxHtmlHelpController::ReadCustomization | ( | wxConfigBase * | cfg,
|  | const wxString & | path = `wxEmptyString`
| ) |  |
| virtual

Reads the controller's setting (position of window, etc.)

## ◆ SetHelpWindow()

void wxHtmlHelpController::SetHelpWindow | ( | wxHtmlHelpWindow * | helpWindow | ) |

Set the help window to be managed by this controller.

This makes it possible to have a help window that might not be in a wxHtmlHelpFrame or dialog but is embedded in some other window in the application. Be sure to use the wxHF_EMBEDDED style in this case.

## ◆ SetShouldPreventAppExit()

void wxHtmlHelpController::SetShouldPreventAppExit | ( | bool | enable | ) |

Sets whether the help frame should prevent application from exiting if it's the only remaining top level window.

Parameters

  enable | If true, the application will not quit unless the help frame is closed. Default is false, i.e. the application does exit if only the help window remains opened.

See also
  wxApp::SetExitOnFrameDelete()

Since
  2.9.2

## ◆ SetTempDir()

void wxHtmlHelpController::SetTempDir | ( | const wxString & | path | ) |

Sets the path for storing temporary files - cached binary versions of index and 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 not deleted when program exits.

Once created these cached files will be used in all subsequent executions of your application. If cached files become older than corresponding `".hhp"` file (e.g. if you regenerate documentation) it will be refreshed.

## ◆ SetTitleFormat()

void wxHtmlHelpController::SetTitleFormat | ( | const wxString & | format | ) |

Sets format of title of the frame.

Must contain exactly one "%s" (for title of displayed HTML page).

## ◆ UseConfig()

void wxHtmlHelpController::UseConfig | ( | wxConfigBase * | config,
|  | const wxString & | rootpath = `wxEmptyString`
| ) |  |

Associates the config object with the controller.

If there is associated config object, wxHtmlHelpController automatically reads and writes settings (including wxHtmlWindow's settings) when needed. 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 wxConfigBase::Set).

## ◆ WriteCustomization()

virtual void wxHtmlHelpController::WriteCustomization | ( | wxConfigBase * | cfg,
|  | const wxString & | path = `wxEmptyString`
| ) |  |
| virtual

Stores controllers setting (position of window etc.)