ScummVM API documentation
scrollcontainer.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_SCROLLCONTAINER_H
23 #define GUI_WIDGETS_SCROLLCONTAINER_H
24 
25 #include "gui/widget.h"
26 #include "common/str.h"
27 #include "gui/widgets/scrollbar.h"
28 #include "gui/animation/FluidScroll.h"
29 
30 namespace GUI {
31 
33  ScrollBarWidget *_verticalScroll;
34  int16 _scrolledX, _scrolledY;
35  int _scrollbarWidth;
36  uint16 _limitH;
37  uint32 _reflowCmd;
38  ThemeEngine::WidgetBackground _backgroundType;
39  Common::String _dialogName;
40  int _mouseDownY = 0;
41  static const int kDragThreshold;
42  int _mouseDownStartY = 0;
43  bool _isMouseDown = false;
44  bool _isDragging = false;
45  float _scrollPos = 0.0f;
46  FluidScroller *_fluidScroller = nullptr;
47  Widget *_childUnderMouse = nullptr;
48 
49  void recalc();
50  void applyScrollPos();
51 
52 public:
53  ScrollContainerWidget(GuiObject *boss, int x, int y, int w, int h, uint32 reflowCmd = 0);
54  ScrollContainerWidget(GuiObject *boss, const Common::String &name, const Common::String &dialogName, uint32 reflowCmd = 0);
55  ~ScrollContainerWidget() override;
56 
57  void init();
58  void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
59  void reflowLayout() override;
60 
61  bool containsWidget(Widget *) const override;
62 
63  void setBackgroundType(ThemeEngine::WidgetBackground backgroundType);
64 
65  void handleMouseWheel(int x, int y, int direction) override;
66  void handleMouseDown(int x, int y, int button, int clickCount) override;
67  void handleMouseUp(int x, int y, int button, int clickCount) override;
68  void handleMouseMoved(int x, int y, int button) override;
69  void handleTickle() override;
70 
71  // We overload getChildY to make sure child widgets are positioned correctly.
72  // Essentially this compensates for the space taken up by the tab title header.
73  int16 getChildX() const override;
74  int16 getChildY() const override;
75  uint16 getWidth() const override;
76  uint16 getHeight() const override;
77  bool wantsFocus() override { return true; }
78 
79  void draw() override;
80  void markAsDirty() override;
81 
82 protected:
83  void drawWidget() override;
84 
85  Widget *findWidget(int x, int y) override;
86 };
87 
88 } // End of namespace GUI
89 
90 #endif
void markAsDirty() override
Definition: str.h:59
WidgetBackground
Widget background type.
Definition: ThemeEngine.h:226
Definition: scrollcontainer.h:32
Definition: FluidScroll.h:34
Definition: scrollbar.h:34
Definition: printman.h:30
Definition: object.h:60
Definition: widget.h:101
Definition: object.h:40