Phoenard
PHNScrollbar.h
Go to the documentation of this file.
1 /*
2 The MIT License (MIT)
3 
4 This file is part of the Phoenard Arduino library
5 Copyright (c) 2014 Phoenard
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 THE SOFTWARE.
24 */
25 
31 #include "PHNWidget.h"
32 
33 #ifndef _PHN_SCROLLBAR_H_
34 #define _PHN_SCROLLBAR_H_
35 
37 #define SCROLL_AUTO_DELAY 800
38 #define SCROLL_AUTO_TICK_DELAY 30
40 
47 class PHN_Scrollbar : public PHN_Widget {
48  public:
50  PHN_Scrollbar(void) : scrollPos(0), scrollMin(0), scrollMax(0) {}
52  void setRange(int minValue, int maxValue);
54  int minValue() const { return scrollMin; }
56  int maxValue() const { return scrollMax; }
58  void setValue(int value);
60  const int value(void) { return scrollPos; }
62  bool isValueChanged(void) const { return valueChanged; }
63 
64  virtual void draw(void);
65  virtual void update(void);
66  private:
67  void updateBar(bool redrawing);
68  void drawArrow(int x, int y, int w, int h, int direction, bool highlight);
69  int scrollPos, scrollMin, scrollMax;
70  int sliderPos;
71  char prevScroll;
72  unsigned long scrollTime;
73  bool barWasPressed;
74  bool valueChanged;
75 };
76 
77 #endif
int maxValue() const
Gets the range maximum value.
Definition: PHNScrollbar.h:56
PHN_Scrollbar(void)
Initializes the value to the pure minimum.
Definition: PHNScrollbar.h:50
virtual void update(void)
Update function routine, where widget logic must be performed.
Definition: PHNScrollbar.cpp:64
A single widget which covers a rectangular area of the screen.
Definition: PHNWidget.h:145
bool isValueChanged(void) const
Gets whether the value was changed since the last update.
Definition: PHNScrollbar.h:62
void setValue(int value)
Sets the scrollbar value.
Definition: PHNScrollbar.cpp:38
virtual void draw(void)
Draw function routine, where widgets must perform drawing.
Definition: PHNScrollbar.cpp:55
Holds the PHN_Widget and PHN_WidgetContainer classes used for managing widgets.
int minValue() const
Gets the range minimum value.
Definition: PHNScrollbar.h:54
const int value(void)
Gets the scrollbar value.
Definition: PHNScrollbar.h:60
Shows a scroll bar the user can drag.
Definition: PHNScrollbar.h:47
void setRange(int minValue, int maxValue)
Sets the minimum and maximum scrolling range.
Definition: PHNScrollbar.cpp:28