TGUI  0.9-dev
tgui::TextStyle Class Reference

Wrapper for text styles. More...

#include <TGUI/TextStyle.hpp>

Public Types

enum  Style {
  Regular = 0, Bold = 1 << 0, Italic = 1 << 1, Underlined = 1 << 2,
  StrikeThrough = 1 << 3
}
 Enumeration of the string drawing styles. More...
 

Public Member Functions

TGUI_CONSTEXPR TextStyle ()
 Creates the object without a text style. More...
 
TGUI_CONSTEXPR TextStyle (unsigned int style)
 Creates the object from one or more tgui::TextStyle::Style enum members. More...
 
 TextStyle (const 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...
 
TGUI_CONSTEXPR bool isSet () const
 Checks if a style was set. More...
 
TGUI_CONSTEXPR operator unsigned int () const
 Converts this object into an unsigned int. 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 a tgui::TextStyle::Style (or multiple combined with | operator) or a string representation as argument.
  • Storing no style at all. Some style settings may be optionally set and can thus remain unspecified.

Member Enumeration Documentation

◆ Style

Enumeration of the string drawing styles.

Enumerator
Regular 

Regular characters, no style.

Bold 

Bold characters.

Italic 

Italic characters.

Underlined 

Underlined characters.

StrikeThrough 

Strike through characters.

Constructor & Destructor Documentation

◆ TextStyle() [1/4]

TGUI_CONSTEXPR tgui::TextStyle::TextStyle ( )
inline

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_CONSTEXPR tgui::TextStyle::TextStyle ( unsigned int  style)
inline

Creates the object from one or more tgui::TextStyle::Style enum members.

Parameters
styleText style to set

◆ TextStyle() [3/4]

tgui::TextStyle::TextStyle ( const 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()

TGUI_CONSTEXPR bool tgui::TextStyle::isSet ( ) const
inline

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 unsigned int()

TGUI_CONSTEXPR tgui::TextStyle::operator unsigned int ( ) const
inline

Converts this object into an unsigned int.

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

The documentation for this class was generated from the following file:
TGUI_CONSTEXPR TextStyle()
Creates the object without a text style.
Definition: TextStyle.hpp:66
@ Italic
Italic characters.
Definition: TextStyle.hpp:55
@ Bold
Bold characters.
Definition: TextStyle.hpp:54