-
Notifications
You must be signed in to change notification settings - Fork 36
/
IGKSometimesCenteredTextCell.m
73 lines (53 loc) · 1.73 KB
/
IGKSometimesCenteredTextCell.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// IGKSometimesCenteredTextCell.m
// Ingredients
//
// Created by Alex Gordon on 04/03/2010.
// Written in 2010 by Fileability.
//
#import "IGKSometimesCenteredTextCell.h"
@implementation IGKStrikethroughTextCell
@synthesize hasStrikethrough;
+ (void)drawStrikethroughInRect:(NSRect)rect
{
[[NSColor redColor] set];
rect.origin.y = rect.origin.y + floor(rect.size.height / 2.0) + 2;
rect.size.height = 1.0;
NSRectFillUsingOperation(rect, NSCompositeSourceOver);
}
@end
@implementation IGKSometimesCenteredTextCell
/*
- (NSRect)titleRectForBounds:(NSRect)theRect {
NSRect titleFrame = [super titleRectForBounds:theRect];
NSSize titleSize = [[self attributedStringValue] size];
titleFrame.origin.y += [self tag];
return titleFrame;
}
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
NSRect titleRect = [self titleRectForBounds:cellFrame];
[[self attributedStringValue] drawInRect:titleRect];
}
*/
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
cellFrame.origin.y += [self tag];
[super drawWithFrame:cellFrame inView:controlView];
if (hasStrikethrough)
[[self class] drawStrikethroughInRect:cellFrame];
}
@end
@implementation IGKSometimesCenteredTextCell2
- (NSRect)titleRectForBounds:(NSRect)theRect {
NSRect titleFrame = [super titleRectForBounds:theRect];
NSSize titleSize = [[self attributedStringValue] size];
titleFrame.origin.y += [self tag];
return titleFrame;
}
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
NSRect titleRect = [self titleRectForBounds:cellFrame];
[[self attributedStringValue] drawInRect:titleRect];
if (hasStrikethrough)
[[self class] drawStrikethroughInRect:cellFrame];
}
@end