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 NUVIE_GUI_GUI_SCROLLER_H
24 #define NUVIE_GUI_GUI_SCROLLER_H
25 
26 
27 
28 #include "ultima/nuvie/gui/widgets/gui_widget.h"
29 #include "ultima/nuvie/screen/screen.h"
30 
31 namespace Ultima {
32 namespace Nuvie {
33 
34 class GUI_ScrollBar;
35 
36 class GUI_Scroller : public GUI_Widget {
37 
38 	uint8 R, G, B;
39 	uint32 bg_color;
40 	uint16 row_height;
41 	uint16 rows_per_page;
42 	uint16 num_rows;
43 	GUI_ScrollBar *scroll_bar;
44 	uint16 disp_offset;
45 
46 public:
47 	/* Passed the area, color and shape */
48 	GUI_Scroller(int x, int y, int w, int h, uint8 r, uint8 g, uint8 b, uint16 r_height);
49 
50 	/* Map the color to the display */
51 	void SetDisplay(Screen *s) override;
52 	void PlaceOnScreen(Screen *s, GUI_DragManager *dm, int x, int y) override;
53 	void move_up();
54 	void move_down();
55 	void page_up(bool all = false);
56 	void page_down(bool all = false);
57 
58 	int AddWidget(GUI_Widget *widget);
59 
60 	/* Show the widget  */
61 	void Display(bool full_redraw) override;
62 
63 	/* events, used for dragging the area. */
64 	GUI_status MouseDown(int x, int y, Shared::MouseButton button) override;
65 	GUI_status MouseUp(int x, int y, Shared::MouseButton button) override;
66 	GUI_status MouseMotion(int x, int y, uint8 state) override;
67 	GUI_status MouseWheel(sint32 x, sint32 y) override;
68 
69 protected:
70 	void update_viewport(bool update_slider);
71 	void move_percentage(float offset_percentage);
72 	GUI_status callback(uint16 msg, GUI_CallBack *caller, void *data) override;
73 };
74 
75 } // End of namespace Nuvie
76 } // End of namespace Ultima
77 
78 #endif
79