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

  1. #ifndef _IMNDIHDR_
  2. #define _IMNDIHDR_
  3. /*******************************************************************************
  4. * FILE NAME: imndihdr.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IMenuDrawItemHandler - The draw item menu event handler class            *
  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. // Forward declarations for other classes:
  20. class IKeyboardHandler;
  21. #ifndef _IHANDLER_
  22.  #include <ihandler.hpp>
  23. #endif
  24. #ifndef _IMNDIEVT_
  25.  #include <imndievt.hpp>
  26. #endif
  27. #ifndef _IBITFLAG_
  28.   #include <ibitflag.hpp>
  29. #endif
  30. #ifndef _IPOINT_
  31.   #include <ipoint.hpp>
  32. #endif
  33.  
  34. /*----------------------------------------------------------------------------*/
  35. /* Align classes on four byte boundary.                                       */
  36. /*----------------------------------------------------------------------------*/
  37. #pragma pack(4)
  38.  
  39. class IMenuDrawItemHandler : public IHandler {
  40. typedef IHandler Inherited;
  41. /*******************************************************************************
  42. * The IMenuDrawItemHandler class is used to process the draw item menu events. *
  43. *                                                                              *
  44. * The menu item must be created with the IMenuItem constructor that creates    *
  45. * a draw item.  You can also call IMenuItem::setDrawItem after the item has    *
  46. * been created.                                                                *
  47. *******************************************************************************/
  48. public:
  49. /*------------------------ Constructor -----------------------------------------
  50. | The only way to construct instances of this class is by using the default    |
  51. | constructor.                                                                 |
  52. ------------------------------------------------------------------------------*/
  53.   IMenuDrawItemHandler();
  54.  
  55. protected:
  56. /*-------------------------------- DrawFlag ------------------------------------
  57. | This flag is set in the overridden draw function to indicate the actions     |
  58. | that were taken.                                                             |
  59. |                                                                              |
  60. |   DrawFlag - Nested class that provides static members that define the set   |
  61. |              of valid actions taken within a draw function.  An instance of  |
  62. |              a DrawFlag is passed as the second argument to an overridden    |
  63. |              IMenuDrawItemHandler::draw function.  The overridden function   |
  64. |              sets the appropriate DrawFlag flags to indicate whether it      |
  65. |              handled any of the special drawing needs of the menu item.      |
  66. |                                                                              |
  67. |              The declaration of the IMenuDrawItemHandler::DrawFlag nested    |
  68. |              class is generated by the INESTEDBITFLAGCLASSDEF0 macro.        |
  69. |                                                                              |
  70. | The valid menu owner-draw flags are:                                         |
  71. |                                                                              |
  72. |   drewChecked  - The menu item's check mark is drawn.                        |
  73. |   drewDisabled - The menu item's disabled state is drawn.                    |
  74. |   drewSelected - The highlighting of the menu item is drawn.                 |
  75. ------------------------------------------------------------------------------*/
  76. INESTEDBITFLAGCLASSDEF0(DrawFlag, IMenuDrawItemHandler);
  77. static const DrawFlag
  78.   drewChecked,
  79.   drewDisabled,
  80.   drewSelected;
  81.  
  82. /*------------------------- Override Functions ---------------------------------
  83. | This class overrides the following inherited function:                       |
  84. |   dispatchHandlerEvent - Dispatches command functions for this handler.      |
  85. ------------------------------------------------------------------------------*/
  86. virtual Boolean
  87.   dispatchHandlerEvent(IEvent& evt);
  88.  
  89. /*------------------------- Event Handling Functions ---------------------------
  90. | These event handling functions are dispatched by this handler:               |
  91. |   setSize    - Override this function to set the width and height of each    |
  92. |                draw item menu item.  This event is dispatched only once for  |
  93. |                each menu item, when the menu is initialized.  Set the size   |
  94. |                in the newSize argument.                                      |
  95. |   draw       - Override this function to draw the menu item.  By default,    |
  96. |                the system will draw a check mark, halftone the text for a    |
  97. |                disabled menu item, and invert the bits to indicate menu      |
  98. |                item selection.  Unless the system default method is          |
  99. |                unacceptable, you should not have to draw these attributes.   |
  100. |                If you draw any of these attributes yourself, set the         |
  101. |                appropriate DrawFlag before returning from the draw           |
  102. |                function.  This will prevent the system from drawing these    |
  103. |                attributes.  The IMenuDrawItemEvent class provides testing    |
  104. |                functions to query whether the menu item is selected,         |
  105. |                checked, or disabled.                                         |
  106. |  highlight   - Override this function if you want to draw the highlight      |
  107. |                that indicates a menu item has been selected.  You should do  |
  108. |                this only if the system default of inverting the bits for a   |
  109. |                selected item is unacceptable.                                |
  110. |  unhighlight - Override this function if you want to remove the highlight    |
  111. |                that indicates a menu item has been de-selected.  You should  |
  112. |                do this only if the system default is unacceptable.           |
  113. |-----------------------------------------------------------------------------*/
  114. virtual Boolean
  115.   setSize(ISize& newSize),
  116.   draw(IMenuDrawItemEvent& evt, DrawFlag& flag),
  117.   highlight(IMenuDrawItemEvent& evt),
  118.   unhighlight(IMenuDrawItemEvent& evt);
  119. };
  120.  
  121. /*----------------------------------------------------------------------------*/
  122. /* Resume compiler default packing.                                           */
  123. /*----------------------------------------------------------------------------*/
  124. #pragma pack()
  125.  
  126. #endif /* _IMNDIHDR_ */
  127.