X-Git-Url: http://git.ithinksw.org/ITKit.git/blobdiff_plain/78553c25bacdbd190fd14591420cf4f7fa578617..3263678eef57c78d7017185eaa2efb9e644c7f29:/ITTableCornerView.m?ds=inline diff --git a/ITTableCornerView.m b/ITTableCornerView.m old mode 100755 new mode 100644 index 4f90316..2f231d2 --- a/ITTableCornerView.m +++ b/ITTableCornerView.m @@ -1,31 +1,57 @@ #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