25#ifndef TGUI_GLOBAL_HPP
26#define TGUI_GLOBAL_HPP
30#include <TGUI/Config.hpp>
31#include <TGUI/Exception.hpp>
32#include <TGUI/Duration.hpp>
33#include <TGUI/Font.hpp>
34#include <TGUI/String.hpp>
35#include <TGUI/Filesystem.hpp>
53#if defined(__cpp_lib_smart_ptr_for_overwrite) && (__cpp_lib_smart_ptr_for_overwrite >= 202002L)
60 return std::unique_ptr<T>(
new typename std::remove_extent_t<T>[size]);
68 TGUI_NODISCARD
constexpr const T&
clamp(
const T& v,
const T& lo,
const T& hi)
70 return (v < lo) ? lo : (hi < v) ? hi : v;
150 TGUI_API
bool writeFile(
const String& filename,
const std::stringstream& textToWrite);
165 template <
typename To,
typename From>
168 TGUI_ASSERT(
dynamic_cast<std::remove_reference_t<To>*
>(&base),
"Downcasting to wrong type");
169 return static_cast<To
>(base);
175 template <
typename To,
typename From>
178 TGUI_ASSERT(
dynamic_cast<To
>(base),
"Downcasting to wrong type");
179 return static_cast<To
>(base);
185 template <
typename To,
typename From>
186 std::shared_ptr<To>
downcast(std::shared_ptr<From> base)
188 TGUI_ASSERT(std::dynamic_pointer_cast<To>(base),
"Downcasting to wrong type");
189 return std::static_pointer_cast<To>(base);
Wrapper for durations.
Definition Duration.hpp:53
Object to represent paths on a filesystem.
Definition Filesystem.hpp:56
Wrapper class to store strings.
Definition String.hpp:94
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36
TGUI_API void setDoubleClickTime(Duration duration)
Sets the double-click time for the mouse.
TGUI_API const Filesystem::Path & getResourcePath()
Returns the resource path.
TGUI_API void setGlobalTextSize(unsigned int textSize)
Sets the default text size for all widgets created after calling the function.
TGUI_API void setEditCursorBlinkRate(Duration blinkRate)
Changes the blink rate of the cursor in edit fields such as EditBox and TextArea.
TGUI_API void setResourcePath(const Filesystem::Path &path)
Sets a new resource path.
constexpr const T & clamp(const T &v, const T &lo, const T &hi)
Clamps a value between two boundries. This function exists because std::clamp was only added with c++...
Definition Global.hpp:68
TGUI_API Duration getDoubleClickTime()
Retrieves the double-click time for the mouse.
TGUI_API std::unique_ptr< std::uint8_t[]> readFileToMemory(const String &filename, std::size_t &fileSize)
Opens a file and reads its contents into memory.
TGUI_API Duration getEditCursorBlinkRate()
Returns the blink rate of the cursor in edit fields such as EditBox and TextArea.
std::unique_ptr< T > MakeUniqueForOverwrite(const std::size_t size)
Create a unique_ptr containing an uninitialized array.
Definition Global.hpp:58
TGUI_API bool writeFile(const String &filename, const std::stringstream &textToWrite)
Opens a file and writes the given contents to it.
To downcast(From &base)
Cast from a reference of a base class to a reference of a derived class.
Definition Global.hpp:166
TGUI_API unsigned int getGlobalTextSize()
Retrieves the default text size used for all new widgets.