2001-10-19 19:41:13 +00:00
|
|
|
#import "NameFormatter.h"
|
2002-02-23 03:40:24 +00:00
|
|
|
#import "NSOutlineView-SelectedItems.h"
|
|
|
|
#import "Resource.h"
|
2001-10-19 19:41:13 +00:00
|
|
|
|
2008-07-31 20:27:55 +00:00
|
|
|
/* NameFormatter has been deprecated (it never did what I wanted anyway :-) */
|
|
|
|
/* functionality is now in -outlineView:willDisplayCell:forTableColumn:item: */
|
|
|
|
|
2001-10-19 19:41:13 +00:00
|
|
|
@implementation NameFormatter
|
|
|
|
|
|
|
|
- (NSString *)stringForObjectValue:(id)obj
|
|
|
|
{
|
|
|
|
if( ![obj isKindOfClass:[NSString class]] ) return nil;
|
|
|
|
if( [obj isEqualToString:@""] )
|
|
|
|
{
|
2002-02-23 03:40:24 +00:00
|
|
|
// unfortunetly this is wrong, the resource I'm being asked about is NOT the selected one!
|
|
|
|
if( [[(Resource *)[outlineView selectedItem] type] isEqualToString:@"icns"] )
|
|
|
|
return NSLocalizedString( @"Custom Icon", nil );
|
2001-10-19 19:41:13 +00:00
|
|
|
else return NSLocalizedString( @"Untitled Resource", nil );
|
|
|
|
}
|
|
|
|
else return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSAttributedString *)attributedStringForObjectValue:(id)obj withDefaultAttributes:(NSDictionary *)attrs
|
|
|
|
{
|
|
|
|
NSString *string = [self stringForObjectValue:obj];
|
|
|
|
if( [obj isEqualToString:@""] )
|
2002-02-14 23:24:53 +00:00
|
|
|
return [[NSAttributedString alloc] initWithString:string attributes:[NSDictionary dictionaryWithObject:[NSColor grayColor] forKey:NSForegroundColorAttributeName]];
|
2001-10-19 19:41:13 +00:00
|
|
|
else return [[NSAttributedString alloc] initWithString:string attributes:attrs];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)editingStringForObjectValue:(id)obj
|
|
|
|
{
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString **)error
|
|
|
|
{
|
|
|
|
*obj = string;
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|