#include <guitext.h>
Inheritance diagram for GuiText:
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 () |
| |
void | setAlign (VAlign v, HAlign h) |
const char * | getText () const |
| |
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 SdlFont * | fontSizeToFont (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 |
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)
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.
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.
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) |
virtual const char* GuiText::getClassName | ( | ) | [inline, virtual] |
This function should be overriden in every sub-class of BasicObject!
Reimplemented from GuiElement.
Reimplemented in GuiTextInput, GuiKeyControl, and GuiFrameCounter.
void GuiText::setText | ( | const char * | t | ) |
Changes the displayed text.
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.
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.
t | the text string to add |
bool GuiText::clearLine | ( | int | l = 0 |
) |
Clears a line from the text.
l | the line's index (starting with 0 for the first line, last line is numLines()-1) |
Changes the alignments of the text.
v | the vertical alignment | |
h | the horizontal alignment |
void GuiText::chooseFont | ( | FontSize | size, | |
bool | light | |||
) |
Changes the font.
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.
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.
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.
s | the string to convert |
Fetches the font, that is used in the theme, has the size and is light or dark (as specified).
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 |
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.
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.
t | pointer to the new used theme |
Reimplemented from GuiElement.
Reimplemented in GuiTextInput.