TGUI  1.3-dev
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
26#ifndef TGUI_TEXT_STYLE_HPP
27#define TGUI_TEXT_STYLE_HPP
28
29#include <TGUI/String.hpp>
30
32
33TGUI_MODULE_EXPORT namespace tgui
34{
38 enum TextStyle : unsigned int
39 {
40 Regular = 0,
41 Bold = 1 << 0,
42 Italic = 1 << 1,
43 Underlined = 1 << 2,
44 StrikeThrough = 1 << 3
45 };
46
47
56 class TGUI_API TextStyles
57 {
58 public:
59
65 constexpr TextStyles() :
66 m_isSet{false},
67 m_style{Regular}
68 {
69 }
70
71
81 constexpr TextStyles(unsigned int style) :
82 m_isSet{true},
83 m_style{style}
84 {
85 }
86
87
93 TextStyles(const String& string);
94
95
105 TextStyles(const char* string);
106
107
113 TGUI_NODISCARD constexpr bool isSet() const
114 {
115 return m_isSet;
116 }
117
118
124 constexpr operator unsigned int() const
125 {
126 return m_style;
127 }
128
129
131 private:
132
133 bool m_isSet; // Stores the flag indicating whether this object has been explicitly initialized or created from default.
134
135 unsigned int m_style; // Stores the text styles represented by this object.
136 };
137
139}
140
142
143#endif // TGUI_TEXT_STYLE_HPP
Wrapper class to store strings.
Definition String.hpp:101
Wrapper for text styles.
Definition TextStyle.hpp:57
TGUI_NODISCARD constexpr bool isSet() const
Checks if a style was set.
Definition TextStyle.hpp:113
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:81
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:65
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39
TextStyle
Enumeration of the text drawing styles.
Definition TextStyle.hpp:39
@ Underlined
Underlined characters.
Definition TextStyle.hpp:43
@ Bold
Bold characters.
Definition TextStyle.hpp:41
@ Italic
Italic characters.
Definition TextStyle.hpp:42
@ Regular
Regular characters, no style.
Definition TextStyle.hpp:40
@ StrikeThrough
Strike through characters.
Definition TextStyle.hpp:44