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
|
//
// SelectBoxLayer.m
// TikZiT
//
// Created by Aleks Kissinger on 14/06/2010.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "SelectBoxLayer.h"
@implementation SelectBoxLayer
@synthesize active;
- (id)init {
if (!(self = [super init])) return nil;
box = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f);
active = NO;
return self;
}
- (void)setSelectBox:(NSRect)r {
box = NSRectToCGRect(r);
}
- (NSRect)selectBox {
return NSRectFromCGRect(box);
}
- (void)drawInContext:(CGContextRef)context {
if (active) {
CGContextAddRect(context, box);
CGContextSetRGBStrokeColor(context, 0.6, 0.6, 0.6, 1);
CGContextSetRGBFillColor(context, 0.8, 0.8, 0.8, 0.2);
CGContextSetLineWidth(context, 1);
CGContextSetShouldAntialias(context, NO);
CGContextDrawPath(context, kCGPathFillStroke);
}
}
+ (SelectBoxLayer*)layer {
return [[SelectBoxLayer alloc] init];
}
@end
|