Created
December 25, 2009 14:21
-
-
Save alexanderweiss/263642 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (id)outlineView:(CPOutlineView)outlineView objectValueForTableColumn:(CPTableColumn)tableColumn byItem:(id)item | |
{ | |
CPLog("outlineView:%@ objectValueForTableColumn:%@ byItem:%@", outlineView, tableColumn, item); | |
var values = [items objectForKey:item]; | |
var label = [values objectForKey:@"name"]; | |
var fileName = [[CPString alloc] initWithFormat:@"%@_%@.png", [values objectForKey:@"basic_type"], [values objectForKey:@"extra_type"]]; | |
return [[AOOutlineViewObjectData alloc] initWithLabel:label iconName:fileName]; | |
} | |
@end | |
@implementation AODataView : CPView | |
{ | |
CPTextField label; | |
CPImageView iconView; | |
} | |
- (void)setObjectValue:(JSObject)object | |
{ | |
CPLog("setObjectValue:%@", object); | |
if (!label) | |
{ | |
label = [[CPTextField alloc] initWithFrame:CGRectInset([self bounds], 20.0 ,1.0)]; | |
[self addSubview:label]; | |
} | |
if (!icon) | |
{ | |
var icon = [[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:@"globe.png"] size:CGSizeMake(16.0, 16.0)]; | |
iconView = [[CPImageView alloc] initWithFrame:CGRectMake(2.0,0,18.0,18.0)]; | |
[iconView setImage:[[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:[object iconName]]]]; | |
[self addSubview:iconView]; | |
} | |
[label setStringValue:[object label]]; | |
[label sizeToFit]; | |
} | |
@end | |
@implementation AOOutlineViewObjectData : CPObject | |
{ | |
CPTextField label; | |
CPImageView iconName; | |
} | |
- (void)initWithLabel:(CPString)aLabel iconName:(CPString)anIconName | |
{ | |
if([super init]) | |
{ | |
console.log('init label'); | |
label = aLabel; | |
iconName = anIconName; | |
} | |
return self; | |
} | |
- (CPString)label | |
{ | |
console.log(label); | |
return label; | |
} | |
- (CPString)iconName | |
{ | |
return iconName; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment