// // ShadowView.m // // Created by Andrew Zamler-Carhart on Tue Jul 02 2002. // mailto:andrew@zamler-carhart.com // Copyright (c) 2002 Andrew Zamler-Carhart. // // Thanks to John C. Randolph and Tom Waters. // #import "ShadowView.h" @implementation ShadowView - (void) enlargeFrame: (int) offset { NSRect newFrame = NSMakeRect([self frame].origin.x - offset, [self frame].origin.y - offset, [self frame].size.width + 2 * offset, [self frame].size.height + 2 * offset); [self setFrame: newFrame]; [self setNeedsDisplay: YES]; } - (void) showShadowHeight: (int) height radius: (int) radius azimuth: (int) azimuth ka: (float) ka { extern void *CGSReadObjectFromCString(char*); extern char *CGSUniqueCString(char*); extern void *CGSSetGStateAttribute(void*,char*,void*); void *graphicsPort; NSString *shadowValuesString = [NSString stringWithFormat: @"{ Style = Shadow; Height = %d; Radius = %d; Azimuth = %d; Ka = %f; }", height, radius, azimuth, ka]; [NSGraphicsContext saveGraphicsState]; shadowValues = CGSReadObjectFromCString((char *) [shadowValuesString cString]); graphicsPort = [[NSGraphicsContext currentContext] graphicsPort]; CGSSetGStateAttribute(graphicsPort, CGSUniqueCString("Style"), shadowValues); } - (void) hideShadow { extern void *CGSReleaseGenericObj(void*); [NSGraphicsContext restoreGraphicsState]; CGSReleaseGenericObj(shadowValues); } @end