OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TextEdit.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_TEXTEDIT_H
20 #define OPENXCOM_TEXTEDIT_H
21 
22 #include "../Engine/InteractiveSurface.h"
23 #include "Text.h"
24 
25 namespace OpenXcom
26 {
27 
28 class Timer;
29 
36 {
37 private:
38  Text *_text, *_caret;
39  std::wstring _value;
40  bool _blink, _modal;
41  Timer *_timer;
42  wchar_t _ascii;
43  size_t _caretPos;
44  bool _numerical;
45  ActionHandler _change;
46  State *_state;
48  bool exceedsMaxWidth(wchar_t c);
49 public:
51  TextEdit(State *state, int width, int height, int x = 0, int y = 0);
53  ~TextEdit();
55  void handle(Action *action, State *state);
57  void setFocus(bool focus, bool modal = true);
59  void setBig();
61  void setSmall();
63  void initText(Font *big, Font *small, Language *lang);
65  void setText(const std::wstring &text);
67  std::wstring getText() const;
69  void setWordWrap(bool wrap);
71  void setInvert(bool invert);
73  void setHighContrast(bool contrast);
75  void setAlign(TextHAlign align);
77  void setVerticalAlign(TextVAlign valign);
79  void setNumerical(bool numerical);
81  void setColor(Uint8 color);
83  Uint8 getColor() const;
85  void setSecondaryColor(Uint8 color);
87  Uint8 getSecondaryColor() const;
89  void setPalette(SDL_Color *colors, int firstcolor = 0, int ncolors = 256);
91  void think();
93  void blink();
95  void draw();
97  void mousePress(Action *action, State *state);
99  void keyboardPress(Action *action, State *state);
101  void onChange(ActionHandler handler);
102 };
103 
104 }
105 
106 #endif
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:34
void setSmall()
Sets the text size to small.
Definition: TextEdit.cpp:121
void setPalette(SDL_Color *colors, int firstcolor=0, int ncolors=256)
Sets the text edit's palette.
Definition: TextEdit.cpp:270
void setSecondaryColor(Uint8 color)
Sets the text edit's secondary color.
Definition: TextEdit.cpp:250
void setWordWrap(bool wrap)
Sets the text edit's wordwrap setting.
Definition: TextEdit.cpp:167
A game state that receives user input and reacts accordingly.
Definition: State.h:44
TextEdit(State *state, int width, int height, int x=0, int y=0)
Creates a new text edit with the specified size and position.
Definition: TextEdit.cpp:37
void think()
Handles the timers.
Definition: TextEdit.cpp:280
Timer used to run code in fixed intervals.
Definition: Timer.h:37
Surface that the user can interact with.
Definition: InteractiveSurface.h:39
void setFocus(bool focus, bool modal=true)
Sets focus on this text edit.
Definition: TextEdit.cpp:82
void initText(Font *big, Font *small, Language *lang)
Initializes the text edit's resources.
Definition: TextEdit.cpp:135
Text string displayed on screen.
Definition: Text.h:41
void setBig()
Sets the text size to big.
Definition: TextEdit.cpp:112
void setVerticalAlign(TextVAlign valign)
Sets the text edit's vertical alignment.
Definition: TextEdit.cpp:209
void setText(const std::wstring &text)
Sets the text's string.
Definition: TextEdit.cpp:145
void setHighContrast(bool contrast)
Sets the text edit's high contrast color setting.
Definition: TextEdit.cpp:188
void setInvert(bool invert)
Sets the text edit's color invert setting.
Definition: TextEdit.cpp:177
void keyboardPress(Action *action, State *state)
Special handling for keyboard presses.
Definition: TextEdit.cpp:407
Contains strings used throughout the game for localization.
Definition: Language.h:42
void setNumerical(bool numerical)
Sets the text edit to numerical input.
Definition: TextEdit.cpp:218
Takes care of loading and storing each character in a sprite font.
Definition: Font.h:40
void blink()
Plays the blinking animation.
Definition: TextEdit.cpp:289
void draw()
Draws the text edit.
Definition: TextEdit.cpp:299
~TextEdit()
Cleans up the text edit.
Definition: TextEdit.cpp:50
void setColor(Uint8 color)
Sets the text edit's color.
Definition: TextEdit.cpp:229
void mousePress(Action *action, State *state)
Special handling for mouse presses.
Definition: TextEdit.cpp:367
std::wstring getText() const
Gets the text edit's string.
Definition: TextEdit.cpp:156
Uint8 getSecondaryColor() const
Gets the text edit's secondary color.
Definition: TextEdit.cpp:259
void invert(Uint8 mid)
Inverts the surface's colors.
Definition: Surface.cpp:451
void onChange(ActionHandler handler)
Hooks an action handler to when the slider changes.
Definition: TextEdit.cpp:508
void handle(Action *action, State *state)
Handle focus.
Definition: TextEdit.cpp:65
Uint8 getColor() const
Gets the text edit's color.
Definition: TextEdit.cpp:239
Editable version of Text.
Definition: TextEdit.h:35
void setAlign(TextHAlign align)
Sets the text edit's horizontal alignment.
Definition: TextEdit.cpp:199