14#include <egt/button.h>
15#include <egt/detail/meta.h>
46 explicit CheckBox(
const std::string& text = {},
47 const Rect& rect = {})
noexcept;
55 const std::string& text = {},
56 const Rect& rect = {})
noexcept;
126 using CheckBox::min_size_hint;
137 const std::string& on_text)
139 bool off = detail::change_if_diff<>(m_off_text, off_text);
140 bool on = detail::change_if_diff<>(m_on_text, on_text);
149 EGT_NODISCARD
const std::string&
off_text()
const {
return m_off_text; }
154 EGT_NODISCARD
const std::string&
on_text()
const {
return m_on_text; }
171 if (detail::change_if_diff<>(m_enable_disable, value))
184 using TextWidget::text;
199 bool m_enable_disable{
true};
Alignment flags.
Definition widgetflags.h:379
Boolean checkbox.
Definition checkbox.h:39
void draw(Painter &painter, const Rect &rect) override
Draw the widget.
void draw_switch(Painter &painter, const Rect &handle) const override
EGT_NODISCARD AlignFlags checkbox_align() const
Get the image alignment.
Definition checkbox.h:75
CheckBox(const std::string &text={}, const Rect &rect={}) noexcept
void checkbox_align(const AlignFlags &align)
Set the alignment of the checkbox relative to the text.
Definition checkbox.h:67
CheckBox(Frame &parent, const std::string &text={}, const Rect &rect={}) noexcept
A Frame is a Widget that has children widgets.
Definition frame.h:45
Drawing interface for 2D graphics.
Definition painter.h:45
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
CheckBox with a boolean slider style interface.
Definition checkbox.h:91
std::string m_off_text
Optional "off" text.
Definition checkbox.h:189
EGT_NODISCARD Size min_size_hint() const override
Get a minimum size hint for the Widget.
ToggleBox(const Rect &rect={}) noexcept
void draw(Painter &painter, const Rect &rect) override
Draw the widget.
static void default_draw(ToggleBox &widget, Painter &painter, const Rect &rect)
Default draw method for the CheckBox.
std::string m_on_text
Optional "on" text.
Definition checkbox.h:194
void enable_disable(bool value)
Set the enable/disable mode.
Definition checkbox.h:169
EGT_NODISCARD bool enable_disable() const
Get the enable/disable mode.
Definition checkbox.h:159
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
EGT_NODISCARD const std::string & on_text() const
Get the "on" text.
Definition checkbox.h:154
void toggle_text(const std::string &off_text, const std::string &on_text)
Set the optional "on" and "off" text.
Definition checkbox.h:136
ToggleBox(Frame &parent, const Rect &rect={}) noexcept
ToggleBox(Serializer::Properties &props) noexcept
Definition checkbox.h:108
ToggleBox(Serializer::Properties &props, bool is_derived) noexcept
EGT_NODISCARD const std::string & off_text() const
Get the "off" text.
Definition checkbox.h:149
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