Add GetDPIScaleFactor to wxDC and wxGraphicsContext

It can be used to scale coordinates and sizes to make them DPI aware.

In the common headers, use wxDisplay::GetStdPPIValue() as default DPI value,
so the correct values are used on Windows (96) and macOS (72).

In wxMemoryDC use m_contentScaleFactor as the DPIScaleFactor, see e4c2298e5e
(Use window scale factor for all MSW wxDCs associated with windows, 2022-04-04).
This commit is contained in:
Maarten Bent
2022-04-16 00:31:10 +02:00
parent d72a3f7cec
commit ee2b02614e
9 changed files with 39 additions and 6 deletions

View File

@@ -24,6 +24,8 @@
#include "wx/geometry.h"
#endif
#include "wx/display.h"
//-----------------------------------------------------------------------------
// Local functions
//-----------------------------------------------------------------------------
@@ -485,7 +487,12 @@ wxSize wxGCDCImpl::GetPPI() const
// This is the same value that wxGraphicsContext::GetDPI() returns by
// default.
return wxSize(72, 72);
return wxDisplay::GetStdPPI();
}
double wxGCDCImpl::GetDPIScaleFactor() const
{
return m_graphicContext ? m_graphicContext->GetDPIScaleFactor() : 1.0;
}
int wxGCDCImpl::GetDepth() const