-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBlackView.m
57 lines (44 loc) · 1.06 KB
/
BlackView.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
//
// BlackView.m
// Isolator
//
// Created by Ben Willmore on 08/02/2007.
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
#include "Cocoa/Cocoa.h"
#import "BlackView.h"
@implementation BlackView
-(id) initWithFrame:(NSRect)frameRect
{
[super initWithFrame:(NSRect)frameRect];
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
if (![defaults objectForKey:@"BackgroundColor"]) {
NSData *theData=[NSArchiver archivedDataWithRootObject:[NSColor blackColor]];
[[NSUserDefaults standardUserDefaults] setObject:theData forKey:@"BackgroundColor"];
}
[self setColor];
return self;
}
-(void) drawRect:(NSRect)theRect
{
[bgColor set];
NSRectFill(theRect);
}
-(void) setColor
{
if (bgColor)
[bgColor release];
NSData *theData=[[NSUserDefaults standardUserDefaults] dataForKey:@"BackgroundColor"];
if (theData)
bgColor = (NSColor *)[NSUnarchiver unarchiveObjectWithData:theData];
else
bgColor = [NSColor blackColor];
[bgColor retain];
[self setNeedsDisplay:YES];
}
-(void) dealloc
{
[bgColor release];
[super dealloc];
}
@end