Removing the use of private CoreGraphics APIs to draw shadows, and replacing with...
[ITKit.git] / ITTableCornerView.m
1 #import "ITTableCornerView.h"
2
3 @interface ITTableCornerView (Private)
4
5 - (id)initWithFrame:(NSRect)frame cellClass:(Class)cellClass;
6
7 @end
8
9 @implementation ITTableCornerView
10
11 - (id)initWithFrame:(NSRect)frame {
12         return [self initWithFrame:frame cellClass:[NSTableHeaderCell class]];
13 }
14
15 - (id)initWithFrame:(NSRect)frame cellClass:(Class)cellClass {
16         if ((self = [super initWithFrame:frame])) {
17                 headerCell = [[cellClass alloc] init];
18                 [self setPullsDown:YES];
19         }
20         return self;
21 }
22
23 - (void)drawRect:(NSRect)rect {
24         NSImage *drawImage;
25
26         rect.origin.y = 0;
27         rect.size.height = 17;
28         rect.size.width += 1;
29
30         [headerCell setState:([[self cell] isHighlighted] ? NSOnState : NSOffState)];
31         [headerCell drawWithFrame:rect inView:nil];
32
33         if ((drawImage = [self image])) {
34                 BOOL oldFlipped = [drawImage isFlipped];
35                 [drawImage setFlipped:YES];
36                 [drawImage drawAtPoint:rect.origin fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
37                 [drawImage setFlipped:oldFlipped];
38         }
39 }
40
41 - (void)setImage:(NSImage *)anImage {
42         [super setImage:anImage];
43         [image autorelease];
44         image = [anImage copy];
45 }
46
47 - (NSImage *)image {
48         return (image ? image : [super image]);
49 }
50
51 - (void)dealloc {
52         [image release];
53         [headerCell release];
54         [super dealloc];
55 }
56
57 @end