New topic: Function ScalingFactor(Extends G As Graphics) As Single
<http://forums.realsoftware.com/viewtopic.php?t=46646> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message Markus Winter Post subject: Function ScalingFactor(Extends G As Graphics) As SinglePosted: Tue Jan 22, 2013 4:56 pm Joined: Sun Feb 19, 2006 4:00 pm Posts: 1240 Location: Heidelberg, Germany Hi all, nobody on the mailing list was answering, so maybe someone on the forum can answer my question about how to deal with retina displays: > Iâm looking at the following code from Thom: > >> For those that would like to do this without plugins, declares work >> exceptionally well. First, you'll need to define the CGSize structure: >> >> CGSize: >> Width As Single >> Height As Single >> >> And then an extension method for the graphics class: >> >> Function ScalingFactor(Extends G As Graphics) As Single >> #if TargetCocoa >> Declare Function CGContextConvertSizeToDeviceSpace Lib >> "ApplicationServices" (Context As Integer, UserSize As CGSize) As CGSize >> If >> System.IsFunctionAvailable("CGContextConvertSizeToDeviceSpace","ApplicationServices") >> Then >> Dim UserSize As CGSize >> UserSize.Width = 100 >> UserSize.Height = 100 >> Dim Handle As Integer = G.Handle(Graphics.HandleTypeCGContextRef) >> Dim DeviceSize As CGSize = >> CGContextConvertSizeToDeviceSpace(Handle,UserSize) >> Return DeviceSize.Width / UserSize.Width >> Else >> Return 1 >> End If >> #else >> Return 1 >> #endif >> End Function > > Could one not also simply do > > Function ScalingFactor(Extends G As Graphics) As Single > > If System.IsFunctionAvailable("BackingScaleFactor", "AppKit") then > Declare Function BackingScaleFactor Lib "AppKit" Selector > "backingScaleFactor" (target As WindowPtr) As Double > Return BackingScaleFactor( w ) > else > return 1 > end if > > End Function > > or am I missing something? > > Markus Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ]
-- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml rbforumnotifier@monkeybreadsoftware.de