Used to draw some text on the screen. More...
#include <gui_text.hpp>
Classes | |
struct | format |
Contains information about the text at a given position. More... | |
struct | letter |
Holds the position, tex. coordinates and color of a character. More... | |
struct | line |
Contains a string that will be drawn on a line. More... | |
Public Types | |
enum | color_action { COLOR_ACTION_NONE, COLOR_ACTION_SET, COLOR_ACTION_RESET } |
enum | alignment { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT } |
enum | vertical_alignment { ALIGN_TOP, ALIGN_MIDDLE, ALIGN_BOTTOM } |
Public Member Functions | |
text (manager *pManager, const std::string &sFileName, float fSize) | |
Constructor. | |
~text () | |
Destructor. | |
const std::string & | get_font_name () const |
Returns the path to the .ttf file. | |
float | get_font_size () const |
Returns the size of the font. | |
float | get_line_height () const |
Returns the height of one line (constant). | |
void | set_text (const std::string &sText) |
set_ the text to render. | |
const std::string & | get_text () const |
Returns the text that will be rendered. | |
const utils::ustring & | get_unicode_text () const |
Returns the text that will be rendered (unicode character set). | |
void | set_color (const color &mColor, bool bForceColor=false) |
Sets this text's default color. | |
const color & | get_color () const |
Returns this text's default color. | |
void | set_dimensions (float fW, float fH) |
Sets the dimensions of the text box. | |
void | set_box_width (float fBoxW) |
Sets the width of the text box. | |
void | set_box_height (float fBoxH) |
Sets the height of the text box. | |
float | get_width () |
Returns the width of the rendered text. | |
float | get_height () |
Returns the height of the rendered text. | |
float | get_box_width () const |
Returns the width of the text box. | |
float | get_box_height () const |
Returns the height of the text box. | |
float | get_text_width () const |
Returns the length of the text. | |
float | get_string_width (const std::string &sString) const |
Returns the lenght of a provided string. | |
float | get_string_width (const utils::ustring &sString) const |
Returns the lenght of a provided string. | |
float | get_character_width (uint uiChar) const |
Returns the length of a single character. | |
float | get_character_kerning (uint uiChar1, uint uiChar2) const |
Returns the kerning between two characters. | |
float | get_text_height () const |
Returns the height of the text. | |
void | set_alignment (const alignment &mAlign) |
Sets text alignment. | |
void | set_vertical_alignment (const vertical_alignment &mVertAlign) |
Sets text vertical alignment. | |
const alignment & | get_alignment () const |
Returns the text aligment. | |
const vertical_alignment & | get_vertical_alignment () const |
Returns the text aligment. | |
void | set_tracking (float fTracking) |
Sets this text's tracking. | |
float | get_tracking () const |
Returns this text's tracking. | |
void | set_line_spacing (float fLineSpacing) |
Sets this text's line spacing. | |
float | get_line_spacing () const |
Returns this text's line spacing. | |
void | set_remove_starting_spaces (bool bRemoveStartingSpaces) |
Allows removal of a line's starting spaces. | |
bool | get_remove_starting_spaces () const |
Checks if starting spaces removing is active. | |
void | enable_word_wrap (bool bWrap, bool bAddEllipsis) |
Allows word wrap when the line is too long for the text box. | |
bool | is_word_wrap_enabled () const |
Checks if word wrap is enabled. | |
void | enable_formatting (bool bFormatting) |
Enables color formatting. | |
void | render (float fX, float fY) |
Renders this text at the given position. | |
void | update () |
updates this text's cache. | |
const std::vector< letter > & | get_letter_cache () |
Returns the cached letters (position, size, texture coordinates). | |
utils::refptr< sprite > | create_sprite (uint uiChar) const |
Creates a sprite that contains the provided character. |
Used to draw some text on the screen.
Definition at line 22 of file gui_text.hpp.
enum gui::text::alignment |
Definition at line 50 of file gui_text.hpp.
Definition at line 33 of file gui_text.hpp.
Definition at line 57 of file gui_text.hpp.
gui::text::text | ( | manager * | pManager, | |
const std::string & | sFileName, | |||
float | fSize | |||
) |
Constructor.
sFileName | The path to the .ttf file to use | |
fSize | The size of the font (in point) |
Definition at line 17 of file gui_text.cpp.
gui::text::~text | ( | ) |
Destructor.
Definition at line 41 of file gui_text.cpp.
utils::refptr< sprite > gui::text::create_sprite | ( | uint | uiChar | ) | const |
Creates a sprite that contains the provided character.
uiChar | The character to draw |
Definition at line 924 of file gui_text.cpp.
void gui::text::enable_formatting | ( | bool | bFormatting | ) |
void gui::text::enable_word_wrap | ( | bool | bWrap, | |
bool | bAddEllipsis | |||
) |
Allows word wrap when the line is too long for the text box.
bWrap | 'true' to enable word wrap | |
bAddEllipsis | 'true' to put "..." at the end of a truncated line |
Definition at line 323 of file gui_text.cpp.
const text::alignment & gui::text::get_alignment | ( | ) | const |
float gui::text::get_box_height | ( | ) | const |
Returns the height of the text box.
Definition at line 141 of file gui_text.cpp.
float gui::text::get_box_width | ( | ) | const |
Returns the width of the text box.
Definition at line 136 of file gui_text.cpp.
float gui::text::get_character_kerning | ( | uint | uiChar1, | |
uint | uiChar2 | |||
) | const |
Returns the kerning between two characters.
uiChar1 | The first character | |
uiChar2 | The second character |
Definition at line 248 of file gui_text.cpp.
float gui::text::get_character_width | ( | uint | uiChar | ) | const |
Returns the length of a single character.
uiChar | The character to measure |
Definition at line 233 of file gui_text.cpp.
const color & gui::text::get_color | ( | ) | const |
Returns this text's default color.
Definition at line 90 of file gui_text.cpp.
const std::string & gui::text::get_font_name | ( | ) | const |
Returns the path to the .ttf file.
Definition at line 45 of file gui_text.cpp.
float gui::text::get_font_size | ( | ) | const |
Returns the size of the font.
Definition at line 50 of file gui_text.cpp.
float gui::text::get_height | ( | ) |
Returns the height of the rendered text.
Definition at line 129 of file gui_text.cpp.
const std::vector< text::letter > & gui::text::get_letter_cache | ( | ) |
Returns the cached letters (position, size, texture coordinates).
Definition at line 939 of file gui_text.cpp.
float gui::text::get_line_height | ( | ) | const |
Returns the height of one line (constant).
Definition at line 55 of file gui_text.cpp.
float gui::text::get_line_spacing | ( | ) | const |
Returns this text's line spacing.
Definition at line 304 of file gui_text.cpp.
bool gui::text::get_remove_starting_spaces | ( | ) | const |
Checks if starting spaces removing is active.
Definition at line 318 of file gui_text.cpp.
float gui::text::get_string_width | ( | const utils::ustring & | sString | ) | const |
Returns the lenght of a provided string.
sString | The string to measure |
Definition at line 198 of file gui_text.cpp.
float gui::text::get_string_width | ( | const std::string & | sString | ) | const |
Returns the lenght of a provided string.
sString | The string to measure |
Definition at line 193 of file gui_text.cpp.
const std::string & gui::text::get_text | ( | ) | const |
Returns the text that will be rendered.
Definition at line 70 of file gui_text.cpp.
float gui::text::get_text_height | ( | ) | const |
float gui::text::get_text_width | ( | ) | const |
float gui::text::get_tracking | ( | ) | const |
Returns this text's tracking.
Definition at line 290 of file gui_text.cpp.
const utils::ustring & gui::text::get_unicode_text | ( | ) | const |
Returns the text that will be rendered (unicode character set).
Definition at line 75 of file gui_text.cpp.
const text::vertical_alignment & gui::text::get_vertical_alignment | ( | ) | const |
float gui::text::get_width | ( | ) |
Returns the width of the rendered text.
Definition at line 122 of file gui_text.cpp.
bool gui::text::is_word_wrap_enabled | ( | ) | const |
Checks if word wrap is enabled.
Definition at line 333 of file gui_text.cpp.
void gui::text::render | ( | float | fX, | |
float | fY | |||
) |
Renders this text at the given position.
fX | The horizontal position of the top left corner | |
fY | The vertical position of the top left corner |
Definition at line 347 of file gui_text.cpp.
void gui::text::set_alignment | ( | const alignment & | mAlign | ) |
Sets text alignment.
mAlign | The new alignment |
Definition at line 253 of file gui_text.cpp.
void gui::text::set_box_height | ( | float | fBoxH | ) |
Sets the height of the text box.
fBoxH | The new height |
Definition at line 113 of file gui_text.cpp.
void gui::text::set_box_width | ( | float | fBoxW | ) |
Sets the width of the text box.
fBoxW | The new witdh |
Definition at line 104 of file gui_text.cpp.
void gui::text::set_color | ( | const color & | mColor, | |
bool | bForceColor = false | |||
) |
Sets this text's default color.
Definition at line 80 of file gui_text.cpp.
void gui::text::set_dimensions | ( | float | fW, | |
float | fH | |||
) |
Sets the dimensions of the text box.
fW | The new witdh | |
fH | The new height |
Definition at line 95 of file gui_text.cpp.
void gui::text::set_line_spacing | ( | float | fLineSpacing | ) |
Sets this text's line spacing.
fLineSpacing | The new line spacing |
Definition at line 295 of file gui_text.cpp.
void gui::text::set_remove_starting_spaces | ( | bool | bRemoveStartingSpaces | ) |
Allows removal of a line's starting spaces.
bRemoveStartingSpaces | 'true' to remove them |
Definition at line 309 of file gui_text.cpp.
void gui::text::set_text | ( | const std::string & | sText | ) |
void gui::text::set_tracking | ( | float | fTracking | ) |
Sets this text's tracking.
fTracking | The new tracking |
Definition at line 281 of file gui_text.cpp.
void gui::text::set_vertical_alignment | ( | const vertical_alignment & | mVertAlign | ) |
Sets text vertical alignment.
mVertAlign | The new vertical alignment |
Definition at line 262 of file gui_text.cpp.
void gui::text::update | ( | ) |
updates this text's cache.
Definition at line 416 of file gui_text.cpp.