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

  1. #ifndef _ISPINHDR_
  2.   #define _ISPINHDR_
  3. /*******************************************************************************
  4. * FILE NAME: ispinhdr.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     ISpinHandler - Process a spin event for a spin button.                   *
  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. #ifndef _IHANDLER_
  19.   #include <ihandler.hpp>
  20. #endif
  21. #ifndef _ICTLEVT_
  22.   #include <ictlevt.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 IEvent;
  32.  
  33.  
  34. class ISpinHandler : public IHandler {
  35. typedef IHandler
  36.   Inherited;
  37. /*******************************************************************************
  38. * The ISpinHandler class handles the processing of spin events for             *
  39. * ISpinButton objects.  It is designed to handle events that result from a     *
  40. * user interacting with a spin button control, such as when the user clicks    *
  41. * on the down arrow in a spin button.                                          *
  42. *                                                                              *
  43. * An ISpinHandler should be attached to the spin button that generated the     *
  44. * spin event or to the owner window of the spin button.  This is done by       *
  45. * passing the spin button or owner window on the handleEventsFor function of   *
  46. * the ISpinHandler object.                                                     *
  47. *                                                                              *
  48. * When it receives a spin event, the ISpinHandler object processes the event   *
  49. * by creating an IControlEvent object and routing it to the appropriate        *
  50. * virtual function.  You can override these virtual functions to supply your   *
  51. * own specialized processing of the event.  The return value from the virtual  *
  52. * function specifies whether the IControlEvent should be passed on for         *
  53. * additional processing, as follows:                                           *
  54. *                                                                              *
  55. *   Value   Meaning                                                            *
  56. *   ---------------                                                            *
  57. *   true  - The IControlEvent requires no additional processing and should     *
  58. *           not be passed to another handler.                                  *
  59. *   false - The IControlEvent should be passed on for additional processing,   *
  60. *           as follows:                                                        *
  61. *           -- If there is a next handler for the spin button or owner         *
  62. *              window, the event is passed on to the next handler.             *
  63. *           -- If this is the last handler for the spin button, the event is   *
  64. *              dispatched to the owner window of the spin button               *
  65. *              (see IWindow::dispatch).                                        *
  66. *           -- If this is the last handler for the owner window, the event is  *
  67. *              passed on a call to the owner window's defaultProcedure         *
  68. *              function (see IWindow::defaultProcedure).                       *
  69. *                                                                              *
  70. * Example:                                                                     *
  71. *   MyWindow::MyWindow()                                                       *
  72. *     : ...                                                                    *
  73. *   {                                                                          *
  74. *     MySpinHandler* spnh = new MySpinHandler();                               *
  75. *     ...                                                                      *
  76. *     ISpinButton* spb = new ISpinButton(ID_SB, this, this, IRectangle(...));  *
  77. *     spnh->handleEventsFor(spb);                                              *
  78. *     ...                                                                      *
  79. *     show();                                                                  *
  80. *   }                                                                          *
  81. *   Boolean  MySpinHandler::spinEnded(IControlEvent& evt)                      *
  82. *   {                                                                          *
  83. *     // do some processing                                                    *
  84. *     ...                                                                      *
  85. *     return false;            // let another handle event also                *
  86. *   }                                                                          *
  87. *******************************************************************************/
  88. public:
  89. /*-------------------------- Constructor/Destructor ----------------------------
  90. | The only way to construct instances of this class is to use the default      |
  91. | constructor, which does not take any arguments.                              |
  92. ------------------------------------------------------------------------------*/
  93.   ISpinHandler         ( );
  94. virtual
  95.  ~ISpinHandler         ( );
  96.  
  97. protected:
  98. /*---------------------------- Event Dispatching -------------------------------
  99. | This function evaluates the event to determine if it is appropriate for
  100. | this handler object to process.  If it is, it calls the virtual function
  101. | used to process the event.                                                           |
  102. |   dispatchHandlerEvent - Calls the appropriate virtual function to process   |
  103. |                          a spin event.                                       |
  104. ------------------------------------------------------------------------------*/
  105. virtual Boolean
  106.   dispatchHandlerEvent ( IEvent& event );
  107.  
  108. /*----------------------------- Event Processing -------------------------------
  109. | These functions must be supplied by a derived class to process a spin event. |
  110. |   arrowUp   - Implemented by derived classes to process the pressing of the  |
  111. |               up arrow key or clicking on the up arrow of the spin button.   |
  112. |   arrowDown - Implemented by derived classes to process the pressing of the  |
  113. |               down arrow key or clicking on the down arrow of the spin       |
  114. |               button.                                                        |
  115. |   spinEnded - Implemented by derived classes to process the release of an    |
  116. |               arrow key or the mouse button while spinning the spin button.  |
  117. ------------------------------------------------------------------------------*/
  118. virtual Boolean
  119.   arrowUp              ( IControlEvent& event ),
  120.   arrowDown            ( IControlEvent& event ),
  121.   spinEnded            ( IControlEvent& event );
  122. }; // ISpinHandler
  123.  
  124. /*----------------------------------------------------------------------------*/
  125. /* Resume compiler default packing.                                           */
  126. /*----------------------------------------------------------------------------*/
  127. #pragma pack()
  128.  
  129. #endif /* _ISPINHDR_ */
  130.