Created
June 8, 2010 03:52
-
-
Save aljungberg/429587 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
+ (CPTextField)standardTextFieldWithBase:(CPTextField)baseInstance | |
{ | |
var textfield = [self textField:baseInstance], | |
bezelColor = [CPColor colorWithPatternImage:[[CPNinePartImage alloc] initWithImageSlices: | |
[ | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-0.png" size:CGSizeMake(2.0, 3.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-1.png" size:CGSizeMake(1.0, 3.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-2.png" size:CGSizeMake(2.0, 3.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-3.png" size:CGSizeMake(2.0, 1.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-4.png" size:CGSizeMake(1.0, 1.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-5.png" size:CGSizeMake(2.0, 1.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-6.png" size:CGSizeMake(2.0, 2.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-7.png" size:CGSizeMake(1.0, 2.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-8.png" size:CGSizeMake(2.0, 2.0)] | |
]]], | |
bezelFocusedColor = [CPColor colorWithPatternImage:[[CPNinePartImage alloc] initWithImageSlices: | |
[ | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-focused-0.png" size:CGSizeMake(6.0, 7.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-focused-1.png" size:CGSizeMake(1.0, 7.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-focused-2.png" size:CGSizeMake(6.0, 7.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-focused-3.png" size:CGSizeMake(6.0, 1.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-focused-4.png" size:CGSizeMake(1.0, 1.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-focused-5.png" size:CGSizeMake(6.0, 1.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-focused-6.png" size:CGSizeMake(6.0, 5.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-focused-7.png" size:CGSizeMake(1.0, 5.0)], | |
[_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-focused-8.png" size:CGSizeMake(6.0, 5.0)] | |
]]]; | |
[textfield setBezeled:YES]; | |
[textfield setValue:bezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBezeled]; | |
[textfield setValue:bezelFocusedColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBezeled|CPThemeStateEditing]; | |
[textfield setValue:[CPFont systemFontOfSize:12.0] forThemeAttribute:@"font" inState:CPThemeStateBezeled]; | |
[textfield setValue:CGInsetMake(9.0, 7.0, 5.0, 8.0) forThemeAttribute:@"content-inset" inState:CPThemeStateBezeled]; | |
[textfield setValue:CGInsetMake(4.0, 4.0, 3.0, 4.0) forThemeAttribute:@"bezel-inset" inState:CPThemeStateBezeled]; | |
[textfield setValue:CGInsetMake(0.0, 0.0, 0.0, 0.0) forThemeAttribute:@"bezel-inset" inState:CPThemeStateBezeled|CPThemeStateEditing]; | |
[textfield setPlaceholderString:"placeholder"]; | |
[textfield setStringValue:""]; | |
[textfield setEditable:YES]; | |
return textfield; | |
} | |
+ (CPTokenField)themedTokenField | |
{ | |
var tokenField = [self standardTextFieldWithBase:[CPTokenField alloc]]; | |
[tokenField setValue:CGInsetMake(9.0, 0.0, 5.0, 2.0) forThemeAttribute:@"content-inset" inState:CPTextFieldStatePlaceholder]; | |
return tokenField; | |
} | |
+ (_CPTokenFieldToken)themedTokenFieldToken | |
{ | |
var tokenfield = [[_CPTokenFieldToken alloc] initWithFrame:CGRectMake(0.0, 0.0, 60.0, 24.0)]; | |
var bezelColor = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices: | |
[ | |
[_CPCibCustomResource imageResourceWithName:@"tokenfield-left.png" size:CPSizeMake(7.0, 21.0)], | |
[_CPCibCustomResource imageResourceWithName:@"tokenfield-middle.png" size:CPSizeMake(4.0, 21.0)], | |
[_CPCibCustomResource imageResourceWithName:@"tokenfield-right.png" size:CPSizeMake(7.0, 21.0)] | |
] isVertical:NO]]; | |
bezelFocusedColor = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices: | |
[ | |
[_CPCibCustomResource imageResourceWithName:@"tokenfield-focused-left.png" size:CPSizeMake(7.0, 21.0)], | |
[_CPCibCustomResource imageResourceWithName:@"tokenfield-focused-middle.png" size:CPSizeMake(4.0, 21.0)], | |
[_CPCibCustomResource imageResourceWithName:@"tokenfield-focused-right.png" size:CPSizeMake(7.0, 21.0)] | |
] isVertical:NO]]; | |
[tokenfield setValue:[CPColor colorWithRed:41.0 / 255.0 green:51.0 / 255.0 blue:64.0 / 255.0 alpha:1.0] forThemeAttribute:@"text-color"]; | |
[tokenfield setValue:bezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBezeled]; | |
[tokenfield setValue:bezelFocusedColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBezeled|CPThemeStateHighlighted]; | |
[tokenfield setValue:CGInsetMake(2, 0.0, 2, 0.0) forThemeAttribute:@"bezel-inset" inState:CPThemeStateBezeled]; | |
[tokenfield setValue:CGInsetMake(2.0, 20.0, 1.0, 10.0) forThemeAttribute:@"content-inset" inState:CPThemeStateBezeled]; | |
[tokenfield setValue:CPCenterTextAlignment forThemeAttribute:@"vertical-alignment"] | |
return tokenfield; | |
} | |
+ (_CPTokenFieldTokenCloseButton)themedTokenFieldTokenCloseButton | |
{ | |
var button = [[_CPTokenFieldTokenCloseButton alloc] initWithFrame:CGRectMake(0, 0, 7, 7)]; | |
var bezelColor = PatternColor([[CPThreePartImage alloc] initWithImageSlices: | |
[ | |
[_CPCibCustomResource imageResourceWithName:"tokenfield-close.png" size:CGSizeMake(7.0, 7.0)], nil, nil | |
] | |
isVertical:NO]), | |
bezelColorPushed = PatternColor([[CPThreePartImage alloc] initWithImageSlices: | |
[ | |
[_CPCibCustomResource imageResourceWithName:"tokenfield-close-pushed.png" size:CGSizeMake(7.0, 7.0)], nil, nil | |
] | |
isVertical:NO]); | |
[button setValue:bezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered]; | |
[button setValue:bezelColorPushed forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered|CPThemeStateHighlighted]; | |
[button setValue:CGSizeMake(7.0, 7.0) forThemeAttribute:@"min-size"]; | |
[button setValue:CGSizeMake(7.0, 7.0) forThemeAttribute:@"max-size"]; | |
return button; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment