OpenXcom  1.0
Open-source clone of the original X-Com
TextButton.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 Text;
26 class Font;
27 class Language;
28 class Sound;
29 class ComboBox;
30 
39 {
40 private:
41  Uint8 _color;
42  Text *_text;
43  TextButton **_group;
44  bool _contrast, _geoscapeButton;
45  ComboBox *_comboBox;
46  // for use by RuleInterface
47  void setSecondaryColor(Uint8 color) { setTextColor(color); }
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::string &text);
75  std::string 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  void setWidth(int width);
89  void setHeight(int height);
90  void setGeoscapeButton(bool geo);
91 };
92 
93 }
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:32
Uint8 getColor() const
Gets the text button&#39;s color.
Definition: TextButton.cpp:84
void setText(const std::string &text)
Sets the text button&#39;s text.
Definition: TextButton.cpp:157
A game state that receives user input and reacts accordingly.
Definition: State.h:44
Surface that the user can interact with.
Definition: InteractiveSurface.h:37
std::string getText() const
Gets the text button&#39;s text.
Definition: TextButton.cpp:167
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&#39;s color.
Definition: TextButton.cpp:73
Text string displayed on screen.
Definition: Text.h:40
Container for sound effects.
Definition: Sound.h:30
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:282
void setComboBox(ComboBox *comboBox)
Attaches this button to a combobox.
Definition: TextButton.cpp:332
void setHeight(int height)
Sets the height of the surface.
Definition: TextButton.cpp:351
void initText(Font *big, Font *small, Language *lang)
Initializes the text edit&#39;s resources.
Definition: TextButton.cpp:135
Contains strings used throughout the game for localization.
Definition: Language.h:39
void draw()
Draws the text button.
Definition: TextButton.cpp:199
Text button with a list dropdown when pressed.
Definition: ComboBox.h:36
Takes care of loading and storing each character in a sprite font.
Definition: Font.h:46
void setGroup(TextButton **group)
Sets the text button&#39;s group.
Definition: TextButton.cpp:177
void setPalette(SDL_Color *colors, int firstcolor=0, int ncolors=256)
Sets the text button&#39;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&#39;s current font.
Definition: TextButton.cpp:121
Coloured button with a text label.
Definition: TextButton.h:38
void setHighContrast(bool contrast)
Sets the text button&#39;s high contrast color setting.
Definition: TextButton.cpp:146
void setWidth(int width)
Sets the width of the surface.
Definition: TextButton.cpp:345
void mouseRelease(Action *action, State *state)
Special handling for mouse releases.
Definition: TextButton.cpp:317
~TextButton()
Cleans up the text button.
Definition: TextButton.cpp:52
void setTextColor(Uint8 color)
Sets the text button&#39;s text color.
Definition: TextButton.cpp:93
void setBig()
Sets the text size to big.
Definition: TextButton.cpp:102
Definition: BaseInfoState.cpp:40