Make wxWindow::GetContentScaleFactor() useful for non-OSX platforms.
Return the ration of the current DPI to the standard one to allow using this function to scale pixel values for the current screen resolution.
This commit is contained in:
@@ -791,6 +791,21 @@ wxSize wxWindowBase::DoGetBestSize() const
|
||||
return best;
|
||||
}
|
||||
|
||||
double wxWindowBase::GetContentScaleFactor() const
|
||||
{
|
||||
// Currently we don't support per-monitor DPI, so it's useless to construct
|
||||
// a DC associated with this window, just use the global value.
|
||||
//
|
||||
// We also use just the vertical component of the DPI because it's the one
|
||||
// that counts most and, in practice, it's equal to the horizontal one
|
||||
// anyhow.
|
||||
//
|
||||
// Finally, we consider 96 DPI to be the standard value, this is correct
|
||||
// at least for MSW, but could conceivably need adjustment for the other
|
||||
// platforms.
|
||||
return wxScreenDC().GetPPI().y / 96.;
|
||||
}
|
||||
|
||||
// helper of GetWindowBorderSize(): as many ports don't implement support for
|
||||
// wxSYS_BORDER/EDGE_X/Y metrics in their wxSystemSettings, use hard coded
|
||||
// fallbacks in this case
|
||||
|
Reference in New Issue
Block a user