forked from OpenXcom/OpenXcom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextButton.h
79 lines (73 loc) · 2.37 KB
/
TextButton.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright 2010-2013 OpenXcom Developers.
*
* This file is part of OpenXcom.
*
* OpenXcom is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenXcom is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPENXCOM_TEXTBUTTON_H
#define OPENXCOM_TEXTBUTTON_H
#include "../Engine/InteractiveSurface.h"
namespace OpenXcom
{
class Text;
class Font;
class Sound;
/**
* Coloured button with a text label.
* Drawn to look like a 3D-shaped box with text on top,
* responds to mouse clicks. Can be attached to a group of
* buttons to turn it into a radio button (only one button
* pushed at a time).
*/
class TextButton : public InteractiveSurface
{
private:
Uint8 _color, _inactiveColor;
Text *_text;
TextButton **_group;
bool _contrast;
public:
static Sound *soundPress;
/// Creates a new text button with the specified size and position.
TextButton(int width, int height, int x = 0, int y = 0);
/// Cleans up the text button.
~TextButton();
/// Sets the text button's color.
void setColor(Uint8 color, Uint8 inactiveColor = 0);
/// Gets the text button's color.
Uint8 getColor() const;
/// Sets the text button's various fonts.
void setFonts(Font *big, Font *small);
/// Sets the text button's high contrast color setting.
void setHighContrast(bool contrast);
/// Sets the text button's text.
void setText(const std::wstring &text);
/// Gets the text button's text.
std::wstring getText() const;
/// Sets the text button's group.
void setGroup(TextButton **group);
/// Sets the text button's palette.
void setPalette(SDL_Color *colors, int firstcolor = 0, int ncolors = 256);
/// Draws the text button.
void draw();
/// Special handling for mouse presses.
void mousePress(Action *action, State *state);
/// Special handling for mouse releases.
void mouseRelease(Action *action, State *state);
/// Sets the activity flag.
void setActive(bool active);
};
}
#endif