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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef GUI_WIDGETS_SCROLLCONTAINER_H
24 #define GUI_WIDGETS_SCROLLCONTAINER_H
25 
26 #include "gui/widget.h"
27 #include "common/str.h"
28 #include "scrollbar.h"
29 
30 namespace GUI {
31 
32 class ScrollContainerWidget: public Widget, public CommandSender {
33 	ScrollBarWidget *_verticalScroll;
34 	int16 _scrolledX, _scrolledY;
35 	uint16 _limitH;
36 	uint32 _reflowCmd;
37 	ThemeEngine::DialogBackground _backgroundType;
38 
39 	void recalc();
40 
41 public:
42 	ScrollContainerWidget(GuiObject *boss, int x, int y, int w, int h, uint32 reflowCmd = 0);
43 	ScrollContainerWidget(GuiObject *boss, const Common::String &name, uint32 reflowCmd = 0);
44 	~ScrollContainerWidget() override;
45 
46 	void init();
47 	void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
48 	void reflowLayout() override;
49 
50 	bool containsWidget(Widget *) const override;
51 
52 	Common::Rect getClipRect() const override;
53 
54 	void setBackgroundType(ThemeEngine::DialogBackground backgroundType);
55 
56 	void handleMouseWheel(int x, int y, int direction) override;
57 
58 protected:
59 	// We overload getChildY to make sure child widgets are positioned correctly.
60 	// Essentially this compensates for the space taken up by the tab title header.
61 	int16	getChildX() const override;
62 	int16	getChildY() const override;
63 	uint16	getWidth() const override;
64 	uint16	getHeight() const override;
65 
66 	void drawWidget() override;
67 
68 	Widget *findWidget(int x, int y) override;
69 };
70 
71 } // End of namespace GUI
72 
73 #endif
74