aboutsummaryrefslogtreecommitdiff
path: root/src/win/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/win/gui')
-rw-r--r--src/win/gui/CMakeLists.txt3
-rw-r--r--src/win/gui/Cursor.cpp2
-rw-r--r--src/win/gui/TimerManager.cpp2
-rw-r--r--src/win/gui/UiApplication.cpp6
-rw-r--r--src/win/gui/Window.cpp26
-rw-r--r--src/win/gui/WindowClass.cpp2
6 files changed, 21 insertions, 20 deletions
diff --git a/src/win/gui/CMakeLists.txt b/src/win/gui/CMakeLists.txt
index 2c8d1aab..b9d2862f 100644
--- a/src/win/gui/CMakeLists.txt
+++ b/src/win/gui/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_library(cru_win_gui STATIC
+add_library(cru_win_gui SHARED
TimerManager.hpp
WindowManager.hpp
@@ -15,3 +15,4 @@ add_library(cru_win_gui STATIC
)
target_link_libraries(cru_win_gui PUBLIC imm32)
target_link_libraries(cru_win_gui PUBLIC cru_win_graphics_direct cru_platform_gui)
+target_compile_definitions(cru_win_gui PRIVATE CRU_WIN_GUI_EXPORT_API)
diff --git a/src/win/gui/Cursor.cpp b/src/win/gui/Cursor.cpp
index 80e8a749..a3a7f824 100644
--- a/src/win/gui/Cursor.cpp
+++ b/src/win/gui/Cursor.cpp
@@ -27,7 +27,7 @@ WinCursor* LoadWinCursor(const wchar_t* name) {
const auto handle = static_cast<HCURSOR>(::LoadImageW(
NULL, name, IMAGE_CURSOR, SM_CYCURSOR, SM_CYCURSOR, LR_SHARED));
if (handle == NULL) {
- throw Win32Error(::GetLastError(), "Failed to load system cursor.");
+ throw Win32Error(::GetLastError(), u"Failed to load system cursor.");
}
return new WinCursor(handle, false);
}
diff --git a/src/win/gui/TimerManager.cpp b/src/win/gui/TimerManager.cpp
index fc26b6c4..f3da1f09 100644
--- a/src/win/gui/TimerManager.cpp
+++ b/src/win/gui/TimerManager.cpp
@@ -26,7 +26,7 @@ long long TimerManager::SetTimer(TimerType type, int period,
gsl::narrow<UINT_PTR>(id), 0)) {
throw Win32Error(
::GetLastError(),
- "Failed to post window message to god window for set immediate.");
+ u"Failed to post window message to god window for set immediate.");
}
} else {
CreateNativeTimer(&timer_info);
diff --git a/src/win/gui/UiApplication.cpp b/src/win/gui/UiApplication.cpp
index cb0f0a4c..dadcfc75 100644
--- a/src/win/gui/UiApplication.cpp
+++ b/src/win/gui/UiApplication.cpp
@@ -1,11 +1,11 @@
#include "cru/win/gui/UiApplication.hpp"
-#include "../DebugLogger.hpp"
-#include "../StdOutLogger.hpp"
#include "TimerManager.hpp"
#include "WindowManager.hpp"
#include "cru/common/Logger.hpp"
#include "cru/platform/Check.hpp"
+#include "cru/win/DebugLogger.hpp"
+#include "cru/win/StdOutLogger.hpp"
#include "cru/win/graphics/direct/Factory.hpp"
#include "cru/win/gui/Cursor.hpp"
#include "cru/win/gui/Exception.hpp"
@@ -27,7 +27,7 @@ WinUiApplication::WinUiApplication() {
instance_handle_ = ::GetModuleHandleW(nullptr);
if (!instance_handle_)
- throw Win32Error("Failed to get module(instance) handle.");
+ throw Win32Error(u"Failed to get module(instance) handle.");
::SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE);
diff --git a/src/win/gui/Window.cpp b/src/win/gui/Window.cpp
index 7ee2fb71..b3cf7065 100644
--- a/src/win/gui/Window.cpp
+++ b/src/win/gui/Window.cpp
@@ -42,7 +42,7 @@ Rect CalcWindowRectFromClient(const Rect& rect, WindowStyleFlag style_flag,
r.right = DipToPixel(rect.GetRight(), dpi);
r.bottom = DipToPixel(rect.GetBottom(), dpi);
if (!AdjustWindowRectEx(&r, CalcWindowStyle(style_flag), FALSE, 0))
- throw Win32Error(::GetLastError(), "Failed to invoke AdjustWindowRectEx.");
+ throw Win32Error(::GetLastError(), u"Failed to invoke AdjustWindowRectEx.");
Rect result =
Rect::FromVertices(PixelToDip(r.left, dpi), PixelToDip(r.top, dpi),
@@ -55,7 +55,7 @@ Rect CalcClientRectFromWindow(const Rect& rect, WindowStyleFlag style_flag,
RECT o{100, 100, 500, 500};
RECT s = o;
if (!AdjustWindowRectEx(&s, CalcWindowStyle(style_flag), FALSE, 0))
- throw Win32Error(::GetLastError(), "Failed to invoke AdjustWindowRectEx.");
+ throw Win32Error(::GetLastError(), u"Failed to invoke AdjustWindowRectEx.");
Rect result = rect;
result.Shrink(Thickness(PixelToDip(s.left - o.left, dpi),
@@ -125,7 +125,7 @@ void WinNativeWindow::SetClientSize(const Size& size) {
if (!SetWindowPos(hwnd_, nullptr, 0, 0, rect.right - rect.left,
rect.bottom - rect.top, SWP_NOZORDER | SWP_NOMOVE))
- throw Win32Error(::GetLastError(), "Failed to invoke SetWindowPos.");
+ throw Win32Error(::GetLastError(), u"Failed to invoke SetWindowPos.");
}
}
@@ -140,7 +140,7 @@ void WinNativeWindow::SetClientRect(const Rect& rect) {
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.");
+ throw Win32Error(::GetLastError(), u"Failed to invoke SetWindowPos.");
}
}
@@ -148,7 +148,7 @@ Rect WinNativeWindow::GetWindowRect() {
if (hwnd_) {
RECT rect;
if (!::GetWindowRect(hwnd_, &rect))
- throw Win32Error(::GetLastError(), "Failed to invoke GetWindowRect.");
+ throw Win32Error(::GetLastError(), u"Failed to invoke GetWindowRect.");
return Rect::FromVertices(PixelToDip(rect.left), PixelToDip(rect.top),
PixelToDip(rect.right), PixelToDip(rect.bottom));
@@ -164,7 +164,7 @@ void WinNativeWindow::SetWindowRect(const Rect& rect) {
if (!SetWindowPos(hwnd_, nullptr, DipToPixel(rect.left),
DipToPixel(rect.top), DipToPixel(rect.GetRight()),
DipToPixel(rect.GetBottom()), SWP_NOZORDER))
- throw Win32Error(::GetLastError(), "Failed to invoke SetWindowPos.");
+ throw Win32Error(::GetLastError(), u"Failed to invoke SetWindowPos.");
}
}
@@ -179,9 +179,9 @@ bool WinNativeWindow::RequestFocus() {
Point WinNativeWindow::GetMousePosition() {
POINT p;
if (!::GetCursorPos(&p))
- throw Win32Error(::GetLastError(), "Failed to get cursor position.");
+ throw Win32Error(::GetLastError(), u"Failed to get cursor position.");
if (!::ScreenToClient(hwnd_, &p))
- throw Win32Error(::GetLastError(), "Failed to call ScreenToClient.");
+ throw Win32Error(::GetLastError(), u"Failed to call ScreenToClient.");
return PixelToDip(p);
}
@@ -200,9 +200,9 @@ void WinNativeWindow::RequestRepaint() {
log::TagDebug(log_tag, u"A repaint is requested.");
}
if (!::InvalidateRect(hwnd_, nullptr, FALSE))
- throw Win32Error(::GetLastError(), "Failed to invalidate window.");
+ throw Win32Error(::GetLastError(), u"Failed to invalidate window.");
if (!::UpdateWindow(hwnd_))
- throw Win32Error(::GetLastError(), "Failed to update window.");
+ throw Win32Error(::GetLastError(), u"Failed to update window.");
}
std::unique_ptr<graphics::IPainter> WinNativeWindow::BeginPaint() {
@@ -438,7 +438,7 @@ bool WinNativeWindow::HandleNativeWindowMessage(HWND hwnd, UINT msg,
RECT WinNativeWindow::GetClientRectPixel() {
RECT rect;
if (!::GetClientRect(hwnd_, &rect))
- throw Win32Error(::GetLastError(), "Failed to invoke GetClientRect.");
+ throw Win32Error(::GetLastError(), u"Failed to invoke GetClientRect.");
return rect;
}
@@ -453,11 +453,11 @@ void WinNativeWindow::RecreateWindow() {
nullptr, application_->GetInstanceHandle(), nullptr);
if (hwnd_ == nullptr)
- throw Win32Error(::GetLastError(), "Failed to create window.");
+ throw Win32Error(::GetLastError(), u"Failed to create window.");
auto dpi = ::GetDpiForWindow(hwnd_);
if (dpi == 0)
- throw Win32Error(::GetLastError(), "Failed to get dpi of window.");
+ throw Win32Error(::GetLastError(), u"Failed to get dpi of window.");
dpi_ = static_cast<float>(dpi);
log::Debug(u"Dpi of window is {}.", dpi_);
diff --git a/src/win/gui/WindowClass.cpp b/src/win/gui/WindowClass.cpp
index a033d091..9d86d791 100644
--- a/src/win/gui/WindowClass.cpp
+++ b/src/win/gui/WindowClass.cpp
@@ -23,6 +23,6 @@ WindowClass::WindowClass(std::wstring name, WNDPROC window_proc,
atom_ = ::RegisterClassExW(&window_class);
if (atom_ == 0)
- throw Win32Error(::GetLastError(), "Failed to create window class.");
+ throw Win32Error(::GetLastError(), u"Failed to create window class.");
}
} // namespace cru::platform::gui::win