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 "../unicode/unicode.hpp"
18#include "../l10n/l10n.hpp"
19#include "../macros.hpp"
24hi_export_module(hikogui.widgets.text_delegate);
26hi_export
namespace hi {
inline namespace v1 {
37 virtual void init(
widget_intf const& sender)
noexcept {}
38 virtual void deinit(
widget_intf const& sender)
noexcept {}
50 template<forward_of<
void()> Func>
51 [[nodiscard]]
callback<void()>
subscribe(Func&& func, callback_flags flags = callback_flags::synchronous)
noexcept
53 return _notifier.subscribe(std::forward<Func>(func), flags);
57 notifier<void()> _notifier;
75 using value_type =
char const *;
83 template<forward_of<observer<value_type>> Value>
86 _value_cbt = this->value.
subscribe([&](
auto...) {
102 callback<void(value_type)> _value_cbt;
120 template<forward_of<observer<value_type>> Value>
123 _value_cbt = this->value.
subscribe([&](
auto...) {
130 return to_gstring(*value);
135 value = to_string(text);
139 callback<void(value_type)> _value_cbt;
149 using value_type = gstring;
157 template<forward_of<observer<value_type>> Value>
160 _value_cbt = this->value.
subscribe([&](
auto...) {
176 callback<void(value_type)> _value_cbt;
186 using value_type =
txt;
194 template<forward_of<observer<value_type>> Value>
197 _value_cbt = this->value.
subscribe([&](
auto...) {
204 return value->translate();
213 callback<void(value_type)> _value_cbt;
223template<
typename Value>
227 return std::make_shared<default_text_delegate<observer_decay_t<Value>>>(std::forward<Value>(value));
std::shared_ptr< text_delegate > make_default_text_delegate(Value &&value) noexcept
Create a shared pointer to a default text delegate.
Definition text_delegate.hpp:224
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
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
A delegate that controls the state of a text_widget.
Definition text_delegate.hpp:33
callback< void()> subscribe(Func &&func, callback_flags flags=callback_flags::synchronous) noexcept
Subscribe a callback for notifying the widget of a data change.
Definition text_delegate.hpp:51
virtual gstring read(widget_intf const &sender) noexcept=0
Read text as a string of graphemes.
virtual void write(widget_intf const &sender, gstring const &text) noexcept=0
Write text from a string of graphemes.
A default text delegate.
Definition text_delegate.hpp:66
gstring read(widget_intf const &sender) noexcept override
Read text as a string of graphemes.
Definition text_delegate.hpp:91
default_text_delegate(Value &&value) noexcept
Construct a delegate.
Definition text_delegate.hpp:84
void write(widget_intf const &sender, gstring const &text) noexcept override
Write text from a string of graphemes.
Definition text_delegate.hpp:96
gstring read(widget_intf const &sender) noexcept override
Read text as a string of graphemes.
Definition text_delegate.hpp:128
default_text_delegate(Value &&value) noexcept
Construct a delegate.
Definition text_delegate.hpp:121
void write(widget_intf const &sender, gstring const &text) noexcept override
Write text from a string of graphemes.
Definition text_delegate.hpp:133
default_text_delegate(Value &&value) noexcept
Construct a delegate.
Definition text_delegate.hpp:158
gstring read(widget_intf const &sender) noexcept override
Read text as a string of graphemes.
Definition text_delegate.hpp:165
void write(widget_intf const &sender, gstring const &text) noexcept override
Write text from a string of graphemes.
Definition text_delegate.hpp:170
default_text_delegate(Value &&value) noexcept
Construct a delegate.
Definition text_delegate.hpp:195
void write(widget_intf const &sender, gstring const &text) noexcept override
Write text from a string of graphemes.
Definition text_delegate.hpp:207
gstring read(widget_intf const &sender) noexcept override
Read text as a string of graphemes.
Definition text_delegate.hpp:202