TGUI  v0.6.10
Public Types | Public Member Functions | List of all members
tgui::Label Class Reference
Inheritance diagram for tgui::Label:
tgui::ClickableWidget tgui::Widget tgui::Transformable tgui::CallbackManager

Public Types

- Public Types inherited from tgui::ClickableWidget
- Public Types inherited from tgui::Widget

Public Member Functions

 Label ()
 Default constructor. More...
 
virtual ~Label ()
 Destructor. More...
 
bool load (const std::string &configFileFilename, const std::string &sectionName="Label")
 Loads the widget. More...
 
const std::string & getLoadedConfigFile () const
 Returns the filename of the config file that was used to load the widget. More...
 
virtual void setSize (float width, float height)
 Changes the area of the text that will be drawn. More...
 
virtual void setPosition (float x, float y)
 Set the position of the widget. More...
 
void setText (const sf::String &text)
 Changes the text. More...
 
const sf::String & getText () const
 Returns the text. More...
 
void setTextFont (const sf::Font &font)
 Changes the font of the text. More...
 
const sf::Font * getTextFont () const
 Returns the font of the text. More...
 
void setTextColor (const sf::Color &color)
 Changes the color of the text. More...
 
const sf::Color & getTextColor () const
 Returns the color of the text. More...
 
void setTextStyle (sf::Uint32 style)
 Changes the style of the text. More...
 
sf::Uint32 getTextStyle () const
 Returns the style of the text. More...
 
void setTextSize (unsigned int size)
 Changes the character size of the text. More...
 
unsigned int getTextSize () const
 Returns the character size of the text. More...
 
void setBackgroundColor (const sf::Color &backgroundColor)
 Changes the background color of the label. More...
 
const sf::Color & getBackgroundColor () const
 Returns the background color of the label. More...
 
virtual void setAutoSize (bool autoSize)
 Changes whether the label is auto-sized or not. More...
 
virtual bool getAutoSize () const
 Returns whether the label is auto-sized or not. More...
 
- Public Member Functions inherited from tgui::ClickableWidget
 ClickableWidget ()
 Default constructor. More...
 
 ClickableWidget (const ClickableWidget &copy)
 Copy constructor. More...
 
virtual ~ClickableWidget ()
 Destructor. More...
 
ClickableWidgetoperator= (const ClickableWidget &right)
 Overload of assignment operator. More...
 
virtual sf::Vector2f getSize () const
 Returns the size of the widget. More...
 
- Public Member Functions inherited from tgui::Widget
 Widget ()
 Default constructor. More...
 
 Widget (const Widget &copy)
 Copy constructor. More...
 
virtual ~Widget ()
 Destructor. More...
 
Widgetoperator= (const Widget &right)
 Overload of assignment operator. More...
 
virtual sf::Vector2f getAbsolutePosition () const
 Get the absolute position of the widget on the screen. More...
 
virtual void show ()
 Shows the widget. More...
 
virtual void hide ()
 Hides the widget. More...
 
bool isVisible () const
 Returns true when the widget is visible. More...
 
virtual void enable ()
 Enables the widget. More...
 
virtual void disable ()
 Disables the widget. More...
 
bool isEnabled () const
 Returns true when the widget is enabled. More...
 
bool isDisabled () const
 Returns true when the widget is disabled. More...
 
bool isLoaded () const
 Returns true when the widget is loaded successfully. More...
 
virtual void focus ()
 Focus the widget. More...
 
virtual void unfocus ()
 Unfocus the widget. More...
 
bool isFocused () const
 Returns true when the widget is focused and false otherwise. More...
 
WidgetTypes getWidgetType () const
 Returns the type of the widget. More...
 
ContainergetParent () const
 Returns a pointer to the parent widget. More...
 
virtual void setTransparency (unsigned char transparency)
 Changes the transparency of the widget. More...
 
unsigned char getTransparency () const
 Returns the transparency of the widget. More...
 
virtual void moveToFront ()
 Places the widget before all other widgets. More...
 
virtual void moveToBack ()
 Places the widget behind all other widgets. More...
 
void setCallbackId (unsigned int callbackId)
 Changes the callback id of the widget. More...
 
unsigned int getCallbackId ()
 Returns the callback id of the widget. More...
 
- Public Member Functions inherited from tgui::Transformable
 Transformable ()
 Default constructor. More...
 
virtual ~Transformable ()
 Destructor. More...
 
void setPosition (const sf::Vector2f &position)
 set the position of the widget More...
 
const sf::Vector2f & getPosition () const
 get the position of the widget More...
 
void move (float offsetX, float offsetY)
 Move the widget by a given offset. More...
 
void move (const sf::Vector2f &offset)
 Move the widget by a given offset. More...
 
virtual sf::Vector2f getFullSize () const
 Returns the entire size that the widget is using. More...
 
void scale (float factorX, float factorY)
 Scale the widget. More...
 
void scale (const sf::Vector2f &factors)
 Scale the widget. More...
 
- Public Member Functions inherited from tgui::CallbackManager
void bindCallback (std::function< void()> func, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
template<typename T >
void bindCallback (void(T::*func)(), T *const classPtr, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
void bindCallbackEx (std::function< void(const Callback &)> func, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
template<typename T >
void bindCallbackEx (void(T::*func)(const Callback &), T *const classPtr, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
void bindCallback (unsigned int trigger)
 Bind one or more specific callback trigger(s) to the parent widget. More...
 
void unbindCallback (unsigned int trigger)
 Unbind all callback function bound to the given trigger. More...
 
void unbindAllCallback ()
 Unbind all callback functions bound to any callback. More...
 

Member Enumeration Documentation

Defines specific triggers to Label.

Enumerator
AllLabelCallbacks 

All triggers defined in Label and its base classes.

Constructor & Destructor Documentation

tgui::Label::Label ( )

Default constructor.

virtual tgui::Label::~Label ( )
virtual

Destructor.

Member Function Documentation

virtual bool tgui::Label::getAutoSize ( ) const
virtual

Returns whether the label is auto-sized or not.

Returns
Is the size of the label changed when the text changes?
const sf::Color& tgui::Label::getBackgroundColor ( ) const

Returns the background color of the label.

The background color is transparent by default.

Returns
The current background color
const std::string& tgui::Label::getLoadedConfigFile ( ) const

Returns the filename of the config file that was used to load the widget.

Returns
Filename of loaded config file. Empty string when no config file was loaded yet.
const sf::String& tgui::Label::getText ( ) const

Returns the text.

Returns
Text that is currently used
const sf::Color& tgui::Label::getTextColor ( ) const

Returns the color of the text.

Returns
The current text color
const sf::Font* tgui::Label::getTextFont ( ) const

Returns the font of the text.

Returns
Pointer to the font that is currently being used.
unsigned int tgui::Label::getTextSize ( ) const

Returns the character size of the text.

Returns
The current text size.
sf::Uint32 tgui::Label::getTextStyle ( ) const

Returns the style of the text.

Returns
The current text style
bool tgui::Label::load ( const std::string &  configFileFilename,
const std::string &  sectionName = "Label" 
)

Loads the widget.

Parameters
configFileFilenameFilename of the config file.
sectionNameName of the section in the file to load

The config file must contain a Label section with the needed information.

virtual void tgui::Label::setAutoSize ( bool  autoSize)
virtual

Changes whether the label is auto-sized or not.

Parameters
autoSizeShould the size of the label be changed when the text changes?

When the label is in auto-size mode, the width and height of the label will be changed to fit the text. Otherwise, only the part defined by the size will be visible.

The label is auto-sized by default.

void tgui::Label::setBackgroundColor ( const sf::Color &  backgroundColor)

Changes the background color of the label.

Parameters
backgroundColorNew background color

The background color is transparent by default.

When auto-size is enabled (default), then the background is just as big as the text. When a manual size is set, the background will fill this whole area.

virtual void tgui::Label::setPosition ( float  x,
float  y 
)
virtual

Set the position of the widget.

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable widget is (0, 0).

Parameters
xX coordinate of the new position
yY coordinate of the new position
See also
move, getPosition

Reimplemented from tgui::Transformable.

virtual void tgui::Label::setSize ( float  width,
float  height 
)
virtual

Changes the area of the text that will be drawn.

Parameters
widthWidth of the part to draw
heightHeight of the part to draw

Only the part of the text that lies within the size will be drawn.

When a background color is set, the drawn background will have this size. So setting a size that is bigger than the text will result in a bigger area being filled.

When this function is called, the label will no longer be auto-sizing.

See also
setAutoSize

Reimplemented from tgui::ClickableWidget.

void tgui::Label::setText ( const sf::String &  text)

Changes the text.

Parameters
textThe new text

When the text is auto-sized (default), then the size of the label will be changed to fit the whole text.

See also
setAutoSize
void tgui::Label::setTextColor ( const sf::Color &  color)

Changes the color of the text.

Parameters
colorNew text color
void tgui::Label::setTextFont ( const sf::Font &  font)

Changes the font of the text.

When you don't call this function then the global font will be use. This global font can be changed with the setGlobalFont function from the parent.

Parameters
fontThe new font.
void tgui::Label::setTextSize ( unsigned int  size)

Changes the character size of the text.

Parameters
sizeThe new text size
void tgui::Label::setTextStyle ( sf::Uint32  style)

Changes the style of the text.

The possible styles can be found in the sf::Text::Style enum. You can pass a combination of one or more styles, for example sf::Text::Bold | sf::Text::Italic. The default style is sf::Text::Regular.

Parameters
styleNew text style

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