TGUI  0.9-dev
TextStyle.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2020 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 #include <string>
31 
33 
34 namespace tgui
35 {
44  class TGUI_API TextStyle
45  {
46  public:
47 
51  enum Style
52  {
53  Regular = 0,
54  Bold = 1 << 0,
55  Italic = 1 << 1,
56  Underlined = 1 << 2,
57  StrikeThrough = 1 << 3
58  };
59 
60 
66  TGUI_CONSTEXPR TextStyle() :
67  m_isSet{false},
68  m_style{Regular}
69  {
70  }
71 
72 
82  TGUI_CONSTEXPR TextStyle(unsigned int style) :
83  m_isSet{true},
84  m_style{style}
85  {
86  }
87 
88 
94  TextStyle(const String& string);
95 
96 
106  TextStyle(const char* string);
107 
108 
114  TGUI_CONSTEXPR bool isSet() const
115  {
116  return m_isSet;
117  }
118 
119 
125  TGUI_CONSTEXPR operator unsigned int() const
126  {
127  return m_style;
128  }
129 
130 
132  private:
133 
134  bool m_isSet;
135  unsigned int m_style;
136  };
137 
139 }
140 
142 
143 #endif // TGUI_TEXT_STYLE_HPP
TGUI_CONSTEXPR TextStyle(unsigned int style)
Creates the object from one or more tgui::TextStyle::Style enum members.
Definition: TextStyle.hpp:82
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:35
TGUI_CONSTEXPR TextStyle()
Creates the object without a text style.
Definition: TextStyle.hpp:66
Style
Enumeration of the string drawing styles.
Definition: TextStyle.hpp:51
TGUI_CONSTEXPR bool isSet() const
Checks if a style was set.
Definition: TextStyle.hpp:114
Wrapper for text styles.
Definition: TextStyle.hpp:44