26#include <SDL3_ttf/SDL_ttf.h>
30typedef SSIZE_T ssize_t;
33#if !defined(HAS_NOEXCEPT)
35#if __has_feature(cxx_noexcept)
38#elif defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46 || \
39 defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026
51 SdlWidget(std::shared_ptr<SDL_Renderer>& renderer,
const SDL_FRect& rect);
52#if defined(WITH_SDL_IMAGE_DIALOGS)
53 SdlWidget(std::shared_ptr<SDL_Renderer>& renderer,
const SDL_FRect& rect, SDL_IOStream* ops);
62 bool fill(SDL_Color color)
const;
63 bool fill(
const std::vector<SDL_Color>& colors)
const;
64 bool update_text(
const std::string& text);
66 [[nodiscard]]
bool wrap()
const;
67 bool set_wrap(
bool wrap =
true,
size_t width = 0);
68 [[nodiscard]]
const SDL_FRect& rect()
const;
72#define widget_log_error(res, what) SdlWidget::error_ex(res, what, __FILE__, __LINE__, __func__)
73 static bool error_ex(
bool success,
const char* what,
const char* file,
size_t line,
77 std::shared_ptr<SDL_Renderer> _renderer{};
78 SDL_Color _backgroundcolor = { 0x56, 0x56, 0x56, 0xff };
79 SDL_Color _fontcolor = { 0xd1, 0xcf, 0xcd, 0xff };
80 mutable std::string _text;
82 virtual bool clear()
const;
83 virtual bool updateInternal();
86 bool draw_rect(
const SDL_FRect& rect, SDL_Color color)
const;
87 std::shared_ptr<SDL_Texture> render_text(
const std::string& text, SDL_Color fgcolor,
88 SDL_FRect& src, SDL_FRect& dst)
const;
89 std::shared_ptr<SDL_Texture> render_text_wrapped(
const std::string& text, SDL_Color fgcolor,
90 SDL_FRect& src, SDL_FRect& dst)
const;
92 std::shared_ptr<TTF_Font> _font =
nullptr;
93 std::shared_ptr<SDL_Texture> _image =
nullptr;
94 std::shared_ptr<TTF_TextEngine> _engine =
nullptr;
97 size_t _text_width = 0;