diff options
author | B Stack <bgstack15@gmail.com> | 2021-04-05 11:02:07 -0400 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2021-04-05 11:02:07 -0400 |
commit | 74361d859354e4416285cd803b1b0075be1fe514 (patch) | |
tree | dafb5e266c513a5ed9863401e62d246742861e0c /wx+/dc.h | |
parent | Merge branch '11.7' into 'master' (diff) | |
download | FreeFileSync-74361d859354e4416285cd803b1b0075be1fe514.tar.gz FreeFileSync-74361d859354e4416285cd803b1b0075be1fe514.tar.bz2 FreeFileSync-74361d859354e4416285cd803b1b0075be1fe514.zip |
add upstream 11.9
Diffstat (limited to 'wx+/dc.h')
-rw-r--r-- | wx+/dc.h | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -64,9 +64,10 @@ void drawFilledRectangle(wxDC& dc, wxRect rect, int borderWidth, const wxColor& /* 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) */ +constexpr int defaultDpi = 96; inline -int fastFromDIP(int d) //like wxWindow::FromDIP (but tied to primary monitor and buffered) +int getDPI() { #ifndef wxHAVE_DPI_INDEPENDENT_PIXELS #error why is wxHAVE_DPI_INDEPENDENT_PIXELS not defined? @@ -75,11 +76,24 @@ int fastFromDIP(int d) //like wxWindow::FromDIP (but tied to primary monitor and //=> requires general fix at wxWidgets-level //https://github.com/wxWidgets/wxWidgets/blob/d9d05c2bb201078f5e762c42458ca2f74af5b322/include/wx/window.h#L2060 - return d; //e.g. macOS, GTK3 + return defaultDpi; //e.g. macOS, GTK3 +} + + +inline +int fastFromDIP(int d) //like wxWindow::FromDIP (but tied to primary monitor and buffered) +{ + return numeric::intDivRound(d * getDPI() - 10 /*round values like 1.5 down => 1 pixel on 150% scale*/, defaultDpi); } int fastFromDIP(double d) = delete; +inline +int getDpiScalePercent() +{ + return numeric::intDivRound(100 * getDPI(), defaultDpi); +} + //---------------------- implementation ------------------------ class RecursiveDcClipper |