From bc7a3ceebaed362ee622ed912c521486112b4040 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 28 Jun 2013 13:24:27 +0000 Subject: [PATCH] support getting device resolution on all osx ports git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74303 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/cocoa/private.h | 1 - include/wx/osx/core/private.h | 4 +++- src/osx/carbon/utilscocoa.mm | 29 ++++++++++++++++++++++++++++- src/osx/core/bitmap.cpp | 2 -- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/include/wx/osx/cocoa/private.h b/include/wx/osx/cocoa/private.h index 49dd2b4eeb..e55ea62c1b 100644 --- a/include/wx/osx/cocoa/private.h +++ b/include/wx/osx/cocoa/private.h @@ -42,7 +42,6 @@ OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage( WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCGImage( CGImageRef image, double scale = 1.0 ); CGImageRef WXDLLIMPEXP_CORE wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage, double *scale = NULL ); CGContextRef WXDLLIMPEXP_CORE wxOSXCreateBitmapContextFromNSImage( WX_NSImage nsimage); -double WXDLLIMPEXP_CORE wxOSXGetMainScreenContentScaleFactor(); wxBitmap WXDLLIMPEXP_CORE wxOSXCreateSystemBitmap(const wxString& id, const wxString &client, const wxSize& size); WXWindow WXDLLIMPEXP_CORE wxOSXGetMainWindow(); diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h index 9c4660a765..fb1d230c32 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -122,7 +122,9 @@ WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithCFData( CFDataRe WXDLLIMPEXP_CORE CGDataConsumerRef wxMacCGDataConsumerCreateWithCFData( CFMutableDataRef data ); WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer& buf ); -CGColorSpaceRef WXDLLIMPEXP_CORE wxMacGetGenericRGBColorSpace(void); +WXDLLIMPEXP_CORE CGColorSpaceRef wxMacGetGenericRGBColorSpace(void); + +WXDLLIMPEXP_CORE double wxOSXGetMainScreenContentScaleFactor(); class wxWindowMac; // to diff --git a/src/osx/carbon/utilscocoa.mm b/src/osx/carbon/utilscocoa.mm index ff1d770dbc..58ec857b1a 100644 --- a/src/osx/carbon/utilscocoa.mm +++ b/src/osx/carbon/utilscocoa.mm @@ -381,6 +381,33 @@ wxBitmap wxOSXCreateSystemBitmap(const wxString& name, const wxString &client, c #endif } +double wxOSXGetMainScreenContentScaleFactor() +{ + double scale; + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000 + if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) + { + scale=[[UIScreen mainScreen] scale]; + } + else +#endif + { + scale=1.0; + } + + return scale; +} + +#endif + +#if wxOSX_USE_CARBON + +double wxOSXGetMainScreenContentScaleFactor() +{ + return 1.0; +} + #endif #if wxOSX_USE_COCOA @@ -446,7 +473,7 @@ CGContextRef WXDLLIMPEXP_CORE wxOSXCreateBitmapContextFromNSImage( WX_NSImage ns return hbitmap; } -double WXDLLIMPEXP_CORE wxOSXGetMainScreenContentScaleFactor() +double wxOSXGetMainScreenContentScaleFactor() { #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) if ( [ [NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)] ) diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index 4da8104bf9..ac0804d1f1 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -1857,13 +1857,11 @@ bool wxBundleResourceHandler::LoadFile(wxBitmap *bitmap, wxCFRef imageURL; -#if wxOSX_USE_COCOA if ( wxOSXGetMainScreenContentScaleFactor() > 1.9 ) { imageURL.reset(CFBundleCopyResourceURL(CFBundleGetMainBundle(), resname2x, restype, NULL)); scale = 2.0; } -#endif if ( imageURL.get() == NULL ) { -- 2.45.2