summaryrefslogtreecommitdiff
path: root/wx+/dc.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <shieldwed@outlook.com>2018-05-09 00:11:35 +0200
committerDaniel Wilhelm <shieldwed@outlook.com>2018-05-09 00:11:35 +0200
commit015bb675d6eb177900c8ac94a6d35edc5ad90576 (patch)
treeedde4153ce9b2ba6bdaf9d3c0af0966ed6dfd717 /wx+/dc.h
parent9.8 (diff)
downloadFreeFileSync-015bb675d6eb177900c8ac94a6d35edc5ad90576.tar.gz
FreeFileSync-015bb675d6eb177900c8ac94a6d35edc5ad90576.tar.bz2
FreeFileSync-015bb675d6eb177900c8ac94a6d35edc5ad90576.zip
9.9
Diffstat (limited to 'wx+/dc.h')
-rwxr-xr-xwx+/dc.h21
1 files changed, 21 insertions, 0 deletions
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 <unordered_map>
#include <zen/optional.h>
+#include <zen/basic_math.h>
#include <wx/dcbuffer.h> //for macro: wxALWAYS_NATIVE_DOUBLE_BUFFER
+#include <wx/dcscreen.h>
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
+}
+
bgstack15