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
30namespace 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 static const int kDragThreshold = 5;
41 int _mouseDownY = 0;
42 int _mouseDownStartY = 0;
43 bool _isMouseDown = false;
44 bool _isDragging = false;
45 float _scrollPos = 0.0f;
46 FluidScroller *_fluidScroller = nullptr;
47
48 void recalc();
49 void applyScrollPos();
50
51public:
52 ScrollContainerWidget(GuiObject *boss, int x, int y, int w, int h, uint32 reflowCmd = 0);
53 ScrollContainerWidget(GuiObject *boss, const Common::String &name, const Common::String &dialogName, uint32 reflowCmd = 0);
54 ~ScrollContainerWidget() override;
55
56 void init();
57 void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
58 void reflowLayout() override;
59
60 bool containsWidget(Widget *) const override;
61
62 void setBackgroundType(ThemeEngine::WidgetBackground backgroundType);
63
64 void handleMouseWheel(int x, int y, int direction) override;
65 void handleMouseDown(int x, int y, int button, int clickCount) override;
66 void handleMouseUp(int x, int y, int button, int clickCount) override;
67 void handleMouseMoved(int x, int y, int button) override;
68 void handleTickle() override;
69 bool handleDragHook(Widget *origTarget, int state, int x, int y, int button) override;
70
71 void cancelDrag() override;
72 void cancelTickle() override;
73
74 // We overload getChildY to make sure child widgets are positioned correctly.
75 // Essentially this compensates for the space taken up by the tab title header.
76 int16 getChildX() const override;
77 int16 getChildY() const override;
78 uint16 getWidth() const override;
79 uint16 getHeight() const override;
80
81 void draw() override;
82 void markAsDirty() override;
83
84protected:
85 void drawWidget() override;
86
87 Widget *findWidget(int x, int y) override;
88};
89
90} // End of namespace GUI
91
92#endif
Definition: str.h:59
Definition: object.h:40
Definition: FluidScroll.h:34
Definition: object.h:60
Definition: scrollbar.h:34
Definition: scrollcontainer.h:32
void markAsDirty() override
WidgetBackground
Widget background type.
Definition: ThemeEngine.h:226
Definition: widget.h:99