Revision: 6634
          http://skim-app.svn.sourceforge.net/skim-app/?rev=6634&view=rev
Author:   hofman
Date:     2010-07-21 10:18:05 +0000 (Wed, 21 Jul 2010)

Log Message:
-----------
NSScreen category in separate files

Modified Paths:
--------------
    trunk/SKApplicationController.m
    trunk/SKImageToolTipWindow.m
    trunk/SKMainWindowController.m
    trunk/Skim.xcodeproj/project.pbxproj

Added Paths:
-----------
    trunk/NSScreen_SKExtensions.h
    trunk/NSScreen_SKExtensions.m

Added: trunk/NSScreen_SKExtensions.h
===================================================================
--- trunk/NSScreen_SKExtensions.h                               (rev 0)
+++ trunk/NSScreen_SKExtensions.h       2010-07-21 10:18:05 UTC (rev 6634)
@@ -0,0 +1,48 @@
+//
+//  NSScreen_SKExtensions.h
+//  Skim
+//
+//  Created by Christiaan on 7/21/10.
+/*
+ This software is Copyright (c) 2010
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+
+...@interface NSScreen (SKExtensions)
+
++ (NSScreen *)primaryScreen;
+
++ (NSScreen *)screenForPoint:(NSPoint)point;
+
+...@end

Added: trunk/NSScreen_SKExtensions.m
===================================================================
--- trunk/NSScreen_SKExtensions.m                               (rev 0)
+++ trunk/NSScreen_SKExtensions.m       2010-07-21 10:18:05 UTC (rev 6634)
@@ -0,0 +1,89 @@
+//
+//  NSScreen_SKExtensions.m
+//  Skim
+//
+//  Created by Christiaan on 7/21/10.
+/*
+ This software is Copyright (c) 2010
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "NSScreen_SKExtensions.h"
+
+
+...@implementation NSScreen (SKExtensions)
+
+
++ (NSScreen *)primaryScreen {
+    return [[self screens] objectAtIndex:0];
+}
+
+static inline CGFloat SKSquaredDistanceFromPointToRect(NSPoint point, NSRect 
rect) {
+    CGFloat dx, dy;
+
+    if (point.x < NSMinX(rect))
+        dx = NSMinX(rect) - point.x;
+    else if (point.x > NSMaxX(rect))
+        dx = point.x - NSMaxX(rect);
+    else
+        dx = 0.0;
+
+    if (point.y < NSMinY(rect))
+        dy = NSMinY(rect) - point.y;
+    else if (point.y > NSMaxY(rect))
+        dy = point.y - NSMaxY(rect);
+    else
+        dy = 0.0;
+    
+    return dx * dx + dy * dy;
+}
+
++ (NSScreen *)screenForPoint:(NSPoint)point {
+    NSScreen *screen = nil;
+    CGFloat distanceSquared = CGFLOAT_MAX;
+    
+    for (NSScreen *aScreen in [NSScreen screens]) {
+        NSRect frame = [aScreen frame];
+        
+        if (NSPointInRect(point, frame))
+            return aScreen;
+        
+        CGFloat aDistanceSquared = SKSquaredDistanceFromPointToRect(point, 
frame);
+        if (aDistanceSquared < distanceSquared) {
+            distanceSquared = aDistanceSquared;
+            screen = aScreen;
+        }
+    }
+    
+    return screen;
+}
+
+...@end

Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m     2010-07-18 21:52:50 UTC (rev 6633)
+++ trunk/SKApplicationController.m     2010-07-21 10:18:05 UTC (rev 6634)
@@ -76,6 +76,7 @@
 #import "SKFDFParser.h"
 #import "SKLocalization.h"
 #import "SKScriptMenu.h"
+#import "NSScreen_SKExtensions.h"
 
 #define WEBSITE_URL @"http://skim-app.sourceforge.net/";
 #define WIKI_URL    @"http://sourceforge.net/apps/mediawiki/skim-app/";
@@ -160,7 +161,7 @@
     GetSystemUIMode(&currentMode, &currentOptions);
     id doc = [[[aNotification object] windowController] document];
     SKMainWindowController *mwc = [doc 
respondsToSelector:@selector(mainWindowController)] ? [doc 
mainWindowController] : nil;
-    if ([[[mwc window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]]) {
+    if ([[[mwc window] screen] isEqual:[NSScreen primaryScreen]]) {
         if ([mwc interactionMode] == SKPresentationMode) {
             mode = kUIModeAllHidden;
             options = kUIOptionDisableProcessSwitch;

Modified: trunk/SKImageToolTipWindow.m
===================================================================
--- trunk/SKImageToolTipWindow.m        2010-07-18 21:52:50 UTC (rev 6633)
+++ trunk/SKImageToolTipWindow.m        2010-07-21 10:18:05 UTC (rev 6634)
@@ -38,6 +38,7 @@
 
 #import "SKImageToolTipWindow.h"
 #import "NSGeometry_SKExtensions.h"
+#import "NSScreen_SKExtensions.h"
 
 #define WINDOW_OFFSET           20.0
 #define ALPHA_VALUE             0.95
@@ -47,11 +48,6 @@
 #define ALT_SHOW_DELAY          0.1
 
 
-...@interface NSScreen (SKExtensions)
-+ (NSScreen *)screenForPoint:(NSPoint)point;
-...@end
-
-
 @implementation SKImageToolTipWindow
 
 @synthesize currentImageContext=context;
@@ -145,49 +141,3 @@
 }
 
 @end
-
-
-static inline CGFloat SKSquaredDistanceFromPointToRect(NSPoint point, NSRect 
rect) {
-    CGFloat dx, dy;
-
-    if (point.x < NSMinX(rect))
-        dx = NSMinX(rect) - point.x;
-    else if (point.x > NSMaxX(rect))
-        dx = point.x - NSMaxX(rect);
-    else
-        dx = 0.0;
-
-    if (point.y < NSMinY(rect))
-        dy = NSMinY(rect) - point.y;
-    else if (point.y > NSMaxY(rect))
-        dy = point.y - NSMaxY(rect);
-    else
-        dy = 0.0;
-    
-    return dx * dx + dy * dy;
-}
-
-
-...@implementation NSScreen (SKExtensions)
-
-+ (NSScreen *)screenForPoint:(NSPoint)point {
-    NSScreen *screen = nil;
-    CGFloat distanceSquared = CGFLOAT_MAX;
-    
-    for (NSScreen *aScreen in [NSScreen screens]) {
-        NSRect frame = [aScreen frame];
-        
-        if (NSPointInRect(point, frame))
-            return aScreen;
-        
-        CGFloat aDistanceSquared = SKSquaredDistanceFromPointToRect(point, 
frame);
-        if (aDistanceSquared < distanceSquared) {
-            distanceSquared = aDistanceSquared;
-            screen = aScreen;
-        }
-    }
-    
-    return screen;
-}
-
-...@end

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2010-07-18 21:52:50 UTC (rev 6633)
+++ trunk/SKMainWindowController.m      2010-07-21 10:18:05 UTC (rev 6634)
@@ -102,6 +102,7 @@
 #import "SKColorCell.h"
 #import "PDFDocument_SKExtensions.h"
 #import "SKPDFPage.h"
+#import "NSScreen_SKExtensions.h"
 
 #define MULTIPLICATION_SIGN_CHARACTER 0x00d7
 
@@ -1403,7 +1404,7 @@
     BOOL wasPresentation = [self interactionMode] == SKPresentationMode;
     
     NSScreen *screen = [[self window] screen] ?: [NSScreen mainScreen]; // @@ 
screen: or should we use the main screen?
-    if ([screen isEqual:[[NSScreen screens] objectAtIndex:0]])
+    if ([screen isEqual:[NSScreen primaryScreen]])
         SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);
     else if (wasPresentation)
         SetSystemUIMode(kUIModeNormal, 0);
@@ -1443,7 +1444,7 @@
     [self enterPresentationMode];
     
     NSScreen *screen = [[self window] screen] ?: [NSScreen mainScreen]; // @@ 
screen: or should we use the main screen?
-    if ([screen isEqual:[[NSScreen screens] objectAtIndex:0]])
+    if ([screen isEqual:[NSScreen primaryScreen]])
         SetSystemUIMode(kUIModeAllHidden, kUIOptionDisableProcessSwitch);
     else
         SetSystemUIMode(kUIModeNormal, 0);

Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj        2010-07-18 21:52:50 UTC (rev 
6633)
+++ trunk/Skim.xcodeproj/project.pbxproj        2010-07-21 10:18:05 UTC (rev 
6634)
@@ -294,6 +294,7 @@
                CEFBC96A103C5CBF00535C74 /* SKFormatCommand.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CEFBC969103C5CBF00535C74 /* SKFormatCommand.m 
*/; };
                CEFC7EDA1137FDE20055D1E2 /* NotesPanel.xib in Resources */ = 
{isa = PBXBuildFile; fileRef = CEFC7ED91137FDE20055D1E2 /* NotesPanel.xib */; };
                CEFD68740C01D4080027B933 /* SkimImporter.mdimporter in Copy 
Files: Spotlight */ = {isa = PBXBuildFile; fileRef = CEFD68690C01D3BB0027B933 
/* SkimImporter.mdimporter */; };
+               CEFDEA9111F6FF8300D6FEBA /* NSScreen_SKExtensions.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = CEFDEA9011F6FF8300D6FEBA /* 
NSScreen_SKExtensions.m */; };
                CEFDF8BE0B3848C40091C61A /* SKNavigationWindow.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CEFDF8BD0B3848C40091C61A /* 
SKNavigationWindow.m */; };
                CEFE71951129AAA30018CD74 /* ServicesMenu.strings in Resources 
*/ = {isa = PBXBuildFile; fileRef = CEFE71941129AAA30018CD74 /* 
ServicesMenu.strings */; };
                CEFF22F711412E51008DB4DC /* DownloadsWindow.xib in Resources */ 
= {isa = PBXBuildFile; fileRef = CEFF22F611412E51008DB4DC /* 
DownloadsWindow.xib */; };
@@ -1201,6 +1202,8 @@
                CEFBC969103C5CBF00535C74 /* SKFormatCommand.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= SKFormatCommand.m; sourceTree = "<group>"; };
                CEFC7ED91137FDE20055D1E2 /* NotesPanel.xib */ = {isa = 
PBXFileReference; lastKnownFileType = file.xib; path = NotesPanel.xib; 
sourceTree = "<group>"; };
                CEFD68610C01D3BB0027B933 /* SkimImporter.xcodeproj */ = {isa = 
PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = 
SkimImporter.xcodeproj; path = SkimImporter/SkimImporter.xcodeproj; sourceTree 
= "<group>"; };
+               CEFDEA8F11F6FF8300D6FEBA /* NSScreen_SKExtensions.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
NSScreen_SKExtensions.h; sourceTree = "<group>"; };
+               CEFDEA9011F6FF8300D6FEBA /* NSScreen_SKExtensions.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= NSScreen_SKExtensions.m; sourceTree = "<group>"; };
                CEFDF8BC0B3848C40091C61A /* SKNavigationWindow.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKNavigationWindow.h; sourceTree = "<group>"; };
                CEFDF8BD0B3848C40091C61A /* SKNavigationWindow.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= SKNavigationWindow.m; sourceTree = "<group>"; };
                CEFE718E1129AA540018CD74 /* English */ = {isa = 
PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; 
name = English; path = English.lproj/ServicesMenu.strings; sourceTree = 
"<group>"; };
@@ -1951,6 +1954,8 @@
                                CE3400AB0E0034DF00A7FFE6 /* 
NSMenu_SKExtensions.m */,
                                CE0A3C8C0EBF3AAA00526C74 /* 
NSResponder_SKExtensions.h */,
                                CE0A3C8D0EBF3AAA00526C74 /* 
NSResponder_SKExtensions.m */,
+                               CEFDEA8F11F6FF8300D6FEBA /* 
NSScreen_SKExtensions.h */,
+                               CEFDEA9011F6FF8300D6FEBA /* 
NSScreen_SKExtensions.m */,
                                CE070EA00B89039700733CC8 /* 
NSScrollView_SKExtensions.h */,
                                CE070EA10B89039700733CC8 /* 
NSScrollView_SKExtensions.m */,
                                CEE54F6E0DA3FBE00037169F /* 
NSSegmentedControl_SKExtensions.h */,
@@ -2566,6 +2571,7 @@
                                CE8BF02A115F7C5C0029020F /* 
SKRightSideViewController.m in Sources */,
                                CE9768831161195C008DCB8F /* 
SKDownloadPreferenceController.m in Sources */,
                                CE121AC81180644A00951425 /* SKScriptMenu.m in 
Sources */,
+                               CEFDEA9111F6FF8300D6FEBA /* 
NSScreen_SKExtensions.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };


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

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to