Created
April 30, 2010 00:50
-
-
Save j4johnfox/384537 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
/* | |
* MMSSimpleWhiteScroller.j | |
* | |
* Created by John C. Fox on 04/29/2010. | |
* Copyright 2010 GroupSmarts, LLC. All rights reserved. | |
*/ | |
@import <Foundation/CPObject.j> | |
@import <AppKit/CPTheme.j> | |
@implementation MMSSimpleWhiteScroller : CPScroller | |
{ | |
} | |
- (id)initWithFrame:(CGRect)aFrame | |
{ | |
self = [super initWithFrame:aFrame]; | |
if (self) | |
{ | |
// Configure Attributes for Vertical Orientation | |
if ([self isVertical]) | |
{ | |
[self configureVerticalThemeAttributes]; | |
} | |
else | |
{ | |
// Configure Attributes for Horizontal Orientation | |
[self configureHorizontalThemeAttributes]; | |
} | |
[self setFloatValue:0.1 knobProportion:0.5]; | |
} | |
return self; | |
} | |
- (void)configureVerticalThemeAttributes | |
{ | |
var topArrowColor = PatternColor(CPImageInBundle("MMSScrollerTrackVerticalTop.png", CGSizeMake(16.0, 1.0))); | |
[self setValue:topArrowColor forThemeAttribute:@"decrement-line-color" ]; | |
[self setValue:CGSizeMake(16.0, 9.0) forThemeAttribute:@"decrement-line-size" inState:CPThemeStateVertical]; | |
[self setValue:21.0 forThemeAttribute:@"minimum-knob-length" inState:CPThemeStateVertical]; | |
[self setValue:CGInsetMake(0.0, 3.0, 0.0, 3.0) forThemeAttribute:@"knob-inset" inState:CPThemeStateVertical]; | |
[self setValue:CGInsetMake(0.0, 0.0, 0.0, 0.0) forThemeAttribute:@"track-inset" inState:CPThemeStateVertical]; | |
var trackColor = PatternColor(CPImageInBundle("MMSScrollerTrackVerticalCenter.png", CGSizeMake(16.0, 1.0))); | |
[self setValue:trackColor forThemeAttribute:@"knob-slot-color" inState:CPThemeStateVertical]; | |
var knobColor = PatternColor([[CPThreePartImage alloc] initWithImageSlices: | |
[ | |
CPImageInBundle("MMSScrollerKnobTop.png", CGSizeMake(10.0, 6.0)), | |
CPImageInBundle("MMSScrollerKnobMiddle.png", CGSizeMake(10, 1.0)), | |
CPImageInBundle("MMSScrollerKnobBottom.png", CGSizeMake(10.0, 6.0)) | |
] | |
isVertical:YES]); | |
[self setValue:knobColor forThemeAttribute:@"knob-color" inState:CPThemeStateVertical]; | |
var bottomArrowColor = PatternColor(CPImageInBundle("MMSScrollerTrackVerticalBottom.png", CGSizeMake(16.0, 1.0))); | |
[self setValue:bottomArrowColor forThemeAttribute:@"increment-line-color" inState:CPThemeStateVertical]; | |
[self setValue:CGSizeMake(16.0, 9.0) forThemeAttribute:@"increment-line-size" inState:CPThemeStateVertical]; | |
} | |
- (void)configureHorizontalThemeAttributes | |
{ | |
var leftArrowColor = PatternColor(CPImageInBundle("MMSScrollerTrackHorizontalLeft.png", CGSizeMake(1.0, 16.0))); | |
[self setValue:leftArrowColor forThemeAttribute:@"decrement-line-color"]; | |
[self setValue:CGSizeMake(9.0, 16.0) forThemeAttribute:@"decrement-line-size"]; | |
[self setValue:21.0 forThemeAttribute:@"minimum-knob-length"]; | |
[self setValue:CGInsetMake(3.0, 0.0, 3.0, 0.0) forThemeAttribute:@"knob-inset"]; | |
[self setValue:CGInsetMake(0.0, 0.0, 0.0, 0.0) forThemeAttribute:@"track-inset"]; | |
var trackColor = PatternColor(CPImageInBundle("MMSScrollerTrackHorizontalCenter.png", CGSizeMake(1.0, 16.0))); | |
[self setValue:trackColor forThemeAttribute:@"knob-slot-color"]; | |
var knobColor = PatternColor([[CPThreePartImage alloc] initWithImageSlices: | |
[ | |
CPImageInBundle("MMSScrollerKnobLeft.png", CGSizeMake(6.0, 10.0)), | |
CPImageInBundle("MMSScrollerKnobCenter.png", CGSizeMake(1.0, 10.0)), | |
CPImageInBundle("MMSScrollerKnobRight.png", CGSizeMake(6.0, 10.0)) | |
] | |
isVertical:NO]); | |
[self setValue:knobColor forThemeAttribute:@"knob-color"]; | |
var rightArrowColor = PatternColor(CPImageInBundle("MMSScrollerTrackHorizontalRight.png", CGSizeMake(1.0, 16.0))); | |
[self setValue:rightArrowColor forThemeAttribute:@"increment-line-color"]; | |
[self setValue:CGSizeMake(9.0, 16.0) forThemeAttribute:@"increment-line-size"]; | |
} | |
@end | |
function PatternColor(anImage) | |
{ | |
return [CPColor colorWithPatternImage:anImage]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment