aboutsummaryrefslogtreecommitdiff
path: root/CruUI/ui/controls/text_block.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-09-11 00:35:57 +0800
committercrupest <crupest@outlook.com>2018-09-11 00:35:57 +0800
commite2dab3893a8be43de0e50587c85df9e11abf87fe (patch)
tree1e95bcd4719a1b558a6ba641d4d655e190678b05 /CruUI/ui/controls/text_block.h
parent0607ef5f16327e79915676aceec10f2e3037e719 (diff)
downloadcru-e2dab3893a8be43de0e50587c85df9e11abf87fe.tar.gz
cru-e2dab3893a8be43de0e50587c85df9e11abf87fe.tar.bz2
cru-e2dab3893a8be43de0e50587c85df9e11abf87fe.zip
...
Diffstat (limited to 'CruUI/ui/controls/text_block.h')
-rw-r--r--CruUI/ui/controls/text_block.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/CruUI/ui/controls/text_block.h b/CruUI/ui/controls/text_block.h
index 04347a0c..d6d173ba 100644
--- a/CruUI/ui/controls/text_block.h
+++ b/CruUI/ui/controls/text_block.h
@@ -10,6 +10,32 @@ namespace cru
{
namespace controls
{
+ struct TextRange
+ {
+ TextRange() = default;
+ TextRange(const int position, const int count)
+ : position(position), count(count)
+ {
+
+ }
+ TextRange(const TextRange& other) = default;
+ TextRange(TextRange&& other) = default;
+ TextRange& operator=(const TextRange& other) = default;
+ TextRange& operator=(TextRange&& other) = default;
+ ~TextRange() = default;
+
+ unsigned position;
+ unsigned count;
+
+ operator DWRITE_TEXT_RANGE() const
+ {
+ DWRITE_TEXT_RANGE result;
+ result.startPosition = position;
+ result.length = count;
+ return result;
+ }
+ };
+
class TextBlock : public Control
{
public:
@@ -74,6 +100,9 @@ namespace cru
void OnSizeChangedCore(events::SizeChangedEventArgs& args) override final;
void OnDraw(ID2D1DeviceContext* device_context) override;
+ void OnMouseDownCore(events::MouseButtonEventArgs& args) override;
+ void OnMouseMoveCore(events::MouseEventArgs& args) override;
+
Size OnMeasure(const Size& available_size) override;
private:
@@ -91,6 +120,11 @@ namespace cru
Microsoft::WRL::ComPtr<IDWriteTextLayout> text_layout_;
Vector<std::shared_ptr<TextLayoutHandler>> text_layout_handlers_;
+
+ unsigned mouse_down_position_;
+ std::optional<TextRange> selected_range_;
+
+ bool is_mouse_down_ = false; //TODO!!!
};
}
}