ASPiK SDK
cscrollbar.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #ifndef __cscrollbar__
6 #define __cscrollbar__
7 
8 #include "ccontrol.h"
9 #include "../ccolor.h"
10 
11 namespace VSTGUI {
12 
13 //-----------------------------------------------------------------------------
14 // CScrollbar Declaration
17 //-----------------------------------------------------------------------------
18 class CScrollbar : public CControl
19 {
20 public:
21  enum ScrollbarDirection {
22  kHorizontal,
23  kVertical
24  };
25 
26  CScrollbar (const CRect& size, IControlListener* listener, int32_t tag, ScrollbarDirection style, const CRect& scrollSize);
27  CScrollbar (const CScrollbar& scrollbar);
28 
29  //-----------------------------------------------------------------------------
31  //-----------------------------------------------------------------------------
33  virtual void setDrawer (IScrollbarDrawer* d) { drawer = d; }
34  virtual void setScrollSize (const CRect& ssize);
35  virtual void setStep (float newStep) { stepValue = newStep; }
36 
37  CRect& getScrollSize (CRect& rect) const { rect = scrollSize; return rect; }
38  float getStep () const { return stepValue; }
39 
40  virtual void setFrameColor (const CColor& color) { frameColor = color; }
41  virtual void setScrollerColor (const CColor& color) { scrollerColor = color; }
42  virtual void setBackgroundColor (const CColor& color) { backgroundColor = color; }
43 
44  CColor getFrameColor () const { return frameColor; }
45  CColor getScrollerColor () const { return scrollerColor; }
46  CColor getBackgroundColor () const { return backgroundColor; }
47 
48  bool getOverlayStyle () const { return overlayStyle; }
49  virtual void setOverlayStyle (bool state);
50 
51  virtual void onVisualChange ();
52  CRect getScrollerRect ();
54 
55  // overwrite
56  void draw (CDrawContext* pContext) override;
57  bool onWheel (const CPoint& where, const CMouseWheelAxis& axis, const float& distance, const CButtonState& buttons) override;
58  CMouseEventResult onMouseDown (CPoint& where, const CButtonState& buttons) override;
59  CMouseEventResult onMouseUp (CPoint& where, const CButtonState& buttons) override;
60  CMouseEventResult onMouseMoved (CPoint& where, const CButtonState& buttons) override;
61  CMouseEventResult onMouseCancel () override;
62  CMessageResult notify (CBaseObject* sender, IdStringPtr message) override;
63  void setViewSize (const CRect& newSize, bool invalid) override;
64 
65  CMouseEventResult onMouseEntered (CPoint& where, const CButtonState& buttons) override;
66  CMouseEventResult onMouseExited (CPoint& where, const CButtonState& buttons) override;
67 
68  CLASS_METHODS(CScrollbar, CControl)
69  //-----------------------------------------------------------------------------
70 protected:
71  ~CScrollbar () noexcept override = default;
72 
73  void drawBackground (CDrawContext* pContext);
74  void drawScroller (CDrawContext* pContext, const CRect& size);
75 
76  void calculateScrollerLength ();
77  void doStepping ();
78 
79  ScrollbarDirection direction;
80  CRect scrollSize;
81  CRect scrollerArea;
82 
83  float stepValue;
84  CCoord scrollerLength;
85 
86  CColor frameColor;
87  CColor scrollerColor;
88  CColor backgroundColor;
89 
90  bool overlayStyle;
91  bool mouseIsInside;
92 
93  IScrollbarDrawer* drawer;
94 private:
96  CPoint startPoint;
97  CRect scrollerRect;
98  bool scrolling;
99 };
100 
101 //-----------------------------------------------------------------------------
103 //-----------------------------------------------------------------------------
104 {
105 public:
106  virtual void drawScrollbarBackground (CDrawContext* pContext, const CRect& size, CScrollbar::ScrollbarDirection direction, CScrollbar* bar) = 0;
107  virtual void drawScrollbarScroller (CDrawContext* pContext, const CRect& size, CScrollbar::ScrollbarDirection direction, CScrollbar* bar) = 0;
108 };
109 
110 
111 }
112 
113 #endif // __cscrollbar__
CMouseEventResult onMouseMoved(CPoint &where, const CButtonState &buttons) override
called when a mouse move event occurs
Definition: cscrollbar.cpp:239
void draw(CDrawContext *pContext) override
called if the view should draw itself
Definition: cscrollbar.cpp:391
bool onWheel(const CPoint &where, const CMouseWheelAxis &axis, const float &distance, const CButtonState &buttons) override
called if a mouse wheel event is happening over this view
Definition: cscrollbar.cpp:307
Rect structure.
Definition: crect.h:17
Definition: cscrollbar.h:102
void setViewSize(const CRect &newSize, bool invalid) override
set views size
Definition: cscrollbar.cpp:55
Definition: xmlparse.c:181
Definition: vstguibase.h:299
A drawing context encapsulates the drawing context of the underlying OS.
Definition: cdrawcontext.h:29
Base Object with reference counter.
Definition: vstguibase.h:276
RGBA Color structure.
Definition: ccolor.h:15
a scrollbar control
Definition: cscrollbar.h:18
Definition: customcontrols.cpp:8
base class of all VSTGUI controls
Definition: ccontrol.h:76
Button and Modifier state.
Definition: cbuttonstate.h:34
CMouseEventResult onMouseDown(CPoint &where, const CButtonState &buttons) override
called when a mouse down event occurs
Definition: cscrollbar.cpp:209
CMouseEventResult onMouseCancel() override
called when mouse tracking should be canceled
Definition: cscrollbar.cpp:280
virtual void invalid()
mark whole view as invalid
Definition: cview.h:63
CMouseEventResult onMouseEntered(CPoint &where, const CButtonState &buttons) override
called when the mouse enters this view
Definition: cscrollbar.cpp:178
CMouseEventResult onMouseUp(CPoint &where, const CButtonState &buttons) override
called when a mouse up event occurs
Definition: cscrollbar.cpp:232
Point structure.
Definition: cpoint.h:17
Definition: icontrollistener.h:14
CMouseEventResult onMouseExited(CPoint &where, const CButtonState &buttons) override
called when the mouse leaves this view
Definition: cscrollbar.cpp:189