Improve wxD2DContext::GetDPI and wxGDIPlusContext::GetDPI
If there is a valid wxWindow, use its DPI. Otherwise use a dedicated function of the context to get the DPI. Don't use the common wxGraphicsContext::GetDPI because this will return hard-coded 72 when there is no valid wxWindow.
This commit is contained in:
@@ -458,6 +458,7 @@ public:
|
||||
virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const wxOVERRIDE;
|
||||
virtual bool ShouldOffset() const wxOVERRIDE;
|
||||
virtual void GetSize( wxDouble* width, wxDouble *height );
|
||||
virtual void GetDPI(wxDouble* dpiX, wxDouble* dpiY) const wxOVERRIDE;
|
||||
|
||||
Graphics* GetGraphics() const { return m_context; }
|
||||
|
||||
@@ -2397,6 +2398,26 @@ void wxGDIPlusContext::GetSize( wxDouble* width, wxDouble *height )
|
||||
*height = m_height;
|
||||
}
|
||||
|
||||
void wxGDIPlusContext::GetDPI(wxDouble* dpiX, wxDouble* dpiY) const
|
||||
{
|
||||
if ( GetWindow() )
|
||||
{
|
||||
const wxSize dpi = GetWindow()->GetDPI();
|
||||
|
||||
if ( dpiX )
|
||||
*dpiX = dpi.x;
|
||||
if ( dpiY )
|
||||
*dpiY = dpi.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( dpiX )
|
||||
*dpiX = GetGraphics()->GetDpiX();
|
||||
if ( dpiY )
|
||||
*dpiY = GetGraphics()->GetDpiY();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxGDIPlusPrintingContext implementation
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@@ -4575,11 +4575,26 @@ void wxD2DContext::Flush()
|
||||
}
|
||||
|
||||
void wxD2DContext::GetDPI(wxDouble* dpiX, wxDouble* dpiY) const
|
||||
{
|
||||
if ( GetWindow() )
|
||||
{
|
||||
const wxSize dpi = GetWindow()->GetDPI();
|
||||
|
||||
if ( dpiX )
|
||||
*dpiX = dpi.x;
|
||||
if ( dpiY )
|
||||
*dpiY = dpi.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
FLOAT x, y;
|
||||
GetRenderTarget()->GetDpi(&x, &y);
|
||||
if (dpiX != NULL) *dpiX = x;
|
||||
if (dpiY != NULL) *dpiY = y;
|
||||
|
||||
if ( dpiX )
|
||||
*dpiX = x;
|
||||
if ( dpiY )
|
||||
*dpiY = y;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user