From 015bb675d6eb177900c8ac94a6d35edc5ad90576 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Wed, 9 May 2018 00:11:35 +0200 Subject: 9.9 --- wx+/dc.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'wx+/dc.h') diff --git a/wx+/dc.h b/wx+/dc.h index 55047a53..23c70d3f 100755 --- a/wx+/dc.h +++ b/wx+/dc.h @@ -9,7 +9,9 @@ #include #include +#include #include //for macro: wxALWAYS_NATIVE_DOUBLE_BUFFER +#include namespace zen @@ -41,6 +43,25 @@ void clearArea(wxDC& dc, const wxRect& rect, const wxColor& col) } +/* +Standard DPI: + Windows/Ubuntu: 96 x 96 + macOS: wxWidgets uses DIP (note: wxScreenDC().GetPPI() returns 72 x 72 which is a lie; looks like 96 x 96) +*/ +inline +int fastFromDIP(int d) //like wxWindow::FromDIP (but tied to primary monitor and buffered) +{ + +#ifdef wxHAVE_DPI_INDEPENDENT_PIXELS //pulled from wx/window.h + return d; //e.g. macOS, GTK3 +#else + assert(wxTheApp); //only call after wxWidgets was initalized! + static const int dpiY = wxScreenDC().GetPPI().y; //perf: buffering for calls to ::GetDeviceCaps() needed!? + const int defaultDpi = 96; + return numeric::round(1.0 * d * dpiY / defaultDpi); +#endif +} + -- cgit