1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * Declares ScrollBar widget for paging in long text windows.
24 * This does not include scales and sliders, which are of Slider class.
25 * @author The GemRB Project
37 // !!! Keep these synchronized with GUIDefines.py !!!
38 #define IE_GUI_SCROLLBAR_ON_CHANGE 0x07000000
40 #define IE_GUI_SCROLLBAR_DEFAULT 0x00000040 // mousewheel triggers it
42 #define IE_GUI_SCROLLBAR_UP_UNPRESSED 0
43 #define IE_GUI_SCROLLBAR_UP_PRESSED 1
44 #define IE_GUI_SCROLLBAR_DOWN_UNPRESSED 2
45 #define IE_GUI_SCROLLBAR_DOWN_PRESSED 3
46 #define IE_GUI_SCROLLBAR_TROUGH 4
47 #define IE_GUI_SCROLLBAR_SLIDER 5
49 #define UP_PRESS 0x0001
50 #define DOWN_PRESS 0x0010
51 #define SLIDER_GRAB 0x0100
55 * Widget displaying scrollbars for paging in long text windows
58 #define SB_RES_COUNT 6
60 class GEM_EXPORT ScrollBar
: public Control
{
64 /**sets position, updates associated stuff */
65 void SetPos(int NewPos
);
68 /**redraws scrollbar if associated with VarName */
69 void RedrawScrollBar(const char* VarName
, int Sum
);
71 void Draw(unsigned short x
, unsigned short y
);
72 private: //Private attributes
73 /** Images for drawing the Scroll Bar */
74 Sprite2D
* Frames
[SB_RES_COUNT
];
75 /** Cursor Position */
77 /** Scroll Bar Status */
79 /** Sets the Text of the current control */
80 int SetText(const char* string
, int pos
= 0);
82 void SetImage(unsigned char type
, Sprite2D
* img
);
83 /** Sets the Maximum Value of the ScrollBar */
84 void SetMax(unsigned short Max
);
85 /** TextArea Associated Control */
87 public: // Public Events
88 /** Mouse Button Down */
89 void OnMouseDown(unsigned short x
, unsigned short y
, unsigned short Button
,
91 /** Mouse Button Up */
92 void OnMouseUp(unsigned short x
, unsigned short y
, unsigned short Button
,
94 /** Mouse Over Event */
95 void OnMouseOver(unsigned short x
, unsigned short y
);
96 /** Set handler for specified event */
97 bool SetEvent(int eventType
, EventHandler handler
);
98 /** OnChange Scripted Event Function Name */
99 EventHandler ScrollBarOnChange
;