blob: a6e4566dc2f785af4ece5565a0ec0e62ba4d854d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#pragma once
#include "text_control.h"
#include "timer.h"
#include "border_delegate.h"
namespace cru::ui::controls
{
class TextBox : public TextControl
{
public:
static TextBox* Create(
const Microsoft::WRL::ComPtr<IDWriteTextFormat>& init_text_format = nullptr,
const Microsoft::WRL::ComPtr<ID2D1Brush>& init_brush = nullptr)
{
return new TextBox(init_text_format, init_brush);
}
protected:
explicit TextBox(
const Microsoft::WRL::ComPtr<IDWriteTextFormat>& init_text_format,
const Microsoft::WRL::ComPtr<ID2D1Brush>& init_brush
);
public:
TextBox(const TextBox& other) = delete;
TextBox(TextBox&& other) = delete;
TextBox& operator=(const TextBox& other) = delete;
TextBox& operator=(TextBox&& other) = delete;
~TextBox() override;
protected:
void OnDraw(ID2D1DeviceContext* device_context) override;
void OnGetFocusCore(events::FocusChangeEventArgs& args) override final;
void OnLoseFocusCore(events::FocusChangeEventArgs& args) override final;
void OnKeyDownCore(events::KeyEventArgs& args) override final;
void OnCharCore(events::CharEventArgs& args) override final;
Size OnMeasure(const Size& available_size) override;
void RequestChangeCaretPosition(unsigned position) override;
private:
unsigned caret_position_ = 0;
TimerTask caret_timer_;
ActionPtr caret_action_;
Microsoft::WRL::ComPtr<ID2D1Brush> caret_brush_;
bool is_caret_show_ = false;
std::unique_ptr<BorderDelegate> border_delegate_;
};
}
|