home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 19.ddi / OWLINC.PAK / SLIDER.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  5.3 KB  |  177 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   include\owl\slider.h
  4. //   Defines class TSlider & TVSlider.  This defines the basic behavior
  5. //   of slider controls.
  6. //----------------------------------------------------------------------------
  7. #if !defined(__OWL_SLIDER_H)
  8. #define __OWL_SLIDER_H
  9.  
  10. #if !defined(__OWL_SCROLLBA_H)
  11.   #include <owl\scrollba.h>
  12. #endif
  13. #if !defined(__OWL_COLOR_H)
  14.   #include <owl\color.h>
  15. #endif
  16. #include <owl\slider.rh>
  17.  
  18. class _OWLCLASS TDC;
  19. class _OWLCLASS TRegion;
  20. class _OWLCLASS TBrush;
  21.  
  22. //
  23. //  class TSlider
  24. //  ----- -------
  25. //
  26. class _OWLCLASS TSlider : public TScrollBar {
  27.   public:
  28.     TSlider(TWindow*        parent,
  29.             int             id,
  30.             int X, int Y, int W, int H,
  31.             TResId          thumbResId,
  32.             TModule*        module = 0);
  33.  
  34.     ~TSlider();
  35.  
  36.     //
  37.     // Overload TScrollBar virtual functions 
  38.     //
  39.     void          GetRange(int& min, int& max) const {min = Min; max = Max;}
  40.     int           GetPosition() const {return Pos;}
  41.     void          SetRange(int min, int max);
  42.     void          SetPosition(int thumbPos);
  43.     
  44.     void          SetRuler(int ticGap, BOOL snap = FALSE)
  45.                     {TicGap = ticGap; Snap = snap;}
  46.  
  47.   protected:
  48.  
  49.     //
  50.     // Override TWindow virtual member functions
  51.     //
  52.     void          SetupWindow();
  53.   
  54.     //
  55.     // TSlider virtual functions
  56.     //
  57.     virtual int    PointToPos(TPoint& point) = 0;
  58.     virtual TPoint PosToPoint(int pos) = 0;
  59.     virtual void   NotifyParent(int scrollCode, int pos=0) = 0;
  60.  
  61.     virtual void   SetupThumbRgn();
  62.     virtual int    HitTest(TPoint& point) = 0;
  63.     virtual void   SlideThumb(TDC& dc, int thumbPos);
  64.     
  65.     virtual void   PaintRuler(TDC& dc) = 0;
  66.     virtual void   PaintSlot(TDC& dc) = 0;
  67.     virtual void   PaintThumb(TDC& dc);
  68.  
  69.     int            SnapPos(int pos);
  70.     void           GetBkColor(TDC& dc);
  71.  
  72.     //
  73.     // message response functions
  74.     //
  75.     void          EvSize(UINT sizeType, TSize& size);
  76.     UINT          EvGetDlgCode(MSG far*);
  77.     BOOL          EvEraseBkgnd(HDC hDC);
  78.     void          EvPaint();
  79.     void          EvLButtonDown(UINT modKeys, TPoint& point);
  80.     void          EvMouseMove(UINT modKeys, TPoint& point);
  81.     void          EvLButtonUp(UINT modKeys, TPoint& point);
  82.     void          EvLButtonDblClk(UINT modKeys, TPoint& point);
  83.     void          EvKeyDown(UINT key, UINT repeatCount, UINT flags);
  84.     void          EvSetFocus(HWND hWndLostFocus);
  85.     void          EvKillFocus(HWND hWndGetFocus);
  86.   
  87.   protected:
  88.     int           Min;        // Minimum position value
  89.     int           Max;        // Maximum position value
  90.     UINT          Range;      // Positive range
  91.     int           Pos;        // Current position value
  92.     TResId        ThumbResId; // Bitmap res id for thumb knob
  93.     TRect         ThumbRect;  // Bounding rect of Thumb in pixels
  94.     TRegion*      ThumbRgn;   // Optional clipping/hit test region
  95.     TRect         CaretRect;  // Bounding rect of Thumb's blink caret
  96.     int           SlotThick;  // Thickness(width or height) of slot
  97.     int           TicGap;     // Gap between tics in pos units
  98.     BOOL          Snap;       // Snap Thumb to tics
  99.  
  100.     BOOL          Sliding;
  101.     TColor        BkColor;    // color to use to paint background
  102.  
  103.     //
  104.     // Statics used while the mouse is down & Thumb is sliding
  105.     //
  106.     static TSize  MouseOffset;
  107.     static TDC*   SlideDC;
  108.  
  109.   DECLARE_RESPONSE_TABLE(TSlider);
  110.   DECLARE_ABSTRACT_STREAMABLE(_OWLCLASS, TSlider, 1);
  111. };
  112.  
  113. //
  114. //  class THSlider
  115. //  ----- --------
  116. //
  117. class _OWLCLASS THSlider : public TSlider {
  118.   public:
  119.     THSlider(TWindow*        parent,
  120.              int             id,
  121.              int X, int Y, int W, int H,
  122.              TResId          thumbResId = IDB_HSLIDERTHUMB,
  123.              TModule*        module = 0);
  124.  
  125.   protected:
  126.     //
  127.     // Override TSlider virtual member functions
  128.     //
  129.     int    PointToPos(TPoint& point);
  130.     TPoint PosToPoint(int pos);
  131.     void   NotifyParent(int scrollCode, int pos=0);
  132.     int    HitTest(TPoint& point);
  133.     void   PaintRuler(TDC& dc);
  134.     void   PaintSlot(TDC& dc);
  135.   
  136.   private:
  137.     //
  138.     // hidden to prevent accidental copying or assignment
  139.     //
  140.     THSlider(const THSlider&);
  141.     THSlider& operator =(const THSlider&);
  142.  
  143.   DECLARE_STREAMABLE(_OWLCLASS, THSlider, 1);
  144. };
  145.  
  146. //
  147. //  class TVSlider
  148. //  ----- --------
  149. //
  150. class _OWLCLASS TVSlider : public TSlider {
  151.   public:
  152.     TVSlider(TWindow*        parent,
  153.              int             id,
  154.              int X, int Y, int W, int H,
  155.              TResId          thumbResId = IDB_VSLIDERTHUMB,
  156.              TModule*        module = 0);
  157.  
  158.   protected:
  159.     //
  160.     // Override TSlider virtual member functions
  161.     //
  162.     int    PointToPos(TPoint& point);
  163.     TPoint PosToPoint(int pos);
  164.     void   NotifyParent(int scrollCode, int pos=0);
  165.     int    HitTest(TPoint& point);
  166.     void   PaintRuler(TDC& dc);
  167.     void   PaintSlot(TDC& dc);
  168.   
  169.   private:
  170.     TVSlider(const TVSlider&);
  171.     TVSlider& operator =(const TVSlider&);
  172.  
  173.   DECLARE_STREAMABLE(_OWLCLASS, TVSlider, 1);
  174. };
  175.  
  176. #endif  // __OWL_SLIDER_H
  177.