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:
@@ -3444,6 +3444,38 @@ public:
|
||||
Returns the new DPI.
|
||||
*/
|
||||
wxSize GetNewDPI() const;
|
||||
|
||||
/**
|
||||
Rescale a value in pixels to match the new DPI.
|
||||
|
||||
This is a convenience function to use in wxEVT_DPI_CHANGED event
|
||||
handlers, as they often need to update some sizes to the new DPI.
|
||||
It simply calls wxRescaleCoord() with GetNewDPI() and GetOldDPI().
|
||||
|
||||
For example, the returned value will be twice bigger than the original
|
||||
one when switching from normal (96) DPI to high (2x, 192) DPI.
|
||||
|
||||
@since 3.1.6
|
||||
*/
|
||||
wxSize Scale(wxSize sz) const;
|
||||
|
||||
/**
|
||||
Rescale horizontal component to match the new DPI.
|
||||
|
||||
This is the same as Scale(), but for the horizontal component only.
|
||||
|
||||
@since 3.1.6
|
||||
*/
|
||||
int ScaleX(int x) const;
|
||||
|
||||
/**
|
||||
Rescale vertical component to match the new DPI.
|
||||
|
||||
This is the same as Scale(), but for the vertical component only.
|
||||
|
||||
@since 3.1.6
|
||||
*/
|
||||
int ScaleY(int y) const;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user