]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/help.h
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     interface of wxHelpController 
   4 // Author:      wxWidgets team 
   6 // Licence:     wxWindows license 
   7 ///////////////////////////////////////////////////////////////////////////// 
  10     @class wxHelpController 
  12     This is a family of classes by which applications may invoke a help viewer 
  13     to provide on-line help. 
  15     A help controller allows an application to display help, at the contents 
  16     or at a particular topic, and shut the help program down on termination. 
  17     This avoids proliferation of many instances of the help viewer whenever the 
  18     user requests a different topic via the application's menus or buttons. 
  20     Typically, an application will create a help controller instance when it starts, 
  21     and immediately call wxHelpController::Initialize to associate a filename with it. 
  22     The help viewer will only get run, however, just before the first call to 
  25     Most help controller classes actually derive from wxHelpControllerBase and have 
  26     names of the form wxXXXHelpController or wxHelpControllerXXX. 
  27     An appropriate class is aliased to the name wxHelpController for each platform, as 
  29     - On desktop Windows, wxCHMHelpController is used (MS HTML Help). 
  30     - On Windows CE, wxWinceHelpController is used. 
  31     - On all other platforms, wxHtmlHelpController is used if wxHTML is compiled 
  32       into wxWidgets; otherwise wxExtHelpController is used (for invoking an 
  35     The remaining help controller classes need to be named explicitly by an 
  36     application that wishes to make use of them. 
  38     The following help controller classes are defined: 
  39     - wxWinHelpController, for controlling Windows Help. 
  40     - wxCHMHelpController, for controlling MS HTML Help. To use this, you need to 
  41       set wxUSE_MS_HTML_HELP to 1 in setup.h and have the htmlhelp.h header from 
  42       Microsoft's HTML Help kit. (You don't need the VC++-specific htmlhelp.lib 
  43       because wxWidgets loads necessary DLL at runtime and so it works with all 
  45     - wxBestHelpController, for controlling MS HTML Help or, if Microsoft's runtime 
  46       is not available, wxHtmlHelpController. You need to provide @b both CHM and 
  47       HTB versions of the help file. For wxMSW only. 
  48     - wxExtHelpController, for controlling external browsers under Unix. 
  49       The default browser is Netscape Navigator. The 'help' sample shows its use. 
  50     - wxWinceHelpController, for controlling a simple @c .htm help controller for 
  51       Windows CE applications. 
  52     - wxHtmlHelpController, a sophisticated help controller using wxHTML, in a 
  53       similar style to the Microsoft HTML Help viewer and using some of the same 
  54       files. Although it has an API compatible with other help controllers, it has 
  55       more advanced features, so it is recommended that you use the specific API 
  56       for this class instead. Note that if you use .zip or .htb formats for your 
  57       books, you must add this line to your application initialization: 
  58       @code wxFileSystem::AddHandler(new wxArchiveFSHandler); @endcode 
  59       or nothing will be shown in your help window. 
  64     @see wxHtmlHelpController, @ref overview_html 
  66 class wxHelpController 
: public wxHelpControllerBase
 
  70         Constructs a help instance object, but does not invoke the help viewer. 
  72         If you provide a window, it will be used by some help controller classes, such as 
  73         wxCHMHelpController, wxWinHelpController and wxHtmlHelpController, as the 
  74         parent for the help window instead of the value of wxApp::GetTopWindow. 
  76         You can also change the parent window later with SetParentWindow(). 
  78     wxHelpController(wxWindow
* parentWindow 
= NULL
); 
  81         Destroys the help instance, closing down the viewer if it is running. 
  86         If the help viewer is not running, runs it and displays the file at the given 
  89         - @e WinHelp: Refers to the context number. 
  90         - @e MS HTML Help: Refers to the context number. 
  91         - @e External HTML help: the same as for DisplaySection(). 
  92         - @e wxHtmlHelpController: @e sectionNo is an identifier as specified in 
  93           the @c .hhc file. See @ref overview_html_helpformats. 
  96         This function is for backward compatibility only, and applications 
  97         should use DisplaySection() instead. 
  99     virtual bool DisplayBlock(long blockNo
); 
 102         If the help viewer is not running, runs it and displays the contents. 
 104     virtual bool DisplayContents(); 
 107         Displays the section as a popup window using a context id. 
 108         Returns @false if unsuccessful or not implemented. 
 110     virtual bool DisplayContextPopup(int contextId
); 
 113         If the help viewer is not running, runs it and displays the given section. 
 115         The interpretation of section differs between help viewers. 
 116         For most viewers, this call is equivalent to KeywordSearch. 
 117         For MS HTML Help, wxHTML help and external HTML help, if section has a 
 118         .htm or .html extension, that HTML file will be displayed; otherwise a 
 119         keyword search is done. 
 121     virtual bool DisplaySection(const wxString
& section
); 
 124         If the help viewer is not running, runs it and displays the given section. 
 126         - @e WinHelp, MS HTML Help @a sectionNo is a context id. 
 127         - @e External HTML help: wxExtHelpController implements @a sectionNo as 
 128           an id in a map file, which is of the form: 
 129         - @e wxHtmlHelpController: @a sectionNo is an identifier as specified in 
 130           the @c .hhc file. See @ref overview_html_helpformats. 
 131           See also the help sample for notes on how to specify section numbers for 
 132           various help file formats. 
 134     virtual bool DisplaySection(int sectionNo
); 
 137         Displays the text in a popup window, if possible. 
 139         Returns @false if unsuccessful or not implemented. 
 141     virtual bool DisplayTextPopup(const wxString
& text
, 
 145         For wxHtmlHelpController, returns the latest frame size and position 
 146         settings and whether a new frame is drawn with each invocation. 
 147         For all other help controllers, this function does nothing and just returns @NULL. 
 150             The most recent frame size. 
 152             The most recent frame position. 
 153         @param newFrameEachTime 
 154             @true if a new frame is drawn with each invocation. 
 156     virtual wxFrame
* GetFrameParameters(const wxSize
* size 
= NULL
, 
 157                                         const wxPoint
* pos 
= NULL
, 
 158                                         bool* newFrameEachTime 
= NULL
); 
 161         Returns the window to be used as the parent for the help window. 
 162         This window is used by wxCHMHelpController, wxWinHelpController and 
 163         wxHtmlHelpController. 
 165     virtual wxWindow
* GetParentWindow() const; 
 169         Initializes the help instance with a help filename, and optionally a server 
 170         socket number if using wxHelp (now obsolete). Does not invoke the help viewer. 
 171         This must be called directly after the help instance object is created and 
 172         before any attempts to communicate with the viewer. 
 174         You may omit the file extension and a suitable one will be chosen. 
 175         For wxHtmlHelpController, the extensions zip, htb and hhp will be appended 
 176         while searching for a suitable file. For WinHelp, the hlp extension is appended. 
 178     virtual bool Initialize(const wxString
& file
); 
 179     virtual bool Initialize(const wxString
& file
, int server
); 
 183         If the help viewer is not running, runs it, and searches for sections matching 
 184         the given keyword. If one match is found, the file is displayed at this section. 
 185         The optional parameter allows the search the index (wxHELP_SEARCH_INDEX) 
 186         but this currently only supported by the wxHtmlHelpController. 
 188         - @e WinHelp, MS HTML Help: 
 189           If more than one match is found, the first topic is displayed. 
 190         - @e External HTML help, simple wxHTML help: 
 191           If more than one match is found, a choice of topics is displayed. 
 192         - @e wxHtmlHelpController: see wxHtmlHelpController::KeywordSearch. 
 194     virtual bool KeywordSearch(const wxString
& keyWord
, 
 195                                wxHelpSearchMode mode 
= wxHELP_SEARCH_ALL
); 
 198         If the help viewer is not running, runs it and loads the given file. 
 199         If the filename is not supplied or is empty, the file specified in 
 200         Initialize() is used. 
 202         If the viewer is already displaying the specified file, it will not be 
 203         reloaded. This member function may be used before each display call in 
 204         case the user has opened another file. 
 206         wxHtmlHelpController ignores this call. 
 208     virtual bool LoadFile(const wxString
& file 
= ""); 
 211         Overrideable member called when this application's viewer is quit by the user. 
 212         This does not work for all help controllers. 
 214     virtual bool OnQuit(); 
 217         If the viewer is running, quits it by disconnecting. 
 218         For Windows Help, the viewer will only close if no other application is using it. 
 223         For wxHtmlHelpController, the title is set (with %s indicating the 
 224         page title) and also the size and position of the frame if the frame is 
 225         already open. @a newFrameEachTime is ignored. 
 227         For all other help controllers this function has no effect. 
 229     virtual void SetFrameParameters(const wxString
& title
, 
 231                                     const wxPoint
& pos 
= wxDefaultPosition
, 
 232                                     bool newFrameEachTime 
= false); 
 235         Sets the window to be used as the parent for the help window. This is used 
 236         by wxCHMHelpController, wxWinHelpController and wxHtmlHelpController. 
 238     virtual void SetParentWindow(wxWindow
* parentWindow
); 
 241         Sets detailed viewer information. 
 242         So far this is only relevant to wxExtHelpController. 
 243         Some examples of usage: 
 246         m_help.SetViewer("kdehelp"); 
 247         m_help.SetViewer("gnome-help-browser"); 
 248         m_help.SetViewer("netscape", wxHELP_NETSCAPE); 
 252             This defaults to "netscape" for wxExtHelpController. 
 254             This defaults to wxHELP_NETSCAPE for wxExtHelpController, indicating 
 255             that the viewer is a variant of Netscape Navigator. 
 257         @todo modernize this function with ::wxLaunchDefaultBrowser 
 259     virtual void SetViewer(const wxString
& viewer
, long flags
);