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

  1. #ifndef _IINFOA_
  2.   #define _IINFOA_
  3. /*******************************************************************************
  4. * FILE NAME: iinfoa.hpp                                                        *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   This file contains the declaration(s) of the class(es):                    *
  8. *     IInfoa - Information area for a frame 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               *
  15. *   disclosure                                                                 *
  16. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  17. *                                                                              *
  18. *******************************************************************************/
  19. #ifndef _ISTATTXT_
  20.   #include <istattxt.hpp>
  21. #endif
  22. #ifndef _IMENUHDR_
  23.   #include <imenuhdr.hpp>
  24. #endif
  25. #ifndef _ISTRING_
  26.   #include <istring.hpp>
  27. #endif
  28.  
  29. /*----------------------------------------------------------------------------*/
  30. /* Align classes on four byte boundary.                                       */
  31. /*----------------------------------------------------------------------------*/
  32. #pragma pack(4)
  33.  
  34. // Forward declarations for other classes:
  35. class IFrameWindow;
  36. class IMenuEvent;
  37. class IModuleHandle;
  38. class IResourceLibrary;
  39.  
  40.  
  41. class IInfoArea : public IStaticText, public IMenuHandler {
  42. typedef IStaticText
  43.   Inherited;
  44. /*******************************************************************************
  45. * The IInfoArea class objects provide a frame extension at the bottom of the   *
  46. * client area that shows information about the frame menu item at which the    *
  47. * selection cursor is currently positioned.                                    *
  48. *                                                                              *
  49. * The information area will display the contents of an entry in a resource     *
  50. * string table.  The string resource will be obtained by using the same ID as  *
  51. * the menu item plus some optional "offset" value that will be added to the    *
  52. * menu item ID to locate the corresponding string of information about it.     *
  53. *                                                                              *
  54. * The strings will be loaded from a dynamic link library (DLL).  A library     *
  55. * name can be specified, or 0 can be used to indicate that the resources       *
  56. * should come from the default user appliction resource library.               *
  57. *                                                                              *
  58. * Example:                                                                     *
  59. *   // In .rc file...                                                          *
  60. *   MENU MENU_ID                                                               *
  61. *   BEGIN                                                                      *
  62. *     MENUITEM "Item 1", ITEM_1                                                *
  63. *     SUBMENU "Item 2", ITEM_2                                                 *
  64. *     BEGIN                                                                    *
  65. *       MENUITEM "Item 2.1", ITEM_21                                           *
  66. *       MENUITEM "Item 2.2", ITEM_22                                           *
  67. *     END                                                                      *
  68. *   END                                                                        *
  69. *   STRINGTABLE                                                                *
  70. *   BEGIN                                                                      *
  71. *     MENU_ID "Information about menu choices in general"                      *
  72. *     ITEM_1  "Information about menu item 1"                                  *
  73. *     ITEM_2  "Information about submenu 2"                                    *
  74. *     ITEM_21 "Information about submenu item 2.1"                             *
  75. *     ITEM_22 "Information about submenu item 2.2"                             *
  76. *   END                                                                        *
  77. *                                                                              *
  78. *   // Create a frame.                                                         *
  79. *   IFrameWindow                                                               *
  80. *     frame( IFrame::menuBar, MENU_ID );                                       *
  81. *                                                                              *
  82. *   // Attach information area:                                                *
  83. *   IInfoArea                                                                  *
  84. *     infoArea( &frame );                                                      *
  85. *******************************************************************************/
  86. public:
  87. /*------------------------- Constructors/Destructor ----------------------------
  88. | You can construct an instance of this class with the following required      |
  89. | information:                                                                 |
  90. |    - A pointer to the frame window to which the information area is to be    |
  91. |      attached.                                                               |
  92. |    - The ID to be given the information area control.  The default is 0.     |
  93. |    - The specification of the resource library from which the information    |
  94. |      strings are to be loaded.  This can be specified by either of the       |
  95. |      following:                                                              |
  96. |        - A module handle of the resource DLL                                 |
  97. |        - A module handle of 0 for the current .exe                           |
  98. |        - The name of a .DLL file                                             |
  99. |        - The name of a .DLL library.                                         |
  100. |      The default is the user default library obtained from                   |
  101. |      IApplication::current().resourceLibrary().                              |
  102. |                                                                              |
  103. | The second and third arguments are optional.  Either or both can be          |
  104. | specified, in any order.                                                     |
  105. ------------------------------------------------------------------------------*/
  106.   IInfoArea ( IFrameWindow        *frame,
  107.               unsigned long        id = 0 );
  108.   IInfoArea ( IFrameWindow        *frame,
  109.               unsigned long        id,
  110.               const char          *resDLLName );
  111.  
  112.   IInfoArea ( IFrameWindow        *frame,
  113.               const IModuleHandle &resMod,
  114.               unsigned long        id = 0 );
  115.   IInfoArea ( IFrameWindow        *frame,
  116.               const char          *resDLLName,
  117.               unsigned long        id = 0 );
  118.  
  119. virtual
  120.  ~IInfoArea ( );
  121.  
  122. /*----------------------------- Resource Library -------------------------------
  123. | These functions query and set the resource library from which the            |
  124. | information strings are loaded:                                              |
  125. |   resourceLibrary    - Returns a reference to the library being used.        |
  126. |   setResourceLibrary - Sets the resource library to be used.  This can be    |
  127. |                        specified as a module handle, a .DLL file, or a       |
  128. |                        library name.                                         |
  129. ------------------------------------------------------------------------------*/
  130. virtual IResourceLibrary
  131.  &resourceLibrary       ( ) const;
  132.  
  133. virtual IInfoArea
  134.  &setResourceLibrary    ( const IModuleHandle &resMod ),
  135.  &setResourceLibrary    ( const char          *resDLLName );
  136.  
  137. /*--------------------------- String Table Offset ------------------------------
  138. | These functions query and set the "string table offset" that is added        |
  139. | to the menu identifier to obtain the identifier for the string providing     |
  140. | the information about the menu item.  The default is zero.                   |
  141. |   stringTableOffset    - Returns the offset currently in use.                |
  142. |   setStringTableOffset - Sets the offset to be used to calculate the         |
  143. |                          information string ID.                              |
  144. ------------------------------------------------------------------------------*/
  145. virtual long
  146.   stringTableOffset     ( ) const;
  147.  
  148. virtual IInfoArea
  149.  &setStringTableOffset  ( long newOffset );
  150.  
  151. /*----------------------- Special Information Strings --------------------------
  152. | These functions query and set the value of the information strings displayed |
  153. | in special circumstances.  Each special string can be specified as either    |
  154. | an IString or the identifier for a string from the resource library.         |
  155. |   inactiveText     - Returns the text displayed when the menu is inactive.   |
  156. |   setInactiveText  - Sets the text to be used when the menu is inactive.     |
  157. |   disabledText     - Returns the text displayed when the menu item at the    |
  158. |                      selection cursor is disabled.                           |
  159. |   setDisabledText  - Sets the text that is to be displayed whenever a        |
  160. |                      disabled menu item becomes the current menu item.       |
  161. |                      To display this text, the setDisabledText function      |
  162. |                      must be called before the disabled menu item is made    |
  163. |                      the current menu item; otherwise, the normal            |
  164. |                      information area text is displayed.                     |
  165. |   missingText      - Returns the text to be displayed when the required      |
  166. |                      information string cannot be obtained from the          |
  167. |                      resource library.                                       |
  168. |   setMissingText   - Sets the text to be displayed when the information      |
  169. |                      string cannot be found.                                 |
  170. ------------------------------------------------------------------------------*/
  171. virtual IString
  172.   inactiveText          ( ) const,
  173.   disabledText          ( ) const,
  174.   missingText           ( ) const;
  175.  
  176. virtual IInfoArea
  177.  &setInactiveText       ( unsigned long  id ),
  178.  &setInactiveText       ( const IString &id ),
  179.  &setDisabledText       ( unsigned long  id ),
  180.  &setDisabledText       ( const IString &id ),
  181.  &setMissingText        ( unsigned long  id ),
  182.  &setMissingText        ( const IString &id );
  183.  
  184. /*---------------------------- Window Attachment -------------------------------
  185. | These functions permit attaching and detaching the handler of the            |
  186. | information area to/from a frame window (these are called automatically by   |
  187. | this class):                                                                 |
  188. |   handleEventsFor       - Attaches the handler of the information area to    |
  189. |                           the specified frame window.                        |
  190. |   stopHandlingEventsFor - Detaches the handler of the information area from  |
  191. |                           the specified frame window.                        |
  192. ------------------------------------------------------------------------------*/
  193. virtual IInfoArea
  194.  &handleEventsFor       ( IFrameWindow* frame ),
  195.  &stopHandlingEventsFor ( IFrameWindow* frame );
  196.  
  197. protected:
  198. /*------------------------------ Implementation --------------------------------
  199. | This utility member function is used to implement this class.  Derived       |
  200. | classes can override it in order to tailor the behavior.                     |
  201. |   informationFor - Returns the information string for the argument menu ID.  |
  202. ------------------------------------------------------------------------------*/
  203. virtual IString
  204.   informationFor        ( unsigned long menuId ) const;
  205.  
  206. /*-------------------------------- Overrides -----------------------------------
  207. | The following functions are overridden from class IMenuHandler in order      |
  208. | to handle the menu events appropriately.                                     |
  209. |   menuSelected - Places the corresponding information string into the        |
  210. |                  static text frame extension.                                |
  211. |   menuEnded    - Places the "inactive" information string into the           |
  212. |                  information area.                                           |
  213. ------------------------------------------------------------------------------*/
  214. virtual Boolean
  215.   menuSelected          ( IMenuEvent& menuEvent ),
  216.   menuEnded             ( IMenuEvent& menuEvent );
  217.  
  218. private:
  219. /*--------------------------------- Private ----------------------------------*/
  220. enum Status
  221.   {
  222.   noneShowing,
  223.   missingShowing,
  224.   inactiveShowing,
  225.   disabledShowing
  226.   };
  227. virtual IHandler
  228.  &handleEventsFor       ( IWindow* window ),
  229.  &stopHandlingEventsFor ( IWindow* window );
  230. void
  231.   setString             ( IString &, unsigned long ),
  232.   addTo                 ( IFrameWindow * ),
  233.   showText              ( Status newStatus, const IString &text );
  234. Status
  235.   status;
  236. IResourceLibrary
  237.  *pResLib;
  238. long
  239.   strTblOffset;
  240. IString
  241.   inactive,
  242.   disabled,
  243.   missing;
  244. }; // class IInfoArea
  245.  
  246. /*----------------------------------------------------------------------------*/
  247. /* Resume compiler default packing.                                           */
  248. /*----------------------------------------------------------------------------*/
  249. #pragma pack()
  250.  
  251. #endif /* _IINFOA_ */
  252.