Really implement wxGraphicsContext::GetDPI()

Return the DPI of the associated window, if any, instead of always
returning hard-coded 72*72.
This commit is contained in:
Vadim Zeitlin 2018-11-06 03:19:27 +01:00
parent 5e53b22bd4
commit d5c43831b5
2 changed files with 16 additions and 3 deletions

View File

@ -128,7 +128,7 @@ All (GUI):
- Add wxGrid::SetCornerLabelValue() (Pavel Kalugin).
- Add strikethrough support for fonts defined in XRC.
- Add wxDisplay::GetPPI().
- Add wxGraphicsContext::GetWindow().
- Add wxGraphicsContext::GetWindow() and implement wxGraphicsContext::GetDPI().
wxGTK:

View File

@ -31,6 +31,8 @@
#include "wx/log.h"
#endif
#include "wx/display.h"
#ifdef __WXMSW__
#include "wx/msw/enhmeta.h"
#endif
@ -620,8 +622,19 @@ wxDouble wxGraphicsContext::GetAlpha() const
void wxGraphicsContext::GetDPI( wxDouble* dpiX, wxDouble* dpiY)
{
*dpiX = 72.0;
*dpiY = 72.0;
if ( m_window )
{
const wxSize ppi = wxDisplay(m_window).GetPPI();
*dpiX = ppi.x;
*dpiY = ppi.y;
}
else
{
// Use some standard DPI value, it doesn't make much sense for the
// contexts not using any pixels anyhow.
*dpiX = 72.0;
*dpiY = 72.0;
}
}
// sets the pen