11#include "../l10n/l10n.hpp"
12#include "../observer/module.hpp"
13#include "../macros.hpp"
19namespace hi {
inline namespace v1 {
20class text_field_widget;
29 using callback_token = notifier_type::callback_token;
30 using callback_proto = notifier_type::callback_proto;
74 return _notifier.subscribe(hi_forward(callback), flags);
78 notifier_type _notifier;
96template<std::
integral T>
105 _value_cbt = this->value.subscribe([&](
auto...) {
115 return {
txt(
"Invalid integer")};
123 return to_gstring(to_string(*value));
137 typename decltype(value)::callback_token _value_cbt;
147template<std::
floating_po
int T>
148class default_text_field_delegate<T> :
public text_field_delegate {
150 using value_type = T;
156 _value_cbt = this->value.subscribe([&](
auto...) {
166 return {elusive_icon::WarningSign,
txt(
"Invalid floating point number")};
174 return to_gstring(to_string(*value));
188 typename decltype(value)::callback_token _value_cbt;
203 using value_type = observer_decay_t<
decltype(value)>;
204 return std::make_shared<default_text_field_delegate<value_type>>(hi_forward(value));
std::shared_ptr< text_field_delegate > make_default_text_field_delegate(auto &&value) noexcept
Create a shared pointer to a default text delegate.
Definition text_field_delegate.hpp:198
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
A localizable message.
Definition txt.hpp:100
Exception thrown during parsing on an error.
Definition exception_intf.hpp:47
A delegate that controls the state of a text_field_widget.
Definition text_field_delegate.hpp:26
virtual gstring text(text_field_widget &sender) noexcept
Get the text to show in the text field.
Definition text_field_delegate.hpp:54
virtual label validate(text_field_widget &sender, gstring const &text) noexcept
Validate the text field.
Definition text_field_delegate.hpp:42
virtual void set_text(text_field_widget &sender, gstring const &text) noexcept
Set the text as entered by the user.
Definition text_field_delegate.hpp:69
A default text delegate.
Definition text_field_delegate.hpp:87
label validate(text_field_widget &sender, gstring const &text) noexcept override
Validate the text field.
Definition text_field_delegate.hpp:161
gstring text(text_field_widget &sender) noexcept override
Get the text to show in the text field.
Definition text_field_delegate.hpp:121
std::optional< label > validate(text_field_widget &sender, gstring const &text) noexcept override
Validate the text field.
Definition text_field_delegate.hpp:110
void set_text(text_field_widget &sender, gstring const &text) noexcept override
Set the text as entered by the user.
Definition text_field_delegate.hpp:177
A single line text field.
Definition text_field_widget.hpp:63
True if T is a forwarded type of Forward.
Definition concepts.hpp:131