home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IHELP.HPP < prev    next >
C/C++ Source or Header  |  1993-10-22  |  19KB  |  346 lines

  1. #ifndef _IHELP_
  2. #define _IHELP_
  3. /*******************************************************************************
  4. * FILE NAME: ihelp.hpp.                                                        *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IHelpWindow - The application's help window                              *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   Licensed Materials - Property of IBM                                       *
  12. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  13. *   All Rights Reserved                                                        *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18.  
  19. #ifndef _IWINDOW_
  20.   #include <iwindow.hpp>
  21. #endif
  22. #ifndef _IHANDLE_
  23.   #include <ihandle.hpp>
  24. #endif
  25. #ifndef _ISTRING_
  26.   #include <istring.hpp>
  27. #endif
  28. #ifndef _IRESLIB_
  29.   #include <ireslib.hpp>
  30. #endif
  31. #ifndef _IFRAME_
  32.   #include <iframe.hpp>
  33. #endif
  34.  
  35. /*----------------------------------------------------------------------------*/
  36. /* Align classes on four byte boundary.                                       */
  37. /*----------------------------------------------------------------------------*/
  38. #pragma pack(4)
  39.  
  40. /*----------------------------------------------------------------------------*/
  41. /* Turn off warning for compiler generated copy/assignment                    */
  42. /*----------------------------------------------------------------------------*/
  43. #pragma info(nocpy)
  44.  
  45. // Forward declarations for other classes:
  46. class ISize;
  47. class IString;
  48. class IPoint;
  49. class IRectangle;
  50. class IResourceId;
  51. class IFrameWindow;
  52.  
  53.  
  54. class IHelpWindow : public IWindow {
  55. typedef IWindow
  56.   Inherited;
  57. /*******************************************************************************
  58. | The IHelpWindow class is used to provide help for application windows using  |
  59. | the OS/2 Information Presentation Facility (IPF).  Typically, an             |
  60. | IHelpWindow is created and associated with one of the application's main     |
  61. | windows.  Multiple help windows can exist within an application.  When an    |
  62. | application window is associated with a help window, help events will be     |
  63. | dispatched to the help handler attached to the window.                       |
  64. |                                                                              |
  65. |  MyFrameWindow :: MyFrameWindow() {                                          |
  66. |   IHelpWindow* phelp = new IHelpWindow(CPP_HELP_TABLE, this);                |
  67. |   phelp->setTitle("C++ Help");                                               |
  68. |   IHelpHandler* phelpHandler = new IHelpHandler()                            |
  69. |   phelpHandler->startHandling(this);                                         |
  70. |   handleEventsFor(this);                                                     |
  71. |  }                                                                           |
  72. |                                                                              |
  73. *******************************************************************************/
  74. public :
  75.  
  76.  
  77. class Settings : public IBase {
  78. /*******************************************************************************
  79. | The IHelpWindow::Settings class provides initial information for the         |
  80. | constructor of the IHelpWindow class.  Typically, a Settings instance is     |
  81. | created and some or all of the data is set before passing it on to the       |
  82. | IHelpWindow constructor that takes a Settings instance.                      |
  83. *******************************************************************************/
  84. typedef IBase
  85.   Inherited;
  86.  
  87. /*------------------------- Constructor/Destructor -----------------------------
  88. | Instances of this nested class can be constructed using the default          |
  89. | constructor only.                                                            |
  90. ------------------------------------------------------------------------------*/
  91. public :
  92.   Settings();
  93.  
  94. /*------------------------------ Accessors  ------------------------------------
  95. | The following functions provide a means of getting and setting the           |
  96. | accessible attributes of instances of this class.  These functions are used  |
  97. | before the help window is created.                                           |
  98. |                                                                              |
  99. |   setTitle           - Indicates the text to use in the title of the help    |
  100. |                        window.  The text can be specified as either a text   |
  101. |                        string or as a resource ID to be loaded.              |
  102. |   setLibraries       - Adds a library or list of libraries to those          |
  103. |                        referenced when looking for help windows by their     |
  104. |                        ID.  If multiple library names are specified, they    |
  105. |                        should be separated by a blank space.  This member    |
  106. |                        function deals with the binary help files that have   |
  107. |                        an .HLP extension.                                    |
  108. |   setTutorial        - Sets the name of the application's tutorial.  If      |
  109. |                        this name is specified, IPF will provide a Tutorial   |
  110. |                        choice in the Help menu.                              |
  111. |   setHelpTable       - Specifies a new help table to use to identify help    |
  112. |                        windows.                                              |
  113. |   setUsingHelp       - Specifies the application help panel to be used       |
  114. |                        instead of the default IPF Using Help window.         |
  115. |   setMenuBar         - Specifies a menu bar template to use instead of the   |
  116. |                        IPF default menu bar                                  |
  117. |   setHelpResLibrary  - Sets the dynamic resource library that contains the   |
  118. |                        help table script.  The default setting is the        |
  119. |                        executable file.                                      |
  120. |   setAccelResLibrary - Sets the dynamic resource link library that contains  |
  121. |                        the help window menu accelerator table.  The .DLL     |
  122. |                        extension should be part of the given string.  The    |
  123. |                        default setting is the executable file.               |
  124. |   setAccelerator     - If a modified menu bar is being used, this function   |
  125. |                        specifies an accelerator table to use with it.        |
  126. ------------------------------------------------------------------------------*/
  127. Settings
  128.  &setTitle             ( const char*          titleText),
  129.  &setTitle             ( const IResourceId&   titleId),
  130.  &setLibraries         ( const char*          helpLibraryNames),
  131.  &setTutorial          ( const char*          tutorial),
  132.  &setHelpTable         ( unsigned long        helpTable),
  133.  &setUsingHelp         ( unsigned long        helpId),
  134.  &setMenuBar           ( unsigned long        menuBar),
  135.  &setHelpResLibrary    ( const char*   helpTableResLibrary),
  136.  &setAccelResLibrary   ( const char*   menuAccelResLibrary),
  137.  &setAccelerator       ( unsigned long        accelerator);
  138.  
  139.  
  140.  
  141. private:
  142.  
  143. IString
  144.  title,
  145.  tutorial,
  146.  helpLibraries,
  147.  HTResLib,
  148.  MAResLib;
  149.  
  150. unsigned long
  151.  usingHelpId,
  152.  helpTableId,
  153.  menuBarId,
  154.  acceleratorId;
  155.  
  156. friend class IHelpWindow;
  157.  
  158. };  //end Class Settings
  159.  
  160. /*------------------------ Constructors/Destructor  ----------------------------
  161. | You can construct an instance of this class in the following ways:           |
  162. |                                                                              |
  163. |    - By providing an optional application window which:                      |
  164. |        - The help window references to position itself.                      |
  165. |        - Receives help notification events.                                  |
  166. |                                                                              |
  167. |    - By providing a resource ID to identify the help table in addition to    |
  168. |      an optional application window which:                                   |
  169. |        - The help window references to position itself.                      |
  170. |        - Receives help notification events.                                  |
  171. |                                                                              |
  172. |    - By providing a Settings class instance to associate the help with       |
  173. |      initial information such as a modified menu bar, accelerator            |
  174. |      table, title, tutorial, and library names.  The application can also    |
  175. |      pass in the helpEventReceiver frame window so that the help instance    |
  176. |      can be associated when the constructor is run.  Otherwise, the          |
  177. |      application can call associateWindow after construction.                |
  178. |                                                                              |
  179. |    - From an existing help instance by providing the window handle.          |
  180. ------------------------------------------------------------------------------*/
  181.   IHelpWindow     ( IFrameWindow*  helpEventReceiver = 0);
  182.  
  183.   IHelpWindow     ( const IResourceId&   helpTable,
  184.                     IFrameWindow*  helpEventReceiver );
  185.  
  186.   IHelpWindow     ( IHelpWindow::Settings  initialSettings,
  187.                     IFrameWindow*  helpEventReceiver = 0);
  188.  
  189.   IHelpWindow     ( const IWindowHandle& helpWindowHandle);
  190.  
  191. virtual
  192.   ~IHelpWindow    ( );
  193.  
  194.  
  195. /*------------------------------ Event Processing ------------------------------
  196. | The following functions are used to facilitate the processing of help window |
  197. | events:                                                                      |
  198. |   associateWindow - Sets the application window chain to receive help        |
  199. |                     events.  Setting frameWindow to 0 will dissassociate     |
  200. |                     any previously set window.                               |
  201. |   setActiveWindow - Sets the application window to receive window help       |
  202. |                     events.  This is the window that a help handler should   |
  203. |                     be associated with to process help events.  Optionally,  |
  204. |                     the window next to which the help window should be       |
  205. |                     positioned can be specified.                             |
  206. ------------------------------------------------------------------------------*/
  207. IHelpWindow
  208.   &associateWindow           ( IFrameWindow* frameWindow),
  209.   &setActiveWindow           ( IFrameWindow* handlerWindow,
  210.                                IFrameWindow* relativeWindow = 0);
  211.  
  212. /*------------------------------ Help Attribute  -------------------------------
  213. | These functions provide means of getting and setting the help specific       |
  214. | attributes of instances of this class.  These functions are used after the   |
  215. | help window has been created.                                                |
  216. |                                                                              |
  217. |   setTitle     - Indicates the text to use in the title of the help window.  |
  218. |                  The text can be specified as either a text string or as a   |
  219. |                  resource ID to be loaded.                                   |
  220. |   setHelpTable - Specifies a new help table to use to identify help windows. |
  221. |   addLibraries - Adds a library or list of libraries to those referenced     |
  222. |                  when looking for help windows by their ID.  If multiple     |
  223. |                  library names are specified, they should be separated by a  |
  224. |                  blank space.  This member function deals with the binary    |
  225. |                  help files that have an .HLP extension.                     |
  226. |   setUsingHelp - Specifies the application help panel to be used instead of  |
  227. |                  the default IPF Using Help window.                          |
  228. ------------------------------------------------------------------------------*/
  229. IHelpWindow
  230.   &setTitle                  ( const char*         titleText),
  231.   &setTitle                  ( const IResourceId&  titleId),
  232.   &setHelpTable              ( const IResourceId&  helpTable),
  233.   &addLibraries              ( const char*         helpLibraryNames),
  234.   &setUsingHelp              ( unsigned long       helpId);
  235.  
  236.  
  237. /*------------------------------ Window Accessing ------------------------------
  238. | The following functions provide information about accessing the window:      |
  239. |   indexWindow         - Returns the handle of the Index window.              |
  240. |   contentsWindow      - Returns the handle of the Table of Contents window.  |
  241. |   searchListWindow    - Returns the handle of the Search hit-list window.    |
  242. |   viewedPagesWindow   - Returns the handle of the Viewed Pages window.       |
  243. |   communicationWindow - Returns the handle of the active communication       |
  244. |                         window.                                              |
  245. |   coverPageWindow     - Returns the handle of the IPF multiple document      |
  246. |                         interface parent window.                             |
  247. |   helpForWindow       - Returns the current active window.  If there is not  |
  248. |                         an active window, 0 is returned.                     |
  249. |   helpWindow          - Returns a pointer to an IHelpWindow given an         |
  250. |                         application window.  The parent window chain is      |
  251. |                         searched until an application window that contains   |
  252. |                         a help window is found.  If a help window cannot be  |
  253. |                         found, 0 is returned.                                |
  254. ------------------------------------------------------------------------------*/
  255. IWindowHandle
  256.   indexWindow               ( ) const,
  257.   contentsWindow            ( ) const,
  258.   searchListWindow          ( ) const,
  259.   viewedPagesWindow         ( ) const,
  260.   communicationWindow       ( ) const,
  261.   coverPageWindow           ( ) const;
  262.  
  263. IFrameWindow
  264.  *helpForWindow              ( ) const;
  265.  
  266. static IHelpWindow
  267.  *helpWindow                ( const IWindow*      window);
  268.  
  269.  
  270. /*------------------------------ Related Types ---------------------------------
  271. | The following types are defined within the IHelpWindow:                      |
  272. |   HelpType  - Identifies the type of the help window to be displayed on      |
  273. |               a call to IHelpWindow::show.  It can be set to one of the      |
  274. |               following values:                                              |
  275. |                                                                              |
  276. |         index    - The Help Index window.                                    |
  277. |         general  - The General Help window.                                  |
  278. |         contents - The Help Contents window.                                 |
  279. |         keys     - The Keys Help window.                                     |
  280. |         using    - The Using Help window.                                    |
  281. ------------------------------------------------------------------------------*/
  282. enum HelpType {index, general, contents, keys, using};
  283.  
  284.  
  285.  
  286. /*-------------------------------- Display -------------------------------------
  287. | The following functions are used to display and remove help windows:         |
  288. |   show         - Displays a help window.  The help window can be specified   |
  289. |                  by either its ID, which is used to load the help window     |
  290. |                  from the current help table, or by passing one of the       |
  291. |                  HelpType flags.  If a window ID of 0 is specified, the      |
  292. |                  Using Help window is displayed.
  293. |   hide         - Dismisses the help window.                                  |
  294. |   showPanelIds - Adds the panel ID of help windows to the help window title. |
  295. |   hidePanelIds - Removes the panel ID of help windows from the help window   |
  296. |                  title.                                                      |
  297. ------------------------------------------------------------------------------*/
  298. IHelpWindow
  299.  &show           ( HelpType           helpType),
  300.  &show           ( const IResourceId& panelId),
  301.  &show           ( const char*        panelName),
  302.  &hide           ( ),
  303.  &showPanelIds   ( Boolean            visibleId = true),
  304.  &hidePanelIds   ( );
  305.  
  306.  
  307. /*-------------------------------- Overrides -----------------------------------
  308. | The following inherited functions are overridden:                            |
  309. |   handle     - Returns the help instance window handle.                      |
  310. |   sizeTo     - Changes the size of the help cover page window (the window    |
  311. |                within which all other IPF windows are displayed).            |
  312. |   moveTo     - Changes the position of the help cover page window.           |
  313. |   moveSizeTo - Changes the size and position of the help cover page window.  |
  314. ------------------------------------------------------------------------------*/
  315. IWindowHandle
  316.   handle           ( ) const;
  317.  
  318. IHelpWindow
  319.  &sizeTo           ( const ISize&       aSize),
  320.  &moveTo           ( const IPoint&      aPoint),
  321.  &moveSizeTo       ( const IRectangle&  aRectangle);
  322.  
  323. /*--------------------------------- Private ----------------------------------*/
  324. private :
  325. IWindowHandle
  326.   helpHandle;
  327. IResourceLibrary
  328.  *pHTResLib,
  329.  *pMAResLib;
  330. IString                                   //xxxxxxx
  331.  helpLibraries;
  332.  
  333.  
  334. IHelpWindow
  335.  &show           ( Boolean            show=true);
  336.  
  337. };
  338.  
  339. /*----------------------------------------------------------------------------*/
  340. /* Resume compiler default packing and warning messages.                      */
  341. /*----------------------------------------------------------------------------*/
  342. #pragma pack()
  343. #pragma info(restore)
  344.  
  345. #endif
  346.