PageRenderTime 33ms CodeModel.GetById 27ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/CPBox+CPCoding.j

http://github.com/rheimbuch/YED
Unknown | 49 lines | 37 code | 12 blank | 0 comment | 0 complexity | 6cbe1b6478fd56ebd5ddb88975e60e26 MD5 | raw file
 1@import <AppKit/CPBox.j>
 2@import <Foundation/CPCoder.j>
 3
 4var CPBoxBorderTypeKey      = @"CPBoxBorderTypeKey",
 5    CPBoxBorderColorKey     = @"CPBoxBorderColorKey",
 6    CPBoxFillColorKey       = @"CPBoxFillColorKey",
 7    CPBoxCornerRadiusKey    = @"CPBoxCornerRadiusKey",
 8    CPBoxBorderWidthKey     = @"CPBoxBorderWidthKey",
 9    CPBoxContentMarginKey   = @"CPBoxContentMarginKey",
10    CPBoxContentViewKey     = @"CPBoxContentViewKey";
11
12@implementation CPBox (CPCoding)
13
14- (id)initWithCoder:(CPCoder)coder
15{
16    self = [super initWithCoder:coder];
17    if(self)
18    {
19        _borderType = [coder decodeObjectForKey:CPBoxBorderTypeKey];
20        
21        _borderColor = [coder decodeObjectForKey:CPBoxBorderColorKey];
22        _fillColor = [coder decodeObjectForKey:CPBoxFillColorKey];
23        
24        _cornerRadius = [coder decodeObjectForKey:CPBoxCornerRadiusKey];
25        _borderWidth = [coder decodeObjectForKey:CPBoxBorderWidthKey];
26        
27        _contentMargin = [coder decodeObjectForKey:CPBoxContentMarginKey];
28        _contentView = [coder decodeObjectForKey:CPBoxContentViewKey];
29    }
30    return self;
31}
32
33- (void)encodeWithCoder:(CPCoder)coder
34{
35    [super encodeWithCoder:coder];
36    
37    [coder encodeInt:_borderType forKey:CPBoxBorderTypeKey];
38    
39    [coder encodeObject:_borderColor forKey:CPBoxBorderColorKey];
40    [coder encodeObject:_fillColor forKey:CPBoxFillColorKey];
41    
42    [coder encodeFloat:_cornerRadius forKey:CPBoxCornerRadiusKey];
43    [coder encodeFloat:_borderWidth forKey:CPBoxBorderWidthKey];
44    
45    [coder encodeSize:_contentMargin forKey:CPBoxContentMarginKey];
46    [coder encodeObject:_contentView forKey:CPBoxContentViewKey];
47}
48
49@end