From 59cbcc38ab2b4ec3b4a69ab4e6896a1b7c118dae Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 18 Aug 2009 09:54:33 +0000 Subject: =?UTF-8?q?=E2=80=A2=20SPTooltip:=20added=20type=20"image"=20-=20s?= =?UTF-8?q?how=20images=20directly=20as=20a=20NSImage=20in=20a=20NSImageVi?= =?UTF-8?q?ew=20(this=20decreases=20the=20memory=20usage=20enormously)=20?= =?UTF-8?q?=E2=80=A2=C2=A0applied=20new=20tooltip=20invocation=20for=20ima?= =?UTF-8?q?ge=20blob=20data=20in=20Content=20Pane=20and=20Custom=20Query?= =?UTF-8?q?=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/TableContent.m | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'Source/TableContent.m') diff --git a/Source/TableContent.m b/Source/TableContent.m index 3f8c9596..3ac60e29 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1799,6 +1799,8 @@ - (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(SPTextAndLinkCell *)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation { + NSImage *image; + if([[aCell stringValue] length] < 1) return nil; NSPoint pos = [NSEvent mouseLocation]; @@ -1807,22 +1809,17 @@ // Get the original data for trying to display the blob data as an image id theValue = NSArrayObjectAtIndex(NSArrayObjectAtIndex(tableValues, row), [[aTableColumn identifier] intValue]); if ([theValue isKindOfClass:[NSData class]]) { - NSImage *image = [[NSImage alloc] initWithData:theValue]; + image = [[NSImage alloc] initWithData:theValue]; if(image) { - int imageWidth = [image size].width; - if (imageWidth > 100) imageWidth = 100; - [SPTooltip showWithObject:[NSString stringWithFormat: - @"", - imageWidth, - [[image TIFFRepresentationUsingCompression:NSTIFFCompressionJPEG factor:0.01] base64EncodingWithLineLength:0]] - atLocation:pos - ofType:@"html" - displayOptions:[NSDictionary dictionaryWithObjectsAndKeys:@"transparent", @"transparent", nil]]; + [SPTooltip showWithObject:image atLocation:pos ofType:@"image"]; + [image release]; + theValue = nil; + return nil; } - [image release]; - return nil; } + if(image) [image release]; + // Show the cell string value as tooltip (including line breaks and tabs) if([[aCell stringValue] length] > 1) [SPTooltip showWithObject:[aCell stringValue] atLocation:pos]; -- cgit v1.2.3