1 #import "ITImageCell.h"
2 #import <ApplicationServices/ApplicationServices.h>
3 #import "ITCoreGraphicsHacks.h"
6 @implementation ITImageCell
9 - (id)initImageCell:(NSImage *)image
11 if ( (self = [super initImageCell:image]) ) {
12 _scalesSmoothly = YES;
14 shadowElevation = 45.0;
19 shadowSaturation = 1.0;
27 if ( (self = [super init]) ) {
28 _scalesSmoothly = YES;
30 shadowElevation = 45.0;
35 shadowSaturation = 1.0;
40 - (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView
42 CGSGenericObj style = nil;
45 if ( _scalesSmoothly || castsShadow ) {
46 [NSGraphicsContext saveGraphicsState];
49 if ( _scalesSmoothly ) {
50 CGContextSetInterpolationQuality([[NSGraphicsContext currentContext] graphicsPort], kCGInterpolationHigh);
54 // Create the shadow style to use for drawing the string
56 shadow.elevation = shadowElevation;
57 shadow.azimuth = shadowAzimuth;
58 shadow.ambient = shadowAmbient;
59 shadow.height = shadowHeight;
60 shadow.radius = shadowRadius;
61 shadow.saturation = shadowSaturation;
62 style = CGStyleCreateShadow(&shadow);
63 CGContextSetStyle([[NSGraphicsContext currentContext] graphicsPort], style);
66 [super drawWithFrame:rect inView:controlView];
68 if ( _scalesSmoothly || castsShadow ) {
69 [NSGraphicsContext restoreGraphicsState];
73 CGStyleRelease(style);
77 - (BOOL)scalesSmoothly
79 return _scalesSmoothly;
82 - (void)setScalesSmoothly:(BOOL)flag
84 _scalesSmoothly = flag;
85 [[self controlView] setNeedsDisplay:YES];
93 - (void)setCastsShadow:(BOOL)newSetting;
95 castsShadow = newSetting;
96 [[self controlView] setNeedsDisplay:YES];
99 - (float)shadowElevation;
101 return shadowElevation;
104 - (void)setShadowElevation:(float)newElevation;
106 shadowElevation = newElevation;
107 [[self controlView] setNeedsDisplay:YES];
110 - (float)shadowAzimuth;
112 return shadowAzimuth;
115 - (void)setShadowAzimuth:(float)newAzimuth;
117 shadowAzimuth = newAzimuth;
118 [[self controlView] setNeedsDisplay:YES];
121 - (float)shadowAmbient;
123 return shadowAmbient;
126 - (void)setShadowAmbient:(float)newAmbient;
128 shadowAmbient = newAmbient;
129 [[self controlView] setNeedsDisplay:YES];
132 - (float)shadowHeight;
137 - (void)setShadowHeight:(float)newHeight;
139 shadowHeight = newHeight;
140 [[self controlView] setNeedsDisplay:YES];
143 - (float)shadowRadius;
148 - (void)setShadowRadius:(float)newRadius;
150 shadowRadius = newRadius;
151 [[self controlView] setNeedsDisplay:YES];
154 - (float)shadowSaturation;
156 return shadowSaturation;
159 - (void)setShadowSaturation:(float)newSaturation;
161 shadowSaturation = newSaturation;
162 [[self controlView] setNeedsDisplay:YES];