X-Git-Url: http://git.ithinksw.org/ITKit.git/blobdiff_plain/22a86e1af594d77fde7f056cf5152478f14dafbf..d7b837d03d47a5ffa60975081a2a7598edc839e3:/ITTextField.m?ds=sidebyside diff --git a/ITTextField.m b/ITTextField.m index 3ab85b7..3ccab70 100755 --- a/ITTextField.m +++ b/ITTextField.m @@ -1,5 +1,6 @@ #import "ITTextField.h" -#import +#import "ITTextFieldCell.h" +#import #import "ITCoreGraphicsHacks.h" @@ -10,81 +11,25 @@ @implementation ITTextField + /*************************************************************************/ #pragma mark - #pragma mark INITIALIZATION METHODS /*************************************************************************/ -- (id)initWithFrame:(NSRect)frameRect ++ (void)initialize { - if ( ( self = [super initWithFrame:frameRect] ) ) { - castsShadow = NO; - shadowElevation = 45.0; - shadowAzimuth = 90.0; - shadowAmbient = 0.15; - shadowHeight = 1.00; - shadowRadius = 4.00; - shadowSaturation = 1.0; + if ( self == [ITTextField class] ) { + [self setCellClass:[ITTextFieldCell class]]; } - - return self; } -- (id)initWithCoder:(NSCoder *)coder ++ (Class)cellClass { - if ( ( self = [super initWithCoder:coder] ) ) { - castsShadow = NO; - shadowElevation = 45.0; - shadowAzimuth = 90.0; - shadowAmbient = 0.15; - shadowHeight = 1.00; - shadowRadius = 4.00; - shadowSaturation = 1.0; - } - - return self; + return [ITTextFieldCell class]; } -/*************************************************************************/ -#pragma mark - -#pragma mark DRAWING METHODS -/*************************************************************************/ - -- (void)drawRect:(NSRect)rect -{ - 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 drawRect:rect]; - - - if ( castsShadow ) { - // Restore the old context - [NSGraphicsContext restoreGraphicsState]; - CGStyleRelease(style); - } -} - - - /*************************************************************************/ #pragma mark - #pragma mark ACCESSOR METHODS @@ -92,79 +37,72 @@ - (BOOL)castsShadow; { - return castsShadow; + return [[self cell] castsShadow]; } - (void)setCastsShadow:(BOOL)newSetting; { - castsShadow = newSetting; - [self setNeedsDisplay:YES]; + [[self cell] setCastsShadow:newSetting]; } - (float)shadowElevation; { - return shadowElevation; + return [[self cell] shadowElevation]; } - (void)setShadowElevation:(float)newElevation; { - shadowElevation = newElevation; - [self setNeedsDisplay:YES]; + [[self cell] setShadowElevation:newElevation]; } - (float)shadowAzimuth; { - return shadowAzimuth; + return [[self cell] shadowAzimuth]; } - (void)setShadowAzimuth:(float)newAzimuth; { - shadowAzimuth = newAzimuth; - [self setNeedsDisplay:YES]; + [[self cell] setShadowAzimuth:newAzimuth]; } - (float)shadowAmbient; { - return shadowAmbient; + return [[self cell] shadowAmbient]; } - (void)setShadowAmbient:(float)newAmbient; { - shadowAmbient = newAmbient; - [self setNeedsDisplay:YES]; + [[self cell] setShadowAmbient:newAmbient]; } - (float)shadowHeight; { - return shadowHeight; + return [[self cell] shadowHeight]; } - (void)setShadowHeight:(float)newHeight; { - shadowHeight = newHeight; - [self setNeedsDisplay:YES]; + [[self cell] setShadowHeight:newHeight]; } - (float)shadowRadius; { - return shadowRadius; + return [[self cell] shadowRadius]; } - (void)setShadowRadius:(float)newRadius; { - shadowRadius = newRadius; - [self setNeedsDisplay:YES]; + [[self cell] setShadowRadius:newRadius]; } - (float)shadowSaturation; { - return shadowSaturation; + return [[self cell] shadowSaturation]; } - (void)setShadowSaturation:(float)newSaturation; { - shadowSaturation = newSaturation; - [self setNeedsDisplay:YES]; + [[self cell] setShadowSaturation:newSaturation]; }