Numworks Epsilon  1.4.1
Graphing Calculator Operating System
scroll_view.h
Go to the documentation of this file.
1 #ifndef ESCHER_SCROLL_VIEW_H
2 #define ESCHER_SCROLL_VIEW_H
3 
4 #include <escher/view.h>
7 
8 class ScrollView : public View {
9 public:
10  ScrollView(View * contentView, ScrollViewDataSource * dataSource);
11  void drawRect(KDContext * ctx, KDRect rect) const override;
12 
13  void setTopMargin(KDCoordinate m) { m_topMargin = m; }
14  KDCoordinate topMargin() const { return m_topMargin; }
15  void setRightMargin(KDCoordinate m) { m_rightMargin = m; }
16  KDCoordinate rightMargin() const { return m_rightMargin; }
17  void setBottomMargin(KDCoordinate m) { m_bottomMargin = m; }
18  KDCoordinate bottomMargin() const { return m_bottomMargin; }
19  void setLeftMargin(KDCoordinate m) { m_leftMargin = m; }
20  KDCoordinate leftMargin() const { return m_leftMargin; }
21 
23  setTopMargin(top); setRightMargin(right); setBottomMargin(bottom); setLeftMargin(left);
24  }
25  void setMargins(KDCoordinate m) { setMargins(m, m, m, m); }
26  void setCommonMargins();
27 
28  void setShowsIndicators(bool s) { m_showsIndicators = s; }
29  bool showsIndicators() const { return m_showsIndicators; }
30  void setColorsBackground(bool c) { m_colorsBackground = c; }
31  bool colorsBackground() const { return m_colorsBackground; }
32  void setBackgroundColor(KDColor c) { m_backgroundColor = c; }
33  KDColor backgroundColor() const { return m_backgroundColor; }
34 
35  ScrollViewIndicator * verticalScrollIndicator() { return &m_verticalScrollIndicator; }
36  ScrollViewIndicator * horizontalScrollIndicator() { return &m_horizontalScrollIndicator; }
37  void setIndicatorThickness(KDCoordinate t) { m_indicatorThickness = t; }
38  KDCoordinate indicatorThickness() const { return m_indicatorThickness; }
39 
40  void setContentOffset(KDPoint offset, bool forceRelayout = false);
41  KDPoint contentOffset() const { return m_dataSource->offset(); }
42 
43  void scrollToContentPoint(KDPoint p, bool allowOverscroll = false);
44  void scrollToContentRect(KDRect rect, bool allowOverscroll = false); // Minimal scrolling to make this rect visible
45 protected:
49  void layoutSubviews() override;
50  void updateScrollIndicator();
52 #if ESCHER_VIEW_LOGGING
53  virtual const char * className() const override;
54  virtual void logAttributes(std::ostream &os) const override;
55 #endif
57 private:
58  ScrollViewDataSource * m_dataSource;
59  int numberOfSubviews() const override;
60  View * subviewAtIndex(int index) override;
61 
62  ScrollViewIndicator m_verticalScrollIndicator;
63  ScrollViewIndicator m_horizontalScrollIndicator;
64  bool hasVerticalIndicator() const;
65  bool hasHorizontalIndicator() const;
66  KDCoordinate m_topMargin;
67  KDCoordinate m_rightMargin;
68  KDCoordinate m_bottomMargin;
69  KDCoordinate m_leftMargin;
70  KDCoordinate m_indicatorThickness;
71  bool m_showsIndicators;
72  bool m_colorsBackground;
73  KDColor m_backgroundColor;
74 };
75 
76 #endif
KDCoordinate maxContentHeightDisplayableWithoutScrolling()
void setLeftMargin(KDCoordinate m)
Definition: scroll_view.h:19
bool showsIndicators() const
Definition: scroll_view.h:29
KDCoordinate indicatorThickness() const
Definition: scroll_view.h:38
void setShowsIndicators(bool s)
Definition: scroll_view.h:28
void scrollToContentRect(KDRect rect, bool allowOverscroll=false)
void setBackgroundColor(KDColor c)
Definition: scroll_view.h:32
void setBottomMargin(KDCoordinate m)
Definition: scroll_view.h:17
int16_t KDCoordinate
Definition: coordinate.h:6
void scrollToContentPoint(KDPoint p, bool allowOverscroll=false)
Definition: scroll_view.cpp:80
bool colorsBackground() const
Definition: scroll_view.h:31
void setMargins(KDCoordinate m)
Definition: scroll_view.h:25
void layoutSubviews() override
KDCoordinate maxContentWidthDisplayableWithoutScrolling()
void updateScrollIndicator()
KDColor backgroundColor() const
Definition: scroll_view.h:33
Definition: point.h:6
KDSize contentSize()
void setCommonMargins()
Definition: scroll_view.cpp:27
ScrollViewIndicator * horizontalScrollIndicator()
Definition: scroll_view.h:36
Definition: size.h:6
c(generic_all_nodes)
void setTopMargin(KDCoordinate m)
Definition: scroll_view.h:13
KDCoordinate rightMargin() const
Definition: scroll_view.h:16
ScrollViewIndicator * verticalScrollIndicator()
Definition: scroll_view.h:35
void drawRect(KDContext *ctx, KDRect rect) const override
Definition: scroll_view.cpp:64
void setColorsBackground(bool c)
Definition: scroll_view.h:30
KDCoordinate topMargin() const
Definition: scroll_view.h:14
KDCoordinate leftMargin() const
Definition: scroll_view.h:20
void setContentOffset(KDPoint offset, bool forceRelayout=false)
void setIndicatorThickness(KDCoordinate t)
Definition: scroll_view.h:37
void setMargins(KDCoordinate top, KDCoordinate right, KDCoordinate bottom, KDCoordinate left)
Definition: scroll_view.h:22
Definition: rect.h:26
Definition: color.h:6
KDRect visibleContentRect()
void setRightMargin(KDCoordinate m)
Definition: scroll_view.h:15
KDPoint contentOffset() const
Definition: scroll_view.h:41
Definition: view.h:23
KDCoordinate bottomMargin() const
Definition: scroll_view.h:18
ScrollView(View *contentView, ScrollViewDataSource *dataSource)
Definition: scroll_view.cpp:9
View * m_contentView
Definition: scroll_view.h:56