TGUI  0.8-dev
tgui::TextStyle Class Reference

Wrapper for text styles. More...

#include <TextStyle.hpp>

Public Member Functions

 TextStyle ()
 Creates the object without a text style. More...
 
 TextStyle (sf::Uint32 style)
 Creates the object from one or more sf::Text::Style enum members. More...
 
 TextStyle (const std::string &string)
 Creates the object from a string representing the text styles. More...
 
 TextStyle (const char *string)
 Creates the object from a string representing the text styles. More...
 
bool isSet () const
 Checks if a style was set. More...
 
 operator sf::Uint32 () const
 Converts this object into an sf::Uint32 object. More...
 

Detailed Description

Wrapper for text styles.

The class is used for 2 purposes:

  • Implicit converter for parameters. A function taking a TextStyle as parameter can be given either an sf::Text::Style or a string representation as argument.
  • Storing no style at all. Some style settings may be optionally set and can thus remain unspecified.

Constructor & Destructor Documentation

◆ TextStyle() [1/4]

tgui::TextStyle::TextStyle ( )

Creates the object without a text style.

The isSet function will return false when the object was created using this constructor.

◆ TextStyle() [2/4]

tgui::TextStyle::TextStyle ( sf::Uint32  style)

Creates the object from one or more sf::Text::Style enum members.

Parameters
styleText style to set
TextStyle style{sf::Text::Italic | sf::Text::Bold};

◆ TextStyle() [3/4]

tgui::TextStyle::TextStyle ( const std::string &  string)

Creates the object from a string representing the text styles.

Parameters
stringString to be deserialized as text styles

◆ TextStyle() [4/4]

tgui::TextStyle::TextStyle ( const char *  string)

Creates the object from a string representing the text styles.

Parameters
stringString to be deserialized as text styles
TextStyle style{"Italic | Bold"};

Member Function Documentation

◆ isSet()

bool tgui::TextStyle::isSet ( ) const

Checks if a style was set.

Returns
True if a text style was passed to the constructor, false when the default constructor was used

◆ operator sf::Uint32()

tgui::TextStyle::operator sf::Uint32 ( ) const

Converts this object into an sf::Uint32 object.

Returns
The text styles stored in this object, or sf::Text::Regular if no style was set

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