forked from glebd/bwtoolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BWSelectableToolbarHelper.m
84 lines (63 loc) · 2.35 KB
/
BWSelectableToolbarHelper.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// BWSelectableToolbarHelper.m
// BWToolkit
//
// Created by Brandon Walkin (www.brandonwalkin.com)
// All code is provided under the New BSD license.
//
#import "BWSelectableToolbarHelper.h"
@implementation BWSelectableToolbarHelper
@synthesize contentViewsByIdentifier;
@synthesize windowSizesByIdentifier;
@synthesize selectedIdentifier;
@synthesize oldWindowTitle;
@synthesize initialIBWindowSize;
@synthesize isPreferencesToolbar;
- (id)init
{
if(self = [super init])
{
if (contentViewsByIdentifier == nil)
contentViewsByIdentifier = [[NSMutableDictionary alloc] init];
if (windowSizesByIdentifier == nil)
windowSizesByIdentifier = [[NSMutableDictionary alloc] init];
if (selectedIdentifier == nil)
selectedIdentifier = [[NSString alloc] init];
if (oldWindowTitle == nil)
oldWindowTitle = [[NSString alloc] init];
}
return self;
}
- (id)initWithCoder:(NSCoder *)decoder;
{
if ((self = [super init]) != nil)
{
[self setContentViewsByIdentifier:[decoder decodeObjectForKey:@"BWSTHContentViewsByIdentifier"]];
NSData *data = [decoder decodeObjectForKey:@"BWSTHWindowSizesByIdentifier"];
[self setWindowSizesByIdentifier:[NSUnarchiver unarchiveObjectWithData:data]];
[self setSelectedIdentifier:[decoder decodeObjectForKey:@"BWSTHSelectedIdentifier"]];
[self setOldWindowTitle:[decoder decodeObjectForKey:@"BWSTHOldWindowTitle"]];
[self setInitialIBWindowSize:[decoder decodeSizeForKey:@"BWSTHInitialIBWindowSize"]];
[self setIsPreferencesToolbar:[decoder decodeBoolForKey:@"BWSTHIsPreferencesToolbar"]];
}
return self;
}
- (void)encodeWithCoder:(NSCoder*)coder
{
[coder encodeObject:[self contentViewsByIdentifier] forKey:@"BWSTHContentViewsByIdentifier"];
NSData *data = [NSArchiver archivedDataWithRootObject:[self windowSizesByIdentifier]];
[coder encodeObject:data forKey:@"BWSTHWindowSizesByIdentifier"];
[coder encodeObject:[self selectedIdentifier] forKey:@"BWSTHSelectedIdentifier"];
[coder encodeObject:[self oldWindowTitle] forKey:@"BWSTHOldWindowTitle"];
[coder encodeSize:[self initialIBWindowSize] forKey:@"BWSTHInitialIBWindowSize"];
[coder encodeBool:[self isPreferencesToolbar] forKey:@"BWSTHIsPreferencesToolbar"];
}
- (void)dealloc
{
[contentViewsByIdentifier release];
[windowSizesByIdentifier release];
[selectedIdentifier release];
[oldWindowTitle release];
[super dealloc];
}
@end