-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathITTableCornerView.m
57 lines (43 loc) · 1.22 KB
/
ITTableCornerView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#import "ITTableCornerView.h"
@interface ITTableCornerView (Private)
- (id)initWithFrame:(NSRect)frame cellClass:(Class)cellClass;
@end
@implementation ITTableCornerView
- (id)initWithFrame:(NSRect)frame {
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 {
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 {
[image release];
[headerCell release];
[super dealloc];
}
@end