From c4eab94aeae8b82d89dd2ee946f179854f10bd68 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Fri, 10 Aug 2007 17:46:02 +0000 Subject: [PATCH] declare methods in FileBrowserCell, and make some private --- macosx/FileBrowserCell.h | 4 ++ macosx/FileBrowserCell.m | 103 ++++++++++++++++++++++----------------- 2 files changed, 61 insertions(+), 46 deletions(-) diff --git a/macosx/FileBrowserCell.h b/macosx/FileBrowserCell.h index 08324f517..05de38854 100644 --- a/macosx/FileBrowserCell.h +++ b/macosx/FileBrowserCell.h @@ -33,4 +33,8 @@ - (void) setProgress: (float) progress; +- (NSRect) titleRectForBounds: (NSRect) bounds; +- (NSRect) statusRectForBounds: (NSRect) bounds; +- (NSRect) imageRectForBounds: (NSRect) bounds; + @end diff --git a/macosx/FileBrowserCell.m b/macosx/FileBrowserCell.m index d31e74a66..1aa5b3787 100644 --- a/macosx/FileBrowserCell.m +++ b/macosx/FileBrowserCell.m @@ -33,6 +33,13 @@ #define PADDING_BELOW_STATUS_REG 1.0 #define PADDING_AFTER_TITLE 1.0 +@interface FileBrowserCell (Private) + +- (NSAttributedString *) attributedTitleWithColor: (NSColor *) color; +- (NSAttributedString *) attributedStatusWithColor: (NSColor *) color; + +@end + @implementation FileBrowserCell - (void) awakeFromNib @@ -55,27 +62,6 @@ fPercent = progress * 100.0; } -- (NSAttributedString *) attributedTitleWithColor: (NSColor *) color -{ - if (!fTitleAttributes) - { - NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; - [paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail]; - - fTitleAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys: - [NSFont messageFontOfSize: 12.0], NSFontAttributeName, - paragraphStyle, NSParagraphStyleAttributeName, nil]; - - [paragraphStyle release]; - } - - if (color) - [fTitleAttributes setObject: color forKey: NSForegroundColorAttributeName]; - - NSString * title = [[self objectValue] objectForKey: @"Name"]; - return [[[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes] autorelease]; -} - - (NSRect) titleRectForBounds: (NSRect) bounds { NSAttributedString * title = [self attributedTitleWithColor: nil]; @@ -99,31 +85,6 @@ return result; } -- (NSAttributedString *) attributedStatusWithColor: (NSColor *) color -{ - if (!fStatusAttributes) - { - NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; - [paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail]; - - fStatusAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys: - [NSFont messageFontOfSize: 9.0], NSFontAttributeName, - paragraphStyle, NSParagraphStyleAttributeName, nil]; - - [paragraphStyle release]; - } - - if (color) - [fStatusAttributes setObject: color forKey: NSForegroundColorAttributeName]; - - #warning fPercent? - NSString * status = [NSString stringWithFormat: NSLocalizedString(@"%.2f%% of %@", - "Inspector -> Files tab -> file status string"), fPercent, - [NSString stringForFileSize: [[[self objectValue] objectForKey: @"Size"] unsignedLongLongValue]]]; - - return [[[NSAttributedString alloc] initWithString: status attributes: fStatusAttributes] autorelease]; -} - - (NSRect) statusRectForBounds: (NSRect) bounds { if ([[[self objectValue] objectForKey: @"IsFolder"] boolValue]) @@ -176,3 +137,53 @@ } @end + +@implementation FileBrowserCell (Private) + +- (NSAttributedString *) attributedTitleWithColor: (NSColor *) color +{ + if (!fTitleAttributes) + { + NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; + [paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail]; + + fTitleAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys: + [NSFont messageFontOfSize: 12.0], NSFontAttributeName, + paragraphStyle, NSParagraphStyleAttributeName, nil]; + + [paragraphStyle release]; + } + + if (color) + [fTitleAttributes setObject: color forKey: NSForegroundColorAttributeName]; + + NSString * title = [[self objectValue] objectForKey: @"Name"]; + return [[[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes] autorelease]; +} + +- (NSAttributedString *) attributedStatusWithColor: (NSColor *) color +{ + if (!fStatusAttributes) + { + NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; + [paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail]; + + fStatusAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys: + [NSFont messageFontOfSize: 9.0], NSFontAttributeName, + paragraphStyle, NSParagraphStyleAttributeName, nil]; + + [paragraphStyle release]; + } + + if (color) + [fStatusAttributes setObject: color forKey: NSForegroundColorAttributeName]; + + #warning fPercent? + NSString * status = [NSString stringWithFormat: NSLocalizedString(@"%.2f%% of %@", + "Inspector -> Files tab -> file status string"), fPercent, + [NSString stringForFileSize: [[[self objectValue] objectForKey: @"Size"] unsignedLongLongValue]]]; + + return [[[NSAttributedString alloc] initWithString: status attributes: fStatusAttributes] autorelease]; +} + +@end