2017-03-15 12:56:06 +00:00
|
|
|
#pragma once
|
|
|
|
#include <Windows.h>
|
|
|
|
|
|
|
|
namespace brightray {
|
|
|
|
|
2017-04-03 10:11:39 +00:00
|
|
|
struct NotificationData {
|
2017-03-15 12:56:06 +00:00
|
|
|
DesktopNotificationController* controller = nullptr;
|
|
|
|
|
|
|
|
std::wstring caption;
|
2017-03-17 13:41:22 +00:00
|
|
|
std::wstring body_text;
|
2017-03-15 12:56:06 +00:00
|
|
|
HBITMAP image = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
NotificationData() = default;
|
|
|
|
|
2017-04-03 10:11:39 +00:00
|
|
|
~NotificationData() {
|
2017-04-03 11:34:01 +00:00
|
|
|
if (image) DeleteObject(image);
|
2017-03-15 12:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NotificationData(const NotificationData& other) = delete;
|
|
|
|
NotificationData& operator=(const NotificationData& other) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
2017-04-03 10:11:39 +00:00
|
|
|
inline T ScaleForDpi(T value, unsigned dpi) {
|
2017-03-15 12:56:06 +00:00
|
|
|
return value * dpi / 96;
|
|
|
|
}
|
|
|
|
|
2017-04-03 10:11:39 +00:00
|
|
|
struct ScreenMetrics {
|
2017-03-17 13:41:22 +00:00
|
|
|
UINT dpi_x, dpi_y;
|
2017-03-15 12:56:06 +00:00
|
|
|
|
2017-04-03 10:11:39 +00:00
|
|
|
ScreenMetrics() {
|
2017-03-15 12:56:06 +00:00
|
|
|
typedef HRESULT WINAPI GetDpiForMonitor_t(HMONITOR, int, UINT*, UINT*);
|
2017-04-03 08:38:21 +00:00
|
|
|
auto GetDpiForMonitor =
|
|
|
|
(GetDpiForMonitor_t*)GetProcAddress(GetModuleHandle(TEXT("shcore")),
|
|
|
|
"GetDpiForMonitor");
|
2017-04-03 11:34:01 +00:00
|
|
|
if (GetDpiForMonitor) {
|
2017-03-15 12:56:06 +00:00
|
|
|
auto monitor = MonitorFromPoint({}, MONITOR_DEFAULTTOPRIMARY);
|
2017-04-03 11:34:01 +00:00
|
|
|
if (GetDpiForMonitor(monitor, 0, &dpi_x, &dpi_y) == S_OK)
|
2017-03-15 12:56:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
HDC hdc = GetDC(NULL);
|
2017-03-17 13:41:22 +00:00
|
|
|
dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
|
|
|
|
dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
|
2017-03-15 12:56:06 +00:00
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
}
|
|
|
|
|
2017-04-03 08:38:21 +00:00
|
|
|
template<class T> T X(T value) const { return ScaleForDpi(value, dpi_x); }
|
|
|
|
template<class T> T Y(T value) const { return ScaleForDpi(value, dpi_y); }
|
2017-03-15 12:56:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|