aboutsummaryrefslogtreecommitdiff
path: root/include/cru/win
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/win')
-rw-r--r--include/cru/win/graph/direct/brush.hpp33
-rw-r--r--include/cru/win/graph/direct/com_resource.hpp10
-rw-r--r--include/cru/win/graph/direct/convert_util.hpp9
-rw-r--r--include/cru/win/graph/direct/direct_factory.hpp16
-rw-r--r--include/cru/win/graph/direct/factory.hpp48
-rw-r--r--include/cru/win/graph/direct/font.hpp23
-rw-r--r--include/cru/win/graph/direct/geometry.hpp41
-rw-r--r--include/cru/win/graph/direct/graph_factory.hpp71
-rw-r--r--include/cru/win/graph/direct/painter.hpp28
-rw-r--r--include/cru/win/graph/direct/platform_id.hpp18
-rw-r--r--include/cru/win/graph/direct/resource.hpp49
-rw-r--r--include/cru/win/graph/direct/text_layout.hpp39
-rw-r--r--include/cru/win/native/native_window.hpp2
-rw-r--r--include/cru/win/native/platform_id.hpp19
-rw-r--r--include/cru/win/native/ui_application.hpp4
-rw-r--r--include/cru/win/string.hpp10
16 files changed, 188 insertions, 232 deletions
diff --git a/include/cru/win/graph/direct/brush.hpp b/include/cru/win/graph/direct/brush.hpp
index 1f1c319f..0726ec3f 100644
--- a/include/cru/win/graph/direct/brush.hpp
+++ b/include/cru/win/graph/direct/brush.hpp
@@ -1,44 +1,39 @@
#pragma once
#include "com_resource.hpp"
-#include "direct_factory.hpp"
-#include "platform_id.hpp"
+#include "resource.hpp"
#include "cru/platform/graph/brush.hpp"
namespace cru::platform::graph::win::direct {
-struct ID2DBrush {
- virtual ~ID2DBrush() = default;
-
+struct ID2DBrush : virtual IBrush {
virtual ID2D1Brush* GetD2DBrushInterface() const = 0;
};
-class D2DSolidColorBrush : public SolidColorBrush,
- public ID2DBrush,
- public IComResource<ID2D1SolidColorBrush> {
+class D2DSolidColorBrush : public DirectGraphResource,
+ public virtual ISolidColorBrush,
+ public virtual ID2DBrush,
+ public virtual IComResource<ID2D1SolidColorBrush> {
public:
- explicit D2DSolidColorBrush(IDirectFactory* factory);
-
- D2DSolidColorBrush(const D2DSolidColorBrush& other) = delete;
- D2DSolidColorBrush& operator=(const D2DSolidColorBrush& other) = delete;
+ explicit D2DSolidColorBrush(DirectGraphFactory* factory);
- D2DSolidColorBrush(D2DSolidColorBrush&& other) = delete;
- D2DSolidColorBrush& operator=(D2DSolidColorBrush&& other) = delete;
+ CRU_DELETE_COPY(D2DSolidColorBrush)
+ CRU_DELETE_MOVE(D2DSolidColorBrush)
~D2DSolidColorBrush() override = default;
- CRU_PLATFORMID_IMPLEMENT_DIRECT
-
public:
+ Color GetColor() override { return color_; }
+ void SetColor(const Color& color) override;
+
ID2D1Brush* GetD2DBrushInterface() const override { return brush_.Get(); }
ID2D1SolidColorBrush* GetComInterface() const override {
return brush_.Get();
}
- protected:
- void OnSetColor(const Color& color) override;
-
private:
+ Color color_ = colors::black;
+
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> brush_;
};
} // namespace cru::platform::graph::win::direct
diff --git a/include/cru/win/graph/direct/com_resource.hpp b/include/cru/win/graph/direct/com_resource.hpp
index 22d1d6f0..a6c83434 100644
--- a/include/cru/win/graph/direct/com_resource.hpp
+++ b/include/cru/win/graph/direct/com_resource.hpp
@@ -1,11 +1,11 @@
#pragma once
#include "../../win_pre_config.hpp"
-namespace cru::platform::graph::win::direct {
-template<typename TInterface>
-struct IComResource {
- virtual ~IComResource() = default;
+#include "cru/common/base.hpp"
+namespace cru::platform::graph::win::direct {
+template <typename TInterface>
+struct IComResource : virtual Interface {
virtual TInterface* GetComInterface() const = 0;
};
-} // namespace cru::platform::graph::win_direct
+} // namespace cru::platform::graph::win::direct
diff --git a/include/cru/win/graph/direct/convert_util.hpp b/include/cru/win/graph/direct/convert_util.hpp
index 2c45c63a..ef343a3f 100644
--- a/include/cru/win/graph/direct/convert_util.hpp
+++ b/include/cru/win/graph/direct/convert_util.hpp
@@ -1,8 +1,7 @@
#pragma once
#include "../../win_pre_config.hpp"
-#include "cru/platform/graphic_base.hpp"
-#include "cru/platform/matrix.hpp"
+#include "cru/platform/graph/base.hpp"
namespace cru::platform::graph::win::direct {
inline D2D1_MATRIX_3X2_F Convert(const platform::Matrix& matrix) {
@@ -48,7 +47,7 @@ inline platform::Matrix Convert(const D2D1_MATRIX_3X2_F& matrix) {
inline Color Convert(const D2D1_COLOR_F& color) {
auto floor = [](float n) { return static_cast<std::uint8_t>(n + 0.5f); };
return Color{floor(color.r * 255.0f), floor(color.g * 255.0f),
- floor(color.b * 255.0f), floor(color.a * 255.0f)};
+ floor(color.b * 255.0f), floor(color.a * 255.0f)};
}
inline Point Convert(const D2D1_POINT_2F& point) {
@@ -57,12 +56,12 @@ inline Point Convert(const D2D1_POINT_2F& point) {
inline Rect Convert(const D2D1_RECT_F& rect) {
return Rect(rect.left, rect.top, rect.right - rect.left,
- rect.bottom - rect.top);
+ rect.bottom - rect.top);
}
inline RoundedRect Convert(const D2D1_ROUNDED_RECT& rounded_rect) {
return RoundedRect(Convert(rounded_rect.rect), rounded_rect.radiusX,
- rounded_rect.radiusY);
+ rounded_rect.radiusY);
}
inline Ellipse Convert(const D2D1_ELLIPSE& ellipse) {
diff --git a/include/cru/win/graph/direct/direct_factory.hpp b/include/cru/win/graph/direct/direct_factory.hpp
deleted file mode 100644
index b150d5aa..00000000
--- a/include/cru/win/graph/direct/direct_factory.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#pragma once
-#include "../../win_pre_config.hpp"
-
-namespace cru::platform::graph::win::direct {
-// Interface provides access to root d2d resources.
-struct IDirectFactory {
- virtual ~IDirectFactory() = default;
-
- virtual ID2D1Factory1* GetD2D1Factory() const = 0;
- virtual ID2D1DeviceContext* GetD2D1DeviceContext() const = 0;
- virtual ID3D11Device* GetD3D11Device() const = 0;
- virtual IDXGIFactory2* GetDxgiFactory() const = 0;
- virtual IDWriteFactory* GetDWriteFactory() const = 0;
- virtual IDWriteFontCollection* GetSystemFontCollection() const = 0;
-};
-} // namespace cru::platform::graph::win::direct
diff --git a/include/cru/win/graph/direct/factory.hpp b/include/cru/win/graph/direct/factory.hpp
new file mode 100644
index 00000000..ae4eeb3a
--- /dev/null
+++ b/include/cru/win/graph/direct/factory.hpp
@@ -0,0 +1,48 @@
+#pragma once
+#include "resource.hpp"
+
+#include "cru/platform/graph/factory.hpp"
+
+namespace cru::platform::graph::win::direct {
+class DirectGraphFactory : public DirectResource, public virtual IGraphFactory {
+ private:
+ DirectGraphFactory();
+
+ public:
+ CRU_DELETE_COPY(DirectGraphFactory)
+ CRU_DELETE_MOVE(DirectGraphFactory)
+
+ ~DirectGraphFactory() override = default;
+
+ public:
+ ID2D1Factory1* GetD2D1Factory() const { return d2d1_factory_.Get(); }
+ ID2D1DeviceContext* GetD2D1DeviceContext() const {
+ return d2d1_device_context_.Get();
+ }
+ ID3D11Device* GetD3D11Device() const { return d3d11_device_.Get(); }
+ IDXGIFactory2* GetDxgiFactory() const { return dxgi_factory_.Get(); }
+ IDWriteFactory* GetDWriteFactory() const { return dwrite_factory_.Get(); }
+ IDWriteFontCollection* GetSystemFontCollection() const {
+ return dwrite_system_font_collection_.Get();
+ }
+
+ public:
+ std::unique_ptr<ISolidColorBrush> CreateSolidColorBrush() override;
+
+ std::unique_ptr<IGeometryBuilder> CreateGeometryBuilder() override;
+
+ std::unique_ptr<IFont> CreateFont(const std::string_view& font_family,
+ float font_size) override;
+
+ std::unique_ptr<ITextLayout> CreateTextLayout(std::shared_ptr<IFont> font,
+ std::string text) override;
+
+ private:
+ Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device_;
+ Microsoft::WRL::ComPtr<ID2D1Factory1> d2d1_factory_;
+ Microsoft::WRL::ComPtr<ID2D1DeviceContext> d2d1_device_context_;
+ Microsoft::WRL::ComPtr<IDXGIFactory2> dxgi_factory_;
+ Microsoft::WRL::ComPtr<IDWriteFactory> dwrite_factory_;
+ Microsoft::WRL::ComPtr<IDWriteFontCollection> dwrite_system_font_collection_;
+};
+} // namespace cru::platform::graph::win::direct
diff --git a/include/cru/win/graph/direct/font.hpp b/include/cru/win/graph/direct/font.hpp
index d3376503..08213ca5 100644
--- a/include/cru/win/graph/direct/font.hpp
+++ b/include/cru/win/graph/direct/font.hpp
@@ -1,31 +1,28 @@
#pragma once
#include "com_resource.hpp"
-#include "direct_factory.hpp"
-#include "platform_id.hpp"
+#include "resource.hpp"
#include "cru/platform/graph/font.hpp"
#include <string_view>
namespace cru::platform::graph::win::direct {
-
-class DWriteFont : public Font, public IComResource<IDWriteTextFormat> {
+class DWriteFont : public DirectGraphResource,
+ public virtual IFont,
+ public virtual IComResource<IDWriteTextFormat> {
public:
- DWriteFont(IDirectFactory* factory, const std::wstring_view& font_family,
+ DWriteFont(DirectGraphFactory* factory, const std::string_view& font_family,
float font_size);
- DWriteFont(const DWriteFont& other) = delete;
- DWriteFont& operator=(const DWriteFont& other) = delete;
-
- DWriteFont(DWriteFont&& other) = delete;
- DWriteFont& operator=(DWriteFont&& other) = delete;
+ CRU_DELETE_COPY(DWriteFont)
+ CRU_DELETE_MOVE(DWriteFont)
~DWriteFont() override = default;
- CRU_PLATFORMID_IMPLEMENT_DIRECT
-
public:
- IDWriteTextFormat* GetComInterface() const override { return text_format_.Get(); }
+ IDWriteTextFormat* GetComInterface() const override {
+ return text_format_.Get();
+ }
private:
Microsoft::WRL::ComPtr<IDWriteTextFormat> text_format_;
diff --git a/include/cru/win/graph/direct/geometry.hpp b/include/cru/win/graph/direct/geometry.hpp
index 1ee60247..086b31cc 100644
--- a/include/cru/win/graph/direct/geometry.hpp
+++ b/include/cru/win/graph/direct/geometry.hpp
@@ -1,26 +1,20 @@
#pragma once
#include "com_resource.hpp"
-#include "direct_factory.hpp"
-#include "platform_id.hpp"
+#include "resource.hpp"
-#include "cru/platform/exception.hpp"
#include "cru/platform/graph/geometry.hpp"
namespace cru::platform::graph::win::direct {
-class D2DGeometryBuilder : public GeometryBuilder {
+class D2DGeometryBuilder : public DirectGraphResource,
+ public virtual IGeometryBuilder {
public:
- explicit D2DGeometryBuilder(IDirectFactory* factory);
+ explicit D2DGeometryBuilder(DirectGraphFactory* factory);
- D2DGeometryBuilder(const D2DGeometryBuilder& other) = delete;
- D2DGeometryBuilder& operator=(const D2DGeometryBuilder& other) = delete;
-
- D2DGeometryBuilder(D2DGeometryBuilder&& other) = delete;
- D2DGeometryBuilder& operator=(D2DGeometryBuilder&& other) = delete;
+ CRU_DELETE_COPY(D2DGeometryBuilder)
+ CRU_DELETE_MOVE(D2DGeometryBuilder)
~D2DGeometryBuilder() override = default;
- CRU_PLATFORMID_IMPLEMENT_DIRECT
-
public:
void BeginFigure(const Point& point) override;
void LineTo(const Point& point) override;
@@ -28,34 +22,29 @@ class D2DGeometryBuilder : public GeometryBuilder {
const Point& end_point) override;
void CloseFigure(bool close) override;
- Geometry* Build() override;
+ std::unique_ptr<IGeometry> Build() override;
private:
bool IsValid() { return geometry_ != nullptr; }
- void CheckValidation() {
- if (!IsValid())
- throw ReuseException("The geometry builder is already disposed.");
- }
+ void CheckValidation();
private:
Microsoft::WRL::ComPtr<ID2D1PathGeometry> geometry_;
Microsoft::WRL::ComPtr<ID2D1GeometrySink> geometry_sink_;
};
-class D2DGeometry : public Geometry, public IComResource<ID2D1Geometry> {
+class D2DGeometry : public DirectGraphResource,
+ public virtual IGeometry,
+ public IComResource<ID2D1Geometry> {
public:
- explicit D2DGeometry(Microsoft::WRL::ComPtr<ID2D1PathGeometry> geometry);
+ D2DGeometry(DirectGraphFactory* factory,
+ Microsoft::WRL::ComPtr<ID2D1PathGeometry> geometry);
- D2DGeometry(const D2DGeometry& other) = delete;
- D2DGeometry& operator=(const D2DGeometry& other) = delete;
-
- D2DGeometry(D2DGeometry&& other) = delete;
- D2DGeometry& operator=(D2DGeometry&& other) = delete;
+ CRU_DELETE_COPY(D2DGeometry)
+ CRU_DELETE_MOVE(D2DGeometry)
~D2DGeometry() override = default;
- CRU_PLATFORMID_IMPLEMENT_DIRECT
-
public:
ID2D1Geometry* GetComInterface() const override { return geometry_.Get(); }
diff --git a/include/cru/win/graph/direct/graph_factory.hpp b/include/cru/win/graph/direct/graph_factory.hpp
deleted file mode 100644
index fb26a7c5..00000000
--- a/include/cru/win/graph/direct/graph_factory.hpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#pragma once
-#include "direct_factory.hpp"
-#include "platform_id.hpp"
-
-#include "brush.hpp"
-#include "font.hpp"
-#include "geometry.hpp"
-#include "text_layout.hpp"
-
-#include "cru/platform/graph/graph_factory.hpp"
-
-namespace cru::platform::graph::win::direct {
-class DirectGraphFactory : public GraphFactory, public IDirectFactory {
- friend GraphFactory* GraphFactory::CreateInstance();
-
- public:
- static DirectGraphFactory* GetInstance();
-
- private:
- DirectGraphFactory();
-
- public:
- DirectGraphFactory(const DirectGraphFactory& other) = delete;
- DirectGraphFactory& operator=(const DirectGraphFactory& other) = delete;
-
- DirectGraphFactory(DirectGraphFactory&& other) = delete;
- DirectGraphFactory& operator=(DirectGraphFactory&& other) = delete;
-
- ~DirectGraphFactory() override;
-
- CRU_PLATFORMID_IMPLEMENT_DIRECT
-
- public:
- ID2D1Factory1* GetD2D1Factory() const override { return d2d1_factory_.Get(); }
- ID2D1DeviceContext* GetD2D1DeviceContext() const override {
- return d2d1_device_context_.Get();
- }
- ID3D11Device* GetD3D11Device() const override { return d3d11_device_.Get(); }
- IDXGIFactory2* GetDxgiFactory() const override { return dxgi_factory_.Get(); }
- IDWriteFactory* GetDWriteFactory() const override {
- return dwrite_factory_.Get();
- }
- IDWriteFontCollection* GetSystemFontCollection() const override {
- return dwrite_system_font_collection_.Get();
- }
-
- public:
- D2DSolidColorBrush* CreateSolidColorBrush() override;
-
- D2DGeometryBuilder* CreateGeometryBuilder() override;
-
- DWriteFont* CreateFont(const std::wstring_view& font_family,
- float font_size) override;
-
- DWriteTextLayout* CreateTextLayout(std::shared_ptr<Font> font,
- std::wstring text) override;
-
- bool IsAutoDelete() const override { return auto_delete_; }
- void SetAutoDelete(bool value) override { auto_delete_ = value; }
-
- private:
- bool auto_delete_ = false;
-
- Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device_;
- Microsoft::WRL::ComPtr<ID2D1Factory1> d2d1_factory_;
- Microsoft::WRL::ComPtr<ID2D1DeviceContext> d2d1_device_context_;
- Microsoft::WRL::ComPtr<IDXGIFactory2> dxgi_factory_;
- Microsoft::WRL::ComPtr<IDWriteFactory> dwrite_factory_;
- Microsoft::WRL::ComPtr<IDWriteFontCollection> dwrite_system_font_collection_;
-};
-} // namespace cru::platform::graph::win::direct
diff --git a/include/cru/win/graph/direct/painter.hpp b/include/cru/win/graph/direct/painter.hpp
index d8791c7f..5a1fe03f 100644
--- a/include/cru/win/graph/direct/painter.hpp
+++ b/include/cru/win/graph/direct/painter.hpp
@@ -1,24 +1,21 @@
#pragma once
#include "com_resource.hpp"
-#include "platform_id.hpp"
+#include "resource.hpp"
#include "cru/platform/graph/painter.hpp"
namespace cru::platform::graph::win::direct {
-class D2DPainter : public Painter, public IComResource<ID2D1RenderTarget> {
+class D2DPainter : public DirectResource,
+ public virtual IPainter,
+ public virtual IComResource<ID2D1RenderTarget> {
public:
explicit D2DPainter(ID2D1RenderTarget* render_target);
- D2DPainter(const D2DPainter& other) = delete;
- D2DPainter& operator=(const D2DPainter& other) = delete;
-
- D2DPainter(D2DPainter&& other) = delete;
- D2DPainter& operator=(D2DPainter&& other) = delete;
+ CRU_DELETE_COPY(D2DPainter)
+ CRU_DELETE_MOVE(D2DPainter)
~D2DPainter() override = default;
- CRU_PLATFORMID_IMPLEMENT_DIRECT
-
public:
ID2D1RenderTarget* GetComInterface() const override { return render_target_; }
@@ -28,15 +25,15 @@ class D2DPainter : public Painter, public IComResource<ID2D1RenderTarget> {
void Clear(const Color& color) override;
- void StrokeRectangle(const Rect& rectangle, Brush* brush,
+ void StrokeRectangle(const Rect& rectangle, IBrush* brush,
float width) override;
- void FillRectangle(const Rect& rectangle, Brush* brush) override;
+ void FillRectangle(const Rect& rectangle, IBrush* brush) override;
- void StrokeGeometry(Geometry* geometry, Brush* brush, float width) override;
- void FillGeometry(Geometry* geometry, Brush* brush) override;
+ void StrokeGeometry(IGeometry* geometry, IBrush* brush, float width) override;
+ void FillGeometry(IGeometry* geometry, IBrush* brush) override;
- void DrawText(const Point& offset, TextLayout* text_layout,
- Brush* brush) override;
+ void DrawText(const Point& offset, ITextLayout* text_layout,
+ IBrush* brush) override;
void EndDraw() override final;
@@ -45,6 +42,7 @@ class D2DPainter : public Painter, public IComResource<ID2D1RenderTarget> {
private:
bool IsValid() { return is_drawing_; }
+ void CheckValidation();
private:
ID2D1RenderTarget* render_target_;
diff --git a/include/cru/win/graph/direct/platform_id.hpp b/include/cru/win/graph/direct/platform_id.hpp
deleted file mode 100644
index edac38f1..00000000
--- a/include/cru/win/graph/direct/platform_id.hpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-#include <cru/platform/native_resource.hpp>
-
-#include <string_view>
-
-namespace cru::platform::graph::win::direct {
-constexpr std::wstring_view win_direct_platform_id = L"Windows Direct";
-
-inline bool IsDirectResource(NativeResource* resource) {
- return resource->GetPlatformId() == win_direct_platform_id;
-}
-
-} // namespace cru::platform::graph::win::direct
-
-#define CRU_PLATFORMID_IMPLEMENT_DIRECT \
- std::wstring_view GetPlatformId() const override { \
- return ::cru::platform::graph::win::direct::win_direct_platform_id; \
- }
diff --git a/include/cru/win/graph/direct/resource.hpp b/include/cru/win/graph/direct/resource.hpp
new file mode 100644
index 00000000..94a91a40
--- /dev/null
+++ b/include/cru/win/graph/direct/resource.hpp
@@ -0,0 +1,49 @@
+#pragma once
+#include "../../win_pre_config.hpp"
+
+#include "cru/platform/graph/resource.hpp"
+
+#include <string_view>
+
+namespace cru::platform::graph::win::direct {
+class DirectGraphFactory;
+
+class DirectResource : public Object, public virtual INativeResource {
+ public:
+ static constexpr std::string_view k_platform_id = "Windows Direct";
+
+ protected:
+ DirectResource() = default;
+
+ public:
+ CRU_DELETE_COPY(DirectResource)
+ CRU_DELETE_MOVE(DirectResource)
+
+ ~DirectResource() override = default;
+
+ public:
+ std::string_view GetPlatformId() const final { return k_platform_id; }
+};
+
+class DirectGraphResource : public DirectResource,
+ public virtual IGraphResource {
+ protected:
+ // Param factory can't be null.
+ explicit DirectGraphResource(DirectGraphFactory* factory);
+
+ public:
+ CRU_DELETE_COPY(DirectGraphResource)
+ CRU_DELETE_MOVE(DirectGraphResource)
+
+ ~DirectGraphResource() override = default;
+
+ public:
+ IGraphFactory* GetGraphFactory() final;
+
+ public:
+ DirectGraphFactory* GetDirectFactory() const { return factory_; }
+
+ private:
+ DirectGraphFactory* factory_;
+};
+} // namespace cru::platform::graph::win::direct
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;
diff --git a/include/cru/win/native/native_window.hpp b/include/cru/win/native/native_window.hpp
index cba5cc3e..16b14dbf 100644
--- a/include/cru/win/native/native_window.hpp
+++ b/include/cru/win/native/native_window.hpp
@@ -13,7 +13,7 @@ class WindowClass;
class WindowManager;
class WindowRenderTarget;
-class WinNativeWindow : public NativeWindow {
+class WinNativeWindow : public INativeWindow {
public:
WinNativeWindow(WinUiApplication* application,
std::shared_ptr<WindowClass> window_class, DWORD window_style,
diff --git a/include/cru/win/native/platform_id.hpp b/include/cru/win/native/platform_id.hpp
deleted file mode 100644
index e1899ad4..00000000
--- a/include/cru/win/native/platform_id.hpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#pragma once
-#include <cru/platform/native_resource.hpp>
-
-#include <stdexcept>
-#include <string_view>
-
-namespace cru::platform::native::win {
-constexpr std::wstring_view win_platform_id = L"Windows";
-
-inline bool IsWindowsResource(NativeResource* resource) {
- return resource->GetPlatformId() == win_platform_id;
-}
-
-} // namespace cru::platform::native::win
-
-#define CRU_PLATFORMID_IMPLEMENT_WIN \
- std::wstring_view GetPlatformId() const override { \
- return ::cru::platform::native::win::win_platform_id; \
- }
diff --git a/include/cru/win/native/ui_application.hpp b/include/cru/win/native/ui_application.hpp
index addf2c93..94c4b1eb 100644
--- a/include/cru/win/native/ui_application.hpp
+++ b/include/cru/win/native/ui_application.hpp
@@ -44,8 +44,8 @@ class WinUiApplication : public UiApplication {
const std::function<void()>& action) override;
void CancelTimer(unsigned long id) override;
- std::vector<NativeWindow*> GetAllWindow() override;
- NativeWindow* CreateWindow(NativeWindow* parent) override;
+ std::vector<INativeWindow*> GetAllWindow() override;
+ INativeWindow* CreateWindow(INativeWindow* parent) override;
WinCursorManager* GetCursorManager() override;
diff --git a/include/cru/win/string.hpp b/include/cru/win/string.hpp
new file mode 100644
index 00000000..7a12e47e
--- /dev/null
+++ b/include/cru/win/string.hpp
@@ -0,0 +1,10 @@
+#pragma once
+#include "win_pre_config.hpp"
+
+#include <string>
+#include <string_view>
+
+namespace cru::platform::win {
+std::string ToUtf8String(const std::wstring_view& string);
+std::wstring ToUtf16String(const std::string_view& string);
+}