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

  1. #ifndef _IMENUHDR_
  2.   #define _IMENUHDR_
  3. /******************************************************************************
  4. * FILE NAME: imenuhdr.hpp                                                     *
  5. *                                                                             *
  6. * DESCRIPTION:                                                                *
  7. *    Declaration of the class:                                                *
  8. *      IMenu - Handles menu events, except menu command.                      *
  9. *                                                                             *
  10. * COPYRIGHT:                                                                  *
  11. *   Licensed Materials - Property of IBM                                      *
  12. *   (c) Copyright IBM Corporation 1992, 1993                                  *
  13. *   US Government Users Restricted Rights - Use duplication                   *
  14. *   or disclosure restricted by GSA ADP Schedule Contract                     *
  15. *   with IBM Corp.                                                            *
  16. *                                                                             *
  17. *******************************************************************************/
  18. #ifndef _IHANDLER_
  19.   #include <ihandler.hpp>
  20. #endif
  21. #ifndef _IMENUEVT_
  22.   #include <imenuevt.hpp>
  23. #endif
  24.  
  25. /*----------------------------------------------------------------------------*/
  26. /* Align classes on four byte boundary.                                       */
  27. /*----------------------------------------------------------------------------*/
  28. #pragma pack(4)
  29.  
  30. // Forward declarations for other classes
  31. class ISubmenu;
  32.  
  33. class IMenuHandler : public IHandler {
  34. typedef IHandler
  35.   Inherited;
  36. /*******************************************************************************
  37. * The IMenuHandler class is used to process the following menu events:         *
  38. *   - Display pop-up menu.                                                     *
  39. *   - Alter a submenu menu item before it is shown.                            *
  40. *   - Perform processing when a menu item is selected.                         *
  41. *   - Perform processing when a submenu terminates.                            *
  42. *                                                                              *
  43. * The application must override the virtual functions to respond to the event. *
  44. *                                                                              *
  45. * NOTE: Menu command events are handled by the ICommandHandler class.          *
  46. *******************************************************************************/
  47. public:
  48. /*------------------ Constructor/Destructor ------------------------------------
  49. |  The only way to construct instances of this class is with the default       |
  50. |  constructor.                                                                |
  51. ------------------------------------------------------------------------------*/
  52.    IMenuHandler();
  53.   ~IMenuHandler();
  54.  
  55. protected:
  56. /*---------------------------- Event Dispatching -------------------------------
  57. | This function evaluates the event to determine if it is appropriate for      |
  58. | this handler object to process.  If it is, this function calls the virtual   |
  59. | function used to process the event.                                          |
  60. |   dispatchHandlerEvent - Calls the appropriate virtual function or           |
  61. |                          functions to process a menu event.                  |
  62. ------------------------------------------------------------------------------*/
  63. virtual Boolean
  64.   dispatchHandlerEvent(IEvent& event);
  65.  
  66. /*-------------------- Event Handling Virtual Functions ------------------------
  67. | The following functions are dispatched to instances of this handler class:   |
  68. |                                                                              |
  69. |  makePopUpMenu - Called when a context or pop-up menu is requested for the   |
  70. |                  object to which the handler applies.                        |
  71. |                                                                              |
  72. |                  You can override this function to create and show a pop-up  |
  73. |                  menu by using the IPopUpMenu class.  Code your override     |
  74. |                  function to return true if your program constructs an       |
  75. |                  IPopUpMenu; otherwise, code it to return false.  The        |
  76. |                  pop-up menu terminates when the menuEnded function is       |
  77. |                  called.  If, at this point, you want the library to delete  |
  78. |                  your IPopUpMenu instance, call the                          |
  79. |                  IWindow::setAutoDeleteObject function.  This requires you   |
  80. |                  to create the IPopUpMenu with the operator new.             |
  81. |                                                                              |
  82. |  menuShowing   - Called before a submenu, such as a pull-down, cascading     |
  83. |                  menu or pop-up menu, is shown.                              |
  84. |                                                                              |
  85. |                  An instance of the ISubmenu class is provided to allow you  |
  86. |                  to alter the menu items temporarily.  If true is returned   |
  87. |                  on this function, any change to the ISubmenu will be        |
  88. |                  undone when menuEnded is called to terminate the menu.      |
  89. |                                                                              |
  90. |  menuSelected  - Called when a menu item is selected.                        |
  91. |                                                                              |
  92. |  menuEnded     - Called when a submenu, such as a pull-down, cascading menu  |
  93. |                  or pop-up menu, terminates.                                 |
  94. |                                                                              |
  95. ------------------------------------------------------------------------------*/
  96. virtual Boolean
  97.   makePopUpMenu ( IMenuEvent& menuEvent ),
  98.   menuShowing   ( IMenuEvent& menuEvent,
  99.                   ISubmenu&   submenuAboutToShow ),
  100.   menuSelected  ( IMenuEvent& menuEvent ),
  101.   menuEnded     ( IMenuEvent& menuEvent );
  102.  
  103.  
  104. /*-------------------- Show/Hide Source Emphasis--------------------------------
  105. | The following functions provide a means to override the default              |
  106. | implementation of pop-up menu visual clue drawing.                           |
  107. |                                                                              |
  108. |  addSourceEmphasis    - Invokes the IWindow::showSourceEmphasis function.    |
  109. |  removeSourceEmphasis - Invokes the IWindow::hideSourceEmphasis function.    |
  110. ------------------------------------------------------------------------------*/
  111. virtual void
  112.   addSourceEmphasis( const IMenuEvent& menuEvent ),
  113.   removeSourceEmphasis( const IMenuEvent& menuEvent );
  114. };
  115.  
  116. /*----------------------------------------------------------------------------*/
  117. /* Resume compiler default packing.                                           */
  118. /*----------------------------------------------------------------------------*/
  119. #pragma pack()
  120.  
  121. #endif /* IMENUHDR */
  122.