28 #define SHOULD_SHOW_CORNER_VIEW() (_scrollerStyle === CPScrollerStyleLegacy && _verticalScroller && ![_verticalScroller isHidden])
32 var _isBrowserUsingOverlayScrollers =
function()
47 var outer = document.createElement(
'div'),
48 inner = document.createElement(
'p');
51 outer.style.position =
"absolute";
52 outer.style.top =
"0px";
53 outer.style.left =
"0px";
54 outer.style.visibility =
"hidden";
55 outer.style.width =
"200px";
56 outer.style.height =
"150px";
57 outer.style.overflow =
"scroll";
59 inner.style.width =
"100%";
60 inner.style.height =
"200px";
61 outer.appendChild(inner);
63 document.body.appendChild(outer);
65 var usingOverlayScrollers = outer.clientWidth === outer.offsetWidth;
67 document.body.removeChild(outer);
69 return usingOverlayScrollers;
104 BOOL _hasVerticalScroller;
105 BOOL _hasHorizontalScroller;
106 BOOL _autohidesScrollers;
111 CPInteger _recursionCount;
112 CPInteger _implementedDelegateMethods;
114 float _verticalLineScroll;
115 float _verticalPageScroll;
116 float _horizontalLineScroll;
117 float _horizontalPageScroll;
119 CPBorderType _borderType;
124 int _scrollerKnobStyle;
129 #pragma mark Class methods
138 if (globalValue === nil || globalValue === -1)
157 + (CGSize)contentSizeForFrameSize:(CGSize)frameSize hasHorizontalScroller:(BOOL)hFlag hasVerticalScroller:(BOOL)vFlag borderType:(CPBorderType)borderType
159 var bounds = [
self _insetBounds:CGRectMake(0.0, 0.0, frameSize.width, frameSize.height) borderType:borderType],
163 bounds.size.height -= scrollerWidth;
166 bounds.size.width -= scrollerWidth;
171 + (CGSize)frameSizeForContentSize:(CGSize)contentSize hasHorizontalScroller:(BOOL)hFlag hasVerticalScroller:(BOOL)vFlag borderType:(CPBorderType)borderType
173 var bounds = [
self _insetBounds:CGRectMake(0.0, 0.0, contentSize.width, contentSize.height) borderType:borderType],
174 widthInset = contentSize.width - bounds.size.width,
175 heightInset = contentSize.height - bounds.size.height,
176 frameSize = CGSizeMake(contentSize.width + widthInset, contentSize.height + heightInset),
180 frameSize.height += scrollerWidth;
183 frameSize.width += scrollerWidth;
188 + (CGRect)_insetBounds:(CGRect)bounds borderType:(CPBorderType)borderType
194 return CGRectInset(bounds, 1.0, 1.0);
197 bounds = CGRectInset(bounds, 2.0, 2.0);
199 --bounds.size.height;
211 + (int)globalScrollerStyle
221 + (void)setGlobalScrollerStyle:(
int)aStyle
229 #pragma mark Initialization
231 - (id)initWithFrame:(CGRect)aFrame
233 self = [
super initWithFrame:aFrame];
237 _verticalLineScroll = 10.0;
238 _verticalPageScroll = 10.0;
240 _horizontalLineScroll = 10.0;
241 _horizontalPageScroll = 10.0;
245 _contentView = [[
CPClipView alloc] initWithFrame:[
self _insetBounds]];
246 [
self addSubview:_contentView];
249 [
self addSubview:_headerClipView];
251 _bottomCornerView = [[
CPView alloc] init];
252 [
self addSubview:_bottomCornerView];
261 _implementedDelegateMethods = 0;
265 name:CPScrollerStyleGlobalChangeNotification
274 #pragma mark Getters / Setters
299 - (void)setDelegate:(
id)aDelegate
301 if (aDelegate === _delegate)
304 _delegate = aDelegate;
305 _implementedDelegateMethods = 0;
307 if (_delegate === nil)
310 if ([_delegate respondsToSelector:
@selector(scrollViewWillScroll:)])
313 if ([_delegate respondsToSelector:
@selector(scrollViewDidScroll:)])
319 return _scrollerStyle;
328 - (void)setScrollerStyle:(
int)aStyle
330 if (_scrollerStyle === aStyle)
333 _scrollerStyle = aStyle;
335 [
self _updateScrollerStyle];
348 - (int)scrollerKnobStyle
350 return _scrollerKnobStyle;
363 - (void)setScrollerKnobStyle:(
int)newScrollerKnobStyle
365 if (_scrollerKnobStyle === newScrollerKnobStyle)
368 _scrollerKnobStyle = newScrollerKnobStyle;
370 [
self _updateScrollerStyle];
388 if (_contentView === aContentView || !aContentView)
391 var documentView = [aContentView documentView];
396 [_contentView removeFromSuperview];
398 _contentView = aContentView;
400 [_contentView setDocumentView:documentView];
402 [
self addSubview:_contentView];
411 - (CGSize)contentSize
413 return [_contentView frame].size;
421 return [_contentView documentView];
431 [_contentView setDocumentView:aView];
434 [
self _updateCornerAndHeaderView];
441 - (CPBorderType)borderType
456 - (void)setBorderType:(CPBorderType)borderType
458 if (_borderType == borderType)
461 _borderType = borderType;
464 [
self setNeedsDisplay:YES];
473 return _horizontalScroller;
483 if (_horizontalScroller === aScroller)
486 [_horizontalScroller removeFromSuperview];
487 [_horizontalScroller setTarget:nil];
488 [_horizontalScroller setAction:nil];
490 _horizontalScroller = aScroller;
492 [_horizontalScroller setTarget:self];
493 [_horizontalScroller setAction:@selector(_horizontalScrollerDidScroll:)];
495 [
self addSubview:_horizontalScroller];
497 [
self _updateScrollerStyle];
503 - (BOOL)hasHorizontalScroller
505 return _hasHorizontalScroller;
514 - (void)setHasHorizontalScroller:(BOOL)shouldHaveHorizontalScroller
516 if (_hasHorizontalScroller === shouldHaveHorizontalScroller)
519 _hasHorizontalScroller = shouldHaveHorizontalScroller;
521 if (_hasHorizontalScroller && !_horizontalScroller)
523 var bounds = [
self _insetBounds];
537 return _verticalScroller;
547 if (_verticalScroller === aScroller)
550 [_verticalScroller removeFromSuperview];
551 [_verticalScroller setTarget:nil];
552 [_verticalScroller setAction:nil];
554 _verticalScroller = aScroller;
556 [_verticalScroller setTarget:self];
557 [_verticalScroller setAction:@selector(_verticalScrollerDidScroll:)];
559 [
self addSubview:_verticalScroller];
561 [
self _updateScrollerStyle];
567 - (BOOL)hasVerticalScroller
569 return _hasVerticalScroller;
579 - (void)setHasVerticalScroller:(BOOL)shouldHaveVerticalScroller
581 if (_hasVerticalScroller === shouldHaveVerticalScroller)
584 _hasVerticalScroller = shouldHaveVerticalScroller;
586 if (_hasVerticalScroller && !_verticalScroller)
588 var bounds = [
self _insetBounds];
600 - (BOOL)autohidesScrollers
602 return _autohidesScrollers;
611 - (void)setAutohidesScrollers:(BOOL)autohidesScrollers
613 if (_autohidesScrollers == autohidesScrollers)
616 _autohidesScrollers = autohidesScrollers;
623 return _bottomCornerView;
626 - (void)setBottomCornerView:(
CPView)aBottomCornerView
628 if (_bottomCornerView === aBottomCornerView)
631 [_bottomCornerView removeFromSuperview];
633 [aBottomCornerView setFrame:[
self _bottomCornerViewFrame]];
634 [
self addSubview:aBottomCornerView];
636 _bottomCornerView = aBottomCornerView;
638 [
self _updateCornerAndHeaderView];
654 - (void)setLineScroll:(
float)aLineScroll
663 - (float)horizontalLineScroll
665 return _horizontalLineScroll;
673 - (void)setHorizontalLineScroll:(
float)aLineScroll
675 _horizontalLineScroll = aLineScroll;
681 - (float)verticalLineScroll
683 return _verticalLineScroll;
691 - (void)setVerticalLineScroll:(
float)aLineScroll
693 _verticalLineScroll = aLineScroll;
709 - (void)setPageScroll:(
float)aPageScroll
718 - (float)horizontalPageScroll
720 return _horizontalPageScroll;
728 - (void)setHorizontalPageScroll:(
float)aPageScroll
730 _horizontalPageScroll = aPageScroll;
736 - (float)verticalPageScroll
738 return _verticalPageScroll;
746 - (void)setVerticalPageScroll:(
float)aPageScroll
748 _verticalPageScroll = aPageScroll;
753 #pragma mark Privates
756 - (void)_updateScrollerStyle
758 if (_hasHorizontalScroller)
760 [_horizontalScroller setStyle:_scrollerStyle];
761 [_horizontalScroller unsetThemeState:CPThemeStateSelected];
763 switch (_scrollerKnobStyle)
766 [_horizontalScroller unsetThemeState:CPThemeStateScrollerKnobDark];
767 [_horizontalScroller setThemeState:CPThemeStateScrollerKnobLight];
771 [_horizontalScroller unsetThemeState:CPThemeStateScrollerKnobLight];
772 [_horizontalScroller setThemeState:CPThemeStateScrollerKnobDark];
776 [_horizontalScroller unsetThemeState:CPThemeStateScrollerKnobLight];
777 [_horizontalScroller unsetThemeState:CPThemeStateScrollerKnobDark];
781 if (_hasVerticalScroller)
783 [_verticalScroller setStyle:_scrollerStyle];
784 [_verticalScroller unsetThemeState:CPThemeStateSelected];
786 switch (_scrollerKnobStyle)
789 [_verticalScroller unsetThemeState:CPThemeStateScrollerKnobDark];
790 [_verticalScroller setThemeState:CPThemeStateScrollerKnobLight];
794 [_verticalScroller unsetThemeState:CPThemeStateScrollerKnobLight];
795 [_verticalScroller setThemeState:CPThemeStateScrollerKnobDark];
799 [_verticalScroller unsetThemeState:CPThemeStateScrollerKnobLight];
800 [_verticalScroller unsetThemeState:CPThemeStateScrollerKnobDark];
806 if (_timerScrollersHide)
807 [_timerScrollersHide invalidate];
810 [[
self bottomCornerView] setHidden:YES];
813 [[
self bottomCornerView] setHidden:NO];
815 [
self reflectScrolledClipView:_contentView];
819 - (CGRect)_insetBounds
821 return [[
self class] _insetBounds:[
self bounds] borderType:_borderType];
825 - (void)_updateCornerAndHeaderView
827 var documentView = [
self documentView],
828 currentHeaderView = [
self _headerView],
829 documentHeaderView = [documentView respondsToSelector:@selector(headerView)] ? [documentView headerView] : nil;
831 if (currentHeaderView !== documentHeaderView)
833 [currentHeaderView removeFromSuperview];
834 [_headerClipView setDocumentView:documentHeaderView];
837 var documentCornerView = [documentView respondsToSelector:@selector(cornerView)] ? [documentView cornerView] : nil;
839 if (_cornerView !== documentCornerView)
841 [_cornerView removeFromSuperview];
843 _cornerView = documentCornerView;
847 [_cornerView setHidden:!SHOULD_SHOW_CORNER_VIEW()];
848 [
self addSubview:_cornerView];
852 [
self reflectScrolledClipView:_contentView];
853 [documentHeaderView setNeedsLayout];
854 [documentHeaderView setNeedsDisplay:YES];
860 return [_headerClipView documentView];
864 - (CGRect)_cornerViewFrame
867 return CGRectMakeZero();
869 var bounds = [
self _insetBounds],
870 frame = [_cornerView frame];
872 frame.origin.x = CGRectGetMaxX(bounds) - CGRectGetWidth(
frame);
873 frame.origin.y = CGRectGetMinY(bounds);
879 - (CGRect)_headerClipViewFrame
881 var headerView = [
self _headerView];
884 return CGRectMakeZero();
886 var
frame = [
self _insetBounds];
888 frame.size.height = CGRectGetHeight([headerView frame]);
891 frame.size.width -= CGRectGetWidth([self _cornerViewFrame]);
897 - (CGRect)_bottomCornerViewFrame
899 if ([[
self horizontalScroller] isHidden] || [[
self verticalScroller] isHidden])
900 return CGRectMakeZero();
902 var verticalFrame = [[
self verticalScroller] frame],
903 bottomCornerFrame = CGRectMakeZero();
905 bottomCornerFrame.origin.x = CGRectGetMinX(verticalFrame);
906 bottomCornerFrame.origin.y = CGRectGetMaxY(verticalFrame);
910 return bottomCornerFrame;
914 - (void)_verticalScrollerDidScroll:(
CPScroller)aScroller
917 documentFrame = [[_contentView documentView] frame],
918 contentBounds = [_contentView bounds];
921 switch ([_verticalScroller hitPart])
924 contentBounds.origin.y -= _verticalLineScroll;
928 contentBounds.origin.y += _verticalLineScroll;
932 contentBounds.origin.y -= CGRectGetHeight(contentBounds) - _verticalPageScroll;
936 contentBounds.origin.y += CGRectGetHeight(contentBounds) - _verticalPageScroll;
943 contentBounds.origin.y = ROUND(value * (CGRectGetHeight(documentFrame) - CGRectGetHeight(contentBounds)));
946 [
self _sendDelegateMessages];
948 [_contentView scrollToPoint:contentBounds.origin];
952 - (void)_horizontalScrollerDidScroll:(
CPScroller)aScroller
955 documentFrame = [[
self documentView] frame],
956 contentBounds = [_contentView bounds];
958 switch ([_horizontalScroller hitPart])
961 contentBounds.origin.x -= _horizontalLineScroll;
965 contentBounds.origin.x += _horizontalLineScroll;
969 contentBounds.origin.x -= CGRectGetWidth(contentBounds) - _horizontalPageScroll;
973 contentBounds.origin.x += CGRectGetWidth(contentBounds) - _horizontalPageScroll;
980 contentBounds.origin.x = ROUND(value * (CGRectGetWidth(documentFrame) - CGRectGetWidth(contentBounds)));
983 [
self _sendDelegateMessages];
985 [_contentView scrollToPoint:contentBounds.origin];
986 [_headerClipView scrollToPoint:CGPointMake(contentBounds.origin.x, 0.0)];
990 - (void)_sendDelegateMessages
992 if (_implementedDelegateMethods == 0)
997 [
self _scrollViewWillScroll];
1005 - (void)_hideScrollers:(
CPTimer)theTimer
1007 if ([_verticalScroller allowFadingOut])
1008 [_verticalScroller fadeOut];
1009 if ([_horizontalScroller allowFadingOut])
1010 [_horizontalScroller fadeOut];
1011 _timerScrollersHide = nil;
1015 - (void)_respondToScrollWheelEventWithDeltaX:(
float)deltaX deltaY:(
float)deltaY
1017 var documentFrame = [[
self documentView] frame],
1018 contentBounds = [_contentView bounds],
1019 contentFrame = [_contentView frame],
1020 enclosingScrollView = [
self enclosingScrollView];
1023 contentBounds.origin.x = ROUND(contentBounds.origin.x + deltaX);
1024 contentBounds.origin.y = ROUND(contentBounds.origin.y + deltaY);
1026 var constrainedOrigin = [_contentView constrainScrollPoint:CGPointCreateCopy(contentBounds.origin)],
1027 extraX = contentBounds.origin.x - constrainedOrigin.x,
1028 extraY = contentBounds.origin.y - constrainedOrigin.y;
1030 [
self _sendDelegateMessages];
1032 [_contentView scrollToPoint:constrainedOrigin];
1033 [_headerClipView scrollToPoint:CGPointMake(constrainedOrigin.x, 0.0)];
1035 if (extraX || extraY)
1036 [enclosingScrollView _respondToScrollWheelEventWithDeltaX:extraX deltaY:extraY];
1040 - (void)_scrollViewWillScroll
1043 [_delegate scrollViewWillScroll:self];
1047 - (void)_scrollViewDidScroll
1049 [_scrollTimer invalidate];
1053 [_delegate scrollViewDidScroll:self];
1057 - (void)_didReceiveDefaultStyleChange:(
CPNotification)aNotification
1059 [
self setScrollerStyle:CPScrollerStyleGlobal];
1065 #pragma mark Utilities
1085 if (_contentView !== aClipView)
1088 if (_recursionCount > 5)
1097 if (_autohidesScrollers)
1099 [_verticalScroller setHidden:YES];
1100 [_horizontalScroller setHidden:YES];
1103 [_contentView setFrame:[
self _insetBounds]];
1104 [_headerClipView setFrame:CGRectMakeZero()];
1111 var documentFrame = [documentView frame],
1112 contentFrame = [
self _insetBounds],
1113 headerClipViewFrame = [
self _headerClipViewFrame],
1114 headerClipViewHeight = CGRectGetHeight(headerClipViewFrame);
1116 contentFrame.origin.y += headerClipViewHeight;
1117 contentFrame.size.height -= headerClipViewHeight;
1119 var difference = CGSizeMake(CGRectGetWidth(documentFrame) - CGRectGetWidth(contentFrame), CGRectGetHeight(documentFrame) - CGRectGetHeight(contentFrame)),
1122 hasVerticalScroll = difference.height > 0.0,
1123 hasHorizontalScroll = difference.width > 0.0,
1124 shouldShowVerticalScroller = _hasVerticalScroller && (!_autohidesScrollers || hasVerticalScroll),
1125 shouldShowHorizontalScroller = _hasHorizontalScroller && (!_autohidesScrollers || hasHorizontalScroll);
1128 if (shouldShowVerticalScroller)
1131 difference.width += verticalScrollerWidth;
1132 hasHorizontalScroll = difference.width > 0.0;
1133 shouldShowHorizontalScroller = _hasHorizontalScroller && (!_autohidesScrollers || hasHorizontalScroll);
1136 if (shouldShowHorizontalScroller)
1139 difference.height += horizontalScrollerHeight;
1140 hasVerticalScroll = difference.height > 0.0;
1141 shouldShowVerticalScroller = _hasVerticalScroller && (!_autohidesScrollers || hasVerticalScroll);
1145 [_verticalScroller setHidden:!shouldShowVerticalScroller];
1146 [_verticalScroller setEnabled:hasVerticalScroll];
1148 [_horizontalScroller setHidden:!shouldShowHorizontalScroller];
1149 [_horizontalScroller setEnabled:hasHorizontalScroll];
1155 if (shouldShowVerticalScroller)
1156 contentFrame.size.width -= verticalScrollerWidth;
1158 if (shouldShowHorizontalScroller)
1159 contentFrame.size.height -= horizontalScrollerHeight;
1163 var scrollPoint = [_contentView bounds].origin,
1164 wasShowingVerticalScroller = ![_verticalScroller isHidden],
1165 wasShowingHorizontalScroller = ![_horizontalScroller isHidden];
1167 if (shouldShowVerticalScroller)
1169 var verticalScrollerY =
1170 MAX(CGRectGetMinY(contentFrame), MAX(CGRectGetMaxY([
self _cornerViewFrame]), CGRectGetMaxY(headerClipViewFrame)));
1172 var verticalScrollerHeight = CGRectGetMaxY(contentFrame) - verticalScrollerY;
1176 verticalScrollerHeight -= horizontalScrollerHeight;
1178 var documentHeight = CGRectGetHeight(documentFrame);
1179 [_verticalScroller setFloatValue:(difference.height <= 0.0) ? 0.0 : scrollPoint.y / difference.height];
1180 [_verticalScroller setKnobProportion:documentHeight > 0 ? CGRectGetHeight(contentFrame) / documentHeight : 1.0];
1181 [_verticalScroller setFrame:CGRectMake(CGRectGetMaxX(contentFrame) - overlay, verticalScrollerY, verticalScrollerWidth, verticalScrollerHeight)];
1183 else if (wasShowingVerticalScroller)
1185 [_verticalScroller setFloatValue:0.0];
1186 [_verticalScroller setKnobProportion:1.0];
1189 if (shouldShowHorizontalScroller)
1191 var horizontalScrollerWidth = CGRectGetWidth(contentFrame);
1194 horizontalScrollerWidth -= verticalScrollerWidth;
1196 var documentWidth = CGRectGetWidth(documentFrame);
1198 [_horizontalScroller setFloatValue:(difference.width <= 0.0) ? 0.0 : scrollPoint.x / difference.width];
1199 [_horizontalScroller setKnobProportion:documentWidth > 0 ? CGRectGetWidth(contentFrame) / documentWidth : 1.0];
1200 [_horizontalScroller setFrame:CGRectMake(CGRectGetMinX(contentFrame), CGRectGetMaxY(contentFrame) - overlay, horizontalScrollerWidth, horizontalScrollerHeight)];
1202 else if (wasShowingHorizontalScroller)
1204 [_horizontalScroller setFloatValue:0.0];
1205 [_horizontalScroller setKnobProportion:1.0];
1208 [_contentView setFrame:contentFrame];
1209 [_headerClipView setFrame:[
self _headerClipViewFrame]];
1210 [[_headerClipView documentView] setNeedsDisplay:YES];
1213 [_cornerView setFrame:[
self _cornerViewFrame]];
1214 [_cornerView setHidden:NO];
1217 [_cornerView setHidden:YES];
1222 [[
self bottomCornerView] setBackgroundColor:[
self currentValueForThemeAttribute:@"bottom-corner-color"]];
1231 - (void)flashScrollers
1236 if (_hasHorizontalScroller)
1238 [_horizontalScroller setHidden:NO];
1239 [_horizontalScroller fadeIn];
1242 if (_hasVerticalScroller)
1244 [_verticalScroller setHidden:NO];
1245 [_verticalScroller fadeIn];
1248 if (_timerScrollersHide)
1249 [_timerScrollersHide invalidate]
1255 - (void)resizeSubviewsWithOldSize:(CGSize)aSize
1262 #pragma mark Overrides
1264 - (void)drawRect:(CGRect)aRect
1266 [
super drawRect:aRect];
1271 var strokeRect = [
self bounds],
1276 switch (_borderType)
1284 [
self _drawGrayBezelInContext:context bounds:strokeRect];
1288 [
self _drawGrooveInContext:context bounds:strokeRect];
1296 - (void)_drawGrayBezelInContext:(CGContext)context bounds:(CGRect)aRect
1298 var minX = CGRectGetMinX(aRect),
1299 maxX = CGRectGetMaxX(aRect),
1300 minY = CGRectGetMinY(aRect),
1301 maxY = CGRectGetMaxY(aRect),
1330 - (void)_drawGrooveInContext:(CGContext)context bounds:(CGRect)aRect
1332 var minX = CGRectGetMinX(aRect),
1333 maxX = CGRectGetMaxX(aRect),
1334 minY = CGRectGetMinY(aRect),
1335 maxY = CGRectGetMaxY(aRect);
1365 var rect = CGRectOffset(aRect, 1.0, 1.0);
1367 rect.size.width -= 1.0;
1368 rect.size.height -= 1.0;
1388 if (_timerScrollersHide)
1389 [_timerScrollersHide invalidate];
1390 if (![_verticalScroller isHidden])
1391 [_verticalScroller fadeIn];
1392 if (![_horizontalScroller isHidden])
1393 [_horizontalScroller fadeIn];
1394 if (![_horizontalScroller isHidden] || ![_verticalScroller isHidden])
1397 [
self _respondToScrollWheelEventWithDeltaX:[anEvent deltaX] deltaY:[anEvent deltaY]];
1400 - (void)scrollPageUp:(
id)sender
1402 var contentBounds = [_contentView bounds];
1403 [
self moveByOffset:CGSizeMake(0.0, -(CGRectGetHeight(contentBounds) - _verticalPageScroll))];
1406 - (void)scrollPageDown:(
id)sender
1408 var contentBounds = [_contentView bounds];
1409 [
self moveByOffset:CGSizeMake(0.0, CGRectGetHeight(contentBounds) - _verticalPageScroll)];
1412 - (void)scrollToBeginningOfDocument:(
id)sender
1414 [_contentView scrollToPoint:CGPointMakeZero()];
1415 [_headerClipView scrollToPoint:CGPointMakeZero()];
1418 - (void)scrollToEndOfDocument:(
id)sender
1420 var contentBounds = [_contentView bounds],
1422 scrollPoint = CGPointMake(0.0, CGRectGetHeight(documentFrame) - CGRectGetHeight(contentBounds));
1424 [_contentView scrollToPoint:scrollPoint];
1425 [_headerClipView scrollToPoint:CGPointMakeZero()];
1428 - (void)moveLeft:(
id)sender
1430 [
self moveByOffset:CGSizeMake(-_horizontalLineScroll, 0.0)];
1433 - (void)moveRight:(
id)sender
1435 [
self moveByOffset:CGSizeMake(_horizontalLineScroll, 0.0)];
1438 - (void)moveUp:(
id)sender
1440 [
self moveByOffset:CGSizeMake(0.0, -_verticalLineScroll)];
1443 - (void)moveDown:(
id)sender
1445 [
self moveByOffset:CGSizeMake(0.0, _verticalLineScroll)];
1448 - (void)moveByOffset:(CGSize)aSize
1451 contentBounds = [_contentView bounds];
1453 contentBounds.origin.x += aSize.width;
1454 contentBounds.origin.y += aSize.height;
1456 [_contentView scrollToPoint:contentBounds.origin];
1457 [_headerClipView scrollToPoint:CGPointMake(contentBounds.origin.x, 0)];
1484 if (
self = [super initWithCoder:aCoder])
1486 _verticalLineScroll = [aCoder decodeFloatForKey:CPScrollViewVLineScrollKey];
1487 _verticalPageScroll = [aCoder decodeFloatForKey:CPScrollViewVPageScrollKey];
1489 _horizontalLineScroll = [aCoder decodeFloatForKey:CPScrollViewHLineScrollKey];
1490 _horizontalPageScroll = [aCoder decodeFloatForKey:CPScrollViewHPageScrollKey];
1492 _contentView = [aCoder decodeObjectForKey:CPScrollViewContentViewKey];
1493 _headerClipView = [aCoder decodeObjectForKey:CPScrollViewHeaderClipViewKey];
1495 if (!_headerClipView)
1498 [
self addSubview:_headerClipView];
1501 _verticalScroller = [aCoder decodeObjectForKey:CPScrollViewVScrollerKey];
1502 _horizontalScroller = [aCoder decodeObjectForKey:CPScrollViewHScrollerKey];
1504 _hasVerticalScroller = [aCoder decodeBoolForKey:CPScrollViewHasVScrollerKey];
1505 _hasHorizontalScroller = [aCoder decodeBoolForKey:CPScrollViewHasHScrollerKey];
1506 _autohidesScrollers = [aCoder decodeBoolForKey:CPScrollViewAutohidesScrollerKey];
1508 _borderType = [aCoder decodeIntForKey:CPScrollViewBorderTypeKey];
1510 _cornerView = [aCoder decodeObjectForKey:CPScrollViewCornerViewKey];
1511 _bottomCornerView = [aCoder decodeObjectForKey:CPScrollViewBottomCornerViewKey];
1515 _implementedDelegateMethods = 0;
1522 name:CPScrollerStyleGlobalChangeNotification
1532 - (void)awakeFromCib
1534 [
self _updateScrollerStyle];
1535 [
self _updateCornerAndHeaderView];
1540 [
super encodeWithCoder:aCoder];
1542 [aCoder encodeObject:_contentView forKey:CPScrollViewContentViewKey];
1543 [aCoder encodeObject:_headerClipView forKey:CPScrollViewHeaderClipViewKey];
1545 [aCoder encodeObject:_verticalScroller forKey:CPScrollViewVScrollerKey];
1546 [aCoder encodeObject:_horizontalScroller forKey:CPScrollViewHScrollerKey];
1548 [aCoder encodeFloat:_verticalLineScroll forKey:CPScrollViewVLineScrollKey];
1549 [aCoder encodeFloat:_verticalPageScroll forKey:CPScrollViewVPageScrollKey];
1550 [aCoder encodeFloat:_horizontalLineScroll forKey:CPScrollViewHLineScrollKey];
1551 [aCoder encodeFloat:_horizontalPageScroll forKey:CPScrollViewHPageScrollKey];
1553 [aCoder encodeBool:_hasVerticalScroller forKey:CPScrollViewHasVScrollerKey];
1554 [aCoder encodeBool:_hasHorizontalScroller forKey:CPScrollViewHasHScrollerKey];
1555 [aCoder encodeBool:_autohidesScrollers forKey:CPScrollViewAutohidesScrollerKey];
1557 [aCoder encodeObject:_cornerView forKey:CPScrollViewCornerViewKey];
1558 [aCoder encodeObject:_bottomCornerView forKey:CPScrollViewBottomCornerViewKey];
1560 [aCoder encodeInt:_borderType forKey:CPScrollViewBorderTypeKey];
1562 [aCoder encodeInt:_scrollerStyle forKey:CPScrollViewScrollerStyleKey];
1563 [aCoder encodeInt:_scrollerKnobStyle forKey:CPScrollViewScrollerKnobStyleKey];