diff options
author | crupest <crupest@outlook.com> | 2018-09-23 17:58:28 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-09-23 17:58:28 +0800 |
commit | 09864c09e519eaa58e3a7269baad7f48e8145f4f (patch) | |
tree | a494ea818ae485c22259d6e9d9f3c04b484c8499 /CruUI/ui/controls/text_block.cpp | |
parent | 95d54b36044196b7e996a188840ae8b1ef360895 (diff) | |
download | cru-09864c09e519eaa58e3a7269baad7f48e8145f4f.tar.gz cru-09864c09e519eaa58e3a7269baad7f48e8145f4f.tar.bz2 cru-09864c09e519eaa58e3a7269baad7f48e8145f4f.zip |
Move CreateDefaultTextFormat to graph.
Diffstat (limited to 'CruUI/ui/controls/text_block.cpp')
-rw-r--r-- | CruUI/ui/controls/text_block.cpp | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/CruUI/ui/controls/text_block.cpp b/CruUI/ui/controls/text_block.cpp index 8800fd91..f0ef41d9 100644 --- a/CruUI/ui/controls/text_block.cpp +++ b/CruUI/ui/controls/text_block.cpp @@ -21,8 +21,11 @@ namespace cru const Microsoft::WRL::ComPtr<ID2D1Brush>& init_brush) : Control(false) { text_format_ = init_text_format; + if (init_brush == nullptr) brush_ = CreateSolidBrush(D2D1::ColorF(D2D1::ColorF::Black)); + else + brush_ = init_brush; selection_brush_ = CreateSolidBrush(D2D1::ColorF(D2D1::ColorF::LightSkyBlue)); } @@ -60,7 +63,7 @@ namespace cru void TextBlock::RemoveTextLayoutHandler(const TextLayoutHandlerPtr& handler) { const auto find_result = std::find(text_layout_handlers_.cbegin(), text_layout_handlers_.cend(), - handler); + handler); if (find_result != text_layout_handlers_.cend()) text_layout_handlers_.erase(find_result); } @@ -259,23 +262,6 @@ namespace cru Repaint(); } - void TextBlock::CreateDefaultTextFormat() - { - const auto dwrite_factory = GetDWriteFactory(); - - ThrowIfFailed(dwrite_factory->CreateTextFormat( - L"΅ΘΟί", nullptr, - DWRITE_FONT_WEIGHT_NORMAL, - DWRITE_FONT_STYLE_NORMAL, - DWRITE_FONT_STRETCH_NORMAL, - 24.0, L"zh-cn", - &text_format_ - )); - - ThrowIfFailed(text_format_->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER)); - ThrowIfFailed(text_format_->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER)); - } - void TextBlock::RecreateTextLayout() { if (text_.empty()) @@ -287,7 +273,7 @@ namespace cru const auto dwrite_factory = GetDWriteFactory(); if (text_format_ == nullptr) - CreateDefaultTextFormat(); + text_format_ = graph::CreateDefaultTextFormat(); const auto&& size = GetSize(); |