1//============================================================================
2//
3// SSSS tt lll lll
4// SS SS tt ll ll
5// SS tttttt eeee ll ll aaaa
6// SSSS tt ee ee ll ll aa
7// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8// SS SS tt ee ll ll aa aa
9// SSSS ttt eeeee llll llll aaaaa
10//
11// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
12// and the Stella Team
13//
14// See the file "License.txt" for information on usage and redistribution of
15// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16//============================================================================
17
18#ifndef SCROLL_BAR_WIDGET_HXX
19#define SCROLL_BAR_WIDGET_HXX
20
21class GuiObject;
22
23#include "Widget.hxx"
24#include "Command.hxx"
25#include "bspf.hxx"
26
27enum {
28 kScrollBarWidth = 15
29};
30
31class ScrollBarWidget : public Widget, public CommandSender
32{
33 public:
34 ScrollBarWidget(GuiObject* boss, const GUI::Font& font,
35 int x, int y, int w, int h);
36 virtual ~ScrollBarWidget() = default;
37
38 void recalc();
39 void handleMouseWheel(int x, int y, int direction) override;
40
41 static void setWheelLines(int lines) { _WHEEL_LINES = lines; }
42 static int getWheelLines() { return _WHEEL_LINES; }
43
44 private:
45 void drawWidget(bool hilite) override;
46 void checkBounds(int old_pos);
47
48 void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
49 void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
50 void handleMouseMoved(int x, int y) override;
51 bool handleMouseClicks(int x, int y, MouseButton b) override;
52 void handleMouseEntered() override;
53 void handleMouseLeft() override;
54
55 public:
56 int _numEntries;
57 int _entriesPerPage;
58 int _currentPos;
59 int _wheel_lines;
60
61 private:
62 enum Part {
63 kNoPart,
64 kUpArrowPart,
65 kDownArrowPart,
66 kSliderPart,
67 kPageUpPart,
68 kPageDownPart
69 };
70
71 Part _part;
72 Part _draggingPart;
73 int _sliderHeight;
74 int _sliderPos;
75 int _sliderDeltaMouseDownPos;
76
77 static int _WHEEL_LINES;
78
79 private:
80 // Following constructors and assignment operators not supported
81 ScrollBarWidget() = delete;
82 ScrollBarWidget(const ScrollBarWidget&) = delete;
83 ScrollBarWidget(ScrollBarWidget&&) = delete;
84 ScrollBarWidget& operator=(const ScrollBarWidget&) = delete;
85 ScrollBarWidget& operator=(ScrollBarWidget&&) = delete;
86};
87
88#endif
89