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