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

  1. #ifndef _IMCHDR_
  2.   #define _IMCHDR_
  3. /*******************************************************************************
  4. * FILE NAME: imchdr.hpp                                                        *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IMouseClickHandler - Process a mouse click event.                        *
  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 _IMCEVT_
  22.   #include <imcevt.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 IMouseClickHandler : public IHandler {
  35. typedef IHandler
  36.   Inherited;
  37. /*******************************************************************************
  38. * Instances of the IMouseClickHandler class can be used to process a variety   *
  39. * of mouse events.  These events include button presses and releases,          *
  40. * double-clicks, and multiple button presses.                                  *
  41. *                                                                              *
  42. * An IMouseClickHandler object can be attached to any kind of window.          *
  43. * Although the control or window that the mouse is over is the first to        *
  44. * receive a mouse click event, any event that is passed on for additional      *
  45. * processing is dispatched to the owner window.                                *
  46. *                                                                              *
  47. * A mouse click event continues to travel up the owner window chain until      *
  48. * either a handler stops it or the event is processed by the window itself.    *
  49. * As a result, an IMouseClickHandler object should not stop the processing of  *
  50. * any mouse click event that it does not understand, since the event has the   *
  51. * potential of being handled by any window in the owner chain, such as the     *
  52. * frame window.                                                                *
  53. *                                                                              *
  54. * When an IMouseClickHandler object receives a mouse click event, the          *
  55. * IMouseClickHandler object creates an IMouseClickEvent object and routes it   *
  56. * to the mouseClicked virtual function.  You should override the mouseClicked  *
  57. * virtual function to supply your own processing of a mouse event.  If the     *
  58. * virtual function indicates that the mouse click event requires no            *
  59. * additional processing, the event is not passed to any other handlers.        *
  60. * The return value from the virtual function is intrepreted as follows:        *
  61. *                                                                              *
  62. *   Value   Meaning                                                            *
  63. *   ---------------                                                            *
  64. *   true  - The IMouseClickEvent requires no additional processing and should  *
  65. *           not be passed to another handler.                                  *
  66. *   false - The IMouseClickEvent should be passed on for additional            *
  67. *           processing when the following situations occur:                    *
  68. *           -- If there is another handler for the window, the event is        *
  69. *              passed on to the next handler.                                  *
  70. *           -- If this is the last handler for the window, the event is        *
  71. *              passed on a call to the window's defaultProcedure function.     *
  72. *              This could result in the event being dispatched to the          *
  73. *              window's owner window, where the processing of the mouse click  *
  74. *              event starts again.                                             *
  75. *                                                                              *
  76. * Example:                                                                     *
  77. *   MyWindow::MyWindow()                                                       *
  78. *     : ...                                                                    *
  79. *   {                                                                          *
  80. *     MyMouseClickHandler* mchBitmap = new MyMouseClickHandler();              *
  81. *     ...                                                                      *
  82. *     IBitmapControl* bmp = new IBitmapControl(ID_EF, this, this,              *
  83. *                                          IResourceId(...), IRectangle(...)); *
  84. *     mchBitmap->handleEventsFor(bmp);                                         *
  85. *     ...                                                                      *
  86. *     show();                                                                  *
  87. *   }                                                                          *
  88. *   Boolean  MyMouseClickHandler::mouseClicked(IMouseClickEvent& mcevt)        *
  89. *   {                                                                          *
  90. *     Boolean bRc = false;                                                     *
  91. *     if (mcevt.mouseNumber() == IMouseClickEvent::button1  &&                 *
  92. *         mcevt.mouseAction() == IMouseClickEvent::click)                      *
  93. *     {                           // bitmap clicked on                         *
  94. *        // change bitmap if appropriate                                       *
  95. *        bRc = true;                                                           *
  96. *     }                                                                        *
  97. *     return bRc;                                                              *
  98. *   }                                                                          *
  99. *******************************************************************************/
  100. public:
  101. /*-------------------------- Constructor/Destructor ----------------------------
  102. | The only way to construct instances of this class is to use the default      |
  103. | constructor, which does not take any arguments.                              |
  104. ------------------------------------------------------------------------------*/
  105.   IMouseClickHandler   ( );
  106. virtual
  107.  ~IMouseClickHandler   ( );
  108.  
  109. protected:
  110. /*---------------------------- Event Dispatching -------------------------------
  111. | This function evaluates the event to determine if it is appropriate for      |
  112. | this handler object to process.  If it is, this function calls the virtual   |
  113. | function used to process the event.                                          |
  114. |   dispatchHandlerEvent - Calls the mouseClicked virtual function to process  |
  115. |                          a mouse click event.                                |
  116. ------------------------------------------------------------------------------*/
  117. virtual Boolean
  118.   dispatchHandlerEvent ( IEvent& event );
  119.  
  120. /*----------------------------- Event Processing -------------------------------
  121. | This function must be supplied by a derived class to process a mouse click   |
  122. | event.                                                                       |
  123. |   mouseClicked - Implemented by derived classes to process a mouse click     |
  124. |                  event.                                                      |
  125. ------------------------------------------------------------------------------*/
  126. virtual Boolean
  127.   mouseClicked         ( IMouseClickEvent& event ) = 0;
  128. }; // IMouseClickHandler
  129.  
  130. /*----------------------------------------------------------------------------*/
  131. /* Resume compiler default packing.                                           */
  132. /*----------------------------------------------------------------------------*/
  133. #pragma pack()
  134.  
  135. #endif /* _IMCHDR_ */
  136.