making GetDPIScaleFactor virtual, adding macOS direct impl

This commit is contained in:
Stefan Csomor
2020-08-08 18:43:55 +02:00
committed by Vadim Zeitlin
parent 8bad3b5e80
commit 7dc67a1f9f
3 changed files with 10 additions and 2 deletions

View File

@@ -121,6 +121,7 @@ public:
#endif // wxUSE_HOTKEY #endif // wxUSE_HOTKEY
virtual wxSize GetDPI() const wxOVERRIDE; virtual wxSize GetDPI() const wxOVERRIDE;
virtual double GetDPIScaleFactor() const wxOVERRIDE;
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget( wxDropTarget *dropTarget ) wxOVERRIDE; virtual void SetDropTarget( wxDropTarget *dropTarget ) wxOVERRIDE;

View File

@@ -537,7 +537,7 @@ public:
// Return the ratio of the DPI used by this window to the standard DPI, // Return the ratio of the DPI used by this window to the standard DPI,
// e.g. 1 for standard DPI screens and 2 for "200% scaling". // e.g. 1 for standard DPI screens and 2 for "200% scaling".
double GetDPIScaleFactor() const; virtual double GetDPIScaleFactor() const;
// return the size of the left/right and top/bottom borders in x and y // return the size of the left/right and top/bottom borders in x and y
// components of the result respectively // components of the result respectively

View File

@@ -2629,6 +2629,12 @@ wxSize wxWindowMac::OSXMakeDPIFromScaleFactor(double scaleFactor)
} }
wxSize wxWindowMac::GetDPI() const wxSize wxWindowMac::GetDPI() const
{
return OSXMakeDPIFromScaleFactor(GetDPIScaleFactor());
}
// on mac ContentScale and DPIScale are identical
double wxWindowMac::GetDPIScaleFactor() const
{ {
double scaleFactor; double scaleFactor;
if ( wxNonOwnedWindow* tlw = MacGetTopLevelWindow() ) if ( wxNonOwnedWindow* tlw = MacGetTopLevelWindow() )
@@ -2636,9 +2642,10 @@ wxSize wxWindowMac::GetDPI() const
else else
scaleFactor = wxOSXGetMainScreenContentScaleFactor(); scaleFactor = wxOSXGetMainScreenContentScaleFactor();
return OSXMakeDPIFromScaleFactor(scaleFactor); return scaleFactor;
} }
// //
// wxWidgetImpl // wxWidgetImpl
// //