aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/cru/common/PropertyTree.hpp4
-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.hpp2
-rw-r--r--include/cru/platform/graphics/Painter.hpp2
-rw-r--r--include/cru/platform/graphics/Resource.hpp2
-rw-r--r--include/cru/platform/graphics/TextLayout.hpp2
-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/gui/Window.hpp3
-rw-r--r--include/cru/xml/Base.hpp11
-rw-r--r--include/cru/xml/XmlNode.hpp12
-rw-r--r--include/cru/xml/XmlParser.hpp4
-rw-r--r--src/parse/CMakeLists.txt1
-rw-r--r--src/parse/RecursiveDescentAlgorithm.cpp1
-rw-r--r--src/parse/RecursiveDescentAlgorithmContext.cpp1
-rw-r--r--src/platform/graphics/CMakeLists.txt2
-rw-r--r--src/platform/graphics/ForDllExport.cpp7
-rw-r--r--src/toml/CMakeLists.txt1
-rw-r--r--src/ui/components/Menu.cpp2
-rw-r--r--src/ui/controls/TextHostControlService.cpp4
-rw-r--r--src/ui/render/TextRenderObject.cpp1
-rw-r--r--src/win/Exception.cpp6
-rw-r--r--src/win/graphics/direct/Geometry.cpp2
-rw-r--r--src/win/graphics/direct/Painter.cpp2
-rw-r--r--src/win/gui/Window.cpp62
-rw-r--r--src/xml/CMakeLists.txt1
44 files changed, 168 insertions, 50 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/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 7889f99e..b5c796d3 100644
--- a/include/cru/platform/graphics/NullPainter.hpp
+++ b/include/cru/platform/graphics/NullPainter.hpp
@@ -3,7 +3,7 @@
#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;
diff --git a/include/cru/platform/graphics/Painter.hpp b/include/cru/platform/graphics/Painter.hpp
index 552a3307..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;
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/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/gui/Window.hpp b/include/cru/win/gui/Window.hpp
index 5ce3ed25..7a982da7 100644
--- a/include/cru/win/gui/Window.hpp
+++ b/include/cru/win/gui/Window.hpp
@@ -44,7 +44,6 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
// Set the rect of the window containing frame.
// The lefttop of the rect is relative to screen lefttop.
- // TODO: Known limitation: can't calc client rect and save.
void SetWindowRect(const Rect& rect) override;
bool RequestFocus() override;
@@ -149,8 +148,10 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
//*************** 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();
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);
diff --git a/src/parse/CMakeLists.txt b/src/parse/CMakeLists.txt
index 72bac707..17b26a3a 100644
--- a/src/parse/CMakeLists.txt
+++ b/src/parse/CMakeLists.txt
@@ -13,4 +13,5 @@ add_library(cru_parse SHARED
Token.cpp
TokenType.cpp
)
+target_compile_definitions(cru_parse PRIVATE CRU_PARSE_EXPORT_API)
target_link_libraries(cru_parse PUBLIC cru_base)
diff --git a/src/parse/RecursiveDescentAlgorithm.cpp b/src/parse/RecursiveDescentAlgorithm.cpp
index a6549f8a..8ff2571d 100644
--- a/src/parse/RecursiveDescentAlgorithm.cpp
+++ b/src/parse/RecursiveDescentAlgorithm.cpp
@@ -4,6 +4,7 @@
namespace cru::parse {
bool RecursiveDescentAlgorithm::CanHandle(Grammar *grammar) const {
+ CRU_UNUSED(grammar);
return true;
}
diff --git a/src/parse/RecursiveDescentAlgorithmContext.cpp b/src/parse/RecursiveDescentAlgorithmContext.cpp
index 8de0abc4..acfd9eee 100644
--- a/src/parse/RecursiveDescentAlgorithmContext.cpp
+++ b/src/parse/RecursiveDescentAlgorithmContext.cpp
@@ -10,6 +10,7 @@ RecursiveDescentAlgorithmContext::~RecursiveDescentAlgorithmContext() = default;
ParsingTreeNode* RecursiveDescentAlgorithmContext::Parse(
const std::vector<Terminal*>& input) {
+ CRU_UNUSED(input)
// TODO: Implement this.
return nullptr;
}
diff --git a/src/platform/graphics/CMakeLists.txt b/src/platform/graphics/CMakeLists.txt
index 7d86db40..692f8e70 100644
--- a/src/platform/graphics/CMakeLists.txt
+++ b/src/platform/graphics/CMakeLists.txt
@@ -1,5 +1,6 @@
set(CRU_PLATFORM_GRAPHICS_INCLUDE_DIR ${CRU_INCLUDE_DIR}/cru/platform/graphics)
add_library(cru_platform_graphics SHARED
+ ForDllExport.cpp
NullPainter.cpp
)
target_sources(cru_platform_graphics PUBLIC
@@ -14,4 +15,5 @@ target_sources(cru_platform_graphics PUBLIC
${CRU_PLATFORM_GRAPHICS_INCLUDE_DIR}/TextLayout.hpp
${CRU_PLATFORM_GRAPHICS_INCLUDE_DIR}/util/Painter.hpp
)
+target_compile_definitions(cru_platform_graphics PRIVATE CRU_PLATFORM_GRAPHICS_EXPORT_API)
target_link_libraries(cru_platform_graphics PUBLIC cru_platform_base)
diff --git a/src/platform/graphics/ForDllExport.cpp b/src/platform/graphics/ForDllExport.cpp
new file mode 100644
index 00000000..1a571365
--- /dev/null
+++ b/src/platform/graphics/ForDllExport.cpp
@@ -0,0 +1,7 @@
+#include "cru/platform/graphics/Brush.hpp"
+#include "cru/platform/graphics/Factory.hpp"
+#include "cru/platform/graphics/Font.hpp"
+#include "cru/platform/graphics/Geometry.hpp"
+#include "cru/platform/graphics/Painter.hpp"
+#include "cru/platform/graphics/Resource.hpp"
+#include "cru/platform/graphics/TextLayout.hpp"
diff --git a/src/toml/CMakeLists.txt b/src/toml/CMakeLists.txt
index 0285b454..be04ad79 100644
--- a/src/toml/CMakeLists.txt
+++ b/src/toml/CMakeLists.txt
@@ -2,4 +2,5 @@ add_library(cru_toml SHARED
TomlDocument.cpp
TomlParser.cpp
)
+target_compile_definitions(cru_toml PRIVATE CRU_TOML_EXPORT_API)
target_link_libraries(cru_toml PUBLIC cru_base)
diff --git a/src/ui/components/Menu.cpp b/src/ui/components/Menu.cpp
index 681b44b7..05324865 100644
--- a/src/ui/components/Menu.cpp
+++ b/src/ui/components/Menu.cpp
@@ -92,7 +92,7 @@ PopupMenu::PopupMenu(controls::Control* attached_control)
menu_ = new Menu();
- menu_->SetOnItemClick([this](Index _) { this->Close(); });
+ menu_->SetOnItemClick([this](Index) { this->Close(); });
popup_->AddChild(menu_->GetRootControl(), 0);
}
diff --git a/src/ui/controls/TextHostControlService.cpp b/src/ui/controls/TextHostControlService.cpp
index 7fcf70e9..0f136034 100644
--- a/src/ui/controls/TextHostControlService.cpp
+++ b/src/ui/controls/TextHostControlService.cpp
@@ -87,7 +87,7 @@ TextControlMovePattern TextControlMovePattern::kHome(
gsl::index current_position) {
CRU_UNUSED(service)
return Utf16BackwardUntil(text, current_position,
- [](char16_t c) { return c == u'\n'; });
+ [](CodePoint c) { return c == u'\n'; });
});
TextControlMovePattern TextControlMovePattern::kEnd(
u"End(Line End)", helper::ShortcutKeyBind(platform::gui::KeyCode::End),
@@ -95,7 +95,7 @@ TextControlMovePattern TextControlMovePattern::kEnd(
gsl::index current_position) {
CRU_UNUSED(service)
return Utf16ForwardUntil(text, current_position,
- [](char16_t c) { return c == u'\n'; });
+ [](CodePoint c) { return c == u'\n'; });
});
TextControlMovePattern TextControlMovePattern::kCtrlHome(
u"Ctrl+Home(Document Begin)",
diff --git a/src/ui/render/TextRenderObject.cpp b/src/ui/render/TextRenderObject.cpp
index 0e65da92..f7665beb 100644
--- a/src/ui/render/TextRenderObject.cpp
+++ b/src/ui/render/TextRenderObject.cpp
@@ -147,7 +147,6 @@ Rect TextRenderObject::GetCaretRectInContent() {
const auto caret_top_center =
this->text_layout_->TextSinglePoint(caret_pos, false);
- const auto font_height = this->font_->GetFontSize();
const auto caret_width = this->caret_width_;
auto rect = Rect{caret_top_center.left - caret_width / 2.0f,
diff --git a/src/win/Exception.cpp b/src/win/Exception.cpp
index cf55c191..2664b092 100644
--- a/src/win/Exception.cpp
+++ b/src/win/Exception.cpp
@@ -7,9 +7,9 @@ namespace cru::platform::win {
inline String HResultMakeMessage(HRESULT h_result,
std::optional<String> message) {
if (message.has_value())
- return Format(L"HRESULT: {}. Message: {}", h_result, message->WinCStr());
+ return Format(u"HRESULT: {}. Message: {}", h_result, message->WinCStr());
else
- return Format(L"HRESULT: {}.", h_result);
+ return Format(u"HRESULT: {}.", h_result);
}
HResultError::HResultError(HRESULT h_result)
@@ -24,7 +24,7 @@ HResultError::HResultError(HRESULT h_result,
h_result_(h_result) {}
inline String Win32MakeMessage(DWORD error_code, String message) {
- return Format(L"Last error code: {}.\nMessage: {}\n", error_code,
+ return Format(u"Last error code: {}.\nMessage: {}\n", error_code,
message.WinCStr());
}
diff --git a/src/win/graphics/direct/Geometry.cpp b/src/win/graphics/direct/Geometry.cpp
index 2a544859..b37dd9f4 100644
--- a/src/win/graphics/direct/Geometry.cpp
+++ b/src/win/graphics/direct/Geometry.cpp
@@ -13,7 +13,7 @@ D2DGeometryBuilder::D2DGeometryBuilder(DirectGraphicsFactory* factory)
void D2DGeometryBuilder::CheckValidation() {
if (!IsValid())
- throw ReuseException(L"The geometry builder is already disposed.");
+ throw ReuseException(u"The geometry builder is already disposed.");
}
void D2DGeometryBuilder::BeginFigure(const Point& point) {
diff --git a/src/win/graphics/direct/Painter.cpp b/src/win/graphics/direct/Painter.cpp
index 5db60fd1..1a43d1d0 100644
--- a/src/win/graphics/direct/Painter.cpp
+++ b/src/win/graphics/direct/Painter.cpp
@@ -146,7 +146,7 @@ void D2DPainter::EndDraw() {
void D2DPainter::CheckValidation() {
if (!is_drawing_) {
throw cru::platform::ReuseException(
- L"Can't do that on painter after end drawing.");
+ u"Can't do that on painter after end drawing.");
}
}
} // namespace cru::platform::graphics::win::direct
diff --git a/src/win/gui/Window.cpp b/src/win/gui/Window.cpp
index 20f86aff..827cc0a8 100644
--- a/src/win/gui/Window.cpp
+++ b/src/win/gui/Window.cpp
@@ -15,6 +15,7 @@
#include "cru/win/gui/WindowClass.hpp"
#include <windowsx.h>
+#include <winuser.h>
namespace cru::platform::gui::win {
namespace {
@@ -47,6 +48,21 @@ Rect CalcWindowRectFromClient(const Rect& rect, WindowStyleFlag style_flag,
return result;
}
+Rect CalcClientRectFromWindow(const Rect& rect, WindowStyleFlag style_flag,
+ float dpi) {
+ RECT o{100, 100, 500, 500};
+ RECT s = o;
+ if (!AdjustWindowRectEx(&s, CalcWindowStyle(style_flag), FALSE, 0))
+ throw Win32Error(::GetLastError(), "Failed to invoke AdjustWindowRectEx.");
+
+ Rect result = rect;
+ result.Shrink(Thickness(PixelToDip(s.left - o.left, dpi),
+ PixelToDip(o.top - s.top, dpi),
+ PixelToDip(s.right - o.right, dpi),
+ PixelToDip(s.bottom - o.bottom, dpi)));
+
+ return result;
+}
} // namespace
WinNativeWindow::WinNativeWindow(WinUiApplication* application)
@@ -60,6 +76,15 @@ void WinNativeWindow::Close() {
if (hwnd_) ::DestroyWindow(hwnd_);
}
+void WinNativeWindow::SetParent(INativeWindow *parent) {
+ auto p = CheckPlatform<WinNativeWindow>(parent, GetPlatformId());
+ parent_window_ = p;
+
+ if (hwnd_) {
+ ::SetParent(hwnd_, parent_window_->hwnd_);
+ }
+}
+
void WinNativeWindow::SetStyleFlag(WindowStyleFlag flag) {
if (flag == style_flag_) return;
@@ -108,11 +133,11 @@ void WinNativeWindow::SetClientRect(const Rect& rect) {
client_rect_ = rect;
if (hwnd_) {
- RECT rect =
+ RECT r =
DipToPixel(CalcWindowRectFromClient(client_rect_, style_flag_, dpi_));
- if (!SetWindowPos(hwnd_, nullptr, 0, 0, rect.right - rect.left,
- rect.bottom - rect.top, SWP_NOZORDER | SWP_NOMOVE))
+ if (!SetWindowPos(hwnd_, nullptr, 0, 0, r.right - r.left, r.bottom - r.top,
+ SWP_NOZORDER | SWP_NOMOVE))
throw Win32Error(::GetLastError(), "Failed to invoke SetWindowPos.");
}
}
@@ -126,11 +151,13 @@ Rect WinNativeWindow::GetWindowRect() {
return Rect::FromVertices(PixelToDip(rect.left), PixelToDip(rect.top),
PixelToDip(rect.right), PixelToDip(rect.bottom));
} else {
- return {};
+ return CalcWindowRectFromClient(client_rect_, style_flag_, dpi_);
}
}
void WinNativeWindow::SetWindowRect(const Rect& rect) {
+ client_rect_ = CalcClientRectFromWindow(rect, style_flag_, dpi_);
+
if (hwnd_) {
if (!SetWindowPos(hwnd_, nullptr, DipToPixel(rect.left),
DipToPixel(rect.top), DipToPixel(rect.GetRight()),
@@ -139,6 +166,14 @@ void WinNativeWindow::SetWindowRect(const Rect& rect) {
}
}
+bool WinNativeWindow::RequestFocus() {
+ if (hwnd_) {
+ SetFocus(hwnd_);
+ return true;
+ }
+ return false;
+}
+
Point WinNativeWindow::GetMousePosition() {
POINT p;
if (!::GetCursorPos(&p))
@@ -193,7 +228,7 @@ void WinNativeWindow::SetCursor(std::shared_ptr<ICursor> cursor) {
if (GetVisibility() != WindowVisibilityType::Show) return;
- auto lg = [](const std::u16string_view& reason) {
+ auto lg = [](StringView reason) {
log::TagWarn(
log_tag,
u"Failed to set cursor because {} when window is visible. (We need to "
@@ -348,6 +383,14 @@ bool WinNativeWindow::HandleNativeWindowMessage(HWND hwnd, UINT msg,
return true;
}
return false;
+ case WM_CREATE:
+ OnCreateInternal();
+ *result = 0;
+ return true;
+ case WM_MOVE:
+ OnMoveInternal(LOWORD(l_param), HIWORD(l_param));
+ *result = 0;
+ return true;
case WM_SIZE:
OnResizeInternal(LOWORD(l_param), HIWORD(l_param));
*result = 0;
@@ -427,6 +470,8 @@ void WinNativeWindow::RecreateWindow() {
input_method_context_->DisableIME();
}
+void WinNativeWindow::OnCreateInternal() { create_event_.Raise(nullptr); }
+
void WinNativeWindow::OnDestroyInternal() {
destroy_event_.Raise(nullptr);
application_->GetWindowManager()->UnregisterWindow(hwnd_);
@@ -441,8 +486,15 @@ void WinNativeWindow::OnPaintInternal() {
}
}
+void WinNativeWindow::OnMoveInternal(const int new_left, const int new_top) {
+ client_rect_.left = PixelToDip(new_left);
+ client_rect_.top = PixelToDip(new_top);
+}
+
void WinNativeWindow::OnResizeInternal(const int new_width,
const int new_height) {
+ client_rect_.width = PixelToDip(new_width);
+ client_rect_.height = PixelToDip(new_height);
if (!(new_width == 0 && new_height == 0)) {
window_render_target_->ResizeBuffer(new_width, new_height);
resize_event_.Raise(Size{PixelToDip(new_width), PixelToDip(new_height)});
diff --git a/src/xml/CMakeLists.txt b/src/xml/CMakeLists.txt
index 20e889ec..014e820c 100644
--- a/src/xml/CMakeLists.txt
+++ b/src/xml/CMakeLists.txt
@@ -2,4 +2,5 @@ add_library(cru_xml SHARED
XmlNode.cpp
XmlParser.cpp
)
+target_compile_definitions(cru_xml PRIVATE CRU_XML_EXPORT_API)
target_link_libraries(cru_xml PUBLIC cru_base)