diff options
Diffstat (limited to 'src/ui/controls/text_box.cpp')
-rw-r--r-- | src/ui/controls/text_box.cpp | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/ui/controls/text_box.cpp b/src/ui/controls/text_box.cpp index 0d65f1ad..30b9069a 100644 --- a/src/ui/controls/text_box.cpp +++ b/src/ui/controls/text_box.cpp @@ -27,27 +27,22 @@ namespace cru::ui::controls Repaint(); }); - border_delegate_ = std::make_unique<BorderDelegate>(this); + SetBordered(true); } TextBox::~TextBox() = default; - void TextBox::OnDraw(ID2D1DeviceContext* device_context) + void TextBox::OnDrawContent(ID2D1DeviceContext* device_context) { - border_delegate_->Draw(device_context, GetSize()); - const auto border_thickness = border_delegate_->GetBorderThickness(); - graph::WithTransform(device_context, D2D1::Matrix3x2F::Translation(border_thickness.left, border_thickness.top), [this](ID2D1DeviceContext* device_context) + TextControl::OnDrawContent(device_context); + if (is_caret_show_) { - TextControl::OnDraw(device_context); - if (is_caret_show_) - { - const auto caret_half_width = Application::GetInstance()->GetCaretInfo().half_caret_width; - FLOAT x, y; - DWRITE_HIT_TEST_METRICS metrics{}; - ThrowIfFailed(text_layout_->HitTestTextPosition(caret_position_, FALSE, &x, &y, &metrics)); - device_context->FillRectangle(D2D1::RectF(metrics.left - caret_half_width, metrics.top, metrics.left + caret_half_width, metrics.top + metrics.height), caret_brush_.Get()); - } - }); + const auto caret_half_width = Application::GetInstance()->GetCaretInfo().half_caret_width; + FLOAT x, y; + DWRITE_HIT_TEST_METRICS metrics{}; + ThrowIfFailed(text_layout_->HitTestTextPosition(caret_position_, FALSE, &x, &y, &metrics)); + device_context->FillRectangle(D2D1::RectF(metrics.left - caret_half_width, metrics.top, metrics.left + caret_half_width, metrics.top + metrics.height), caret_brush_.Get()); + } } void TextBox::OnGetFocusCore(events::FocusChangeEventArgs& args) @@ -138,11 +133,6 @@ namespace cru::ui::controls } } - Size TextBox::OnMeasure(const Size& available_size) - { - return TextMeasureWithPadding(available_size, border_delegate_->GetBorderThickness()); - } - void TextBox::RequestChangeCaretPosition(const unsigned position) { caret_position_ = position; |