home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / OWLINC.PAK / SLIDER.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  5KB  |  178 lines

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