Created
July 27, 2010 18:01
-
-
Save luebken/492593 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
@import <AppKit/CPView.j> | |
@implementation TextFieldColumnView : CPControl | |
{ | |
CPTextField field; | |
} | |
- (id)initWithFrame:(CGRect)rect andTable:(CPTableView)table { | |
self = [super initWithFrame:rect]; | |
field = [CPTextField textFieldWithStringValue:@"" | |
placeholder:@"" | |
width:100]; | |
[field setFrame:CGRectMake(5,9,10,26)]; | |
[field setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable | CPViewMaxYMargin | CPViewMinYMargin]; | |
[self addSubview:field]; | |
[field setTarget:table]; | |
[field setAction:@selector(_commitDataViewObjectValue:)]; | |
return self; | |
} | |
//a custom object containing information about visibility and the data | |
- (void)setObjectValue:(Object)value { | |
if(value) { | |
if(!value.visible) { | |
[field setStringValue:""]; | |
[field setEditable:NO]; | |
[field setBordered:NO]; | |
[field setBezeled:NO]; | |
[field setAutoresizingMask:CPViewWidthSizable]; | |
} else { | |
[field setAutoresizingMask:CPViewWidthSizable]; | |
[field setStringValue:value.title]; | |
[field setEditable:value.editing]; | |
[field setBordered:value.editing]; | |
[field setBezeled:value.editing]; | |
} | |
} | |
} | |
- (id)initWithCoder:(CPCoder)aCoder { | |
self = [super initWithCoder:aCoder]; | |
field = [aCoder decodeObjectForKey:"field"]; | |
return self; | |
} | |
- (void)encodeWithCoder:(CPCoder)aCoder { | |
[super encodeWithCoder:aCoder]; | |
[aCoder encodeObject:field forKey:"field"]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment