#include "RmlUi_SystemInterface_Win64.h" #include "..\Common\Consoles_App.h" #include "StringTable.h" #include "Windows64_App.h" SystemInterface_Win64::SystemInterface_Win64() { LARGE_INTEGER freq; QueryPerformanceFrequency(&freq); m_frequency = static_cast(freq.QuadPart); QueryPerformanceCounter(&m_startup); } SystemInterface_Win64::~SystemInterface_Win64() { } double SystemInterface_Win64::GetElapsedTime() { LARGE_INTEGER now; QueryPerformanceCounter(&now); return static_cast(now.QuadPart - m_startup.QuadPart) / m_frequency; } int SystemInterface_Win64::TranslateString(Rml::String& translated, const Rml::String& input) { translated = input; int count = 0; std::string result; result.reserve(input.size()); for (size_t i = 0; i < input.size(); ) { if (input[i] == '[') { size_t end = input.find(']', i + 1); if (end != Rml::String::npos) { Rml::String key = input.substr(i + 1, end - i - 1); std::wstring wkey = utils.Utf8ToWide(key); if (!wkey.empty()) { LPCWSTR wstr = app.GetString(wkey); if (wstr && wcslen(wstr) > 0) { std::string utf8 = utils.WideToUtf8(wstr); if (!utf8.empty()) { result += utf8; count++; } else result += input.substr(i, end - i + 1); } else result += input.substr(i, end - i + 1); } else result += input.substr(i, end - i + 1); i = end + 1; } else { result += input[i]; i++; } } else { result += input[i]; i++; } } translated = result; return count; } void SystemInterface_Win64::JoinPath(Rml::String& translated_path, const Rml::String& document_path, const Rml::String& path) { Rml::SystemInterface::JoinPath(translated_path, document_path, path); } bool SystemInterface_Win64::LogMessage(Rml::Log::Type type, const Rml::String& message) { app.DebugPrintf("[RmlUi] %s\n", message.c_str()); return true; } void SystemInterface_Win64::SetMouseCursor(const Rml::String& cursor_name) { static HCURSOR cursor_default = LoadCursor(nullptr, IDC_ARROW); static HCURSOR cursor_move = LoadCursor(nullptr, IDC_SIZEALL); static HCURSOR cursor_pointer = LoadCursor(nullptr, IDC_HAND); static HCURSOR cursor_resize = LoadCursor(nullptr, IDC_SIZEWE); static HCURSOR cursor_cross = LoadCursor(nullptr, IDC_CROSS); static HCURSOR cursor_text = LoadCursor(nullptr, IDC_IBEAM); static HCURSOR cursor_unavailable = LoadCursor(nullptr, IDC_NO); extern HWND g_hWnd; HCURSOR cursor_handle = nullptr; if (cursor_name.empty() || cursor_name == "arrow") cursor_handle = cursor_default; else if (cursor_name == "pointer") cursor_handle = cursor_pointer; else if (cursor_name == "move") cursor_handle = cursor_move; else if (cursor_name == "resize") cursor_handle = cursor_resize; else if (cursor_name == "cross") cursor_handle = cursor_cross; else if (cursor_name == "text") cursor_handle = cursor_text; else if (cursor_name == "unavailable" || cursor_name == "not-allowed") cursor_handle = cursor_unavailable; if (cursor_handle && g_hWnd) { SetCursor(cursor_handle); SetClassLongPtrA(g_hWnd, GCLP_HCURSOR, (LONG_PTR)cursor_handle); } } void SystemInterface_Win64::SetClipboardText(const Rml::String& text) { if (!OpenClipboard(nullptr)) return; EmptyClipboard(); HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, text.size() + 1); if (hGlobal) { memcpy(GlobalLock(hGlobal), text.c_str(), text.size() + 1); GlobalUnlock(hGlobal); SetClipboardData(CF_TEXT, hGlobal); } CloseClipboard(); } void SystemInterface_Win64::GetClipboardText(Rml::String& text) { text.clear(); if (!OpenClipboard(nullptr)) return; HANDLE hData = GetClipboardData(CF_TEXT); if (hData) { char* pszText = static_cast(GlobalLock(hData)); if (pszText) { text = pszText; GlobalUnlock(hData); } } CloseClipboard(); } void SystemInterface_Win64::ActivateKeyboard(Rml::Vector2f /*caret_position*/, float /*line_height*/) { } void SystemInterface_Win64::DeactivateKeyboard() { }