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 {}
40 [[nodiscard]]
virtual gstring get_text(
widget_intf const& sender)
noexcept = 0;
41 [[nodiscard]]
virtual void set_text(
widget_intf const& sender, gstring
const& text)
noexcept = 0;
42 [[nodiscard]]
virtual bool can_set_text(
widget_intf const& sender)
noexcept = 0;
54 notifier<void()> _notifier;
72 using value_type =
char const *;
80 template<forward_of<observer<value_type>> Value>
83 _value_cbt = this->value.
subscribe([&](
auto...) {
99 callback<void(value_type)> _value_cbt;
117 template<forward_of<observer<value_type>> Value>
120 _value_cbt = this->value.
subscribe([&](
auto...) {
127 return to_gstring(*value);
132 value = to_string(text);
136 callback<void(value_type)> _value_cbt;
146 using value_type = gstring;
154 template<forward_of<observer<value_type>> Value>
157 _value_cbt = this->value.
subscribe([&](
auto...) {
173 callback<void(value_type)> _value_cbt;
183 using value_type =
txt;
191 template<forward_of<observer<value_type>> Value>
194 _value_cbt = this->value.
subscribe([&](
auto...) {
201 return value->translate();
210 callback<void(value_type)> _value_cbt;
220template<
typename 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:221
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
The HikoGUI API version 1.
Definition recursive_iterator.hpp:16
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
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:63
gstring read(widget_intf const &sender) noexcept override
Read text as a string of graphemes.
Definition text_delegate.hpp:88
default_text_delegate(Value &&value) noexcept
Construct a delegate.
Definition text_delegate.hpp:81
void write(widget_intf const &sender, gstring const &text) noexcept override
Write text from a string of graphemes.
Definition text_delegate.hpp:93
gstring read(widget_intf const &sender) noexcept override
Read text as a string of graphemes.
Definition text_delegate.hpp:125
default_text_delegate(Value &&value) noexcept
Construct a delegate.
Definition text_delegate.hpp:118
void write(widget_intf const &sender, gstring const &text) noexcept override
Write text from a string of graphemes.
Definition text_delegate.hpp:130
default_text_delegate(Value &&value) noexcept
Construct a delegate.
Definition text_delegate.hpp:155
gstring read(widget_intf const &sender) noexcept override
Read text as a string of graphemes.
Definition text_delegate.hpp:162
void write(widget_intf const &sender, gstring const &text) noexcept override
Write text from a string of graphemes.
Definition text_delegate.hpp:167
default_text_delegate(Value &&value) noexcept
Construct a delegate.
Definition text_delegate.hpp:192
void write(widget_intf const &sender, gstring const &text) noexcept override
Write text from a string of graphemes.
Definition text_delegate.hpp:204
gstring read(widget_intf const &sender) noexcept override
Read text as a string of graphemes.
Definition text_delegate.hpp:199
A text widget.
Definition text_widget.hpp:62