aboutsummaryrefslogtreecommitdiff
path: root/src/win
diff options
context:
space:
mode:
Diffstat (limited to 'src/win')
-rw-r--r--src/win/Exception.cpp24
-rw-r--r--src/win/graphics/direct/Geometry.cpp2
-rw-r--r--src/win/graphics/direct/Painter.cpp2
-rw-r--r--src/win/graphics/direct/Resource.cpp2
-rw-r--r--src/win/gui/CMakeLists.txt1
-rw-r--r--src/win/gui/Resource.cpp6
6 files changed, 24 insertions, 13 deletions
diff --git a/src/win/Exception.cpp b/src/win/Exception.cpp
index 8d2eee23..df2103fd 100644
--- a/src/win/Exception.cpp
+++ b/src/win/Exception.cpp
@@ -5,13 +5,13 @@
namespace cru::platform::win {
-inline std::string HResultMakeMessage(
- HRESULT h_result, std::optional<std::string_view> message) {
+inline String HResultMakeMessage(HRESULT h_result,
+ std::optional<String> message) {
if (message.has_value())
- return fmt::format(FMT_STRING("HRESULT: {:#08x}. Message: {}"), h_result,
- *message);
+ return fmt::format(FMT_STRING(L"HRESULT: {:#08x}. Message: {}"), h_result,
+ message->WinCStr());
else
- return fmt::format(FMT_STRING("HRESULT: {:#08x}."), h_result);
+ return fmt::format(FMT_STRING(L"HRESULT: {:#08x}."), h_result);
}
HResultError::HResultError(HRESULT h_result)
@@ -20,19 +20,21 @@ HResultError::HResultError(HRESULT h_result)
HResultError::HResultError(HRESULT h_result,
std::string_view additional_message)
- : PlatformException(HResultMakeMessage(h_result, additional_message)),
+ : PlatformException(HResultMakeMessage(
+ h_result, String::FromUtf8(additional_message.data(),
+ additional_message.size()))),
h_result_(h_result) {}
-inline std::string Win32MakeMessage(DWORD error_code,
- std::string_view message) {
- return fmt::format("Last error code: {:#04x}.\nMessage: {}\n", error_code,
- message);
+inline String Win32MakeMessage(DWORD error_code, String message) {
+ return fmt::format(L"Last error code: {:#04x}.\nMessage: {}\n", error_code,
+ message.WinCStr());
}
Win32Error::Win32Error(std::string_view message)
: Win32Error(::GetLastError(), message) {}
Win32Error::Win32Error(DWORD error_code, std::string_view message)
- : PlatformException(Win32MakeMessage(error_code, message)),
+ : PlatformException(Win32MakeMessage(
+ error_code, String::FromUtf8(message.data(), message.size()))),
error_code_(error_code) {}
} // namespace cru::platform::win
diff --git a/src/win/graphics/direct/Geometry.cpp b/src/win/graphics/direct/Geometry.cpp
index 8aa961b2..d07a819f 100644
--- a/src/win/graphics/direct/Geometry.cpp
+++ b/src/win/graphics/direct/Geometry.cpp
@@ -13,7 +13,7 @@ D2DGeometryBuilder::D2DGeometryBuilder(DirectGraphFactory* factory)
void D2DGeometryBuilder::CheckValidation() {
if (!IsValid())
- throw ReuseException("The geometry builder is already disposed.");
+ throw ReuseException(L"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 d6999cfa..26ef92ec 100644
--- a/src/win/graphics/direct/Painter.cpp
+++ b/src/win/graphics/direct/Painter.cpp
@@ -106,7 +106,7 @@ void D2DPainter::EndDraw() {
void D2DPainter::CheckValidation() {
if (!is_drawing_) {
throw cru::platform::ReuseException(
- "Can't do that on painter after end drawing.");
+ L"Can't do that on painter after end drawing.");
}
}
} // namespace cru::platform::graphics::win::direct
diff --git a/src/win/graphics/direct/Resource.cpp b/src/win/graphics/direct/Resource.cpp
index 2b4a0772..6ae74e64 100644
--- a/src/win/graphics/direct/Resource.cpp
+++ b/src/win/graphics/direct/Resource.cpp
@@ -3,6 +3,8 @@
#include "cru/win/graphics/direct/Factory.hpp"
namespace cru::platform::graphics::win::direct {
+String DirectResource::kPlatformId = u"Windows Direct";
+
DirectGraphResource::DirectGraphResource(DirectGraphFactory* factory)
: factory_(factory) {
Expects(factory);
diff --git a/src/win/gui/CMakeLists.txt b/src/win/gui/CMakeLists.txt
index 48bed00d..53dfe69b 100644
--- a/src/win/gui/CMakeLists.txt
+++ b/src/win/gui/CMakeLists.txt
@@ -8,6 +8,7 @@ add_library(cru_win_gui STATIC
GodWindow.cpp
InputMethod.cpp
Keyboard.cpp
+ Resource.cpp
TimerManager.cpp
UiApplication.cpp
Window.cpp
diff --git a/src/win/gui/Resource.cpp b/src/win/gui/Resource.cpp
new file mode 100644
index 00000000..dc4de173
--- /dev/null
+++ b/src/win/gui/Resource.cpp
@@ -0,0 +1,6 @@
+#include "cru/win/gui/Resource.hpp"
+#include "cru/win/gui/Window.hpp"
+
+namespace cru::platform::gui::win {
+String WinNativeResource::kPlatformId = u"Windows";
+}