class MASKING_DLL_DECLSPEC Label

Label is a very simple widget for creating both static and dynamic textual labels.

Inheritance:

Label - Widget - Rect


Public Methods

[more] Label()
default constructor
[more] ~Label()
destructor
[more]void Setup(int x, int y, int w, int h, int key, int flags, const char* text, int a=0)
Shortcut for Widget::Setup, SetText and SetAlignment
[more]virtual void SetText(const char* t)
Sets the text string the label is supposed to print out
[more]virtual void SetNumber(int value)
The label can render numbers as well as normal text.
[more]virtual void SetNumber(double value)
See Setnumber (int)
[more]virtual char* GetText()
Returns the label's text
[more]virtual int GetInt()
This function attempts to convert as much of the text as possible to an integer.
[more]virtual double GetDouble()
This function attempts to convert as much of the text as possible to a double.
[more]virtual void SetAlignment(int a)
Sets the alignment method the label should use to render text.
[more]virtual int GetAlignment()
returns the current alignment
[more]virtual void AlignLeft()
Shortcut for SetAlignment (0);
[more]virtual void AlignRight()
Shortcut for SetAlignment (1);
[more]virtual void AlignCentre()
Shortcut for SetAlignment (2);
[more]virtual void SetVAlignment(int value)
Sets the vertical alignment.
[more]virtual int GetVAlignment()
returns the current vertical alignment setting
[more]virtual bool GetWordWrap()
returns the current word-wrapping setting
[more]virtual void SetWordWrap(bool value)
turns word-wrapping on or off
[more]virtual int GetPreferredHeight()
Calculates and returns the height required to print the entire text with the current font and at the current width

Protected Methods

[more]void MsgInitSkin()
Sets the text background and font colours to the default skin values
[more]virtual void UpdateSize()
If the D_AUTOSIZE flag is set this function resizes the label to the length and height of the text
[more]void Draw(Bitmap &canvas)
Renders the text to the canvas.


Documentation

Label is a very simple widget for creating both static and dynamic textual labels. It can display multi-line text with automatic wordwrapping. It treats newline characters as hard line breaks.

The label can automatically resize itself to the length and height of the text and can render the text with transparent background which is perfect for static text because it minimizes the chances of redraw but if you want a label that changes dynamically (for example to display the value of a slider or the current time) this doesn't work to well because when the text changes and the label is redrawn the old text can show through. In that case you should clear the D_AUTOSIZE flag, set the text's size to the maximum length of the text you expect to display and set the text background with the SetTextMode() function.

note: the autosize option doesn't work well with non left-aligned labels.

ovoid MsgInitSkin()
Sets the text background and font colours to the default skin values

ovirtual void UpdateSize()
If the D_AUTOSIZE flag is set this function resizes the label to the length and height of the text

ovoid Draw(Bitmap &canvas)
Renders the text to the canvas. If the text mode colour is different than -1 it first fills the canvas with this colour then it renders the text. If the size of the widget is different from the size of the actual text, the text is horizontally aligned according to the alignment settings and is centered vertically.

o Label()
default constructor

o ~Label()
destructor

ovoid Setup(int x, int y, int w, int h, int key, int flags, const char* text, int a=0)
Shortcut for Widget::Setup, SetText and SetAlignment

ovirtual void SetText(const char* t)
Sets the text string the label is supposed to print out

ovirtual void SetNumber(int value)
The label can render numbers as well as normal text. Pass an integer or a double and the label will render them as text. It will even make sure that just enough decimal places are rendered for doubles.

ovirtual void SetNumber(double value)
See Setnumber (int)

ovirtual char* GetText()
Returns the label's text

ovirtual int GetInt()
This function attempts to convert as much of the text as possible to an integer. If the text doesn't represent a number, 0 is returned.

ovirtual double GetDouble()
This function attempts to convert as much of the text as possible to a double. If the text doesn't represent a number, 0 is returned.

ovirtual void SetAlignment(int a)
Sets the alignment method the label should use to render text. Valid values for a are 0 for left alignment, 1 for right alignment and 2 for centered text. Note that this has meaning only if the D_AUTOSIZE flag is turned off. By default it isn't which means the label will automatically resize itself to the length and height of the text.

ovirtual int GetAlignment()
returns the current alignment

ovirtual void AlignLeft()
Shortcut for SetAlignment (0);

ovirtual void AlignRight()
Shortcut for SetAlignment (1);

ovirtual void AlignCentre()
Shortcut for SetAlignment (2);

ovirtual void SetVAlignment(int value)
Sets the vertical alignment. Possible values are 0 for top alignment, 1 for bottom and 2 for vertical centre.

ovirtual int GetVAlignment()
returns the current vertical alignment setting

ovirtual bool GetWordWrap()
returns the current word-wrapping setting

ovirtual void SetWordWrap(bool value)
turns word-wrapping on or off

ovirtual int GetPreferredHeight()
Calculates and returns the height required to print the entire text with the current font and at the current width


Direct child classes:
FPS
EditBox
Button

Alphabetic index Hierarchy of classes


Back to front page   |   page generated with DOC++