-
-/*************************************************************************/
-#pragma mark -
-#pragma mark DRAWING METHODS
-/*************************************************************************/
-
-- (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView
-{
- CGSGenericObj style = nil;
- CGShadowStyle shadow;
-
- if ( castsShadow ) {
-// Create the shadow style to use for drawing the string
- shadow.version = 0;
- shadow.elevation = shadowElevation;
- shadow.azimuth = shadowAzimuth;
- shadow.ambient = shadowAmbient;
- shadow.height = shadowHeight;
- shadow.radius = shadowRadius;
- shadow.saturation = shadowSaturation;
- style = CGStyleCreateShadow(&shadow);
-
- // Set the context for drawing the string
- [NSGraphicsContext saveGraphicsState];
- CGContextSetStyle([[NSGraphicsContext currentContext] graphicsPort], style);
- }
-
- // Draw the string
- [super drawWithFrame:rect inView:controlView];
-
-
- if ( castsShadow ) {
- // Restore the old context
- [NSGraphicsContext restoreGraphicsState];
- CGStyleRelease(style);
- }
+- (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView {
+ NSShadow *shadow;
+
+ if (castsShadow) {
+ CGFloat height = ((2.0*tan((M_PI/360.0)*(shadowAzimuth-180.0)))*shadowHeight)/(1.0+pow(tan((M_PI/360.0)*(shadowAzimuth-180.0)),2.0));
+ CGFloat width = sqrt(pow(shadowHeight, 2.0)-pow(height, 2.0));
+
+ shadow = [[NSShadow alloc] init];
+ [shadow setShadowColor:[[NSColor blackColor] colorWithAlphaComponent:(1.0 - shadowAmbient)]];
+ [shadow setShadowOffset:NSMakeSize(width, height)];
+ [shadow setShadowBlurRadius:shadowRadius];
+
+ [NSGraphicsContext saveGraphicsState];
+ [shadow set];
+ }
+
+ // Draw the string
+ [super drawWithFrame:rect inView:controlView];
+
+ if (castsShadow) {
+ // Restore the old context
+ [NSGraphicsContext restoreGraphicsState];
+ [shadow release];
+ }