Huge audit of ITKit, mostly everything has been updated to current coding
[ITKit.git] / ITTableCornerView.m
old mode 100755 (executable)
new mode 100644 (file)
index 256c808..2f231d2
@@ -1,39 +1,57 @@
-//
-//  ITTableCornerView.m
-//  
-//
-//  Created by Joseph Spiros on Wed Jan 22 2003.
-//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
-//
-
 #import "ITTableCornerView.h"
 
+@interface ITTableCornerView (Private)
+
+- (id)initWithFrame:(NSRect)frame cellClass:(Class)cellClass;
+
+@end
+
 @implementation ITTableCornerView
 
 - (id)initWithFrame:(NSRect)frame {
-    self = [super initWithFrame:frame];
-    if (self) {
-        headerCell = [[NSTableHeaderCell alloc] init];
-    }
-    return self;
+       return [self initWithFrame:frame cellClass:[NSTableHeaderCell class]];
+}
+
+- (id)initWithFrame:(NSRect)frame cellClass:(Class)cellClass {
+       if ((self = [super initWithFrame:frame])) {
+               headerCell = [[cellClass alloc] init];
+               [self setPullsDown:YES];
+       }
+       return self;
 }
 
 - (void)drawRect:(NSRect)rect {
-    rect.origin.y = 0;
-    rect.size.height = 17;
-    rect.size.width += 1;
-    
-    [headerCell setState: ([[self cell] isHighlighted]) ? NSOnState : NSOffState];
-    [headerCell drawWithFrame:rect inView:nil];
-    
-    if ([self image]) {
-        [[self image] drawAtPoint:rect.origin fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
-    }
+       NSImage *drawImage;
+
+       rect.origin.y = 0;
+       rect.size.height = 17;
+       rect.size.width += 1;
+
+       [headerCell setState:([[self cell] isHighlighted] ? NSOnState : NSOffState)];
+       [headerCell drawWithFrame:rect inView:nil];
+
+       if ((drawImage = [self image])) {
+               BOOL oldFlipped = [drawImage isFlipped];
+               [drawImage setFlipped:YES];
+               [drawImage drawAtPoint:rect.origin fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
+               [drawImage setFlipped:oldFlipped];
+       }
+}
+
+- (void)setImage:(NSImage *)anImage {
+       [super setImage:anImage];
+       [image autorelease];
+       image = [anImage copy];
+}
+
+- (NSImage *)image {
+       return (image ? image : [super image]);
 }
 
 - (void)dealloc {
-    [headerCell release];
-    [super dealloc];
+       [image release];
+       [headerCell release];
+       [super dealloc];
 }
 
 @end
\ No newline at end of file