Revision: 7856
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7856&view=rev
Author:   hofman
Date:     2012-12-15 23:10:08 +0000 (Sat, 15 Dec 2012)
Log Message:
-----------
Implement pdfsync event handler in PDFView category so we can reuse it in all 
subclasses

Modified Paths:
--------------
    trunk/PDFView_SKExtensions.h
    trunk/PDFView_SKExtensions.m
    trunk/SKMainWindowController_UI.m
    trunk/SKPDFView.h
    trunk/SKPDFView.m
    trunk/SKSecondaryPDFView.m
    trunk/SKSnapshotPDFView.m

Modified: trunk/PDFView_SKExtensions.h
===================================================================
--- trunk/PDFView_SKExtensions.h        2012-12-15 15:28:01 UTC (rev 7855)
+++ trunk/PDFView_SKExtensions.h        2012-12-15 23:10:08 UTC (rev 7856)
@@ -51,4 +51,6 @@
 - (NSRect)convertRect:(NSRect)rect toDocumentViewFromPage:(PDFPage *)page;
 - (NSRect)convertRect:(NSRect)rect fromDocumentViewToPage:(PDFPage *)page;
 
+- (void)doPdfsyncWithEvent:(NSEvent *)theEvent;
+
 @end

Modified: trunk/PDFView_SKExtensions.m
===================================================================
--- trunk/PDFView_SKExtensions.m        2012-12-15 15:28:01 UTC (rev 7855)
+++ trunk/PDFView_SKExtensions.m        2012-12-15 23:10:08 UTC (rev 7856)
@@ -38,6 +38,11 @@
 
 #import "PDFView_SKExtensions.h"
 #import "PDFAnnotation_SKExtensions.h"
+#import "SKMainDocument.h"
+#import "SKPDFSynchronizer.h"
+#import "PDFPage_SKExtensions.h"
+#import "PDFSelection_SKExtensions.h"
+#import "NSEvent_SKExtensions.h"
 
 
 @implementation PDFView (SKExtensions)
@@ -95,4 +100,34 @@
     return [self convertRect:[self convertRect:rect fromView:[self 
documentView]] toPage:page];
 }
 
+- (void)doPdfsyncWithEvent:(NSEvent *)theEvent {
+    // eat up mouseDragged/mouseUp events, so we won't get their event handlers
+    while (YES) {
+        if ([[[self window] nextEventMatchingMask: NSLeftMouseUpMask | 
NSLeftMouseDraggedMask] type] == NSLeftMouseUp)
+            break;
+    }
+    
+    SKMainDocument *document = (SKMainDocument *)[[[self window] 
windowController] document];
+    
+    if ([document respondsToSelector:@selector(synchronizer)]) {
+        
+        NSPoint mouseLoc = [theEvent locationInView:self];
+        PDFPage *page = [self pageForPoint:mouseLoc nearest:YES];
+        NSPoint location = [self convertPoint:mouseLoc toPage:page];
+        NSUInteger pageIndex = [page pageIndex];
+        PDFSelection *sel = [page selectionForLineAtPoint:location];
+        NSRect rect = [sel hasCharacters] ? [sel boundsForPage:page] : 
NSMakeRect(location.x - 20.0, location.y - 5.0, 40.0, 10.0);
+        
+        [[document synchronizer] findFileAndLineForLocation:location 
inRect:rect pageBounds:[page boundsForBox:kPDFDisplayBoxMediaBox] 
atPageIndex:pageIndex];
+    }
+}
+
+- (void)doNothingWithEvent:(NSEvent *)theEvent {
+    // eat up mouseDragged/mouseUp events, so we won't get their event handlers
+    while (YES) {
+        if ([[[self window] nextEventMatchingMask: NSLeftMouseUpMask | 
NSLeftMouseDraggedMask] type] == NSLeftMouseUp)
+            break;
+    }
+}
+
 @end

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2012-12-15 15:28:01 UTC (rev 7855)
+++ trunk/SKMainWindowController_UI.m   2012-12-15 23:10:08 UTC (rev 7856)
@@ -1264,11 +1264,6 @@
     [self showSnapshotAtPageNumber:pageNum forRect:rect 
scaleFactor:scaleFactor autoFits:autoFits];
 }
 
-- (void)PDFView:(PDFView *)sender findFileAndLineForLocation:(NSPoint)point 
inRect:(NSRect)rect pageBounds:(NSRect)bounds atPageIndex:(NSUInteger)pageIndex 
{
-    if ([[self document] respondsToSelector:@selector(synchronizer)])
-        [[[self document] synchronizer] findFileAndLineForLocation:point 
inRect:rect pageBounds:bounds atPageIndex:pageIndex];
-}
-
 - (void)PDFViewExitFullscreen:(PDFView *)sender {
     [self exitFullscreen:sender];
 }

Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h   2012-12-15 15:28:01 UTC (rev 7855)
+++ trunk/SKPDFView.h   2012-12-15 23:10:08 UTC (rev 7856)
@@ -189,7 +189,6 @@
 - (void)PDFViewDidEndEditing:(PDFView *)sender;
 - (void)PDFView:(PDFView *)sender editAnnotation:(PDFAnnotation *)annotation;
 - (void)PDFView:(PDFView *)sender showSnapshotAtPageNumber:(NSInteger)pageNum 
forRect:(NSRect)rect scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits;
-- (void)PDFView:(PDFView *)sender findFileAndLineForLocation:(NSPoint)point 
inRect:(NSRect)rect pageBounds:(NSRect)bounds atPageIndex:(NSUInteger)pageIndex;
 - (void)PDFViewExitFullscreen:(PDFView *)sender;
 - (void)PDFViewToggleContents:(PDFView *)sender;
 @end

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2012-12-15 15:28:01 UTC (rev 7855)
+++ trunk/SKPDFView.m   2012-12-15 23:10:08 UTC (rev 7856)
@@ -158,7 +158,6 @@
 - (void)doSelectTextWithEvent:(NSEvent *)theEvent;
 - (void)doDragReadingBarWithEvent:(NSEvent *)theEvent;
 - (void)doResizeReadingBarWithEvent:(NSEvent *)theEvent;
-- (void)doPdfsyncWithEvent:(NSEvent *)theEvent;
 - (void)doNothingWithEvent:(NSEvent *)theEvent;
 - (NSCursor *)cursorForResizeHandle:(SKRectEdges)mask 
rotation:(NSInteger)rotation;
 - (NSCursor *)getCursorForEvent:(NSEvent *)theEvent;
@@ -4023,22 +4022,6 @@
     [[self getCursorForEvent:theEvent] performSelector:@selector(set) 
withObject:nil afterDelay:0];
 }
 
-- (void)doPdfsyncWithEvent:(NSEvent *)theEvent {
-    [self doNothingWithEvent:theEvent];
-    
-    if ([[self delegate] 
respondsToSelector:@selector(PDFView:findFileAndLineForLocation:inRect:pageBounds:atPageIndex:)])
 {
-        
-        NSPoint mouseLoc = [theEvent locationInView:self];
-        PDFPage *page = [self pageForPoint:mouseLoc nearest:YES];
-        NSPoint location = [self convertPoint:mouseLoc toPage:page];
-        NSUInteger pageIndex = [page pageIndex];
-        PDFSelection *sel = [page selectionForLineAtPoint:location];
-        NSRect rect = [sel hasCharacters] ? [sel boundsForPage:page] : 
NSMakeRect(location.x - 20.0, location.y - 5.0, 40.0, 10.0);
-        
-        [[self delegate] PDFView:self findFileAndLineForLocation:location 
inRect:rect pageBounds:[page boundsForBox:kPDFDisplayBoxMediaBox] 
atPageIndex:pageIndex];
-    }
-}
-
 - (void)doNothingWithEvent:(NSEvent *)theEvent {
     // eat up mouseDragged/mouseUp events, so we won't get their event handlers
     while (YES) {

Modified: trunk/SKSecondaryPDFView.m
===================================================================
--- trunk/SKSecondaryPDFView.m  2012-12-15 15:28:01 UTC (rev 7855)
+++ trunk/SKSecondaryPDFView.m  2012-12-15 23:10:08 UTC (rev 7856)
@@ -564,25 +564,7 @@
         [synchronizedPDFView goToDestination:[[[PDFDestination alloc] 
initWithPage:page atPoint:location] autorelease]];
         
     } else if (modifiers == (NSCommandKeyMask | NSShiftKeyMask)) {
-        // eat up mouseDragged/mouseUp events, so we won't get their event 
handlers
-        while (YES) {
-            if ([[[self window] nextEventMatchingMask: NSLeftMouseUpMask | 
NSLeftMouseDraggedMask] type] == NSLeftMouseUp)
-                break;
-        }
-        
-        SKMainDocument *document = (SKMainDocument *)[[[self window] 
windowController] document];
-        
-        if ([document respondsToSelector:@selector(synchronizer)]) {
-            
-            NSPoint mouseLoc = [theEvent locationInView:self];
-            PDFPage *page = [self pageForPoint:mouseLoc nearest:YES];
-            NSPoint location = [self convertPoint:mouseLoc toPage:page];
-            NSUInteger pageIndex = [page pageIndex];
-            PDFSelection *sel = [page selectionForLineAtPoint:location];
-            NSRect rect = [sel hasCharacters] ? [sel boundsForPage:page] : 
NSMakeRect(location.x - 20.0, location.y - 5.0, 40.0, 10.0);
-            
-            [[document synchronizer] findFileAndLineForLocation:location 
inRect:rect pageBounds:[page boundsForBox:kPDFDisplayBoxMediaBox] 
atPageIndex:pageIndex];
-        }
+        [self doPdfsyncWithEvent:theEvent];
     } else {
         [[NSCursor closedHandCursor] push];
     }

Modified: trunk/SKSnapshotPDFView.m
===================================================================
--- trunk/SKSnapshotPDFView.m   2012-12-15 15:28:01 UTC (rev 7855)
+++ trunk/SKSnapshotPDFView.m   2012-12-15 23:10:08 UTC (rev 7856)
@@ -421,25 +421,7 @@
 - (void)mouseDown:(NSEvent *)theEvent{
     [[self window] makeFirstResponder:self];
        if ((NSCommandKeyMask | NSShiftKeyMask) == ([theEvent modifierFlags] & 
(NSCommandKeyMask | NSShiftKeyMask))) {
-        // eat up mouseDragged/mouseUp events, so we won't get their event 
handlers
-        while (YES) {
-            if ([[[self window] nextEventMatchingMask: NSLeftMouseUpMask | 
NSLeftMouseDraggedMask] type] == NSLeftMouseUp)
-                break;
-        }
-        
-        SKMainDocument *document = (SKMainDocument *)[[[self window] 
windowController] document];
-        
-        if ([document respondsToSelector:@selector(synchronizer)]) {
-            
-            NSPoint mouseLoc = [theEvent locationInView:self];
-            PDFPage *page = [self pageForPoint:mouseLoc nearest:YES];
-            NSPoint location = [self convertPoint:mouseLoc toPage:page];
-            NSUInteger pageIndex = [page pageIndex];
-            PDFSelection *sel = [page selectionForLineAtPoint:location];
-            NSRect rect = [sel hasCharacters] ? [sel boundsForPage:page] : 
NSMakeRect(location.x - 20.0, location.y - 5.0, 40.0, 10.0);
-            
-            [[document synchronizer] findFileAndLineForLocation:location 
inRect:rect pageBounds:[page boundsForBox:kPDFDisplayBoxMediaBox] 
atPageIndex:pageIndex];
-        }
+        [self doPdfsyncWithEvent:theEvent];
     } else {
         [[NSCursor closedHandCursor] push];
     }

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


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to