1 #import "ITTextFieldCell.h"
2 #import <ApplicationServices/ApplicationServices.h>
3 #import "ITCoreGraphicsHacks.h"
6 /*************************************************************************/
8 #pragma mark IMPLEMENTATION
9 /*************************************************************************/
11 @implementation ITTextFieldCell
13 /*************************************************************************/
15 #pragma mark INITIALIZATION METHODS
16 /*************************************************************************/
18 - (id)initTextCell:(NSString *)string
20 if ( ( self = [super initTextCell:string] ) ) {
22 shadowElevation = 45.0;
27 shadowSaturation = 1.0;
33 - (id)initWithCoder:(NSCoder *)coder
35 if ( ( self = [super initWithCoder:coder] ) ) {
37 shadowElevation = 45.0;
42 shadowSaturation = 1.0;
49 /*************************************************************************/
51 #pragma mark DRAWING METHODS
52 /*************************************************************************/
54 - (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView
56 CGSGenericObj style = nil;
60 // Create the shadow style to use for drawing the string
62 shadow.elevation = shadowElevation;
63 shadow.azimuth = shadowAzimuth;
64 shadow.ambient = shadowAmbient;
65 shadow.height = shadowHeight;
66 shadow.radius = shadowRadius;
67 shadow.saturation = shadowSaturation;
68 style = CGStyleCreateShadow(&shadow);
70 // Set the context for drawing the string
71 [NSGraphicsContext saveGraphicsState];
72 CGContextSetStyle([[NSGraphicsContext currentContext] graphicsPort], style);
76 [super drawWithFrame:rect inView:controlView];
80 // Restore the old context
81 [NSGraphicsContext restoreGraphicsState];
82 CGStyleRelease(style);
88 /*************************************************************************/
90 #pragma mark ACCESSOR METHODS
91 /*************************************************************************/
98 - (void)setCastsShadow:(BOOL)newSetting;
100 castsShadow = newSetting;
101 [[self controlView] setNeedsDisplay:YES];
104 - (float)shadowElevation;
106 return shadowElevation;
109 - (void)setShadowElevation:(float)newElevation;
111 shadowElevation = newElevation;
112 [[self controlView] setNeedsDisplay:YES];
115 - (float)shadowAzimuth;
117 return shadowAzimuth;
120 - (void)setShadowAzimuth:(float)newAzimuth;
122 shadowAzimuth = newAzimuth;
123 [[self controlView] setNeedsDisplay:YES];
126 - (float)shadowAmbient;
128 return shadowAmbient;
131 - (void)setShadowAmbient:(float)newAmbient;
133 shadowAmbient = newAmbient;
134 [[self controlView] setNeedsDisplay:YES];
137 - (float)shadowHeight;
142 - (void)setShadowHeight:(float)newHeight;
144 shadowHeight = newHeight;
145 [[self controlView] setNeedsDisplay:YES];
148 - (float)shadowRadius;
153 - (void)setShadowRadius:(float)newRadius;
155 shadowRadius = newRadius;
156 [[self controlView] setNeedsDisplay:YES];
159 - (float)shadowSaturation;
161 return shadowSaturation;
164 - (void)setShadowSaturation:(float)newSaturation;
166 shadowSaturation = newSaturation;
167 [[self controlView] setNeedsDisplay:YES];