diff options
author | crupest <crupest@outlook.com> | 2019-12-12 19:53:17 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-12-12 19:53:17 +0800 |
commit | e69911a8b161b81ce3f7b209175766da2b7b3d4b (patch) | |
tree | 76b1f4b6f9f5ad6111578771be783ee456aeb912 /include/cru/win/graph/direct/text_layout.hpp | |
parent | 154b5b838edfdcef93cd0a33c013ad7f5f9d7337 (diff) | |
download | cru-e69911a8b161b81ce3f7b209175766da2b7b3d4b.tar.gz cru-e69911a8b161b81ce3f7b209175766da2b7b3d4b.tar.bz2 cru-e69911a8b161b81ce3f7b209175766da2b7b3d4b.zip |
...
Diffstat (limited to 'include/cru/win/graph/direct/text_layout.hpp')
-rw-r--r-- | include/cru/win/graph/direct/text_layout.hpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/include/cru/win/graph/direct/text_layout.hpp b/include/cru/win/graph/direct/text_layout.hpp index a20591c2..5a8f3f9c 100644 --- a/include/cru/win/graph/direct/text_layout.hpp +++ b/include/cru/win/graph/direct/text_layout.hpp @@ -1,30 +1,25 @@ #pragma once #include "com_resource.hpp" -#include "direct_factory.hpp" -#include "platform_id.hpp" +#include "resource.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); +class DWriteFont; - DWriteTextLayout(const DWriteTextLayout& other) = delete; - DWriteTextLayout& operator=(const DWriteTextLayout& other) = delete; - - DWriteTextLayout(DWriteTextLayout&& other) = delete; - DWriteTextLayout& operator=(DWriteTextLayout&& other) = delete; +class DWriteTextLayout : public DirectGraphResource, + public virtual ITextLayout, + public virtual IComResource<IDWriteTextLayout> { + public: + DWriteTextLayout(DirectGraphFactory* factory, std::shared_ptr<IFont> font, + std::string text); - ~DWriteTextLayout() override = default; + CRU_DELETE_COPY(DWriteTextLayout) + CRU_DELETE_MOVE(DWriteTextLayout) - CRU_PLATFORMID_IMPLEMENT_DIRECT + ~DWriteTextLayout() override; public: IDWriteTextLayout* GetComInterface() const override { @@ -32,11 +27,11 @@ class DWriteTextLayout : public TextLayout, } public: - std::wstring GetText() override; - void SetText(std::wstring new_text) override; + std::string GetText() override; + void SetText(std::string new_text) override; - std::shared_ptr<Font> GetFont() override; - void SetFont(std::shared_ptr<Font> font) 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; @@ -45,8 +40,8 @@ class DWriteTextLayout : public TextLayout, std::vector<Rect> TextRangeRect(const TextRange& text_range) override; private: - IDirectFactory* factory_; - std::wstring text_; + std::string text_; + std::wstring w_text_; std::shared_ptr<DWriteFont> font_; float max_width_ = 0.0f; float max_height_ = 0.0f; |