Control: Change controls to use new callback infrastrucure.
[gemrb.git] / gemrb / core / Slider.h
blob8e0ac79710c6b954d6867ec254974688da576224
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.
21 /**
22 * @file Slider.h
23 * Declares Slider widget for displaying scales and sliders for setting
24 * numerical values
25 * @author The GemRB Project
28 #ifndef SLIDER_H
29 #define SLIDER_H
31 #include "exports.h"
33 #include "Control.h"
34 #include "Sprite2D.h"
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
44 /**
45 * @class Slider
46 * Widget displaying sliders or scales for inputting numerical values
47 * with a limited range
50 class GEM_EXPORT Slider : public Control {
51 public:
52 Slider(short KnobXPos, short KnobYPos, short KnobStep, unsigned short KnobStepsCount, bool Clear = false);
53 ~Slider();
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;
72 /** Knob Image */
73 Sprite2D * Knob;
74 /** Grabbed Knob Image */
75 Sprite2D * GrabbedKnob;
76 /** Knob Starting X Position */
77 short KnobXPos;
78 /** Knob Starting Y Position */
79 short KnobYPos;
80 /** Knob Step Size */
81 short KnobStep;
82 /** Knob Steps Count */
83 unsigned short KnobStepsCount;
84 /** If true, on deletion the Slider will destroy the associated images */
85 bool Clear;
86 /** Actual Knob Status */
87 unsigned char State;
88 /** Slider Position Value */
89 unsigned int Pos;
90 public: // Public Events
91 /** Mouse Button Down */
92 void OnMouseDown(unsigned short x, unsigned short y, unsigned short Button,
93 unsigned short Mod);
94 /** Mouse Button Up */
95 void OnMouseUp(unsigned short x, unsigned short y, unsigned short Button,
96 unsigned short Mod);
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;
105 #endif