blob: 1ac56a9dcdba7d0805c65bea7d713faab89d0eae (
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
54
55
56
57
58
59
60
61
|
#pragma once
#include "ComResource.hpp"
#include "Resource.hpp"
#include "cru/platform/graphics/TextLayout.hpp"
#include <limits>
#include <memory>
namespace cru::platform::graphics::win::direct {
class DWriteFont;
class DWriteTextLayout : public DirectGraphicsResource,
public virtual ITextLayout,
public virtual IComResource<IDWriteTextLayout> {
public:
DWriteTextLayout(DirectGraphicsFactory* factory, std::shared_ptr<IFont> font,
String text);
CRU_DELETE_COPY(DWriteTextLayout)
CRU_DELETE_MOVE(DWriteTextLayout)
~DWriteTextLayout() override;
public:
IDWriteTextLayout* GetComInterface() const override {
return text_layout_.Get();
}
public:
String GetText() override;
void SetText(String new_text) override;
std::shared_ptr<IFont> GetFont() override;
void SetFont(std::shared_ptr<IFont> font) override;
void SetMaxWidth(float max_width) override;
void SetMaxHeight(float max_height) override;
bool IsEditMode() override;
void SetEditMode(bool enable) override;
Index GetLineIndexFromCharIndex(Index char_index) override;
float GetLineHeight(Index line_index) override;
Index GetLineCount() override;
Rect GetTextBounds(bool includingTrailingSpace = false) override;
// Return empty vector if text_range.count is 0. Text range could be in
// reverse direction, it should be normalized first in implementation.
std::vector<Rect> TextRangeRect(const TextRange& text_range) override;
Rect TextSinglePoint(Index position, bool trailing) override;
TextHitTestResult HitTest(const Point& point) override;
private:
String text_;
std::shared_ptr<DWriteFont> font_;
float max_width_ = std::numeric_limits<float>::max();
float max_height_ = std::numeric_limits<float>::max();
Microsoft::WRL::ComPtr<IDWriteTextLayout> text_layout_;
};
} // namespace cru::platform::graphics::win::direct
|