#pragma once #include "../win_pre_config.hpp" #include "cru/platform/graph/text_layout.hpp" #include namespace cru::win::graph { class GraphManager; class WinFontDescriptor; class WinTextLayout : public Object, public virtual platform::graph::TextLayout { public: explicit WinTextLayout(GraphManager* graph_manager, std::shared_ptr font, std::wstring text); WinTextLayout(const WinTextLayout& other) = delete; WinTextLayout(WinTextLayout&& other) = delete; WinTextLayout& operator=(const WinTextLayout& other) = delete; WinTextLayout& operator=(WinTextLayout&& other) = delete; ~WinTextLayout() override = default; std::wstring GetText() override; void SetText(std::wstring new_text) override; std::shared_ptr GetFont(); void SetFont(std::shared_ptr font); void SetMaxWidth(float max_width) override; void SetMaxHeight(float max_height) override; ui::Rect GetTextBounds() override; std::vector TextRangeRect( const ui::TextRange& text_range) override; IDWriteTextLayout* GetDWriteTextLayout() const { return text_layout_.Get(); } private: GraphManager* graph_manager_; std::wstring text_; std::shared_ptr font_descriptor_; float max_width_ = 0.0f; float max_height_ = 0.0f; Microsoft::WRL::ComPtr text_layout_; }; } // namespace cru::platform::win