ScummVM API documentation
gui_scroll_bar.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 NUVIE_GUI_GUI_SCROLLBAR_H
23 #define NUVIE_GUI_GUI_SCROLLBAR_H
24 
25 
26 
27 #include "ultima/nuvie/gui/widgets/gui_widget.h"
28 #include "ultima/nuvie/screen/screen.h"
29 
30 namespace Ultima {
31 namespace Nuvie {
32 
33 #define GUI_DIALOG_MOVABLE true
34 
35 #define SCROLLBAR_WIDTH 14
36 
37 // Callback message types
38 
39 #define SCROLLBAR_CB_DOWN_BUTTON 0x1
40 #define SCROLLBAR_CB_UP_BUTTON 0x2
41 #define SCROLLBAR_CB_SLIDER_MOVED 0x3
42 #define SCROLLBAR_CB_PAGE_DOWN 0x4
43 #define SCROLLBAR_CB_PAGE_UP 0x5
44 
45 class GUI_Button;
46 
47 class GUI_ScrollBar : public GUI_Widget {
48  GUI_CallBack *callback_object;
49  GUI_Button *up_button, *down_button;
50 
51  bool drag;
52  uint16 button_height;
53 
54  // Various colours.
55 
56  uint32 slider_highlight_c;
57  uint32 slider_shadow_c;
58  uint32 slider_base_c;
59  uint32 track_border_c;
60  uint32 track_base_c;
61 
62  uint16 track_length;
63  uint16 slider_length;
64  uint16 slider_y;
65  uint16 slider_click_offset; // where on the slider were we clicked?
66 
67 public:
68  /* Passed the area, color and shape */
69  GUI_ScrollBar(int x, int y, int h, GUI_CallBack *callback);
70 
71  void set_slider_length(float percentage);
72  void set_slider_position(float percentage);
73 
74  /* Map the color to the display */
75  void SetDisplay(Screen *s) override;
76 
77  /* Show the widget */
78  void Display(bool full_redraw) override;
79 
80  /* events, used for dragging the area. */
81  GUI_status MouseDown(int x, int y, Shared::MouseButton button) override;
82  GUI_status MouseUp(int x, int y, Shared::MouseButton button) override;
83  GUI_status MouseMotion(int x, int y, uint8 state) override;
84  GUI_status MouseWheel(sint32 x, sint32 y) override;
85 
86 protected:
87  void loadButtons();
88  void DisplaySlider();
89 
90  void send_slider_moved_msg();
91  bool move_slider(int new_slider_y);
92  GUI_status callback(uint16 msg, GUI_CallBack *caller, void *data) override;
93 
94  void send_up_button_msg();
95  void send_down_button_msg();
96 };
97 
98 } // End of namespace Nuvie
99 } // End of namespace Ultima
100 
101 #endif
Definition: gui_widget.h:38
Definition: gui_button.h:70
Definition: gui_scroll_bar.h:47
Definition: screen.h:41
Definition: detection.h:27
Definition: gui_callback.h:31