Huge audit of ITKit, mostly everything has been updated to current coding
[ITKit.git] / ITTextField.m
old mode 100755 (executable)
new mode 100644 (file)
index 3ab85b7..841d6c8
 #import "ITTextField.h"
-#import <CoreGraphics/CoreGraphics.h>
-#import "ITCoreGraphicsHacks.h"
-
-
-/*************************************************************************/
-#pragma mark -
-#pragma mark IMPLEMENTATION
-/*************************************************************************/
+#import "ITTextFieldCell.h"
 
 @implementation ITTextField
 
-/*************************************************************************/
-#pragma mark -
-#pragma mark INITIALIZATION METHODS
-/*************************************************************************/
-
-- (id)initWithFrame:(NSRect)frameRect
-{
-    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;
-    }
-
-    return self;
++ (void)initialize {
+       if (self == [ITTextField class]) {
+               [self setCellClass:[ITTextFieldCell class]];
+       }
 }
 
-- (id)initWithCoder:(NSCoder *)coder
-{
-    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;
++ (Class)cellClass {
+       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);
-    }
+- (BOOL)castsShadow {
+       return [[self cell] castsShadow];
 }
 
-
-
-/*************************************************************************/
-#pragma mark -
-#pragma mark ACCESSOR METHODS
-/*************************************************************************/
-
-- (BOOL)castsShadow;
-{
-    return castsShadow;
+- (void)setCastsShadow:(BOOL)newSetting {
+       [[self cell] setCastsShadow:newSetting];
 }
 
-- (void)setCastsShadow:(BOOL)newSetting;
-{
-    castsShadow = newSetting;
-    [self setNeedsDisplay:YES];
+- (float)shadowElevation {
+       return [[self cell] shadowElevation];
 }
 
-- (float)shadowElevation;
-{
-    return shadowElevation;
+- (void)setShadowElevation:(float)newElevation {
+       [[self cell] setShadowElevation:newElevation];
 }
 
-- (void)setShadowElevation:(float)newElevation;
-{
-    shadowElevation = newElevation;
-    [self setNeedsDisplay:YES];
+- (float)shadowAzimuth {
+       return [[self cell] shadowAzimuth];
 }
 
-- (float)shadowAzimuth;
-{
-    return shadowAzimuth;
+- (void)setShadowAzimuth:(float)newAzimuth {
+       [[self cell] setShadowAzimuth:newAzimuth];
 }
 
-- (void)setShadowAzimuth:(float)newAzimuth;
-{
-    shadowAzimuth = newAzimuth;
-    [self setNeedsDisplay:YES];
+- (float)shadowAmbient {
+       return [[self cell] shadowAmbient];
 }
 
-- (float)shadowAmbient;
-{
-    return shadowAmbient;
+- (void)setShadowAmbient:(float)newAmbient {
+       [[self cell] setShadowAmbient:newAmbient];
 }
 
-- (void)setShadowAmbient:(float)newAmbient;
-{
-    shadowAmbient = newAmbient;
-    [self setNeedsDisplay:YES];
+- (float)shadowHeight {
+       return [[self cell] shadowHeight];
 }
 
-- (float)shadowHeight;
-{
-    return shadowHeight;
+- (void)setShadowHeight:(float)newHeight {
+       [[self cell] setShadowHeight:newHeight];
 }
 
-- (void)setShadowHeight:(float)newHeight;
-{
-    shadowHeight = newHeight;
-    [self setNeedsDisplay:YES];
+- (float)shadowRadius {
+       return [[self cell] shadowRadius];
 }
 
-- (float)shadowRadius;
-{
-    return shadowRadius;
+- (void)setShadowRadius:(float)newRadius {
+       [[self cell] setShadowRadius:newRadius];
 }
 
-- (void)setShadowRadius:(float)newRadius;
-{
-    shadowRadius = newRadius;
-    [self setNeedsDisplay:YES];
+- (float)shadowSaturation {
+       return [[self cell] shadowSaturation];
 }
 
-- (float)shadowSaturation;
-{
-    return shadowSaturation;
+- (void)setShadowSaturation:(float)newSaturation {
+       [[self cell] setShadowSaturation:newSaturation];
 }
 
-- (void)setShadowSaturation:(float)newSaturation;
-{
-    shadowSaturation = newSaturation;
-    [self setNeedsDisplay:YES];
-}
-
-
-@end
+@end
\ No newline at end of file