-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathQSPasteboardAccessoryCell.m
56 lines (39 loc) · 1.55 KB
/
QSPasteboardAccessoryCell.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
#import "QSPasteboardAccessoryCell.h"
@implementation QSPasteboardAccessoryCell
@synthesize textColor = _textColor;
- (id)initImageCell:(NSImage *)anImage{
if (self=[super initImageCell:anImage]){
}
return self;
}
- (void)dealloc{
[self setTextColor:nil];
}
- (NSColor *)textColor {
@synchronized(self) {
return _textColor;
}
}
- (void)setTextColor:(NSColor *)newTextColor {
@synchronized(self) {
_textColor = newTextColor;
[[self controlView] setNeedsDisplay:YES];
}
}
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView{
if (![self isHighlighted]){
NSBezierPath *roundRect=[NSBezierPath bezierPath];
[roundRect appendBezierPathWithRoundedRectangle:NSInsetRect(cellFrame,1,1) withRadius:NSWidth(cellFrame)/4];
[[[self textColor] colorWithAlphaComponent:0.1]set];
[roundRect fill];
}
if ([self objectValue]){
NSUInteger rank=[[self objectValue] unsignedIntegerValue];
NSDictionary *attributes=[NSDictionary dictionaryWithObjectsAndKeys:[self textColor] ? [self textColor] : [NSColor textColor],NSForegroundColorAttributeName,[self font] ? [self font] : [NSFont systemFontOfSize:11], NSFontAttributeName,nil];
NSString *string=[NSString stringWithFormat:@"%lu",(unsigned long)rank];
NSSize textSize=[string sizeWithAttributes:attributes];
NSRect drawRect=centerRectInRect(rectFromSize(textSize),cellFrame);
[string drawInRect:drawRect withAttributes:attributes];
}
}
@end