ASPiK SDK
cscrollview.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 __cscrollview__
6 #define __cscrollview__
7 
8 #include "vstguifwd.h"
9 #include "cviewcontainer.h"
10 #include "iviewlistener.h"
11 #include "controls/icontrollistener.h"
12 
13 namespace VSTGUI {
14 class CScrollContainer;
15 
16 //-----------------------------------------------------------------------------
17 // CScrollView Declaration
20 //-----------------------------------------------------------------------------
22 {
23 protected:
24  enum
25  {
26  kHorizontalScrollbarFlag,
27  kVerticalScrollbarFlag,
28  kDontDrawFrameFlag,
29  kAutoDragScollingFlag,
30  kOverlayScrollbarsFlag,
31  kFollowFocusViewFlag,
32  kAutoHideScrollbarsFlag,
33 
34  kLastScrollViewStyleFlag
35  };
36 
37 public:
38  CScrollView (const CRect& size, const CRect& containerSize, int32_t style, CCoord scrollbarWidth = 16, CBitmap* pBackground = nullptr);
39  CScrollView (const CScrollView& scrollView);
40 
43  {
44  kHorizontalScrollbar = 1 << kHorizontalScrollbarFlag,
45  kVerticalScrollbar = 1 << kVerticalScrollbarFlag,
46  kDontDrawFrame = 1 << kDontDrawFrameFlag,
47  kAutoDragScrolling = 1 << kAutoDragScollingFlag,
48  kOverlayScrollbars = 1 << kOverlayScrollbarsFlag,
49  kFollowFocusView = 1 << kFollowFocusViewFlag,
50  kAutoHideScrollbars = 1 << kAutoHideScrollbarsFlag
51  };
52 
53  //-----------------------------------------------------------------------------
55  //-----------------------------------------------------------------------------
57  int32_t getStyle () const { return style; }
58  void setStyle (int32_t newStyle);
59 
60  int32_t getActiveScrollbars () const { return activeScrollbarStyle; }
61 
62  CCoord getScrollbarWidth () const { return scrollbarWidth; }
63  void setScrollbarWidth (CCoord width);
64 
65  virtual void setContainerSize (const CRect& cs, bool keepVisibleArea = false);
66  const CRect& getContainerSize () const { return containerSize; }
67  const CPoint& getScrollOffset () const;
68  void resetScrollOffset ();
69 
70  CScrollbar* getVerticalScrollbar () const { return vsb; }
71  CScrollbar* getHorizontalScrollbar () const { return hsb; }
72 
73  virtual void makeRectVisible (const CRect& rect);
74 
75 
76  // overwrite
77  bool addView (CView* pView) override;
78  bool addView (CView* pView, const CRect& mouseableArea, bool mouseEnabled = true) override;
79  bool addView (CView* pView, CView* pBefore) override;
80  bool removeView (CView* pView, bool withForget = true) override;
81  bool removeAll (bool withForget = true) override;
82  uint32_t getNbViews () const override;
83  CView* getView (uint32_t index) const override;
84  void drawBackgroundRect (CDrawContext* pContext, const CRect& _updateRect) override;
85  bool onWheel (const CPoint& where, const CMouseWheelAxis& axis, const float& distance, const CButtonState& buttons) override;
86  void valueChanged (CControl* pControl) override;
87  void setTransparency (bool val) override;
88  void setBackgroundColor (const CColor& color) override;
89  void setViewSize (const CRect& rect, bool invalid = true) override;
90  void setAutosizeFlags (int32_t flags) override;
91  CMessageResult notify (CBaseObject* sender, IdStringPtr message) override;
92 
93  CLASS_METHODS(CScrollView, CViewContainer)
94 //-----------------------------------------------------------------------------
95 protected:
96  ~CScrollView () noexcept override = default;
97  virtual void recalculateSubViews ();
98 
99  void viewSizeChanged (CView* view, const CRect& oldSize) override;
100  void viewWillDelete (CView* view) override;
101 
102  CScrollContainer* sc;
103  CScrollbar* vsb;
104  CScrollbar* hsb;
105 
106  CRect containerSize;
107  CCoord scrollbarWidth;
108  int32_t style;
109  int32_t activeScrollbarStyle;
110  bool recalculateSubViewsRecursionGard {false};
111  enum {
112  kHSBTag,
113  kVSBTag
114  };
115 };
116 
117 } // namespace
118 
119 #endif
void setBackgroundColor(const CColor &color) override
set the background color (will only be drawn if this container is not set to transparent and does not...
Definition: cscrollview.cpp:658
View Listener Interface Adapter.
Definition: iviewlistener.h:45
void invalid() override
mark whole view as invalid
Definition: cviewcontainer.cpp:618
Container Class of CView objects.
Definition: cviewcontainer.h:52
Rect structure.
Definition: crect.h:17
const CPoint & getScrollOffset() const
get scroll offset
Definition: cscrollview.cpp:604
bool removeAll(bool withForget=true) override
remove all child views
Definition: cscrollview.cpp:634
add a horizontal scrollbar
Definition: cscrollview.h:44
a scrollable container view with scrollbars
Definition: cscrollview.h:21
scroll to focus view when focus view changes
Definition: cscrollview.h:49
bool addView(CView *pView) override
add a child view
virtual void makeRectVisible(const CRect &rect)
set scrollview to show rect
Definition: cscrollview.cpp:525
A drawing context encapsulates the drawing context of the underlying OS.
Definition: cdrawcontext.h:29
void setAutosizeFlags(int32_t flags) override
set autosize flags
Definition: cscrollview.cpp:440
scrollbars are overlayed of the content
Definition: cscrollview.h:48
Base Object with reference counter.
Definition: vstguibase.h:276
automatically hides the scrollbar if the container size is smaller than the size of the scrollview ...
Definition: cscrollview.h:50
uint32_t getNbViews() const override
get the number of child views
Definition: cscrollview.cpp:640
bool removeView(CView *pView, bool withForget=true) override
remove a child view
Definition: cscrollview.cpp:628
RGBA Color structure.
Definition: ccolor.h:15
a scrollbar control
Definition: cscrollbar.h:18
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: cscrollview.cpp:718
Encapsulates various platform depended kinds of bitmaps.
Definition: cbitmap.h:21
CScrollViewStyle
Definition: cscrollview.h:42
Definition: customcontrols.cpp:8
virtual void setContainerSize(const CRect &cs, bool keepVisibleArea=false)
set the virtual size of this container
Definition: cscrollview.cpp:470
base class of all VSTGUI controls
Definition: ccontrol.h:76
Button and Modifier state.
Definition: cbuttonstate.h:34
void drawBackgroundRect(CDrawContext *pContext, const CRect &_updateRect) override
draw the background
Definition: cscrollview.cpp:710
CScrollbar * getHorizontalScrollbar() const
get the horizontal scrollbar
Definition: cscrollview.h:71
Base Class of all view objects.
Definition: cview.h:44
add a vertical scrollbar
Definition: cscrollview.h:45
automatic scrolling for drag moves
Definition: cscrollview.h:47
CView * getView(uint32_t index) const override
get the child view at index
Definition: cscrollview.cpp:646
CScrollbar * getVerticalScrollbar() const
get the vertical scrollbar
Definition: cscrollview.h:70
void setViewSize(const CRect &rect, bool invalid=true) override
set views size
Definition: cscrollview.cpp:429
void setTransparency(bool val) override
set views transparent state
Definition: cscrollview.cpp:652
don&#39;t draw frame
Definition: cscrollview.h:46
Point structure.
Definition: cpoint.h:17
Definition: icontrollistener.h:14