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

  1. #ifndef _ISCRLHDR_
  2.   #define _ISCRLHDR_
  3. /*******************************************************************************
  4. * FILE NAME: iscrlhdr.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IScrollHandler - Process a scrolling event for an IScrollBar object.     *
  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 _ISCRLEVT_
  22.   #include <iscrlevt.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 IScrollHandler : public IHandler {
  35. typedef IHandler
  36.   Inherited;
  37. /*******************************************************************************
  38. * The IScrollHandler class handles events that result from a user interacting  *
  39. * with an IScrollBar object, such as when the user clicks on the down scroll   *
  40. * button of a vertical scroll bar.  An IScrollHandler should be used to        *
  41. * handle scroll events for the owner window of a scroll bar.  This is done by  *
  42. * passing the owner window to the handleEventsFor function of the              *
  43. * IScrollHandler object.                                                       *
  44. *                                                                              *
  45. * NOTE: Scroll events are not first dispatched to the scroll bar itself.       *
  46. *                                                                              *
  47. * When it receives a scroll event, the IScrollHandler object creates an        *
  48. * IScrollEvent object and routes it to the appropriate virtual function.  You  *
  49. * can override the virtual functions of IScrollHandler to supply your own      *
  50. * specialized processing of an event.  The return value from the virtual       *
  51. * functions specifies whether the IScrollEvent should be passed on for more    *
  52. * processing, as follows:                                                      *
  53. *                                                                              *
  54. *   Value   Meaning                                                            *
  55. *   ---------------                                                            *
  56. *   true  - The IScrollEvent has been handled and requires no additional       *
  57. *           processing.                                                        *
  58. *   false - The IScrollEvent should be passed on to the next handler.  If the  *
  59. *           next handler is the last handler for the owner window, the event   *
  60. *           is passed on to a call to the window's defaultProcedure function   *
  61. *           (see IWindow::defaultProcedure).                                   *
  62. *                                                                              *
  63. * Example:                                                                     *
  64. *   MyWindow::MyWindow()   // inherits from IWindow, IScrollHandler            *
  65. *     : sb(ID_SB, this, this, IRectangle(...)),   // IScrollBar object         *
  66. *       stxtPos(0, this, this, IRectangle(...)),  // IStaticText object        *
  67. *       ...                                                                    *
  68. *   {                                                                          *
  69. *     ((IScrollHandler*)this)->handleEventsFor(this);  // for events from sb   *
  70. *     ...                                                                      *
  71. *     show();                                                                  *
  72. *   }                                                                          *
  73. *   Boolean  MyWindow::pageUp(IScrollEvent& evt)                               *
  74. *   {                                                                          *
  75. *     Boolean bProcessed = false;                                              *
  76. *     ulScroll = evt.scrollAmount(); // get the number of items scrolled       *
  77. *     if (evt.scrollBarWindow()->handle() == sb.handle())                      *
  78. *     {                         // scroll event for sb                         *
  79. *        ...                    // scroll the associated window                *
  80. *        moveScrollBox(evt);    // default processing to position scroll box   *
  81. *        unsigned long ulPos = evt.scrollBarWindow->scrollBoxPosition();       *
  82. *        stxtPos.setText() = IString(ulPos);  // show current scroll position  *
  83. *        bProcessed = true;                                                    *
  84. *     }                                                                        *
  85. *     return bProcessed;                                                       *
  86. *   }                                                                          *
  87. *******************************************************************************/
  88. public:
  89. /*------------------------------- Constructor ----------------------------------
  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.   IScrollHandler       ( );
  94. virtual
  95.  ~IScrollHandler       ( );
  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 if a scroll  |
  103. |                          event is found.                                     |
  104. ------------------------------------------------------------------------------*/
  105. virtual Boolean
  106.   dispatchHandlerEvent ( IEvent& event );
  107.  
  108. /*----------------------------- Event Processing -------------------------------
  109. | These functions must be supplied by a derived class in order to process a    |
  110. | scroll event.                                                                |
  111. |   lineUp            - Implemented by derived classes to process a scroll     |
  112. |                       event initiated by clicking on the up scroll button    |
  113. |                       of a vertical scroll bar.                              |
  114. |   lineDown          - Implemented by derived classes to process a scroll     |
  115. |                       event initiated by clicking on the down scroll button  |
  116. |                       of a vertical scroll bar.                              |
  117. |   pageUp            - Implemented by derived classes to process a scroll     |
  118. |                       event initiated by clicking on the scroll shaft above  |
  119. |                       the scroll box of a vertical scroll bar.               |
  120. |   pageDown          - Implemented by derived classes to process a scroll     |
  121. |                       event initiated by clicking on the scroll shaft below  |
  122. |                       the scroll box of a vertical scroll bar.               |
  123. |   lineLeft          - Implemented by derived classes to process a scroll     |
  124. |                       event initiated by clicking on the left scroll button  |
  125. |                       of a horizontal scroll bar.                            |
  126. |   lineRight         - Implemented by derived classes to process a scroll     |
  127. |                       event initiated by clicking on the right scroll        |
  128. |                       button of a horizontal scroll bar.                     |
  129. |   pageLeft          - Implemented by derived classes to process a scroll     |
  130. |                       event initiated by clicking on the scroll shaft to     |
  131. |                       the left of the scroll box of a horizontal scroll bar. |
  132. |   pageRight         - Implemented by derived classes to process a scroll     |
  133. |                       event initiated by clicking on the scroll shaft to     |
  134. |                       the right of the scroll box of a horizontal scroll     |
  135. |                       bar.                                                   |
  136. |   scrollBoxTrack    - Implemented by derived classes to process a scroll     |
  137. |                       event each time the scroll box is moved by dragging    |
  138. |                       it with the mouse.                                     |
  139. |   scrollBoxTrackEnd - Implemented by derived classes to process the end of   |
  140. |                       a scroll event that is being performed by dragging     |
  141. |                       the scroll box with the mouse.                         |
  142. |   scrollEnd         - Implemented by derived classes to process the end of   |
  143. |                       a scroll event not caused by dragging the scroll box,  |
  144. |                       such as releasing the mouse button after clicking on   |
  145. |                       a scroll button or scroll shaft.                       |
  146. ------------------------------------------------------------------------------*/
  147. virtual Boolean
  148.   lineUp               ( IScrollEvent& event ),
  149.   lineDown             ( IScrollEvent& event ),
  150.   pageUp               ( IScrollEvent& event ),
  151.   pageDown             ( IScrollEvent& event ),
  152.   lineLeft             ( IScrollEvent& event ),
  153.   lineRight            ( IScrollEvent& event ),
  154.   pageLeft             ( IScrollEvent& event ),
  155.   pageRight            ( IScrollEvent& event ),
  156.   scrollBoxTrack       ( IScrollEvent& event ),
  157.   scrollBoxTrackEnd    ( IScrollEvent& event ),
  158.   scrollEnd            ( IScrollEvent& event );
  159.  
  160. /*------------------------------ Implementation --------------------------------
  161. | This function is called by many of the virtual functions to provide some     |
  162. | default processing of a scroll event:                                        |
  163. |   moveScrollBox  - Positions the scroll box based on the scroll event.       |
  164. ------------------------------------------------------------------------------*/
  165. IScrollHandler
  166.  &moveScrollBox        ( IScrollEvent& event );
  167. }; // IScrollHandler
  168.  
  169. /*----------------------------------------------------------------------------*/
  170. /* Resume compiler default packing.                                           */
  171. /*----------------------------------------------------------------------------*/
  172. #pragma pack()
  173.  
  174. #endif /* _ISCRLHDR_ */
  175.