Add OSXMakeDPIFromScaleFactor() helper
No real changes, just avoid repeating wxRound(scaleFactor*72) in several places and do it in this single function instead.
This commit is contained in:
@@ -294,6 +294,9 @@ public:
|
|||||||
// internal response to size events
|
// internal response to size events
|
||||||
virtual void MacOnInternalSize() {}
|
virtual void MacOnInternalSize() {}
|
||||||
|
|
||||||
|
// Return the DPI corresponding to the given scale factor.
|
||||||
|
static wxSize OSXMakeDPIFromScaleFactor(double scaleFactor);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// For controls like radio buttons which are genuinely composite
|
// For controls like radio buttons which are genuinely composite
|
||||||
wxList m_subControls;
|
wxList m_subControls;
|
||||||
|
@@ -629,8 +629,8 @@ extern int wxOSXGetIdFromSelector(SEL action );
|
|||||||
doubleValue];
|
doubleValue];
|
||||||
if (newBackingScaleFactor != oldBackingScaleFactor)
|
if (newBackingScaleFactor != oldBackingScaleFactor)
|
||||||
{
|
{
|
||||||
wxSize oldDPI((int)(oldBackingScaleFactor*72.0),(int)(oldBackingScaleFactor*72.0));
|
const wxSize oldDPI = wxWindow::OSXMakeDPIFromScaleFactor(oldBackingScaleFactor);
|
||||||
wxSize newDPI((int)(newBackingScaleFactor*72.0),(int)(newBackingScaleFactor*72.0));
|
const wxSize newDPI = wxWindow::OSXMakeDPIFromScaleFactor(newBackingScaleFactor);
|
||||||
|
|
||||||
wxDPIChangedEvent event(oldDPI, newDPI);
|
wxDPIChangedEvent event(oldDPI, newDPI);
|
||||||
event.SetEventObject(wxpeer);
|
event.SetEventObject(wxpeer);
|
||||||
|
@@ -2620,6 +2620,14 @@ bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event )
|
|||||||
return handled ;
|
return handled ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
wxSize wxWindowMac::OSXMakeDPIFromScaleFactor(double scaleFactor)
|
||||||
|
{
|
||||||
|
const int dpi = wxRound(scaleFactor*72.0);
|
||||||
|
|
||||||
|
return wxSize(dpi, dpi);
|
||||||
|
}
|
||||||
|
|
||||||
wxSize wxWindowMac::GetDPI() const
|
wxSize wxWindowMac::GetDPI() const
|
||||||
{
|
{
|
||||||
double scaleFactor;
|
double scaleFactor;
|
||||||
@@ -2628,7 +2636,7 @@ wxSize wxWindowMac::GetDPI() const
|
|||||||
else
|
else
|
||||||
scaleFactor = wxOSXGetMainScreenContentScaleFactor();
|
scaleFactor = wxOSXGetMainScreenContentScaleFactor();
|
||||||
|
|
||||||
return wxSize(wxRound(scaleFactor*72.0),wxRound(scaleFactor*72.0));
|
return OSXMakeDPIFromScaleFactor(scaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user