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
36 // !!! Keep these synchronized with GUIDefines.py !!!
37 #define IE_GUI_SCROLLBAR_ON_CHANGE 0x07000000
39 #define IE_GUI_SCROLLBAR_DEFAULT 0x00000040 // mousewheel triggers it
41 #define IE_GUI_SCROLLBAR_UP_UNPRESSED 0
42 #define IE_GUI_SCROLLBAR_UP_PRESSED 1
43 #define IE_GUI_SCROLLBAR_DOWN_UNPRESSED 2
44 #define IE_GUI_SCROLLBAR_DOWN_PRESSED 3
45 #define IE_GUI_SCROLLBAR_TROUGH 4
46 #define IE_GUI_SCROLLBAR_SLIDER 5
48 #define UP_PRESS 0x0001
49 #define DOWN_PRESS 0x0010
50 #define SLIDER_GRAB 0x0100
54 * Widget displaying scrollbars for paging in long text windows
57 #define SB_RES_COUNT 6
59 class GEM_EXPORT ScrollBar
: public Control
{
63 /**sets position, updates associated stuff */
64 void SetPos(int NewPos
);
67 /**redraws scrollbar if associated with VarName */
68 void RedrawScrollBar(const char* VarName
, int Sum
);
70 void Draw(unsigned short x
, unsigned short y
);
71 private: //Private attributes
72 /** Images for drawing the Scroll Bar */
73 Sprite2D
* Frames
[SB_RES_COUNT
];
74 /** Cursor Position */
76 /** Scroll Bar Status */
78 /** Sets the Text of the current control */
79 int SetText(const char* string
, int pos
= 0);
81 void SetImage(unsigned char type
, Sprite2D
* img
);
82 /** Sets the Maximum Value of the ScrollBar */
83 void SetMax(unsigned short Max
);
84 /** TextArea Associated Control */
86 public: // Public Events
87 /** Mouse Button Down */
88 void OnMouseDown(unsigned short x
, unsigned short y
, unsigned short Button
,
90 /** Mouse Button Up */
91 void OnMouseUp(unsigned short x
, unsigned short y
, unsigned short Button
,
93 /** Mouse Over Event */
94 void OnMouseOver(unsigned short x
, unsigned short y
);
95 /** Set handler for specified event */
96 bool SetEvent(int eventType
, const char *handler
);
97 /** OnChange Scripted Event Function Name */
98 EventHandler ScrollBarOnChange
;