-
Notifications
You must be signed in to change notification settings - Fork 0
/
CTContainer.extern.m
50 lines (48 loc) · 1.1 KB
/
CTContainer.extern.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
// ------------- CocoaView ----------------------------
@interface CocoaView : NSView {
@private
int r;
int g;
int b;
float alpha;
}
-(void) setBackgroundColor:(int) ra:(int) ga:(int) ba:(float) newAlpha;
@end
@implementation CocoaView
- (BOOL)isFlipped {
return YES;
}
- (id)init {
if ((self = [super init])) {
r = 100;
g = 100;
b = 100;
alpha = 1.0;
}
return self;
}
- (id)initWithFrame:(NSRect)frame {
if ((self = [super initWithFrame:frame])) {
r = 100;
g = 100;
b = 100;
}
return self;
}
- (void)dealloc {
[super dealloc];
}
- (void)drawRect:(NSRect)dirtyRect {
// Fill in background Color
CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
CGContextSetRGBFillColor(context, r/255.0, g/255.0, b/255.0, alpha);
CGContextFillRect(context, NSRectToCGRect(dirtyRect));
}
-(void) setBackgroundColor:(int) ra:(int) ga:(int) ba :(float) newAlpha{
r = ra;
g = ga;
b = ba;
alpha = newAlpha;
[self setNeedsDisplay:YES];
}
@end