Add wxDPIChangedEvent::Scale() and use it in this event handlers

This is more concise and less error-prone than multiplying/dividing DPI
values manually.

No real changes except, maybe, in wxSlider code where the rounding was
done differently before for some reason.
This commit is contained in:
Vadim Zeitlin
2021-07-11 19:31:51 +01:00
parent 453468f2f9
commit 3787f55a6b
9 changed files with 51 additions and 17 deletions

View File

@@ -446,9 +446,10 @@ void wxListCtrl::OnDPIChanged(wxDPIChangedEvent &event)
for ( int i = 0; i < numCols; ++i )
{
int width = GetColumnWidth(i);
if ( width > 0 )
width = width * event.GetNewDPI().x / event.GetOldDPI().x;
SetColumnWidth(i, width);
if ( width <= 0 )
continue;
SetColumnWidth(i, event.ScaleX(width));
}
}