blob: c765776233fbf077d07a0a6a2deb6f56fa3e116c (
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
|
#pragma once
#include "com_resource.hpp"
#include "direct_factory.hpp"
#include "platform_id.hpp"
#include "cru/platform/graph/text_layout.hpp"
#include "font.hpp"
#include <memory>
namespace cru::platform::graph::win::direct {
class DWriteTextLayout : public TextLayout,
public IComResource<IDWriteTextLayout> {
public:
explicit DWriteTextLayout(IDirectFactory* factory, std::shared_ptr<Font> font,
std::wstring text);
DWriteTextLayout(const DWriteTextLayout& other) = delete;
DWriteTextLayout& operator=(const DWriteTextLayout& other) = delete;
DWriteTextLayout(DWriteTextLayout&& other) = delete;
DWriteTextLayout& operator=(DWriteTextLayout&& other) = delete;
~DWriteTextLayout() override = default;
CRU_PLATFORMID_IMPLEMENT_DIRECT
public:
IDWriteTextLayout* GetComInterface() const override {
return text_layout_.Get();
}
public:
std::wstring GetText() override;
void SetText(std::wstring new_text) override;
std::shared_ptr<Font> GetFont();
void SetFont(std::shared_ptr<Font> font);
void SetMaxWidth(float max_width) override;
void SetMaxHeight(float max_height) override;
Rect GetTextBounds() override;
std::vector<Rect> TextRangeRect(const TextRange& text_range) override;
private:
IDirectFactory* factory_;
std::wstring text_;
std::shared_ptr<DWriteFont> font_;
float max_width_ = 0.0f;
float max_height_ = 0.0f;
Microsoft::WRL::ComPtr<IDWriteTextLayout> text_layout_;
};
} // namespace cru::platform::graph::win::direct
|