TextSurface Class Reference
[C++ Wrapper for SDL]

Class that can draw text, similiar to a TextLabel.

Support multi-line and autowrap. More...

#include <TextSurface.hh>

Inheritance diagram for TextSurface:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 TextSurface (const std::string &font_name, int font_size, int surf_width, int surf_height)
 TextSurface (const TextSurface &ts)
TextSurfaceoperator= (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_

Detailed Description

Class that can draw text, similiar to a TextLabel.

Support multi-line and autowrap.


Member Function Documentation

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.

Parameters:
text Text to add.

bool TextSurface::getAutoWrap (  )  const

Get Auto-wrapping current setting.

Returns:
Auto-wrap current setting.

std::string TextSurface::getText (  )  const

Return the text (all lines) currently displayed.

Returns:
Displayed text.

void TextSurface::setAutoWrap ( bool  enabled  ) 

Auto-wrap text, add new lines when text go beyond surface width.

Parameters:
enabled Enable or disable it (default: enabled).

void TextSurface::setBgColor ( const SDL_Color &  bg  ) 

Set baground color, only for method eTextShaded.

Parameters:
bg Color to set (default: white).

void TextSurface::setRenderMethod ( enum eTextRenderMethod  m  ) 

Set rendering method.

Parameters:
m Render method to use.

void TextSurface::setText ( const std::string &  text  ) 

Set text to be printed, clearing previous content.

Parameters:
text Text to set.

void TextSurface::setTextColor ( const SDL_Color &  fg  ) 

Set text color.

Parameters:
fg Color to set (default: black).

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, ...

Note:
Don't forget to call update for the base class at the end of your function , otherwise strange things will happen.

Reimplemented from Surface.

Reimplemented in InputTextSurface.


The documentation for this class was generated from the following files:
Generated on Sat Jun 23 16:14:17 2007 for Stechec/TBT by  doxygen 1.4.7