Revision: 5526
http://skim-app.svn.sourceforge.net/skim-app/?rev=5526&view=rev
Author: hofman
Date: 2009-08-09 15:18:26 +0000 (Sun, 09 Aug 2009)
Log Message:
-----------
also allow PDFDestination as the context for the PDF tooltip
Modified Paths:
--------------
trunk/SKMainWindowController_UI.m
trunk/SKPDFToolTipWindow.h
trunk/SKPDFToolTipWindow.m
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2009-08-09 13:52:56 UTC (rev 5525)
+++ trunk/SKMainWindowController_UI.m 2009-08-09 15:18:26 UTC (rev 5526)
@@ -111,7 +111,6 @@
- (void)showToolTipForDestination:(PDFDestination *)dest {
if ([NSApp isActive] && [[NSUserDefaults standardUserDefaults]
boolForKey:SKDisableTableToolTipsKey] == NO) {
- PDFAnnotationLink *annotation = [[[PDFAnnotationLink alloc]
initWithBounds:NSZeroRect] autorelease];
NSPoint point = [dest point];
switch ([[dest page] rotation]) {
case 0:
@@ -131,8 +130,7 @@
point.y += 50.0;
break;
}
- [annotation setDestination:[[[PDFDestination alloc] initWithPage:[dest
page] atPoint:point] autorelease]];
- [[SKPDFToolTipWindow sharedToolTipWindow] showForPDFContext:annotation
atPoint:NSZeroPoint];
+ [[SKPDFToolTipWindow sharedToolTipWindow]
showForPDFContext:[[[PDFDestination alloc] initWithPage:[dest page]
atPoint:point] autorelease] atPoint:NSZeroPoint];
}
}
Modified: trunk/SKPDFToolTipWindow.h
===================================================================
--- trunk/SKPDFToolTipWindow.h 2009-08-09 13:52:56 UTC (rev 5525)
+++ trunk/SKPDFToolTipWindow.h 2009-08-09 15:18:26 UTC (rev 5526)
@@ -51,7 +51,8 @@
+ (id)sharedToolTipWindow;
-- (void)showForPDFContext:(id)annotationOrPage atPoint:(NSPoint)aPoint;
+// aContext can be a PDFAnnotation, PDFDestination, or PDFPage
+- (void)showForPDFContext:(id)aContext atPoint:(NSPoint)aPoint;
- (void)handleApplicationWillResignActiveNotification:(NSNotification
*)notification;
Modified: trunk/SKPDFToolTipWindow.m
===================================================================
--- trunk/SKPDFToolTipWindow.m 2009-08-09 13:52:56 UTC (rev 5525)
+++ trunk/SKPDFToolTipWindow.m 2009-08-09 15:18:26 UTC (rev 5526)
@@ -200,12 +200,17 @@
image = [[context thumbnailWithSize:128.0 forBox:kPDFDisplayBoxCropBox
shadowBlurRadius:0.0 shadowOffset:NSZeroSize readingBarRect:NSZeroRect] retain];
- } else if ([context isLink]) {
+ } else {
- PDFDestination *dest = [context destination];
- PDFPage *page = [dest page];
+ PDFDestination *dest = nil;
+ PDFPage *page;
- if (page) {
+ if ([context isKindOfClass:[PDFDestination class]])
+ dest = context;
+ else if ([context isKindOfClass:[PDFAnnotationLink class]])
+ dest = [context destination];
+
+ if (page = [dest page]) {
NSImage *pageImage = [page thumbnailWithSize:0.0
forBox:kPDFDisplayBoxCropBox shadowBlurRadius:0.0 shadowOffset:NSZeroSize
readingBarRect:NSZeroRect];
NSRect pageImageRect = {NSZeroPoint, [pageImage size]};
@@ -274,40 +279,40 @@
[attrs release];
[labelString release];
- } else {
+ } else if ([context isKindOfClass:[PDFAnnotationLink class]]) {
string = [[(PDFAnnotationLink *)context URL] absoluteString];
+ } else if ([context isKindOfClass:[PDFAnnotation class]]) {
+
+ text = [context text];
+ string = [text string];
+ NSUInteger i = 0, l = [string length];
+ NSRange r = NSMakeRange(0, l);
+
+ while (i != NSNotFound) {
+ r = NSMakeRange(i, l - i);
+ i = [string rangeOfCharacterFromSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet] options:NSAnchoredSearch range:r].location;
+ }
+ i = l;
+ while (i != NSNotFound) {
+ r.length = i - r.location;
+ i = [string rangeOfCharacterFromSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet] options:NSBackwardsSearch | NSAnchoredSearch
range:r].location;
+ }
+ if (r.length < l)
+ text = [text attributedSubstringFromRange:r];
+
+ string = nil;
+
+ if ([text length] == 0) {
+ text = nil;
+ if ([[context string] length])
+ string = [context string];
+ }
+ // we release text later
+ [text retain];
+
}
-
- } else {
-
- text = [context text];
- string = [text string];
- NSUInteger i = 0, l = [string length];
- NSRange r = NSMakeRange(0, l);
-
- while (i != NSNotFound) {
- r = NSMakeRange(i, l - i);
- i = [string rangeOfCharacterFromSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet] options:NSAnchoredSearch range:r].location;
- }
- i = l;
- while (i != NSNotFound) {
- r.length = i - r.location;
- i = [string rangeOfCharacterFromSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet] options:NSBackwardsSearch | NSAnchoredSearch
range:r].location;
- }
- if (r.length < l)
- text = [text attributedSubstringFromRange:r];
-
- string = nil;
-
- if ([text length] == 0) {
- text = nil;
- if ([[context string] length])
- string = [context string];
- }
- // we release text later
- [text retain];
}
if (string) {
@@ -367,14 +372,14 @@
[[self class] cancelPreviousPerformRequestsWithTarget:self
selector:@selector(showDelayed) object:nil];
}
-- (void)showForPDFContext:(id)annotationOrPage atPoint:(NSPoint)aPoint {
+- (void)showForPDFContext:(id)aContext atPoint:(NSPoint)aPoint {
point = aPoint;
- if ([annotationOrPage isEqual:context] == NO) {
+ if ([aContext isEqual:context] == NO) {
[self stopAnimation];
[context release];
- context = [annotationOrPage retain];
+ context = [aContext retain];
[self performSelector:@selector(showDelayed) withObject:nil
afterDelay:[self isVisible] ? ALT_SHOW_DELAY : DEFAULT_SHOW_DELAY];
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit