TGUI  0.7.8
ObjectConverter.hpp
1
2//
3// TGUI - Texus's Graphical User Interface
4// Copyright (C) 2012-2017 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_OBJECT_CONVERTER_HPP
27#define TGUI_OBJECT_CONVERTER_HPP
28
29
30#include <TGUI/Color.hpp>
31#include <TGUI/Borders.hpp>
32#include <TGUI/Texture.hpp>
33
35
36namespace tgui
37{
42 class TGUI_API ObjectConverter
43 {
44 public:
45 enum class Type
46 {
47 None,
48 Font,
49 Color,
50 String,
51 Number,
52 Borders,
54 };
55
56
62
63
70 ObjectConverter(const std::shared_ptr<sf::Font>& font);
71
72
79 ObjectConverter(const sf::Color& color);
80
81
88 ObjectConverter(const sf::String& string);
89
90
97 ObjectConverter(float number);
98
99
106 ObjectConverter(const Borders& borders);
107
108
115 ObjectConverter(const Texture& texture);
116
117
126 const std::shared_ptr<sf::Font>& getFont() const;
127
128
137 const sf::Color& getColor() const;
138
139
148 const Borders& getBorders() const;
149
150
159 const sf::String& getString() const;
160
161
170 float getNumber() const;
171
172
181 const Texture& getTexture() const;
182
183
190 Type getType() const;
191
192
194 private:
195 Type m_type = Type::None;
196
197 std::shared_ptr<sf::Font> m_font;
198 sf::Color m_color;
199 sf::String m_string;
200 float m_number = 0;
201 Borders m_borders;
202 Texture m_texture;
203 };
204
206}
207
209
210#endif // TGUI_OBJECT_CONVERTER_HPP
Definition: Borders.hpp:38
Implicit converter for colors.
Definition: Color.hpp:40
Definition: Font.hpp:38
Implicit converter for settable properties.
Definition: ObjectConverter.hpp:43
const sf::String & getString() const
Retrieve the saved string.
ObjectConverter(const Borders &borders)
Store a borders object for later retrieval.
ObjectConverter(float number)
Store a number for later retrieval.
const Texture & getTexture() const
Retrieve the saved texture.
ObjectConverter(const std::shared_ptr< sf::Font > &font)
Store a font object for later retrieval.
ObjectConverter(const sf::String &string)
Store a string for later retrieval.
const sf::Color & getColor() const
Retrieve the saved color.
ObjectConverter(const Texture &texture)
Store a texture object for later retrieval.
const Borders & getBorders() const
Retrieve the saved borders.
ObjectConverter()
Default constructor, to create an empty object.
Type getType() const
Retrieve the type of the object that has been stored.
ObjectConverter(const sf::Color &color)
Store a color object for later retrieval.
const std::shared_ptr< sf::Font > & getFont() const
Retrieve the saved font.
float getNumber() const
Retrieve the saved number.
Definition: Texture.hpp:45
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:34