Fixed: -moveColumn:to: now preserve selected columns

Fixed: Starting a column drag is now faster.
Fixed: When dragging a selected column, selection is now drawn on the dragging view and the cursor is the closed hand.
Fixed: When dragging a table column, underlying columns were sliding according to the tracking location instead of the column lateral edges.
Fixed: In CPTableView, the drop indicator for rows could appear when dragging a column.

This commit creates directly the dragging column instead of relying on
built-in drag&drop. Also fixes a bug where the drop indicator would appear when
dragging a column if some rows were previously drag&dropped.
This commit is contained in:
cacaodev
2013-04-01 20:08:37 +02:00
parent a4bf6c1f7a
commit 984c7a67f5
4 changed files with 537 additions and 418 deletions
+401 -348
View File
@@ -20,19 +20,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/CPIndexSet.j>
@import "CPCursor.j"
@import "CPPasteboard.j"
@import "CPTableColumn.j"
@import "CPTableView.j"
@import "CPView.j"
@import "CPCursor.j"
@import "_CPImageAndTextView.j"
@class CPTableView
@global CPApp
@implementation _CPTableColumnHeaderView : CPView
{
_CPImageAndTextView _textField;
@@ -69,13 +64,18 @@
- (void)_init
{
_textField = [[_CPImageAndTextView alloc] initWithFrame:CGRectMakeZero()];
_textField = [[_CPImageAndTextView alloc] initWithFrame:
CGRectMake(5.0, 0.0, CGRectGetWidth([self bounds]) - 10.0, CGRectGetHeight([self bounds]))];
[_textField setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[_textField setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
[_textField setLineBreakMode:CPLineBreakByTruncatingTail];
[_textField setTextColor:[CPColor colorWithRed:51.0 / 255.0 green:51.0 / 255.0 blue:51.0 / 255.0 alpha:1.0]];
[_textField setFont:[CPFont boldSystemFontOfSize:12.0]];
[_textField setAlignment:CPLeftTextAlignment];
[_textField setVerticalAlignment:CPCenterVerticalTextAlignment];
[_textField setTextShadowColor:[CPColor whiteColor]];
[_textField setTextShadowOffset:CGSizeMake(0,1)];
[self addSubview:_textField];
}
@@ -168,26 +168,49 @@
- (void)_setIndicatorImage:(CPImage)anImage
{
if (anImage)
{
[_textField setImage:anImage];
[_textField setImagePosition:CPImageRight];
}
else
{
[_textField setImagePosition:CPNoImage];
}
if (anImage)
{
[_textField setImage:anImage];
[_textField setImagePosition:CPImageRight];
}
else
{
[_textField setImagePosition:CPNoImage];
}
}
- (CPImage)_indicatorImage
{
return [_textField imagePosition] === CPNoImage ? nil : [_textField image];
}
- (void)drawRect:(CGRect)aRect
{
var bounds = [self bounds];
if (!CGRectIntersectsRect(aRect, bounds))
return;
var context = [[CPGraphicsContext currentContext] graphicsPort],
maxX = CGRectGetMaxX(bounds) - 0.5;
CGContextSetLineWidth(context, 1);
CGContextSetStrokeColor(context, [CPColor colorWithWhite:192.0/255.0 alpha:1.0]);
CGContextBeginPath(context);
CGContextMoveToPoint(context, maxX, CGRectGetMinY(bounds));
CGContextAddLineToPoint(context, maxX, CGRectGetMaxY(bounds));
CGContextStrokePath(context);
}
@end
var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringValueKey",
_CPTableColumnHeaderViewFontKey = @"_CPTableColumnHeaderViewFontKey",
_CPTableColumnHeaderViewTextColorKey = @"_CPTableColumnHeaderViewTextColorKey",
_CPTableColumnHeaderViewTextShadowColorKey = @"_CPTableColumnHeaderViewTextShadowColorKey",
_CPTableColumnHeaderViewAlignmentKey = @"_CPTableColumnHeaderViewAlignmentKey",
_CPTableColumnHeaderViewLineBreakModeKey = @"_CPTableColumnHeaderViewLineBreakModeKey",
_CPTableColumnHeaderViewImageKey = @"_CPTableColumnHeaderViewImageKey";
_CPTableColumnHeaderViewIsDraggingKey = @"_CPTableColumnHeaderViewIsDraggingKey";
@implementation _CPTableColumnHeaderView (CPCoding)
@@ -199,10 +222,7 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
[self _setIndicatorImage:[aCoder decodeObjectForKey:_CPTableColumnHeaderViewImageKey]];
[self setStringValue:[aCoder decodeObjectForKey:_CPTableColumnHeaderViewStringValueKey]];
[self setFont:[aCoder decodeObjectForKey:_CPTableColumnHeaderViewFontKey]];
[self setTextColor:[aCoder decodeObjectForKey:_CPTableColumnHeaderViewTextColorKey]];
[self setTextShadowColor:[aCoder decodeObjectForKey:_CPTableColumnHeaderViewTextShadowColorKey]];
[self setAlignment:[aCoder decodeIntForKey:_CPTableColumnHeaderViewAlignmentKey]];
[self setLineBreakMode:[aCoder decodeIntForKey:_CPTableColumnHeaderViewLineBreakModeKey]];
[self setFont:[aCoder decodeObjectForKey:_CPTableColumnHeaderViewFontKey]];
}
return self;
@@ -214,30 +234,37 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
[aCoder encodeObject:[_textField text] forKey:_CPTableColumnHeaderViewStringValueKey];
[aCoder encodeObject:[_textField image] forKey:_CPTableColumnHeaderViewImageKey];
[aCoder encodeObject:[self font] forKey:_CPTableColumnHeaderViewFontKey];
[aCoder encodeObject:[self textColor] forKey:_CPTableColumnHeaderViewTextColorKey];
[aCoder encodeObject:[self textShadowColor] forKey:_CPTableColumnHeaderViewTextShadowColorKey];
[aCoder encodeInt:[self alignment] forKey:_CPTableColumnHeaderViewAlignmentKey];
[aCoder encodeInt:[self lineBreakMode] forKey:_CPTableColumnHeaderViewLineBreakModeKey];
[aCoder encodeObject:[_textField font] forKey:_CPTableColumnHeaderViewFontKey];
}
@end
CPTableHeaderViewDragColumnHeaderTag = 1;
var CPTableHeaderViewResizeZone = 3.0,
CPTableHeaderViewDragTolerance = 10.0;
@implementation CPTableHeaderView : CPView
{
CGPoint _mouseDownLocation;
CGPoint _previousTrackingLocation;
int _activeColumn;
int _pressedColumn;
CGPoint _mouseDownLocation;
CGPoint _columnMouseDownLocation;
CGPoint _mouseEnterExitLocation;
CGPoint _previousTrackingLocation;
BOOL _isResizing;
BOOL _isDragging;
BOOL _isTrackingColumn;
BOOL _drawsColumnLines;
int _activeColumn;
int _pressedColumn;
float _columnOldWidth;
BOOL _isResizing;
BOOL _isDragging;
BOOL _canDragColumn;
CPTableView _tableView @accessors(property=tableView);
CPView _columnDragView;
CPView _columnDragHeaderView;
CPView _columnDragClipView;
float _columnOldWidth;
CPTableView _tableView @accessors(property=tableView);
}
+ (CPString)defaultThemeClass
@@ -256,14 +283,16 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
- (void)_init
{
_mouseDownLocation = CGPointMakeZero();
_columnMouseDownLocation = CGPointMakeZero();
_mouseEnterExitLocation = CGPointMakeZero();
_previousTrackingLocation = CGPointMakeZero();
_activeColumn = -1;
_pressedColumn = -1;
_isResizing = NO;
_isDragging = NO;
_isTrackingColumn = NO;
_drawsColumnLines = YES;
_canDragColumn = NO;
_columnOldWidth = 0.0;
@@ -280,14 +309,39 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
return self;
}
- (int)columnAtPoint:(CGPoint)aPoint
// Checking Altered Columns
- (CPInteger)draggedColumn
{
return [_tableView columnAtPoint:CGPointMake(aPoint.x, aPoint.y)];
return _isDragging ? _activeColumn : -1;
}
- (CGRect)headerRectOfColumn:(int)aColumnIndex
- (float)draggedDistance
{
var headerRect = CGRectMakeCopy([self bounds]),
if (_isDragging)
return (CGRectGetMinX(_columnDragClipView) - _columnMouseDownLocation.x);
else
return -1;
}
- (CPInteger)resizedColumn
{
if (_isResizing)
return _activeColumn;
else
return -1;
}
// Utility Methods
- (CPInteger)columnAtPoint:(CGPoint)aPoint
{
return [_tableView columnAtPoint:aPoint];
}
- (CGRect)headerRectOfColumn:(CPInteger)aColumnIndex
{
var headerRect = [self bounds],
columnRect = [_tableView rectOfColumn:aColumnIndex];
headerRect.origin.x = CGRectGetMinX(columnRect);
@@ -296,31 +350,163 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
return headerRect;
}
- (void)setDrawsColumnLines:(BOOL)aFlag
// CPView Overrides
- (void)viewDidMoveToWindow
{
_drawsColumnLines = aFlag;
[super viewDidMoveToWindow];
[[self window] setAcceptsMouseMovedEvents:YES];
}
- (BOOL)drawsColumnLines
- (void)layoutSubviews
{
return _drawsColumnLines;
var tableColumns = [_tableView tableColumns],
count = [tableColumns count];
for (var i = 0; i < count; i++)
{
var column = [tableColumns objectAtIndex:i],
headerView = [column headerView],
frame = [self headerRectOfColumn:i];
[headerView setFrame:frame];
if ([headerView superview] != self)
[self addSubview:headerView];
}
}
- (CGRect)_cursorRectForColumn:(int)column
// CPResponder Overrides
- (void)mouseDown:(CPEvent)theEvent
{
var currentLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil],
adjustedLocation = CGPointMake(MAX(currentLocation.x - CPTableHeaderViewResizeZone, 0.0), currentLocation.y),
columnIndex = [self columnAtPoint:adjustedLocation];
if (columnIndex === -1)
return;
_mouseDownLocation = currentLocation;
_activeColumn = columnIndex;
_canDragColumn = YES;
[_tableView _sendDelegateDidMouseDownInHeader:columnIndex];
if ([self _shouldResizeTableColumn:columnIndex at:currentLocation])
[self _startResizingTableColumn:columnIndex at:currentLocation];
else
[self _setPressedColumn:columnIndex];
}
- (void)mouseDragged:(CPEvent)theEvent
{
var currentLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil],
adjustedLocation = CGPointMake(MAX(currentLocation.x - CPTableHeaderViewResizeZone, 0.0), currentLocation.y),
columnIndex = [self columnAtPoint:adjustedLocation];
if (_isResizing)
{
[self _autoscroll:theEvent localLocation:currentLocation];
[self _continueResizingTableColumn:_activeColumn at:currentLocation];
}
else if (_isDragging)
{
// Disable autoscrolling until it behaves correctly.
//[self _autoscroll:theEvent localLocation:currentLocation];
[self _dragTableColumn:_activeColumn to:currentLocation];
}
else // tracking a press, could become a drag
{
if (CGRectContainsPoint([self headerRectOfColumn:_activeColumn], currentLocation))
{
if ([self _shouldDragTableColumn:columnIndex at:currentLocation])
[self _startDraggingTableColumn:columnIndex at:currentLocation];
else
[self _setPressedColumn:_activeColumn];
}
else
[self _setPressedColumn:-1];
}
}
- (void)mouseUp:(CPEvent)theEvent
{
if (_isResizing)
{
[self _stopResizingTableColumn:_activeColumn];
}
else if (_isDragging)
{
[self _stopDraggingTableColumn:_activeColumn];
}
else if (_activeColumn != -1)
{
var currentLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil];
if (CGRectContainsPoint([self headerRectOfColumn:_activeColumn], currentLocation))
[_tableView _didClickTableColumn:_activeColumn modifierFlags:[theEvent modifierFlags]];
}
[self _setPressedColumn:-1];
[self _updateResizeCursor:[CPApp currentEvent]];
_activeColumn = -1;
}
- (void)mouseEntered:(CPEvent)theEvent
{
var location = [theEvent globalLocation];
if (CGPointEqualToPoint(location, _mouseEnterExitLocation))
return;
_mouseEnterExitLocation = location;
[self _updateResizeCursor:theEvent];
}
- (void)mouseMoved:(CPEvent)theEvent
{
[self _updateResizeCursor:theEvent];
}
- (void)mouseExited:(CPEvent)theEvent
{
var location = [theEvent globalLocation];
if (CGPointEqualToPoint(location, _mouseEnterExitLocation))
return;
_mouseEnterExitLocation = location;
// FIXME: we should use CPCursor push/pop (if previous currentCursor != arrow).
[[CPCursor arrowCursor] set];
}
@end
@implementation CPTableHeaderView (CPTableHeaderViewPrivate)
- (CGRect)_cursorRectForColumn:(CPInteger)column
{
if (column == -1 || !([_tableView._tableColumns[column] resizingMask] & CPTableColumnUserResizingMask))
return CGRectMakeZero();
var rect = [self headerRectOfColumn:column];
rect.origin.x = CGRectGetMaxX(rect) - 5;
rect.size.width = 20;
rect.origin.x = (CGRectGetMaxX(rect) - CPTableHeaderViewResizeZone) - 1.0;
rect.size.width = (CPTableHeaderViewResizeZone * 2.0) + 1.0; // + 1 for resize line
return rect;
}
- (void)_setPressedColumn:(CPInteger)column
{
if (_pressedColumn === column)
return;
if (_pressedColumn != -1)
{
var headerView = [_tableView._tableColumns[_pressedColumn] headerView];
@@ -331,131 +517,37 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
{
var headerView = [_tableView._tableColumns[column] headerView];
[headerView setThemeState:CPThemeStateHighlighted];
if (_tableView._editingColumn == column)
[[self window] makeFirstResponder:_tableView];
}
else
{
// Once the mouse leaves the pressed column, it can no longer drag
_canDragColumn = NO;
}
_pressedColumn = column;
}
- (void)mouseDown:(CPEvent)theEvent
- (BOOL)_shouldDragTableColumn:(CPInteger)aColumnIndex at:(CGPoint)aPoint
{
[self trackMouse:theEvent];
return _canDragColumn && [_tableView allowsColumnReordering] && ABS(aPoint.x - _mouseDownLocation.x) >= CPTableHeaderViewDragTolerance;
}
- (void)trackMouse:(CPEvent)theEvent
- (void)_autoscroll:(CPEvent)theEvent localLocation:(CGPoint)theLocation
{
var type = [theEvent type],
currentLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil];
// Constrain the y coordinate so we don't autoscroll vertically
var constrainedLocation = CGPointMake(theLocation.x, CGRectGetMinY([_tableView visibleRect])),
constrainedEvent = [CPEvent mouseEventWithType:CPLeftMouseDragged
location:[self convertPoint:constrainedLocation toView:nil]
modifierFlags:[theEvent modifierFlags]
timestamp:[theEvent timestamp]
windowNumber:[theEvent windowNumber]
context:nil
eventNumber:0
clickCount:[theEvent clickCount]
pressure:[theEvent pressure]];
// Take the right columns resize tracking area into account
currentLocation.x -= 5.0;
var columnIndex = [self columnAtPoint:currentLocation],
shouldResize = [self shouldResizeTableColumn:columnIndex at:CGPointMake(currentLocation.x + 5.0, currentLocation.y)];
if (type === CPLeftMouseUp)
{
if (shouldResize)
[self stopResizingTableColumn:_activeColumn at:currentLocation];
else if ([self _shouldStopTrackingTableColumn:columnIndex at:currentLocation])
{
[_tableView _didClickTableColumn:columnIndex modifierFlags:[theEvent modifierFlags]];
[self stopTrackingTableColumn:columnIndex at:currentLocation];
_isTrackingColumn = NO;
}
[self _updateResizeCursor:[CPApp currentEvent]];
_activeColumn = CPNotFound;
return;
}
if (type === CPLeftMouseDown)
{
if (columnIndex === -1)
return;
_mouseDownLocation = currentLocation;
_activeColumn = columnIndex;
[_tableView _sendDelegateDidMouseDownInHeader:columnIndex];
if (shouldResize)
[self startResizingTableColumn:columnIndex at:currentLocation];
else
{
[self startTrackingTableColumn:columnIndex at:currentLocation];
_isTrackingColumn = YES;
}
}
else if (type === CPLeftMouseDragged)
{
if (shouldResize)
[self continueResizingTableColumn:_activeColumn at:currentLocation];
else
{
if (_activeColumn === columnIndex && CGRectContainsPoint([self headerRectOfColumn:columnIndex], currentLocation))
{
if (_isTrackingColumn && _pressedColumn !== -1)
{
if (![self continueTrackingTableColumn:columnIndex at:currentLocation])
return; // Stop tracking the column, because it's being dragged
} else
[self startTrackingTableColumn:columnIndex at:currentLocation];
} else if (_isTrackingColumn && _pressedColumn !== -1)
[self stopTrackingTableColumn:_activeColumn at:currentLocation];
}
}
_previousTrackingLocation = currentLocation;
[CPApp setTarget:self selector:@selector(trackMouse:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES];
}
- (void)startTrackingTableColumn:(int)aColumnIndex at:(CGPoint)aPoint
{
[self _setPressedColumn:aColumnIndex];
}
- (BOOL)continueTrackingTableColumn:(int)aColumnIndex at:(CGPoint)aPoint
{
if ([self _shouldDragTableColumn:aColumnIndex at:aPoint])
{
var columnRect = [self headerRectOfColumn:aColumnIndex],
offset = CGPointMakeZero(),
view = [_tableView _dragViewForColumn:aColumnIndex event:[CPApp currentEvent] offset:offset],
viewLocation = CGPointMakeZero();
viewLocation.x = ( CGRectGetMinX(columnRect) + offset.x ) + ( aPoint.x - _mouseDownLocation.x );
viewLocation.y = CGRectGetMinY(columnRect) + offset.y;
[self dragView:view at:viewLocation offset:CGSizeMakeZero() event:[CPApp currentEvent]
pasteboard:[CPPasteboard pasteboardWithName:CPDragPboard] source:self slideBack:YES];
return NO;
}
return YES;
}
- (BOOL)_shouldStopTrackingTableColumn:(int)aColumnIndex at:(CGPoint)aPoint
{
return _isTrackingColumn && _activeColumn === aColumnIndex &&
CGRectContainsPoint([self headerRectOfColumn:aColumnIndex], aPoint);
}
- (void)stopTrackingTableColumn:(int)aColumnIndex at:(CGPoint)aPoint
{
[self _setPressedColumn:CPNotFound];
[self _updateResizeCursor:[CPApp currentEvent]];
}
- (BOOL)_shouldDragTableColumn:(int)aColumnIndex at:(CGPoint)aPoint
{
return [_tableView allowsColumnReordering] && ABS(aPoint.x - _mouseDownLocation.x) >= 10.0;
[self autoscroll:constrainedEvent];
[_tableView autoscroll:constrainedEvent];
}
- (CGRect)_headerRectOfLastVisibleColumn
@@ -474,143 +566,203 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
return nil;
}
- (void)_constrainDragView:(CPView)theDragView at:(CGPoint)aPoint
- (CGPoint)_constrainDragPoint:(CGPoint)aPoint
{
var tableColumns = [_tableView tableColumns],
// This effectively clamps the value between the minimum and maximum
var visibleRect = [_tableView visibleRect],
lastColumnRect = [self _headerRectOfLastVisibleColumn],
activeColumnRect = [self headerRectOfColumn:_activeColumn],
dragWindow = [theDragView window],
frame = [dragWindow frame];
maxX = CGRectGetMaxX(lastColumnRect) - CGRectGetWidth(activeColumnRect) - CGRectGetMinX(visibleRect),
point = CGPointMake(MAX(MIN(aPoint.x, maxX), -CGRectGetMinX(visibleRect)), aPoint.y);
// Convert the frame origin from the global coordinate system to the windows' coordinate system
frame.origin = [[self window] convertGlobalToBase:frame.origin];
// the from the window to the view
frame.origin = [self convertPoint:frame.origin fromView:nil];
// This effectively clamps the value between the minimum and maximum
frame.origin.x = MAX(0.0, MIN(CGRectGetMinX(frame), CGRectGetMaxX(lastColumnRect) - CGRectGetWidth(activeColumnRect)));
// Make sure the column cannot move vertically
frame.origin.y = CGRectGetMinY(lastColumnRect);
// Convert the calculated origin back to the window coordinate system
frame.origin = [self convertPoint:frame.origin toView:nil];
// Then back to the global coordinate system
frame.origin = [[self window] convertBaseToGlobal:frame.origin];
[dragWindow setFrame:frame];
return point;
}
- (void)_moveColumn:(int)aFromIndex toColumn:(int)aToIndex
- (void)_moveColumn:(CPInteger)aFromIndex toColumn:(CPInteger)aToIndex
{
[_tableView moveColumn:aFromIndex toColumn:aToIndex];
_activeColumn = aToIndex;
_pressedColumn = _activeColumn;
}
- (void)draggedView:(CPView)aView beganAt:(CGPoint)aPoint
{
_isDragging = YES;
var column = [[_tableView tableColumns] objectAtIndex:_activeColumn];
[[column headerView] setHidden:YES];
[_tableView _setDraggedColumn:column];
[_tableView _setDraggedColumn:_activeColumn];
[self setNeedsDisplay:YES];
}
- (void)draggedView:(CPView)aView movedTo:(CGPoint)aPoint
- (BOOL)isDragging
{
[self _constrainDragView:aView at:aPoint];
return _isDragging;
}
var dragWindow = [aView window],
dragWindowFrame = [dragWindow frame];
- (void)_startDraggingTableColumn:(CPInteger)aColumnIndex at:(CGPoint)aPoint
{
_isDragging = YES;
_columnDragView = [_tableView _dragViewForColumn:aColumnIndex];
_previousTrackingLocation = aPoint;
var hoverPoint = CGPointCreateCopy(aPoint);
// Create a new clip view for the drag view that clips to the header + visible content
var headerHeight = CGRectGetHeight([self frame]),
scrollView = [self enclosingScrollView],
contentFrame = [[scrollView contentView] frame];
if (aPoint.x < _previousTrackingLocation.x)
hoverPoint = CGPointMake(CGRectGetMinX(dragWindowFrame), CGRectGetMinY(dragWindowFrame));
else if (aPoint.x > _previousTrackingLocation.x)
hoverPoint = CGPointMake(CGRectGetMaxX(dragWindowFrame), CGRectGetMinY(dragWindowFrame));
contentFrame.origin.y -= headerHeight;
contentFrame.size.height += headerHeight;
// Convert the hover point from the global coordinate system to windows' coordinate system
hoverPoint = [[self window] convertGlobalToBase:hoverPoint];
// then to the view
hoverPoint = [self convertPoint:hoverPoint fromView:nil];
_columnDragClipView = [[CPView alloc] initWithFrame:contentFrame];
var hoveredColumn = [self columnAtPoint:hoverPoint];
[_columnDragClipView addSubview:_columnDragView];
if (hoveredColumn !== -1)
// Insert the clip view above the table header (and content)
[scrollView addSubview:_columnDragClipView positioned:CPWindowAbove relativeTo:self];
// Hide the underlying column header subviews, we just want to draw the chrome
var headerView = [[[_tableView tableColumns] objectAtIndex:aColumnIndex] headerView];
[[headerView subviews] makeObjectsPerformSelector:@selector(setHidden:) withObject:YES];
// The underlying column header shows normal state
[headerView unsetThemeState:CPThemeStateHighlighted | CPThemeStateSelected];
// Keep track of the location within the column header where the original mousedown occurred
_columnDragHeaderView = [_columnDragView viewWithTag:CPTableHeaderViewDragColumnHeaderTag];
_columnMouseDownLocation = [self convertPoint:_mouseDownLocation toView:_columnDragHeaderView];
[_tableView _setDraggedColumn:aColumnIndex];
[[CPCursor closedHandCursor] set];
[self setNeedsDisplay:YES];
}
- (void)_dragTableColumn:(CPInteger)aColumnIndex to:(CGPoint)aPoint
{
var delta = aPoint.x - _previousTrackingLocation.x,
columnPoint = [_columnDragHeaderView convertPoint:aPoint fromView:self];
// Only move if the mouse is past the original click point in the direction of movement
if ((delta > 0 && columnPoint.x > _columnMouseDownLocation.x) || (delta < 0 && columnPoint.x < _columnMouseDownLocation.x))
{
var columnRect = [self headerRectOfColumn:hoveredColumn],
columnCenterPoint = [self convertPoint:CGPointMake(CGRectGetMidX(columnRect), CGRectGetMidY(columnRect)) fromView:self];
if (hoveredColumn < _activeColumn && hoverPoint.x < columnCenterPoint.x)
[self _moveColumn:_activeColumn toColumn:hoveredColumn];
else if (hoveredColumn > _activeColumn && hoverPoint.x > columnCenterPoint.x)
[self _moveColumn:_activeColumn toColumn:hoveredColumn];
var dragFrame = [_columnDragView frame],
newOrigin = [self _constrainDragPoint:CGPointMake(CGRectGetMinX(dragFrame) + delta, CGRectGetMinY(dragFrame))];
[_columnDragView setFrameOrigin:newOrigin];
// When the edge of the dragged column passes the midpoint of an adjacent column, they swap
var hoverPoint = CGPointMakeCopy(aPoint);
// The drag frame is in content view coordinates, we need it to be in our coordinates
dragFrame = [self convertRect:dragFrame fromView:[_columnDragView superview]];
if (delta > 0)
hoverPoint.x = CGRectGetMaxX(dragFrame);
else
hoverPoint.x = CGRectGetMinX(dragFrame);
var hoveredColumn = [self columnAtPoint:hoverPoint];
if (hoveredColumn !== -1)
{
var columnRect = [self headerRectOfColumn:hoveredColumn],
columnCenterPoint = CGPointMake(CGRectGetMidX(columnRect), CGRectGetMidY(columnRect));
if (hoveredColumn < _activeColumn && hoverPoint.x < columnCenterPoint.x)
[self _moveColumn:_activeColumn toColumn:hoveredColumn];
else if (hoveredColumn > _activeColumn && hoverPoint.x > columnCenterPoint.x)
[self _moveColumn:_activeColumn toColumn:hoveredColumn];
}
}
_previousTrackingLocation = aPoint;
}
- (void)draggedView:(CPImage)aView endedAt:(CGPoint)aLocation operation:(CPDragOperation)anOperation
- (void)_stopDraggingTableColumn:(CPInteger)aColumnIndex
{
_isDragging = NO;
_isTrackingColumn = NO; // We need to do this explicitly because the mouse up section of trackMouse is never reached
[_tableView _setDraggedColumn:nil];
[[[[_tableView tableColumns] objectAtIndex:_activeColumn] headerView] setHidden:NO];
[self stopTrackingTableColumn:_activeColumn at:aLocation];
[_columnDragClipView removeFromSuperview];
[_tableView _setDraggedColumn:-1];
[self setNeedsDisplay:YES];
var headerView = [[[_tableView tableColumns] objectAtIndex:aColumnIndex] headerView];
[[headerView subviews] makeObjectsPerformSelector:@selector(setHidden:) withObject:NO];
if (_tableView._draggedColumnIsSelected)
[headerView setThemeState:CPThemeStateSelected];
var columnRect = [_tableView rectOfColumn:aColumnIndex];
[_tableView _reloadDataViews];
[[_tableView headerView] setNeedsLayout];
[[CPCursor arrowCursor] set];
}
- (BOOL)shouldResizeTableColumn:(int)aColumnIndex at:(CGPoint)aPoint
- (BOOL)_shouldResizeTableColumn:(CPInteger)aColumnIndex at:(CGPoint)aPoint
{
if (_isResizing)
return YES;
if (_isTrackingColumn)
return NO;
return [_tableView allowsColumnResizing] && CGRectContainsPoint([self _cursorRectForColumn:aColumnIndex], aPoint);
}
- (void)startResizingTableColumn:(int)aColumnIndex at:(CGPoint)aPoint
- (void)_startResizingTableColumn:(CPInteger)aColumnIndex at:(CGPoint)aPoint
{
_isResizing = YES;
_previousTrackingLocation = aPoint;
_activeColumn = aColumnIndex;
var tableColumn = [[_tableView tableColumns] objectAtIndex:aColumnIndex];
_columnOldWidth = [tableColumn width];
[tableColumn setDisableResizingPosting:YES];
[_tableView setDisableAutomaticResizing:YES];
}
- (void)continueResizingTableColumn:(int)aColumnIndex at:(CGPoint)aPoint
- (void)_continueResizingTableColumn:(CPInteger)aColumnIndex at:(CGPoint)aPoint
{
var tableColumn = [[_tableView tableColumns] objectAtIndex:aColumnIndex],
newWidth = [tableColumn width] + aPoint.x - _previousTrackingLocation.x;
delta = aPoint.x - _previousTrackingLocation.x,
spacing = [_tableView intercellSpacing].width,
newWidth = [tableColumn width] + spacing + delta,
minWidth = [tableColumn minWidth] + spacing,
maxWidth = [tableColumn maxWidth] + spacing;
if (newWidth < [tableColumn minWidth])
if (newWidth <= minWidth)
[[CPCursor resizeRightCursor] set];
else if (newWidth > [tableColumn maxWidth])
else if (newWidth >= maxWidth)
[[CPCursor resizeLeftCursor] set];
else
{
_tableView._lastColumnShouldSnap = NO;
[tableColumn setWidth:newWidth];
[[CPCursor resizeLeftRightCursor] set];
var columnRect = [_tableView rectOfColumn:aColumnIndex],
columnWidth = CGRectGetWidth(columnRect);
if ((delta > 0 && columnWidth == maxWidth) || (delta < 0 && columnWidth == minWidth))
return;
var columnMinX = CGRectGetMinX(columnRect),
columnMaxX = CGRectGetMaxX(columnRect);
if ((delta > 0 && aPoint.x > columnMaxX) || (delta < 0 && aPoint.x < columnMaxX))
{
[tableColumn setWidth:newWidth - spacing];
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
_previousTrackingLocation = aPoint;
}
- (void)stopResizingTableColumn:(int)aColumnIndex at:(CGPoint)aPoint
- (void)_stopResizingTableColumn:(CPInteger)aColumnIndex
{
var tableColumn = [[_tableView tableColumns] objectAtIndex:aColumnIndex];
[tableColumn _postDidResizeNotificationWithOldWidth:_columnOldWidth];
if ([tableColumn width] != _columnOldWidth)
[tableColumn _postDidResizeNotificationWithOldWidth:_columnOldWidth];
[tableColumn setDisableResizingPosting:NO];
[_tableView setDisableAutomaticResizing:NO];
@@ -627,17 +779,18 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
}
var mouseLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil],
mouseOverLocation = CGPointMake(mouseLocation.x - 5, mouseLocation.y),
mouseOverLocation = CGPointMake(MAX(mouseLocation.x - CPTableHeaderViewResizeZone, 0.0), mouseLocation.y),
overColumn = [self columnAtPoint:mouseOverLocation];
if (overColumn >= 0 && CGRectContainsPoint([self _cursorRectForColumn:overColumn], mouseLocation))
{
var tableColumn = [[_tableView tableColumns] objectAtIndex:overColumn],
spacing = [_tableView intercellSpacing].width,
width = [tableColumn width];
if (width == [tableColumn minWidth])
if (width <= [tableColumn minWidth])
[[CPCursor resizeRightCursor] set];
else if (width == [tableColumn maxWidth])
else if (width >= [tableColumn maxWidth])
[[CPCursor resizeLeftCursor] set];
else
[[CPCursor resizeLeftRightCursor] set];
@@ -646,99 +799,9 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
[[CPCursor arrowCursor] set];
}
- (void)mouseEntered:(CPEvent)theEvent
{
[self _updateResizeCursor:theEvent];
}
@end // CPTableView (CPTableViewPrivate)
- (void)mouseMoved:(CPEvent)theEvent
{
[self _updateResizeCursor:theEvent];
}
- (void)mouseExited:(CPEvent)theEvent
{
// FIXME: we should use CPCursor push/pop (if previous currentCursor != arrow).
[[CPCursor arrowCursor] set];
}
- (void)layoutSubviews
{
var tableColumns = [_tableView tableColumns],
count = [tableColumns count];
for (var i = 0; i < count; i++)
{
var column = [tableColumns objectAtIndex:i],
headerView = [column headerView],
frame = [self headerRectOfColumn:i];
// Make space for the gridline on the right.
frame.origin.x -= 0.5;
frame.size.width -= 1.0;
frame.size.height -= 0.5;
// Note: we're not adding in intercell spacing here. This setting only affects the regular
// table cell data views, not the header. Verified in Cocoa on March 29th, 2011.
[headerView setFrame:frame];
if ([headerView superview] != self)
[self addSubview:headerView];
}
[self setBackgroundColor:[self currentValueForThemeAttribute:@"background-color"]];
}
- (void)drawRect:(CGRect)aRect
{
if (!_tableView || ![self drawsColumnLines])
return;
var context = [[CPGraphicsContext currentContext] graphicsPort],
exposedColumnIndexes = [_tableView columnIndexesInRect:aRect],
columnsArray = [],
tableColumns = [_tableView tableColumns],
exposedTableColumns = _tableView._exposedColumns,
firstIndex = [exposedTableColumns firstIndex],
exposedRange = CPMakeRange(firstIndex, [exposedTableColumns lastIndex] - firstIndex + 1);
CGContextSetLineWidth(context, 1);
CGContextSetStrokeColor(context, [self currentValueForThemeAttribute:@"divider-color"]);
[exposedColumnIndexes getIndexes:columnsArray maxCount:-1 inIndexRange:exposedRange];
var columnArrayIndex = 0,
columnArrayCount = columnsArray.length,
columnMaxX;
CGContextBeginPath(context);
for (; columnArrayIndex < columnArrayCount; columnArrayIndex++)
{
// grab each column rect and add vertical lines
var columnIndex = columnsArray[columnArrayIndex],
columnToStroke = [self headerRectOfColumn:columnIndex];
columnMaxX = CGRectGetMaxX(columnToStroke);
CGContextMoveToPoint(context, FLOOR(columnMaxX) - 0.5, ROUND(CGRectGetMinY(columnToStroke)));
CGContextAddLineToPoint(context, FLOOR(columnMaxX) - 0.5, ROUND(CGRectGetMaxY(columnToStroke)) - 1.0);
}
CGContextClosePath(context);
CGContextStrokePath(context);
/*if (_isDragging)
{
CGContextSetFillColor(context, [CPColor grayColor]);
CGContextFillRect(context, [self headerRectOfColumn:_activeColumn])
}*/
}
@end
var CPTableHeaderViewTableViewKey = @"CPTableHeaderViewTableViewKey",
CPTableHeaderViewDrawsColumnLines = @"CPTableHeaderViewDrawsColumnLines";
var CPTableHeaderViewTableViewKey = @"CPTableHeaderViewTableViewKey";
@implementation CPTableHeaderView (CPCoding)
@@ -748,15 +811,6 @@ var CPTableHeaderViewTableViewKey = @"CPTableHeaderViewTableViewKey",
{
[self _init];
_tableView = [aCoder decodeObjectForKey:CPTableHeaderViewTableViewKey];
// FIX ME: Take this out before 1.0
if ([aCoder containsValueForKey:CPTableHeaderViewDrawsColumnLines])
_drawsColumnLines = [aCoder decodeBoolForKey:CPTableHeaderViewDrawsColumnLines];
else
{
_drawsColumnLines = YES;
CPLog.warn("The tableview header being decoded is using an old cib. Please run Nib2Cib.");
}
}
return self;
@@ -766,7 +820,6 @@ var CPTableHeaderViewTableViewKey = @"CPTableHeaderViewTableViewKey",
{
[super encodeWithCoder:aCoder];
[aCoder encodeObject:_tableView forKey:CPTableHeaderViewTableViewKey];
[aCoder encodeBool:_drawsColumnLines forKey:CPTableHeaderViewDrawsColumnLines];
}
@end
@end
+132 -70
View File
@@ -40,6 +40,7 @@
@class CPClipView
@class CPUserDefaults
@class CPTableHeaderView
@class _CPTableColumnHeaderView
@class CPClipView
@class CPButton
@@ -267,7 +268,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
SEL _viewForTableColumnRowSelector;
CPTableColumn _draggedColumn;
CPInteger _draggedColumnIndex;
BOOL _draggedColumnIsSelected;
CPArray _differedColumnDataToRemove;
}
@@ -394,7 +396,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
[_tableDrawView setBackgroundColor:[CPColor clearColor]];
[self addSubview:_tableDrawView];
_draggedColumn = nil;
_draggedColumnIndex = -1;
_draggedColumnIsSelected = NO;
_editingRow = CPNotFound;
_editingColumn = CPNotFound;
@@ -1059,21 +1062,16 @@ NOT YET IMPLEMENTED
@ignore
Internally used to set a column that will be dragged
*/
- (void)_setDraggedColumn:(CPTableColumn)aColumn
- (void)_setDraggedColumn:(CPInteger)columnIndex
{
if (_draggedColumn === aColumn)
if (_draggedColumnIndex === columnIndex)
return;
var previouslyDraggedColumn = _draggedColumn;
_draggedColumn = aColumn;
// If ending a column drag, reselect the column if it was selected before the drag
if (columnIndex === -1 && _draggedColumnIsSelected)
[_selectedColumnIndexes addIndex:_draggedColumnIndex];
// if a column is currently being dragged, update that column (removing data views)
if (aColumn)
[self _layoutViewsForRowIndexes:_exposedRows columnIndexes:[CPIndexSet indexSetWithIndex:[_tableColumns indexOfObject:aColumn]]];
// when the column is dropped, we should also update it.
if (previouslyDraggedColumn)
[self _layoutViewsForRowIndexes:_exposedRows columnIndexes:[CPIndexSet indexSetWithIndex:[_tableColumns indexOfObject:previouslyDraggedColumn]]];
_draggedColumnIndex = columnIndex;
}
/*
@@ -1094,7 +1092,8 @@ NOT YET IMPLEMENTED
else
_dirtyTableColumnRangeIndex = MIN(fromIndex, toIndex, _dirtyTableColumnRangeIndex);
var tableColumn = _tableColumns[fromIndex];
var tableColumn = _tableColumns[fromIndex],
selectedTableColumns = [_tableColumns objectsAtIndexes:_selectedColumnIndexes];
[_tableColumns removeObjectAtIndex:fromIndex];
[_tableColumns insertObject:tableColumn atIndex:toIndex];
@@ -1102,10 +1101,25 @@ NOT YET IMPLEMENTED
[[self headerView] setNeedsLayout];
[[self headerView] setNeedsDisplay:YES];
var range = CPMakeRange(MIN(fromIndex, toIndex), ABS(fromIndex - toIndex) + 1);
var columnIndexes = [CPIndexSet indexSetWithIndexesInRange:range];
var range = CPMakeRange(MIN(fromIndex, toIndex), ABS(fromIndex - toIndex) + 1),
layoutColumnIndexes = [CPIndexSet indexSetWithIndexesInRange:range],
selectedColumnIndexes = [CPIndexSet indexSet];
[_tableColumns enumerateObjectsUsingBlock:function(tableColumn, idx, stop)
{
if ([selectedTableColumns containsObjectIdenticalTo:tableColumn])
[selectedColumnIndexes addIndex:idx];
}];
if ([_selectedColumnIndexes containsIndex:fromIndex])
[selectedColumnIndexes addIndex:toIndex];
if (_draggedColumnIndex !== -1)
[layoutColumnIndexes removeIndex:toIndex];
[self _layoutViewsForRowIndexes:_exposedRows columnIndexes:layoutColumnIndexes];
[self selectColumnIndexes:selectedColumnIndexes byExtendingSelection:NO];
[self _layoutViewsForRowIndexes:_exposedRows columnIndexes:columnIndexes];
// Notify even if programmatically moving a column as in Cocoa.
// TODO Only notify when a column drag operation ends, not each time a column reaches a new slot?
[[CPNotificationCenter defaultCenter] postNotificationName:CPTableViewColumnDidMoveNotification
@@ -2997,48 +3011,74 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
return dragView;
}
/*!
@ignore
// Fetches all the data views (from the datasource) for the column and it's visible rows
// Copy the dataviews add them to a transparent drag view and use that drag view
// to make it appear we are dragging images of those rows (as you would do in regular Cocoa)
*/
- (CPView)_dragViewForColumn:(int)theColumnIndex event:(CPEvent)theDragEvent offset:(CGPoint)theDragViewOffset
- (CPView)_dragViewForColumn:(CPInteger)columnIndex
{
var dragView = [[_CPColumnDragView alloc] initWithLineColor:[self gridColor]],
tableColumn = [[self tableColumns] objectAtIndex:theColumnIndex],
defaultRowHeight = [self valueForThemeAttribute:@"default-row-height"],
bounds = CGRectMake(0.0, 0.0, [tableColumn width], CGRectGetHeight([self exposedRect]) + defaultRowHeight),
columnRect = [self rectOfColumn:theColumnIndex],
headerView = [tableColumn headerView],
row = [_exposedRows firstIndex];
var headerFrame = [_headerView frame],
visibleRect = [self visibleRect],
visibleRows = [self rowsInRect:visibleRect],
columnRect = [self rectOfColumn:columnIndex],
tableColumn = [[self tableColumns] objectAtIndex:columnIndex],
tableColumnUID = [tableColumn UID],
columnHeaderView = [tableColumn headerView],
columnHeaderFrame = [columnHeaderView frame],
frame = CGRectMake(MAX(CGRectGetMinX(columnRect) - CGRectGetMinX(visibleRect), 0.0),
0.0,
CGRectGetWidth(columnHeaderFrame),
CGRectGetHeight(visibleRect) + CGRectGetHeight(headerFrame));
[dragView setFrame:bounds];
// We need a wrapper view around the header and column, this is what will be dragged
var dragView = [[_CPColumnDragDrawingView alloc] initWithFrame:frame];
while (row !== CPNotFound)
[dragView setTableView:self];
[dragView setColumnIndex:columnIndex];
[dragView setBackgroundColor:[CPColor clearColor]];
[dragView setAlphaValue:0.6];
// Now a view that clips the column data views, which itself is clipped to the content view
var columnVisRect = CGRectIntersection(columnRect, visibleRect);
frame = CGRectMake(0.0, CGRectGetHeight(headerFrame), CGRectGetWidth(columnVisRect), CGRectGetHeight(columnVisRect));
var columnClipView = [[CPView alloc] initWithFrame:frame];
[dragView addSubview:columnClipView];
[dragView setColumnClipView:columnClipView];
_draggedColumnIsSelected = [self isColumnSelected:columnIndex];
var columnLeft = CGRectGetMinX(columnRect);
[self _enumerateViewsInRows:_exposedRows columns:[CPIndexSet indexSetWithIndex:columnIndex] usingBlock:function(dataView, row, column, stop)
{
var dataView = [self _newDataViewForRow:row tableColumn:tableColumn],
dataViewFrame = [self frameOfDataViewAtColumn:theColumnIndex row:row];
var dataViewFrame = [self frameOfDataViewAtColumn:column row:row];
// Only one column is ever dragged so we just place the view at
dataViewFrame.origin.x = 0.0;
dataViewFrame.origin.x -= columnLeft;
// Offset by table header height - scroll position
dataViewFrame.origin.y = ( CGRectGetMinY(dataViewFrame) - CGRectGetMinY([self exposedRect]) ) + defaultRowHeight;
dataViewFrame.origin.y -= CGRectGetMinY(visibleRect);
[dataView setFrame:dataViewFrame];
[self _setObjectValueForTableColumn:tableColumn row:row forView:dataView];
[dragView addSubview:dataView];
[columnClipView addSubview:dataView];
row = [_exposedRows indexGreaterThanIndex:row];
}
delete (_dataViewsForRows[row][tableColumnUID]);
}];
// Add a copy of the header view.
var columnHeaderView = [CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:headerView]];
[dragView addSubview:columnHeaderView];
// Add the column header view
columnHeaderFrame.origin = CGPointMakeZero();
[dragView setBackgroundColor:[CPColor whiteColor]];
[dragView setAlphaValue:0.7];
var dragColumnHeaderView = [[_CPTableColumnHeaderView alloc] initWithFrame:columnHeaderFrame],
image = [columnHeaderView _indicatorImage];
[dragColumnHeaderView setStringValue:[columnHeaderView stringValue]];
[dragColumnHeaderView setThemeState:[columnHeaderView themeState]];
[dragColumnHeaderView _setIndicatorImage:image];
// Give it a tag so it can be found later
[dragColumnHeaderView setTag:1];
[dragView addSubview:dragColumnHeaderView];
// While dragging, the column is deselected in the table view
[_selectedColumnIndexes removeIndex:columnIndex];
return dragView;
}
@@ -5534,45 +5574,67 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
@end
@implementation _CPColumnDragView : CPView
@implementation _CPColumnDragDrawingView : CPView
{
CPColor _lineColor;
CPTableView tableView @accessors;
int columnIndex @accessors;
CPView columnClipView @accessors;
}
- (id)initWithLineColor:(CPColor)aColor
- (void)drawRect:(CGRect)dirtyRect
{
self = [super initWithFrame:CGRectMakeZero()];
var context = [[CPGraphicsContext currentContext] graphicsPort],
columnRect = [tableView rectOfColumn:columnIndex],
headerHeight = CGRectGetHeight([[tableView headerView] frame]),
bounds = [columnClipView bounds],
visibleRect = [tableView visibleRect],
xScroll = CGRectGetMinX(visibleRect),
yScroll = CGRectGetMinY(visibleRect);
if (self)
_lineColor = aColor;
// Because we are sharing drawing code with regular table drawing,
// we have to play a few tricks to fool the drawing code into thinking
// our drag column is in the same place as the real column.
return self;
}
// Shift the bounds origin to align with the column rect, and extend it vertically to ensure
// it reaches the bottom of the tableView when scrolled.
bounds.origin.x = CGRectGetMinX(columnRect) - xScroll;
bounds.size.height += yScroll;
- (void)drawRect:(CGRect)aRect
{
var context = [[CPGraphicsContext currentContext] graphicsPort];
// Fix up the CTM to account for the header and scroll
CGContextTranslateCTM(context, -bounds.origin.x, headerHeight - yScroll);
CGContextSetStrokeColor(context, _lineColor);
//[tableView drawBackgroundInClipRect:bounds];
var points = [
CGPointMake(0.5, 0),
CGPointMake(0.5, aRect.size.height)
];
if (tableView._draggedColumnIsSelected)
{
CGContextSetFillColor(context, [tableView selectionHighlightColor]);
CGContextFillRect(context, bounds);
}
else
[tableView highlightSelectionInClipRect:bounds];
CGContextStrokeLineSegments(context, points, 2);
//[tableView _drawHorizontalGridInClipRect:bounds];
points = [
CGPointMake(aRect.size.width - 0.5, 0),
CGPointMake(aRect.size.width - 0.5, aRect.size.height)
];
var minX = CGRectGetMinX(bounds) + 0.5,
maxX = CGRectGetMaxX(bounds) - 0.5;
CGContextStrokeLineSegments(context, points, 2);
CGContextSetLineWidth(context, 1.0);
CGContextSetAlpha(context, 1.0);
CGContextSetStrokeColor(context, [tableView gridColor]);
CGContextBeginPath(context);
CGContextMoveToPoint(context, minX, CGRectGetMinY(bounds));
CGContextAddLineToPoint(context, minX, CGRectGetMaxY(bounds));
CGContextMoveToPoint(context, maxX, CGRectGetMinY(bounds));
CGContextAddLineToPoint(context, maxX, CGRectGetMaxY(bounds));
CGContextStrokePath(context);
}
@end
@implementation CPTableCellView : CPView
{
id _objectValue @accessors(property=objectValue);
@@ -29,6 +29,8 @@ CPLogRegister(CPLogConsole);
if (duration)
console.log(receiver + " " + selector + " in " + averager(duration));
});
CPTrace("CPTableHeaderView", "_startDraggingTableColumn:at:");
}
- (void)awakeFromCib
@@ -44,6 +44,8 @@ CPLogRegister(CPLogConsole)
if (duration)
console.log(receiver + " " + selector + " in " + averager(duration));
});
CPTrace("CPTableHeaderView", "_startDraggingTableColumn:at:");
}
- (void)awakeFromCib