Gel2D - The free/open source game creation suite

Public Member Functions | Public Attributes
gel::GelText Class Reference

Text object. More...

#include <gelText.h>

Inheritance diagram for gel::GelText:
gel::GelObject gel::GelTextureObject gel::GelEventReceiver

List of all members.

Public Member Functions

 GelText ()
 Default constructor.
 GelText (GelFont *fnt)
 Convenience constructor.
 GelText (GelFont *fnt, const char *st,...)
 Convenience constructor.
 GelText (GelFont *fnt, Gel2dVec obj_pos)
 Convenience constructor.
 ~GelText ()
 Destructor.
GelFontgetFont () const
 Gets the font associated with this text object.
void setFont (GelFont *fnt)
 Sets the font to be used by the text.
void setString (const char *st,...)
 Sets the text that will be rendered to the screen.
void setCharPos (Gel2dVec position)
 Sets the position of the characters.
void setCharRot (float deg)
 Sets the rotation of the characters.
void setCharScl (Gel2dVec scale)
 Sets the scale of the characters.
void skewChar (float sk)
 Skews the character.
void setMaxLineLength (int len)
 Sets the maximum line length.
float getMaxLineLength () const
 Gets the maximum line length.
float getStringLength ()
 Gets the length of the text's string.
float getStringLength (const char *str)
 Gets the length of a specified string.
void setCharSpacing (float dist)
 Sets the spacing between characters.
float getCharSpacing () const
 Gets the spacing between characters.
void setLineSpacing (float dist)
 Sets the spacing between lines of text.
float getLineSpacing () const
 Gets the spacing between lines of text.
void setAlignment (Alignment mode)
 Sets the text alignment mode.
Alignment getAlignment () const
 Gets the text alignment mode.
void setOrientation (Orientation mode)
 Sets the orientation of the text.
Orientation getOrientation () const
 Gets the orientation of the text.
GelColor getCol () const
 Gets the color of the text.
void setCol (GelColor color)
 Sets the color of the text.
void setRGB (float r, float g, float b)
 Sets the color of the text in RGB floats.
float getAlpha () const
 Gets the transparency of the text.
void setAlpha (float alpha)
 Sets the transparency of the text.
void setTexture (GelTexture *tex)
 Sets the text's texture.
void render ()
 Renders the text to the screen.

Public Attributes

GelFontChar fchar [256]

Detailed Description

Text object.

This class is used for printing text to the screen. It gets most of its character information from a GelFont object.


Constructor & Destructor Documentation

gel::GelText::GelText ( )

Default constructor.

gel::GelText::GelText ( GelFont fnt)

Convenience constructor.

Parameters:
fnt: A GelFont object.
gel::GelText::GelText ( GelFont fnt,
const char *  st,
  ... 
)

Convenience constructor.

Parameters:
fnt: A GelFont object.
st: The string.
...: Optional arguments list.
gel::GelText::GelText ( GelFont fnt,
Gel2dVec  obj_pos 
)

Convenience constructor.

Parameters:
fnt: A GelFont object.
obj_pos: The object's x and y coordinates.
gel::GelText::~GelText ( )

Destructor.


Member Function Documentation

GelFont* gel::GelText::getFont ( ) const [inline]

Gets the font associated with this text object.

Returns:
Pointer to a GelFont.
void gel::GelText::setFont ( GelFont fnt)

Sets the font to be used by the text.

Parameters:
fnt: A GelFont object.
void gel::GelText::setString ( const char *  st,
  ... 
)

Sets the text that will be rendered to the screen.

Parameters:
st: The string.
...: Optional arguments list.
void gel::GelText::setCharPos ( Gel2dVec  position)

Sets the position of the characters.

void gel::GelText::setCharRot ( float  deg)

Sets the rotation of the characters.

void gel::GelText::setCharScl ( Gel2dVec  scale)

Sets the scale of the characters.

void gel::GelText::skewChar ( float  sk) [inline]

Skews the character.

This is a quick, handy way to italicize any font.

Parameters:
sk: The amount of skew to apply to the characters, in pixels
void gel::GelText::setMaxLineLength ( int  len) [inline]

Sets the maximum line length.

If the text string is longer than the maximum line length, it will start a new line below the previous one.

Parameters:
len: The maximum line length in pixels.
float gel::GelText::getMaxLineLength ( ) const [inline]

Gets the maximum line length.

Returns:
The maximum line length in pixels.
float gel::GelText::getStringLength ( )

Gets the length of the text's string.

Depending on whether the orientation of the text is horizontal or vertical, it will return the length or height of the string, respectively.

Returns:
The length of the string in pixels.
float gel::GelText::getStringLength ( const char *  str)

Gets the length of a specified string.

This function behaves the same as getStringLength().

Parameters:
str: The string to get the length of.
Returns:
The length of the string in pixels.
void gel::GelText::setCharSpacing ( float  dist) [inline]

Sets the spacing between characters.

Parameters:
dist: The number of pixels the characters should be spaced apart.
float gel::GelText::getCharSpacing ( ) const [inline]

Gets the spacing between characters.

Returns:
The amount of space between characters in pixels.
void gel::GelText::setLineSpacing ( float  dist) [inline]

Sets the spacing between lines of text.

Parameters:
dist: The number of pixels the lines of text should be spaced apart.
float gel::GelText::getLineSpacing ( ) const [inline]

Gets the spacing between lines of text.

Returns:
The amount of space between lines of text in pixels.
void gel::GelText::setAlignment ( Alignment  mode) [inline]

Sets the text alignment mode.

Alignment gel::GelText::getAlignment ( ) const [inline]

Gets the text alignment mode.

void gel::GelText::setOrientation ( Orientation  mode) [inline]

Sets the orientation of the text.

Orientation gel::GelText::getOrientation ( ) const [inline]

Gets the orientation of the text.

GelColor gel::GelText::getCol ( ) const [inline]

Gets the color of the text.

Returns:
The color of the text.
void gel::GelText::setCol ( GelColor  color)

Sets the color of the text.

Parameters:
color: The new color of the text.
void gel::GelText::setRGB ( float  r,
float  g,
float  b 
) [inline]

Sets the color of the text in RGB floats.

Parameters:
r: New red value.
g: New green value.
b: New blue value.
float gel::GelText::getAlpha ( ) const [inline]

Gets the transparency of the text.

Returns:
The alpha color component of the text.
void gel::GelText::setAlpha ( float  alpha) [inline]

Sets the transparency of the text.

It should be in range from 0 (transparent) to 1 (opaque).

Parameters:
alpha: The new alpha value.
void gel::GelText::setTexture ( GelTexture tex)

Sets the text's texture.

Parameters:
tex: The text's new texture.
void gel::GelText::render ( ) [virtual]

Renders the text to the screen.

Reimplemented from gel::GelObject.


Member Data Documentation


The documentation for this class was generated from the following file: