TGUI  1.6.1
Loading...
Searching...
No Matches
TextStyle.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2024 Bruno Van de Velde (vdv_b@tgui.eu)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef TGUI_TEXT_STYLE_HPP
26#define TGUI_TEXT_STYLE_HPP
27
28#include <TGUI/String.hpp>
29
31
32TGUI_MODULE_EXPORT namespace tgui
33{
37 enum TextStyle : unsigned int
38 {
39 Regular = 0,
40 Bold = 1 << 0,
41 Italic = 1 << 1,
42 Underlined = 1 << 2,
43 StrikeThrough = 1 << 3
44 };
45
54 class TGUI_API TextStyles
55 {
56 public:
57
63 constexpr TextStyles() :
64 m_isSet{false},
65 m_style{Regular}
66 {
67 }
68
78 constexpr TextStyles(unsigned int style) :
79 m_isSet{true},
80 m_style{style}
81 {
82 }
83
89 TextStyles(const String& string);
90
100 TextStyles(const char* string);
101
107 TGUI_NODISCARD constexpr bool isSet() const
108 {
109 return m_isSet;
110 }
111
117 constexpr operator unsigned int() const
118 {
119 return m_style;
120 }
121
123 private:
124
125 bool m_isSet; // Stores the flag indicating whether this object has been explicitly initialized or created from default.
126
127 unsigned int m_style; // Stores the text styles represented by this object.
128 };
129
131}
132
134
135#endif // TGUI_TEXT_STYLE_HPP
Wrapper class to store strings.
Definition String.hpp:96
Wrapper for text styles.
Definition TextStyle.hpp:55
constexpr bool isSet() const
Checks if a style was set.
Definition TextStyle.hpp:107
TextStyles(const char *string)
Creates the object from a string representing the text styles.
constexpr TextStyles(unsigned int style)
Creates the object from one or more tgui::TextStyle::Style enum members.
Definition TextStyle.hpp:78
TextStyles(const String &string)
Creates the object from a string representing the text styles.
constexpr TextStyles()
Creates the object without a text style.
Definition TextStyle.hpp:63
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
TextStyle
Enumeration of the text drawing styles.
Definition TextStyle.hpp:38
@ Underlined
Underlined characters.
Definition TextStyle.hpp:42
@ Bold
Bold characters.
Definition TextStyle.hpp:40
@ Italic
Italic characters.
Definition TextStyle.hpp:41
@ Regular
Regular characters, no style.
Definition TextStyle.hpp:39
@ StrikeThrough
Strike through characters.
Definition TextStyle.hpp:43