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 Slider widget for displaying scales and sliders for setting
25 * @author The GemRB Project
36 // !!! Keep these synchronized with GUIDefines.py !!!
37 #define IE_GUI_SLIDER_ON_CHANGE 0x02000000
40 #define IE_GUI_SLIDER_KNOB 0
41 #define IE_GUI_SLIDER_GRABBEDKNOB 1
42 #define IE_GUI_SLIDER_BACKGROUND 2
46 * Widget displaying sliders or scales for inputting numerical values
47 * with a limited range
50 class GEM_EXPORT Slider
: public Control
{
52 Slider(short KnobXPos
, short KnobYPos
, short KnobStep
, unsigned short KnobStepsCount
, bool Clear
= false);
54 /** Draws the Control on the Output Display */
55 void Draw(unsigned short x
, unsigned short y
);
56 /** Returns the actual Slider Position */
57 unsigned int GetPosition();
58 /** Sets the actual Slider Position trimming to the Max and Min Values */
59 void SetPosition(unsigned int pos
);
60 /** Sets the selected image */
61 void SetImage(unsigned char type
, Sprite2D
* img
);
62 /** Sets the Text of the current control */
63 int SetText(const char * string
, int pos
= 0);
64 /** Sets the State of the Slider */
65 void SetState(int arg
) { State
=(unsigned char) arg
; }
66 /** Redraws a slider which is associated with VariableName */
67 void RedrawSlider(const char *VariableName
, int Sum
);
69 private: // Private attributes
70 /** BackGround Image. If smaller than the Control Size, the image will be tiled. */
71 Sprite2D
* BackGround
;
74 /** Grabbed Knob Image */
75 Sprite2D
* GrabbedKnob
;
76 /** Knob Starting X Position */
78 /** Knob Starting Y Position */
82 /** Knob Steps Count */
83 unsigned short KnobStepsCount
;
84 /** If true, on deletion the Slider will destroy the associated images */
86 /** Actual Knob Status */
88 /** Slider Position Value */
90 public: // Public Events
91 /** Mouse Button Down */
92 void OnMouseDown(unsigned short x
, unsigned short y
, unsigned short Button
,
94 /** Mouse Button Up */
95 void OnMouseUp(unsigned short x
, unsigned short y
, unsigned short Button
,
97 /** Mouse Over Event */
98 void OnMouseOver(unsigned short x
, unsigned short y
);
99 /** Set handler for specified event */
100 bool SetEvent(int eventType
, EventHandler handler
);
101 /** OnChange Scripted Event Function Name */
102 EventHandler SliderOnChange
;