Revision: 5484
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5484&view=rev
Author:   hofman
Date:     2009-07-15 13:09:53 +0000 (Wed, 15 Jul 2009)

Log Message:
-----------
allow drawing using tablet in presentation mode

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

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2009-07-15 11:25:09 UTC (rev 5483)
+++ trunk/SKPDFView.m   2009-07-15 13:09:53 UTC (rev 5484)
@@ -160,6 +160,7 @@
 - (void)doSelectSnapshotWithEvent:(NSEvent *)theEvent;
 - (void)doMagnifyWithEvent:(NSEvent *)theEvent;
 - (void)doDragWithEvent:(NSEvent *)theEvent;
+- (void)doDrawFreehandNoteWithEvent:(NSEvent *)theEvent;
 - (void)doSelectWithEvent:(NSEvent *)theEvent;
 - (void)doSelectTextWithEvent:(NSEvent *)theEvent;
 - (void)doDragReadingBarWithEvent:(NSEvent *)theEvent;
@@ -1073,6 +1074,8 @@
     } else if (interactionMode == SKPresentationMode) {
         if ([self areaOfInterestForMouse:theEvent] & kPDFLinkArea) {
             [super mouseDown:theEvent];
+        } else if ([theEvent subtype] == NSTabletProximity || [theEvent 
subtype] == NSTabletPoint) {
+            [self doDrawFreehandNoteWithEvent:theEvent];
         } else {
             [self goToNextPage:self];
             // Eat up drag events because we don't want to select
@@ -2992,6 +2995,31 @@
     }
 }
 
+- (void)doDrawFreehandNoteWithEvent:(NSEvent *)theEvent {
+    NSPoint mouseDownOnPage = [self convertPoint:[theEvent locationInWindow] 
fromView:nil];
+    PDFPage *page = [self pageForPoint:mouseDownOnPage nearest:YES];
+    NSPoint pagePoint = [self convertPoint:mouseDownOnPage toPage:page];
+    BOOL didDraw = NO;
+    bezierPath = [[NSBezierPath alloc] init];
+    [bezierPath setLineCapStyle:NSRoundLineCapStyle];
+    [bezierPath setLineJoinStyle:NSRoundLineJoinStyle];
+    [bezierPath setLineWidth:[[NSUserDefaults standardUserDefaults] 
floatForKey:SKInkNoteLineWidthKey]];
+    [bezierPath moveToPoint:pagePoint];
+    pathPageIndex = [page pageIndex];
+    while (YES) {
+        theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask | 
NSLeftMouseDraggedMask];
+        [bezierPath lineToPoint:[self convertPoint:[self 
convertPoint:[theEvent locationInWindow] fromView:nil] toPage:page]];
+        [self setNeedsDisplayInRect:[self convertRect:NSInsetRect([bezierPath 
nonEmptyBounds], -8.0, -8.0) fromPage:page]];
+        if ([theEvent type] == NSLeftMouseUp)
+            break;
+        didDraw = YES;
+    }
+    if (didDraw)
+        [self addAnnotationWithType:SKInkNote contents:nil page:page 
bounds:NSZeroRect];
+    [bezierPath release];
+    bezierPath = nil;
+}
+
 - (BOOL)doSelectAnnotationWithEvent:(NSEvent *)theEvent {
     PDFAnnotation *newActiveAnnotation = nil;
     NSArray *annotations;
@@ -3202,25 +3230,7 @@
         
     } else if (toolMode == SKNoteToolMode && annotationMode == SKInkNote && 
hideNotes == NO && page != nil) {
         
-        BOOL didDraw = NO;
-        bezierPath = [[NSBezierPath alloc] init];
-        [bezierPath setLineCapStyle:NSRoundLineCapStyle];
-        [bezierPath setLineJoinStyle:NSRoundLineJoinStyle];
-        [bezierPath setLineWidth:[[NSUserDefaults standardUserDefaults] 
floatForKey:SKInkNoteLineWidthKey]];
-        [bezierPath moveToPoint:pagePoint];
-        pathPageIndex = [page pageIndex];
-        while (YES) {
-            theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask 
| NSLeftMouseDraggedMask];
-            [bezierPath lineToPoint:[self convertPoint:[self 
convertPoint:[theEvent locationInWindow] fromView:nil] toPage:page]];
-            [self setNeedsDisplayInRect:[self 
convertRect:NSInsetRect([bezierPath nonEmptyBounds], -8.0, -8.0) 
fromPage:page]];
-            if ([theEvent type] == NSLeftMouseUp)
-                break;
-            didDraw = YES;
-        }
-        if (didDraw)
-            [self addAnnotationWithType:SKInkNote contents:nil page:page 
bounds:NSZeroRect];
-        [bezierPath release];
-        bezierPath = nil;
+        [self doDrawFreehandNoteWithEvent:theEvent];
         
         return YES;
         


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

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to