diff options
author | avenjamin <avenjamin@gmail.com> | 2009-06-24 15:46:27 +0000 |
---|---|---|
committer | avenjamin <avenjamin@gmail.com> | 2009-06-24 15:46:27 +0000 |
commit | 5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40 (patch) | |
tree | f0eaf423f2c13f2091fe9cfceaa2e0a6f2169723 /Frameworks/BWToolkitFramework.framework/BWUnanchoredButtonCell.m | |
parent | 37bd86b2879c107ebb026954693540979cf25e2a (diff) | |
download | sequelpro-5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40.tar.gz sequelpro-5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40.tar.bz2 sequelpro-5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40.zip |
- Changed the way the BWToolkit framework was included to allow modifications to be made easily.
- Fixed show/hide info pane toggle button image states to now show correctly
Diffstat (limited to 'Frameworks/BWToolkitFramework.framework/BWUnanchoredButtonCell.m')
-rw-r--r-- | Frameworks/BWToolkitFramework.framework/BWUnanchoredButtonCell.m | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Frameworks/BWToolkitFramework.framework/BWUnanchoredButtonCell.m b/Frameworks/BWToolkitFramework.framework/BWUnanchoredButtonCell.m new file mode 100644 index 00000000..8c8fc4d4 --- /dev/null +++ b/Frameworks/BWToolkitFramework.framework/BWUnanchoredButtonCell.m @@ -0,0 +1,77 @@ +// +// BWUnanchoredButtonCell.m +// BWToolkit +// +// Created by Brandon Walkin (www.brandonwalkin.com) +// All code is provided under the New BSD license. +// + +#import "BWUnanchoredButtonCell.h" +#import "BWUnanchoredButton.h" +#import "NSColor+BWAdditions.h" + +static NSColor *fillStop1, *fillStop2, *fillStop3, *fillStop4; +static NSColor *borderColor, *topBorderColor, *bottomInsetColor, *topInsetColor, *pressedColor; +static NSGradient *fillGradient; + +@interface BWAnchoredButtonCell (BWUBCPrivate) +- (void)drawTitleInFrame:(NSRect)cellFrame; +- (void)drawImageInFrame:(NSRect)cellFrame; +@end + +@implementation BWUnanchoredButtonCell + ++ (void)initialize; +{ + fillStop1 = [[NSColor colorWithCalibratedWhite:(251.0f / 255.0f) alpha:1] retain]; + fillStop2 = [[NSColor colorWithCalibratedWhite:(251.0f / 255.0f) alpha:1] retain]; + fillStop3 = [[NSColor colorWithCalibratedWhite:(236.0f / 255.0f) alpha:1] retain]; + fillStop4 = [[NSColor colorWithCalibratedWhite:(243.0f / 255.0f) alpha:1] retain]; + + fillGradient = [[NSGradient alloc] initWithColorsAndLocations: + fillStop1, (CGFloat)0.0, + fillStop2, (CGFloat)0.5, + fillStop3, (CGFloat)0.5, + fillStop4, (CGFloat)1.0, + nil]; + + topBorderColor = [[NSColor colorWithCalibratedWhite:(126.0f / 255.0f) alpha:1] retain]; + borderColor = [[NSColor colorWithCalibratedWhite:(151.0f / 255.0f) alpha:1] retain]; + + topInsetColor = [[NSColor colorWithCalibratedWhite:(0.0f / 255.0f) alpha:0.08] retain]; + bottomInsetColor = [[NSColor colorWithCalibratedWhite:(255.0f / 255.0f) alpha:0.54] retain]; + + pressedColor = [[NSColor colorWithCalibratedWhite:(0.0f / 255.0f) alpha:0.3] retain]; +} + + +- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView +{ + [fillGradient drawInRect:NSInsetRect(cellFrame, 0, 2) angle:90]; + + [topInsetColor drawPixelThickLineAtPosition:0 withInset:0 inRect:cellFrame inView:[self controlView] horizontal:YES flip:NO]; + [topBorderColor drawPixelThickLineAtPosition:1 withInset:0 inRect:cellFrame inView:[self controlView] horizontal:YES flip:NO]; + [borderColor drawPixelThickLineAtPosition:1 withInset:0 inRect:cellFrame inView:[self controlView] horizontal:YES flip:YES]; + [bottomInsetColor drawPixelThickLineAtPosition:0 withInset:0 inRect:cellFrame inView:[self controlView] horizontal:YES flip:YES]; + + [borderColor drawPixelThickLineAtPosition:0 withInset:2 inRect:cellFrame inView:[self controlView] horizontal:NO flip:YES]; + [borderColor drawPixelThickLineAtPosition:0 withInset:2 inRect:cellFrame inView:[self controlView] horizontal:NO flip:NO]; + + if ([self image] == nil) + { + NSRect titleRect = cellFrame; + titleRect.size.height -= 4; + [super drawTitleInFrame:titleRect]; + } + else + [super drawImageInFrame:cellFrame]; + + if ([self isHighlighted]) + { + [pressedColor set]; + NSRectFillUsingOperation(NSInsetRect(cellFrame,0,1), NSCompositeSourceOver); + } +} + + +@end |