OpenXcom  1.0
Open-source clone of the original X-Com
Slider.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include "../Engine/InteractiveSurface.h"
21 
22 namespace OpenXcom
23 {
24 
25 class Font;
26 class Language;
27 class Frame;
28 class TextButton;
29 class Text;
30 
34 class Slider : public InteractiveSurface
35 {
36 private:
37  Frame *_frame;
38  Text *_txtMinus, *_txtPlus;
39  TextButton *_button;
40  double _pos;
41  int _min, _max, _value;
42  bool _pressed;
43  ActionHandler _change;
44  int _thickness, _textness, _minX, _maxX, _offsetX;
45 
47  void setPosition(double pos);
48 public:
50  Slider(int width, int height, int x = 0, int y = 0);
52  ~Slider();
54  void setX(int x);
56  void setY(int y);
58  void initText(Font *big, Font *small, Language *lang);
60  void setHighContrast(bool contrast);
62  void setColor(Uint8 color);
64  Uint8 getColor() const;
66  void setPalette(SDL_Color *colors, int firstcolor = 0, int ncolors = 256);
68  void setRange(int min, int max);
70  void setValue(int value);
72  int getValue() const;
74  void blit(Surface *surface);
76  void handle(Action *action, State *state);
78  void mousePress(Action *action, State *state);
80  void mouseRelease(Action *action, State *state);
82  void onChange(ActionHandler handler);
83 };
84 
85 }
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:32
void mousePress(Action *action, State *state)
Special handling for mouse presses.
Definition: Slider.cpp:263
Uint8 getColor() const
Gets the slider&#39;s color.
Definition: Slider.cpp:147
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
int getValue() const
Gets the slider&#39;s value.
Definition: Slider.cpp:237
Surface that the user can interact with.
Definition: InteractiveSurface.h:37
Horizontal slider control to select from a range of values.
Definition: Slider.h:34
Text string displayed on screen.
Definition: Text.h:40
void initText(Font *big, Font *small, Language *lang)
Initializes the slider&#39;s resources.
Definition: Slider.cpp:111
void setValue(int value)
Sets the slider&#39;s value.
Definition: Slider.cpp:219
void setColor(Uint8 color)
Sets the slider&#39;s color.
Definition: Slider.cpp:135
void setHighContrast(bool contrast)
Sets the slider&#39;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:39
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:46
void setRange(int min, int max)
Sets the slider&#39;s range.
Definition: Slider.cpp:207
void mouseRelease(Action *action, State *state)
Special handling for mouse releases.
Definition: Slider.cpp:286
Coloured button with a text label.
Definition: TextButton.h:38
Element that is blit (rendered) onto the screen.
Definition: Surface.h:38
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:28
void setPalette(SDL_Color *colors, int firstcolor=0, int ncolors=256)
Sets the slider&#39;s palette.
Definition: Slider.cpp:158
~Slider()
Cleans up the slider.
Definition: Slider.cpp:65
Definition: BaseInfoState.cpp:40