ScummVM API documentation
scrollbar.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef GUI_WIDGETS_SCROLLBAR_H
23 #define GUI_WIDGETS_SCROLLBAR_H
24 
25 #include "gui/widget.h"
26 
27 namespace GUI {
28 
29 enum {
30  kSetPositionCmd = 'SETP'
31 };
32 
33 
34 class ScrollBarWidget : public Widget, public CommandSender {
35 protected:
36  typedef enum {
37  kNoPart,
38  kUpArrowPart,
39  kDownArrowPart,
40  kSliderPart,
41  kPageUpPart,
42  kPageDownPart
43  } Part;
44 
45  Part _part;
46  int _sliderHeight;
47  int _sliderPos;
48 
49  Part _draggingPart;
50  int _sliderDeltaMouseDownPos;
51 
52  enum {
53  kRepeatInitialDelay = 500,
54  kRepeatDelay = 100
55  };
56  uint32 _repeatTimer;
57 
58 public:
59  int _numEntries;
60  int _entriesPerPage;
61  int _currentPos;
62  int _singleStep;
63 
64 public:
65  ScrollBarWidget(GuiObject *boss, int x, int y, int w, int h);
66 
67  void handleMouseDown(int x, int y, int button, int clickCount) override;
68  void handleMouseUp(int x, int y, int button, int clickCount) override;
69  void handleMouseWheel(int x, int y, int direction) override;
70  void handleMouseMoved(int x, int y, int button) override;
71  void handleMouseEntered(int button) override { setFlags(WIDGET_HILITED); }
72  void handleMouseLeft(int button) override { clearFlags(WIDGET_HILITED); _part = kNoPart; markAsDirty(); }
73  void handleTickle() override;
74  bool wantsFocus() override { return true; }
75 
76  // FIXME - this should be private, but then we also have to add accessors
77  // for _numEntries, _entriesPerPage and _currentPos. This again leads to the question:
78  // should these accessors force a redraw?
79  void recalc();
80 
81  void checkBounds(int old_pos);
82 
83 protected:
84  void drawWidget() override;
85 };
86 
87 } // End of namespace GUI
88 
89 #endif
Definition: scrollbar.h:34
Definition: system.h:46
Definition: object.h:60
virtual void markAsDirty()
Definition: widget.h:101
Definition: object.h:40