aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/text_box.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-10-04 01:47:49 +0800
committercrupest <crupest@outlook.com>2018-10-04 01:47:49 +0800
commit01ab4511d3006e9f65ff96ae63b21de14b41bc48 (patch)
treee4fa991e7784571c164301ff7ade5aa1ef515744 /src/ui/controls/text_box.cpp
parent30ecda8bb354d5982978af97aa90b5f49d9ea195 (diff)
downloadcru-01ab4511d3006e9f65ff96ae63b21de14b41bc48.tar.gz
cru-01ab4511d3006e9f65ff96ae63b21de14b41bc48.tar.bz2
cru-01ab4511d3006e9f65ff96ae63b21de14b41bc48.zip
...
Diffstat (limited to 'src/ui/controls/text_box.cpp')
-rw-r--r--src/ui/controls/text_box.cpp30
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;