aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/text_box.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-04-24 00:03:16 +0800
committercrupest <crupest@outlook.com>2020-04-24 00:03:16 +0800
commit75ff8a6a05afd02aaadf7e3049b0a0e305241182 (patch)
tree5444bbb3ef80036cc38a827b8ccf03f48b310728 /src/ui/controls/text_box.cpp
parent922d7f6c96f81a33538900f8a8992a5b6f640874 (diff)
downloadcru-75ff8a6a05afd02aaadf7e3049b0a0e305241182.tar.gz
cru-75ff8a6a05afd02aaadf7e3049b0a0e305241182.tar.bz2
cru-75ff8a6a05afd02aaadf7e3049b0a0e305241182.zip
...
Diffstat (limited to 'src/ui/controls/text_box.cpp')
-rw-r--r--src/ui/controls/text_box.cpp27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/ui/controls/text_box.cpp b/src/ui/controls/text_box.cpp
index 99164b9b..7b63eea1 100644
--- a/src/ui/controls/text_box.cpp
+++ b/src/ui/controls/text_box.cpp
@@ -13,29 +13,22 @@ using render::CanvasRenderObject;
using render::StackLayoutRenderObject;
using render::TextRenderObject;
-TextBox::TextBox()
- : border_render_object_(new BorderRenderObject()),
- stack_layout_render_object_(new StackLayoutRenderObject()),
- text_render_object_(),
- caret_render_object_(new CanvasRenderObject()),
- service_(new TextControlService<TextBox>(this)) {
+TextBox::TextBox() : border_render_object_(new BorderRenderObject()) {
const auto theme_resources = UiManager::GetInstance()->GetThemeResources();
- caret_brush_ = theme_resources->caret_brush;
border_style_ = theme_resources->text_box_border_style;
text_render_object_ = std::make_unique<TextRenderObject>(
theme_resources->text_brush, theme_resources->default_font,
- theme_resources->text_selection_brush);
+ theme_resources->text_selection_brush, theme_resources->caret_brush);
- border_render_object_->AddChild(stack_layout_render_object_.get(), 0);
- stack_layout_render_object_->AddChild(text_render_object_.get(), 0);
- stack_layout_render_object_->AddChild(caret_render_object_.get(), 1);
+ border_render_object_->AddChild(text_render_object_.get(), 0);
border_render_object_->SetAttachedControl(this);
- stack_layout_render_object_->SetAttachedControl(this);
text_render_object_->SetAttachedControl(this);
- caret_render_object_->SetAttachedControl(this);
+
+ service_ = std::make_unique<TextControlService<TextBox>>(this);
+ service_->SetEnabled(true);
GainFocusEvent()->Direct()->AddHandler([this](event::FocusChangeEventArgs&) {
this->service_->SetEnabled(true);
@@ -54,14 +47,6 @@ render::TextRenderObject* TextBox::GetTextRenderObject() {
return text_render_object_.get();
}
-render::CanvasRenderObject* TextBox::GetCaretRenderObject() {
- return caret_render_object_.get();
-}
-
-std::shared_ptr<platform::graph::IBrush> TextBox::GetCaretBrush() {
- return caret_brush_;
-}
-
const TextBoxBorderStyle& TextBox::GetBorderStyle() { return border_style_; }
void TextBox::SetBorderStyle(TextBoxBorderStyle border_style) {