1 #import "ITTextFieldCell.h"
2 #import "ITCoreGraphicsHacks.h"
3 #import <ApplicationServices/ApplicationServices.h>
5 @implementation ITTextFieldCell
7 - (id)initTextCell:(NSString *)string {
8 if ((self = [super initTextCell:string])) {
10 shadowElevation = 45.0;
15 shadowSaturation = 1.0;
20 - (id)initWithCoder:(NSCoder *)coder {
21 if ((self = [super initWithCoder:coder])) {
23 shadowElevation = 45.0;
28 shadowSaturation = 1.0;
33 - (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView {
34 CGSGenericObj style = nil;
38 // Create the shadow style to use for drawing the string
40 shadow.elevation = shadowElevation;
41 shadow.azimuth = shadowAzimuth;
42 shadow.ambient = shadowAmbient;
43 shadow.height = shadowHeight;
44 shadow.radius = shadowRadius;
45 shadow.saturation = shadowSaturation;
46 style = CGStyleCreateShadow(&shadow);
48 // Set the context for drawing the string
49 [NSGraphicsContext saveGraphicsState];
50 CGContextSetStyle([[NSGraphicsContext currentContext] graphicsPort], style);
54 [super drawWithFrame:rect inView:controlView];
57 // Restore the old context
58 [NSGraphicsContext restoreGraphicsState];
59 CGStyleRelease(style);
67 - (void)setCastsShadow:(BOOL)newSetting {
68 castsShadow = newSetting;
69 [[self controlView] setNeedsDisplay:YES];
72 - (float)shadowElevation {
73 return shadowElevation;
76 - (void)setShadowElevation:(float)newElevation {
77 shadowElevation = newElevation;
78 [[self controlView] setNeedsDisplay:YES];
81 - (float)shadowAzimuth {
85 - (void)setShadowAzimuth:(float)newAzimuth {
86 shadowAzimuth = newAzimuth;
87 [[self controlView] setNeedsDisplay:YES];
90 - (float)shadowAmbient {
94 - (void)setShadowAmbient:(float)newAmbient {
95 shadowAmbient = newAmbient;
96 [[self controlView] setNeedsDisplay:YES];
99 - (float)shadowHeight {
103 - (void)setShadowHeight:(float)newHeight {
104 shadowHeight = newHeight;
105 [[self controlView] setNeedsDisplay:YES];
108 - (float)shadowRadius {
112 - (void)setShadowRadius:(float)newRadius {
113 shadowRadius = newRadius;
114 [[self controlView] setNeedsDisplay:YES];
117 - (float)shadowSaturation {
118 return shadowSaturation;
121 - (void)setShadowSaturation:(float)newSaturation {
122 shadowSaturation = newSaturation;
123 [[self controlView] setNeedsDisplay:YES];