15 #ifndef TEXT_HPP_INCLUDED
16 #define TEXT_HPP_INCLUDED
22 #include <boost/noncopyable.hpp>
24 #include <pango/pango.h>
25 #include <pango/pangocairo.h>
67 :
private boost::noncopyable
90 sdl::timage render_as_texture()
const;
162 const unsigned column,
const unsigned line = 0)
const;
260 mutable sdl::timage texture_;
364 void rerender(
const bool force =
false)
const;
Uint32 foreground_color_
The foreground color.
void create_surface_buffer(const size_t size) const
Creates a new buffer.
std::vector< char_t > string
ttext & set_alignment(const PangoAlignment alignment)
family_class
Font classes for get_font_families().
ttext & set_link_aware(bool b)
void recalculate(const bool force=false) const
Recalculates the text.
const std::string & text() const
ttext & set_font_style(const unsigned font_style)
ttext & set_maximum_length(const size_t maximum_length)
bool calculation_dirty_
The text has two dirty states:
unsigned insert_text(const unsigned offset, const std::string &text)
Inserts UTF-8 text.
bool is_truncated() const
Has the text been truncated?
ttext & set_font_size(const unsigned font_size)
gui2::tpoint get_column_line(const gui2::tpoint &position) const
Gets the column of line of the character at the position.
bool markedup_text_
Is the text markedup if so the markedup render routines need to be used.
ttext & set_maximum_width(int width)
ttext & set_link_color(const std::string &color)
bool surface_dirty_
The dirty state of the surface.
PangoAlignment alignment_
The alignment of the text.
A class inherited from ttext_box that displays its input as stars.
GLdouble GLdouble GLdouble b
std::string link_color_
The color to render links in.
unsigned characters_per_line_
The number of characters per line.
int get_height() const
Returns the height needed for the text.
bool set_markup(const std::string &text)
Sets the markup'ed text.
std::string get_link(const gui2::tpoint &position) const
Checks if position points to a character in a link in the text, returns it if so, empty string otherw...
ttext & set_maximum_height(int height, bool multiline)
size_t get_length() const
Gets the length of the text in characters.
gui2::tpoint get_size() const
Returns the size needed for the text.
font::family_class font_class_
The font family class used.
static const unsigned STYLE_BOLD
Bold text.
gui2::tpoint get_cursor_position(const unsigned column, const unsigned line=0) const
Gets the location for the cursor.
int maximum_height_
The maximum height of the text.
ttext & set_characters_per_line(const unsigned characters_per_line)
void rerender(const bool force=false) const
Renders the text.
bool link_aware_
Are hyperlinks in the text marked-up, and will get_link return them.
static const unsigned STYLE_ITALIC
Italicized text.
unsigned font_style_
The style of the font, this is an orred mask of the font flags.
static const unsigned STYLE_NORMAL
The flags have the same values as the ones in SDL_TTF so it's easy to mix them for now...
GLenum GLenum GLvoid GLvoid * column
std::string escape_text(const std::string &text)
Escapes the markup characters in a text.
std::string get_token(const gui2::tpoint &position, const char *delimiters=" \n\r\t") const
Gets the largest collection of characters, including the token at position, and not including any cha...
surface render() const
Returns the rendered text.
std::string handle_token(const std::string &token) const
surface surface_
The surface to render upon used as a cache.
Contains a wrapper class for the GPU_Image class.
bool insert_unicode(const unsigned offset, ucs4::char_t unicode)
Inserts a unicode char.
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
unsigned char * surface_buffer_
Buffer to store the image on.
unsigned font_size_
The font size to draw.
ttext & set_family_class(font::family_class fclass)
int get_width() const
Returns the width needed for the text.
int maximum_width_
The maximum width of the text.
bool set_text(const std::string &text, const bool markedup)
Sets the text to render.
GLint GLint GLint GLint GLint GLint GLsizei width
PangoEllipsizeMode ellipse_mode_
The way too long text is shown depends on this mode.
std::string text_
The text to draw (stored as UTF-8).
bool set_markup_helper(const std::string &text)
size_t maximum_length_
The maximum length of the text.
static const unsigned STYLE_UNDERLINE
Underlined text.
GLsizei const GLcharARB ** string
size_t length_
Length of the text.
ttext & set_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
ttext & set_foreground_color(const Uint32 color)