GuiText Class Reference
[2D graphical user interface]

Displays a text. More...

#include <guitext.h>

Inheritance diagram for GuiText:

Inheritance graph
[legend]
Collaboration diagram for GuiText:

Collaboration graph
[legend]
List of all members.

Public Types

enum  FontSize {
  fs_theme = -1, fs_standard = 0, fs_text, fs_button,
  fs_heading
}
typedef SdlFont::VAlign VAlign
 see SdlFont::VAlign
typedef SdlFont::HAlign HAlign
 see SdlFont::HAlign

Public Member Functions

DECLSPEC GuiText (const SDL_Rect &r, GuiElement *p, const char *name, const char *t=0, FontSize font=fs_theme, bool light=false, bool stdAlign=true)
DECLSPEC GuiText (TiXmlElement *el, GuiElement *p)
virtual const char * getClassName ()
DECLSPEC void setText (const char *t)
DECLSPEC void addText (const char *t)
DECLSPEC void addLine (const char *t)
DECLSPEC bool clearLine (int l=0)
DECLSPEC int numLines ()
 
Returns:
the number of lines, the text has

void setAlign (VAlign v, HAlign h)
const char * getText () const
 
Returns:
the current text

DECLSPEC void chooseFont (FontSize size, bool light)
DECLSPEC void setFont (SdlFont *f)
virtual void setWordWrap (bool active)

Static Public Member Functions

static DECLSPEC FontSize strToSize (const char *s)
static DECLSPEC SdlFontfontSizeToFont (FontSize s, bool l, UiTheme *t)
static void newguiobject (void *presult, BasicObject *o, void *xmldata)
static void settext (void *sender, BasicObject *aim, void *text)

Protected Member Functions

virtual DECLSPEC Uint32 onFrame (SdlSurface *dst)
virtual DECLSPEC void onInit ()
virtual DECLSPEC Uint32 onThemeChanged (UiTheme *t)

Protected Attributes

int nCharWidth
 the size of one font letter
int nCharHeight
int curpos
 the position of the cursor, or -1 if invisible
bool showcursor
 whether to show the cursor or not
bool bWordWrap
 whether to use word wrapping or not

Detailed Description

Displays a text.


Member Enumeration Documentation

enum GuiText::FontSize

Font sizes.
fs_theme the theme default font
fs_standard the standard font should be used
fs_text the font for texts should be used (usually a small font)
fs_button the font for buttons should be used (usually a font of average size)
fs_heading the font for headings should be used (usually a font of big size)


Constructor & Destructor Documentation

GuiText::GuiText ( const SDL_Rect &  r,
GuiElement p,
const char *  name,
const char *  t = 0,
FontSize  font = fs_theme,
bool  light = false,
bool  stdAlign = true 
)

Constructor.

Parameters:
r the rect of the element's appearance, relative to the parent's top-left position
p the parent element; or NULL, if it will be used as top level
t the text to display; NULL, if no text should be displayed
font the font to use
light specifies whether to use the light font or the dark one
stdAlign if true, the theme's default align for this class is used

GuiText::GuiText ( TiXmlElement el,
GuiElement p 
)

Constructor. Uses XML data.

Parameters:
el the XML data for initialisation, the following attributes are read: ThemeAlign (bool), FontSize, LightFont (bool), Text (string), VAlign, HAlign
p parent element (or NULL, to take GuiManager::the as parent)
See also:
GuiElement(TiXmlElement*,GuiElement*)


Member Function Documentation

virtual const char* GuiText::getClassName (  )  [inline, virtual]

This function should be overriden in every sub-class of BasicObject!

Returns:
the name of the class.

Reimplemented from GuiElement.

Reimplemented in GuiTextInput, GuiKeyControl, and GuiFrameCounter.

void GuiText::setText ( const char *  t  ) 

Changes the displayed text.

Parameters:
t the new text string (maximum possible length is 65535 signs)

void GuiText::addText ( const char *  t  ) 

Adds text at the end of the current text.

Parameters:
t the text string to concatenate

void GuiText::addLine ( const char *  t  ) 

Adds text in a new line at the end of the current text.

Parameters:
t the text string to add

bool GuiText::clearLine ( int  l = 0  ) 

Clears a line from the text.

Parameters:
l the line's index (starting with 0 for the first line, last line is numLines()-1)
Returns:
true, if the line could be removed

void GuiText::setAlign ( VAlign  v,
HAlign  h 
) [inline]

Changes the alignments of the text.

Parameters:
v the vertical alignment
h the horizontal alignment

void GuiText::chooseFont ( FontSize  size,
bool  light 
)

Changes the font.

Parameters:
size the font's size category
light whether it should be light or dark

void GuiText::setFont ( SdlFont f  ) 

Changes the font by specifying the font directly.

Parameters:
f the font to use

virtual void GuiText::setWordWrap ( bool  active  )  [inline, virtual]

Specifies, whether or not to start a new line, when a line does not fit into the element's rect.

Parameters:
active if true, word wrapping is enabled; if false it is not

GuiText::FontSize GuiText::strToSize ( const char *  s  )  [static]

Converts a string to a kind of font size. Possible strings are: standard; text; button; heading; theme.

Parameters:
s the string to convert
Returns:
the corresponding value or fs_standard, if the expression is unknown

SdlFont * GuiText::fontSizeToFont ( FontSize  s,
bool  l,
UiTheme t 
) [static]

Fetches the font, that is used in the theme, has the size and is light or dark (as specified).

Parameters:
s the font's size category
l whether it must be light (true) or dark (false)
t the theme, in which the font must be deklared
Returns:
the font

static void GuiText::settext ( void *  sender,
BasicObject aim,
void *  text 
) [inline, static]

Used to set the text directly by callbacks that support a string as last param.

Uint32 GuiText::onFrame ( SdlSurface dst  )  [protected, virtual]

This event is called, when a frame is drawn. If the object should be visible, is has to draw it's look to a valid surface. This method calls the children's function, if visible.

Returns:
zero, if no error occured; if not zero, drawing is stopped
Note:
if you derive the function, then call GuiElement::onFrame(SdlSurface*) after your class's drawing was done in the onFrame-event, otherwise you paint over the children elements

Reimplemented from GuiElement.

Reimplemented in GuiTextInput, GuiKeyControl, and GuiFrameCounter.

void GuiText::onInit (  )  [protected, virtual]

Initializes the object's variables by reading data from the XML element. If there were no XML data used for creation, nothing is done. This function calls onInit() of its children recursively (after it has inited itself). It is highly recommended to call BasicObject::onInit(), usually at the end of the onInit() method, when overwriting it in a derived class.

Reimplemented from GuiElement.

Reimplemented in GuiTextInput, GuiKeyControl, and GuiFrameCounter.

Uint32 GuiText::onThemeChanged ( UiTheme t  )  [protected, virtual]

This event is called, when the theme changes. Perform here the changes of the object's look and feel.

Parameters:
t pointer to the new used theme
Returns:
currently the result is not used; may be zero, if no error...

Reimplemented from GuiElement.

Reimplemented in GuiTextInput.


The documentation for this class was generated from the following files:
Generated on Wed May 9 17:36:28 2007 for netrinjo by  doxygen 1.5.1