diff options
author | crupest <crupest@outlook.com> | 2018-09-25 17:42:57 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-09-25 17:42:57 +0800 |
commit | da768af31952a28aa7aca8f60acd85bf2832465c (patch) | |
tree | 27317ae0d9ac5b1409408ef165595f9c127aa027 /src/ui/controls/text_control.h | |
parent | ccbc293c0158d4450c0db344474193f17925403f (diff) | |
download | cru-da768af31952a28aa7aca8f60acd85bf2832465c.tar.gz cru-da768af31952a28aa7aca8f60acd85bf2832465c.tar.bz2 cru-da768af31952a28aa7aca8f60acd85bf2832465c.zip |
Make TextBox inherates TextControl. Add slection-related features to it.
Diffstat (limited to 'src/ui/controls/text_control.h')
-rw-r--r-- | src/ui/controls/text_control.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ui/controls/text_control.h b/src/ui/controls/text_control.h index ca23ec95..a24766dc 100644 --- a/src/ui/controls/text_control.h +++ b/src/ui/controls/text_control.h @@ -51,8 +51,6 @@ namespace cru::ui::controls return is_selectable_; } - void SetSelectable(bool is_selectable); - std::optional<TextRange> GetSelectedRange() const { return selected_range_; @@ -60,6 +58,14 @@ namespace cru::ui::controls void SetSelectedRange(std::optional<TextRange> text_range); + void ClearSelection() + { + SetSelectedRange(std::nullopt); + } + + protected: + void SetSelectable(bool is_selectable); + protected: void OnSizeChangedCore(events::SizeChangedEventArgs& args) override final; void OnDraw(ID2D1DeviceContext* device_context) override; @@ -68,10 +74,11 @@ namespace cru::ui::controls void OnMouseMoveCore(events::MouseEventArgs& args) override final; void OnMouseUpCore(events::MouseButtonEventArgs& args) override final; - void OnLoseFocusCore(events::FocusChangeEventArgs& args) override final; + void OnLoseFocusCore(events::FocusChangeEventArgs& args) override; Size OnMeasure(const Size& available_size) override final; + virtual void RequestChangeCaretPosition(unsigned position); private: void OnTextChangedCore(const String& old_text, const String& new_text); @@ -84,8 +91,10 @@ namespace cru::ui::controls Microsoft::WRL::ComPtr<ID2D1Brush> brush_; Microsoft::WRL::ComPtr<ID2D1Brush> selection_brush_; Microsoft::WRL::ComPtr<IDWriteTextFormat> text_format_; + protected: Microsoft::WRL::ComPtr<IDWriteTextLayout> text_layout_; + private: Vector<TextLayoutHandlerPtr> text_layout_handlers_; bool is_selectable_ = false; |