Revision: 5009
http://skim-app.svn.sourceforge.net/skim-app/?rev=5009&view=rev
Author: hofman
Date: 2008-11-28 16:27:25 +0000 (Fri, 28 Nov 2008)
Log Message:
-----------
Simplify page drawing code
Modified Paths:
--------------
trunk/SKPDFView.m
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2008-11-28 12:13:18 UTC (rev 5008)
+++ trunk/SKPDFView.m 2008-11-28 16:27:25 UTC (rev 5009)
@@ -167,10 +167,14 @@
#pragma mark -
// Adobe Reader recognizes a path from the hyperref command \url{./test.pdf}
as a file: URL, but PDFKit turns it into an http: URL (which of course doesn't
work); I notice this because my collaborators use Adobe Reader
[EMAIL PROTECTED] PDFAnnotationLink (SKRelativePathFix)
[EMAIL PROTECTED] PDFAnnotation (SKRelativePathFix)
- (void)fixRelativeURLIfNeeded;
@end
[EMAIL PROTECTED] PDFAnnotation (SKRelativePathFix)
+- (void)fixRelativeURLIfNeeded {}
[EMAIL PROTECTED]
+
@implementation PDFAnnotationLink (SKRelativePathFix)
// class posing indicates that setURL: is never called, and neither is
setContents: (-contents returns nil), so this is the only way I can find to fix
the thing, since we don't have an equivalent to textView:clickedOnLink:atIndex:
@@ -354,61 +358,49 @@
[NSGraphicsContext restoreGraphicsState];
}
- NSArray *allAnnotations = [pdfPage annotations];
+ [[pdfPage annotations]
makeObjectsPerformSelector:@selector(fixRelativeURLIfNeeded)];
- if (allAnnotations) {
- unsigned int i, count = [allAnnotations count];
-
- for (i = 0; i < count; i++) {
- PDFAnnotation *annotation = [allAnnotations objectAtIndex: i];
- if ([annotation isLink])
- [(PDFAnnotationLink *)annotation fixRelativeURLIfNeeded];
- }
-
- // activeAnnotation may be a leftover, and we don't want to outline it
on the wrong page
- if (activeAnnotation && [[activeAnnotation page] isEqual:pdfPage]) {
- BOOL isLink = [activeAnnotation isLink];
- float lineWidth = isLink ? 2.0 : 1.0;
- NSRect bounds = [activeAnnotation bounds];
- NSRect rect = NSInsetRect(NSIntegralRect(bounds), 0.5 * lineWidth,
0.5 * lineWidth);
- if (isLink) {
- CGMutablePathRef path =
SKCGCreatePathWithRoundRectInRect(*(CGRect *)&rect, floorf(0.3 *
NSHeight(rect)));
- float color[4] = { 0.0, 0.0, 0.0, 0.1 };
- CGContextSetFillColor(context, color);
- CGContextBeginPath(context);
- CGContextAddPath(context, path);
- CGContextFillPath(context);
- color[3] = 0.5;
- CGContextSetStrokeColor(context, color);
- CGContextSetLineWidth(context, lineWidth);
- CGContextAddPath(context, path);
- CGContextStrokePath(context);
- CGPathRelease(path);
- } else if ([[activeAnnotation type]
isEqualToString:SKNLineString]) {
- NSPoint point = SKAddPoints(bounds.origin, [(PDFAnnotationLine
*)activeAnnotation startPoint]);
- SKCGContextDrawGrabHandle(context, *(CGPoint *)&point, 4.0,
dragMask == BDSKMaxXEdgeMask);
- point = SKAddPoints(bounds.origin, [(PDFAnnotationLine
*)activeAnnotation endPoint]);
- SKCGContextDrawGrabHandle(context, *(CGPoint *)&point, 4.0,
dragMask == BDSKMinXEdgeMask);
- } else if (editField == nil) {
- float color[4] = { 0.278477, 0.467857, 0.810941, 1.0 };
- CGContextSetStrokeColor(context, color);
- CGContextStrokeRectWithWidth(context, *(CGRect *)&rect,
lineWidth);
- if ([activeAnnotation isResizable])
- SKCGContextDrawGrabHandles(context, *(CGRect *)&bounds,
4.0, dragMask);
- }
- }
- if (highlightAnnotation && [[highlightAnnotation page]
isEqual:pdfPage]) {
- float color[4] = { 0.0, 0.0, 0.0, 1.0 };
- NSRect bounds = [highlightAnnotation bounds];
- NSRect rect = NSInsetRect(NSIntegralRect(bounds), 0.5, 0.5);
+ if ([[activeAnnotation page] isEqual:pdfPage]) {
+ BOOL isLink = [activeAnnotation isLink];
+ float lineWidth = isLink ? 2.0 : 1.0;
+ NSRect bounds = [activeAnnotation bounds];
+ NSRect rect = NSInsetRect(NSIntegralRect(bounds), 0.5 * lineWidth, 0.5
* lineWidth);
+ if (isLink) {
+ CGMutablePathRef path = SKCGCreatePathWithRoundRectInRect(*(CGRect
*)&rect, floorf(0.3 * NSHeight(rect)));
+ float color[4] = { 0.0, 0.0, 0.0, 0.1 };
+ CGContextSetFillColor(context, color);
+ CGContextBeginPath(context);
+ CGContextAddPath(context, path);
+ CGContextFillPath(context);
+ color[3] = 0.5;
CGContextSetStrokeColor(context, color);
- CGContextStrokeRectWithWidth(context, *(CGRect *)&rect, 1.0);
+ CGContextSetLineWidth(context, lineWidth);
+ CGContextAddPath(context, path);
+ CGContextStrokePath(context);
+ CGPathRelease(path);
+ } else if ([[activeAnnotation type] isEqualToString:SKNLineString]) {
+ NSPoint point = SKAddPoints(bounds.origin, [(PDFAnnotationLine
*)activeAnnotation startPoint]);
+ SKCGContextDrawGrabHandle(context, *(CGPoint *)&point, 4.0,
dragMask == BDSKMaxXEdgeMask);
+ point = SKAddPoints(bounds.origin, [(PDFAnnotationLine
*)activeAnnotation endPoint]);
+ SKCGContextDrawGrabHandle(context, *(CGPoint *)&point, 4.0,
dragMask == BDSKMinXEdgeMask);
+ } else if (editField == nil) {
+ float color[4] = { 0.278477, 0.467857, 0.810941, 1.0 };
+ CGContextSetStrokeColor(context, color);
+ CGContextStrokeRectWithWidth(context, *(CGRect *)&rect, lineWidth);
+ if ([activeAnnotation isResizable])
+ SKCGContextDrawGrabHandles(context, *(CGRect *)&bounds, 4.0,
dragMask);
}
-
}
+ if ([[highlightAnnotation page] isEqual:pdfPage]) {
+ float color[4] = { 0.0, 0.0, 0.0, 1.0 };
+ NSRect bounds = [highlightAnnotation bounds];
+ NSRect rect = NSInsetRect(NSIntegralRect(bounds), 0.5, 0.5);
+ CGContextSetStrokeColor(context, color);
+ CGContextStrokeRectWithWidth(context, *(CGRect *)&rect, 1.0);
+ }
+
if (readingBar) {
-
NSRect rect = [readingBar currentBoundsForBox:[self displayBox]];
BOOL invert = [[NSUserDefaults standardUserDefaults]
boolForKey:SKReadingBarInvertKey];
NSColor *nsColor = [[NSUserDefaults standardUserDefaults]
colorForKey:SKReadingBarColorKey];
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