-
Notifications
You must be signed in to change notification settings - Fork 6
/
MKColorSwatchCell.m
38 lines (32 loc) · 1.09 KB
/
MKColorSwatchCell.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
//
// MKColorSwatchCell.m
// Color Picker
//
// Created by Mark Dodwell on 5/27/12.
// Copyright (c) 2012 mkdynamic. All rights reserved.
//
#import "MKColorSwatchCell.h"
@implementation MKColorSwatchCell
@synthesize color;
- (void)drawWithFrame:(NSRect)cellFrame
inView:(NSMatrix *)controlView
{
[super drawWithFrame:cellFrame inView:controlView];
if ([color isEqualTo:[NSColor clearColor]]) {
[[NSColor whiteColor] setFill];
NSRectFill(cellFrame);
NSBezierPath *line = [NSBezierPath bezierPath];
[line moveToPoint:NSMakePoint(cellFrame.size.width, cellFrame.origin.y)];
[line lineToPoint:NSMakePoint(cellFrame.origin.x, cellFrame.size.height)];
[line setLineWidth:1.5];
[[NSColor redColor] setStroke];
[[NSGraphicsContext currentContext] saveGraphicsState];
[[NSBezierPath bezierPathWithRect:cellFrame] setClip];
[line stroke];
[[NSGraphicsContext currentContext] restoreGraphicsState];
} else {
[color setFill];
NSRectFill(cellFrame);
}
}
@end