78 var DOMElementPrototype = nil,
80 BackgroundTrivialColor = 0,
81 BackgroundVerticalThreePartImage = 1,
82 BackgroundHorizontalThreePartImage = 2,
83 BackgroundNinePartImage = 3,
84 BackgroundTransparentColor = 4;
122 CGAffineTransform _boundsTransform;
123 CGAffineTransform _inverseBoundsTransform;
125 CPSet _registeredDraggedTypes;
126 CPArray _registeredDraggedTypesArray;
132 BOOL _postsFrameChangedNotifications;
133 BOOL _postsBoundsChangedNotifications;
134 BOOL _inhibitFrameAndBoundsChangedNotifications;
138 DOMElement _DOMElement;
139 DOMElement _DOMContentsElement;
144 unsigned _backgroundType;
152 BOOL _autoresizesSubviews;
153 unsigned _autoresizingMask;
159 BOOL _isInFullScreenMode;
161 _CPViewFullScreenModeState _fullScreenModeState;
165 JSObject _ephemeralSubviews;
170 JSObject _themeAttributes;
171 unsigned _themeState;
173 JSObject _ephemeralSubviewsForNames;
174 CPSet _ephereralSubviews;
180 unsigned _viewClassFlags;
184 Function _toolTipFunctionIn;
185 Function _toolTipFunctionOut;
186 BOOL _toolTipInstalled;
195 if (
self !== [
CPView class])
199 DOMElementPrototype = document.createElement(
"div");
201 var style = DOMElementPrototype.style;
203 style.overflow =
"hidden";
204 style.position =
"absolute";
205 style.visibility =
"visible";
212 - (void)_setupViewFlags
214 var theClass = [
self class],
215 classUID = [theClass UID];
221 if ([theClass instanceMethodForSelector:
@selector(drawRect:)] !== [
CPView instanceMethodForSelector:
@selector(drawRect:)])
224 if ([theClass instanceMethodForSelector:
@selector(layoutSubviews)] !== [
CPView instanceMethodForSelector:
@selector(layoutSubviews)])
233 - (void)_setupToolTipHandlers
235 _toolTipInstalled = NO;
236 _toolTipFunctionIn =
function(e) { [_CPToolTip scheduleToolTipForView:self]; }
237 _toolTipFunctionOut =
function(e) { [_CPToolTip invalidateCurrentToolTipIfNeeded]; };
240 + (
CPSet)keyPathsForValuesAffectingFrame
245 + (
CPSet)keyPathsForValuesAffectingBounds
264 - (id)initWithFrame:(CGRect)aFrame
270 var
width = _CGRectGetWidth(aFrame),
271 height = _CGRectGetHeight(aFrame);
274 _registeredDraggedTypes = [
CPSet set];
275 _registeredDraggedTypesArray = [];
279 _frame = _CGRectMakeCopy(aFrame);
280 _bounds = _CGRectMake(0.0, 0.0, width, height);
283 _autoresizesSubviews = YES;
284 _clipsToBounds = YES;
291 _DOMElement = DOMElementPrototype.cloneNode(
false);
293 CPDOMDisplayServerSetStyleLeftTop(_DOMElement, NULL, _CGRectGetMinX(aFrame), _CGRectGetMinY(aFrame));
294 CPDOMDisplayServerSetStyleSize(_DOMElement, width, height);
296 if (typeof(appkit_tag_dom_elements) !==
"undefined" && !!appkit_tag_dom_elements)
297 _DOMElement.setAttribute(
"data-cappuccino-view", [
self className]);
306 [
self _setupToolTipHandlers];
307 [
self _setupViewFlags];
309 [
self _loadThemeAttributes];
323 if (_toolTip == aToolTip)
326 if (aToolTip && ![aToolTip isKindOfClass:
CPString])
332 [
self _installToolTipEventHandlers];
334 [
self _uninstallToolTipEventHandlers];
341 - (void)_installToolTipEventHandlers
343 if (_toolTipInstalled)
347 if (_DOMElement.addEventListener)
349 _DOMElement.addEventListener(
"mouseover", _toolTipFunctionIn, NO);
350 _DOMElement.addEventListener(
"keypress", _toolTipFunctionOut, NO);
351 _DOMElement.addEventListener(
"mouseout", _toolTipFunctionOut, NO);
353 else if (_DOMElement.attachEvent)
355 _DOMElement.attachEvent(
"onmouseover", _toolTipFunctionIn);
356 _DOMElement.attachEvent(
"onkeypress", _toolTipFunctionOut);
357 _DOMElement.attachEvent(
"onmouseout", _toolTipFunctionOut);
361 _toolTipInstalled = YES;
368 - (void)_uninstallToolTipEventHandlers
370 if (!_toolTipInstalled)
374 if (_DOMElement.removeEventListener)
376 _DOMElement.removeEventListener(
"mouseover", _toolTipFunctionIn, NO);
377 _DOMElement.removeEventListener(
"keypress", _toolTipFunctionOut, NO);
378 _DOMElement.removeEventListener(
"mouseout", _toolTipFunctionOut, NO);
380 else if (_DOMElement.detachEvent)
382 _DOMElement.detachEvent(
"onmouseover", _toolTipFunctionIn);
383 _DOMElement.detachEvent(
"onkeypress", _toolTipFunctionOut);
384 _DOMElement.detachEvent(
"onmouseout", _toolTipFunctionOut);
388 _toolTipInstalled = NO;
406 return [_subviews copy];
423 [
self _insertSubview:aSubview atIndex:CPNotFound];
432 - (void)addSubview:(
CPView)aSubview positioned:(CPWindowOrderingMode)anOrderingMode relativeTo:(
CPView)anotherView
434 var index = anotherView ? [_subviews indexOfObjectIdenticalTo:anotherView] :
CPNotFound;
438 index = (anOrderingMode ===
CPWindowAbove) ? [_subviews count] : 0;
444 [
self _insertSubview:aSubview atIndex:index];
448 - (void)_insertSubview:(
CPView)aSubview atIndex:(
int)anIndex
450 if (aSubview ===
self)
454 var count = _subviews.length;
457 [[
self window] _dirtyKeyViewLoop];
460 if (aSubview._superview ==
self)
462 var index = [_subviews indexOfObjectIdenticalTo:aSubview];
465 if (index === anIndex || index === count - 1 && anIndex === count)
468 [_subviews removeObjectAtIndex:index];
471 CPDOMDisplayServerRemoveChild(_DOMElement, aSubview._DOMElement);
486 [aSubview _setWindow:_window];
492 aSubview._superview =
self;
495 if (anIndex ===
CPNotFound || anIndex >= count)
497 _subviews.push(aSubview);
501 CPDOMDisplayServerAppendChild(_DOMElement, aSubview._DOMElement);
506 _subviews.splice(anIndex, 0, aSubview);
510 CPDOMDisplayServerInsertBefore(_DOMElement, aSubview._DOMElement, _subviews[anIndex + 1]._DOMElement);
517 [
self didAddSubview:aSubview];
532 - (void)removeFromSuperview
538 [[
self window] _dirtyKeyViewLoop];
540 [_superview willRemoveSubview:self];
542 [_superview._subviews removeObject:self];
545 CPDOMDisplayServerRemoveChild(_superview._DOMElement, _DOMElement);
549 [
self _setWindow:nil];
559 if (aSubview._superview !==
self)
562 var index = [_subviews indexOfObjectIdenticalTo:aSubview];
566 [
self _insertSubview:aView atIndex:index];
572 [
CPException raise:CPInvalidArgumentException
reason:"newSubviews cannot be nil in -[CPView setSubviews:]"];
575 if ([_subviews
isEqual:newSubviews])
579 if ([_subviews count] === 0)
582 count = [newSubviews count];
584 for (; index < count; ++index)
585 [
self addSubview:newSubviews[index]];
591 if ([newSubviews count] === 0)
593 var count = [_subviews count];
596 [_subviews[count] removeFromSuperview];
604 [removedSubviews removeObjectsInArray:newSubviews];
605 [removedSubviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
610 [addedSubviews removeObjectsInArray:_subviews];
612 var addedSubview = nil,
613 addedSubviewEnumerator = [addedSubviews objectEnumerator];
615 while ((addedSubview = [addedSubviewEnumerator nextObject]) !== nil)
619 if ([_subviews
isEqual:newSubviews])
622 _subviews = [newSubviews copy];
626 count = [_subviews count];
628 for (; index < count; ++index)
630 var subview = _subviews[index];
632 CPDOMDisplayServerRemoveChild(_DOMElement, subview._DOMElement);
633 CPDOMDisplayServerAppendChild(_DOMElement, subview._DOMElement);
639 - (void)_setWindow:(
CPWindow)aWindow
641 if (_window === aWindow)
644 [[
self window] _dirtyKeyViewLoop];
647 if ([_window firstResponder] ===
self)
648 [_window makeFirstResponder:nil];
651 [
self viewWillMoveToWindow:aWindow];
655 if (_registeredDraggedTypes)
657 [_window _noteUnregisteredDraggedTypes:_registeredDraggedTypes];
658 [aWindow _noteRegisteredDraggedTypes:_registeredDraggedTypes];
663 var count = [_subviews count];
666 [_subviews[count] _setWindow:aWindow];
668 [
self viewDidMoveToWindow];
670 [[
self window] _dirtyKeyViewLoop];
685 }
while(view = [view superview])
693 - (void)viewDidMoveToSuperview
702 - (void)viewDidMoveToWindow
710 - (void)viewWillMoveToSuperview:(
CPView)aView
738 while (view && ![view isKindOfClass:[_CPMenuItemView
class]])
739 view = [view superview];
742 return view._menuItem;
754 - (void)setTag:(CPInteger)aTag
766 if ([
self tag] == aTag)
770 count = _subviews.length;
772 for (; index < count; ++index)
774 var view = [_subviews[index] viewWithTag:aTag];
799 - (void)setFrame:(CGRect)aFrame
801 if (_CGRectEqualToRect(_frame, aFrame))
804 _inhibitFrameAndBoundsChangedNotifications = YES;
809 _inhibitFrameAndBoundsChangedNotifications = NO;
811 if (_postsFrameChangedNotifications)
812 [CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
821 return _CGRectMakeCopy(_frame);
824 - (CGPoint)frameOrigin
826 return _CGPointMakeCopy(_frame.origin);
831 return _CGSizeMakeCopy(_frame.size);
841 - (void)setCenter:(CGPoint)aPoint
843 [
self setFrameOrigin:CGPointMake(aPoint.x - _frame.size.width / 2.0, aPoint.y - _frame.size.height / 2.0)];
852 return CGPointMake(_frame.size.width / 2.0 + _frame.origin.x, _frame.size.height / 2.0 + _frame.origin.y);
862 - (void)setFrameOrigin:(CGPoint)aPoint
864 var origin = _frame.origin;
866 if (!aPoint || _CGPointEqualToPoint(origin, aPoint))
872 if (_postsFrameChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications)
873 [CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
876 var transform = _superview ? _superview._boundsTransform : NULL;
878 CPDOMDisplayServerSetStyleLeftTop(_DOMElement, transform, origin.x, origin.y);
888 - (void)setFrameSize:(CGSize)aSize
890 var size = _frame.size;
892 if (!aSize || _CGSizeEqualToSize(size, aSize))
895 var oldSize = _CGSizeMakeCopy(size);
897 size.width = aSize.width;
898 size.height = aSize.height;
902 _bounds.size.width = aSize.width;
903 _bounds.size.height = aSize.height;
907 [_layer _owningViewBoundsChanged];
909 if (_autoresizesSubviews)
916 CPDOMDisplayServerSetStyleSize(_DOMElement, size.width, size.height);
918 if (_DOMContentsElement)
920 CPDOMDisplayServerSetSize(_DOMContentsElement, size.width, size.height);
921 CPDOMDisplayServerSetStyleSize(_DOMContentsElement, size.width, size.height);
924 if (_backgroundType !== BackgroundTrivialColor)
926 if (_backgroundType === BackgroundTransparentColor)
928 CPDOMDisplayServerSetStyleSize(_DOMImageParts[0], size.width, size.height);
932 var images = [[_backgroundColor patternImage] imageSlices],
935 if (_backgroundType === BackgroundVerticalThreePartImage)
937 var top = _DOMImageSizes[0] ? _DOMImageSizes[0].height : 0,
938 bottom = _DOMImageSizes[2] ? _DOMImageSizes[2].height : 0;
943 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], size.width, top);
946 if (_DOMImageSizes[1])
948 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], size.width, size.height - top - bottom);
953 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], size.width, bottom);
956 else if (_backgroundType === BackgroundHorizontalThreePartImage)
958 var left = _DOMImageSizes[0] ? _DOMImageSizes[0].width : 0,
959 right = _DOMImageSizes[2] ? _DOMImageSizes[2].width : 0;
964 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], left, size.height);
967 if (_DOMImageSizes[1])
969 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], size.width - left - right, size.height);
974 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], right, size.height);
977 else if (_backgroundType === BackgroundNinePartImage)
979 var left = _DOMImageSizes[0] ? _DOMImageSizes[0].width : 0,
980 right = _DOMImageSizes[2] ? _DOMImageSizes[2].width : 0,
981 top = _DOMImageSizes[0] ? _DOMImageSizes[0].height : 0,
982 bottom = _DOMImageSizes[6] ? _DOMImageSizes[6].height : 0,
983 width = size.width - left - right,
984 height = size.height - top - bottom;
986 if (_DOMImageSizes[0])
988 if (_DOMImageSizes[1])
990 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex],
width, top);
993 if (_DOMImageSizes[2])
995 if (_DOMImageSizes[3])
997 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], _DOMImageSizes[3].
width, height);
1000 if (_DOMImageSizes[4])
1002 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex],
width, height);
1005 if (_DOMImageSizes[5])
1007 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], _DOMImageSizes[5].
width, height);
1010 if (_DOMImageSizes[6])
1012 if (_DOMImageSizes[7])
1014 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex],
width, _DOMImageSizes[7].height);
1021 if (_postsFrameChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications)
1022 [CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
1030 - (void)setBounds:(CGRect)bounds
1032 if (_CGRectEqualToRect(_bounds, bounds))
1035 _inhibitFrameAndBoundsChangedNotifications = YES;
1040 _inhibitFrameAndBoundsChangedNotifications = NO;
1042 if (_postsBoundsChangedNotifications)
1043 [CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
1052 return _CGRectMakeCopy(_bounds);
1055 - (CGPoint)boundsOrigin
1057 return _CGPointMakeCopy(_bounds.origin);
1060 - (CGSize)boundsSize
1062 return _CGSizeMakeCopy(_bounds.size);
1071 - (void)setBoundsOrigin:(CGPoint)aPoint
1073 var origin = _bounds.origin;
1075 if (_CGPointEqualToPoint(origin, aPoint))
1078 origin.x = aPoint.x;
1079 origin.y = aPoint.y;
1081 if (origin.x != 0 || origin.y != 0)
1083 _boundsTransform = _CGAffineTransformMakeTranslation(-origin.x, -origin.y);
1088 _boundsTransform = nil;
1089 _inverseBoundsTransform = nil;
1093 var index = _subviews.length;
1097 var view = _subviews[index],
1098 origin = view._frame.origin;
1100 CPDOMDisplayServerSetStyleLeftTop(view._DOMElement, _boundsTransform, origin.x, origin.y);
1104 if (_postsBoundsChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications)
1105 [CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
1114 - (void)setBoundsSize:(CGSize)aSize
1116 var size = _bounds.size;
1118 if (_CGSizeEqualToSize(size, aSize))
1121 var frameSize = _frame.size;
1123 if (!_CGSizeEqualToSize(size, frameSize))
1125 var origin = _bounds.origin;
1127 origin.x /= size.width / frameSize.width;
1128 origin.y /= size.height / frameSize.height;
1131 size.width = aSize.width;
1132 size.height = aSize.height;
1134 if (!_CGSizeEqualToSize(size, frameSize))
1136 var origin = _bounds.origin;
1138 origin.x *= size.width / frameSize.width;
1139 origin.y *= size.height / frameSize.height;
1142 if (_postsBoundsChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications)
1143 [CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
1151 - (void)resizeWithOldSuperviewSize:(CGSize)aSize
1158 var
frame = _superview._frame,
1159 newFrame = _CGRectMakeCopy(_frame),
1160 dX = (_CGRectGetWidth(
frame) - aSize.width) /
1162 dY = (_CGRectGetHeight(
frame) - aSize.height) /
1166 newFrame.origin.x += dX;
1168 newFrame.size.width += dX;
1171 newFrame.origin.y += dY;
1173 newFrame.size.height += dY;
1182 - (void)resizeSubviewsWithOldSize:(CGSize)aSize
1184 var count = _subviews.length;
1187 [_subviews[count] resizeWithOldSuperviewSize:aSize];
1197 - (void)setAutoresizesSubviews:(BOOL)aFlag
1199 _autoresizesSubviews = !!aFlag;
1206 - (BOOL)autoresizesSubviews
1208 return _autoresizesSubviews;
1215 - (void)setAutoresizingMask:(
unsigned)aMask
1217 _autoresizingMask = aMask;
1223 - (unsigned)autoresizingMask
1225 return _autoresizingMask;
1233 - (BOOL)enterFullScreenMode
1245 _fullScreenModeState = _CPViewFullScreenModeStateMake(
self);
1249 [fullScreenWindow setLevel:CPScreenSaverWindowLevel];
1250 [fullScreenWindow setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
1252 var contentView = [fullScreenWindow contentView];
1255 [contentView addSubview:self];
1258 [
self setFrame:CGRectMakeCopy([contentView bounds])];
1260 [fullScreenWindow makeKeyAndOrderFront:self];
1262 [fullScreenWindow makeFirstResponder:self];
1264 _isInFullScreenMode = YES;
1272 - (void)exitFullScreenMode
1283 if (!_isInFullScreenMode)
1286 _isInFullScreenMode = NO;
1288 [
self setFrame:_fullScreenModeState.frame];
1290 [_fullScreenModeState.superview _insertSubview:self atIndex:_fullScreenModeState.index];
1298 - (BOOL)isInFullScreenMode
1300 return _isInFullScreenMode;
1307 - (void)setHidden:(BOOL)aFlag
1311 if (_isHidden === aFlag)
1318 _DOMElement.style.display = _isHidden ?
"none" :
"block";
1323 var view = [_window firstResponder];
1325 if ([view isKindOfClass:[
CPView class]])
1335 while (view = [view superview]);
1338 [
self _notifyViewDidHide];
1342 [
self _notifyViewDidUnhide];
1346 - (void)_notifyViewDidHide
1350 var count = [_subviews count];
1352 [_subviews[count] _notifyViewDidHide];
1355 - (void)_notifyViewDidUnhide
1357 [
self viewDidUnhide];
1359 var count = [_subviews count];
1361 [_subviews[count] _notifyViewDidUnhide];
1372 - (void)setClipsToBounds:(BOOL)shouldClip
1374 if (_clipsToBounds === shouldClip)
1377 _clipsToBounds = shouldClip;
1380 _DOMElement.style.overflow = _clipsToBounds ?
"hidden" :
"visible";
1384 - (BOOL)clipsToBounds
1386 return _clipsToBounds;
1394 - (void)setAlphaValue:(
float)anAlphaValue
1396 if (_opacity == anAlphaValue)
1399 _opacity = anAlphaValue;
1405 if (anAlphaValue === 1.0)
1406 try { _DOMElement.style.removeAttribute(
"filter") }
catch (anException) { }
1408 _DOMElement.style.filter =
"alpha(opacity=" + anAlphaValue * 100 +
")";
1411 _DOMElement.style.opacity = anAlphaValue;
1429 - (BOOL)isHiddenOrHasHiddenAncestor
1433 while (view && ![view isHidden])
1434 view = [view superview];
1436 return view !== nil;
1444 return ![
self isHiddenOrHasHiddenAncestor] && [[
self window] isVisible];
1470 - (void)viewDidUnhide
1499 - (void)setHitTests:(BOOL)shouldHitTest
1501 _hitTests = !!shouldHitTest;
1511 if (_isHidden || !_hitTests || !_CGRectContainsPoint(_frame, aPoint))
1515 i = _subviews.length,
1516 adjustedPoint = _CGPointMake(aPoint.x - _CGRectGetMinX(_frame), aPoint.y - _CGRectGetMinY(_frame));
1518 if (_inverseBoundsTransform)
1519 adjustedPoint = _CGPointApplyAffineTransform(adjustedPoint, _inverseBoundsTransform);
1522 if (view = [_subviews[i] hitTest:adjustedPoint])
1531 - (BOOL)needsPanelToBecomeKey
1540 - (BOOL)mouseDownCanMoveWindow
1547 if ([
self mouseDownCanMoveWindow])
1556 else if ([[
self nextResponder] isKindOfClass:
CPView])
1564 return [
self menu] || [[
self class] defaultMenu];
1573 if (_backgroundColor == aColor)
1576 if (aColor == [
CPNull null])
1579 _backgroundColor = aColor;
1582 var patternImage = [_backgroundColor patternImage],
1583 colorExists = _backgroundColor && ([_backgroundColor patternImage] || [_backgroundColor alphaComponent] > 0.0),
1584 colorHasAlpha = colorExists && [_backgroundColor alphaComponent] < 1.0,
1586 colorNeedsDOMElement = colorHasAlpha && !supportsRGBA,
1590 if ([patternImage isThreePartImage])
1592 _backgroundType = [patternImage isVertical] ? BackgroundVerticalThreePartImage : BackgroundHorizontalThreePartImage;
1595 else if ([patternImage isNinePartImage])
1597 _backgroundType = BackgroundNinePartImage;
1602 _backgroundType = colorNeedsDOMElement ? BackgroundTransparentColor : BackgroundTrivialColor;
1603 amount = (colorNeedsDOMElement ? 1 : 0) - _DOMImageParts.length;
1607 if (_backgroundType === BackgroundVerticalThreePartImage || _backgroundType === BackgroundHorizontalThreePartImage || _backgroundType === BackgroundNinePartImage)
1609 slices = [patternImage imageSlices];
1612 amount = MIN(amount, slices.length);
1614 for (var i = 0, count = slices.length; i < count; i++)
1616 var image = slices[i],
1617 size = [image size];
1619 if (!size || (size.width == 0 && size.height == 0))
1622 _DOMImageSizes[i] = size;
1630 amount -= _DOMImageParts.length;
1638 var DOMElement = DOMElementPrototype.cloneNode(
false);
1640 DOMElement.style.zIndex = -1000;
1642 _DOMImageParts.push(DOMElement);
1643 _DOMElement.appendChild(DOMElement);
1650 _DOMElement.removeChild(_DOMImageParts.pop());
1653 if (_backgroundType === BackgroundTrivialColor || _backgroundType === BackgroundTransparentColor)
1655 var colorCSS = colorExists ? [_backgroundColor cssString] :
"";
1657 if (colorNeedsDOMElement)
1659 _DOMElement.style.background =
"";
1660 _DOMImageParts[0].style.background = [_backgroundColor cssString];
1663 _DOMImageParts[0].style.filter =
"alpha(opacity=" + [_backgroundColor alphaComponent] * 100 +
")";
1665 _DOMImageParts[0].style.opacity = [_backgroundColor alphaComponent];
1667 var size = [
self bounds].size;
1668 CPDOMDisplayServerSetStyleSize(_DOMImageParts[0], size.width, size.height);
1671 _DOMElement.style.background = colorCSS;
1675 var frameSize = _frame.size,
1678 for (var i = 0; i < slices.length; i++)
1680 var size = _DOMImageSizes[i];
1685 var image = slices[i];
1690 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], size.width, size.height);
1692 _DOMImageParts[partIndex].style.background =
"url(\"" + [image filename] +
"\")";
1697 try { _DOMImageParts[partIndex].style.removeAttribute(
"filter") }
catch (anException) { }
1699 _DOMImageParts[partIndex].style.opacity = 1.0;
1705 if (_backgroundType == BackgroundNinePartImage)
1707 var left = _DOMImageSizes[0] ? _DOMImageSizes[0].width : 0,
1708 right = _DOMImageSizes[2] ? _DOMImageSizes[2].width : 0,
1709 top = _DOMImageSizes[0] ? _DOMImageSizes[0].height : 0,
1710 bottom = _DOMImageSizes[6] ? _DOMImageSizes[6].height : 0,
1711 width = frameSize.width - left - right,
1712 height = frameSize.height - top - bottom;
1716 if (_DOMImageSizes[0])
1718 CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[partIndex], NULL, 0.0, 0.0);
1721 if (_DOMImageSizes[1])
1723 CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[partIndex], NULL, left, 0.0);
1724 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex],
width, _DOMImageSizes[1].height);
1727 if (_DOMImageSizes[2])
1729 CPDOMDisplayServerSetStyleRightTop(_DOMImageParts[partIndex], NULL, 0.0, 0.0);
1732 if (_DOMImageSizes[3])
1734 CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[partIndex], NULL, 0.0, top);
1735 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], _DOMImageSizes[3].
width, height);
1738 if (_DOMImageSizes[4])
1740 CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[partIndex], NULL, left, top);
1741 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex],
width, height);
1744 if (_DOMImageSizes[5])
1746 CPDOMDisplayServerSetStyleRightTop(_DOMImageParts[partIndex], NULL, 0.0, top);
1747 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], _DOMImageSizes[5].
width, height);
1750 if (_DOMImageSizes[6])
1752 CPDOMDisplayServerSetStyleLeftBottom(_DOMImageParts[partIndex], NULL, 0.0, 0.0);
1755 if (_DOMImageSizes[7])
1757 CPDOMDisplayServerSetStyleLeftBottom(_DOMImageParts[partIndex], NULL, left, 0.0);
1758 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex],
width, _DOMImageSizes[7].height);
1761 if (_DOMImageSizes[8])
1763 CPDOMDisplayServerSetStyleRightBottom(_DOMImageParts[partIndex], NULL, 0.0, 0.0);
1766 else if (_backgroundType == BackgroundVerticalThreePartImage)
1768 var top = _DOMImageSizes[0] ? _DOMImageSizes[0].height : 0,
1769 bottom = _DOMImageSizes[2] ? _DOMImageSizes[2].height : 0;
1776 CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[partIndex], NULL, 0.0, 0.0);
1777 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], frameSize.width, top);
1780 if (_DOMImageSizes[1])
1782 CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[partIndex], NULL, 0.0, top);
1783 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], frameSize.width, frameSize.height - top - bottom);
1788 CPDOMDisplayServerSetStyleLeftBottom(_DOMImageParts[partIndex], NULL, 0.0, 0.0);
1789 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], frameSize.width, bottom);
1792 else if (_backgroundType == BackgroundHorizontalThreePartImage)
1794 var left = _DOMImageSizes[0] ? _DOMImageSizes[0].width : 0,
1795 right = _DOMImageSizes[2] ? _DOMImageSizes[2].width : 0;
1802 CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[partIndex], NULL, 0.0, 0.0);
1803 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], left, frameSize.height);
1806 if (_DOMImageSizes[1])
1808 CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[partIndex], NULL, left, 0.0);
1809 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], frameSize.width - left - right, frameSize.height);
1814 CPDOMDisplayServerSetStyleRightTop(_DOMImageParts[partIndex], NULL, 0.0, 0.0);
1815 CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], right, frameSize.height);
1827 return _backgroundColor;
1837 - (CGPoint)convertPoint:(CGPoint)aPoint fromView:(
CPView)aView
1839 return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(aView,
self));
1847 - (CGPoint)convertPointFromBase:(CGPoint)aPoint
1849 return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(nil,
self));
1858 - (CGPoint)convertPoint:(CGPoint)aPoint toView:(
CPView)aView
1860 return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(
self, aView));
1868 - (CGPoint)convertPointToBase:(CGPoint)aPoint
1870 return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(
self, nil));
1879 - (CGSize)convertSize:(CGSize)aSize fromView:(
CPView)aView
1881 return CGSizeApplyAffineTransform(aSize, _CPViewGetTransform(aView,
self));
1890 - (CGSize)convertSize:(CGSize)aSize toView:(
CPView)aView
1892 return CGSizeApplyAffineTransform(aSize, _CPViewGetTransform(
self, aView));
1901 - (CGRect)convertRect:(CGRect)aRect fromView:(
CPView)aView
1911 - (CGRect)convertRectFromBase:(CGRect)aRect
1922 - (CGRect)convertRect:(CGRect)aRect toView:(
CPView)aView
1932 - (CGRect)convertRectToBase:(CGRect)aRect
1949 - (void)setPostsFrameChangedNotifications:(BOOL)shouldPostFrameChangedNotifications
1951 shouldPostFrameChangedNotifications = !!shouldPostFrameChangedNotifications;
1953 if (_postsFrameChangedNotifications === shouldPostFrameChangedNotifications)
1956 _postsFrameChangedNotifications = shouldPostFrameChangedNotifications;
1958 if (_postsFrameChangedNotifications)
1959 [CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
1965 - (BOOL)postsFrameChangedNotifications
1967 return _postsFrameChangedNotifications;
1982 - (void)setPostsBoundsChangedNotifications:(BOOL)shouldPostBoundsChangedNotifications
1984 shouldPostBoundsChangedNotifications = !!shouldPostBoundsChangedNotifications;
1986 if (_postsBoundsChangedNotifications === shouldPostBoundsChangedNotifications)
1989 _postsBoundsChangedNotifications = shouldPostBoundsChangedNotifications;
1991 if (_postsBoundsChangedNotifications)
1992 [CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
2000 - (BOOL)postsBoundsChangedNotifications
2002 return _postsBoundsChangedNotifications;
2015 - (void)dragImage:(
CPImage)anImage at:(CGPoint)aLocation offset:(CGSize)mouseOffset event:(
CPEvent)anEvent pasteboard:(
CPPasteboard)aPasteboard source:(
id)aSourceObject slideBack:(BOOL)slideBack
2017 [_window dragImage:anImage at:[
self convertPoint:aLocation
toView:nil] offset:mouseOffset event:anEvent pasteboard:aPasteboard source:aSourceObject slideBack:slideBack];
2030 - (void)dragView:(
CPView)aView at:(CPPoint)aLocation offset:(CPSize)mouseOffset event:(
CPEvent)anEvent pasteboard:(
CPPasteboard)aPasteboard source:(
id)aSourceObject slideBack:(BOOL)slideBack
2032 [_window dragView:aView at:[
self convertPoint:aLocation
toView:nil] offset:mouseOffset event:anEvent pasteboard:aPasteboard source:aSourceObject slideBack:slideBack];
2039 - (void)registerForDraggedTypes:(
CPArray)pasteboardTypes
2041 if (!pasteboardTypes || ![pasteboardTypes count])
2044 var theWindow = [
self window];
2046 [theWindow _noteUnregisteredDraggedTypes:_registeredDraggedTypes];
2047 [_registeredDraggedTypes addObjectsFromArray:pasteboardTypes];
2048 [theWindow _noteRegisteredDraggedTypes:_registeredDraggedTypes];
2050 _registeredDraggedTypesArray = nil;
2059 if (!_registeredDraggedTypesArray)
2060 _registeredDraggedTypesArray = [_registeredDraggedTypes allObjects];
2062 return _registeredDraggedTypesArray;
2068 - (void)unregisterDraggedTypes
2070 [[
self window] _noteUnregisteredDraggedTypes:_registeredDraggedTypes];
2072 _registeredDraggedTypes = [
CPSet set];
2073 _registeredDraggedTypesArray = [];
2080 - (void)drawRect:(CPRect)aRect
2090 - (void)setNeedsDisplay:(BOOL)aFlag
2100 - (void)setNeedsDisplayInRect:(CPRect)aRect
2105 if (_CGRectIsEmpty(aRect))
2108 if (_dirtyRect && !_CGRectIsEmpty(_dirtyRect))
2109 _dirtyRect = CGRectUnion(aRect, _dirtyRect);
2111 _dirtyRect = _CGRectMakeCopy(aRect);
2113 _CPDisplayServerAddDisplayObject(
self);
2116 - (BOOL)needsDisplay
2118 return _dirtyRect && !_CGRectIsEmpty(_dirtyRect);
2124 - (void)displayIfNeeded
2126 if ([
self needsDisplay])
2138 - (void)displayIfNeededInRect:(CGRect)aRect
2140 if ([
self needsDisplay])
2148 - (void)displayRect:(CPRect)aRect
2159 if ([
self isHidden])
2172 - (void)viewWillDraw
2181 if (!_graphicsContext)
2185 _DOMContentsElement = graphicsPort.DOMElement;
2187 _DOMContentsElement.style.zIndex = -100;
2189 _DOMContentsElement.style.overflow =
"hidden";
2190 _DOMContentsElement.style.position =
"absolute";
2191 _DOMContentsElement.style.visibility =
"visible";
2193 _DOMContentsElement.width = ROUND(_CGRectGetWidth(_frame));
2194 _DOMContentsElement.height = ROUND(_CGRectGetHeight(_frame));
2196 _DOMContentsElement.style.top =
"0px";
2197 _DOMContentsElement.style.left =
"0px";
2198 _DOMContentsElement.style.width = ROUND(_CGRectGetWidth(_frame)) +
"px";
2199 _DOMContentsElement.style.height = ROUND(_CGRectGetHeight(_frame)) +
"px";
2205 _DOMElement.style.webkitTransform =
'translateX(0)';
2207 CPDOMDisplayServerAppendChild(_DOMElement, _DOMContentsElement);
2227 - (void)setNeedsLayout
2234 _CPDisplayServerAddLayoutObject(
self);
2237 - (void)layoutIfNeeded
2247 - (void)layoutSubviews
2262 - (CGRect)visibleRect
2267 return CGRectIntersection([
self convertRect:[_superview visibleRect] fromView:_superview], _bounds);
2274 var superview = _superview,
2277 while (superview && ![superview isKindOfClass:clipViewClass])
2278 superview = superview._superview;
2287 - (void)scrollPoint:(CGPoint)aPoint
2289 var clipView = [
self _enclosingClipView];
2302 - (BOOL)scrollRectToVisible:(CGRect)aRect
2307 aRect = CGRectIntersection(aRect, _bounds);
2310 if (_CGRectIsEmpty(aRect) || CGRectContainsRect(visibleRect, aRect))
2313 var enclosingClipView = [
self _enclosingClipView];
2316 if (!enclosingClipView)
2319 var scrollPoint = _CGPointMakeCopy(visibleRect.origin);
2322 if (_CGRectGetMinX(aRect) <= _CGRectGetMinX(visibleRect))
2323 scrollPoint.x = _CGRectGetMinX(aRect);
2324 else if (_CGRectGetMaxX(aRect) > _CGRectGetMaxX(visibleRect))
2325 scrollPoint.x += _CGRectGetMaxX(aRect) - _CGRectGetMaxX(visibleRect);
2327 if (_CGRectGetMinY(aRect) <= _CGRectGetMinY(visibleRect))
2328 scrollPoint.y = CGRectGetMinY(aRect);
2329 else if (_CGRectGetMaxY(aRect) > _CGRectGetMaxY(visibleRect))
2330 scrollPoint.y += _CGRectGetMaxY(aRect) - _CGRectGetMaxY(visibleRect);
2332 [enclosingClipView scrollToPoint:CGPointMake(scrollPoint.x, scrollPoint.y)];
2351 - (CGRect)adjustScroll:(CGRect)proposedVisibleRect
2353 return proposedVisibleRect;
2359 - (void)scrollRect:(CGRect)aRect by:(
float)anAmount
2370 var superview = _superview,
2373 while (superview && ![superview isKindOfClass:scrollViewClass])
2374 superview = superview._superview;
2384 - (void)scrollClipView:(
CPClipView)aClipView toPoint:(CGPoint)aPoint
2401 - (BOOL)inLiveResize
2403 return _inLiveResize;
2415 - (void)viewWillStartLiveResize
2417 _inLiveResize = YES;
2430 - (void)viewDidEndLiveResize
2455 var count = [_subviews count];
2459 if ([_subviews[count] performKeyEquivalent:anEvent])
2465 - (BOOL)canBecomeKeyView
2472 return _nextKeyView;
2478 firstResult = result;
2480 while (result && ![result canBecomeKeyView])
2482 result = [result nextKeyView];
2485 if (result === firstResult)
2494 return _previousKeyView;
2500 firstResult = result;
2502 while (result && ![result canBecomeKeyView])
2504 result = [result previousKeyView];
2507 if (result === firstResult)
2514 - (void)_setPreviousKeyView:(
CPView)previous
2517 _previousKeyView = nil;
2519 _previousKeyView = previous;
2528 _nextKeyView = next;
2529 [_nextKeyView _setPreviousKeyView:self];
2542 if (_layer == aLayer)
2547 _layer._owningView = nil;
2549 _DOMElement.removeChild(_layer._DOMElement);
2557 var bounds = CGRectMakeCopy([
self bounds]);
2559 [_layer _setOwningView:self];
2562 _layer._DOMElement.style.zIndex = 100;
2564 _DOMElement.appendChild(_layer._DOMElement);
2581 - (void)setWantsLayer:(BOOL)aFlag
2583 _wantsLayer = !!aFlag;
2598 #pragma mark Theme States
2600 - (unsigned)themeState
2611 return !!(_themeState & ((typeof aState ===
"string") ?
CPThemeState(aState) : aState));
2616 var newState = (typeof aState ===
"string") ?
CPThemeState(aState) : aState;
2618 if (_themeState & newState)
2621 _themeState |= newState;
2631 var newState = ((typeof aState ===
"string") ?
CPThemeState(aState) : aState);
2633 if (!(_themeState & newState))
2636 _themeState &= ~newState;
2644 #pragma mark Theme Attributes
2656 return [[
self class] defaultThemeClass];
2661 _themeClass = theClass;
2663 [
self _loadThemeAttributes];
2679 var theClass = [
self class],
2684 for (; theClass && theClass !== CPViewClass; theClass = [theClass superclass])
2688 if (cachedAttributes)
2690 attributes = attributes.length ? attributes.concat(cachedAttributes) : attributes;
2696 var attributeDictionary = [theClass themeAttributes];
2698 if (!attributeDictionary)
2701 var attributeKeys = [attributeDictionary allKeys],
2702 attributeCount = attributeKeys.length;
2704 while (attributeCount--)
2706 var attributeName = attributeKeys[attributeCount],
2707 attributeValue = [attributeDictionary objectForKey:attributeName];
2709 attributes.push(attributeValue === nullValue ? nil : attributeValue);
2710 attributes.push(attributeName);
2717 - (void)_loadThemeAttributes
2719 var theClass = [
self class],
2720 attributes = [theClass _themeAttributes],
2721 count = attributes.length;
2726 var theme = [
self theme],
2727 themeClass = [
self themeClass];
2729 _themeAttributes = {};
2733 var attributeName = attributes[count--],
2734 attribute = [[_CPThemeAttribute alloc] initWithName:attributeName defaultValue:attributes[count]];
2736 [attribute setParentAttribute:[theme attributeWithName:attributeName forClass:themeClass]];
2738 _themeAttributes[attributeName] = attribute;
2744 if (_theme === aTheme)
2757 - (void)viewDidChangeTheme
2759 if (!_themeAttributes)
2762 var theme = [
self theme],
2765 for (var attributeName in _themeAttributes)
2766 if (_themeAttributes.hasOwnProperty(attributeName))
2767 [_themeAttributes[attributeName] setParentAttribute:[theme attributeWithName:attributeName forClass:themeClass]];
2777 if (_themeAttributes)
2779 var theme = [
self theme];
2781 for (var attributeName in _themeAttributes)
2782 if (_themeAttributes.hasOwnProperty(attributeName))
2783 [dictionary setObject:_themeAttributes[attributeName] forKey:attributeName];
2791 if (!_themeAttributes || !_themeAttributes[aName])
2796 [_themeAttributes[aName] setValue:aValue forState:aState];
2798 if ([
self currentValueForThemeAttribute:aName] === currentValue)
2805 - (void)setValue:(
id)aValue forThemeAttribute:(
CPString)aName
2807 if (!_themeAttributes || !_themeAttributes[aName])
2812 [_themeAttributes[aName] setValue:aValue];
2814 if ([
self currentValueForThemeAttribute:aName] === currentValue)
2823 if (!_themeAttributes || !_themeAttributes[aName])
2826 return [_themeAttributes[aName] valueForState:aState];
2831 if (!_themeAttributes || !_themeAttributes[aName])
2834 return [_themeAttributes[aName] value];
2839 if (!_themeAttributes || !_themeAttributes[aName])
2842 return [_themeAttributes[aName] valueForState:_themeState];
2847 return (_themeAttributes && _themeAttributes[aName] !== undefined);
2860 for (var i = 0; i < themeValues.length; ++i)
2862 var attributeValueState = themeValues[i],
2863 attribute = attributeValueState[0],
2864 value = attributeValueState[1],
2865 state = attributeValueState[2];
2887 if (inheritedValues)
2899 - (CGRect)rectForEphemeralSubviewNamed:(
CPString)aViewName
2901 return _CGRectMakeZero();
2905 positioned:(CPWindowOrderingMode)anOrderingMode
2906 relativeToEphemeralSubviewNamed:(
CPString)relativeToViewName
2908 if (!_ephemeralSubviewsForNames)
2910 _ephemeralSubviewsForNames = {};
2918 if (!_ephemeralSubviewsForNames[aViewName])
2922 [_ephemeralSubviews addObject:_ephemeralSubviewsForNames[aViewName]];
2924 if (_ephemeralSubviewsForNames[aViewName])
2928 if (_ephemeralSubviewsForNames[aViewName])
2929 [_ephemeralSubviewsForNames[aViewName] setFrame:frame];
2931 else if (_ephemeralSubviewsForNames[aViewName])
2933 [_ephemeralSubviewsForNames[aViewName] removeFromSuperview];
2935 [_ephemeralSubviews removeObject:_ephemeralSubviewsForNames[aViewName]];
2936 delete _ephemeralSubviewsForNames[aViewName];
2939 return _ephemeralSubviewsForNames[aViewName];
2944 if (!_ephemeralSubviewsForNames)
2947 return (_ephemeralSubviewsForNames[aViewName] || nil);
2984 _DOMElement = DOMElementPrototype.cloneNode(
false);
2988 _frame = [aCoder decodeRectForKey:CPViewFrameKey];
2989 _bounds = [aCoder decodeRectForKey:CPViewBoundsKey];
2996 _tag = [aCoder containsValueForKey:CPViewTagKey] ? [aCoder decodeIntForKey:CPViewTagKey] : -1;
2998 _window = [aCoder decodeObjectForKey:CPViewWindowKey];
2999 _subviews = [aCoder decodeObjectForKey:CPViewSubviewsKey] || [];
3000 _superview = [aCoder decodeObjectForKey:CPViewSuperviewKey];
3003 _registeredDraggedTypes = [
CPSet set];
3004 _registeredDraggedTypesArray = [];
3008 if (_autoresizingMask === nil)
3009 _autoresizingMask = [aCoder decodeIntForKey:CPViewAutoresizingMaskKey] ||
CPViewNotSizable;
3011 _autoresizesSubviews = ![aCoder containsValueForKey:CPViewAutoresizesSubviewsKey] || [aCoder decodeBoolForKey:CPViewAutoresizesSubviewsKey];
3013 _hitTests = ![aCoder containsValueForKey:CPViewHitTestsKey] || [aCoder decodeBoolForKey:CPViewHitTestsKey];
3015 [
self _setupToolTipHandlers];
3016 _toolTip = [aCoder decodeObjectForKey:CPViewToolTipKey];
3019 [
self _installToolTipEventHandlers];
3023 _DOMImageParts = [];
3024 _DOMImageSizes = [];
3026 CPDOMDisplayServerSetStyleLeftTop(_DOMElement, NULL, _CGRectGetMinX(_frame), _CGRectGetMinY(_frame));
3027 CPDOMDisplayServerSetStyleSize(_DOMElement, _CGRectGetWidth(_frame), _CGRectGetHeight(_frame));
3030 count = _subviews.length;
3032 for (; index < count; ++index)
3034 CPDOMDisplayServerAppendChild(_DOMElement, _subviews[index]._DOMElement);
3039 [
self setHidden:[aCoder decodeBoolForKey:CPViewIsHiddenKey]];
3042 [
self setAlphaValue:[aCoder decodeIntForKey:CPViewOpacityKey]];
3047 [
self _setupViewFlags];
3050 _themeClass = [aCoder decodeObjectForKey:CPViewThemeClassKey];
3052 _themeAttributes = {};
3054 var theClass = [
self class],
3056 attributes = [theClass _themeAttributes],
3057 count = attributes.
length;
3061 var attributeName = attributes[count--];
3063 _themeAttributes[attributeName] =
CPThemeAttributeDecode(aCoder, attributeName, attributes[count], _theme, themeClass);
3082 [aCoder encodeInt:_tag forKey:CPViewTagKey];
3084 [aCoder encodeRect:_frame forKey:CPViewFrameKey];
3085 [aCoder encodeRect:_bounds forKey:CPViewBoundsKey];
3088 if (_window !== nil)
3089 [aCoder encodeConditionalObject:_window forKey:CPViewWindowKey];
3091 var count = [_subviews count],
3092 encodedSubviews = _subviews;
3094 if (count > 0 && [_ephemeralSubviews count] > 0)
3096 encodedSubviews = [encodedSubviews copy];
3099 if ([_ephemeralSubviews containsObject:encodedSubviews[count]])
3100 encodedSubviews.splice(count, 1);
3103 if (encodedSubviews.length > 0)
3104 [aCoder encodeObject:encodedSubviews forKey:CPViewSubviewsKey];
3107 if (_superview !== nil)
3108 [aCoder encodeConditionalObject:_superview forKey:CPViewSuperviewKey];
3111 [aCoder encodeInt:_autoresizingMask forKey:CPViewAutoresizingMaskKey];
3113 if (!_autoresizesSubviews)
3114 [aCoder encodeBool:_autoresizesSubviews forKey:CPViewAutoresizesSubviewsKey];
3116 if (_backgroundColor !== nil)
3117 [aCoder encodeObject:_backgroundColor forKey:CPViewBackgroundColorKey];
3119 if (_hitTests !== YES)
3120 [aCoder encodeBool:_hitTests forKey:CPViewHitTestsKey];
3122 if (_opacity !== 1.0)
3123 [aCoder encodeFloat:_opacity forKey:CPViewOpacityKey];
3126 [aCoder encodeBool:_isHidden forKey:CPViewIsHiddenKey];
3129 [aCoder encodeObject:_toolTip forKey:CPViewToolTipKey];
3133 if (nextKeyView !== nil && ![nextKeyView
isEqual:
self])
3134 [aCoder encodeConditionalObject:nextKeyView forKey:CPViewNextKeyViewKey];
3138 if (previousKeyView !== nil && ![previousKeyView
isEqual:
self])
3139 [aCoder encodeConditionalObject:previousKeyView forKey:CPViewPreviousKeyViewKey];
3141 [aCoder encodeObject:[
self themeClass] forKey:CPViewThemeClassKey];
3142 [aCoder encodeInt:CPThemeStateName(_themeState) forKey:CPViewThemeStateKey];
3144 for (var attributeName in _themeAttributes)
3145 if (_themeAttributes.hasOwnProperty(attributeName))
3151 var _CPViewFullScreenModeStateMake =
function(aView)
3153 var superview = aView._superview;
3155 return { autoresizingMask:aView._autoresizingMask,
frame:CGRectMakeCopy(aView._frame), index:(superview ? [superview._subviews indexOfObjectIdenticalTo:aView] : 0), superview:superview };
3158 var _CPViewGetTransform =
function( fromView, toView)
3160 var transform = CGAffineTransformMakeIdentity(),
3167 var view = fromView;
3172 while (view && view != toView)
3174 var
frame = view._frame;
3176 transform.tx += _CGRectGetMinX(frame);
3177 transform.ty += _CGRectGetMinY(frame);
3179 if (view._boundsTransform)
3181 _CGAffineTransformConcatTo(transform, view._boundsTransform, transform);
3184 view = view._superview;
3188 if (view === toView)
3191 else if (fromView && toView)
3193 fromWindow = [fromView window];
3194 toWindow = [toView window];
3196 if (fromWindow && toWindow && fromWindow !== toWindow)
3200 var frame = [fromWindow frame];
3202 transform.tx += _CGRectGetMinX(frame);
3203 transform.ty += _CGRectGetMinY(frame);
3213 var frame = view._frame;
3215 transform.tx -= _CGRectGetMinX(frame);
3216 transform.ty -= _CGRectGetMinY(frame);
3218 if (view._boundsTransform)
3220 _CGAffineTransformConcatTo(transform, view._inverseBoundsTransform, transform);
3223 view = view._superview;
3228 var frame = [toWindow frame];
3230 transform.tx -= _CGRectGetMinX(frame);
3231 transform.ty -= _CGRectGetMinY(frame);