1 /////////////////////////////////////////////////////////////////////////////// 
   2 // Name:        wx/univ/scrthumb.h 
   3 // Purpose:     wxScrollThumb class 
   4 // Author:      Vadim Zeitlin 
   8 // Copyright:   (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) 
   9 // Licence:     wxWindows licence 
  10 /////////////////////////////////////////////////////////////////////////////// 
  12 #ifndef _WX_UNIV_SCRTHUMB_H_ 
  13 #define _WX_UNIV_SCRTHUMB_H_ 
  15 // ---------------------------------------------------------------------------- 
  16 // wxScrollThumb is not a control but just a class containing the common 
  17 // functionality of scroll thumb such as used by scrollbars, sliders and maybe 
  18 // other (user) controls 
  20 // This class is similar to wxScrollThumb. 
  21 // ---------------------------------------------------------------------------- 
  23 class WXDLLIMPEXP_FWD_CORE wxControlWithThumb
; 
  24 class WXDLLIMPEXP_FWD_CORE wxMouseEvent
; 
  25 class WXDLLIMPEXP_FWD_CORE wxRect
; 
  26 class WXDLLIMPEXP_FWD_CORE wxScrollTimer
; 
  30 // ---------------------------------------------------------------------------- 
  31 // wxScrollThumb: an abstraction of scrollbar thumb 
  32 // ---------------------------------------------------------------------------- 
  34 class WXDLLIMPEXP_CORE wxScrollThumb
 
  40         Shaft_Above
,    // or to the left of the thumb 
  41         Shaft_Below
,    // or to the right of the thumb 
  42         Shaft_Thumb
,    // on the thumb 
  46     // ctor requires a back pointer to wxControlWithThumb 
  47     wxScrollThumb(wxControlWithThumb 
*control
); 
  49     // process a mouse click: will capture the mouse if the button was pressed 
  50     // on either the thumb (start dragging it then) or the shaft (start 
  52     bool HandleMouse(const wxMouseEvent
& event
) const; 
  54     // process a mouse move 
  55     bool HandleMouseMove(const wxMouseEvent
& event
) const; 
  61     // do we have the mouse capture? 
  62     bool HasCapture() const { return m_captureData 
!= NULL
; } 
  64     // get the coord of this event in the direction we're interested in (y for 
  65     // vertical shaft or x for horizontal ones) 
  66     wxCoord 
GetMouseCoord(const wxMouseEvent
& event
) const; 
  68     // get the position of the thumb corresponding to the current mouse 
  69     // position (can only be called while we're dragging the thumb!) 
  70     int GetThumbPos(const wxMouseEvent
& event
) const; 
  73     wxControlWithThumb 
*m_control
; 
  75     // the part of it where the mouse currently is 
  78     // the data for the mouse capture 
  79     struct WXDLLIMPEXP_FWD_CORE wxScrollThumbCaptureData 
*m_captureData
; 
  82 // ---------------------------------------------------------------------------- 
  83 // wxControlWithThumb: interface implemented by controls using wxScrollThumb 
  84 // ---------------------------------------------------------------------------- 
  86 class WXDLLIMPEXP_CORE wxControlWithThumb
 
  89     virtual ~wxControlWithThumb() {} 
  94     // get the controls window (used for mouse capturing) 
  95     virtual wxWindow 
*GetWindow() = 0; 
  97     // get the orientation of the shaft (vertical or horizontal) 
  98     virtual bool IsVertical() const = 0; 
 100     // geometry functions 
 101     // ------------------ 
 103     // hit testing: return part of the shaft the point is in (or Shaft_None) 
 104     virtual wxScrollThumb::Shaft 
HitTest(const wxPoint
& pt
) const = 0; 
 106     // get the current position in pixels of the thumb 
 107     virtual wxCoord 
ThumbPosToPixel() const = 0; 
 109     // transform from pixel offset to the thumb logical position 
 110     virtual int PixelToThumbPos(wxCoord x
) const = 0; 
 115     // set or clear the specified flag in the arrow state: this function is 
 116     // responsible for refreshing the control 
 117     virtual void SetShaftPartState(wxScrollThumb::Shaft shaftPart
, 
 119                                    bool set 
= true) = 0; 
 121     // called when the user starts dragging the thumb 
 122     virtual void OnThumbDragStart(int pos
) = 0; 
 124     // called while the user drags the thumb 
 125     virtual void OnThumbDrag(int pos
) = 0; 
 127     // called when the user stops dragging the thumb 
 128     virtual void OnThumbDragEnd(int pos
) = 0; 
 130     // called before starting to call OnPageScroll() - gives the control the 
 131     // possibility to remember its current state 
 132     virtual void OnPageScrollStart() = 0; 
 134     // called while the user keeps the mouse pressed above/below the thumb, 
 135     // return true to continue scrollign and false to stop it (e.g. because the 
 136     // scrollbar has reached the top/bottom) 
 137     virtual bool OnPageScroll(int pageInc
) = 0; 
 140 #endif // _WX_UNIV_SCRTHUMB_H_