home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / iscroll.hp_ / ISCROLL.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  8.1 KB  |  165 lines

  1. #ifndef _ISCROLL_
  2.   #define _ISCROLL_
  3. /*******************************************************************************
  4. * FILE NAME: Iscroll.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *    Iscroll  - This class creates and manages the scroll bar control window.  *
  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. * $Log:   R:/IBMCLASS/IBASECTL/VCS/ISCROLL.HPV  $
  18. //
  19. //   Rev 1.4   25 Oct 1992 17:06:02   nunn
  20. //changed library name to ICLUI
  21. //
  22. //   Rev 1.3   25 Oct 1992 15:36:10   tsuji
  23. //Update example, add IWindow::visible to default style.
  24. //
  25. //   Rev 1.2   25 Oct 1992 10:56:52   boezeman
  26. //Add documentation and converted file to skeleton.hpp format.
  27.  
  28.       Rev 1.2   25 Sep 1992 21:22:06   KKL
  29.    Update for OS/2 2.0
  30.       Rev 1.1   ?? ??? ???? ??:??:??   Tim Hertz
  31.    Initial design and code V2.0
  32. *******************************************************************************/
  33. #ifndef _ICONTROL_
  34.   #include <icontrol.hpp>
  35. #endif
  36.  
  37. // Forward declarations for other classes:
  38. class IScrollBar;
  39. class IWindow;
  40. class IRectangle;
  41. class IRange;
  42.  
  43. class IScrollBar : public IControl  {
  44. /*******************************************************************************
  45. * This class creates and manages the scroll bar control window.                *
  46. *                                                                              *
  47. * EXAMPLE:                                                                     *
  48. * To create the scroll bar:                                                    *
  49. *    pvsb = new IScrollBar(ID_MYVERTSCROLL,                                    *
  50. *                          this,                                               *
  51. *                          IRectangle(0,45, 20,200),                           *
  52. *                          IRange(1,20),                                       *
  53. *                          5);                                                 *
  54. *    pvsb->setLineSize(1);                                                     *
  55. * Then to catch the scroll messages, add:                                      *
  56. *    MyScrollHandler sbh = new MyScrollHandler();                              *
  57. *    pvsb->addHandler(this);                                                   *
  58. * Finally, to process the scroll messages:                                     *
  59. *    Boolean  MyScrollHandler::pageUp(IScrollEvent& evt)                       *
  60. *    {                                                                         *
  61. *       // Scroll the information in the related window                        *
  62. *       //                                                                     *
  63. *       // Call the scroll bar's moveSliderTo function to update its           *
  64. *       //      slider (thumb) position                                        *
  65. *       return true;                                                           *
  66. *    }                                                                         *
  67. *******************************************************************************/
  68. typedef IControl
  69.   Inherited;
  70. public:
  71. INESTEDBITFLAGCLASSDEF1(Style, IScrollBar, IWindow);
  72. static const Style
  73.   autoTrack,
  74.   horizontal,
  75.   vertical;
  76.  
  77. static const unsigned long
  78.   sysVScrollBarWidth,
  79.   sysHScrollBarHeight,
  80.   sysVScrollBarArrowHeight,
  81.   sysHScrollBarArrowWidth,
  82.   sysVScrollSliderHeight,
  83.   sysHScrollSliderWidth;
  84.  
  85. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  86. | There are 4 ways to construct instances of this class:                       |
  87. |   1. default                                                                 |
  88. |   2. Creates a scroll bar with slider range and position                     |
  89. |   3. From a Dialog Template                                                  |
  90. |   4. From a Window                                                           |
  91. ------------------------------------------------------------------------------*/
  92.   IScrollBar(unsigned long winId, const IWindow* parent,
  93.              const IWindow* owner, const IRectangle& rect,
  94.              Style style = (IWindow::visible | vertical | autoTrack));
  95.  
  96.   IScrollBar(unsigned long winId, const IWindow* parent,
  97.              const IWindow* owner, const IRectangle& rect,
  98.              const IRange& minMaxScrollUnit,
  99.              unsigned long sliderUnit,
  100.              unsigned long sliderPos = 1,
  101.              Style style = (IWindow::visible | vertical | autoTrack));
  102.  
  103.   IScrollBar(unsigned long winId, const IWindow* parent);
  104.   IScrollBar(IWindowHandle handle);
  105.  
  106. /*-------------------------------- STYLES --------------------------------------
  107. | These functions provide means of getting and setting the scroll bar styles   |
  108. |   isHorizontal     - Returns true if the scroll bar has the horizontal style.|
  109. |   isVertical       - Returns true if the scroll bar has the vertical style.  |
  110. |   isAutoTrack      - Returns true if the scroll bar has the autotrack style. |
  111. |   enableAutoTrack  - Enables autotrack style for the scroll bar.             |
  112. |   disableAutoTrack - Disables autotrack style for the scroll bar.            |
  113. ------------------------------------------------------------------------------*/
  114. Boolean
  115.   isHorizontal() const,
  116.   isVertical() const,
  117.   isAutoTrack() const;
  118. void
  119.   enableAutoTrack(),
  120.   disableAutoTrack();
  121. /*-------------------------------- MISCELLANEOUS OPERATIONS --------------------
  122. | moveSliderTo    - Move the scroll bar slider to the position given.          |
  123. | setSliderUnit   - Sets the slider size.                                      |
  124. | setScrollUnit   - Sets the range the scroll bar represents.                  |
  125. | setLineUnit     - Sets the line size.                                        |
  126. | scrollUnit      - Returns the range that the scroll bar represents.          |
  127. | sliderPosition  - Returns the current position of the slider.                |
  128. | sliderUnit      - Returns the slider size.                                   |
  129. | lineUnit        - Returns the line size.  The line size must be set using the|
  130. |                   setLineUnit to be accurate.                                |
  131. ------------------------------------------------------------------------------*/
  132. void
  133.   moveSliderTo(unsigned long position = 1),
  134.   setSliderUnit(unsigned long sliderUnit),
  135.   setScrollUnit(const IRange& minMaxScrollUnit),
  136.   setLineUnit(unsigned long value = 1);
  137. IRange
  138.   scrollUnit() const;
  139. unsigned long
  140.   sliderPosition() const,
  141.   sliderUnit() const,
  142.   lineUnit() const;
  143.  
  144. private:
  145. /*--------------------------------- PRIVATE ----------------------------------*/
  146. unsigned long
  147.   ulClLineUnit;
  148. };
  149.  
  150. INESTEDBITFLAGCLASSFUNCS(Style, IScrollBar);
  151.  
  152. /*--------------------------------- INLINES ----------------------------------*/
  153. inline void IScrollBar::setLineUnit(unsigned long ulLineUnit)
  154. /***************************************************************/
  155. /* Set line scroll value.                                      */
  156. /***************************************************************/
  157. { ulClLineUnit = ulLineUnit; }
  158.  
  159. inline unsigned long IScrollBar::lineUnit() const
  160. /***************************************************************/
  161. /* Return line scroll value.                                   */
  162. /***************************************************************/
  163. { return ulClLineUnit; }
  164. #endif /* _ISCROLL_ */
  165.