ResKnife/Cocoa/Classes/NameFormatter.m

48 lines
1.5 KiB
Mathematica
Raw Normal View History

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
/* 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:@""] )
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