declare methods in FileBrowserCell, and make some private

This commit is contained in:
Mitchell Livingston 2007-08-10 17:46:02 +00:00
parent 7b69ebac18
commit c4eab94aea
2 changed files with 61 additions and 46 deletions

View File

@ -33,4 +33,8 @@
- (void) setProgress: (float) progress; - (void) setProgress: (float) progress;
- (NSRect) titleRectForBounds: (NSRect) bounds;
- (NSRect) statusRectForBounds: (NSRect) bounds;
- (NSRect) imageRectForBounds: (NSRect) bounds;
@end @end

View File

@ -33,6 +33,13 @@
#define PADDING_BELOW_STATUS_REG 1.0 #define PADDING_BELOW_STATUS_REG 1.0
#define PADDING_AFTER_TITLE 1.0 #define PADDING_AFTER_TITLE 1.0
@interface FileBrowserCell (Private)
- (NSAttributedString *) attributedTitleWithColor: (NSColor *) color;
- (NSAttributedString *) attributedStatusWithColor: (NSColor *) color;
@end
@implementation FileBrowserCell @implementation FileBrowserCell
- (void) awakeFromNib - (void) awakeFromNib
@ -55,27 +62,6 @@
fPercent = progress * 100.0; 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 - (NSRect) titleRectForBounds: (NSRect) bounds
{ {
NSAttributedString * title = [self attributedTitleWithColor: nil]; NSAttributedString * title = [self attributedTitleWithColor: nil];
@ -99,31 +85,6 @@
return result; 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 - (NSRect) statusRectForBounds: (NSRect) bounds
{ {
if ([[[self objectValue] objectForKey: @"IsFolder"] boolValue]) if ([[[self objectValue] objectForKey: @"IsFolder"] boolValue])
@ -176,3 +137,53 @@
} }
@end @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