From: <ho...@us...> - 2008-09-10 11:17:22
|
Revision: 4600 http://skim-app.svn.sourceforge.net/skim-app/?rev=4600&view=rev Author: hofman Date: 2008-09-10 11:17:19 +0000 (Wed, 10 Sep 2008) Log Message: ----------- Rename hover window class and variables Modified Paths: -------------- trunk/PDFDisplayView_SKExtensions.m trunk/SKMainWindow.m trunk/SKMainWindowController.m trunk/SKMainWindowController_UI.m trunk/SKPDFView.h trunk/SKPDFView.m trunk/Skim.xcodeproj/project.pbxproj Added Paths: ----------- trunk/SKPDFToolTipWindow.h trunk/SKPDFToolTipWindow.m Removed Paths: ------------- trunk/SKPDFHoverWindow.h trunk/SKPDFHoverWindow.m Modified: trunk/PDFDisplayView_SKExtensions.m =================================================================== --- trunk/PDFDisplayView_SKExtensions.m 2008-09-10 11:03:54 UTC (rev 4599) +++ trunk/PDFDisplayView_SKExtensions.m 2008-09-10 11:17:19 UTC (rev 4600) @@ -81,8 +81,8 @@ static void replacementResetCursorRects(id self, SEL _cmd) { originalResetCursorRects(self, _cmd); id pdfView = SKGetPDFView(self); - if ([pdfView respondsToSelector:@selector(resetHoverRects)]) - [pdfView resetHoverRects]; + if ([pdfView respondsToSelector:@selector(resetPDFToolTipRects)]) + [pdfView resetPDFToolTipRects]; } static void replacementPasswordEntered(id self, SEL _cmd, id sender) { Modified: trunk/SKMainWindow.m =================================================================== --- trunk/SKMainWindow.m 2008-09-10 11:03:54 UTC (rev 4599) +++ trunk/SKMainWindow.m 2008-09-10 11:17:19 UTC (rev 4600) @@ -37,24 +37,24 @@ */ #import "SKMainWindow.h" -#import "SKPDFHoverWindow.h" +#import "SKPDFToolTipWindow.h" @implementation SKMainWindow - (void)sendEvent:(NSEvent *)theEvent { if ([theEvent type] == NSLeftMouseDown || [theEvent type] == NSRightMouseDown || [theEvent type] == NSKeyDown) - [[SKPDFHoverWindow sharedHoverWindow] orderOut:nil]; + [[SKPDFToolTipWindow sharedToolTipWindow] orderOut:nil]; [super sendEvent:theEvent]; } - (void)resignMainWindow { - [[SKPDFHoverWindow sharedHoverWindow] orderOut:nil]; + [[SKPDFToolTipWindow sharedToolTipWindow] orderOut:nil]; [super resignMainWindow]; } - (void)resignKeyWindow { - [[SKPDFHoverWindow sharedHoverWindow] orderOut:nil]; + [[SKPDFToolTipWindow sharedToolTipWindow] orderOut:nil]; [super resignKeyWindow]; } Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2008-09-10 11:03:54 UTC (rev 4599) +++ trunk/SKMainWindowController.m 2008-09-10 11:17:19 UTC (rev 4600) @@ -72,7 +72,7 @@ #import "SKFindTableView.h" #import "SKAnnotationTypeImageCell.h" #import "NSWindowController_SKExtensions.h" -#import "SKPDFHoverWindow.h" +#import "SKPDFToolTipWindow.h" #import "PDFSelection_SKExtensions.h" #import "SKToolbarItem.h" #import "NSValue_SKExtensions.h" @@ -723,7 +723,7 @@ CFSetRemoveAllValues(temporaryAnnotations); // make sure these will not be activated, or they can lead to a crash - [pdfView removeHoverRects]; + [pdfView removePDFToolTipRects]; [pdfView setActiveAnnotation:nil]; // these will be invalid. If needed, the document will restore them @@ -807,14 +807,14 @@ [self observeUndoManagerCheckpoint:nil]; [noteOutlineView reloadData]; [self allThumbnailsNeedUpdate]; - [pdfView resetHoverRects]; + [pdfView resetPDFToolTipRects]; } - (void)setAnnotationsFromDictionaries:(NSArray *)noteDicts undoable:(BOOL)undoable{ NSEnumerator *e = [[[notes copy] autorelease] objectEnumerator]; PDFAnnotation *annotation; - [pdfView removeHoverRects]; + [pdfView removePDFToolTipRects]; // remove the current annotations [pdfView setActiveAnnotation:nil]; @@ -2093,7 +2093,7 @@ - (IBAction)toggleLeftSidePane:(id)sender { if ([self isFullScreen]) { - [[SKPDFHoverWindow sharedHoverWindow] fadeOut]; + [[SKPDFToolTipWindow sharedToolTipWindow] fadeOut]; if ([self leftSidePaneIsOpen]) [leftSideWindow collapse]; else @@ -2106,7 +2106,7 @@ } else if (usesDrawers) { if ([self leftSidePaneIsOpen]) { if (leftSidePaneState == SKOutlineSidePaneState || [[searchField stringValue] length]) - [[SKPDFHoverWindow sharedHoverWindow] fadeOut]; + [[SKPDFToolTipWindow sharedToolTipWindow] fadeOut]; [leftSideDrawer close]; } else { [leftSideDrawer openOnEdge:NSMinXEdge]; @@ -2117,7 +2117,7 @@ if ([self leftSidePaneIsOpen]) { if (leftSidePaneState == SKOutlineSidePaneState || [[searchField stringValue] length]) - [[SKPDFHoverWindow sharedHoverWindow] fadeOut]; + [[SKPDFToolTipWindow sharedToolTipWindow] fadeOut]; lastLeftSidePaneWidth = NSWidth(sideFrame); // cache this pdfFrame.size.width += lastLeftSidePaneWidth; sideFrame.size.width = 0.0; @@ -2626,7 +2626,7 @@ NSView *containerView = [newButton superview]; if ([oldView isEqual:tocView] || [oldView isEqual:findView] || [oldView isEqual:groupedFindView]) - [[SKPDFHoverWindow sharedHoverWindow] orderOut:self]; + [[SKPDFToolTipWindow sharedToolTipWindow] orderOut:self]; if (wasFind != isFind) { [newButton setFrame:[oldButton frame]]; @@ -3452,7 +3452,7 @@ [secondaryPdfView setNeedsDisplayInRect:oldRect ofPage:page]; } if ([[note type] isEqualToString:SKNNoteString] && [keyPath isEqualToString:SKNPDFAnnotationBoundsKey]) - [pdfView resetHoverRects]; + [pdfView resetPDFToolTipRects]; if ([keyPath isEqualToString:SKNPDFAnnotationBoundsKey] || [keyPath isEqualToString:SKNPDFAnnotationStringKey] || [keyPath isEqualToString:SKNPDFAnnotationTextKey]) { [noteArrayController rearrangeObjects]; Modified: trunk/SKMainWindowController_UI.m =================================================================== --- trunk/SKMainWindowController_UI.m 2008-09-10 11:03:54 UTC (rev 4599) +++ trunk/SKMainWindowController_UI.m 2008-09-10 11:17:19 UTC (rev 4600) @@ -54,7 +54,7 @@ #import <SkimNotes/SkimNotes.h> #import "PDFAnnotation_SKExtensions.h" #import "SKNPDFAnnotationNote_SKExtensions.h" -#import "SKPDFHoverWindow.h" +#import "SKPDFToolTipWindow.h" #import "SKPDFDocument.h" #import "PDFPage_SKExtensions.h" #import "SKGroupedSearchResult.h" @@ -105,7 +105,7 @@ #pragma mark Support -- (void)showHoverWindowForDestination:(PDFDestination *)dest { +- (void)showToolTipForDestination:(PDFDestination *)dest { if ([NSApp isActive] && [[NSUserDefaults standardUserDefaults] boolForKey:SKDisableTableToolTipsKey] == NO) { PDFAnnotationLink *annotation = [[[PDFAnnotationLink alloc] initWithBounds:NSZeroRect] autorelease]; NSPoint point = [dest point]; @@ -128,7 +128,7 @@ break; } [annotation setDestination:[[[PDFDestination alloc] initWithPage:[dest page] atPoint:point] autorelease]]; - [[SKPDFHoverWindow sharedHoverWindow] showForAnnotation:annotation atPoint:NSZeroPoint]; + [[SKPDFToolTipWindow sharedToolTipWindow] showForAnnotation:annotation atPoint:NSZeroPoint]; } } @@ -442,18 +442,18 @@ - (void)tableView:(NSTableView *)tv mouseEnteredTableColumn:(NSTableColumn *)aTableColumn row:(int)row { if ([tv isEqual:findTableView]) { PDFDestination *dest = [[[findArrayController arrangedObjects] objectAtIndex:row] destination]; - [self showHoverWindowForDestination:dest]; + [self showToolTipForDestination:dest]; } else if ([tv isEqual:groupedFindTableView]) { PDFDestination *dest = [[[[[groupedFindArrayController arrangedObjects] objectAtIndex:row] matches] objectAtIndex:0] destination]; - [self showHoverWindowForDestination:dest]; + [self showToolTipForDestination:dest]; } } - (void)tableView:(NSTableView *)tv mouseExitedTableColumn:(NSTableColumn *)aTableColumn row:(int)row { if ([tv isEqual:findTableView]) { - [[SKPDFHoverWindow sharedHoverWindow] fadeOut]; + [[SKPDFToolTipWindow sharedToolTipWindow] fadeOut]; } else if ([tv isEqual:groupedFindTableView]) { - [[SKPDFHoverWindow sharedHoverWindow] fadeOut]; + [[SKPDFToolTipWindow sharedToolTipWindow] fadeOut]; } } @@ -843,13 +843,13 @@ - (void)outlineView:(NSOutlineView *)ov mouseEnteredTableColumn:(NSTableColumn *)aTableColumn item:(id)item { if ([ov isEqual:outlineView]) { - [self showHoverWindowForDestination:[item destination]]; + [self showToolTipForDestination:[item destination]]; } } - (void)outlineView:(NSOutlineView *)ov mouseExitedTableColumn:(NSTableColumn *)aTableColumn item:(id)item { if ([ov isEqual:outlineView]) { - [[SKPDFHoverWindow sharedHoverWindow] fadeOut]; + [[SKPDFToolTipWindow sharedToolTipWindow] fadeOut]; } } Deleted: trunk/SKPDFHoverWindow.h =================================================================== --- trunk/SKPDFHoverWindow.h 2008-09-10 11:03:54 UTC (rev 4599) +++ trunk/SKPDFHoverWindow.h 2008-09-10 11:17:19 UTC (rev 4600) @@ -1,71 +0,0 @@ -// -// SKPDFHoverWindow.h -// Skim -// -// Created by Christiaan Hofman on 2/16/07. -/* - This software is Copyright (c) 2007-2008 - Christiaan Hofman. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of Christiaan Hofman nor the names of any - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <Cocoa/Cocoa.h> -#import "SKAnimatedBorderlessWindow.h" - -@class PDFAnnotation; - -@interface SKPDFHoverWindow : SKAnimatedBorderlessWindow { - NSFont *font; - NSColor *backgroundColor; - NSFont *labelFont; - NSColor *labelColor; - PDFAnnotation *annotation; - NSPoint point; -} - -+ (id)sharedHoverWindow; - -- (void)showForAnnotation:(PDFAnnotation *)annotation atPoint:(NSPoint)aPoint; - -- (void)handleApplicationWillResignActiveNotification:(NSNotification *)notification; - -- (NSFont *)font; -- (void)setFont:(NSFont *)newFont; - -- (NSColor *)backgroundColor; -- (void)setBackgroundColor:(NSColor *)newColor; - -- (NSFont *)labelFont; -- (void)setLabelFont:(NSFont *)newFont; - -- (NSColor *)labelColor; -- (void)setLabelColor:(NSColor *)newColor; - -@end Deleted: trunk/SKPDFHoverWindow.m =================================================================== --- trunk/SKPDFHoverWindow.m 2008-09-10 11:03:54 UTC (rev 4599) +++ trunk/SKPDFHoverWindow.m 2008-09-10 11:17:19 UTC (rev 4600) @@ -1,426 +0,0 @@ -// -// SKPDFHoverWindow.m -// Skim -// -// Created by Christiaan Hofman on 2/16/07. -/* - This software is Copyright (c) 2007-2008 - Christiaan Hofman. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of Christiaan Hofman nor the names of any - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "SKPDFHoverWindow.h" -#import "PDFPage_SKExtensions.h" -#import <SkimNotes/SkimNotes.h> -#import "PDFAnnotation_SKExtensions.h" -#import "NSBezierPath_BDSKExtensions.h" -#import "NSParagraphStyle_SKExtensions.h" -#import "NSGeometry_SKExtensions.h" -#import "NSAffineTransform_SKExtensions.h" - -#define WINDOW_OFFSET 20.0 -#define TEXT_MARGIN_X 2.0 -#define TEXT_MARGIN_Y 2.0 -#define ALPHA_VALUE 0.95 -#define CRITICAL_ALPHA_VALUE 0.9 -#define AUTO_HIDE_TIME_INTERVAL 7.0 -#define DEFAULT_SHOW_DELAY 1.0 -#define ALT_SHOW_DELAY 0.1 - - -NSString *SKToolTipWidthKey = @"SKToolTipWidth"; -NSString *SKToolTipHeightKey = @"SKToolTipHeight"; - -@interface NSScreen (SKExtensions) -+ (NSScreen *)screenForPoint:(NSPoint)point; -@end - - -@implementation SKPDFHoverWindow - -static SKPDFHoverWindow *sharedHoverWindow = nil; - -+ (id)sharedHoverWindow { - if (sharedHoverWindow == nil) - [[self alloc] init]; - return sharedHoverWindow; -} - -+ (id)allocWithZone:(NSZone *)zone { - return sharedHoverWindow ?: [super allocWithZone:zone]; -} - -- (id)init { - if (sharedHoverWindow == nil && (sharedHoverWindow = self = [super initWithContentRect:NSZeroRect])) { - [self setHidesOnDeactivate:NO]; - [self setIgnoresMouseEvents:YES]; - [self setOpaque:YES]; - [self setBackgroundColor:[NSColor whiteColor]]; - [self setHasShadow:YES]; - [self setLevel:NSStatusWindowLevel]; - - NSImageView *imageView = [[NSImageView alloc] init]; - [imageView setImageFrameStyle:NSImageFrameNone]; - [self setContentView:imageView]; - [imageView release]; - - font = [[NSFont toolTipsFontOfSize:11.0] retain]; - backgroundColor = [[NSColor colorWithCalibratedRed:1.0 green:1.0 blue:0.75 alpha:1.0] retain]; - labelFont = [[NSFont boldSystemFontOfSize:11.0] retain]; - labelColor = [[NSColor colorWithCalibratedWhite:0.5 alpha:0.8] retain]; - - annotation = nil; - point = NSZeroPoint; - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleApplicationWillResignActiveNotification:) - name:NSApplicationWillResignActiveNotification object:NSApp]; - } - return sharedHoverWindow; -} - -- (void)dealloc { - [font release]; - [backgroundColor release]; - [labelFont release]; - [labelColor release]; - [super dealloc]; -} - -- (id)retain { return self; } - -- (id)autorelease { return self; } - -- (void)release {} - -- (unsigned)retainCount { return UINT_MAX; } - -- (NSFont *)font { - return font; -} - -- (void)setFont:(NSFont *)newFont { - if (font != newFont) { - [font release]; - font = [newFont retain]; - } -} - -- (NSColor *)backgroundColor { - return backgroundColor; -} - -- (void)setBackgroundColor:(NSColor *)newColor { - if (backgroundColor != newColor) { - [backgroundColor release]; - backgroundColor = [newColor retain]; - } -} - -- (NSFont *)labelFont { - return labelFont; -} - -- (void)setLabelFont:(NSFont *)newFont { - if (labelFont != newFont) { - [labelFont release]; - labelFont = [newFont retain]; - } -} - -- (NSColor *)labelColor { - return labelColor; -} - -- (void)setLabelColor:(NSColor *)newColor { - if (labelColor != newColor) { - [labelColor release]; - labelColor = [newColor retain]; - } -} - -- (void)handleApplicationWillResignActiveNotification:(NSNotification *)notification { - [[NSNotificationCenter defaultCenter] removeObserver:self]; - [self orderOut:self]; -} - -- (float)defaultAlphaValue { return ALPHA_VALUE; } - -- (NSTimeInterval)autoHideTimeInterval { return AUTO_HIDE_TIME_INTERVAL; } - -- (void)willClose { - [annotation release]; - annotation = nil; - point = NSZeroPoint; -} - -- (void)fadeOut { - [super fadeOut]; -} - -- (void)showDelayed { - NSUserDefaults *sud = [NSUserDefaults standardUserDefaults]; - NSPoint thePoint = NSEqualPoints(point, NSZeroPoint) ? [NSEvent mouseLocation] : point; - NSRect contentRect = NSMakeRect(thePoint.x, thePoint.y - WINDOW_OFFSET, [sud floatForKey:SKToolTipWidthKey], [sud floatForKey:SKToolTipHeightKey]); - NSImage *image = nil; - NSAttributedString *text = nil; - NSString *string = nil; - NSColor *color = nil; - - [self cancelDelayedAnimations]; - - if ([annotation isLink]) { - - PDFDestination *dest = [annotation destination]; - PDFPage *page = [dest page]; - - if (page) { - - NSImage *pageImage = [page thumbnailWithSize:0.0 forBox:kPDFDisplayBoxCropBox shadowBlurRadius:0.0 shadowOffset:NSZeroSize readingBarRect:NSZeroRect]; - NSRect pageImageRect = {NSZeroPoint, [pageImage size]}; - NSRect bounds = [page boundsForBox:kPDFDisplayBoxCropBox]; - NSRect sourceRect = contentRect; - PDFSelection *selection = [page selectionForRect:bounds]; - NSAffineTransform *transform = [NSAffineTransform transform]; - - [transform rotateByDegrees:-[page rotation]]; - switch ([page rotation]) { - case 0: - [transform translateXBy:-NSMinX(bounds) yBy:-NSMinY(bounds)]; - break; - case 90: - [transform translateXBy:-NSMaxX(bounds) yBy:-NSMinY(bounds)]; - break; - case 180: - [transform translateXBy:-NSMaxX(bounds) yBy:-NSMaxY(bounds)]; - break; - case 270: - [transform translateXBy:-NSMinX(bounds) yBy:-NSMaxY(bounds)]; - break; - } - - bounds = [transform transformRect:bounds]; - - sourceRect.origin = [transform transformPoint:[dest point]]; - sourceRect.origin.y -= NSHeight(sourceRect); - - if ([selection string]) { - NSRect selBounds = [transform transformRect:[selection boundsForPage:page]]; - float top = ceilf(fmaxf(NSMaxY(selBounds), NSMinX(selBounds) + NSHeight(sourceRect))); - float left = floorf(fminf(NSMinX(selBounds), NSMaxX(bounds) - NSWidth(sourceRect))); - if (top < NSMaxY(sourceRect)) - sourceRect.origin.y = top - NSHeight(sourceRect); - if (left > NSMinX(sourceRect)) - sourceRect.origin.x = left; - } - - color = [NSColor controlBackgroundColor]; - - sourceRect = SKConstrainRect(sourceRect, pageImageRect); - - NSDictionary *attrs = [[NSDictionary alloc] initWithObjectsAndKeys:labelFont, NSFontAttributeName, color, NSForegroundColorAttributeName, [NSParagraphStyle defaultClippingParagraphStyle], NSParagraphStyleAttributeName, nil]; - NSAttributedString *labelString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"Page %@", @"Tool tip label format"), [page displayLabel]] attributes:attrs]; - NSRect labelRect = [labelString boundingRectWithSize:NSZeroSize options:NSStringDrawingUsesLineFragmentOrigin]; - - labelRect.size.width = floorf(NSWidth(labelRect)); - labelRect.size.height = 2.0 * floorf(0.5 * NSHeight(labelRect)); // make sure the cap radius is integral - labelRect.origin.x = NSWidth(sourceRect) - NSWidth(labelRect) - 0.5 * NSHeight(labelRect) - TEXT_MARGIN_X; - labelRect.origin.y = TEXT_MARGIN_Y; - labelRect = NSIntegralRect(labelRect); - - NSRect targetRect = sourceRect; - targetRect.origin = NSZeroPoint; - - image = [[NSImage alloc] initWithSize:targetRect.size]; - - [image lockFocus]; - [pageImage drawInRect:targetRect fromRect:sourceRect operation:NSCompositeCopy fraction:1.0]; - [labelColor setFill]; - [NSBezierPath fillHorizontalOvalAroundRect:labelRect]; - [labelString drawWithRect:labelRect options:NSStringDrawingUsesLineFragmentOrigin]; - [image unlockFocus]; - - [attrs release]; - [labelString release]; - - } else { - - string = [[(PDFAnnotationLink *)annotation URL] absoluteString]; - - } - - } else { - - text = [annotation text]; - string = [text string]; - unsigned int 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 ([[annotation string] length]) - string = [annotation string]; - } - // we release text later - [text retain]; - } - - if (string) { - NSDictionary *attrs = [[NSDictionary alloc] initWithObjectsAndKeys:font, NSFontAttributeName, [NSParagraphStyle defaultClippingParagraphStyle], NSParagraphStyleAttributeName, nil]; - string = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - text = [[NSAttributedString alloc] initWithString:string attributes:attrs]; - [attrs release]; - } - - if (text) { - - NSRect textRect = [text boundingRectWithSize:NSInsetRect(contentRect, TEXT_MARGIN_X, TEXT_MARGIN_Y).size options:NSStringDrawingUsesLineFragmentOrigin]; - - textRect.size.height = fminf(NSHeight(textRect), NSHeight(contentRect) - 2.0 * TEXT_MARGIN_Y); - textRect.origin = NSMakePoint(TEXT_MARGIN_X, TEXT_MARGIN_Y); - - image = [[NSImage alloc] initWithSize:NSInsetRect(NSIntegralRect(textRect), -TEXT_MARGIN_X, -TEXT_MARGIN_X).size]; - color = backgroundColor; - - [image lockFocus]; - [text drawWithRect:textRect options:NSStringDrawingUsesLineFragmentOrigin]; - [image unlockFocus]; - - [text release]; - - } - - if (image) { - - NSImageView *imageView = (NSImageView *)[self contentView]; - - [imageView setImage:image]; - [image release]; - - contentRect.size = [image size]; - contentRect.origin.y -= NSHeight(contentRect); - contentRect = SKConstrainRect(contentRect, [[NSScreen screenForPoint:thePoint] visibleFrame]); - [self setFrame:[self frameRectForContentRect:contentRect] display:NO]; - - [[imageView enclosingScrollView] setBackgroundColor:color]; - - [self stopAnimation]; - if ([self isVisible] && [self alphaValue] > CRITICAL_ALPHA_VALUE) - [self orderFront:self]; - else - [self fadeIn]; - - } else { - - [self fadeOut]; - - } -} - -- (void)cancelDelayedAnimations { - [super cancelDelayedAnimations]; - [[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(showDelayed) object:nil]; -} - -- (void)showForAnnotation:(PDFAnnotation *)note atPoint:(NSPoint)aPoint { - point = aPoint; - - if ([note isEqual:annotation] == NO) { - [self stopAnimation]; - - [annotation release]; - annotation = [note retain]; - - [self performSelector:@selector(showDelayed) withObject:nil afterDelay:[self isVisible] ? ALT_SHOW_DELAY : DEFAULT_SHOW_DELAY]; - } -} - -@end - - -static inline float SKSquaredDistanceFromPointToRect(NSPoint point, NSRect rect) { - float dx, dy; - - if (point.x < NSMinX(rect)) - dx = NSMinX(rect) - point.x; - else if (point.x > NSMaxX(rect)) - dx = point.x - NSMaxX(rect); - else - dx = 0.0; - - if (point.y < NSMinY(rect)) - dy = NSMinY(rect) - point.y; - else if (point.y > NSMaxY(rect)) - dy = point.y - NSMaxY(rect); - else - dy = 0.0; - - return dx * dx + dy * dy; -} - - -@implementation NSScreen (SKExtensions) - -+ (NSScreen *)screenForPoint:(NSPoint)point { - NSEnumerator *screenEnum = [[NSScreen screens] objectEnumerator]; - NSScreen *aScreen; - NSScreen *screen = nil; - float distanceSquared = FLT_MAX; - - while (aScreen = [screenEnum nextObject]) { - NSRect frame = [aScreen frame]; - - if (NSPointInRect(point, frame)) - return aScreen; - - float aDistanceSquared = SKSquaredDistanceFromPointToRect(point, frame); - if (aDistanceSquared < distanceSquared) { - distanceSquared = aDistanceSquared; - screen = aScreen; - } - } - - return screen; -} - -@end Copied: trunk/SKPDFToolTipWindow.h (from rev 4591, trunk/SKPDFHoverWindow.h) =================================================================== --- trunk/SKPDFToolTipWindow.h (rev 0) +++ trunk/SKPDFToolTipWindow.h 2008-09-10 11:17:19 UTC (rev 4600) @@ -0,0 +1,71 @@ +// +// SKPDFToolTipWindow.h +// Skim +// +// Created by Christiaan Hofman on 2/16/07. +/* + This software is Copyright (c) 2007-2008 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> +#import "SKAnimatedBorderlessWindow.h" + +@class PDFAnnotation; + +@interface SKPDFToolTipWindow : SKAnimatedBorderlessWindow { + NSFont *font; + NSColor *backgroundColor; + NSFont *labelFont; + NSColor *labelColor; + PDFAnnotation *annotation; + NSPoint point; +} + ++ (id)sharedToolTipWindow; + +- (void)showForAnnotation:(PDFAnnotation *)annotation atPoint:(NSPoint)aPoint; + +- (void)handleApplicationWillResignActiveNotification:(NSNotification *)notification; + +- (NSFont *)font; +- (void)setFont:(NSFont *)newFont; + +- (NSColor *)backgroundColor; +- (void)setBackgroundColor:(NSColor *)newColor; + +- (NSFont *)labelFont; +- (void)setLabelFont:(NSFont *)newFont; + +- (NSColor *)labelColor; +- (void)setLabelColor:(NSColor *)newColor; + +@end Copied: trunk/SKPDFToolTipWindow.m (from rev 4591, trunk/SKPDFHoverWindow.m) =================================================================== --- trunk/SKPDFToolTipWindow.m (rev 0) +++ trunk/SKPDFToolTipWindow.m 2008-09-10 11:17:19 UTC (rev 4600) @@ -0,0 +1,426 @@ +// +// SKPDFToolTipWindow.m +// Skim +// +// Created by Christiaan Hofman on 2/16/07. +/* + This software is Copyright (c) 2007-2008 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "SKPDFToolTipWindow.h" +#import "PDFPage_SKExtensions.h" +#import <SkimNotes/SkimNotes.h> +#import "PDFAnnotation_SKExtensions.h" +#import "NSBezierPath_BDSKExtensions.h" +#import "NSParagraphStyle_SKExtensions.h" +#import "NSGeometry_SKExtensions.h" +#import "NSAffineTransform_SKExtensions.h" + +#define WINDOW_OFFSET 20.0 +#define TEXT_MARGIN_X 2.0 +#define TEXT_MARGIN_Y 2.0 +#define ALPHA_VALUE 0.95 +#define CRITICAL_ALPHA_VALUE 0.9 +#define AUTO_HIDE_TIME_INTERVAL 7.0 +#define DEFAULT_SHOW_DELAY 1.0 +#define ALT_SHOW_DELAY 0.1 + + +NSString *SKToolTipWidthKey = @"SKToolTipWidth"; +NSString *SKToolTipHeightKey = @"SKToolTipHeight"; + +@interface NSScreen (SKExtensions) ++ (NSScreen *)screenForPoint:(NSPoint)point; +@end + + +@implementation SKPDFToolTipWindow + +static SKPDFToolTipWindow *sharedToolTipWindow = nil; + ++ (id)sharedToolTipWindow { + if (sharedToolTipWindow == nil) + [[self alloc] init]; + return sharedToolTipWindow; +} + ++ (id)allocWithZone:(NSZone *)zone { + return sharedToolTipWindow ?: [super allocWithZone:zone]; +} + +- (id)init { + if (sharedToolTipWindow == nil && (sharedToolTipWindow = self = [super initWithContentRect:NSZeroRect])) { + [self setHidesOnDeactivate:NO]; + [self setIgnoresMouseEvents:YES]; + [self setOpaque:YES]; + [self setBackgroundColor:[NSColor whiteColor]]; + [self setHasShadow:YES]; + [self setLevel:NSStatusWindowLevel]; + + NSImageView *imageView = [[NSImageView alloc] init]; + [imageView setImageFrameStyle:NSImageFrameNone]; + [self setContentView:imageView]; + [imageView release]; + + font = [[NSFont toolTipsFontOfSize:11.0] retain]; + backgroundColor = [[NSColor colorWithCalibratedRed:1.0 green:1.0 blue:0.75 alpha:1.0] retain]; + labelFont = [[NSFont boldSystemFontOfSize:11.0] retain]; + labelColor = [[NSColor colorWithCalibratedWhite:0.5 alpha:0.8] retain]; + + annotation = nil; + point = NSZeroPoint; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleApplicationWillResignActiveNotification:) + name:NSApplicationWillResignActiveNotification object:NSApp]; + } + return sharedToolTipWindow; +} + +- (void)dealloc { + [font release]; + [backgroundColor release]; + [labelFont release]; + [labelColor release]; + [super dealloc]; +} + +- (id)retain { return self; } + +- (id)autorelease { return self; } + +- (void)release {} + +- (unsigned)retainCount { return UINT_MAX; } + +- (NSFont *)font { + return font; +} + +- (void)setFont:(NSFont *)newFont { + if (font != newFont) { + [font release]; + font = [newFont retain]; + } +} + +- (NSColor *)backgroundColor { + return backgroundColor; +} + +- (void)setBackgroundColor:(NSColor *)newColor { + if (backgroundColor != newColor) { + [backgroundColor release]; + backgroundColor = [newColor retain]; + } +} + +- (NSFont *)labelFont { + return labelFont; +} + +- (void)setLabelFont:(NSFont *)newFont { + if (labelFont != newFont) { + [labelFont release]; + labelFont = [newFont retain]; + } +} + +- (NSColor *)labelColor { + return labelColor; +} + +- (void)setLabelColor:(NSColor *)newColor { + if (labelColor != newColor) { + [labelColor release]; + labelColor = [newColor retain]; + } +} + +- (void)handleApplicationWillResignActiveNotification:(NSNotification *)notification { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [self orderOut:self]; +} + +- (float)defaultAlphaValue { return ALPHA_VALUE; } + +- (NSTimeInterval)autoHideTimeInterval { return AUTO_HIDE_TIME_INTERVAL; } + +- (void)willClose { + [annotation release]; + annotation = nil; + point = NSZeroPoint; +} + +- (void)fadeOut { + [super fadeOut]; +} + +- (void)showDelayed { + NSUserDefaults *sud = [NSUserDefaults standardUserDefaults]; + NSPoint thePoint = NSEqualPoints(point, NSZeroPoint) ? [NSEvent mouseLocation] : point; + NSRect contentRect = NSMakeRect(thePoint.x, thePoint.y - WINDOW_OFFSET, [sud floatForKey:SKToolTipWidthKey], [sud floatForKey:SKToolTipHeightKey]); + NSImage *image = nil; + NSAttributedString *text = nil; + NSString *string = nil; + NSColor *color = nil; + + [self cancelDelayedAnimations]; + + if ([annotation isLink]) { + + PDFDestination *dest = [annotation destination]; + PDFPage *page = [dest page]; + + if (page) { + + NSImage *pageImage = [page thumbnailWithSize:0.0 forBox:kPDFDisplayBoxCropBox shadowBlurRadius:0.0 shadowOffset:NSZeroSize readingBarRect:NSZeroRect]; + NSRect pageImageRect = {NSZeroPoint, [pageImage size]}; + NSRect bounds = [page boundsForBox:kPDFDisplayBoxCropBox]; + NSRect sourceRect = contentRect; + PDFSelection *selection = [page selectionForRect:bounds]; + NSAffineTransform *transform = [NSAffineTransform transform]; + + [transform rotateByDegrees:-[page rotation]]; + switch ([page rotation]) { + case 0: + [transform translateXBy:-NSMinX(bounds) yBy:-NSMinY(bounds)]; + break; + case 90: + [transform translateXBy:-NSMaxX(bounds) yBy:-NSMinY(bounds)]; + break; + case 180: + [transform translateXBy:-NSMaxX(bounds) yBy:-NSMaxY(bounds)]; + break; + case 270: + [transform translateXBy:-NSMinX(bounds) yBy:-NSMaxY(bounds)]; + break; + } + + bounds = [transform transformRect:bounds]; + + sourceRect.origin = [transform transformPoint:[dest point]]; + sourceRect.origin.y -= NSHeight(sourceRect); + + if ([selection string]) { + NSRect selBounds = [transform transformRect:[selection boundsForPage:page]]; + float top = ceilf(fmaxf(NSMaxY(selBounds), NSMinX(selBounds) + NSHeight(sourceRect))); + float left = floorf(fminf(NSMinX(selBounds), NSMaxX(bounds) - NSWidth(sourceRect))); + if (top < NSMaxY(sourceRect)) + sourceRect.origin.y = top - NSHeight(sourceRect); + if (left > NSMinX(sourceRect)) + sourceRect.origin.x = left; + } + + color = [NSColor controlBackgroundColor]; + + sourceRect = SKConstrainRect(sourceRect, pageImageRect); + + NSDictionary *attrs = [[NSDictionary alloc] initWithObjectsAndKeys:labelFont, NSFontAttributeName, color, NSForegroundColorAttributeName, [NSParagraphStyle defaultClippingParagraphStyle], NSParagraphStyleAttributeName, nil]; + NSAttributedString *labelString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"Page %@", @"Tool tip label format"), [page displayLabel]] attributes:attrs]; + NSRect labelRect = [labelString boundingRectWithSize:NSZeroSize options:NSStringDrawingUsesLineFragmentOrigin]; + + labelRect.size.width = floorf(NSWidth(labelRect)); + labelRect.size.height = 2.0 * floorf(0.5 * NSHeight(labelRect)); // make sure the cap radius is integral + labelRect.origin.x = NSWidth(sourceRect) - NSWidth(labelRect) - 0.5 * NSHeight(labelRect) - TEXT_MARGIN_X; + labelRect.origin.y = TEXT_MARGIN_Y; + labelRect = NSIntegralRect(labelRect); + + NSRect targetRect = sourceRect; + targetRect.origin = NSZeroPoint; + + image = [[NSImage alloc] initWithSize:targetRect.size]; + + [image lockFocus]; + [pageImage drawInRect:targetRect fromRect:sourceRect operation:NSCompositeCopy fraction:1.0]; + [labelColor setFill]; + [NSBezierPath fillHorizontalOvalAroundRect:labelRect]; + [labelString drawWithRect:labelRect options:NSStringDrawingUsesLineFragmentOrigin]; + [image unlockFocus]; + + [attrs release]; + [labelString release]; + + } else { + + string = [[(PDFAnnotationLink *)annotation URL] absoluteString]; + + } + + } else { + + text = [annotation text]; + string = [text string]; + unsigned int 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 ([[annotation string] length]) + string = [annotation string]; + } + // we release text later + [text retain]; + } + + if (string) { + NSDictionary *attrs = [[NSDictionary alloc] initWithObjectsAndKeys:font, NSFontAttributeName, [NSParagraphStyle defaultClippingParagraphStyle], NSParagraphStyleAttributeName, nil]; + string = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + text = [[NSAttributedString alloc] initWithString:string attributes:attrs]; + [attrs release]; + } + + if (text) { + + NSRect textRect = [text boundingRectWithSize:NSInsetRect(contentRect, TEXT_MARGIN_X, TEXT_MARGIN_Y).size options:NSStringDrawingUsesLineFragmentOrigin]; + + textRect.size.height = fminf(NSHeight(textRect), NSHeight(contentRect) - 2.0 * TEXT_MARGIN_Y); + textRect.origin = NSMakePoint(TEXT_MARGIN_X, TEXT_MARGIN_Y); + + image = [[NSImage alloc] initWithSize:NSInsetRect(NSIntegralRect(textRect), -TEXT_MARGIN_X, -TEXT_MARGIN_X).size]; + color = backgroundColor; + + [image lockFocus]; + [text drawWithRect:textRect options:NSStringDrawingUsesLineFragmentOrigin]; + [image unlockFocus]; + + [text release]; + + } + + if (image) { + + NSImageView *imageView = (NSImageView *)[self contentView]; + + [imageView setImage:image]; + [image release]; + + contentRect.size = [image size]; + contentRect.origin.y -= NSHeight(contentRect); + contentRect = SKConstrainRect(contentRect, [[NSScreen screenForPoint:thePoint] visibleFrame]); + [self setFrame:[self frameRectForContentRect:contentRect] display:NO]; + + [[imageView enclosingScrollView] setBackgroundColor:color]; + + [self stopAnimation]; + if ([self isVisible] && [self alphaValue] > CRITICAL_ALPHA_VALUE) + [self orderFront:self]; + else + [self fadeIn]; + + } else { + + [self fadeOut]; + + } +} + +- (void)cancelDelayedAnimations { + [super cancelDelayedAnimations]; + [[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(showDelayed) object:nil]; +} + +- (void)showForAnnotation:(PDFAnnotation *)note atPoint:(NSPoint)aPoint { + point = aPoint; + + if ([note isEqual:annotation] == NO) { + [self stopAnimation]; + + [annotation release]; + annotation = [note retain]; + + [self performSelector:@selector(showDelayed) withObject:nil afterDelay:[self isVisible] ? ALT_SHOW_DELAY : DEFAULT_SHOW_DELAY]; + } +} + +@end + + +static inline float SKSquaredDistanceFromPointToRect(NSPoint point, NSRect rect) { + float dx, dy; + + if (point.x < NSMinX(rect)) + dx = NSMinX(rect) - point.x; + else if (point.x > NSMaxX(rect)) + dx = point.x - NSMaxX(rect); + else + dx = 0.0; + + if (point.y < NSMinY(rect)) + dy = NSMinY(rect) - point.y; + else if (point.y > NSMaxY(rect)) + dy = point.y - NSMaxY(rect); + else + dy = 0.0; + + return dx * dx + dy * dy; +} + + +@implementation NSScreen (SKExtensions) + ++ (NSScreen *)screenForPoint:(NSPoint)point { + NSEnumerator *screenEnum = [[NSScreen screens] objectEnumerator]; + NSScreen *aScreen; + NSScreen *screen = nil; + float distanceSquared = FLT_MAX; + + while (aScreen = [screenEnum nextObject]) { + NSRect frame = [aScreen frame]; + + if (NSPointInRect(point, frame)) + return aScreen; + + float aDistanceSquared = SKSquaredDistanceFromPointToRect(point, frame); + if (aDistanceSquared < distanceSquared) { + distanceSquared = aDistanceSquared; + screen = aScreen; + } + } + + return screen; +} + +@end Modified: trunk/SKPDFView.h =================================================================== --- trunk/SKPDFView.h 2008-09-10 11:03:54 UTC (rev 4599) +++ trunk/SKPDFView.h 2008-09-10 11:17:19 UTC (rev 4600) @@ -126,8 +126,8 @@ int dragMask; int trackingRect; - CFMutableArrayRef hoverRects; - int hoverRect; + CFMutableArrayRef PDFToolTipRects; + int PDFToolTipRect; int spellingTag; } @@ -205,8 +205,8 @@ - (void)handleScaleChangedNotification:(NSNotification *)notification; - (void)handleWindowWillCloseNotification:(NSNotification *)notification; -- (void)resetHoverRects; -- (void)removeHoverRects; +- (void)resetPDFToolTipRects; +- (void)removePDFToolTipRects; - (NSArray *)accessibilityChildren; - (id)accessibilityChildAtPoint:(NSPoint)point; Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2008-09-10 11:03:54 UTC (rev 4599) +++ trunk/SKPDFView.m 2008-09-10 11:17:19 UTC (rev 4600) @@ -38,7 +38,7 @@ #import "SKPDFView.h" #import "SKNavigationWindow.h" -#import "SKPDFHoverWindow.h" +#import "SKPDFToolTipWindow.h" #import "SKMainWindowController.h" #import <SkimNotes/SkimNotes.h> #import "PDFAnnotation_SKExtensions.h" @@ -243,7 +243,7 @@ mouseDownInAnnotation = NO; trackingRect = 0; - hoverRects = CFArrayCreateMutable(NULL, 0, NULL); + PDFToolTipRects = CFArrayCreateMutable(NULL, 0, NULL); [self registerForDraggedTypes:[NSArray arrayWithObjects:NSColorPboardType, SKLineStylePboardType, nil]]; @@ -276,9 +276,9 @@ [NSArray arrayWithObjects:SKReadingBarColorKey, SKReadingBarInvertKey, nil]]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [self doAutohide:NO]; // invalidates and releases the timer - [[SKPDFHoverWindow sharedHoverWindow] orderOut:self]; - [self removeHoverRects]; - CFRelease(hoverRects); + [[SKPDFToolTipWindow sharedToolTipWindow] orderOut:self]; + [self removePDFToolTipRects]; + CFRelease(PDFToolTipRects); [typeSelectHelper setDataSource:nil]; [typeSelectHelper release]; [transitionController release]; @@ -288,21 +288,21 @@ [super dealloc]; } -#pragma mark Hover-rects +#pragma mark Tool Tips // Fix a bug in Tiger's PDFKit, tooltips lead to a crash when you reload a PDFDocument in a PDFView // see http://www.cocoabuilder.com/archive/message/cocoa/2007/3/12/180190 - (void)scheduleAddingToolips {} -- (void)removeHoverRects { - CFIndex idx = CFArrayGetCount(hoverRects); +- (void)removePDFToolTipRects { + CFIndex idx = CFArrayGetCount(PDFToolTipRects); while (idx--) - [[self documentView] removeTrackingRect:(NSTrackingRectTag)CFArrayGetValueAtIndex(hoverRects, idx)]; - CFArrayRemoveAllValues(hoverRects); + [[self documentView] removeTrackingRect:(NSTrackingRectTag)CFArrayGetValueAtIndex(PDFToolTipRects, idx)]; + CFArrayRemoveAllValues(PDFToolTipRects); } -- (void)resetHoverRects { - [self removeHoverRects]; +- (void)resetPDFToolTipRects { + [self removePDFToolTipRects]; if ([self document] && [self window]) { NSRange range = [self visiblePageIndexRange]; @@ -320,7 +320,7 @@ if (NSIsEmptyRect(rect) == NO) { rect = [self convertRect:rect toView:[self documentView]]; NSTrackingRectTag tag = [[self documentView] addTrackingRect:rect owner:self userData:annotation assumeInside:NO]; - CFArrayAppendValue(hoverRects, (void *)tag); + CFArrayAppendValue(PDFToolTipRects, (void *)tag); } } } @@ -469,12 +469,12 @@ readingBar = nil; selectionRect = NSZeroRect; selectionPageIndex = NSNotFound; - [self removeHoverRects]; + [self removePDFToolTipRects]; [accessibilityChildren release]; accessibilityChildren = nil; - [[SKPDFHoverWindow sharedHoverWindow] orderOut:self]; + [[SKPDFToolTipWindow sharedToolTipWindow] orderOut:self]; [super setDocument:document]; - [self resetHoverRects]; + [self resetPDFToolTipRects]; } - (SKToolMode)toolMode { @@ -1218,7 +1218,7 @@ [super mouseMoved:theEvent]; if ([activeAnnotation isLink]) { - [[SKPDFHoverWindow sharedHoverWindow] fadeOut]; + [[SKPDFToolTipWindow sharedToolTipWindow] fadeOut]; [self setActiveAnnotation:nil]; } @@ -1451,9 +1451,9 @@ [super mouseEntered:theEvent]; if (trackingNumber == trackingRect) { [[self window] setAcceptsMouseMovedEvents:YES]; - } else if ([NSApp isActive] && -1 != CFArrayGetFirstIndexOfValue(hoverRects, CFRangeMake(0, CFArrayGetCount(hoverRects)), (void *)trackingNumber)) { - [[SKPDFHoverWindow sharedHoverWindow] showForAnnotation:(id)[theEvent userData] atPoint:NSZeroPoint]; - hoverRect = trackingNumber; + } else if ([NSApp isActive] && -1 != CFArrayGetFirstIndexOfValue(PDFToolTipRects, CFRangeMake(0, CFArrayGetCount(PDFToolTipRects)), (void *)trackingNumber)) { + [[SKPDFToolTipWindow sharedToolTipWindow] showForAnnotation:(id)[theEvent userData] atPoint:NSZeroPoint]; + PDFToolTipRect = trackingNumber; } } @@ -1462,9 +1462,9 @@ [super mouseExited:theEvent]; if (trackingNumber == trackingRect) { [[self window] setAcceptsMouseMovedEvents:NO]; - } else if (hoverRect == trackingNumber) { - [[SKPDFHoverWindow sharedHoverWindow] fadeOut]; - hoverRect = 0; + } else if (PDFToolTipRect == trackingNumber) { + [[SKPDFToolTipWindow sharedToolTipWindow] fadeOut]; + PDFToolTipRect = 0; } } @@ -1926,7 +1926,7 @@ [annotation setShouldPrint:hideNotes == NO]; [page addAnnotation:annotation]; [self setNeedsDisplayForAnnotation:annotation]; - [self resetHoverRects]; + [self resetPDFToolTipRects]; [accessibilityChildren release]; accessibilityChildren = nil; [[NSNotificationCenter defaultCenter] postNotificationName:SKPDFViewDidAddAnnotationNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:page, SKPDFViewPageKey, annotation, SKPDFViewAnnotationKey, nil]]; @@ -1969,7 +1969,7 @@ if (accessibilityChildren) [accessibilityChildren removeObject:[SKAccessibilityProxyElement elementWithObject:wasAnnotation parent:[self documentView]]]; if (wasNote) - [self resetHoverRects]; + [self resetPDFToolTipRects]; [[NSNotificationCenter defaultCenter] postNotificationName:SKPDFViewDidRemoveAnnotationNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:wasAnnotation, SKPDFViewAnnotationKey, page, SKPDFViewPageKey, nil]]; [wasAnnotation release]; @@ -1986,7 +1986,7 @@ [annotation release]; [self setNeedsDisplayForAnnotation:annotation]; if ([[annotation type] isEqualToString:SKNNoteString]) - [self resetHoverRects]; + [self resetPDFToolTipRects]; [accessibilityChildren release]; accessibilityChildren = nil; [[NSNotificationCenter defaultCenter] postNotificationName:SKPDFViewDidMoveAnnotationNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:oldPage, SKPDFViewOldPageKey, page, SKPDFViewNewPageKey, annotation, SKPDFViewAnnotationKey, nil]]; @@ -2015,7 +2015,7 @@ if ([activeAnnotation isLink]) { - [[SKPDFHoverWindow sharedHoverWindow] orderOut:self]; + [[SKPDFToolTipWindow sharedToolTipWindow] orderOut:self]; if ([activeAnnotation destination]) [self goToDestination:[(PDFAnnotationLink *)activeAnnotation destination]]; else if ([(PDFAnnotationLink *)activeAnnotation URL]) @@ -2045,7 +2045,7 @@ } else if ([activeAnnotation isEditable]) { - [[SKPDFHoverWindow sharedHoverWindow] orderOut:self]; + [[SKPDFToolTipWindow sharedToolTipWindow] orderOut:self]; if ([[self delegate] respondsToSelector:@selector(PDFView:editAnnotation:)]) [[self delegate] PDFView:self editAnnotation:activeAnnotation]; @@ -2121,9 +2121,9 @@ NSPoint point = NSMakePoint(NSMinX(bounds) + 0.3 * NSWidth(bounds), NSMinY(bounds) + 0.3 * NSHeight(bounds)); point = [self convertPoint:[self convertPoint:point fromPage:[annotation page]] toView:nil]; point = [[self window] convertBaseToScreen:NSMakePoint(roundf(point.x), roundf(point.y))]; - [[SKPDFHoverWindow sharedHoverWindow] showForAnnotation:annotation atPoint:point]; + [[SKPDFToolTipWindow sharedToolTipWindow] showForAnnotation:annotation atPoint:point]; } else { - [[SKPDFHoverWindow sharedHoverWindow] orderOut:self]; + [[SKPDFToolTipWindow sharedToolTipWindow] orderOut:self]; } } } @@ -2170,9 +2170,9 @@ NSPoint point = NSMakePoint(NSMinX(bounds) + 0.3 * NSWidth(bounds), NSMinY(bounds) + 0.3 * NSHeight(bounds)); point = [self convertPoint:[self convertPoint:point fromPage:[annotation page]] toView:nil]; point = [[self window] convertBaseToScreen:NSMakePoint(roundf(point.x), roundf(point.y))]; - [[SKPDFHoverWindow sharedHoverWindow] showForAnnotation:annotation atPoint:point]; + [[SKPDFToolTipWindow sharedToolTipWindow] showForAnnotation:annotation atPoint:point]; } else { - [[SKPDFHoverWindow sharedHoverWindow] orderOut:self]; + [[SKPDFToolTipWindow sharedToolTipWindow] orderOut:self]; } } } @@ -2505,7 +2505,7 @@ dest = [ann destination]; doLink = YES; } - // Set link = NO if the annotation links outside the document (e.g. for a URL); currently this is only used for the hover window. We could do something clever like show a URL icon in the hover window (or a WebView!), but for now we'll just ignore these links. + // Set link = NO if the annotation links outside the document (e.g. for a URL); currently this is only used for the tool tip window. We could do something clever like show a URL icon in the tool tip window (or a WebView!), but for now we'll just ignore these links. } if (isLink) *isLink = doLink; Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2008-09-10 11:03:54 UTC (rev 4599) +++ trunk/Skim.xcodeproj/project.pbxproj 2008-09-10 11:17:19 UTC (rev 4600) @@ -65,7 +65,7 @@ CE2DE49D0B85D4F400D0DA12 /* SKFullScreenWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE2DE49C0B85D4F400D0DA12 /* SKFullScreenWindow.m */; }; CE2DE4C60B85D78200D0DA12 /* SKBorderlessImageWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE2DE4C50B85D78200D0DA12 /* SKBorderlessImageWindow.m */; }; CE2DE4EE0B85DB6300D0DA12 /* NSCursor_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CE2DE4ED0B85DB6300D0DA12 /* NSCursor_SKExtensions.m */; }; - CE2DE4FD0B85DBD400D0DA12 /* SKPDFHoverWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE2DE4FC0B85DBD400D0DA12 /* SKPDFHoverWindow.m */; }; + CE2DE4FD0B85DBD400D0DA12 /* SKPDFToolTipWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE2DE4FC0B85DBD400D0DA12 /* SKPDFToolTipWindow.m */; }; CE2DE50D0B85DC4000D0DA12 /* PDFPage_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CE2DE50C0B85DC4000D0DA12 /* PDFPage_SKExtensions.m */; }; CE2DEB1C0B8618DE00D0DA12 /* SKFindController.m in Sources */ = {isa = PBXBuildFile; fileRef = CE2DEB1B0B8618DE00D0DA12 /* SKFindController.m */; }; CE2DEB920B86206400D0DA12 /* FindPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE2DEB900B86206400D0DA12 /* FindPanel.nib */; }; @@ -481,8 +481,8 @@ CE2DE4C50B85D78200D0DA12 /* SKBorderlessImageWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKBorderlessImageWindow.m; sourceTree = "<group>"; }; CE2DE4EC0B85DB6300D0DA12 /* NSCursor_SKExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSCursor_SKExtensions.h; sourceTree = "<group>"; }; CE2DE4ED0B85DB6300D0DA12 /* NSCursor_SKExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSCursor_SKExtensions.m; sourceTree = "<group>"; }; - CE2DE4FB0B85DBD400D0DA12 /* SKPDFHoverWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKPDFHoverWindow.h; sourceTree = "<group>"; }; - CE2DE4FC0B85DBD400D0DA12 /* SKPDFHoverWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKPDFHoverWindow.m; sourceTree = "<group>"; }; + CE2DE4FB0B85DBD400D0DA12 /* SKPDFToolTipWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKPDFToolTipWindow.h; sourceTree = "<group>"; }; + CE2DE4FC0B85DBD400D0DA12 /* SKPDFToolTipWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKPDFToolTipWindow.m; sourceTree = "<group>"; }; CE2DE50B0B85DC4000D0DA12 /* PDFPage_SKExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDFPage_SKExtensions.h; sourceTree = "<group>"; }; CE2DE50C0B85DC4000D0DA12 /* PDFPage_SKExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PDFPage_SKExtensions.m; sourceTree = "<group>"; }; CE2DEB1A0B8618DE00D0DA12 /* SKFindController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKFindController.h; sourceTree = "<group>"; }; @@ -1236,8 +1236,8 @@ CE9B951C0D04657A00EB1A6C /* SKRemoteStateWindow.m */, CE4EBDD80B7BF3B30091F228 /* SKSideWindow.h */, CE4EBDD90B7BF3B30091F228 /* SKSideWindow.m */, - CE2DE4FB0B85DBD400D0DA12 /* SKPDFHoverWindow.h */, - CE2DE4FC0B85DBD400D0DA12 /* SKPDFHoverWindow.m */, + CE2DE4FB0B85DBD400D0DA12 /* SKPDFToolTipWindow.h */, + CE2DE4FC0B85DBD400D0DA12 /* SKPDFToolTipWindow.m */, ); name = Windows; sourceTree = "<group>"; @@ -1981,7 +1981,7 @@ CE2DE49D0B85D4F400D0DA12 /* SKFullScreenWindow.m in Sources */, CE2DE4C60B85D78200D0DA12 /* SKBorderlessImageWindow.m in Sources */, CE2DE4EE0B85DB6300D0DA12 /* NSCursor_SKExtensions.m in Sources */, - CE2DE4FD0B85DBD400D0DA12 /* SKPDFHoverWindow.m in Sources */, + CE2DE4FD0B85DBD400D0DA12 /* SKPDFToolTipWindow.m in Sources */, CE2DE50D0B85DC4000D0DA12 /* PDFPage_SKExtensions.m in Sources */, CE2DEB1C0B8618DE00D0DA12 /* SKFindController.m in Sources */, CE2DED6C0B86334900D0DA12 /* BDSKFindFieldEditor.m in Sources */, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source developm... [truncated message content] |