11#include "../observer/observer.hpp"
12#include "../utility/utility.hpp"
13#include "../concurrency/concurrency.hpp"
14#include "../dispatch/dispatch.hpp"
15#include "../GUI/GUI.hpp"
16#include "../macros.hpp"
17#include "../l10n/l10n.hpp"
18#include "../macros.hpp"
24hi_export_module(hikogui.widgets.text_field_delegate);
26hi_export
namespace hi {
inline namespace v1 {
34 using notifier_type = notifier<
void()>;
75 template<forward_of<
void()> Func>
76 callback<
void()> subscribe(
Func&&
func, callback_flags flags = callback_flags::synchronous)
noexcept
78 return _notifier.subscribe(std::forward<Func>(
func), flags);
82 notifier_type _notifier;
100template<std::
integral T>
103 using value_type = T;
107 template<forward_of<observer<value_type>> Value>
110 _value_cbt = this->value.
subscribe([&](
auto...) {
120 return {
txt(
"Invalid integer")};
128 return to_gstring(to_string(*value));
152template<std::
floating_po
int T>
155 using value_type = T;
159 template<forward_of<observer<value_type>> Value>
162 _value_cbt = this->value.
subscribe([&](
auto...) {
172 return {elusive_icon::WarningSign,
txt(
"Invalid floating point number")};
180 return to_gstring(to_string(*value));
204template<
typename Value>
209 return std::make_shared<default_text_field_delegate<value_type>>(std::forward<Value>(value));
std::shared_ptr< text_field_delegate > make_default_text_field_delegate(Value &&value) noexcept
Create a shared pointer to a default text delegate.
Definition text_field_delegate.hpp:205
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378
Definition callback.hpp:77
Definition widget_intf.hpp:24
A localizable message.
Definition txt.hpp:100
A observer pointing to the whole or part of a observed_base.
Definition observer_intf.hpp:32
callback< void(value_type)> subscribe(Func &&func, callback_flags flags=callback_flags::synchronous) noexcept
Subscribe a callback to this observer.
Definition observer_intf.hpp:456
Exception thrown during parsing on an error.
Definition exception_intf.hpp:48
A delegate that controls the state of a text_field_widget.
Definition text_field_delegate.hpp:32
virtual label validate(widget_intf const &sender, gstring const &text) noexcept
Validate the text field.
Definition text_field_delegate.hpp:46
virtual gstring text(widget_intf const &sender) noexcept
Get the text to show in the text field.
Definition text_field_delegate.hpp:58
virtual void set_text(widget_intf const &sender, gstring const &text) noexcept
Set the text as entered by the user.
Definition text_field_delegate.hpp:73
A default text delegate.
Definition text_field_delegate.hpp:91
void set_text(widget_intf const &sender, gstring const &text) noexcept override
Set the text as entered by the user.
Definition text_field_delegate.hpp:131
label validate(widget_intf const &sender, gstring const &text) noexcept override
Validate the text field.
Definition text_field_delegate.hpp:115
gstring text(widget_intf const &sender) noexcept override
Get the text to show in the text field.
Definition text_field_delegate.hpp:126