Added coding support for tags to CPView and nib2cib.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I
2008-09-18 22:47:15 -07:00
parent 7ebb457ff9
commit ae6e3f2c47
2 changed files with 23 additions and 0 deletions
+18
View File
@@ -88,6 +88,8 @@ var DOMElementPrototype = nil,
CPGraphicsContext _graphicsContext;
int _tag;
CGRect _frame;
CGRect _bounds;
CGAffineTransform _boundsTransform;
@@ -174,6 +176,8 @@ var DOMElementPrototype = nil,
_subviews = [];
_tag = -1;
_frame = _CGRectMakeCopy(aFrame);
_bounds = _CGRectMake(0.0, 0.0, width, height);
@@ -464,6 +468,11 @@ var DOMElementPrototype = nil,
return enclosingMenuItem;*/
}
- (int)tag
{
return _tag;
}
/*
Returns whether the view is flipped.
@return <code>YES</code> if the view is flipped. <code>NO</code>, otherwise.
@@ -1665,6 +1674,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
CPViewOpacityKey = @"CPViewOpacityKey",
CPViewSubviewsKey = @"CPViewSubviewsKey",
CPViewSuperviewKey = @"CPViewSuperviewKey",
CPViewTagKey = @"CPViewTagKey",
CPViewWindowKey = @"CPViewWindowKey";
@implementation CPView (CPCoding)
@@ -1692,6 +1702,11 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
if (self)
{
_tag = -1;
if ([aCoder containsValueForKey:CPViewTagKey])
_tag = [aCoder decodeIntForKey:CPViewTagKey];
_window = [aCoder decodeObjectForKey:CPViewWindowKey];
_subviews = [aCoder decodeObjectForKey:CPViewSubviewsKey];
_superview = [aCoder decodeObjectForKey:CPViewSuperviewKey];
@@ -1736,6 +1751,9 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
{
[super encodeWithCoder:aCoder];
if (_tag != -1)
[aCoder encodeInt:_tag forKey:CPViewTagKey];
[aCoder encodeRect:_frame forKey:CPViewFrameKey];
[aCoder encodeRect:_bounds forKey:CPViewBoundsKey];
+5
View File
@@ -41,6 +41,11 @@ import <AppKit/CPView.j>
if (self)
{
_tag = -1;
if([aCoder containsValueForKey:@"NSTag"])
_tag = [aCoder decodeIntForKey:@"NSTag"];
_bounds = CGRectMake(0.0, 0.0, CGRectGetWidth(_frame), CGRectGetHeight(_frame));
_window = [aCoder decodeObjectForKey:@"NSWindow"];