// // P4MenuShadedView.m // P4Menu // // Created by Michael Bishop on 7/5/11. // Copyright 2011 Numerical Garden LLC. All rights reserved. // #import "P4MenuShadedView.h" #import "RRGlossCausticShader.h" #import "RRCausticColorMatcher.h" @implementation P4MenuShadedView - (id)initWithFrame:(NSRect)frame { if (! (self = [super initWithFrame:frame]) ) return nil; _shader = [[RRGlossCausticShader alloc] init]; self.baseColor = [NSColor selectedTextBackgroundColor]; return self; } -(void)dealloc { [_shader release]; [super dealloc]; } - (void)drawRect:(NSRect)dirtyRect { // Shade from the top-left corner of the bounds to the bottom-left. NSRect bounds = [self bounds]; [_shader drawShadingFromPoint:NSMakePoint(NSMinX(bounds), NSMaxY(bounds)) toPoint:NSMakePoint(NSMinX(bounds), NSMinY(bounds)) inContext:[[NSGraphicsContext currentContext] graphicsPort]]; } -(void)setBaseColor:(NSColor *)baseColor { [_shader setNoncausticColor:[[baseColor copy] autorelease]]; [_shader update]; } -(NSColor*)baseColor { return [_shader noncausticColor]; } @end