diff options
author | crupest <crupest@outlook.com> | 2018-09-07 23:13:48 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-09-07 23:13:48 +0800 |
commit | f8f9ca9a99da8a9dc014f5ed9a4f7d121eb87252 (patch) | |
tree | 8aaa0eed1afc24c74c890da207b39e07d56d8d72 /CruUI/ui/controls/text_block.h | |
parent | eebec8297a8538c40518ceee043edfc41e3b1343 (diff) | |
download | cru-f8f9ca9a99da8a9dc014f5ed9a4f7d121eb87252.tar.gz cru-f8f9ca9a99da8a9dc014f5ed9a4f7d121eb87252.tar.bz2 cru-f8f9ca9a99da8a9dc014f5ed9a4f7d121eb87252.zip |
...
Diffstat (limited to 'CruUI/ui/controls/text_block.h')
-rw-r--r-- | CruUI/ui/controls/text_block.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/CruUI/ui/controls/text_block.h b/CruUI/ui/controls/text_block.h index 85bfe90c..abf77112 100644 --- a/CruUI/ui/controls/text_block.h +++ b/CruUI/ui/controls/text_block.h @@ -1,5 +1,7 @@ #pragma once +#include <memory> + #include "ui/control.h" namespace cru @@ -11,6 +13,9 @@ namespace cru class TextBlock : public Control { public: + using TextLayoutHandler = Action<Microsoft::WRL::ComPtr<IDWriteTextLayout>>; + + explicit TextBlock( const Microsoft::WRL::ComPtr<IDWriteTextFormat>& init_text_format = nullptr, const Microsoft::WRL::ComPtr<ID2D1Brush>& init_brush = nullptr @@ -42,6 +47,18 @@ namespace cru void SetTextFormat(const Microsoft::WRL::ComPtr<IDWriteTextFormat>& text_format); + + void AddTextLayoutHandler(std::shared_ptr<TextLayoutHandler> handler) + { + text_layout_handlers_.push_back(std::move(handler)); + } + void RemoveTextLayoutHandler(const std::shared_ptr<TextLayoutHandler>& handler) + { + const auto find_result = std::find(text_layout_handlers_.cbegin(), text_layout_handlers_.cend(), handler); + if (find_result != text_layout_handlers_.cend()) + text_layout_handlers_.erase(find_result); + } + protected: void OnSizeChangedCore(events::SizeChangedEventArgs& args) override final; void OnDraw(ID2D1DeviceContext* device_context) override; @@ -61,6 +78,8 @@ namespace cru Microsoft::WRL::ComPtr<ID2D1Brush> brush_; Microsoft::WRL::ComPtr<IDWriteTextFormat> text_format_; Microsoft::WRL::ComPtr<IDWriteTextLayout> text_layout_; + + Vector<std::shared_ptr<TextLayoutHandler>> text_layout_handlers_; }; } } |