home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 3.ddi / OWLINC.ZIP / SCROLLER.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  4.8 KB  |  140 lines

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #ifndef __SCROLLER_H
  4. #define __SCROLLER_H
  5.  
  6. // SCROLLER.H
  7. // Defines type TScroller.
  8. //
  9.  
  10. #pragma option -Vo-
  11. #if     defined(__BCOPT__) && !defined(_ALLOW_po)
  12. #pragma option -po-
  13. #endif
  14.  
  15. _CLASSDEF(TWindow)
  16. _CLASSDEF(TScroller)
  17.  
  18. #define MaxInt 32767
  19. long LongMulDiv(long Mult1, long Mult2, long Div1);
  20.  
  21.   /* TScroller object */
  22.  
  23. class _EXPORT TScroller : public Object, public TStreamable
  24. {
  25. public:
  26.     PTWindow Window;
  27.     long XPos, YPos;      // current pos in horz/vert scroll units
  28.     long XRange, YRange;  // # of scrollable horz/vert scroll units
  29.     int XUnit, YUnit;     //logical device units per horz/vert scroll unit
  30.     int XLine, YLine;        // # of horz/vert scroll units per line
  31.     int XPage, YPage;        // # of horz/vert scroll units per page
  32.     BOOL AutoMode;           // auto scrolling mode
  33.     BOOL TrackMode;          // track scroll mode
  34.     BOOL AutoOrg;            // indicates Scroller offsets origin
  35.     BOOL HasHScrollBar;
  36.     BOOL HasVScrollBar;
  37.  
  38.     TScroller(PTWindow TheWindow, int TheXUnit, int TheYUnit,
  39.               long TheXRange, long TheYRange);
  40.     ~TScroller();
  41.     void SetUnits(int TheXUnit, int TheYUnit);
  42.     virtual void SetPageSize();
  43.     virtual void SetSBarRange();
  44.     void SetRange(long TheXRange, long TheYRange);
  45. #if defined(WIN31)
  46.     // windows 3.1 interface
  47.     virtual void BeginView(HDC PaintDC, PAINTSTRUCT _FAR & PaintInfo);
  48. #endif
  49. #if defined(WIN30)
  50.     // windows 3.0 interface
  51.     virtual void BeginView(HDC_30 PaintDC, PAINTSTRUCT _FAR & PaintInfo);
  52. #endif
  53. #if (defined(WIN30) || defined(WIN31)) && !(defined(WIN30) && defined(WIN31))
  54.     // this function is never called. it is used to pad the vtable so that
  55.     // exactly two BeginView(...) definitions are always present.
  56.     virtual void BeginView(void *, void *) { };
  57. #endif
  58.     virtual void EndView();
  59.     virtual void VScroll(WORD ScrollEvent, int ThumbPos);
  60.     virtual void HScroll(WORD ScrollEvent, int ThumbPos);
  61.     virtual void ScrollTo(long X, long Y);
  62.  
  63.     /* Scrolls to a position calculated using the passed
  64.        "Delta" values. */
  65.     void ScrollBy(long Dx, long Dy)
  66.         { ScrollTo(XPos + Dx, YPos + Dy); }
  67.  
  68.     virtual void AutoScroll();
  69.  
  70.     /* Returns a BOOL value indicating whether or not the passed
  71.        area (in units) is currently visible. */
  72.     BOOL IsVisibleRect(long X, long Y, int XExt, int YExt)
  73.         { return (X + XExt >= XPos) && (Y + YExt >= YPos) &&
  74.              (X < XPos + XPage) && (Y < YPos + YPage); }
  75.  
  76.     /* Converts a horizontal range value from the scrollbar to a
  77.        horizontal scroll value. */
  78.     int XScrollValue(long ARangeUnit)
  79.         { return (int)LongMulDiv(ARangeUnit, MaxInt, XRange); }
  80.  
  81.     /* Converts a vertical range value from the scrollbar to a
  82.        vertical scroll value. */
  83.     int YScrollValue(long ARangeUnit)
  84.         { return (int)LongMulDiv(ARangeUnit, MaxInt, YRange); }
  85.  
  86.     /* Converts a horizontal scroll value from the scrollbar to
  87.        a horizontal range value. */
  88.     long XRangeValue(int AScrollUnit)
  89.         { return LongMulDiv(AScrollUnit, XRange, MaxInt); }
  90.  
  91.     /* Converts a vertical scroll value from the scrollbar to
  92.        a vertical range value. */
  93.     long YRangeValue(int AScrollUnit)
  94.         { return LongMulDiv(AScrollUnit, YRange, MaxInt); }
  95.  
  96.     // define pure virtual functions derived from Object class
  97.     virtual classType      isA() const
  98.         { return scrollerClass; }
  99.     virtual Pchar nameOf() const
  100.         { return "TScroller"; }
  101.     virtual hashValueType hashValue() const
  102.         { return InstanceHashValue; }
  103.     virtual int       isEqual(RCObject testobj)  const
  104.         { return (this ==  &(RTScroller)testobj); }
  105.     virtual void         printOn(Rostream outputStream) const
  106.         { outputStream << nameOf() << "{ Window = " << Window <<" }\n";}
  107.  
  108.     static PTStreamable build();
  109.  
  110. protected:
  111.     TScroller(StreamableInit) {};
  112.     virtual void write (Ropstream os);
  113.     virtual Pvoid read (Ripstream is);
  114.     hashValueType InstanceHashValue;
  115.     static hashValueType ClassHashValue;
  116.  
  117. private:
  118.     virtual const Pchar streamableName() const
  119.         { return "TScroller"; }
  120.     
  121.     void __BeginView(HDC PaintDC, PAINTSTRUCT _FAR & PaintInfo);    
  122. };
  123.  
  124. inline Ripstream operator >> ( Ripstream is, RTScroller cl )
  125.     { return is >> (RTStreamable )cl; }
  126. inline Ripstream operator >> ( Ripstream is, RPTScroller cl )
  127.     { return is >> (RPvoid)cl; }
  128.  
  129. inline Ropstream operator << ( Ropstream os, RTScroller cl )
  130.     { return os << (RTStreamable )cl; }
  131. inline Ropstream operator << ( Ropstream os, PTScroller cl )
  132.     { return os << (PTStreamable )cl; }
  133.  
  134. #pragma option -Vo.
  135. #if     defined(__BCOPT__) && !defined(_ALLOW_po)
  136. #pragma option -po.
  137. #endif
  138.  
  139. #endif  // ifdef __SCROLLER_H
  140.