28 #define SHOULD_SHOW_CORNER_VIEW() (_scrollerStyle === CPScrollerStyleLegacy && _verticalScroller && ![_verticalScroller isHidden]) 41 var _isBrowserUsingOverlayScrollers =
function()
56 var outer = document.createElement(
'div'),
57 inner = document.createElement(
'p');
60 outer.style.position =
"absolute";
61 outer.style.top =
"0px";
62 outer.style.left =
"0px";
63 outer.style.visibility =
"hidden";
64 outer.style.width =
"200px";
65 outer.style.height =
"150px";
66 outer.style.overflow =
"scroll";
68 inner.style.width =
"100%";
69 inner.style.height =
"200px";
70 outer.appendChild(inner);
72 document.body.appendChild(outer);
74 var usingOverlayScrollers = outer.clientWidth === outer.offsetWidth;
76 document.body.removeChild(outer);
78 return usingOverlayScrollers;
107 id <CPScrollViewDelegate> _delegate;
110 BOOL _hasVerticalScroller;
111 BOOL _hasHorizontalScroller;
112 BOOL _autohidesScrollers;
117 CPInteger _recursionCount;
118 CPInteger _implementedDelegateMethods;
120 float _verticalLineScroll;
121 float _verticalPageScroll;
122 float _horizontalLineScroll;
123 float _horizontalPageScroll;
125 CPBorderType _borderType;
130 int _scrollerKnobStyle;
135 #pragma mark Class methods 144 if (globalValue === nil || globalValue === -1)
163 + (CGSize)contentSizeForFrameSize:(CGSize)frameSize hasHorizontalScroller:(BOOL)hFlag hasVerticalScroller:(BOOL)vFlag borderType:(CPBorderType)borderType
165 var
bounds = [
self _insetBounds:CGRectMake(0.0, 0.0, frameSize.width, frameSize.height) borderType:borderType];
168 bounds.size.height -= [_horizontalScroller scrollerWidth];
171 bounds.size.width -= [_verticalScroller scrollerWidth];
176 + (CGSize)frameSizeForContentSize:(CGSize)contentSize hasHorizontalScroller:(BOOL)hFlag hasVerticalScroller:(BOOL)vFlag borderType:(CPBorderType)borderType
178 var
bounds = [
self _insetBounds:CGRectMake(0.0, 0.0, contentSize.width, contentSize.height) borderType:borderType],
179 widthInset = contentSize.width -
bounds.size.width,
180 heightInset = contentSize.height -
bounds.size.height,
181 frameSize = CGSizeMake(contentSize.width + widthInset, contentSize.height + heightInset);
184 frameSize.height += [_horizontalScroller scrollerWidth];
187 frameSize.width += [_verticalScroller scrollerWidth];
192 + (CGRect)_insetBounds:(CGRect)bounds borderType:(CPBorderType)borderType
198 return CGRectInset(
bounds, 1.0, 1.0);
215 + (int)globalScrollerStyle
225 + (void)setGlobalScrollerStyle:(
int)aStyle
233 #pragma mark Initialization 235 - (id)initWithFrame:(CGRect)aFrame
241 _verticalLineScroll = 10.0;
242 _verticalPageScroll = 10.0;
244 _horizontalLineScroll = 10.0;
245 _horizontalPageScroll = 10.0;
249 _contentView = [[
CPClipView alloc] initWithFrame:[
self _insetBounds]];
255 _bottomCornerView = [[
CPView alloc] init];
265 _implementedDelegateMethods = 0;
273 #pragma mark Getters / Setters 298 - (void)setDelegate:(
id <CPScrollViewDelegate>)aDelegate
300 if (aDelegate === _delegate)
303 _delegate = aDelegate;
304 _implementedDelegateMethods = 0;
306 if (_delegate === nil)
309 if ([_delegate respondsToSelector:
@selector(scrollViewWillScroll:)])
312 if ([_delegate respondsToSelector:
@selector(scrollViewDidScroll:)])
318 return _scrollerStyle;
327 - (void)setScrollerStyle:(
int)aStyle
329 if (_scrollerStyle === aStyle)
332 _scrollerStyle = aStyle;
334 [
self _updateScrollerStyle];
347 - (int)scrollerKnobStyle
349 return _scrollerKnobStyle;
362 - (void)setScrollerKnobStyle:(
int)newScrollerKnobStyle
364 if (_scrollerKnobStyle === newScrollerKnobStyle)
367 _scrollerKnobStyle = newScrollerKnobStyle;
369 [
self _updateScrollerStyle];
387 if (_contentView === aContentView || !aContentView)
395 [_contentView removeFromSuperview];
397 _contentView = aContentView;
399 [_contentView setDocumentView:documentView];
410 - (CGSize)contentSize
412 return [_contentView frame].size;
420 return [_contentView documentView];
430 [_contentView setDocumentView:aView];
433 [
self _updateCornerAndHeaderView];
440 - (CPBorderType)borderType
455 - (void)setBorderType:(CPBorderType)borderType
457 if (_borderType == borderType)
460 _borderType = borderType;
472 return _horizontalScroller;
482 if (_horizontalScroller === aScroller)
485 [_horizontalScroller removeFromSuperview];
486 [_horizontalScroller setTarget:nil];
487 [_horizontalScroller setAction:nil];
489 _horizontalScroller = aScroller;
491 [_horizontalScroller setTarget:self];
492 [_horizontalScroller setAction:@selector(_horizontalScrollerDidScroll:)];
496 [
self _updateScrollerStyle];
502 - (BOOL)hasHorizontalScroller
504 return _hasHorizontalScroller;
513 - (void)setHasHorizontalScroller:(BOOL)shouldHaveHorizontalScroller
515 if (_hasHorizontalScroller === shouldHaveHorizontalScroller)
518 _hasHorizontalScroller = shouldHaveHorizontalScroller;
520 if (_hasHorizontalScroller && !_horizontalScroller)
522 var
bounds = [
self _insetBounds];
524 [
self setHorizontalScroller:[[
CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, MAX(CGRectGetWidth(bounds), [_horizontalScroller scrollerWidth] + 1), [_horizontalScroller scrollerWidth])]];
536 return _verticalScroller;
546 if (_verticalScroller === aScroller)
549 [_verticalScroller removeFromSuperview];
550 [_verticalScroller setTarget:nil];
551 [_verticalScroller setAction:nil];
553 _verticalScroller = aScroller;
555 [_verticalScroller setTarget:self];
556 [_verticalScroller setAction:@selector(_verticalScrollerDidScroll:)];
560 [
self _updateScrollerStyle];
566 - (BOOL)hasVerticalScroller
568 return _hasVerticalScroller;
578 - (void)setHasVerticalScroller:(BOOL)shouldHaveVerticalScroller
580 if (_hasVerticalScroller === shouldHaveVerticalScroller)
583 _hasVerticalScroller = shouldHaveVerticalScroller;
585 if (_hasVerticalScroller && !_verticalScroller)
587 var
bounds = [
self _insetBounds];
589 [
self setVerticalScroller:[[
CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, [_verticalScroller scrollerWidth], MAX(CGRectGetHeight(bounds), [_verticalScroller scrollerWidth] + 1))]];
599 - (BOOL)autohidesScrollers
601 return _autohidesScrollers;
610 - (void)setAutohidesScrollers:(BOOL)autohidesScrollers
612 if (_autohidesScrollers == autohidesScrollers)
615 _autohidesScrollers = autohidesScrollers;
622 return _bottomCornerView;
625 - (void)setBottomCornerView:(
CPView)aBottomCornerView
627 if (_bottomCornerView === aBottomCornerView)
630 [_bottomCornerView removeFromSuperview];
632 [aBottomCornerView
setFrame:[
self _bottomCornerViewFrame]];
635 _bottomCornerView = aBottomCornerView;
637 [
self _updateCornerAndHeaderView];
653 - (void)setLineScroll:(
float)aLineScroll
662 - (float)horizontalLineScroll
664 return _horizontalLineScroll;
672 - (void)setHorizontalLineScroll:(
float)aLineScroll
674 _horizontalLineScroll = aLineScroll;
680 - (float)verticalLineScroll
682 return _verticalLineScroll;
690 - (void)setVerticalLineScroll:(
float)aLineScroll
692 _verticalLineScroll = aLineScroll;
708 - (void)setPageScroll:(
float)aPageScroll
717 - (float)horizontalPageScroll
719 return _horizontalPageScroll;
727 - (void)setHorizontalPageScroll:(
float)aPageScroll
729 _horizontalPageScroll = aPageScroll;
735 - (float)verticalPageScroll
737 return _verticalPageScroll;
745 - (void)setVerticalPageScroll:(
float)aPageScroll
747 _verticalPageScroll = aPageScroll;
752 #pragma mark Privates 755 - (void)_updateScrollerStyle
757 if (_hasHorizontalScroller)
759 [_horizontalScroller setStyle:_scrollerStyle];
760 [_horizontalScroller unsetThemeState:CPThemeStateSelected];
762 switch (_scrollerKnobStyle)
765 [_horizontalScroller unsetThemeState:CPThemeStateScrollerKnobDark];
766 [_horizontalScroller setThemeState:CPThemeStateScrollerKnobLight];
770 [_horizontalScroller unsetThemeState:CPThemeStateScrollerKnobLight];
771 [_horizontalScroller setThemeState:CPThemeStateScrollerKnobDark];
775 [_horizontalScroller unsetThemeState:CPThemeStateScrollerKnobLight];
776 [_horizontalScroller unsetThemeState:CPThemeStateScrollerKnobDark];
780 if (_hasVerticalScroller)
782 [_verticalScroller setStyle:_scrollerStyle];
783 [_verticalScroller unsetThemeState:CPThemeStateSelected];
785 switch (_scrollerKnobStyle)
788 [_verticalScroller unsetThemeState:CPThemeStateScrollerKnobDark];
789 [_verticalScroller setThemeState:CPThemeStateScrollerKnobLight];
793 [_verticalScroller unsetThemeState:CPThemeStateScrollerKnobLight];
794 [_verticalScroller setThemeState:CPThemeStateScrollerKnobDark];
798 [_verticalScroller unsetThemeState:CPThemeStateScrollerKnobLight];
799 [_verticalScroller unsetThemeState:CPThemeStateScrollerKnobDark];
805 if (_timerScrollersHide)
806 [_timerScrollersHide invalidate];
809 [[
self bottomCornerView] setHidden:YES];
812 [[
self bottomCornerView] setHidden:NO];
814 [
self reflectScrolledClipView:_contentView];
818 - (CGRect)_insetBounds
820 return [[
self class] _insetBounds:[
self bounds] borderType:_borderType];
824 - (void)_updateCornerAndHeaderView
826 var documentView = [
self documentView],
827 currentHeaderView = [
self _headerView],
828 documentHeaderView = [documentView respondsToSelector:@selector(headerView)] ? [documentView headerView] : nil;
830 if (currentHeaderView !== documentHeaderView)
832 [currentHeaderView removeFromSuperview];
833 [_headerClipView setDocumentView:documentHeaderView];
836 var documentCornerView = [documentView respondsToSelector:@selector(cornerView)] ? [documentView cornerView] : nil;
838 if (_cornerView !== documentCornerView)
840 [_cornerView removeFromSuperview];
842 _cornerView = documentCornerView;
846 [_cornerView setHidden:!SHOULD_SHOW_CORNER_VIEW()];
847 [
self addSubview:_cornerView];
851 [
self reflectScrolledClipView:_contentView];
852 [documentHeaderView setNeedsLayout];
853 [documentHeaderView setNeedsDisplay:YES];
859 return [_headerClipView documentView];
863 - (CGRect)_cornerViewFrame
866 return CGRectMakeZero();
868 var
bounds = [
self _insetBounds],
869 frame = [_cornerView frame];
878 - (CGRect)_headerClipViewFrame
880 var headerView = [
self _headerView];
883 return CGRectMakeZero();
885 var
frame = [
self _insetBounds];
887 frame.size.height = CGRectGetHeight([headerView
frame]);
890 frame.size.width -= CGRectGetWidth([self _cornerViewFrame]);
896 - (CGRect)_bottomCornerViewFrame
898 if ([[
self horizontalScroller]
isHidden] || [[
self verticalScroller]
isHidden])
899 return CGRectMakeZero();
901 var verticalFrame = [[
self verticalScroller] frame],
902 bottomCornerFrame = CGRectMakeZero();
904 bottomCornerFrame.origin.x = CGRectGetMinX(verticalFrame);
905 bottomCornerFrame.origin.y = CGRectGetMaxY(verticalFrame);
906 bottomCornerFrame.size.width = [_verticalScroller scrollerWidth];
907 bottomCornerFrame.size.height = [_horizontalScroller scrollerWidth];
909 return bottomCornerFrame;
913 - (void)_verticalScrollerDidScroll:(
CPScroller)aScroller
916 documentFrame = [[_contentView documentView] frame],
917 contentBounds = [_contentView bounds];
920 switch ([_verticalScroller hitPart])
923 contentBounds.origin.y -= _verticalLineScroll;
927 contentBounds.origin.y += _verticalLineScroll;
931 contentBounds.origin.y -= CGRectGetHeight(contentBounds) - _verticalPageScroll;
935 contentBounds.origin.y += CGRectGetHeight(contentBounds) - _verticalPageScroll;
942 contentBounds.origin.y = ROUND(value * (CGRectGetHeight(documentFrame) - CGRectGetHeight(contentBounds)));
945 [
self _sendDelegateMessages];
947 [_contentView scrollToPoint:contentBounds.origin];
951 - (void)_horizontalScrollerDidScroll:(
CPScroller)aScroller
954 documentFrame = [[
self documentView] frame],
955 contentBounds = [_contentView bounds];
957 switch ([_horizontalScroller hitPart])
960 contentBounds.origin.x -= _horizontalLineScroll;
964 contentBounds.origin.x += _horizontalLineScroll;
968 contentBounds.origin.x -= CGRectGetWidth(contentBounds) - _horizontalPageScroll;
972 contentBounds.origin.x += CGRectGetWidth(contentBounds) - _horizontalPageScroll;
979 contentBounds.origin.x = ROUND(value * (CGRectGetWidth(documentFrame) - CGRectGetWidth(contentBounds)));
982 [
self _sendDelegateMessages];
984 [_contentView scrollToPoint:contentBounds.origin];
985 [_headerClipView scrollToPoint:CGPointMake(contentBounds.origin.x, 0.0)];
989 - (void)_sendDelegateMessages
991 if (_implementedDelegateMethods == 0)
996 [
self _scrollViewWillScroll];
1004 - (void)_hideScrollers:(
CPTimer)theTimer
1006 if ([_verticalScroller allowFadingOut])
1007 [_verticalScroller fadeOut];
1008 if ([_horizontalScroller allowFadingOut])
1009 [_horizontalScroller fadeOut];
1010 _timerScrollersHide = nil;
1014 - (void)_respondToScrollWheelEventWithDeltaX:(
float)deltaX deltaY:(
float)deltaY
1016 var documentFrame = [[
self documentView] frame],
1017 contentBounds = [_contentView bounds],
1018 contentFrame = [_contentView frame],
1019 enclosingScrollView = [
self enclosingScrollView];
1022 contentBounds.origin.x = ROUND(contentBounds.origin.x + deltaX);
1023 contentBounds.origin.y = ROUND(contentBounds.origin.y + deltaY);
1025 var constrainedOrigin = [_contentView constrainScrollPoint:CGPointCreateCopy(contentBounds.origin)],
1026 extraX = contentBounds.origin.x - constrainedOrigin.x,
1027 extraY = contentBounds.origin.y - constrainedOrigin.y;
1029 [
self _sendDelegateMessages];
1031 [_contentView scrollToPoint:constrainedOrigin];
1032 [_headerClipView scrollToPoint:CGPointMake(constrainedOrigin.x, 0.0)];
1034 if (extraX || extraY)
1035 [enclosingScrollView _respondToScrollWheelEventWithDeltaX:extraX deltaY:extraY];
1039 - (void)_scrollViewWillScroll
1042 [_delegate scrollViewWillScroll:self];
1046 - (void)_scrollViewDidScroll
1048 [_scrollTimer invalidate];
1052 [_delegate scrollViewDidScroll:self];
1056 - (void)_didReceiveDefaultStyleChange:(
CPNotification)aNotification
1058 [
self setScrollerStyle:CPScrollerStyleGlobal];
1064 #pragma mark Utilities 1084 if (_contentView !== aClipView)
1087 if (_recursionCount > 5)
1096 if (_autohidesScrollers)
1098 [_verticalScroller setHidden:YES];
1099 [_horizontalScroller setHidden:YES];
1102 [_contentView setFrame:[
self _insetBounds]];
1103 [_headerClipView setFrame:CGRectMakeZero()];
1110 var documentFrame = [documentView frame],
1111 contentFrame = [
self _insetBounds],
1112 headerClipViewFrame = [
self _headerClipViewFrame],
1113 headerClipViewHeight = CGRectGetHeight(headerClipViewFrame);
1115 contentFrame.origin.y += headerClipViewHeight;
1116 contentFrame.size.height -= headerClipViewHeight;
1118 var difference = CGSizeMake(CGRectGetWidth(documentFrame) - CGRectGetWidth(contentFrame), CGRectGetHeight(documentFrame) - CGRectGetHeight(contentFrame)),
1119 verticalScrollerWidth = [_verticalScroller scrollerWidth],
1120 horizontalScrollerHeight = [_horizontalScroller scrollerWidth],
1121 hasVerticalScroll = difference.height > 0.0,
1122 hasHorizontalScroll = difference.width > 0.0,
1123 shouldShowVerticalScroller = _hasVerticalScroller && (!_autohidesScrollers || hasVerticalScroll),
1124 shouldShowHorizontalScroller = _hasHorizontalScroller && (!_autohidesScrollers || hasHorizontalScroll);
1127 if (shouldShowVerticalScroller)
1130 difference.width += verticalScrollerWidth;
1131 hasHorizontalScroll = difference.width > 0.0;
1132 shouldShowHorizontalScroller = _hasHorizontalScroller && (!_autohidesScrollers || hasHorizontalScroll);
1135 if (shouldShowHorizontalScroller)
1138 difference.height += horizontalScrollerHeight;
1139 hasVerticalScroll = difference.height > 0.0;
1140 shouldShowVerticalScroller = _hasVerticalScroller && (!_autohidesScrollers || hasVerticalScroll);
1144 [_verticalScroller setHidden:!shouldShowVerticalScroller];
1145 [_verticalScroller setEnabled:hasVerticalScroll];
1147 [_horizontalScroller setHidden:!shouldShowHorizontalScroller];
1148 [_horizontalScroller setEnabled:hasHorizontalScroll];
1154 if (shouldShowVerticalScroller)
1155 contentFrame.size.width -= verticalScrollerWidth;
1157 if (shouldShowHorizontalScroller)
1158 contentFrame.size.height -= horizontalScrollerHeight;
1162 var scrollPoint = [_contentView bounds].origin,
1163 wasShowingVerticalScroller = ![_verticalScroller isHidden],
1164 wasShowingHorizontalScroller = ![_horizontalScroller isHidden];
1166 if (shouldShowVerticalScroller)
1168 var verticalScrollerY =
1169 MAX(CGRectGetMinY(contentFrame), MAX(CGRectGetMaxY([
self _cornerViewFrame]), CGRectGetMaxY(headerClipViewFrame)));
1171 var verticalScrollerHeight = CGRectGetMaxY(contentFrame) - verticalScrollerY;
1175 verticalScrollerHeight -= horizontalScrollerHeight;
1177 var documentHeight = CGRectGetHeight(documentFrame);
1178 [_verticalScroller setFloatValue:(difference.height <= 0.0) ? 0.0 : scrollPoint.y / difference.height];
1179 [_verticalScroller setKnobProportion:documentHeight > 0 ? CGRectGetHeight(contentFrame) / documentHeight : 1.0];
1180 [_verticalScroller setFrame:CGRectMake(CGRectGetMaxX(contentFrame) - overlay, verticalScrollerY, verticalScrollerWidth, verticalScrollerHeight)];
1182 else if (wasShowingVerticalScroller)
1184 [_verticalScroller setFloatValue:0.0];
1185 [_verticalScroller setKnobProportion:1.0];
1188 if (shouldShowHorizontalScroller)
1190 var horizontalScrollerWidth = CGRectGetWidth(contentFrame);
1193 horizontalScrollerWidth -= verticalScrollerWidth;
1195 var documentWidth = CGRectGetWidth(documentFrame);
1197 [_horizontalScroller setFloatValue:(difference.width <= 0.0) ? 0.0 : scrollPoint.x / difference.width];
1198 [_horizontalScroller setKnobProportion:documentWidth > 0 ? CGRectGetWidth(contentFrame) / documentWidth : 1.0];
1199 [_horizontalScroller setFrame:CGRectMake(CGRectGetMinX(contentFrame), CGRectGetMaxY(contentFrame) - overlay, horizontalScrollerWidth, horizontalScrollerHeight)];
1201 else if (wasShowingHorizontalScroller)
1203 [_horizontalScroller setFloatValue:0.0];
1204 [_horizontalScroller setKnobProportion:1.0];
1207 [_contentView setFrame:contentFrame];
1208 [_headerClipView setFrame:[
self _headerClipViewFrame]];
1209 [[_headerClipView documentView] setNeedsDisplay:YES];
1212 [_cornerView setFrame:[
self _cornerViewFrame]];
1213 [_cornerView setHidden:NO];
1216 [_cornerView setHidden:YES];
1230 - (void)flashScrollers
1235 if (_hasHorizontalScroller)
1237 [_horizontalScroller setHidden:NO];
1238 [_horizontalScroller fadeIn];
1241 if (_hasVerticalScroller)
1243 [_verticalScroller setHidden:NO];
1244 [_verticalScroller fadeIn];
1247 if (_timerScrollersHide)
1248 [_timerScrollersHide invalidate];
1254 - (void)resizeSubviewsWithOldSize:(CGSize)aSize
1259 - (CGRect)documentVisibleRect
1261 return [_contentView documentVisibleRect];
1265 #pragma mark Overrides 1268 - (void)_removeObservers
1274 name:CPScrollerStyleGlobalChangeNotification
1277 [
super _removeObservers];
1280 - (void)_addObservers
1286 [
self _didReceiveDefaultStyleChange:nil];
1290 name:CPScrollerStyleGlobalChangeNotification
1293 [
super _addObservers];
1298 - (void)drawRect:(CGRect)aRect
1305 var strokeRect = [
self bounds],
1310 switch (_borderType)
1318 [
self _drawGrayBezelInContext:context bounds:strokeRect];
1322 [
self _drawGrooveInContext:context bounds:strokeRect];
1330 - (void)_drawGrayBezelInContext:(CGContext)context bounds:(CGRect)aRect
1332 var minX = CGRectGetMinX(aRect),
1333 maxX = CGRectGetMaxX(aRect),
1334 minY = CGRectGetMinY(aRect),
1335 maxY = CGRectGetMaxY(aRect),
1364 - (void)_drawGrooveInContext:(CGContext)context bounds:(CGRect)aRect
1366 var minX = CGRectGetMinX(aRect),
1367 maxX = CGRectGetMaxX(aRect),
1368 minY = CGRectGetMinY(aRect),
1369 maxY = CGRectGetMaxY(aRect);
1399 var rect = CGRectOffset(aRect, 1.0, 1.0);
1401 rect.size.width -= 1.0;
1402 rect.size.height -= 1.0;
1422 if (_timerScrollersHide)
1423 [_timerScrollersHide invalidate];
1425 [_verticalScroller fadeIn];
1426 if (![_horizontalScroller
isHidden])
1427 [_horizontalScroller fadeIn];
1434 if (![anEvent hasPreciseScrollingDeltas])
1436 deltaX *= (_horizontalLineScroll || 1.0);
1437 deltaY *= (_verticalLineScroll || 1.0);
1440 [
self _respondToScrollWheelEventWithDeltaX:deltaX deltaY:deltaY];
1443 - (void)scrollPageUp:(
id)sender
1445 var contentBounds = [_contentView bounds];
1446 [
self moveByOffset:CGSizeMake(0.0, -(CGRectGetHeight(contentBounds) - _verticalPageScroll))];
1449 - (void)scrollPageDown:(
id)sender
1451 var contentBounds = [_contentView bounds];
1452 [
self moveByOffset:CGSizeMake(0.0, CGRectGetHeight(contentBounds) - _verticalPageScroll)];
1455 - (void)scrollToBeginningOfDocument:(
id)sender
1457 [_contentView scrollToPoint:CGPointMakeZero()];
1458 [_headerClipView scrollToPoint:CGPointMakeZero()];
1461 - (void)scrollToEndOfDocument:(
id)sender
1463 var contentBounds = [_contentView bounds],
1465 scrollPoint = CGPointMake(0.0, CGRectGetHeight(documentFrame) - CGRectGetHeight(contentBounds));
1467 [_contentView scrollToPoint:scrollPoint];
1468 [_headerClipView scrollToPoint:CGPointMakeZero()];
1471 - (void)moveLeft:(
id)sender
1473 [
self moveByOffset:CGSizeMake(-_horizontalLineScroll, 0.0)];
1476 - (void)moveRight:(
id)sender
1478 [
self moveByOffset:CGSizeMake(_horizontalLineScroll, 0.0)];
1481 - (void)moveUp:(
id)sender
1483 [
self moveByOffset:CGSizeMake(0.0, -_verticalLineScroll)];
1486 - (void)moveDown:(
id)sender
1488 [
self moveByOffset:CGSizeMake(0.0, _verticalLineScroll)];
1491 - (void)moveByOffset:(CGSize)aSize
1494 contentBounds = [_contentView bounds];
1496 contentBounds.origin.x += aSize.width;
1497 contentBounds.origin.y += aSize.height;
1499 [_contentView scrollToPoint:contentBounds.origin];
1500 [_headerClipView scrollToPoint:CGPointMake(contentBounds.origin.x, 0)];
1515 [
self _stopObservingFirstResponderForWindow:[
self window]];
1518 [
self _startObservingFirstResponderForWindow:aWindow];
1521 - (void)_startObservingFirstResponderForWindow:(
CPWindow)aWindow
1526 - (void)_stopObservingFirstResponderForWindow:(
CPWindow)aWindow
1533 var responder = [[
self window] firstResponder],
1535 shouldAddFocusRing = [responder isKindOfClass:[
CPTableView class]],
1538 while (!(found = (responder ===
self)) && responder)
1539 responder = [responder superview];
1541 if (found && shouldAddFocusRing)
1542 [
self setThemeState:CPThemeStateFirstResponder];
1544 [
self unsetThemeState:CPThemeStateFirstResponder];
1572 if (
self = [super initWithCoder:aCoder])
1574 _verticalLineScroll = [aCoder decodeFloatForKey:CPScrollViewVLineScrollKey];
1575 _verticalPageScroll = [aCoder decodeFloatForKey:CPScrollViewVPageScrollKey];
1577 _horizontalLineScroll = [aCoder decodeFloatForKey:CPScrollViewHLineScrollKey];
1578 _horizontalPageScroll = [aCoder decodeFloatForKey:CPScrollViewHPageScrollKey];
1580 _contentView = [aCoder decodeObjectForKey:CPScrollViewContentViewKey];
1581 _headerClipView = [aCoder decodeObjectForKey:CPScrollViewHeaderClipViewKey];
1583 if (!_headerClipView)
1589 _verticalScroller = [aCoder decodeObjectForKey:CPScrollViewVScrollerKey];
1590 _horizontalScroller = [aCoder decodeObjectForKey:CPScrollViewHScrollerKey];
1592 _hasVerticalScroller = [aCoder decodeBoolForKey:CPScrollViewHasVScrollerKey];
1593 _hasHorizontalScroller = [aCoder decodeBoolForKey:CPScrollViewHasHScrollerKey];
1594 _autohidesScrollers = [aCoder decodeBoolForKey:CPScrollViewAutohidesScrollerKey];
1596 _borderType = [aCoder decodeIntForKey:CPScrollViewBorderTypeKey];
1598 _cornerView = [aCoder decodeObjectForKey:CPScrollViewCornerViewKey];
1599 _bottomCornerView = [aCoder decodeObjectForKey:CPScrollViewBottomCornerViewKey];
1603 _implementedDelegateMethods = 0;
1610 name:CPScrollerStyleGlobalChangeNotification
1620 - (void)awakeFromCib
1622 [
super awakeFromCib];
1624 [
self _updateScrollerStyle];
1625 [
self _updateCornerAndHeaderView];
1632 [aCoder encodeObject:_contentView forKey:CPScrollViewContentViewKey];
1633 [aCoder encodeObject:_headerClipView forKey:CPScrollViewHeaderClipViewKey];
1635 [aCoder encodeObject:_verticalScroller forKey:CPScrollViewVScrollerKey];
1636 [aCoder encodeObject:_horizontalScroller forKey:CPScrollViewHScrollerKey];
1638 [aCoder encodeFloat:_verticalLineScroll forKey:CPScrollViewVLineScrollKey];
1639 [aCoder encodeFloat:_verticalPageScroll forKey:CPScrollViewVPageScrollKey];
1640 [aCoder encodeFloat:_horizontalLineScroll forKey:CPScrollViewHLineScrollKey];
1641 [aCoder encodeFloat:_horizontalPageScroll forKey:CPScrollViewHPageScrollKey];
1643 [aCoder encodeBool:_hasVerticalScroller forKey:CPScrollViewHasVScrollerKey];
1644 [aCoder encodeBool:_hasHorizontalScroller forKey:CPScrollViewHasHScrollerKey];
1645 [aCoder encodeBool:_autohidesScrollers forKey:CPScrollViewAutohidesScrollerKey];
1647 [aCoder encodeObject:_cornerView forKey:CPScrollViewCornerViewKey];
1648 [aCoder encodeObject:_bottomCornerView forKey:CPScrollViewBottomCornerViewKey];
1650 [aCoder encodeInt:_borderType forKey:CPScrollViewBorderTypeKey];
1652 [aCoder encodeInt:_scrollerStyle forKey:CPScrollViewScrollerStyleKey];
1653 [aCoder encodeInt:_scrollerKnobStyle forKey:CPScrollViewScrollerKnobStyleKey];
id initWithFrame:(CGRect aFrame)
void addSubview:(CPView aSubview)
void drawRect:(CGRect aRect)
A representation of a single point in time.
CPGraphicsContext currentContext()
function CGContextSetStrokeColor(aContext, aColor)
void addObserver:selector:name:object:(id anObserver, [selector] SEL aSelector, [name] CPString aNotificationName, [object] id anObject)
void setFrame:(CGRect aFrame)
void postNotificationName:object:(CPString aNotificationName, [object] id anObject)
void viewWillMoveToWindow:(CPWindow aWindow)
function CGContextAddLineToPoint(aContext, x, y)
function CGContextStrokePath(aContext)
CPNotificationCenter defaultCenter()
A mutable key-value pair collection.
function CGContextSetLineWidth(aContext, aLineWidth)
An immutable string (collection of characters).
void setNeedsDisplay:(BOOL aFlag)
void encodeWithCoder:(CPCoder aCoder)
function CGContextBeginPath(aContext)
A notification that can be posted to a CPNotificationCenter.
CPTimer scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:(CPTimeInterval seconds, [target] id aTarget, [selector] SEL aSelector, [userInfo] id userInfo, [repeats] BOOL shouldRepeat)
A timer object that can send a message after the given time interval.
id objectForInfoDictionaryKey:(CPString aKey)
Defines methods for use when archiving & restoring (enc/decoding).
function CGContextStrokeRect(aContext, aRect)
Sends messages (CPNotification) between objects.
void setBackgroundColor:(CPColor aColor)
void removeObserver:name:object:(id anObserver, [name] CPString aNotificationName, [object] id anObject)
id dateWithTimeIntervalSinceNow:(CPTimeInterval seconds)
function CGContextMoveToPoint(aContext, x, y)