OpenXcom
1.0
Open-source clone of the original X-Com
|
Editable version of Text. More...
#include <TextEdit.h>
Public Member Functions | |
TextEdit (State *state, int width, int height, int x=0, int y=0) | |
Creates a new text edit with the specified size and position. More... | |
~TextEdit () | |
Cleans up the text edit. More... | |
void | handle (Action *action, State *state) |
Handle focus. More... | |
void | setFocus (bool focus, bool modal=true) |
Sets focus on this text edit. More... | |
void | setBig () |
Sets the text size to big. More... | |
void | setSmall () |
Sets the text size to small. More... | |
void | initText (Font *big, Font *small, Language *lang) |
Initializes the text edit's resources. More... | |
void | setText (const std::wstring &text) |
Sets the text's string. More... | |
std::wstring | getText () const |
Gets the text edit's string. More... | |
void | setWordWrap (bool wrap) |
Sets the text edit's wordwrap setting. More... | |
void | setInvert (bool invert) |
Sets the text edit's color invert setting. More... | |
void | setHighContrast (bool contrast) |
Sets the text edit's high contrast color setting. More... | |
void | setAlign (TextHAlign align) |
Sets the text edit's horizontal alignment. More... | |
void | setVerticalAlign (TextVAlign valign) |
Sets the text edit's vertical alignment. More... | |
void | setNumerical (bool numerical) |
Sets the text edit to numerical input. More... | |
void | setColor (Uint8 color) |
Sets the text edit's color. More... | |
Uint8 | getColor () const |
Gets the text edit's color. More... | |
void | setSecondaryColor (Uint8 color) |
Sets the text edit's secondary color. More... | |
Uint8 | getSecondaryColor () const |
Gets the text edit's secondary color. More... | |
void | setPalette (SDL_Color *colors, int firstcolor=0, int ncolors=256) |
Sets the text edit's palette. More... | |
void | think () |
Handles the timers. More... | |
void | blink () |
Plays the blinking animation. More... | |
void | draw () |
Draws the text edit. More... | |
void | mousePress (Action *action, State *state) |
Special handling for mouse presses. More... | |
void | keyboardPress (Action *action, State *state) |
Special handling for keyboard presses. More... | |
void | onChange (ActionHandler handler) |
Hooks an action handler to when the slider changes. More... | |
Public Member Functions inherited from OpenXcom::InteractiveSurface | |
InteractiveSurface (int width, int height, int x=0, int y=0) | |
Creates a new interactive surface with the specified size and position. More... | |
virtual | ~InteractiveSurface () |
Cleans up the interactive surface. | |
void | setVisible (bool visible) |
Sets the surface's visibility. More... | |
virtual void | setFocus (bool focus) |
Sets the focus of this surface. More... | |
bool | isFocused () const |
Gets the focus of this surface. More... | |
virtual void | unpress (State *state) |
Unpresses the surface. More... | |
void | onMouseClick (ActionHandler handler, Uint8 button=SDL_BUTTON_LEFT) |
Hooks an action handler to a mouse click on the surface. More... | |
void | onMousePress (ActionHandler handler, Uint8 button=0) |
Hooks an action handler to a mouse press over the surface. More... | |
void | onMouseRelease (ActionHandler handler, Uint8 button=0) |
Hooks an action handler to a mouse release over the surface. More... | |
void | onMouseIn (ActionHandler handler) |
Hooks an action handler to moving the mouse into the surface. More... | |
void | onMouseOver (ActionHandler handler) |
Hooks an action handler to moving the mouse over the surface. More... | |
void | onMouseOut (ActionHandler handler) |
Hooks an action handler to moving the mouse out of the surface. More... | |
void | onKeyboardPress (ActionHandler handler, SDLKey key=SDLK_ANY) |
Hooks an action handler to pressing a key when the surface is focused. More... | |
void | onKeyboardRelease (ActionHandler handler, SDLKey key=SDLK_ANY) |
Hooks an action handler to releasing a key when the surface is focused. More... | |
virtual void | mouseRelease (Action *action, State *state) |
Processes a mouse button release event. More... | |
virtual void | mouseClick (Action *action, State *state) |
Processes a mouse click event. More... | |
virtual void | mouseIn (Action *action, State *state) |
Processes a mouse hover in event. More... | |
virtual void | mouseOver (Action *action, State *state) |
Processes a mouse hover event. More... | |
virtual void | mouseOut (Action *action, State *state) |
Processes a mouse hover out event. More... | |
virtual void | keyboardRelease (Action *action, State *state) |
Processes a keyboard key release event. More... | |
void | setListButton () |
Check this surface to see if it's a textlist button. More... | |
Public Member Functions inherited from OpenXcom::Surface | |
Surface (int width, int height, int x=0, int y=0, int bpp=8) | |
Creates a new surface with the specified size and position. More... | |
Surface (const Surface &other) | |
Creates a new surface from an existing one. More... | |
virtual | ~Surface () |
Cleans up the surface. More... | |
void | loadScr (const std::string &filename) |
Loads an X-Com SCR graphic. More... | |
void | loadSpk (const std::string &filename) |
Loads an X-Com SPK graphic. More... | |
void | loadBdy (const std::string &filename) |
Loads a TFTD BDY graphic. More... | |
void | loadImage (const std::string &filename) |
Loads a general image file. More... | |
void | clear () |
Clears the surface's contents. More... | |
void | offset (int off, int min=-1, int max=-1, int mul=1) |
Offsets the surface's colors by a set amount. More... | |
void | invert (Uint8 mid) |
Inverts the surface's colors. More... | |
virtual void | blit (Surface *surface) |
Blits this surface onto another one. More... | |
void | copy (Surface *surface) |
Copies a portion of another surface into this one. More... | |
void | drawRect (SDL_Rect *rect, Uint8 color) |
Draws a filled rectangle on the surface. More... | |
void | drawRect (Sint16 x, Sint16 y, Sint16 w, Sint16 h, Uint8 color) |
Draws a filled rectangle on the surface. More... | |
void | drawLine (Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 color) |
Draws a line on the surface. More... | |
void | drawCircle (Sint16 x, Sint16 y, Sint16 r, Uint8 color) |
Draws a filled circle on the surface. More... | |
void | drawPolygon (Sint16 *x, Sint16 *y, int n, Uint8 color) |
Draws a filled polygon on the surface. More... | |
void | drawTexturedPolygon (Sint16 *x, Sint16 *y, int n, Surface *texture, int dx, int dy) |
Draws a textured polygon on the surface. More... | |
void | drawString (Sint16 x, Sint16 y, const char *s, Uint8 color) |
Draws a string on the surface. More... | |
SDL_Color * | getPalette () const |
Returns the surface's 8bpp palette. More... | |
virtual void | setX (int x) |
Sets the X position of the surface. More... | |
int | getX () const |
Returns the position of the surface in the X axis. More... | |
virtual void | setY (int y) |
Sets the Y position of the surface. More... | |
int | getY () const |
Returns the position of the surface in the Y axis. More... | |
void | setVisible (bool visible) |
Sets the surface's visibility. More... | |
bool | getVisible () const |
Gets the surface's visibility. More... | |
void | resetCrop () |
Resets the cropping rectangle for the surface. More... | |
SDL_Rect * | getCrop () |
Gets the cropping rectangle for the surface. More... | |
void | setPixel (int x, int y, Uint8 pixel) |
Changes the color of a pixel in the surface, relative to the top-left corner of the surface. More... | |
void | setPixelIterative (int *x, int *y, Uint8 pixel) |
Changes the color of a pixel in the surface and returns the next pixel position. More... | |
Uint8 | getPixel (int x, int y) const |
Returns the color of a specified pixel in the surface. More... | |
SDL_Surface * | getSurface () const |
Returns the internal SDL_Surface for SDL calls. More... | |
int | getWidth () const |
Returns the width of the surface. More... | |
virtual void | setWidth (int width) |
Sets the width of the surface. More... | |
int | getHeight () const |
Returns the height of the surface. More... | |
virtual void | setHeight (int height) |
Sets the height of the surface. More... | |
void | setHidden (bool hidden) |
Sets the surface's special hidden flag. More... | |
void | lock () |
Locks the surface. More... | |
void | unlock () |
Unlocks the surface. More... | |
void | blitNShade (Surface *surface, int x, int y, int off, bool half=false, int newBaseColor=0) |
Specific blit function to blit battlescape terrain data in different shades in a fast way. More... | |
void | invalidate () |
Invalidate the surface: force it to be redrawn. More... | |
std::string | getTooltip () const |
Gets the tooltip of the surface. More... | |
void | setTooltip (const std::string &tooltip) |
Sets the tooltip of the surface. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from OpenXcom::InteractiveSurface | |
bool | isButtonPressed (Uint8 button=0) |
Is this mouse button pressed? | |
virtual bool | isButtonHandled (Uint8 button=0) |
Is this mouse button event handled? | |
void | setButtonPressed (Uint8 button, bool pressed) |
Set a mouse button's internal state. | |
Protected Member Functions inherited from OpenXcom::Surface | |
void | resize (int width, int height) |
Recreates the surface with a new size. More... | |
Editable version of Text.
Receives keyboard input to allow the player to change the text himself.
OpenXcom::TextEdit::TextEdit | ( | State * | state, |
int | width, | ||
int | height, | ||
int | x = 0 , |
||
int | y = 0 |
||
) |
Creates a new text edit with the specified size and position.
Sets up a blank text edit with the specified size and position.
state | Pointer to state the text edit belongs to. |
width | Width in pixels. |
height | Height in pixels. |
x | X position in pixels. |
y | Y position in pixels. |
OpenXcom::TextEdit::~TextEdit | ( | ) |
Cleans up the text edit.
Deletes contents.
void OpenXcom::TextEdit::blink | ( | ) |
Plays the blinking animation.
Plays the blinking animation when the text edit is focused.
|
virtual |
Draws the text edit.
Adds a flashing | caret to the text to show when it's focused and editable.
Reimplemented from OpenXcom::Surface.
Uint8 OpenXcom::TextEdit::getColor | ( | ) | const |
Gets the text edit's color.
Returns the color used to render the text.
Uint8 OpenXcom::TextEdit::getSecondaryColor | ( | ) | const |
Gets the text edit's secondary color.
Returns the secondary color used to render the text.
std::wstring OpenXcom::TextEdit::getText | ( | ) | const |
Handle focus.
Passes events to internal components.
action | Pointer to an action. |
state | State that the action handlers belong to. |
Reimplemented from OpenXcom::InteractiveSurface.
Initializes the text edit's resources.
Changes the various fonts for the text edit to use.
The different fonts need to be passed in advance since the text size can change mid-text.
big | Pointer to large-size font. |
small | Pointer to small-size font. |
lang | Pointer to current language. |
Reimplemented from OpenXcom::Surface.
Special handling for keyboard presses.
Changes the text edit according to keyboard input, and unfocuses the text if Enter is pressed.
action | Pointer to an action. |
state | State that the action handlers belong to. |
Reimplemented from OpenXcom::InteractiveSurface.
Special handling for mouse presses.
Focuses the text edit when it's pressed on.
action | Pointer to an action. |
state | State that the action handlers belong to. |
Reimplemented from OpenXcom::InteractiveSurface.
void OpenXcom::TextEdit::onChange | ( | ActionHandler | handler | ) |
Hooks an action handler to when the slider changes.
Sets a function to be called every time the text changes.
handler | Action handler. |
void OpenXcom::TextEdit::setAlign | ( | TextHAlign | align | ) |
Sets the text edit's horizontal alignment.
Changes the way the text is aligned horizontally relative to the drawing area.
align | Horizontal alignment. |
void OpenXcom::TextEdit::setBig | ( | ) |
Sets the text size to big.
Changes the text edit to use the big-size font.
void OpenXcom::TextEdit::setColor | ( | Uint8 | color | ) |
Sets the text edit's color.
Changes the color used to render the text.
Unlike regular graphics, fonts are greyscale so they need to be assigned a specific position in the palette to be displayed.
color | Color value. |
void OpenXcom::TextEdit::setFocus | ( | bool | focus, |
bool | modal = true |
||
) |
Sets focus on this text edit.
Controls the blinking animation when the text edit is focused.
focus | True if focused, false otherwise. |
modal | True to lock input to this control, false otherwise. |
void OpenXcom::TextEdit::setHighContrast | ( | bool | contrast | ) |
Sets the text edit's high contrast color setting.
Enables/disables high contrast color.
Mostly used for Battlescape text.
contrast | High contrast setting. |
void OpenXcom::TextEdit::setInvert | ( | bool | invert | ) |
Sets the text edit's color invert setting.
Enables/disables color inverting.
Mostly used to make button text look pressed along with the button.
invert | Invert setting. |
void OpenXcom::TextEdit::setNumerical | ( | bool | numerical | ) |
Sets the text edit to numerical input.
Restricts the text to only numerical input.
numerical | Numerical restriction. |
|
virtual |
Sets the text edit's palette.
Replaces a certain amount of colors in the text edit's palette.
colors | Pointer to the set of colors. |
firstcolor | Offset of the first color to replace. |
ncolors | Amount of colors to replace. |
Reimplemented from OpenXcom::Surface.
void OpenXcom::TextEdit::setSecondaryColor | ( | Uint8 | color | ) |
Sets the text edit's secondary color.
Changes the secondary color used to render the text.
The text switches between the primary and secondary color whenever there's a 0x01 in the string.
color | Color value. |
void OpenXcom::TextEdit::setSmall | ( | ) |
Sets the text size to small.
Changes the text edit to use the small-size font.
void OpenXcom::TextEdit::setText | ( | const std::wstring & | text | ) |
void OpenXcom::TextEdit::setVerticalAlign | ( | TextVAlign | valign | ) |
Sets the text edit's vertical alignment.
Changes the way the text is aligned vertically relative to the drawing area.
valign | Vertical alignment. |
void OpenXcom::TextEdit::setWordWrap | ( | bool | wrap | ) |
Sets the text edit's wordwrap setting.
Enables/disables text wordwrapping.
When enabled, lines of text are automatically split to ensure they stay within the drawing area, otherwise they simply go off the edge.
wrap | Wordwrapping setting. |
|
virtual |