OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TextButton.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_TEXTBUTTON_H
20 #define OPENXCOM_TEXTBUTTON_H
21 
22 #include "../Engine/InteractiveSurface.h"
23 
24 namespace OpenXcom
25 {
26 
27 class Text;
28 class Font;
29 class Language;
30 class Sound;
31 class ComboBox;
32 
41 {
42 private:
43  Uint8 _color;
44  Text *_text;
45  TextButton **_group;
46  bool _contrast;
47  ComboBox *_comboBox;
48 protected:
49  bool isButtonHandled(Uint8 button = 0);
50 public:
51  static Sound *soundPress;
53  TextButton(int width, int height, int x = 0, int y = 0);
55  ~TextButton();
57  void setColor(Uint8 color);
59  Uint8 getColor() const;
61  void setTextColor(Uint8 color);
63  void setBig();
65  void setSmall();
67  Font *getFont() const;
69  void initText(Font *big, Font *small, Language *lang);
71  void setHighContrast(bool contrast);
73  void setText(const std::wstring &text);
75  std::wstring getText() const;
77  void setGroup(TextButton **group);
79  void setPalette(SDL_Color *colors, int firstcolor = 0, int ncolors = 256);
81  void draw();
83  void mousePress(Action *action, State *state);
85  void mouseRelease(Action *action, State *state);
87  void setComboBox(ComboBox *comboBox);
88 };
89 
90 }
91 
92 #endif
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:34
std::wstring getText() const
Gets the text button's text.
Definition: TextButton.cpp:167
A game state that receives user input and reacts accordingly.
Definition: State.h:44
Surface that the user can interact with.
Definition: InteractiveSurface.h:39
TextButton(int width, int height, int x=0, int y=0)
Creates a new text button with the specified size and position.
Definition: TextButton.cpp:40
void setColor(Uint8 color)
Sets the text button's color.
Definition: TextButton.cpp:73
Text string displayed on screen.
Definition: Text.h:41
Container for sound effects.
Definition: Sound.h:32
bool isButtonHandled(Uint8 button=0)
Is this mouse button event handled?
Definition: TextButton.cpp:57
void mousePress(Action *action, State *state)
Special handling for mouse presses.
Definition: TextButton.cpp:268
Uint8 getColor() const
Gets the text button's color.
Definition: TextButton.cpp:84
void setComboBox(ComboBox *comboBox)
Attaches this button to a combobox.
Definition: TextButton.cpp:318
void initText(Font *big, Font *small, Language *lang)
Initializes the text edit's resources.
Definition: TextButton.cpp:135
Contains strings used throughout the game for localization.
Definition: Language.h:42
void draw()
Draws the text button.
Definition: TextButton.cpp:199
Text button with a list dropdown when pressed.
Definition: ComboBox.h:38
Takes care of loading and storing each character in a sprite font.
Definition: Font.h:40
void setGroup(TextButton **group)
Sets the text button's group.
Definition: TextButton.cpp:177
void setPalette(SDL_Color *colors, int firstcolor=0, int ncolors=256)
Sets the text button's palette.
Definition: TextButton.cpp:189
void setSmall()
Sets the text size to small.
Definition: TextButton.cpp:111
Font * getFont() const
Gets the text button's current font.
Definition: TextButton.cpp:121
Coloured button with a text label.
Definition: TextButton.h:40
void setHighContrast(bool contrast)
Sets the text button's high contrast color setting.
Definition: TextButton.cpp:146
void mouseRelease(Action *action, State *state)
Special handling for mouse releases.
Definition: TextButton.cpp:303
~TextButton()
Cleans up the text button.
Definition: TextButton.cpp:52
void setText(const std::wstring &text)
Sets the text button's text.
Definition: TextButton.cpp:157
void setTextColor(Uint8 color)
Sets the text button's text color.
Definition: TextButton.cpp:93
void setBig()
Sets the text size to big.
Definition: TextButton.cpp:102