aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/cru/common/PropertyTree.hpp4
-rw-r--r--include/cru/common/String.hpp16
-rw-r--r--include/cru/common/StringUtil.hpp2
-rw-r--r--include/cru/osx/graphics/quartz/Painter.hpp3
-rw-r--r--include/cru/parse/Base.hpp11
-rw-r--r--include/cru/parse/Grammar.hpp2
-rw-r--r--include/cru/parse/Nonterminal.hpp2
-rw-r--r--include/cru/parse/ParsingAlgorithm.hpp2
-rw-r--r--include/cru/parse/ParsingAlgorithmContext.hpp2
-rw-r--r--include/cru/parse/ParsingContext.hpp2
-rw-r--r--include/cru/parse/ParsingTreeNode.hpp2
-rw-r--r--include/cru/parse/Production.hpp2
-rw-r--r--include/cru/parse/RecursiveDescentAlgorithm.hpp2
-rw-r--r--include/cru/parse/RecursiveDescentAlgorithmContext.hpp2
-rw-r--r--include/cru/parse/Symbol.hpp4
-rw-r--r--include/cru/parse/Terminal.hpp2
-rw-r--r--include/cru/parse/TokenType.hpp4
-rw-r--r--include/cru/platform/graphics/Base.hpp11
-rw-r--r--include/cru/platform/graphics/Brush.hpp4
-rw-r--r--include/cru/platform/graphics/Factory.hpp2
-rw-r--r--include/cru/platform/graphics/Font.hpp2
-rw-r--r--include/cru/platform/graphics/Geometry.hpp4
-rw-r--r--include/cru/platform/graphics/NullPainter.hpp53
-rw-r--r--include/cru/platform/graphics/Painter.hpp5
-rw-r--r--include/cru/platform/graphics/Resource.hpp2
-rw-r--r--include/cru/platform/graphics/TextLayout.hpp2
-rw-r--r--include/cru/platform/gui/Window.hpp1
-rw-r--r--include/cru/toml/Base.hpp11
-rw-r--r--include/cru/toml/TomlDocument.hpp6
-rw-r--r--include/cru/toml/TomlParser.hpp4
-rw-r--r--include/cru/win/WinPreConfig.hpp1
-rw-r--r--include/cru/win/graphics/direct/Brush.hpp4
-rw-r--r--include/cru/win/graphics/direct/Factory.hpp15
-rw-r--r--include/cru/win/graphics/direct/Font.hpp6
-rw-r--r--include/cru/win/graphics/direct/Geometry.hpp8
-rw-r--r--include/cru/win/graphics/direct/Painter.hpp10
-rw-r--r--include/cru/win/graphics/direct/Resource.hpp20
-rw-r--r--include/cru/win/graphics/direct/TextLayout.hpp23
-rw-r--r--include/cru/win/graphics/direct/WindowRenderTarget.hpp6
-rw-r--r--include/cru/win/gui/GodWindow.hpp1
-rw-r--r--include/cru/win/gui/InputMethod.hpp6
-rw-r--r--include/cru/win/gui/UiApplication.hpp22
-rw-r--r--include/cru/win/gui/Window.hpp55
-rw-r--r--include/cru/xml/Base.hpp11
-rw-r--r--include/cru/xml/XmlNode.hpp12
-rw-r--r--include/cru/xml/XmlParser.hpp4
46 files changed, 255 insertions, 120 deletions
diff --git a/include/cru/common/PropertyTree.hpp b/include/cru/common/PropertyTree.hpp
index 01b50dac..613bcc47 100644
--- a/include/cru/common/PropertyTree.hpp
+++ b/include/cru/common/PropertyTree.hpp
@@ -8,7 +8,7 @@
namespace cru {
class PropertyTree;
-class PropertySubTreeRef {
+class CRU_BASE_API PropertySubTreeRef {
public:
static String CombineKey(StringView left, StringView right);
@@ -37,7 +37,7 @@ class PropertySubTreeRef {
String path_;
};
-class PropertyTree {
+class CRU_BASE_API PropertyTree {
public:
static String CombineKey(StringView left, StringView right);
diff --git a/include/cru/common/String.hpp b/include/cru/common/String.hpp
index 8acb6a87..dd3da52f 100644
--- a/include/cru/common/String.hpp
+++ b/include/cru/common/String.hpp
@@ -80,6 +80,8 @@ class CRU_BASE_API String {
}
}
+ String(size_type size, value_type ch = 0);
+
String(std::initializer_list<value_type> l);
explicit String(StringView str);
@@ -328,16 +330,16 @@ std::enable_if_t<std::is_integral_v<T>, String> ToString(T value) {
auto result =
std::to_chars(buffer.data(), buffer.data() + buffer.size(), value);
+ if (result.ec == std::errc{}) {
+ } else {
+ throw std::invalid_argument("Failed to convert value to chars.");
+ }
+
auto size = result.ptr - buffer.data();
auto b = new char16_t[size + 1];
b[size] = 0;
std::copy(buffer.data(), result.ptr, b);
return String::FromBuffer(b, size, size);
-
- if (result.ec == std::errc{}) {
- } else {
- throw std::invalid_argument("Failed to convert value to chars.");
- }
}
template <typename T>
@@ -346,7 +348,7 @@ std::enable_if_t<std::is_floating_point_v<T>, String> ToString(T value) {
return String(str.cbegin(), str.cend());
}
-inline String ToString(String value) { return std::move(value); }
+inline String ToString(String value) { return value; }
namespace details {
enum class FormatTokenType { PlaceHolder, Text };
@@ -366,7 +368,7 @@ template <typename TA, typename... T>
void FormatAppendFromFormatTokenList(
String& current, const std::vector<FormatToken>& format_token_list,
Index index, TA&& args0, T&&... args) {
- for (Index i = index; i < format_token_list.size(); i++) {
+ for (Index i = index; i < static_cast<Index>(format_token_list.size()); i++) {
const auto& token = format_token_list[i];
if (token.type == FormatTokenType::PlaceHolder) {
current += ToString(std::forward<TA>(args0));
diff --git a/include/cru/common/StringUtil.hpp b/include/cru/common/StringUtil.hpp
index a0cb6b0b..27ad4b43 100644
--- a/include/cru/common/StringUtil.hpp
+++ b/include/cru/common/StringUtil.hpp
@@ -49,7 +49,7 @@ class CodePointIterator {
struct past_end_tag_t {};
explicit CodePointIterator(const CharType* ptr, Index size, Index current = 0)
- : ptr_(ptr), size_(size), position_(0) {}
+ : ptr_(ptr), size_(size), position_(current) {}
explicit CodePointIterator(const CharType* ptr, Index size, past_end_tag_t)
: ptr_(ptr), size_(size), position_(size) {}
diff --git a/include/cru/osx/graphics/quartz/Painter.hpp b/include/cru/osx/graphics/quartz/Painter.hpp
index 0889d413..83f15516 100644
--- a/include/cru/osx/graphics/quartz/Painter.hpp
+++ b/include/cru/osx/graphics/quartz/Painter.hpp
@@ -40,8 +40,7 @@ class QuartzCGContextPainter : public OsxQuartzResource,
void FillRectangle(const Rect& rectangle, IBrush* brush) override;
void StrokeEllipse(const Rect& outline_rect, IBrush* brush,
float width) override;
- void FillEllipse(const Rect& outline_rect, IBrush* brush,
- float width) override;
+ void FillEllipse(const Rect& outline_rect, IBrush* brush) override;
void StrokeGeometry(IGeometry* geometry, IBrush* brush, float width) override;
void FillGeometry(IGeometry* geometry, IBrush* brush) override;
diff --git a/include/cru/parse/Base.hpp b/include/cru/parse/Base.hpp
new file mode 100644
index 00000000..8f3a05e9
--- /dev/null
+++ b/include/cru/parse/Base.hpp
@@ -0,0 +1,11 @@
+#pragma once
+
+#ifdef CRU_PLATFORM_WINDOWS
+#ifdef CRU_PARSE_EXPORT_API
+#define CRU_PARSE_API __declspec(dllexport)
+#else
+#define CRU_PARSE_API __declspec(dllimport)
+#endif
+#else
+#define CRU_PARSE_API
+#endif
diff --git a/include/cru/parse/Grammar.hpp b/include/cru/parse/Grammar.hpp
index 606fcc33..8dc1833f 100644
--- a/include/cru/parse/Grammar.hpp
+++ b/include/cru/parse/Grammar.hpp
@@ -5,7 +5,7 @@
#include <vector>
namespace cru::parse {
-class Grammar : public Object {
+class CRU_PARSE_API Grammar : public Object {
public:
Grammar();
diff --git a/include/cru/parse/Nonterminal.hpp b/include/cru/parse/Nonterminal.hpp
index 1bc6f9ff..b01c7c8a 100644
--- a/include/cru/parse/Nonterminal.hpp
+++ b/include/cru/parse/Nonterminal.hpp
@@ -2,7 +2,7 @@
#include "Symbol.hpp"
namespace cru::parse {
-class Nonterminal : public Symbol {
+class CRU_PARSE_API Nonterminal : public Symbol {
public:
Nonterminal(Grammar* grammar, String name);
diff --git a/include/cru/parse/ParsingAlgorithm.hpp b/include/cru/parse/ParsingAlgorithm.hpp
index acca159e..8f38c0ab 100644
--- a/include/cru/parse/ParsingAlgorithm.hpp
+++ b/include/cru/parse/ParsingAlgorithm.hpp
@@ -7,7 +7,7 @@ class ParsingAlgorithmContext;
// Represents a parsing algorithm.
// It does not relate to any specific grammar.
// It is used to validate a grammar and create a parsing algorithm context.
-class ParsingAlgorithm {
+class CRU_PARSE_API ParsingAlgorithm {
public:
ParsingAlgorithm() = default;
diff --git a/include/cru/parse/ParsingAlgorithmContext.hpp b/include/cru/parse/ParsingAlgorithmContext.hpp
index f67ccbbc..b959462c 100644
--- a/include/cru/parse/ParsingAlgorithmContext.hpp
+++ b/include/cru/parse/ParsingAlgorithmContext.hpp
@@ -10,7 +10,7 @@ class ParsingAlgorithm;
// A parsing algorithm context contains all data a parsing algorithm needs to
// parse for a grammar. It does not relate to any input. For example, it can
// contain any state machine.
-class ParsingAlgorithmContext {
+class CRU_PARSE_API ParsingAlgorithmContext {
public:
ParsingAlgorithmContext(Grammar* grammar, const ParsingAlgorithm* algorithm);
diff --git a/include/cru/parse/ParsingContext.hpp b/include/cru/parse/ParsingContext.hpp
index ebb7115a..cfb850b9 100644
--- a/include/cru/parse/ParsingContext.hpp
+++ b/include/cru/parse/ParsingContext.hpp
@@ -5,7 +5,7 @@
namespace cru::parse {
// A parsing context contains all info that a program needs to know when parsing
// a input sequence of terminals.
-class ParsingContext {
+class CRU_PARSE_API ParsingContext {
public:
ParsingContext(const ParsingAlgorithmContext* parsing_algorithm_context,
std::vector<Terminal*> input);
diff --git a/include/cru/parse/ParsingTreeNode.hpp b/include/cru/parse/ParsingTreeNode.hpp
index d1c3d058..7119ca0b 100644
--- a/include/cru/parse/ParsingTreeNode.hpp
+++ b/include/cru/parse/ParsingTreeNode.hpp
@@ -4,7 +4,7 @@
#include <vector>
namespace cru::parse {
-class ParsingTreeNode {
+class CRU_PARSE_API ParsingTreeNode {
public:
ParsingTreeNode(Symbol* symbol, Production* production);
diff --git a/include/cru/parse/Production.hpp b/include/cru/parse/Production.hpp
index 8a1331b9..cb3c79c0 100644
--- a/include/cru/parse/Production.hpp
+++ b/include/cru/parse/Production.hpp
@@ -7,7 +7,7 @@
#include <vector>
namespace cru::parse {
-class Production : public Object {
+class CRU_PARSE_API Production : public Object {
public:
Production(Grammar* grammar, String name, Nonterminal* left,
std::vector<Symbol*> right);
diff --git a/include/cru/parse/RecursiveDescentAlgorithm.hpp b/include/cru/parse/RecursiveDescentAlgorithm.hpp
index c12a84f6..373724ea 100644
--- a/include/cru/parse/RecursiveDescentAlgorithm.hpp
+++ b/include/cru/parse/RecursiveDescentAlgorithm.hpp
@@ -3,7 +3,7 @@
#include "ParsingAlgorithm.hpp"
namespace cru::parse {
-class RecursiveDescentAlgorithm : public ParsingAlgorithm {
+class CRU_PARSE_API RecursiveDescentAlgorithm : public ParsingAlgorithm {
public:
RecursiveDescentAlgorithm() = default;
diff --git a/include/cru/parse/RecursiveDescentAlgorithmContext.hpp b/include/cru/parse/RecursiveDescentAlgorithmContext.hpp
index 1b888da9..b29ee1a1 100644
--- a/include/cru/parse/RecursiveDescentAlgorithmContext.hpp
+++ b/include/cru/parse/RecursiveDescentAlgorithmContext.hpp
@@ -6,7 +6,7 @@
#include "cru/parse/Terminal.hpp"
namespace cru::parse {
-class RecursiveDescentAlgorithmContext : public ParsingAlgorithmContext {
+class CRU_PARSE_API RecursiveDescentAlgorithmContext : public ParsingAlgorithmContext {
public:
RecursiveDescentAlgorithmContext(Grammar* grammar,
const RecursiveDescentAlgorithm* algorithm);
diff --git a/include/cru/parse/Symbol.hpp b/include/cru/parse/Symbol.hpp
index e22fb9bc..7404a5e7 100644
--- a/include/cru/parse/Symbol.hpp
+++ b/include/cru/parse/Symbol.hpp
@@ -1,11 +1,13 @@
#pragma once
+#include "Base.hpp"
+
#include "cru/common/String.hpp"
namespace cru::parse {
class Grammar;
// Base class of Terminal and Nonterminal.
-class Symbol : public Object {
+class CRU_PARSE_API Symbol : public Object {
public:
explicit Symbol(Grammar* grammar, String name);
diff --git a/include/cru/parse/Terminal.hpp b/include/cru/parse/Terminal.hpp
index 8d4a31b6..4ff8f898 100644
--- a/include/cru/parse/Terminal.hpp
+++ b/include/cru/parse/Terminal.hpp
@@ -2,7 +2,7 @@
#include "Symbol.hpp"
namespace cru::parse {
-class Terminal : public Symbol {
+class CRU_PARSE_API Terminal : public Symbol {
public:
Terminal(Grammar* grammar, String name);
diff --git a/include/cru/parse/TokenType.hpp b/include/cru/parse/TokenType.hpp
index 54bdf712..49415d3b 100644
--- a/include/cru/parse/TokenType.hpp
+++ b/include/cru/parse/TokenType.hpp
@@ -1,9 +1,11 @@
#pragma once
+#include "Base.hpp"
+
#include "cru/common/Base.hpp"
#include "cru/common/String.hpp"
namespace cru::parse {
-class TokenType : public Object {
+class CRU_PARSE_API TokenType : public Object {
public:
explicit TokenType(String name);
diff --git a/include/cru/platform/graphics/Base.hpp b/include/cru/platform/graphics/Base.hpp
index 26ae725a..3a18e39d 100644
--- a/include/cru/platform/graphics/Base.hpp
+++ b/include/cru/platform/graphics/Base.hpp
@@ -6,6 +6,17 @@
#include <memory>
+#ifdef CRU_PLATFORM_WINDOWS
+#ifdef CRU_PLATFORM_GRAPHICS_EXPORT_API
+#define CRU_PLATFORM_GRAPHICS_API __declspec(dllexport)
+#else
+#define CRU_PLATFORM_GRAPHICS_API __declspec(dllimport)
+#endif
+#else
+#define CRU_PLATFORM_GRAPHICS_API
+#endif
+
+
namespace cru::platform::graphics {
// forward declarations
struct IGraphicsFactory;
diff --git a/include/cru/platform/graphics/Brush.hpp b/include/cru/platform/graphics/Brush.hpp
index aa21f79d..772edd5c 100644
--- a/include/cru/platform/graphics/Brush.hpp
+++ b/include/cru/platform/graphics/Brush.hpp
@@ -2,9 +2,9 @@
#include "Resource.hpp"
namespace cru::platform::graphics {
-struct IBrush : virtual IGraphicsResource {};
+struct CRU_PLATFORM_GRAPHICS_API IBrush : virtual IGraphicsResource {};
-struct ISolidColorBrush : virtual IBrush {
+struct CRU_PLATFORM_GRAPHICS_API ISolidColorBrush : virtual IBrush {
virtual Color GetColor() = 0;
virtual void SetColor(const Color& color) = 0;
};
diff --git a/include/cru/platform/graphics/Factory.hpp b/include/cru/platform/graphics/Factory.hpp
index b79e1c4f..f3802651 100644
--- a/include/cru/platform/graphics/Factory.hpp
+++ b/include/cru/platform/graphics/Factory.hpp
@@ -8,7 +8,7 @@
namespace cru::platform::graphics {
// Entry point of the graphics module.
-struct IGraphicsFactory : virtual IPlatformResource {
+struct CRU_PLATFORM_GRAPHICS_API IGraphicsFactory : virtual IPlatformResource {
virtual std::unique_ptr<ISolidColorBrush> CreateSolidColorBrush() = 0;
virtual std::unique_ptr<IGeometryBuilder> CreateGeometryBuilder() = 0;
diff --git a/include/cru/platform/graphics/Font.hpp b/include/cru/platform/graphics/Font.hpp
index e1a419eb..2d1bc9a6 100644
--- a/include/cru/platform/graphics/Font.hpp
+++ b/include/cru/platform/graphics/Font.hpp
@@ -2,7 +2,7 @@
#include "Resource.hpp"
namespace cru::platform::graphics {
-struct IFont : virtual IGraphicsResource {
+struct CRU_PLATFORM_GRAPHICS_API IFont : virtual IGraphicsResource {
virtual float GetFontSize() = 0;
};
} // namespace cru::platform::graphics
diff --git a/include/cru/platform/graphics/Geometry.hpp b/include/cru/platform/graphics/Geometry.hpp
index f01132fb..e83d1c51 100644
--- a/include/cru/platform/graphics/Geometry.hpp
+++ b/include/cru/platform/graphics/Geometry.hpp
@@ -2,13 +2,13 @@
#include "Resource.hpp"
namespace cru::platform::graphics {
-struct IGeometry : virtual IGraphicsResource {
+struct CRU_PLATFORM_GRAPHICS_API IGeometry : virtual IGraphicsResource {
virtual bool FillContains(const Point& point) = 0;
};
// After called Build, calling every method will throw a
-struct IGeometryBuilder : virtual IGraphicsResource {
+struct CRU_PLATFORM_GRAPHICS_API IGeometryBuilder : virtual IGraphicsResource {
virtual void BeginFigure(const Point& point) = 0;
virtual void LineTo(const Point& point) = 0;
virtual void QuadraticBezierTo(const Point& control_point,
diff --git a/include/cru/platform/graphics/NullPainter.hpp b/include/cru/platform/graphics/NullPainter.hpp
index cf790ccf..b5c796d3 100644
--- a/include/cru/platform/graphics/NullPainter.hpp
+++ b/include/cru/platform/graphics/NullPainter.hpp
@@ -1,8 +1,9 @@
#pragma once
#include "Painter.hpp"
+#include "cru/common/Base.hpp"
namespace cru::platform::graphics {
-class NullPainter : public Object, public virtual IPainter {
+class CRU_PLATFORM_GRAPHICS_API NullPainter : public Object, public virtual IPainter {
public:
NullPainter() = default;
@@ -17,30 +18,54 @@ class NullPainter : public Object, public virtual IPainter {
String GetDebugString() override { return u"NullPainter"; }
Matrix GetTransform() override { return Matrix(); }
- void SetTransform(const Matrix& matrix) override {}
+ void SetTransform(const Matrix& matrix) override { CRU_UNUSED(matrix) }
- void ConcatTransform(const Matrix& matrix) override {}
+ void ConcatTransform(const Matrix& matrix) override { CRU_UNUSED(matrix) }
- void Clear(const Color& color) override {}
+ void Clear(const Color& color) override { CRU_UNUSED(color) }
void DrawLine(const Point& start, const Point& end, IBrush* brush,
- float width) override{};
+ float width) override {
+ CRU_UNUSED(start) CRU_UNUSED(end) CRU_UNUSED(brush) CRU_UNUSED(width)
+ }
void StrokeRectangle(const Rect& rectangle, IBrush* brush,
- float width) override {}
- void FillRectangle(const Rect& rectangle, IBrush* brush) override {}
+ float width) override {
+ CRU_UNUSED(rectangle) CRU_UNUSED(brush) CRU_UNUSED(width)
+ }
+ void FillRectangle(const Rect& rectangle, IBrush* brush) override {
+ CRU_UNUSED(rectangle)
+ CRU_UNUSED(brush)
+ }
void StrokeEllipse(const Rect& outline_rect, IBrush* brush,
- float width) override {}
- void FillEllipse(const Rect& outline_rect, IBrush* brush,
- float width) override {}
+ float width) override {
+ CRU_UNUSED(outline_rect)
+ CRU_UNUSED(brush)
+ CRU_UNUSED(width)
+ }
+ void FillEllipse(const Rect& outline_rect, IBrush* brush) override {
+ CRU_UNUSED(outline_rect)
+ CRU_UNUSED(brush)
+ }
void StrokeGeometry(IGeometry* geometry, IBrush* brush,
- float width) override {}
- void FillGeometry(IGeometry* geometry, IBrush* brush) override {}
+ float width) override {
+ CRU_UNUSED(geometry)
+ CRU_UNUSED(brush)
+ CRU_UNUSED(width)
+ }
+ void FillGeometry(IGeometry* geometry, IBrush* brush) override {
+ CRU_UNUSED(geometry)
+ CRU_UNUSED(brush)
+ }
void DrawText(const Point& offset, ITextLayout* text_layout,
- IBrush* brush) override {}
+ IBrush* brush) override {
+ CRU_UNUSED(offset)
+ CRU_UNUSED(text_layout)
+ CRU_UNUSED(brush)
+ }
- void PushLayer(const Rect& bounds) override{};
+ void PushLayer(const Rect& bounds) override { CRU_UNUSED(bounds) }
void PopLayer() override {}
diff --git a/include/cru/platform/graphics/Painter.hpp b/include/cru/platform/graphics/Painter.hpp
index 4f1724ec..4104a752 100644
--- a/include/cru/platform/graphics/Painter.hpp
+++ b/include/cru/platform/graphics/Painter.hpp
@@ -3,7 +3,7 @@
namespace cru::platform::graphics {
-struct IPainter : virtual IPlatformResource {
+struct CRU_PLATFORM_GRAPHICS_API IPainter : virtual IPlatformResource {
virtual Matrix GetTransform() = 0;
virtual void SetTransform(const Matrix& matrix) = 0;
@@ -18,8 +18,7 @@ struct IPainter : virtual IPlatformResource {
virtual void FillRectangle(const Rect& rectangle, IBrush* brush) = 0;
virtual void StrokeEllipse(const Rect& outline_rect, IBrush* brush,
float width) = 0;
- virtual void FillEllipse(const Rect& outline_rect, IBrush* brush,
- float width) = 0;
+ virtual void FillEllipse(const Rect& outline_rect, IBrush* brush) = 0;
virtual void StrokeGeometry(IGeometry* geometry, IBrush* brush,
float width) = 0;
diff --git a/include/cru/platform/graphics/Resource.hpp b/include/cru/platform/graphics/Resource.hpp
index cd1e5283..e559b0e9 100644
--- a/include/cru/platform/graphics/Resource.hpp
+++ b/include/cru/platform/graphics/Resource.hpp
@@ -4,7 +4,7 @@
namespace cru::platform::graphics {
struct IGraphicsFactory;
-struct IGraphicsResource : virtual IPlatformResource {
+struct CRU_PLATFORM_GRAPHICS_API IGraphicsResource : virtual IPlatformResource {
virtual IGraphicsFactory* GetGraphicsFactory() = 0;
};
} // namespace cru::platform::graphics
diff --git a/include/cru/platform/graphics/TextLayout.hpp b/include/cru/platform/graphics/TextLayout.hpp
index a040ec3b..f9ccc824 100644
--- a/include/cru/platform/graphics/TextLayout.hpp
+++ b/include/cru/platform/graphics/TextLayout.hpp
@@ -7,7 +7,7 @@
namespace cru::platform::graphics {
// Requirement:
// All text must be left-top aligned.
-struct ITextLayout : virtual IGraphicsResource {
+struct CRU_PLATFORM_GRAPHICS_API ITextLayout : virtual IGraphicsResource {
virtual String GetText() = 0;
virtual void SetText(String new_text) = 0;
diff --git a/include/cru/platform/gui/Window.hpp b/include/cru/platform/gui/Window.hpp
index bab5e8fe..9f17b976 100644
--- a/include/cru/platform/gui/Window.hpp
+++ b/include/cru/platform/gui/Window.hpp
@@ -85,7 +85,6 @@ struct INativeWindow : virtual IPlatformResource {
// Remember to call EndDraw on return value and destroy it.
virtual std::unique_ptr<graphics::IPainter> BeginPaint() = 0;
- // Don't use this instance after receive this event.
virtual IEvent<std::nullptr_t>* CreateEvent() = 0;
virtual IEvent<std::nullptr_t>* DestroyEvent() = 0;
virtual IEvent<std::nullptr_t>* PaintEvent() = 0;
diff --git a/include/cru/toml/Base.hpp b/include/cru/toml/Base.hpp
new file mode 100644
index 00000000..de1d558c
--- /dev/null
+++ b/include/cru/toml/Base.hpp
@@ -0,0 +1,11 @@
+#pragma once
+
+#ifdef CRU_PLATFORM_WINDOWS
+#ifdef CRU_TOML_EXPORT_API
+#define CRU_TOML_API __declspec(dllexport)
+#else
+#define CRU_TOML_API __declspec(dllimport)
+#endif
+#else
+#define CRU_TOML_API
+#endif
diff --git a/include/cru/toml/TomlDocument.hpp b/include/cru/toml/TomlDocument.hpp
index 637690f7..1e5caf71 100644
--- a/include/cru/toml/TomlDocument.hpp
+++ b/include/cru/toml/TomlDocument.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "Base.hpp"
+
#include "cru/common/Base.hpp"
#include "cru/common/String.hpp"
@@ -7,7 +9,7 @@
#include <unordered_map>
namespace cru::toml {
-class TomlSection {
+class CRU_TOML_API TomlSection {
public:
CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(TomlSection)
CRU_DEFAULT_COPY(TomlSection)
@@ -29,7 +31,7 @@ class TomlSection {
std::unordered_map<String, String> values_;
};
-class TomlDocument {
+class CRU_TOML_API TomlDocument {
public:
CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(TomlDocument)
CRU_DEFAULT_COPY(TomlDocument)
diff --git a/include/cru/toml/TomlParser.hpp b/include/cru/toml/TomlParser.hpp
index 52332506..c3091bad 100644
--- a/include/cru/toml/TomlParser.hpp
+++ b/include/cru/toml/TomlParser.hpp
@@ -7,12 +7,12 @@
namespace cru::toml {
// A very simple and tolerant TOML parser.
-class TomlParsingException : public Exception {
+class CRU_TOML_API TomlParsingException : public Exception {
public:
using Exception::Exception;
};
-class TomlParser {
+class CRU_TOML_API TomlParser {
public:
explicit TomlParser(String input);
diff --git a/include/cru/win/WinPreConfig.hpp b/include/cru/win/WinPreConfig.hpp
index 1613da95..1bd494f2 100644
--- a/include/cru/win/WinPreConfig.hpp
+++ b/include/cru/win/WinPreConfig.hpp
@@ -8,6 +8,7 @@
#undef CreateWindow
#undef DrawText
#undef CreateFont
+#undef CreateEvent
#include <d2d1_2.h>
#include <d3d11.h>
diff --git a/include/cru/win/graphics/direct/Brush.hpp b/include/cru/win/graphics/direct/Brush.hpp
index fbff83b5..9d8e5384 100644
--- a/include/cru/win/graphics/direct/Brush.hpp
+++ b/include/cru/win/graphics/direct/Brush.hpp
@@ -9,12 +9,12 @@ struct ID2DBrush : virtual IBrush {
virtual ID2D1Brush* GetD2DBrushInterface() const = 0;
};
-class D2DSolidColorBrush : public DirectGraphResource,
+class D2DSolidColorBrush : public DirectGraphicsResource,
public virtual ISolidColorBrush,
public virtual ID2DBrush,
public virtual IComResource<ID2D1SolidColorBrush> {
public:
- explicit D2DSolidColorBrush(DirectGraphFactory* factory);
+ explicit D2DSolidColorBrush(DirectGraphicsFactory* factory);
CRU_DELETE_COPY(D2DSolidColorBrush)
CRU_DELETE_MOVE(D2DSolidColorBrush)
diff --git a/include/cru/win/graphics/direct/Factory.hpp b/include/cru/win/graphics/direct/Factory.hpp
index 70f3ede1..efcebba7 100644
--- a/include/cru/win/graphics/direct/Factory.hpp
+++ b/include/cru/win/graphics/direct/Factory.hpp
@@ -4,14 +4,15 @@
#include "cru/platform/graphics/Factory.hpp"
namespace cru::platform::graphics::win::direct {
-class DirectGraphFactory : public DirectResource, public virtual IGraphFactory {
+class DirectGraphicsFactory : public DirectResource,
+ public virtual IGraphicsFactory {
public:
- DirectGraphFactory();
+ DirectGraphicsFactory();
- CRU_DELETE_COPY(DirectGraphFactory)
- CRU_DELETE_MOVE(DirectGraphFactory)
+ CRU_DELETE_COPY(DirectGraphicsFactory)
+ CRU_DELETE_MOVE(DirectGraphicsFactory)
- ~DirectGraphFactory() override;
+ ~DirectGraphicsFactory() override;
public:
ID3D11Device* GetD3D11Device() const { return d3d11_device_.Get(); }
@@ -38,11 +39,11 @@ class DirectGraphFactory : public DirectResource, public virtual IGraphFactory {
std::unique_ptr<IGeometryBuilder> CreateGeometryBuilder() override;
- std::unique_ptr<IFont> CreateFont(std::u16string font_family,
+ std::unique_ptr<IFont> CreateFont(String font_family,
float font_size) override;
std::unique_ptr<ITextLayout> CreateTextLayout(std::shared_ptr<IFont> font,
- std::u16string text) override;
+ String text) override;
private:
Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device_;
diff --git a/include/cru/win/graphics/direct/Font.hpp b/include/cru/win/graphics/direct/Font.hpp
index fd3921a3..3cd94f82 100644
--- a/include/cru/win/graphics/direct/Font.hpp
+++ b/include/cru/win/graphics/direct/Font.hpp
@@ -7,11 +7,11 @@
#include <string_view>
namespace cru::platform::graphics::win::direct {
-class DWriteFont : public DirectGraphResource,
+class DWriteFont : public DirectGraphicsResource,
public virtual IFont,
public virtual IComResource<IDWriteTextFormat> {
public:
- DWriteFont(DirectGraphFactory* factory, std::u16string font_family,
+ DWriteFont(DirectGraphicsFactory* factory, String font_family,
float font_size);
CRU_DELETE_COPY(DWriteFont)
@@ -27,7 +27,7 @@ class DWriteFont : public DirectGraphResource,
float GetFontSize() override;
private:
- std::u16string font_family_;
+ String font_family_;
Microsoft::WRL::ComPtr<IDWriteTextFormat> text_format_;
};
} // namespace cru::platform::graphics::win::direct
diff --git a/include/cru/win/graphics/direct/Geometry.hpp b/include/cru/win/graphics/direct/Geometry.hpp
index edfec590..b3b82f9c 100644
--- a/include/cru/win/graphics/direct/Geometry.hpp
+++ b/include/cru/win/graphics/direct/Geometry.hpp
@@ -5,10 +5,10 @@
#include "cru/platform/graphics/Geometry.hpp"
namespace cru::platform::graphics::win::direct {
-class D2DGeometryBuilder : public DirectGraphResource,
+class D2DGeometryBuilder : public DirectGraphicsResource,
public virtual IGeometryBuilder {
public:
- explicit D2DGeometryBuilder(DirectGraphFactory* factory);
+ explicit D2DGeometryBuilder(DirectGraphicsFactory* factory);
CRU_DELETE_COPY(D2DGeometryBuilder)
CRU_DELETE_MOVE(D2DGeometryBuilder)
@@ -33,11 +33,11 @@ class D2DGeometryBuilder : public DirectGraphResource,
Microsoft::WRL::ComPtr<ID2D1GeometrySink> geometry_sink_;
};
-class D2DGeometry : public DirectGraphResource,
+class D2DGeometry : public DirectGraphicsResource,
public virtual IGeometry,
public IComResource<ID2D1Geometry> {
public:
- D2DGeometry(DirectGraphFactory* factory,
+ D2DGeometry(DirectGraphicsFactory* factory,
Microsoft::WRL::ComPtr<ID2D1PathGeometry> geometry);
CRU_DELETE_COPY(D2DGeometry)
diff --git a/include/cru/win/graphics/direct/Painter.hpp b/include/cru/win/graphics/direct/Painter.hpp
index b34c1563..d7b90d19 100644
--- a/include/cru/win/graphics/direct/Painter.hpp
+++ b/include/cru/win/graphics/direct/Painter.hpp
@@ -24,6 +24,7 @@ class D2DPainter : public DirectResource,
public:
Matrix GetTransform() override;
void SetTransform(const platform::Matrix& matrix) override;
+ void ConcatTransform(const Matrix& matrix) override;
void Clear(const Color& color) override;
@@ -32,6 +33,9 @@ class D2DPainter : public DirectResource,
void StrokeRectangle(const Rect& rectangle, IBrush* brush,
float width) override;
void FillRectangle(const Rect& rectangle, IBrush* brush) override;
+ void StrokeEllipse(const Rect& outline_rect, IBrush* brush,
+ float width) override;
+ void FillEllipse(const Rect& outline_rect, IBrush* brush) override;
void StrokeGeometry(IGeometry* geometry, IBrush* brush, float width) override;
void FillGeometry(IGeometry* geometry, IBrush* brush) override;
@@ -40,9 +44,11 @@ class D2DPainter : public DirectResource,
IBrush* brush) override;
void PushLayer(const Rect& bounds) override;
-
void PopLayer() override;
+ void PushState() override;
+ void PopState() override;
+
void EndDraw() override final;
protected:
@@ -56,6 +62,8 @@ class D2DPainter : public DirectResource,
ID2D1RenderTarget* render_target_;
std::vector<Microsoft::WRL::ComPtr<ID2D1Layer>> layers_;
+ std::vector<Microsoft::WRL::ComPtr<ID2D1DrawingStateBlock>>
+ drawing_state_stack_;
bool is_drawing_ = true;
};
diff --git a/include/cru/win/graphics/direct/Resource.hpp b/include/cru/win/graphics/direct/Resource.hpp
index e6ffb203..c376628d 100644
--- a/include/cru/win/graphics/direct/Resource.hpp
+++ b/include/cru/win/graphics/direct/Resource.hpp
@@ -6,7 +6,7 @@
#include <string_view>
namespace cru::platform::graphics::win::direct {
-class DirectGraphFactory;
+class DirectGraphicsFactory;
class DirectResource : public Object, public virtual IPlatformResource {
public:
@@ -25,25 +25,25 @@ class DirectResource : public Object, public virtual IPlatformResource {
String GetPlatformId() const final { return kPlatformId; }
};
-class DirectGraphResource : public DirectResource,
- public virtual IGraphResource {
+class DirectGraphicsResource : public DirectResource,
+ public virtual IGraphicsResource {
protected:
// Param factory can't be null.
- explicit DirectGraphResource(DirectGraphFactory* factory);
+ explicit DirectGraphicsResource(DirectGraphicsFactory* factory);
public:
- CRU_DELETE_COPY(DirectGraphResource)
- CRU_DELETE_MOVE(DirectGraphResource)
+ CRU_DELETE_COPY(DirectGraphicsResource)
+ CRU_DELETE_MOVE(DirectGraphicsResource)
- ~DirectGraphResource() override = default;
+ ~DirectGraphicsResource() override = default;
public:
- IGraphFactory* GetGraphFactory() final;
+ IGraphicsFactory* GetGraphicsFactory() final;
public:
- DirectGraphFactory* GetDirectFactory() const { return factory_; }
+ DirectGraphicsFactory* GetDirectFactory() const { return factory_; }
private:
- DirectGraphFactory* factory_;
+ DirectGraphicsFactory* factory_;
};
} // namespace cru::platform::graphics::win::direct
diff --git a/include/cru/win/graphics/direct/TextLayout.hpp b/include/cru/win/graphics/direct/TextLayout.hpp
index aa040278..b1843dd7 100644
--- a/include/cru/win/graphics/direct/TextLayout.hpp
+++ b/include/cru/win/graphics/direct/TextLayout.hpp
@@ -10,12 +10,12 @@
namespace cru::platform::graphics::win::direct {
class DWriteFont;
-class DWriteTextLayout : public DirectGraphResource,
+class DWriteTextLayout : public DirectGraphicsResource,
public virtual ITextLayout,
public virtual IComResource<IDWriteTextLayout> {
public:
- DWriteTextLayout(DirectGraphFactory* factory, std::shared_ptr<IFont> font,
- std::u16string text);
+ DWriteTextLayout(DirectGraphicsFactory* factory, std::shared_ptr<IFont> font,
+ String text);
CRU_DELETE_COPY(DWriteTextLayout)
CRU_DELETE_MOVE(DWriteTextLayout)
@@ -28,9 +28,8 @@ class DWriteTextLayout : public DirectGraphResource,
}
public:
- std::u16string GetText() override;
- std::u16string_view GetTextView() override;
- void SetText(std::u16string new_text) override;
+ String GetText() override;
+ void SetText(String new_text) override;
std::shared_ptr<IFont> GetFont() override;
void SetFont(std::shared_ptr<IFont> font) override;
@@ -38,15 +37,23 @@ class DWriteTextLayout : public DirectGraphResource,
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;
- Point TextSinglePoint(Index position, bool trailing) override;
+ Rect TextSinglePoint(Index position, bool trailing) override;
TextHitTestResult HitTest(const Point& point) override;
private:
- std::u16string text_;
+ bool edit_mode_ = false;
+ String text_;
std::shared_ptr<DWriteFont> font_;
float max_width_ = std::numeric_limits<float>::max();
float max_height_ = std::numeric_limits<float>::max();
diff --git a/include/cru/win/graphics/direct/WindowRenderTarget.hpp b/include/cru/win/graphics/direct/WindowRenderTarget.hpp
index 75b1bf20..c197841d 100644
--- a/include/cru/win/graphics/direct/WindowRenderTarget.hpp
+++ b/include/cru/win/graphics/direct/WindowRenderTarget.hpp
@@ -5,7 +5,7 @@ namespace cru::platform::graphics::win::direct {
// Represents a window render target.
class D2DWindowRenderTarget : public Object {
public:
- D2DWindowRenderTarget(gsl::not_null<DirectGraphFactory*> factory, HWND hwnd);
+ D2DWindowRenderTarget(gsl::not_null<DirectGraphicsFactory*> factory, HWND hwnd);
CRU_DELETE_COPY(D2DWindowRenderTarget)
CRU_DELETE_MOVE(D2DWindowRenderTarget)
@@ -13,7 +13,7 @@ class D2DWindowRenderTarget : public Object {
~D2DWindowRenderTarget() override = default;
public:
- graphics::win::direct::DirectGraphFactory* GetDirectFactory() const {
+ graphics::win::direct::DirectGraphicsFactory* GetDirectFactory() const {
return factory_;
}
@@ -33,7 +33,7 @@ class D2DWindowRenderTarget : public Object {
void CreateTargetBitmap();
private:
- DirectGraphFactory* factory_;
+ DirectGraphicsFactory* factory_;
HWND hwnd_;
Microsoft::WRL::ComPtr<ID2D1DeviceContext> d2d1_device_context_;
Microsoft::WRL::ComPtr<IDXGISwapChain1> dxgi_swap_chain_;
diff --git a/include/cru/win/gui/GodWindow.hpp b/include/cru/win/gui/GodWindow.hpp
index 0343b159..d9a128e6 100644
--- a/include/cru/win/gui/GodWindow.hpp
+++ b/include/cru/win/gui/GodWindow.hpp
@@ -3,6 +3,7 @@
#include "WindowNativeMessageEventArgs.hpp"
#include "cru/common/Event.hpp"
+#include "cru/common/String.hpp"
#include <memory>
diff --git a/include/cru/win/gui/InputMethod.hpp b/include/cru/win/gui/InputMethod.hpp
index 51a007d8..3784dcda 100644
--- a/include/cru/win/gui/InputMethod.hpp
+++ b/include/cru/win/gui/InputMethod.hpp
@@ -65,12 +65,12 @@ class WinInputMethodContext : public WinNativeResource,
IEvent<std::nullptr_t>* CompositionEvent() override;
- IEvent<std::u16string_view>* TextEvent() override;
+ IEvent<StringView>* TextEvent() override;
private:
void OnWindowNativeMessage(WindowNativeMessageEventArgs& args);
- std::u16string GetResultString();
+ String GetResultString();
AutoHIMC GetHIMC();
@@ -82,6 +82,6 @@ class WinInputMethodContext : public WinNativeResource,
Event<std::nullptr_t> composition_start_event_;
Event<std::nullptr_t> composition_end_event_;
Event<std::nullptr_t> composition_event_;
- Event<std::u16string_view> text_event_;
+ Event<StringView> text_event_;
};
} // namespace cru::platform::gui::win
diff --git a/include/cru/win/gui/UiApplication.hpp b/include/cru/win/gui/UiApplication.hpp
index 4cf46858..4b972fee 100644
--- a/include/cru/win/gui/UiApplication.hpp
+++ b/include/cru/win/gui/UiApplication.hpp
@@ -7,7 +7,7 @@
#include <memory>
namespace cru::platform::graphics::win::direct {
-class DirectGraphFactory;
+class DirectGraphicsFactory;
}
namespace cru::platform::gui::win {
@@ -33,6 +33,13 @@ class WinUiApplication : public WinNativeResource,
void AddOnQuitHandler(std::function<void()> handler) override;
+ bool IsQuitOnAllWindowClosed() override {
+ return is_quit_on_all_window_closed_;
+ }
+ void SetQuitOnAllWindowClosed(bool quit_on_all_window_closed) override {
+ is_quit_on_all_window_closed_ = quit_on_all_window_closed;
+ }
+
long long SetImmediate(std::function<void()> action) override;
long long SetTimeout(std::chrono::milliseconds milliseconds,
std::function<void()> action) override;
@@ -41,16 +48,19 @@ class WinUiApplication : public WinNativeResource,
void CancelTimer(long long id) override;
std::vector<INativeWindow*> GetAllWindow() override;
- INativeWindow* CreateWindow(INativeWindow* parent, CreateWindowFlag flag) override;
+ INativeWindow* CreateWindow() override;
- cru::platform::graphics::IGraphFactory* GetGraphFactory() override;
+ cru::platform::graphics::IGraphicsFactory* GetGraphicsFactory() override;
- cru::platform::graphics::win::direct::DirectGraphFactory* GetDirectFactory() {
+ cru::platform::graphics::win::direct::DirectGraphicsFactory*
+ GetDirectFactory() {
return graph_factory_.get();
}
ICursorManager* GetCursorManager() override;
+ IClipboard* GetClipboard() override;
+
HINSTANCE GetInstanceHandle() const { return instance_handle_; }
GodWindow* GetGodWindow() const { return god_window_.get(); }
@@ -60,7 +70,9 @@ class WinUiApplication : public WinNativeResource,
private:
HINSTANCE instance_handle_;
- std::unique_ptr<cru::platform::graphics::win::direct::DirectGraphFactory>
+ bool is_quit_on_all_window_closed_ = true;
+
+ std::unique_ptr<cru::platform::graphics::win::direct::DirectGraphicsFactory>
graph_factory_;
std::unique_ptr<GodWindow> god_window_;
diff --git a/include/cru/win/gui/Window.hpp b/include/cru/win/gui/Window.hpp
index 97a74fa7..41eac5fa 100644
--- a/include/cru/win/gui/Window.hpp
+++ b/include/cru/win/gui/Window.hpp
@@ -2,7 +2,6 @@
#include "Resource.hpp"
#include "WindowNativeMessageEventArgs.hpp"
-#include "cru/platform/GraphBase.hpp"
#include "cru/platform/gui/Base.hpp"
#include "cru/platform/gui/Window.hpp"
#include "cru/win/graphics/direct/WindowRenderTarget.hpp"
@@ -14,8 +13,7 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
CRU_DEFINE_CLASS_LOG_TAG(u"cru::platform::gui::win::WinNativeWindow")
public:
- WinNativeWindow(WinUiApplication* application, WindowClass* window_class,
- DWORD window_style, WinNativeWindow* parent);
+ explicit WinNativeWindow(WinUiApplication* application);
CRU_DELETE_COPY(WinNativeWindow)
CRU_DELETE_MOVE(WinNativeWindow)
@@ -26,13 +24,20 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
void Close() override;
WinNativeWindow* GetParent() override { return parent_window_; }
+ void SetParent(INativeWindow* parent) override;
- bool IsVisible() override;
- void SetVisible(bool is_visible) override;
+ WindowStyleFlag GetStyleFlag() override { return style_flag_; }
+ void SetStyleFlag(WindowStyleFlag flag) override;
+
+ WindowVisibilityType GetVisibility() override { return visibility_; }
+ void SetVisibility(WindowVisibilityType visibility) override;
Size GetClientSize() override;
void SetClientSize(const Size& size) override;
+ Rect GetClientRect() override;
+ void SetClientRect(const Rect& rect) override;
+
// Get the rect of the window containing frame.
// The lefttop of the rect is relative to screen lefttop.
Rect GetWindowRect() override;
@@ -41,6 +46,8 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
// The lefttop of the rect is relative to screen lefttop.
void SetWindowRect(const Rect& rect) override;
+ bool RequestFocus() override;
+
Point GetMousePosition() override;
bool CaptureMouse() override;
@@ -51,8 +58,12 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
void SetCursor(std::shared_ptr<ICursor> cursor) override;
+ IEvent<std::nullptr_t>* CreateEvent() override { return &create_event_; }
IEvent<std::nullptr_t>* DestroyEvent() override { return &destroy_event_; }
IEvent<std::nullptr_t>* PaintEvent() override { return &paint_event_; }
+ IEvent<WindowVisibilityType>* VisibilityChangeEvent() override {
+ return &visibility_change_event_;
+ }
IEvent<Size>* ResizeEvent() override { return &resize_event_; }
IEvent<FocusChangeType>* FocusEvent() override { return &focus_event_; }
IEvent<MouseEnterLeaveType>* MouseEnterLeaveEvent() override {
@@ -106,6 +117,15 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
return result;
}
+ inline RECT DipToPixel(const Rect& dip_rect) {
+ RECT result;
+ result.left = DipToPixel(dip_rect.left);
+ result.top = DipToPixel(dip_rect.top);
+ result.right = DipToPixel(dip_rect.GetRight());
+ result.bottom = DipToPixel(dip_rect.GetBottom());
+ return result;
+ }
+
inline float PixelToDip(const int pixel) {
return static_cast<float>(pixel) * 96.0f / GetDpi();
}
@@ -114,14 +134,24 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
return Point(PixelToDip(pi_point.x), PixelToDip(pi_point.y));
}
+ inline Rect PixelToDip(const RECT& pi_rect) {
+ return Rect::FromVertices(PixelToDip(pi_rect.left), PixelToDip(pi_rect.top),
+ PixelToDip(pi_rect.right),
+ PixelToDip(pi_rect.bottom));
+ }
+
private:
// Get the client rect in pixel.
RECT GetClientRectPixel();
+ void RecreateWindow();
+
//*************** region: native messages ***************
+ void OnCreateInternal();
void OnDestroyInternal();
void OnPaintInternal();
+ void OnMoveInternal(int new_left, int new_top);
void OnResizeInternal(int new_width, int new_height);
void OnSetFocusInternal();
@@ -142,15 +172,12 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
private:
WinUiApplication* application_;
- // when delete is called first, it set this to true to indicate
- // destroy message handler not to double delete this instance;
- // when destroy handler is called first (by user action or method
- // Close), it set this to true to indicate delete not call Close
- // again.
- bool sync_flag_ = false;
+ WindowStyleFlag style_flag_{};
+ WindowVisibilityType visibility_ = WindowVisibilityType::Hide;
+ Rect client_rect_{100, 100, 400, 300};
- HWND hwnd_;
- WinNativeWindow* parent_window_;
+ HWND hwnd_ = nullptr;
+ WinNativeWindow* parent_window_ = nullptr;
float dpi_;
@@ -164,9 +191,11 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
std::unique_ptr<WinInputMethodContext> input_method_context_;
+ Event<std::nullptr_t> create_event_;
Event<std::nullptr_t> destroy_event_;
Event<std::nullptr_t> paint_event_;
Event<Size> resize_event_;
+ Event<WindowVisibilityType> visibility_change_event_;
Event<FocusChangeType> focus_event_;
Event<MouseEnterLeaveType> mouse_enter_leave_event_;
Event<Point> mouse_move_event_;
diff --git a/include/cru/xml/Base.hpp b/include/cru/xml/Base.hpp
new file mode 100644
index 00000000..5d6fe144
--- /dev/null
+++ b/include/cru/xml/Base.hpp
@@ -0,0 +1,11 @@
+#pragma once
+
+#ifdef CRU_PLATFORM_WINDOWS
+#ifdef CRU_XML_EXPORT_API
+#define CRU_XML_API __declspec(dllexport)
+#else
+#define CRU_XML_API __declspec(dllimport)
+#endif
+#else
+#define CRU_XML_API
+#endif
diff --git a/include/cru/xml/XmlNode.hpp b/include/cru/xml/XmlNode.hpp
index cf2543c9..38f09d14 100644
--- a/include/cru/xml/XmlNode.hpp
+++ b/include/cru/xml/XmlNode.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "Base.hpp"
+
#include "cru/common/String.hpp"
#include <algorithm>
@@ -10,7 +12,7 @@ namespace cru::xml {
class XmlElementNode;
class XmlTextNode;
-class XmlNode {
+class CRU_XML_API XmlNode {
friend XmlElementNode;
public:
@@ -40,7 +42,7 @@ class XmlNode {
XmlElementNode* parent_ = nullptr;
};
-class XmlTextNode : public XmlNode {
+class CRU_XML_API XmlTextNode : public XmlNode {
public:
XmlTextNode() : XmlNode(Type::Text) {}
explicit XmlTextNode(String text)
@@ -61,7 +63,7 @@ class XmlTextNode : public XmlNode {
String text_;
};
-class XmlElementNode : public XmlNode {
+class CRU_XML_API XmlElementNode : public XmlNode {
public:
XmlElementNode() : XmlNode(Type::Element) {}
explicit XmlElementNode(String tag,
@@ -86,9 +88,9 @@ class XmlElementNode : public XmlNode {
}
const std::vector<XmlNode*> GetChildren() const { return children_; }
- int GetChildCount() const { return children_.size(); }
+ Index GetChildCount() const { return children_.size(); }
String GetAttribute(const String& key) const { return attributes_.at(key); }
- XmlNode* GetChildAt(int index) const { return children_[index]; }
+ XmlNode* GetChildAt(Index index) const { return children_[index]; }
void AddAttribute(String key, String value);
void AddChild(XmlNode* child);
diff --git a/include/cru/xml/XmlParser.hpp b/include/cru/xml/XmlParser.hpp
index 188a08f2..e916cc53 100644
--- a/include/cru/xml/XmlParser.hpp
+++ b/include/cru/xml/XmlParser.hpp
@@ -8,12 +8,12 @@
#include <optional>
namespace cru::xml {
-class XmlParsingException : public Exception {
+class CRU_XML_API XmlParsingException : public Exception {
public:
using Exception::Exception;
};
-class XmlParser {
+class CRU_XML_API XmlParser {
public:
explicit XmlParser(String xml);