1.11
text.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_TEXT_H
7#define EGT_TEXT_H
8
14#include <egt/detail/meta.h>
15#include <egt/flags.h>
16#include <egt/font.h>
17#include <egt/image.h>
18#include <egt/slider.h>
19#include <egt/textwidget.h>
20#include <egt/timer.h>
21#include <egt/types.h>
22#include <list>
23#include <memory>
24#include <string>
25#include <vector>
26
27namespace egt
28{
29inline namespace v1
30{
31
32
34{
35public:
36
38 enum class TextRectFlag : uint32_t
39 {
42
44 eonel = detail::bit(1),
45
47 bol = detail::bit(2),
48 };
49
52
53 TextRect(uint32_t behave,
54 const Rect& rect,
55 std::string text,
56 const Font::TextExtents& te,
57 const TextRectFlags& flags = {}) noexcept
58 : m_text(std::move(text)),
59 m_rect(rect),
60 m_text_rect_flags(flags),
61 m_behave(behave),
62 m_te(te)
63 {}
64
65 const std::string& text(void) const { return m_text; }
66 const Rect& rect(void) const { return m_rect; }
67 void rect(const Rect& r) { m_rect = r; }
68 void point(const Point& p) { m_rect.point(p); }
69 const TextRectFlags& flags(void) const { return m_text_rect_flags; }
70 uint32_t behave(void) const { return m_behave; }
71 const Font::TextExtents& text_extents(void) const { return m_te; }
72 void select(void) { m_text_rect_flags.set(TextRectFlag::selected); }
73 void deselect(void) { m_text_rect_flags.clear(TextRectFlag::selected); }
74 bool is_selected(void) const { return m_text_rect_flags.is_set(TextRectFlag::selected); }
75 bool end_of_non_empty_line(void) const { return m_text_rect_flags.is_set(TextRectFlag::eonel); }
76 void mark_beginning_of_line(void) { m_text_rect_flags.set(TextRectFlag::bol); }
77 bool beginning_of_line(void) const { return m_text_rect_flags.is_set(TextRectFlag::bol); }
78
79 bool can_consolidate(const TextRect& r) const noexcept
80 {
81 return ((m_text_rect_flags == r.m_text_rect_flags) &&
82 (m_rect.y() == r.m_rect.y()) &&
83 (m_rect.height() == r.m_rect.height()) &&
84 ((m_rect.x() + m_rect.width()) == r.m_rect.x()) &&
85 (r.m_text != "\n"));
86 }
87
88 size_t length(void) const noexcept;
89 TextRect& consolidate(const TextRect& r, const Painter& painter) noexcept;
90 TextRect split(size_t pos, const Painter& painter) noexcept;
91
92private:
93
95 std::string m_text;
96
98 Rect m_rect;
99
101 TextRectFlags m_text_rect_flags{};
102
104 uint32_t m_behave{0};
105
107 Font::TextExtents m_te;
108};
109
110using TextRects = std::list<TextRect>;
111
132class EGT_API TextBox : public TextWidget
133{
134public:
135
137 enum class TextFlag : uint32_t
138 {
140 fit_to_width = detail::bit(0),
141
143 multiline = detail::bit(1),
144
146 word_wrap = detail::bit(2),
147
149 no_virt_keyboard = detail::bit(3),
150
152 horizontal_scrollable = detail::bit(4),
153
155 vertical_scrollable = detail::bit(5),
156 };
157
160
165 using ValidatorCallback = std::function<bool(const std::string&)>;
166
170 static void default_text_align(const AlignFlags& align);
171
177 explicit TextBox(const std::string& text = {},
178 const AlignFlags& text_align = default_text_align(),
179 const TextFlags& flags = {}) noexcept;
180
186 explicit TextBox(const std::string& text,
187 const TextFlags& flags,
188 const AlignFlags& text_align = default_text_align()) noexcept;
189
196 TextBox(const std::string& text,
197 const Rect& rect,
198 const AlignFlags& text_align = default_text_align(),
199 const TextFlags& flags = {}) noexcept;
200
207 explicit TextBox(Frame& parent,
208 const std::string& text = {},
209 const AlignFlags& text_align = default_text_align(),
210 const TextFlags& flags = {}) noexcept;
211
219 TextBox(Frame& parent,
220 const std::string& text,
221 const Rect& rect,
222 const AlignFlags& text_align = default_text_align(),
223 const TextFlags& flags = {}) noexcept;
224
228 explicit TextBox(Serializer::Properties& props) noexcept
229 : TextBox(props, false)
230 {
231 }
232
233protected:
234
235 explicit TextBox(Serializer::Properties& props, bool is_derived) noexcept;
236
237public:
238
239 TextBox(const TextBox&) = delete;
240 TextBox& operator=(const TextBox&) = delete;
241 TextBox(TextBox&&) = default;
242 TextBox& operator=(TextBox&&) = default;
243
244 void handle(Event& event) override;
245
246 void draw(Painter& painter, const Rect& rect) override;
247
248 void resize(const Size& size) override;
249
250 using TextWidget::text;
251
252 void text(const std::string& str) override;
253
254 void clear() override;
255
256 using TextWidget::min_size_hint;
257
258 EGT_NODISCARD Size min_size_hint() const override;
259
265 void max_length(size_t len);
266
270 EGT_NODISCARD size_t max_length() const { return m_max_len;}
271
277 void text_flags(const TextFlags& text_flags)
278 {
279 if (detail::change_if_diff<>(m_text_flags, text_flags))
280 {
281 resize_sliders();
282 damage();
283 }
284 }
285
289 EGT_NODISCARD const TextFlags& text_flags() const { return m_text_flags; }
290
302 size_t append(const std::string& str);
303
310 size_t insert(const std::string& str);
311
315 EGT_NODISCARD size_t cursor() const;
316
321
326
333 void cursor_forward(size_t count = 1);
334
341 void cursor_backward(size_t count = 1);
342
348 void cursor_set(size_t pos);
349
354
361 void selection(size_t pos, size_t length);
362
370 void selection_forward(size_t count = 1);
371
379 void selection_backward(size_t count = 1);
380
390 void selection_move(size_t count, bool save_column = true);
391
397 EGT_NODISCARD size_t selection_cursor();
398
402 EGT_NODISCARD size_t selection_start() const
403 {
404 return m_select_start;
405 }
406
410 EGT_NODISCARD size_t selection_length() const
411 {
412 return m_select_len;
413 }
414
422
428 EGT_NODISCARD std::string selected_text() const;
429
434
441 void input_validation_enabled(bool enabled);
442
452
456 EGT_NODISCARD Point text_offset() const;
457
461 void text_offset(const Point& p);
462
463 void serialize(Serializer& serializer) const override;
464
465 ~TextBox() noexcept override;
466
467protected:
468
469 bool internal_drag() const override { return true; }
470
472 EGT_NODISCARD Rect text_boundaries() const;
473
475 EGT_NODISCARD Rect text_rect() const;
476
478 using TextWidget::text_size;
479 EGT_NODISCARD Size text_size() const;
480
483
485 using ValidatorCallbackArray = std::vector<ValidatorCallback>;
486
489
492
495
497 void cursor_set(size_t pos, bool save_column);
498
500 void change_cursor(size_t pos, bool save_column = true);
501
503 size_t point2pos(const Point& p) const;
504
506 size_t beginning_of_line(size_t cursor_pos) const;
507
509 size_t beginning_of_line() const { return beginning_of_line(m_cursor_pos); }
510
512 size_t end_of_line(size_t cursor_pos) const;
513
515 size_t end_of_line() const { return end_of_line(m_cursor_pos); }
516
518 size_t up(size_t cursor_pos) const;
519
521 size_t up() const { return up(m_cursor_pos); }
522
524 size_t down(size_t cursor_pos) const;
525
527 size_t down() const { return down(m_cursor_pos); }
528
530 virtual void handle_key(const Key& key);
531
533 bool validate_input(const std::string& str);
534
537
539 void tokenize(TextRects& rects);
540
543
545 void consolidate(TextRects& rects);
546
549
557
562 static void get_line(const TextRects& rects,
563 TextRects::iterator& pos,
564 std::string& line,
565 Rect& rect);
566
568 static std::string longest_prefix(const std::string& s1, const std::string& s2);
569
571 static std::string longest_suffix(const std::string& s1, const std::string& s2);
572
575 TextRects::iterator& prev_pos,
576 TextRects& next,
577 TextRects::iterator& next_pos);
578
581 TextRects::iterator& prev_pos,
582 TextRects& next,
583 TextRects::iterator& next_pos);
584
587 TextRects::iterator& prev_pos,
588 TextRects& next,
589 TextRects::iterator& next_pos);
590
592 void tag_line(TextRects& prev,
593 TextRects::iterator& prev_pos,
594 TextRects& next,
595 TextRects::iterator& next_pos);
596
598 void tag_text(TextRects& prev, TextRects& next);
599
601 static void get_line_selection(const TextRects& rects,
602 TextRects::const_iterator& pos,
603 Rect& rect);
604
607 TextRects::const_iterator& prev_pos,
608 const TextRects& next,
609 TextRects::const_iterator& next_pos);
610
612 void tag_text_selection(const TextRects& prev, const TextRects& next);
613
616
619
621 void draw_text(Painter& painter, const Rect& rect);
622
625
627 EGT_NODISCARD Rect text_area() const;
628
631
634
636 static DefaultDim half_screens(DefaultDim size, DefaultDim screen_size);
637
640
643
646
649
652
655
657 void draw_sliders(Painter& painter, const Rect& rect);
658
660 void damage_text(const Rect& rect)
661 {
662 damage(Rect::intersection(rect, text_area()));
663 }
664
667 {
669 damage(Rect::intersection(m_cursor_rect, box()));
670 }
671
674
679 size_t m_cursor_pos{0};
680
685 size_t m_saved_column{0};
686
691 size_t m_select_start{0};
692
694 size_t m_select_len{0};
695
697 size_t m_select_origin{0};
698
700 size_t m_select_drag_start{0};
701
703 bool m_validate_input{false};
704
707
710 mutable bool m_text_rect_valid{false};
711
715
720 EGT_NODISCARD size_t width_to_len(const std::string& str) const;
721
722private:
723 class State
724 {
725 public:
726 State() noexcept
727 {}
728
729 explicit State(const Font* font,
730 const Widget::Flags& flags,
731 const AlignFlags& text_align,
732 const TextFlags& text_flags) noexcept
733 : m_font(font),
734 m_flags(flags),
735 m_text_align(text_align),
736 m_text_flags(text_flags)
737 {}
738
739 State& operator=(const State& rhs) noexcept
740 {
741 m_font = rhs.m_font;
742 m_flags = rhs.m_flags;
743 m_text_align = rhs.m_text_align;
744 m_text_flags = rhs.m_text_flags;
745 return *this;
746 }
747
748 State& operator=(State&& rhs) noexcept
749 {
750 m_font = rhs.m_font;
751 m_flags = std::move(rhs.m_flags);
752 m_text_align = std::move(rhs.m_text_align);
753 m_text_flags = std::move(rhs.m_text_flags);
754 return *this;
755 }
756
757 bool operator==(const State& rhs) const noexcept
758 {
759 return m_font == rhs.m_font &&
760 m_flags == rhs.m_flags &&
761 m_text_align == rhs.m_text_align &&
762 m_text_flags == rhs.m_text_flags;
763 }
764
765 bool operator!=(const State& rhs) const noexcept
766 {
767 return !operator==(rhs);
768 }
769
770 private:
771 const Font* m_font{nullptr};
772 Widget::Flags m_flags;
773 AlignFlags m_text_align;
774 TextFlags m_text_flags;
775 };
776
778 void cursor_timeout();
779
781 bool m_cursor_state{false};
782
784 TextFlags m_text_flags{};
785
787 size_t m_max_len{0};
788
789 State m_state;
790
792 Slider m_hslider;
793
795 Slider m_vslider;
796
798 DefaultDim m_slider_dim{8};
799
801 Signal<>::RegisterHandle m_gain_focus_reg{};
802
804 Signal<>::RegisterHandle m_lost_focus_reg{};
805
806 void initialize(bool init_inherited_properties = true);
807
808 void deserialize(Serializer::Properties& props);
809};
810
811namespace detail
812{
814EGT_API void draw_text(Painter& painter,
815 const Rect& b,
816 const std::string& text,
817 const Font& font,
818 const TextBox::TextFlags& flags,
819 const AlignFlags& text_align,
821 const Pattern& text_color,
822 const std::function<void(const Point& offset, size_t height)>& draw_cursor = nullptr,
823 size_t cursor_pos = 0,
824 const Pattern& highlight_color = {},
825 size_t select_start = 0,
826 size_t select_len = 0);
827
829EGT_API void draw_text(Painter& painter,
830 const Rect& b,
831 const std::string& text,
832 const Font& font,
833 const TextBox::TextFlags& flags,
834 const AlignFlags& text_align,
836 const Pattern& text_color,
837 const AlignFlags& image_align,
838 const Image& image,
839 const std::function<void(const Point& offset, size_t height)>& draw_cursor = nullptr,
840 size_t cursor_pos = 0,
841 const Pattern& highlight_color = {},
842 size_t select_start = 0,
843 size_t select_len = 0);
844}
845
846}
847}
848
849#endif
Alignment flags.
Definition widgetflags.h:380
EGT_NODISCARD constexpr bool is_set(const T flag) const noexcept
Test if the specified flag is set.
Definition flagsbase.h:64
Utility class for managing a set of flags with the ability to observe changes to the flags.
Definition flags.h:40
bool clear(T flag) noexcept
Clear a single flag.
Definition flags.h:125
bool set(T flag) noexcept
Set a single flag.
Definition flags.h:107
Manages a font and properties of a font.
Definition font.h:41
Font extent.
Definition font.h:50
Text extent.
Definition font.h:62
A Frame is a Widget that has children widgets.
Definition frame.h:45
Drawing interface for 2D graphics.
Definition painter.h:54
Periodic timer.
Definition timer.h:281
EGT_NODISCARD constexpr Dim width() const noexcept
Get the width value.
Definition geometry.h:926
EGT_NODISCARD constexpr Dim x() const noexcept
Get the x value.
Definition geometry.h:916
EGT_NODISCARD constexpr const PointType< Dim, DimCompat > & point() const noexcept
Get the PointType of the rectangle.
Definition geometry.h:722
EGT_NODISCARD constexpr Dim height() const noexcept
Get the height value.
Definition geometry.h:928
EGT_NODISCARD constexpr Dim y() const noexcept
Get the y value.
Definition geometry.h:918
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
Input text box.
Definition text.h:133
void selection_move(size_t count, bool save_column=true)
Move the selection cursor to count character(s):
TextBox(Serializer::Properties &props, bool is_derived) noexcept
size_t insert(const std::string &str)
Insert text at the cursor.
size_t up(size_t cursor_pos) const
Get the position in the line befor cursor_pos at the same column, if possible.
void move_vslider()
Move the vertical slider, if needed, to track the cursor.
void damage_cursor()
Damage the cursor but only if visible.
Definition text.h:666
EGT_NODISCARD Size min_size_hint() const override
Get a minimum size hint for the Widget.
void tokenize(TextRects &rects)
Split the text into atomic tokens that fill the TextRects parameter.
void update_hslider()
Update the horizontal slider.
void show_cursor()
Show/enable the visibility of the cursor.
void tag_text(TextRects &prev, TextRects &next)
Damage the differences between two texts.
void draw_sliders(Painter &painter, const Rect &rect)
Draw sliders.
void selection_clear()
Clear any selection.
void clear_selection(TextRects &rects)
Clear the TextRectFlag::selected flag from all TextRects in rects.
void invalidate_text_rect()
Invalidate the cache used by text_rect()
void selection_damage()
Compute damage rectangles for selection updates.
void tag_default_aligned_line(TextRects &prev, TextRects::iterator &prev_pos, TextRects &next, TextRects::iterator &next_pos)
Damage the merged rectangle of two text lines if they are not equal.
void change_cursor(size_t pos, bool save_column=true)
Change the value of m_cursor_pos.
void draw(Painter &painter, const Rect &rect) override
Draw the widget.
EGT_NODISCARD std::string selected_text() const
Get, or copy, the selected text.
EGT_NODISCARD size_t selection_cursor()
Get the position of the moving end of the selection, as opposed to its origin (the fixed end of the s...
static std::string longest_prefix(const std::string &s1, const std::string &s2)
Compute the longest common prefix between two strings.
void selection(size_t pos, size_t length)
Set the selection of text.
void init_sliders()
Init sliders.
ValidatorCallbackArray m_validator_callbacks
Callbacks invoked to validate the input.
Definition text.h:706
Rect m_text_rect
The cache for text_rect().
Definition text.h:709
void hide_cursor()
Hide/disable the visibility of the cursor.
EGT_NODISCARD Point text_offset() const
Get the position offset of the drawn text as compared to the whole text.
static void get_line(const TextRects &rects, TextRects::iterator &pos, std::string &line, Rect &rect)
Get the std::string and Rect from pos to the first follwing TextRect in rects with a different height...
void update_sliders()
Update the horizontal and vertical sliders as needed.
TextBox & operator=(const TextBox &)=delete
void cursor_forward(size_t count=1)
Move the cursor forward by the specified count from the current position.
void prepare_text(TextRects &rects)
Tokenize and compute the layout of a text; fill TextRects accordingly.
void tag_line(TextRects &prev, TextRects::iterator &prev_pos, TextRects &next, TextRects::iterator &next_pos)
Damage the differences between two text lines, based on the text alignment.
egt::Flags< TextFlag > TextFlags
Text flags.
Definition text.h:159
EGT_NODISCARD Rect text_rect() const
Get the rectangle of a text.
void tag_line_selection(const TextRects &prev, TextRects::const_iterator &prev_pos, const TextRects &next, TextRects::const_iterator &next_pos)
Damage the differences between two selected text lines.
static AlignFlags default_text_align()
Change text align.
size_t up() const
Get the position in the previous line at the same column, if possible.
Definition text.h:521
static std::string longest_suffix(const std::string &s1, const std::string &s2)
Compute the longest common suffix between two strings.
EGT_NODISCARD size_t selection_length() const
Get the length of the selection.
Definition text.h:410
TextBox(const std::string &text={}, const AlignFlags &text_align=default_text_align(), const TextFlags &flags={}) noexcept
void text_flags(const TextFlags &text_flags)
Set the text flags.
Definition text.h:277
void resize(const Size &size) override
Resize the widget.
void cursor_begin()
Move the cursor to the beginning.
Font::FontExtents m_fe
Definition text.h:712
void set_selection(TextRects &rects)
Add the TextRectFlag::selected flag to TextRects based on the m_select_start and m_select_len values.
void cursor_backward(size_t count=1)
Move the cursor backward by the specified count from the current position.
void move_hslider()
Move the horizontal slider, if needed, to track the cursor.
Rect m_cursor_rect
Definition text.h:714
size_t down(size_t cursor_pos) const
Get the position in the line after cursor_pos at the same column, if possible.
TextRects m_rects
Definition text.h:713
size_t append(const std::string &str)
Move the cursor to the end and insert.
EGT_NODISCARD size_t selection_start() const
Get the start position of the selection.
Definition text.h:402
EGT_NODISCARD size_t width_to_len(const std::string &str) const
Given text, return the number of UTF8 characters that will fit on a single line inside of the widget.
void consolidate(TextRects &rects)
Merge adjacent TextRect items, when possible.
void tag_left_aligned_line(TextRects &prev, TextRects::iterator &prev_pos, TextRects &next, TextRects::iterator &next_pos)
Damage the merge rectangle of two text lines, excluding their common prefix.
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
TextBox(Frame &parent, const std::string &text={}, const AlignFlags &text_align=default_text_align(), const TextFlags &flags={}) noexcept
void draw_text(Painter &painter, const Rect &rect)
Draw the text based on the m_rects TextRects.
static void default_text_align(const AlignFlags &align)
Change default text align.
TextBox & operator=(TextBox &&)=default
void text_offset(const Point &p)
Set the position offset of the drawn text as compared to the whole text.
EGT_NODISCARD Rect text_boundaries() const
Get the rectangle of the text boundaries.
std::vector< ValidatorCallback > ValidatorCallbackArray
Type array used for validator callbacks.
Definition text.h:485
void update_vslider()
Update the vertical slider.
size_t down() const
Get the position in the next line at the same column, if possible.
Definition text.h:527
TextFlag
Text flags.
Definition text.h:138
EGT_NODISCARD size_t max_length() const
Get the max length of allowed text.
Definition text.h:270
TextBox(const std::string &text, const TextFlags &flags, const AlignFlags &text_align=default_text_align()) noexcept
void selection_backward(size_t count=1)
Extend the selection to the left if the cursor is at its end, otherwise reduce the selection from the...
void add_validator_function(ValidatorCallback callback)
Add a callback to be invoked to validate the input.
static void get_line_selection(const TextRects &rects, TextRects::const_iterator &pos, Rect &rect)
Compute the merged Rect for the selected TextRects on the same line as pos.
EGT_NODISCARD size_t cursor() const
Get the cursor position.
TextBox(Serializer::Properties &props) noexcept
Definition text.h:228
void cursor_set(size_t pos)
Set the cursor to the specific position.
virtual void handle_key(const Key &key)
Process key events.
void handle(Event &event) override
Handle an event.
TextBox(const TextBox &)=delete
EGT_NODISCARD Rect text_area() const
Return the rectangle boundaries where the text can be drawn.
size_t end_of_line(size_t cursor_pos) const
Get the position of the end of the line at cursor_pos.
size_t end_of_line() const
Get the position of the end of the current line.
Definition text.h:515
size_t beginning_of_line() const
Get the position of the beginning of the current line.
Definition text.h:509
void selection_forward(size_t count=1)
Extend the selection to the right if the cursor is at its beginning, otherwise reduce the selection f...
void input_validation_enabled(bool enabled)
Enable or disable input validation.
void compute_layout(TextRects &rects)
Compute the text layout from the tokens contained in the TextRects.
void tag_text_selection(const TextRects &prev, const TextRects &next)
Damage the differences between two selected texts.
void tag_right_aligned_line(TextRects &prev, TextRects::iterator &prev_pos, TextRects &next, TextRects::iterator &next_pos)
Damage the merge rectangle of two text lines, excluding their common suffix.
void get_cursor_rect()
Update m_cursor_rect based on the current position of the cursor.
void cursor_set(size_t pos, bool save_column)
Set the cursor position.
TextBox(Frame &parent, const std::string &text, const Rect &rect, const AlignFlags &text_align=default_text_align(), const TextFlags &flags={}) noexcept
void damage_text(const Rect &rect)
Damage the text but only if visible.
Definition text.h:660
void selection_all()
Select all of the text.
void selection_delete()
Delete the selected text.
void resize_sliders()
Resize the sliders whenever the widget size changes.
size_t point2pos(const Point &p) const
Convert point coordinates to position in text for cursor or selection.
void move_sliders()
Move sliders, if needed, to track the cursor.
~TextBox() noexcept override
void refresh_text_area()
Compute the new text layout and cursor rectangle.
PeriodicTimer m_timer
Timer for blinking the cursor.
Definition text.h:673
void continue_show_cursor()
If the cursor is shown, keep is shown some more.
bool validate_input(const std::string &str)
Validate the input against the validator pattern.
TextBox(TextBox &&)=default
std::function< bool(const std::string &)> ValidatorCallback
Validator callback type.
Definition text.h:165
void clear() override
Clear the text value.
void max_length(size_t len)
Set the maximum allowed length of the text.
size_t beginning_of_line(size_t cursor_pos) const
Get the position of the beginning of the line at cursor_pos.
void cursor_end()
Move the cursor to the end.
static DefaultDim half_screens(DefaultDim size, DefaultDim screen_size)
Return the lowest multiple of 'screen_size' / 2, greater than 'size'.
EGT_NODISCARD const TextFlags & text_flags() const
Get a const ref of the flags.
Definition text.h:289
EGT_NODISCARD Size text_size() const
void text(const std::string &str) override
Set the text.
Definition text.h:34
void deselect(void)
Definition text.h:73
TextRectFlag
TextRect flags.
Definition text.h:39
@ eonel
End of non-empty line.
bool end_of_non_empty_line(void) const
Definition text.h:75
TextRect(uint32_t behave, const Rect &rect, std::string text, const Font::TextExtents &te, const TextRectFlags &flags={}) noexcept
Definition text.h:53
TextRect & consolidate(const TextRect &r, const Painter &painter) noexcept
void point(const Point &p)
Definition text.h:68
const TextRectFlags & flags(void) const
Definition text.h:69
uint32_t behave(void) const
Definition text.h:70
void mark_beginning_of_line(void)
Definition text.h:76
const Rect & rect(void) const
Definition text.h:66
const std::string & text(void) const
Definition text.h:65
bool is_selected(void) const
Definition text.h:74
TextRect split(size_t pos, const Painter &painter) noexcept
size_t length(void) const noexcept
void rect(const Rect &r)
Definition text.h:67
void select(void)
Definition text.h:72
bool beginning_of_line(void) const
Definition text.h:77
bool can_consolidate(const TextRect &r) const noexcept
Definition text.h:79
const Font::TextExtents & text_extents(void) const
Definition text.h:71
A widget with text and text related properties.
Definition textwidget.h:33
RectType< DefaultDim, detail::Compatible::normal > Rect
Helper type alias.
Definition geometry.h:1036
PointType< DefaultDim, detail::Compatible::normal > Point
Helper type alias.
Definition geometry.h:314
constexpr T bit(T n)
Utility to create a bit mask for the specified bit.
Definition meta.h:306
constexpr bool operator!=(const Color &lhs, const Color &rhs)
Color operator.
Definition color.h:509
Justification
Generic justification of children flags.
Definition widgetflags.h:694
std::list< TextRect > TextRects
Definition text.h:110
constexpr bool operator==(const Color &lhs, const Color &rhs)
Color operator.
Definition color.h:500
int DefaultDim
Define the default dimension type used for geometry.
Definition geometry.h:34
EGT framework namespace.
Definition animation.h:24
A single event that has information about the event and state for the event.
Definition event.h:255
Keyboard event data.
Definition event.h:165