Revision: 6974
          http://skim-app.svn.sourceforge.net/skim-app/?rev=6974&view=rev
Author:   hofman
Date:     2010-12-14 11:55:10 +0000 (Tue, 14 Dec 2010)

Log Message:
-----------
Set line dash for path when drawing freehand note

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

Modified: trunk/NSBezierPath_SKExtensions.h
===================================================================
--- trunk/NSBezierPath_SKExtensions.h   2010-12-14 10:39:19 UTC (rev 6973)
+++ trunk/NSBezierPath_SKExtensions.h   2010-12-14 11:55:10 UTC (rev 6974)
@@ -43,6 +43,9 @@
 + (NSBezierPath *)bezierPathWithLeftRoundedRect:(NSRect)rect 
radius:(CGFloat)radius;
 + (NSBezierPath *)bezierPathWithRightRoundedRect:(NSRect)rect 
radius:(CGFloat)radius;
 
+- (NSArray *)dashPattern;
+- (void)setDashPattern:(NSArray *)newPattern;
+
 - (NSRect)nonEmptyBounds;
 
 - (NSPoint)associatedPointForElementAtIndex:(NSUInteger)anIndex;

Modified: trunk/NSBezierPath_SKExtensions.m
===================================================================
--- trunk/NSBezierPath_SKExtensions.m   2010-12-14 10:39:19 UTC (rev 6973)
+++ trunk/NSBezierPath_SKExtensions.m   2010-12-14 11:55:10 UTC (rev 6974)
@@ -97,6 +97,27 @@
     return path;
 }
 
+- (NSArray *)dashPattern {
+    NSInteger i, count = 0;
+    NSMutableArray *array = [NSMutableArray array];
+    [self getLineDash:NULL count:&count phase:NULL];
+    if (count > 0) {
+        CGFloat pattern[count];
+        [self getLineDash:pattern count:&count phase:NULL];
+        for (i = 0; i < count; i++)
+            [array addObject:[NSNumber numberWithDouble:pattern[i]]];
+    }
+    return array;
+}
+
+- (void)setDashPattern:(NSArray *)newPattern {
+    NSInteger i, count = [newPattern count];
+    CGFloat pattern[count];
+    for (i = 0; i< count; i++)
+        pattern[i] = [[newPattern objectAtIndex:i] doubleValue];
+    [self setLineDash:pattern count:count phase:0];
+}
+
 - (NSPoint)associatedPointForElementAtIndex:(NSUInteger)anIndex {
     NSPoint points[3];
     if (NSCurveToBezierPathElement == [self elementAtIndex:anIndex 
associatedPoints:points])

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2010-12-14 10:39:19 UTC (rev 6973)
+++ trunk/SKPDFView.m   2010-12-14 11:55:10 UTC (rev 6974)
@@ -3295,6 +3295,10 @@
             [path setLineCapStyle:NSRoundLineCapStyle];
             [path setLineJoinStyle:NSRoundLineJoinStyle];
             [path setLineWidth:[border lineWidth]];
+            if ([border style] == kPDFBorderStyleDashed) {
+                [path setDashPattern:[border dashPattern]];
+                [path setLineCapStyle:NSButtLineCapStyle];
+            }
         }
         [self removeActiveAnnotation:nil];
         path = [bezierPaths lastObject];
@@ -3306,6 +3310,10 @@
         [path setLineCapStyle:NSRoundLineCapStyle];
         [path setLineJoinStyle:NSRoundLineJoinStyle];
         [path setLineWidth:[[NSUserDefaults standardUserDefaults] 
floatForKey:SKInkNoteLineWidthKey]];
+        if ((PDFBorderStyle)[[NSUserDefaults standardUserDefaults] 
integerForKey:SKInkNoteLineStyleKey] == kPDFBorderStyleDashed) {
+            [path setDashPattern:[[NSUserDefaults standardUserDefaults] 
arrayForKey:SKInkNoteDashPatternKey]];
+            [path setLineCapStyle:NSButtLineCapStyle];
+        }
         [path moveToPoint:pagePoint];
         bezierPaths = [[NSArray alloc] initWithObjects:path, nil];
     }


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

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to