Add wxRescaleCoord() helper and use it

No real changes, just make the code a bit shorter and more clear by
using a dedicated function rather than wxMulDivInt32() directly.
This commit is contained in:
Vadim Zeitlin
2021-07-11 19:31:17 +01:00
parent 7c6f290995
commit 453468f2f9
5 changed files with 50 additions and 28 deletions

View File

@@ -1345,3 +1345,20 @@ void wxDisplaySizeMM(int* width, int* height);
wxSize wxGetDisplaySizeMM();
//@}
/**
Scale the given value by the ratio between 2 other values, with rounding.
Do not scale the value if it's -1, just return it unchanged in this case.
This simply calls wxMulDivInt32() with the provided arguments, but provides
a more clear name for this operation.
@since 3.1.6
*/
int wxRescaleCoord(int n, int newScale, int oldScale);
/// @overload
wxPoint wxRescaleCoord(wxPoint pt, wxSize newScale, wxSize oldScale);
/// @overload
wxSize wxRescaleCoord(wxSize sz, wxSize newScale, wxSize oldScale);