Add FromDIP to wxDC and wxGraphicsContext

Using the same implementation as wxWindow has.
This commit is contained in:
Maarten Bent
2022-04-20 00:50:39 +02:00
parent fda41cdd1b
commit 15a37b91fb
4 changed files with 49 additions and 0 deletions

View File

@@ -34,6 +34,7 @@
#endif
#include "wx/private/graphics.h"
#include "wx/private/rescale.h"
#include "wx/display.h"
//-----------------------------------------------------------------------------
@@ -641,6 +642,18 @@ void wxGraphicsContext::GetDPI( wxDouble* dpiX, wxDouble* dpiY) const
}
}
wxSize wxGraphicsContext::FromDIP(const wxSize& sz) const
{
#ifdef wxHAS_DPI_INDEPENDENT_PIXELS
return sz;
#else
wxRealPoint dpi;
GetDPI(&dpi.x, &dpi.y);
const wxSize baseline = wxDisplay::GetStdPPI();
return wxRescaleCoord(sz).From(baseline).To(wxSize((int)dpi.x, (int)dpi.y));
#endif // wxHAS_DPI_INDEPENDENT_PIXELS
}
// sets the pen
void wxGraphicsContext::SetPen( const wxGraphicsPen& pen )
{