Simplify mm-to-pixel conversion
wxDisplay can already tell us the PPI, just convert it to mm.
This commit is contained in:
parent
64d1d27da9
commit
a65ada2a5e
1 changed files with 9 additions and 8 deletions
|
|
@ -1397,13 +1397,17 @@ float wxDCImpl::GetFontPointSizeAdjustment(float dpi)
|
|||
return float(wxDisplay::GetStdPPIValue()) / dpi;
|
||||
}
|
||||
|
||||
static void mmToPx(wxWindow* win, double& x, double& y)
|
||||
{
|
||||
const wxSize ppi(win ? wxDisplay(win).GetPPI() : wxGetDisplayPPI());
|
||||
x = ppi.x * mm2inches;
|
||||
y = ppi.y * mm2inches;
|
||||
}
|
||||
|
||||
double wxDCImpl::GetMMToPXx() const
|
||||
{
|
||||
if ( wxIsNullDouble(m_mm_to_pix_x) )
|
||||
{
|
||||
m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() /
|
||||
(double)wxGetDisplaySizeMM().GetWidth();
|
||||
}
|
||||
mmToPx(m_window, m_mm_to_pix_x, m_mm_to_pix_y);
|
||||
|
||||
return m_mm_to_pix_x;
|
||||
}
|
||||
|
|
@ -1411,10 +1415,7 @@ double wxDCImpl::GetMMToPXx() const
|
|||
double wxDCImpl::GetMMToPXy() const
|
||||
{
|
||||
if ( wxIsNullDouble(m_mm_to_pix_y) )
|
||||
{
|
||||
m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() /
|
||||
(double)wxGetDisplaySizeMM().GetHeight();
|
||||
}
|
||||
mmToPx(m_window, m_mm_to_pix_x, m_mm_to_pix_y);
|
||||
|
||||
return m_mm_to_pix_y;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue