OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Slider.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_SLIDER_H
20 #define OPENXCOM_SLIDER_H
21 
22 #include "../Engine/InteractiveSurface.h"
23 
24 namespace OpenXcom
25 {
26 
27 class Font;
28 class Language;
29 class Frame;
30 class TextButton;
31 class Text;
32 
36 class Slider : public InteractiveSurface
37 {
38 private:
39  Frame *_frame;
40  Text *_txtMinus, *_txtPlus;
41  TextButton *_button;
42  double _pos;
43  int _min, _max, _value;
44  bool _pressed;
45  ActionHandler _change;
46  int _thickness, _textness, _minX, _maxX, _offsetX;
47 
49  void setPosition(double pos);
50 public:
52  Slider(int width, int height, int x = 0, int y = 0);
54  ~Slider();
56  void setX(int x);
58  void setY(int y);
60  void initText(Font *big, Font *small, Language *lang);
62  void setHighContrast(bool contrast);
64  void setColor(Uint8 color);
66  Uint8 getColor() const;
68  void setPalette(SDL_Color *colors, int firstcolor = 0, int ncolors = 256);
70  void setRange(int min, int max);
72  void setValue(int value);
74  int getValue() const;
76  void blit(Surface *surface);
78  void handle(Action *action, State *state);
80  void mousePress(Action *action, State *state);
82  void mouseRelease(Action *action, State *state);
84  void onChange(ActionHandler handler);
85 };
86 
87 }
88 
89 #endif
void blit(Surface *surface)
Blits the slider onto another surface.
Definition: Slider.cpp:246
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:34
void mousePress(Action *action, State *state)
Special handling for mouse presses.
Definition: Slider.cpp:263
A game state that receives user input and reacts accordingly.
Definition: State.h:44
void handle(Action *action, State *state)
Moves the slider.
Definition: Slider.cpp:173
Surface that the user can interact with.
Definition: InteractiveSurface.h:39
Horizontal slider control to select from a range of values.
Definition: Slider.h:36
Text string displayed on screen.
Definition: Text.h:41
void initText(Font *big, Font *small, Language *lang)
Initializes the slider's resources.
Definition: Slider.cpp:111
void setValue(int value)
Sets the slider's value.
Definition: Slider.cpp:219
void setColor(Uint8 color)
Sets the slider's color.
Definition: Slider.cpp:135
void setHighContrast(bool contrast)
Sets the slider's high contrast color setting.
Definition: Slider.cpp:123
Slider(int width, int height, int x=0, int y=0)
Creates a new slider with the specified size and position.
Definition: Slider.cpp:37
Contains strings used throughout the game for localization.
Definition: Language.h:42
void setY(int y)
Sets the Y position of the surface.
Definition: Slider.cpp:93
Takes care of loading and storing each character in a sprite font.
Definition: Font.h:40
void setRange(int min, int max)
Sets the slider's range.
Definition: Slider.cpp:207
void mouseRelease(Action *action, State *state)
Special handling for mouse releases.
Definition: Slider.cpp:286
int getValue() const
Gets the slider's value.
Definition: Slider.cpp:237
Coloured button with a text label.
Definition: TextButton.h:40
Element that is blit (rendered) onto the screen.
Definition: Surface.h:39
void onChange(ActionHandler handler)
Hooks an action handler to when the slider changes.
Definition: Slider.cpp:300
void setX(int x)
Sets the X position of the surface.
Definition: Slider.cpp:77
Fancy frame border thing used for windows and other elements.
Definition: Frame.h:30
void setPalette(SDL_Color *colors, int firstcolor=0, int ncolors=256)
Sets the slider's palette.
Definition: Slider.cpp:158
~Slider()
Cleans up the slider.
Definition: Slider.cpp:65
Uint8 getColor() const
Gets the slider's color.
Definition: Slider.cpp:147