Class that can draw text, similiar to a TextLabel.Support multi-line and autowrap. More...
#include <TextSurface.hh>

Public Member Functions | |
| TextSurface (const std::string &font_name, int font_size, int surf_width, int surf_height) | |
| TextSurface (const TextSurface &ts) | |
| TextSurface & | operator= (const TextSurface &rhs) |
| void | clearText () |
| Erase all lines. | |
| void | setText (const std::string &text) |
| Set text to be printed, clearing previous content. | |
| void | addText (const std::string &text) |
| Add text to this object, on new line. | |
| std::string | getText () const |
| Return the text (all lines) currently displayed. | |
| void | setAutoWrap (bool enabled) |
| Auto-wrap text, add new lines when text go beyond surface width. | |
| bool | getAutoWrap () const |
| Get Auto-wrapping current setting. | |
| void | setTextColor (const SDL_Color &fg) |
| Set text color. | |
| void | setBgColor (const SDL_Color &bg) |
| Set baground color, only for method eTextShaded. | |
| void | setRenderMethod (enum eTextRenderMethod m) |
| Set rendering method. | |
| virtual void | update () |
| Method called each frame, to perfom user custom code. | |
Protected Types | |
| typedef std::deque< std::string > | LineList |
Protected Member Functions | |
| virtual void | customTextRender (SDL_Surface *surf, int line) |
| Called when a new text surface is generated. | |
Protected Attributes | |
| TTF_Font * | font_ |
| bool | content_changed_ |
| LineList | lines_ |
| std::string | text_ |
Class that can draw text, similiar to a TextLabel.
Support multi-line and autowrap.
| void TextSurface::addText | ( | const std::string & | text | ) |
Add text to this object, on new line.
If the object is too little to show all text, the oldest added lines are removed.
| text | Text to add. |
References Surface::getRect().
Referenced by setText().
| bool TextSurface::getAutoWrap | ( | ) | const |
Get Auto-wrapping current setting.
| std::string TextSurface::getText | ( | ) | const |
Return the text (all lines) currently displayed.
| void TextSurface::setAutoWrap | ( | bool | enabled | ) |
Auto-wrap text, add new lines when text go beyond surface width.
| enabled | Enable or disable it (default: enabled). |
Referenced by sdlvisu::CmdButton::CmdButton().
| void TextSurface::setBgColor | ( | const SDL_Color & | bg | ) |
Set baground color, only for method eTextShaded.
| bg | Color to set (default: white). |
Referenced by sdlvisu::CmdButton::CmdButton(), and sdlvisu::Map::drawPath().
| void TextSurface::setRenderMethod | ( | enum eTextRenderMethod | m | ) |
Set rendering method.
| m | Render method to use. |
Referenced by sdlvisu::CmdButton::CmdButton(), and sdlvisu::Map::drawPath().
| void TextSurface::setText | ( | const std::string & | text | ) |
Set text to be printed, clearing previous content.
| text | Text to set. |
References addText().
Referenced by sdlvisu::InfoBar::addMessage(), sdlvisu::CmdButton::CmdButton(), sdlvisu::Map::drawBlock(), sdlvisu::Map::drawPath(), sdlvisu::Map::drawThrow(), sdlvisu::Panel::setHalf(), and InputTextSurface::update().
| void TextSurface::setTextColor | ( | const SDL_Color & | fg | ) |
Set text color.
| fg | Color to set (default: black). |
Referenced by sdlvisu::CmdButton::CmdButton().
| void TextSurface::update | ( | ) | [virtual] |
Method called each frame, to perfom user custom code.
You should override it.
Since a parent is assigned to the surface (and this parent is itself attached by other means to the root screen), this method is called at each frame. It is not called if this surface or one of its parent is disabled. In this method you can do what you want with your object, like processing input, updating other programs attributes, changing surface property, ...
Reimplemented from Surface.
Reimplemented in InputTextSurface.
References customTextRender(), eTextBlended, eTextShaded, and eTextSolid.
Referenced by sdlvisu::CmdButton::updateStatus().
1.6.3