Revision: 7523
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7523&view=rev
Author:   hofman
Date:     2011-10-24 22:29:16 +0000 (Mon, 24 Oct 2011)
Log Message:
-----------
separate code for physical scale factor

Modified Paths:
--------------
    trunk/PDFView_SKExtensions.m

Modified: trunk/PDFView_SKExtensions.m
===================================================================
--- trunk/PDFView_SKExtensions.m        2011-10-24 17:11:05 UTC (rev 7522)
+++ trunk/PDFView_SKExtensions.m        2011-10-24 22:29:16 UTC (rev 7523)
@@ -44,27 +44,20 @@
 
 @dynamic physicalScaleFactor, scrollView;
 
-- (CGFloat)physicalScaleFactor {
-    CGFloat scale = [self scaleFactor];
-    NSScreen *screen = [[self window] screen];
+static inline CGFloat physicalScaleFactorForView(NSView *view) {
+    NSScreen *screen = [[view window] screen];
        CGDirectDisplayID displayID = (CGDirectDisplayID)[[[screen 
deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue];
        CGSize physicalSize = CGDisplayScreenSize(displayID);
     NSSize resolution = [[[screen deviceDescription] 
objectForKey:NSDeviceResolution] sizeValue];
-       
-    if (CGSizeEqualToSize(physicalSize, CGSizeZero) == NO)
-        scale *= (physicalSize.width * resolution.width) / 
(CGDisplayPixelsWide(displayID) * 25.4f);
-    return scale;
+       return CGSizeEqualToSize(physicalSize, CGSizeZero) ? 1.0 : 
(physicalSize.width * resolution.width) / (CGDisplayPixelsWide(displayID) * 
25.4f);
 }
 
+- (CGFloat)physicalScaleFactor {
+    return [self scaleFactor] * physicalScaleFactorForView(self);
+}
+
 - (void)setPhysicalScaleFactor:(CGFloat)scale {
-    NSScreen *screen = [[self window] screen];
-       CGDirectDisplayID displayID = (CGDirectDisplayID)[[[screen 
deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue];
-       CGSize physicalSize = CGDisplayScreenSize(displayID);
-    NSSize resolution = [[[screen deviceDescription] 
objectForKey:NSDeviceResolution] sizeValue];
-       
-    if (CGSizeEqualToSize(physicalSize, CGSizeZero) == NO)
-        scale *= CGDisplayPixelsWide(displayID) * 25.4f / (physicalSize.width 
* resolution.width);
-    [self setScaleFactor:scale];
+    [self setScaleFactor:scale / physicalScaleFactorForView(self)];
 }
 
 - (NSScrollView *)scrollView {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to