6#ifndef EGT_TEXTWIDGET_H
7#define EGT_TEXTWIDGET_H
14#include <egt/detail/meta.h>
16#include <egt/signal.h>
17#include <egt/widget.h>
52 const Rect& rect = {},
53 const AlignFlags& text_align = AlignFlag::center)
noexcept;
74 virtual void text(
const std::string& str);
84 EGT_NODISCARD
virtual const std::string&
text()
const {
return m_text; }
93 if (detail::change_if_diff<>(m_text_align,
align))
105 EGT_NODISCARD
virtual size_t len()
const;
Alignment flags.
Definition widgetflags.h:379
Manages a font and properties of a font.
Definition font.h:35
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
Signal class used for defining a signal and dispatching events.
Definition signal.h:30
A widget with text and text related properties.
Definition textwidget.h:33
void text_align(const AlignFlags &align)
Set the text alignment within the Label.
Definition textwidget.h:91
EGT_NODISCARD AlignFlags text_align() const
Get the text alignment within the Label.
Definition textwidget.h:100
virtual EGT_NODISCARD const std::string & text() const
Get the text of the Label.
Definition textwidget.h:84
virtual EGT_NODISCARD size_t len() const
Get the length of the text.
static Font scale_font(const Size &target, const std::string &text, const Font &font)
Given a Font, text, and a target Size, scale the font size so that the text will will fit and return ...
EGT_NODISCARD Size text_size(const std::string &text) const
Get the size of the text.
TextWidget(std::string text={}, const Rect &rect={}, const AlignFlags &text_align=AlignFlag::center) noexcept
Signal on_text_changed
Event signal.
Definition textwidget.h:43
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
std::string m_text
The text.
Definition textwidget.h:124
TextWidget(Serializer::Properties &props) noexcept
Definition textwidget.h:58
virtual void clear()
Clear the text value.
TextWidget(Serializer::Properties &props, bool is_derived) noexcept
virtual void text(const std::string &str)
Set the text.
T & align(T &widget, const AlignFlags &a)
Helper to set alignment of a widget.
Definition widgetflags.h:624
EGT framework namespace.
Definition animation.h:24