Revision: 5022
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5022&view=rev
Author:   hofman
Date:     2008-12-04 12:20:55 +0000 (Thu, 04 Dec 2008)

Log Message:
-----------
simplify and collapse code

Modified Paths:
--------------
    trunk/SKSnapshotPDFView.h
    trunk/SKSnapshotPDFView.m

Modified: trunk/SKSnapshotPDFView.h
===================================================================
--- trunk/SKSnapshotPDFView.h   2008-12-04 10:52:18 UTC (rev 5021)
+++ trunk/SKSnapshotPDFView.h   2008-12-04 12:20:55 UTC (rev 5022)
@@ -55,7 +55,6 @@
 - (void)scalePopUpAction:(id)sender;
 - (NSScrollView *)scrollView;
 - (void)setScrollerSize:(NSControlSize)controlSize;
-- (void)dragWithEvent:(NSEvent *)theEvent;
 - (void)handlePDFViewFrameChangedNotification:(NSNotification *)notification;
 - (void)resetAutoFitRectIfNeeded;
 - (void)makeScalePopUpButton;

Modified: trunk/SKSnapshotPDFView.m
===================================================================
--- trunk/SKSnapshotPDFView.m   2008-12-04 10:52:18 UTC (rev 5021)
+++ trunk/SKSnapshotPDFView.m   2008-12-04 12:20:55 UTC (rev 5022)
@@ -71,34 +71,30 @@
 
 #pragma mark Popup button
 
+- (void)commonInitialization {
+    scalePopUpButton = nil;
+    autoFitPage = nil;
+    autoFitRect = NSZeroRect;
+    pinchZoomFactor = 1.0;
+    
+    [self makeScalePopUpButton];
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handlePDFViewFrameChangedNotification:) 
+                                                 
name:NSViewFrameDidChangeNotification object:self];
+    [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handlePDFViewFrameChangedNotification:) 
+                                                 
name:NSViewBoundsDidChangeNotification object:self];
+}
+
 - (id)initWithFrame:(NSRect)frameRect {
     if (self = [super initWithFrame:frameRect]) {
-        scalePopUpButton = nil;
-        autoFitPage = nil;
-        autoFitRect = NSZeroRect;
-        pinchZoomFactor = 1.0;
-        
-        [self makeScalePopUpButton];
-        
-        [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handlePDFViewFrameChangedNotification:) 
-                                                     
name:NSViewFrameDidChangeNotification object:self];
-        [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handlePDFViewFrameChangedNotification:) 
-                                                     
name:NSViewBoundsDidChangeNotification object:self];
+        [self commonInitialization];
     }
     return self;
 }
 
 - (id)initWithCoder:(NSCoder *)decoder {
     if (self = [super initWithCoder:decoder]) {
-        scalePopUpButton = nil;
-        autoFitPage = nil;
-        autoFitRect = NSZeroRect;
-        pinchZoomFactor = 1.0;
-        [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handlePDFViewFrameChangedNotification:) 
-                                                     
name:NSViewFrameDidChangeNotification object:self];
-        [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handlePDFViewFrameChangedNotification:) 
-                                                     
name:NSViewBoundsDidChangeNotification object:self];
-        [self makeScalePopUpButton];
+        [self commonInitialization];
     }
     return self;
 }
@@ -353,8 +349,8 @@
             break;
     }
     
-    unsigned int i = [menu indexOfItemWithTarget:self 
andAction:NSSelectorFromString(@"_setAutoSize:")];
-    if (i != NSNotFound)
+    int i = [menu indexOfItemWithTarget:self 
andAction:NSSelectorFromString(@"_setAutoSize:")];
+    if (i != -1)
         [[menu itemAtIndex:i] setAction:@selector(doAutoFit:)];
     
     return menu;
@@ -428,10 +424,6 @@
 
 - (void)mouseUp:(NSEvent *)theEvent{
     [NSCursor pop];
-    [self mouseMoved:theEvent];
-}
-
-- (void)mouseMoved:(NSEvent *)theEvent {
        NSPoint mouseLoc = [[self documentView] convertPoint:[theEvent 
locationInWindow] fromView:nil];
     if (NSPointInRect(mouseLoc, [[self documentView] visibleRect]))
         [[NSCursor openHandCursor] set];
@@ -440,12 +432,6 @@
 }
 
 - (void)mouseDragged:(NSEvent *)theEvent {
-    [self dragWithEvent:theEvent];     
-    // ??? PDFView's delayed layout seems to reset the cursor to an arrow
-    [self performSelector:@selector(mouseMoved:) withObject:theEvent 
afterDelay:0];
-}
-
-- (void)dragWithEvent:(NSEvent *)theEvent {
        NSPoint initialLocation = [theEvent locationInWindow];
        NSRect visibleRect = [[self documentView] visibleRect];
        BOOL keepGoing = YES;
@@ -485,6 +471,9 @@
         autoFitPage = [self currentPage];
         autoFitRect = [self convertRect:[self convertRect:[clipView 
visibleRect] fromView:clipView] toPage:autoFitPage];
     }
+    
+    // ??? PDFView's delayed layout seems to reset the cursor to an arrow
+    [self performSelector:@selector(mouseMoved:) withObject:theEvent 
afterDelay:0];
 }
 
 @end


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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to