TGUI  0.8-dev
Global.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2018 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_GLOBAL_HPP
26 #define TGUI_GLOBAL_HPP
27 
29 
30 #include <TGUI/Config.hpp>
31 #include <TGUI/Exception.hpp>
32 #include <TGUI/Font.hpp>
33 #include <cstdint>
34 #include <string>
35 #include <memory>
36 
37 #ifdef TGUI_DEBUG
38  #include <iostream>
39 #endif
40 
42 
44 namespace tgui
45 {
46 #ifdef TGUI_NO_CPP14
47  template<typename T, typename... Args>
48  std::unique_ptr<T> make_unique(Args&&... args)
49  {
50  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
51  }
52 #else
53  using std::make_unique;
54 #endif
55 
56 
60  TGUI_API void setGlobalTextSize(unsigned int textSize);
61 
62 
66  TGUI_API unsigned int getGlobalTextSize();
67 
68 
72  TGUI_API void setGlobalFont(Font font);
73 
74 
80  TGUI_API const Font& getGlobalFont();
81 
82 
87  TGUI_API const Font& getInternalGlobalFont();
88 
89 
93  TGUI_API void setDoubleClickTime(unsigned int milliseconds);
94 
95 
99  TGUI_API unsigned int getDoubleClickTime();
100 
101 
110  TGUI_API void setResourcePath(const std::string& path);
111 
112 
121  TGUI_API const std::string& getResourcePath();
122 
123 
126  // Checks if two floats are equal, with regard to a small epsilon margin.
128  TGUI_API bool compareFloats(float x, float y);
129 
130 
133  // Checks if a character is a whitespace character.
135  TGUI_API bool isWhitespace(std::uint32_t character);
136 
137 
140  // Converts a string to an integer. Acts like std::stoi which isn't supported in MinGW TDM.
142  TGUI_API int stoi(const std::string& value);
143 
144 
147  // Converts a string to a float. Acts like std::stof which isn't supported in MinGW TDM.
149  TGUI_API float stof(const std::string& value);
150 
151 
154  // Extracts a bool from a string value.
156  TGUI_API bool extractBoolFromString(const std::string& property, const std::string& value);
157 
158 
161  // Moves the iterator forward until no more whitespace is found
163  TGUI_API bool removeWhitespace(const std::string& line, std::string::const_iterator& c);
164 
165 
168  // Converts a string to lowercase.
170  TGUI_API std::string toLower(std::string str);
171 
172 
175  // Trims the whitespace from a string.
177  TGUI_API std::string trim(std::string str);
178 
179 
181 }
182 
184 
185 #endif // TGUI_GLOBAL_HPP
186 
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
TGUI_API unsigned int getGlobalTextSize()
Retrieves the default text size used for all new widgets.
TGUI_API unsigned int getDoubleClickTime()
Retrieves the double-click time for the mouse.
TGUI_API void setGlobalTextSize(unsigned int textSize)
Sets the default text size for all widgets created after calling the function.
TGUI_API void setGlobalFont(Font font)
Sets the default font used by widgets.
TGUI_API const Font & getGlobalFont()
Retrieves the default font used for all new widgets.
TGUI_API void setDoubleClickTime(unsigned int milliseconds)
Sets the double-click time for the mouse.
TGUI_API const std::string & getResourcePath()
Returns the resource path.
TGUI_API void setResourcePath(const std::string &path)
Sets a new resource path.