mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-15 03:03:50 +00:00
Merge branch 'master' of github.com:280north/cappuccino
This commit is contained in:
commit
0ade0e1361
8 files changed
+566
-213
No files matched your search
+45
-36
@@ -85,6 +85,8 @@ CPOutlineViewDropOnItemIndex = -1;
|
||||
|
||||
BOOL _shouldRetargetChildIndex;
|
||||
CPInteger _retargedChildIndex;
|
||||
CPTimer _dragHoverTimer;
|
||||
id _dropItem;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
@@ -108,6 +110,7 @@ CPOutlineViewDropOnItemIndex = -1;
|
||||
|
||||
_retargedChildIndex = nil;
|
||||
_shouldRetargetChildIndex = NO;
|
||||
_startHoverTime = nil;
|
||||
|
||||
[self setIndentationPerLevel:16.0];
|
||||
[self setIndentationMarkerFollowsDataView:YES];
|
||||
@@ -382,43 +385,14 @@ CPOutlineViewDropOnItemIndex = -1;
|
||||
return frame;
|
||||
}
|
||||
|
||||
- (void)selectRowIndexes:(CPIndexSet)rows byExtendingSelection:(BOOL)shouldExtendSelection
|
||||
- (void)_performSelection:(BOOL)select forRow:(CPInteger)rowIndex context:(id)context
|
||||
{
|
||||
// First un highlight the old disclosure controls
|
||||
var previousSelectedRows = [];
|
||||
[[self selectedRowIndexes] getIndexes:previousSelectedRows maxCount:-1 inIndexRange:nil];
|
||||
[super _performSelection:select forRow:rowIndex context:context];
|
||||
|
||||
var index = [previousSelectedRows count];
|
||||
while (index--)
|
||||
{
|
||||
var rowIndex = previousSelectedRows[index],
|
||||
item = [self itemAtRow:rowIndex];
|
||||
var control = _disclosureControlsForRows[rowIndex],
|
||||
selector = select ? @"setThemeState:" : @"unsetThemeState:";
|
||||
|
||||
if (![self isExpandable:item])
|
||||
continue;
|
||||
|
||||
var control = _disclosureControlsForRows[rowIndex];
|
||||
[control setHighlighted:NO];
|
||||
}
|
||||
|
||||
[super selectRowIndexes:rows byExtendingSelection:shouldExtendSelection];
|
||||
|
||||
// Now highlight the new disclosure controls
|
||||
var selectedRows = [];
|
||||
[rows getIndexes:selectedRows maxCount:-1 inIndexRange:nil];
|
||||
|
||||
var index = [selectedRows count];
|
||||
while (index--)
|
||||
{
|
||||
var rowIndex = selectedRows[index],
|
||||
item = [self itemAtRow:rowIndex];
|
||||
|
||||
if (![self isExpandable:item])
|
||||
continue;
|
||||
|
||||
var control = _disclosureControlsForRows[rowIndex];
|
||||
[control setHighlighted:YES];
|
||||
}
|
||||
[control performSelector:CPSelectorFromString(selector) withObject:CPThemeStateSelected];
|
||||
}
|
||||
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
@@ -534,6 +508,29 @@ CPOutlineViewDropOnItemIndex = -1;
|
||||
|
||||
- (void)setDropItem:(id)theItem dropChildIndex:(int)theIndex
|
||||
{
|
||||
if (_dropItem !== theItem && theIndex < 0 && [self isExpandable:theItem] && ![self isItemExpanded:theItem])
|
||||
{
|
||||
if (_dragHoverTimer)
|
||||
[_dragHoverTimer invalidate];
|
||||
|
||||
var autoExpandCallBack = function(){
|
||||
if (_dropItem)
|
||||
{
|
||||
[_dropOperationFeedbackView blink];
|
||||
[CPTimer scheduledTimerWithTimeInterval:.3 callback:objj_msgSend(self, "expandItem:", _dropItem) repeats:NO]; //[self expandItem:_dropItem];
|
||||
}
|
||||
}
|
||||
|
||||
_dragHoverTimer = [CPTimer scheduledTimerWithTimeInterval:.8 callback:autoExpandCallBack repeats:NO];
|
||||
}
|
||||
|
||||
if (theIndex >= 0)
|
||||
{
|
||||
[_dragHoverTimer invalidate];
|
||||
_dragHoverTimer = nil;
|
||||
}
|
||||
|
||||
_dropItem = theItem;
|
||||
_retargetedItem = theItem;
|
||||
_shouldRetargetItem = YES;
|
||||
|
||||
@@ -541,6 +538,14 @@ CPOutlineViewDropOnItemIndex = -1;
|
||||
_shouldRetargetChildIndex = YES;
|
||||
}
|
||||
|
||||
- (void)_draggingEnded
|
||||
{
|
||||
[super _draggingEnded];
|
||||
_dropItem = nil;
|
||||
[_dragHoverTimer invalidate];
|
||||
_dragHoverTimer = nil;
|
||||
}
|
||||
|
||||
- (id)_parentItemForUpperRow:(int)theUpperRowIndex andLowerRow:(int)theLowerRowIndex atMouseOffset:(CPPoint)theOffset
|
||||
{
|
||||
if (_shouldRetargetItem)
|
||||
@@ -619,6 +624,8 @@ CPOutlineViewDropOnItemIndex = -1;
|
||||
_disclosureControlsForRows[row] = control;
|
||||
|
||||
[control setState:[self isItemExpanded:item] ? CPOnState : CPOffState];
|
||||
var selector = [self isRowSelected:row] ? @"setThemeState:" : @"unsetThemeState:";
|
||||
[control performSelector:CPSelectorFromString(selector) withObject:CPThemeStateSelected];
|
||||
[control setFrame:frame];
|
||||
|
||||
[self addSubview:control];
|
||||
@@ -1080,8 +1087,10 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
CGContextAddLineToPoint(context, 0.0, 0.0);
|
||||
|
||||
CGContextClosePath(context);
|
||||
|
||||
CGContextSetFillColor(context, [self isHighlighted] ? [CPColor whiteColor] : [CPColor grayColor]);
|
||||
var isHighlighted = [self hasThemeState:CPThemeStateHighlighted];
|
||||
var color = [self hasThemeState:CPThemeStateSelected] ? (isHighlighted ? [CPColor lightGrayColor] : [CPColor whiteColor]) : (isHighlighted ? [CPColor blackColor] : [CPColor grayColor]);
|
||||
|
||||
CGContextSetFillColor(context, color);
|
||||
CGContextFillPath(context);
|
||||
}
|
||||
|
||||
|
||||
@@ -348,7 +348,14 @@ CPTableColumnUserResizingMask = 1 << 1;
|
||||
|
||||
- (void)setHidden:(BOOL)shouldBeHidden
|
||||
{
|
||||
shouldBeHidden = !!shouldBeHidden
|
||||
if (_isHidden === shouldBeHidden)
|
||||
return;
|
||||
|
||||
_isHidden = shouldBeHidden;
|
||||
|
||||
[[self headerView] setHidden:shouldBeHidden];
|
||||
[[self tableView] _tableColumnVisibilityDidChange:self];
|
||||
}
|
||||
|
||||
- (BOOL)isHidden
|
||||
|
||||
+285
-139
@@ -26,7 +26,7 @@
|
||||
|
||||
@implementation _CPTableColumnHeaderView : CPView
|
||||
{
|
||||
_CPImageAndTextView _textField;
|
||||
_CPImageAndTextView _textField;
|
||||
}
|
||||
|
||||
- (void)initWithFrame:(CGRect)frame
|
||||
@@ -147,25 +147,32 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
|
||||
@implementation CPTableHeaderView : CPView
|
||||
{
|
||||
int _resizedColumn @accessors(readonly, property=resizedColumn);
|
||||
int _draggedColumn @accessors(readonly, property=draggedColumn);
|
||||
int _pressedColumn @accessors(readonly, property=pressedColumn);
|
||||
CPPoint _mouseDownLocation;
|
||||
CPPoint _previousTrackingLocation;
|
||||
int _activeColumn;
|
||||
int _pressedColumn;
|
||||
|
||||
float _draggedDistance @accessors(readonly, property=draggedDistance);
|
||||
float _lastLocation;
|
||||
float _columnOldWidth;
|
||||
BOOL _isResizing;
|
||||
BOOL _isDragging;
|
||||
BOOL _isTrackingColumn;
|
||||
|
||||
CPTableView _tableView @accessors(property=tableView);
|
||||
float _columnOldWidth;
|
||||
|
||||
CPTableView _tableView @accessors(property=tableView);
|
||||
}
|
||||
|
||||
- (void)_init
|
||||
{
|
||||
_resizedColumn = -1;
|
||||
_draggedColumn = -1;
|
||||
_mouseDownLocation = CPPointMakeZero();
|
||||
_previousTrackingLocation = CPPointMakeZero();
|
||||
_activeColumn = -1;
|
||||
_pressedColumn = -1;
|
||||
_draggedDistance = 0.0;
|
||||
_lastLocation = nil;
|
||||
_columnOldWidth = nil;
|
||||
|
||||
_isResizing = NO;
|
||||
_isDragging = NO;
|
||||
_isTrackingColumn = NO;
|
||||
|
||||
_columnOldWidth = 0.0;
|
||||
|
||||
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
|
||||
}
|
||||
@@ -182,26 +189,18 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
|
||||
- (int)columnAtPoint:(CGPoint)aPoint
|
||||
{
|
||||
return [_tableView columnAtPoint:CGPointMake(aPoint.x, 0)];
|
||||
return [_tableView columnAtPoint:CGPointMake(aPoint.x, aPoint.y)];
|
||||
}
|
||||
|
||||
- (CGRect)headerRectOfColumn:(int)aColumnIndex
|
||||
{
|
||||
var tableColumns = [_tableView tableColumns];
|
||||
|
||||
if (aColumnIndex < 0 || aColumnIndex > [tableColumns count])
|
||||
[CPException raise:"invalid" reason:"tried to get headerRectOfColumn: on invalid column"];
|
||||
|
||||
// UPDATE COLUMN RANGES ?
|
||||
var headerRect = [self bounds],
|
||||
columnRect = [[self tableView] rectOfColumn:aColumnIndex];
|
||||
|
||||
var tableRange = _tableView._tableColumnRanges[aColumnIndex],
|
||||
bounds = [self bounds];
|
||||
|
||||
var rMinX = ROUND(tableRange.location);
|
||||
bounds.origin.x = rMinX;
|
||||
bounds.size.width = FLOOR(tableRange.length + tableRange.location - rMinX);
|
||||
headerRect.origin.x = CPRectGetMinX(columnRect);
|
||||
headerRect.size.width = CPRectGetWidth(columnRect);
|
||||
|
||||
return bounds;
|
||||
return headerRect;
|
||||
}
|
||||
|
||||
- (CGRect)_cursorRectForColumn:(int)column
|
||||
@@ -236,104 +235,273 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
|
||||
- (void)mouseDown:(CPEvent)theEvent
|
||||
{
|
||||
var mouseLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil],
|
||||
clickedColumn = [self columnAtPoint:mouseLocation];
|
||||
|
||||
// should we send column -1 ?
|
||||
[_tableView _sendDelegateDidMouseDownInHeader:clickedColumn];
|
||||
|
||||
var resizeLocation = CGPointMake(mouseLocation.x - 5, mouseLocation.y),
|
||||
resizedColumn = [self columnAtPoint:resizeLocation];
|
||||
|
||||
if (resizedColumn == -1)
|
||||
return;
|
||||
|
||||
// 2 different tracking methods: one for resizing/stop-resizing, another one for selection/reordering
|
||||
if ([_tableView allowsColumnResizing]
|
||||
&& CGRectContainsPoint([self _cursorRectForColumn:resizedColumn], mouseLocation))
|
||||
{
|
||||
_resizedColumn = resizedColumn;
|
||||
[_tableView._tableColumns[_resizedColumn] setDisableResizingPosting:YES];
|
||||
[_tableView setDisableAutomaticResizing:YES];
|
||||
[self trackResizeWithEvent:theEvent];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self _setPressedColumn:clickedColumn];
|
||||
[self trackMouseWithEvent:theEvent];
|
||||
}
|
||||
[self trackMouse:theEvent];
|
||||
}
|
||||
|
||||
- (void)trackMouseWithEvent:(CPEvent)theEvent
|
||||
- (void)trackMouse:(CPEvent)theEvent
|
||||
{
|
||||
var type = [theEvent type];
|
||||
var type = [theEvent type],
|
||||
currentLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||
|
||||
if (type == CPLeftMouseUp)
|
||||
{
|
||||
var location = [self convertPoint:[theEvent locationInWindow] fromView:nil],
|
||||
clickedColumn = [self columnAtPoint:location];
|
||||
// Take the right columns resize tracking area into account
|
||||
currentLocation.x -= 5.0;
|
||||
|
||||
[self _setPressedColumn:-1];
|
||||
var columnIndex = [self columnAtPoint:currentLocation],
|
||||
shouldResize = [self shouldResizeTableColumn:columnIndex at:CPPointMake(currentLocation.x + 5.0, currentLocation.y)];
|
||||
|
||||
if (clickedColumn != -1)
|
||||
[_tableView _didClickTableColumn:clickedColumn modifierFlags:[theEvent modifierFlags]];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
[CPApp setTarget:self selector:@selector(trackMouseWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask | CPLeftMouseDownMask untilDate:nil inMode:nil dequeue:YES];
|
||||
}
|
||||
|
||||
- (void)trackResizeWithEvent:(CPEvent)anEvent
|
||||
{
|
||||
var location = [self convertPoint:[anEvent locationInWindow] fromView:nil],
|
||||
tableColumn = [[_tableView tableColumns] objectAtIndex:_resizedColumn],
|
||||
type = [anEvent type];
|
||||
|
||||
if (_lastLocation == nil)
|
||||
_lastLocation = location;
|
||||
|
||||
if (_columnOldWidth == nil)
|
||||
_columnOldWidth = [tableColumn width];
|
||||
|
||||
if (type === CPLeftMouseUp)
|
||||
{
|
||||
[self _updateResizeCursor:anEvent];
|
||||
|
||||
[tableColumn _postDidResizeNotificationWithOldWidth:_columnOldWidth];
|
||||
[tableColumn setDisableResizingPosting:NO];
|
||||
[_tableView setDisableAutomaticResizing:NO];
|
||||
|
||||
_resizedColumn = -1;
|
||||
_lastLocation = nil;
|
||||
_columnOldWidth = nil;
|
||||
|
||||
return;
|
||||
}
|
||||
else if (type === CPLeftMouseDragged)
|
||||
{
|
||||
var newWidth = [tableColumn width] + location.x - _lastLocation.x;
|
||||
if (shouldResize)
|
||||
[self stopResizingTableColumn:_activeColumn at:currentLocation];
|
||||
else if ([self _shouldStopTrackingTableColumn:columnIndex at:currentLocation])
|
||||
{
|
||||
[[self tableView] _didClickTableColumn:columnIndex modifierFlags:[theEvent modifierFlags]];
|
||||
[self stopTrackingTableColumn:columnIndex at:currentLocation];
|
||||
|
||||
_isTrackingColumn = NO;
|
||||
}
|
||||
|
||||
_activeColumn = CPNotFound;
|
||||
return;
|
||||
}
|
||||
|
||||
if (type === CPLeftMouseDown)
|
||||
{
|
||||
if (columnIndex === -1)
|
||||
return;
|
||||
|
||||
if (newWidth < [tableColumn minWidth])
|
||||
[[CPCursor resizeRightCursor] set];
|
||||
else if (newWidth > [tableColumn maxWidth])
|
||||
[[CPCursor resizeLeftCursor] set];
|
||||
_mouseDownLocation = currentLocation;
|
||||
_activeColumn = columnIndex;
|
||||
|
||||
[[self tableView] _sendDelegateDidMouseDownInHeader:columnIndex];
|
||||
|
||||
if (shouldResize)
|
||||
[self startResizingTableColumn:columnIndex at:currentLocation];
|
||||
else
|
||||
{
|
||||
_tableView._lastColumnShouldSnap = NO;
|
||||
[tableColumn setWidth:newWidth];
|
||||
// FIXME: there has to be a better way to do this...
|
||||
// We should refactor the auto resizing crap.
|
||||
// We need to figure out the exact cocoa behavior here though.
|
||||
_lastLocation = location;
|
||||
|
||||
[[CPCursor resizeLeftRightCursor] set];
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
[self startTrackingTableColumn:columnIndex at:currentLocation];
|
||||
_isTrackingColumn = YES;
|
||||
}
|
||||
}
|
||||
else if (type === CPLeftMouseDragged)
|
||||
{
|
||||
if (shouldResize)
|
||||
[self continueResizingTableColumn:_activeColumn at:currentLocation];
|
||||
else
|
||||
{
|
||||
if (_activeColumn === columnIndex && CPRectContainsPoint([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];
|
||||
}
|
||||
|
||||
[CPApp setTarget:self selector:@selector(trackResizeWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES];
|
||||
- (void)startTrackingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
||||
{
|
||||
[self _setPressedColumn:aColumnIndex];
|
||||
}
|
||||
|
||||
- (BOOL)continueTrackingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
||||
{
|
||||
if ([self _shouldDragTableColumn:aColumnIndex at:aPoint])
|
||||
{
|
||||
var columnRect = [self headerRectOfColumn:aColumnIndex],
|
||||
offset = CPPointMakeZero(),
|
||||
view = [[self tableView] _dragViewForColumn:aColumnIndex event:[CPApp currentEvent] offset:offset],
|
||||
viewLocation = CPPointMakeZero();
|
||||
|
||||
viewLocation.x = ( CPRectGetMinX(columnRect) + offset.x ) + ( aPoint.x - _mouseDownLocation.x );
|
||||
viewLocation.y = CPRectGetMinY(columnRect) + offset.y;
|
||||
|
||||
[self dragView:view at:viewLocation offset:CPSizeMakeZero() event:[CPApp currentEvent]
|
||||
pasteboard:[CPPasteboard pasteboardWithName:CPDragPboard] source:self slideBack:YES];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)_shouldStopTrackingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
||||
{
|
||||
return _isTrackingColumn && _activeColumn === aColumnIndex &&
|
||||
CPRectContainsPoint([self headerRectOfColumn:aColumnIndex], aPoint);
|
||||
}
|
||||
|
||||
- (void)stopTrackingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
||||
{
|
||||
[self _setPressedColumn:CPNotFound];
|
||||
[self _updateResizeCursor:[CPApp currentEvent]];
|
||||
}
|
||||
|
||||
- (BOOL)_shouldDragTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
||||
{
|
||||
return [[self tableView] allowsColumnReordering] && ABS(aPoint.x - _mouseDownLocation.x) >= 10.0;
|
||||
}
|
||||
|
||||
- (CPRect)_headerRectOfLastVisibleColumn
|
||||
{
|
||||
var tableColumns = [[self tableView] tableColumns],
|
||||
columnIndex = [tableColumns count];
|
||||
|
||||
while (columnIndex--)
|
||||
{
|
||||
var tableColumn = [tableColumns objectAtIndex:columnIndex];
|
||||
|
||||
if (![tableColumn isHidden])
|
||||
return [self headerRectOfColumn:columnIndex];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)_constrainDragView:(CPView)theDragView at:(CPPoint)aPoint
|
||||
{
|
||||
var tableColumns = [[self tableView] tableColumns],
|
||||
lastColumnRect = [self _headerRectOfLastVisibleColumn];
|
||||
activeColumnRect = [self headerRectOfColumn:_activeColumn];
|
||||
dragWindow = [theDragView window],
|
||||
frame = [dragWindow frame];
|
||||
|
||||
// Convert the frame origin from the global coordinate system to the windows' coordinate system
|
||||
frame.origin = [[self window] convertGlobalToBase:frame.origin];
|
||||
|
||||
// This effectively clamps the value between the minimum and maximum
|
||||
frame.origin.x = MAX(0.0, MIN(CPRectGetMinX(frame), CPRectGetMaxX(lastColumnRect) - CPRectGetWidth(activeColumnRect)));
|
||||
|
||||
// Make sure the column cannot move vertically
|
||||
frame.origin.y = CPRectGetMinY([self convertRect:lastColumnRect toView:nil]);
|
||||
|
||||
// Convert the calculated origin back to the global coordinate system
|
||||
frame.origin = [[self window] convertBaseToGlobal:frame.origin];
|
||||
|
||||
[dragWindow setFrame:frame];
|
||||
}
|
||||
|
||||
- (void)_moveColumn:(int)aFromIndex toColumn:(int)aToIndex
|
||||
{
|
||||
[[self tableView] moveColumn:aFromIndex toColumn:aToIndex];
|
||||
_activeColumn = aToIndex;
|
||||
_pressedColumn = _activeColumn;
|
||||
|
||||
[[self tableView] _setDraggedColumn:_activeColumn];
|
||||
}
|
||||
|
||||
- (void)draggedView:(CPView)aView beganAt:(CPPoint)aPoint
|
||||
{
|
||||
_isDragging = YES;
|
||||
|
||||
[[[[[self tableView] tableColumns] objectAtIndex:_activeColumn] headerView] setHidden:YES];
|
||||
[[self tableView] _setDraggedColumn:_activeColumn];
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)draggedView:(CPView)aView movedTo:(CPPoint)aPoint
|
||||
{
|
||||
[self _constrainDragView:aView at:aPoint];
|
||||
|
||||
var dragWindow = [aView window],
|
||||
dragWindowFrame = [dragWindow frame];
|
||||
|
||||
var hoverPoint = CPPointCreateCopy(aPoint);
|
||||
if (aPoint.x < _previousTrackingLocation.x)
|
||||
hoverPoint = CPPointMake(CPRectGetMinX(dragWindowFrame), CPRectGetMinY(dragWindowFrame));
|
||||
else if (aPoint.x > _previousTrackingLocation.x)
|
||||
hoverPoint = CPPointMake(CPRectGetMaxX(dragWindowFrame), CPRectGetMinY(dragWindowFrame));
|
||||
|
||||
// Convert the hover point from the global coordinate system to windows' coordinate system
|
||||
hoverPoint = [[self window] convertGlobalToBase:hoverPoint];
|
||||
|
||||
var hoveredColumn = [self columnAtPoint:hoverPoint];
|
||||
|
||||
if (hoveredColumn !== -1)
|
||||
{
|
||||
var columnRect = [self headerRectOfColumn:hoveredColumn],
|
||||
columnCenterPoint = CPPointMake(CPRectGetMidX(columnRect), CPRectGetMidY(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
|
||||
{
|
||||
_isDragging = NO;
|
||||
_isTrackingColumn = NO; // We need to do this explicitly because the mouse up section of trackMouse is never reached
|
||||
|
||||
[[self tableView] _setDraggedColumn:-1];
|
||||
[[[[[self tableView] tableColumns] objectAtIndex:_activeColumn] headerView] setHidden:NO];
|
||||
[self stopTrackingTableColumn:_activeColumn at:aLocation];
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (BOOL)shouldResizeTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
||||
{
|
||||
if (_isResizing)
|
||||
return YES;
|
||||
|
||||
if (_isTrackingColumn)
|
||||
return NO;
|
||||
|
||||
return [[self tableView] allowsColumnResizing] && CPRectContainsPoint([self _cursorRectForColumn:aColumnIndex], aPoint);
|
||||
}
|
||||
|
||||
- (void)startResizingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
||||
{
|
||||
_isResizing = YES;
|
||||
|
||||
var tableColumn = [[[self tableView] tableColumns] objectAtIndex:aColumnIndex];
|
||||
|
||||
[tableColumn setDisableResizingPosting:YES];
|
||||
[[self tableView] setDisableAutomaticResizing:YES];
|
||||
}
|
||||
|
||||
- (void)continueResizingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
||||
{
|
||||
var tableColumn = [[[self tableView] tableColumns] objectAtIndex:aColumnIndex];
|
||||
|
||||
var newWidth = [tableColumn width] + aPoint.x - _previousTrackingLocation.x;
|
||||
|
||||
if (newWidth < [tableColumn minWidth])
|
||||
[[CPCursor resizeRightCursor] set];
|
||||
else if (newWidth > [tableColumn maxWidth])
|
||||
[[CPCursor resizeLeftCursor] set];
|
||||
else
|
||||
{
|
||||
[self tableView]._lastColumnShouldSnap = NO;
|
||||
[tableColumn setWidth:newWidth];
|
||||
|
||||
[[CPCursor resizeLeftRightCursor] set];
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)stopResizingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
||||
{
|
||||
var tableColumn = [[[self tableView] tableColumns] objectAtIndex:aColumnIndex];
|
||||
[tableColumn _postDidResizeNotificationWithOldWidth:_columnOldWidth];
|
||||
[tableColumn setDisableResizingPosting:NO];
|
||||
[[self tableView] setDisableAutomaticResizing:NO];
|
||||
|
||||
_isResizing = NO;
|
||||
}
|
||||
|
||||
- (void)_updateResizeCursor:(CPEvent)theEvent
|
||||
@@ -365,12 +533,6 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
[[CPCursor arrowCursor] set];
|
||||
}
|
||||
|
||||
- (void)viewDidMoveToWindow
|
||||
{
|
||||
//if ([_tableView allowsColumnResizing])
|
||||
// [[self window] setAcceptsMouseMovedEvents:YES];
|
||||
}
|
||||
|
||||
- (void)mouseEntered:(CPEvent)theEvent
|
||||
{
|
||||
[self _updateResizeCursor:theEvent];
|
||||
@@ -449,27 +611,12 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
|
||||
CGContextClosePath(context);
|
||||
CGContextStrokePath(context);
|
||||
|
||||
/*
|
||||
var maxY = CGRectGetMaxY([self bounds]);
|
||||
// draw normal gradient for remaining space
|
||||
if (supportsCanvasGradient)
|
||||
|
||||
if (_isDragging)
|
||||
{
|
||||
aRect.origin.x = columnMaxX - 0.5;
|
||||
aRect.size.width -= columnMaxX;
|
||||
CGContextBeginPath(context);
|
||||
CGContextAddRect(context, CGRectMake(columnMaxX + 1, 0, CGRectGetMaxX([self bounds]) - columnMaxX, CGRectGetHeight([self bounds])));
|
||||
CGContextClosePath(context);
|
||||
CGContextDrawLinearGradient(context, [_CPTableColumnHeaderView headerGradient], CGPointMake(0,0), CGPointMake(0, maxY - 1),0);
|
||||
}
|
||||
|
||||
// Draw bottom line
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context, 0, maxY - 0.5);
|
||||
CGContextAddLineToPoint(context, CGRectGetMaxX([self bounds]), maxY - 0.5);
|
||||
CGContextClosePath(context);
|
||||
CGContextStrokePath(context);
|
||||
*/
|
||||
CGContextSetFillColor(context, [CPColor grayColor]);
|
||||
CGContextFillRect(context, [self headerRectOfColumn:_activeColumn])
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -495,5 +642,4 @@ var CPTableHeaderViewTableViewKey = @"CPTableHeaderViewTableViewKey";
|
||||
[aCoder encodeObject:_tableView forKey:CPTableHeaderViewTableViewKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@end
|
||||
+153
-24
@@ -212,6 +212,9 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
CPGradient _sourceListActiveGradient;
|
||||
CPColor _sourceListActiveTopLineColor;
|
||||
CPColor _sourceListActiveBottomLineColor;
|
||||
|
||||
int _draggedColumnIndex;
|
||||
|
||||
/*
|
||||
CPGradient _sourceListInactiveGradient;
|
||||
CPColor _sourceListInactiveTopLineColor;
|
||||
@@ -309,7 +312,9 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
|
||||
if (!_cornerView)
|
||||
_cornerView = [[_CPCornerView alloc] initWithFrame:CGRectMake(0, 0, [CPScroller scrollerWidth], CGRectGetHeight([_headerView frame]))];
|
||||
|
||||
|
||||
_draggedColumnIndex = -1;
|
||||
|
||||
// Gradients for the source list
|
||||
_sourceListActiveGradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [89.0/255.0, 153.0/255.0, 209.0/255.0,1.0, 33.0/255.0, 94.0/255.0, 208.0/255.0,1.0], [0,1], 2);
|
||||
_sourceListActiveTopLineColor = [CPColor colorWithCalibratedRed:(61.0/255.0) green:(123.0/255.0) blue:(218.0/255.0) alpha:1.0];
|
||||
@@ -672,6 +677,15 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)_setDraggedColumn:(int)aColumnIndex
|
||||
{
|
||||
if (_draggedColumnIndex === aColumnIndex)
|
||||
return;
|
||||
|
||||
_draggedColumnIndex = aColumnIndex;
|
||||
|
||||
[self reloadDataForRowIndexes:_exposedRows columnIndexes:[CPIndexSet indexSetWithIndex:aColumnIndex]];
|
||||
}
|
||||
|
||||
/*!
|
||||
Moves the column and heading at a given index to a new given index.
|
||||
@@ -691,15 +705,37 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
else
|
||||
_dirtyTableColumnRangeIndex = MIN(fromIndex, toIndex, _dirtyTableColumnRangeIndex);
|
||||
|
||||
if (toIndex > fromIndex)
|
||||
--toIndex;
|
||||
|
||||
var tableColumn = _tableColumns[fromIndex];
|
||||
|
||||
[_tableColumns removeObjectAtIndex:fromIndex];
|
||||
[_tableColumns insertObject:tableColumn atIndex:toIndex];
|
||||
|
||||
[[self headerView] setNeedsLayout];
|
||||
[[self headerView] setNeedsDisplay:YES];
|
||||
|
||||
[self setNeedsLayout];
|
||||
var rowIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [self numberOfRows])],
|
||||
columnIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(fromIndex, toIndex)];
|
||||
|
||||
[self reloadDataForRowIndexes:rowIndexes columnIndexes:columnIndexes];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (void)_tableColumnVisibilityDidChange:(CPTableColumn)aColumn
|
||||
{
|
||||
var columnIndex = [[self tableColumns] indexOfObjectIdenticalTo:aColumn];
|
||||
|
||||
if (_dirtyTableColumnRangeIndex < 0)
|
||||
_dirtyTableColumnRangeIndex = columnIndex;
|
||||
else
|
||||
_dirtyTableColumnRangeIndex = MIN(columnIndex, _dirtyTableColumnRangeIndex);
|
||||
|
||||
[[self headerView] setNeedsLayout];
|
||||
[[self headerView] setNeedsDisplay:YES];
|
||||
|
||||
var rowIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [self numberOfRows])];
|
||||
[self reloadDataForRowIndexes:rowIndexes columnIndexes:[CPIndexSet indexSetWithIndex:columnIndex]];
|
||||
}
|
||||
|
||||
- (CPArray)tableColumns
|
||||
@@ -817,22 +853,22 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
|
||||
var count = deselectRows.length;
|
||||
while (count--)
|
||||
{
|
||||
var rowIndex = deselectRows[count];
|
||||
var view = dataViewsInTableColumn[rowIndex];
|
||||
[view unsetThemeState:CPThemeStateSelected];
|
||||
}
|
||||
|
||||
[self _performSelection:NO forRow:deselectRows[count] context:dataViewsInTableColumn];
|
||||
|
||||
count = selectRows.length;
|
||||
while (count--)
|
||||
{
|
||||
var rowIndex = selectRows[count];
|
||||
var view = dataViewsInTableColumn[rowIndex];
|
||||
[view setThemeState:CPThemeStateSelected];
|
||||
}
|
||||
[self _performSelection:YES forRow:selectRows[count] context:dataViewsInTableColumn];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_performSelection:(BOOL)select forRow:(CPInteger)rowIndex context:(id)context
|
||||
{
|
||||
var view = context[rowIndex],
|
||||
selector = select ? @"setThemeState:" : @"unsetThemeState:";
|
||||
|
||||
[view performSelector:CPSelectorFromString(selector) withObject:CPThemeStateSelected];
|
||||
}
|
||||
|
||||
- (void)_updateHighlightWithOldColumns:(CPIndexSet)oldColumns newColumns:(CPIndexSet)newColumns
|
||||
{
|
||||
var firstExposedColumn = [_exposedColumns firstIndex],
|
||||
@@ -1056,6 +1092,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
if (_dirtyTableColumnRangeIndex < 0)
|
||||
return;
|
||||
|
||||
_numberOfHiddenColumns = 0;
|
||||
|
||||
var index = _dirtyTableColumnRangeIndex,
|
||||
count = NUMBER_OF_COLUMNS(),
|
||||
x = index === 0 ? 0.0 : CPMaxRange(_tableColumnRanges[index - 1]);
|
||||
@@ -1065,7 +1103,10 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
var tableColumn = _tableColumns[index];
|
||||
|
||||
if ([tableColumn isHidden])
|
||||
{
|
||||
_numberOfHiddenColumns += 1;
|
||||
_tableColumnRanges[index] = CPMakeRange(x, 0.0);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
@@ -1086,8 +1127,10 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
- (CGRect)rectOfColumn:(CPInteger)aColumnIndex
|
||||
{
|
||||
aColumnIndex = +aColumnIndex;
|
||||
|
||||
var column = [[self tableColumns] objectAtIndex:aColumnIndex];
|
||||
|
||||
if (aColumnIndex < 0 || aColumnIndex >= NUMBER_OF_COLUMNS())
|
||||
if ([column isHidden] || aColumnIndex < 0 || aColumnIndex >= NUMBER_OF_COLUMNS())
|
||||
return _CGRectMakeZero();
|
||||
|
||||
UPDATE_COLUMN_RANGES_IF_NECESSARY();
|
||||
@@ -1780,7 +1823,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
return [[CPImage alloc] initWithContentsOfFile:@"Frameworks/AppKit/Resources/GenericFile.png" size:CGSizeMake(32,32)];
|
||||
}
|
||||
|
||||
- (CPView)dragViewForRowsWithIndexes:(CPIndexSet)theDraggedRows tableColumns:(CPArray)theTableColumns event:(CPEvent)theDragEvent offset:(CPPoint)dragViewOffset
|
||||
- (CPView)dragViewForRowsWithIndexes:(CPIndexSet)theDraggedRows tableColumns:(CPArray)theTableColumns event:(CPEvent)theDragEvent offset:(CPPointPointer)dragViewOffset
|
||||
{
|
||||
var bounds = [self bounds],
|
||||
view = [[CPView alloc] initWithFrame:bounds];
|
||||
@@ -1816,6 +1859,55 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
return view;
|
||||
}
|
||||
|
||||
/*!
|
||||
@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:(CPPointPointer)theDragViewOffset
|
||||
{
|
||||
var dragView = [[CPView alloc] initWithFrame:CPRectMakeZero()];
|
||||
tableColumn = [[self tableColumns] objectAtIndex:theColumnIndex],
|
||||
bounds = CPRectMake(0.0, 0.0, [tableColumn width], CPRectGetHeight([self _exposedRect]) + 23.0),
|
||||
columnRect = [self rectOfColumn:theColumnIndex],
|
||||
headerView = [tableColumn headerView];
|
||||
|
||||
row = [_exposedRows firstIndex];
|
||||
while (row !== CPNotFound)
|
||||
{
|
||||
var dataView = [self _newDataViewForRow:row tableColumn:tableColumn],
|
||||
dataViewFrame = [self frameOfDataViewAtColumn:theColumnIndex row:row];
|
||||
|
||||
// Only one column is ever dragged so we just place the view at
|
||||
dataViewFrame.origin.x = 0.0;
|
||||
|
||||
// Offset by table header height - scroll position
|
||||
dataViewFrame.origin.y = ( CPRectGetMinY(dataViewFrame) - CPRectGetMinY([self _exposedRect]) ) + 23.0;
|
||||
[dataView setFrame:dataViewFrame];
|
||||
|
||||
[dataView setObjectValue:[self _objectValueForTableColumn:tableColumn row:row]];
|
||||
[dragView addSubview:dataView];
|
||||
|
||||
row = [_exposedRows indexGreaterThanIndex:row];
|
||||
}
|
||||
|
||||
// Add the column header view
|
||||
var headerFrame = [headerView frame];
|
||||
headerFrame.origin = CPPointMakeZero();
|
||||
|
||||
columnHeaderView = [[_CPTableColumnHeaderView alloc] initWithFrame:headerFrame];
|
||||
[columnHeaderView setStringValue:[headerView stringValue]];
|
||||
[columnHeaderView setThemeState:[headerView themeState]];
|
||||
[dragView addSubview:columnHeaderView];
|
||||
|
||||
[dragView setBackgroundColor:[CPColor whiteColor]];
|
||||
[dragView setAlphaValue:0.7];
|
||||
[dragView setFrame:bounds];
|
||||
|
||||
return dragView;
|
||||
}
|
||||
|
||||
- (void)setDraggingSourceOperationMask:(CPDragOperation)mask forLocal:(BOOL)isLocal
|
||||
{
|
||||
//ignoral local for the time being since only one capp app can run at a time...
|
||||
@@ -2054,10 +2146,14 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
columnsCount = columnArray.length;
|
||||
|
||||
for (; columnIndex < columnsCount; ++columnIndex)
|
||||
{
|
||||
{
|
||||
var column = columnArray[columnIndex],
|
||||
tableColumn = _tableColumns[column],
|
||||
tableColumnUID = [tableColumn UID];
|
||||
tableColumn = _tableColumns[column];
|
||||
|
||||
if ([tableColumn isHidden] || columnIndex === _draggedColumnIndex)
|
||||
continue;
|
||||
|
||||
var tableColumnUID = [tableColumn UID];
|
||||
|
||||
if (!_dataViewsForTableColumns[tableColumnUID])
|
||||
_dataViewsForTableColumns[tableColumnUID] = [];
|
||||
@@ -2170,6 +2266,9 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
|
||||
- (void)_enqueueReusableDataView:(CPView)aDataView
|
||||
{
|
||||
if (!aDataView)
|
||||
return;
|
||||
|
||||
// FIXME: yuck!
|
||||
var identifier = aDataView.identifier;
|
||||
|
||||
@@ -2207,6 +2306,15 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
[self drawBackgroundInClipRect:exposedRect];
|
||||
[self drawGridInClipRect:exposedRect];
|
||||
[self highlightSelectionInClipRect:exposedRect];
|
||||
|
||||
if (_draggedColumnIndex === -1)
|
||||
return;
|
||||
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
columnRect = [self rectOfColumn:_draggedColumnIndex];
|
||||
|
||||
CGContextSetFillColor(context, [CPColor grayColor]);
|
||||
CGContextFillRect(context, columnRect);
|
||||
}
|
||||
|
||||
- (void)drawBackgroundInClipRect:(CGRect)aRect
|
||||
@@ -2214,7 +2322,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
if (!_usesAlternatingRowBackgroundColors)
|
||||
return;
|
||||
|
||||
|
||||
var rowColors = [self alternatingRowBackgroundColors],
|
||||
colorCount = [rowColors count];
|
||||
|
||||
@@ -3299,11 +3406,12 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
|
||||
unsigned dropOperation @accessors;
|
||||
CPTableView tableView @accessors;
|
||||
int currentRow @accessors;
|
||||
BOOL isBlinking @accessors;
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)aRect
|
||||
{
|
||||
if(tableView._destinationDragStyle === CPTableViewDraggingDestinationFeedbackStyleNone)
|
||||
if(tableView._destinationDragStyle === CPTableViewDraggingDestinationFeedbackStyleNone || isBlinking)
|
||||
return;
|
||||
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort];
|
||||
@@ -3369,7 +3477,28 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
|
||||
CGContextStrokePath(context);
|
||||
//CGContextStrokeLineSegments(context, [aRect.origin.x + 8, aRect.origin.y + 8, 300 , aRect.origin.y + 8]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)blink
|
||||
{
|
||||
if (dropOperation !== CPTableViewDropOn)
|
||||
return;
|
||||
|
||||
isBlinking = YES;
|
||||
|
||||
var showCallback = function() {
|
||||
objj_msgSend(self, "setHidden:", NO)
|
||||
isBlinking = NO;
|
||||
}
|
||||
|
||||
var hideCallback = function() {
|
||||
objj_msgSend(self, "setHidden:", YES)
|
||||
isBlinking = YES;
|
||||
}
|
||||
|
||||
objj_msgSend(self, "setHidden:", YES);
|
||||
[CPTimer scheduledTimerWithTimeInterval:0.1 callback:showCallback repeats:NO];
|
||||
[CPTimer scheduledTimerWithTimeInterval:0.19 callback:hideCallback repeats:NO];
|
||||
[CPTimer scheduledTimerWithTimeInterval:0.27 callback:showCallback repeats:NO];
|
||||
}
|
||||
@end
|
||||
+34
-3
@@ -171,7 +171,32 @@ CPWebViewScrollNative = 2;
|
||||
[self _resizeWebFrame];
|
||||
}
|
||||
|
||||
- (BOOL)_resizeWebFrame
|
||||
- (void)_attachScrollEventIfNecessary
|
||||
{
|
||||
if (_scrollMode !== CPWebViewScrollAppKit)
|
||||
return;
|
||||
|
||||
var win = null;
|
||||
try { win = [self DOMWindow]; } catch (e) {}
|
||||
|
||||
if (win && win.addEventListener)
|
||||
{
|
||||
var scrollEventHandler = function(anEvent)
|
||||
{
|
||||
var frameBounds = [self bounds],
|
||||
frameCenter = CGPointMake(CGRectGetMidX(frameBounds), CGRectGetMidY(frameBounds)),
|
||||
windowOrigin = [self convertPoint:frameCenter toView:nil],
|
||||
globalOrigin = [[self window] convertBaseToBridge:windowOrigin];
|
||||
|
||||
anEvent._overrideLocation = globalOrigin;
|
||||
[[[self window] platformWindow] scrollEvent:anEvent];
|
||||
};
|
||||
|
||||
win.addEventListener("DOMMouseScroll", scrollEventHandler, false);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_resizeWebFrame
|
||||
{
|
||||
if (_scrollMode === CPWebViewScrollAppKit)
|
||||
{
|
||||
@@ -181,7 +206,8 @@ CPWebViewScrollNative = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
[_frameView setFrameSize:[_scrollView contentSize]];
|
||||
var visibleRect = [_frameView visibleRect];
|
||||
[_frameView setFrameSize:CGSizeMake(CGRectGetMaxX(visibleRect), CGRectGetMaxY(visibleRect))];
|
||||
|
||||
// try to get the document size so we can correctly set the frame
|
||||
var win = null;
|
||||
@@ -203,6 +229,8 @@ CPWebViewScrollNative = 2;
|
||||
|
||||
[_frameView setFrameSize:CGSizeMake(800, 1600)];
|
||||
}
|
||||
|
||||
[_frameView scrollRectToVisible:visibleRect];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,6 +284,8 @@ CPWebViewScrollNative = 2;
|
||||
|
||||
[self _setScrollMode:CPWebViewScrollAppKit];
|
||||
|
||||
[_frameView setFrameSize:[_scrollView contentSize]];
|
||||
|
||||
[self _startedLoading];
|
||||
|
||||
_ignoreLoadStart = YES;
|
||||
@@ -315,7 +345,8 @@ CPWebViewScrollNative = 2;
|
||||
- (void)_finishedLoading
|
||||
{
|
||||
[self _resizeWebFrame];
|
||||
|
||||
[self _attachScrollEventIfNecessary];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPWebViewProgressFinishedNotification object:self];
|
||||
|
||||
if ([_frameLoadDelegate respondsToSelector:@selector(webView:didFinishLoadForFrame:)])
|
||||
|
||||
@@ -467,7 +467,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
[PlatformWindows addObject:self];
|
||||
|
||||
// FIXME: cpSetFrame?
|
||||
_DOMWindow.document.write("<html><head></head><body style = 'background-color:transparent;'></body></html>");
|
||||
_DOMWindow.document.write("<!DOCTYPE html><html lang='en'><head></head><body style='background-color:transparent;'></body></html>");
|
||||
_DOMWindow.document.close();
|
||||
|
||||
if (![CPPlatform isBrowser])
|
||||
@@ -851,12 +851,13 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
if(!aDOMEvent)
|
||||
aDOMEvent = window.event;
|
||||
|
||||
var location = nil;
|
||||
if (CPFeatureIsCompatible(CPJavaScriptMouseWheelValues_8_15))
|
||||
{
|
||||
var x = 0.0,
|
||||
y = 0.0,
|
||||
var x = aDOMEvent._offsetX || 0.0,
|
||||
y = aDOMEvent._offsetY || 0.0,
|
||||
element = aDOMEvent.target;
|
||||
|
||||
|
||||
while (element.nodeType !== 1)
|
||||
element = element.parentNode;
|
||||
|
||||
@@ -870,11 +871,13 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
} while (element = element.offsetParent);
|
||||
}
|
||||
|
||||
var location = _CGPointMake((x + ((aDOMEvent.clientX - 8) / 15)), (y + ((aDOMEvent.clientY - 8) / 15)));
|
||||
location = _CGPointMake((x + ((aDOMEvent.clientX - 8) / 15)), (y + ((aDOMEvent.clientY - 8) / 15)));
|
||||
}
|
||||
else if (aDOMEvent._overrideLocation)
|
||||
location = aDOMEvent._overrideLocation;
|
||||
else
|
||||
var location = _CGPointMake(aDOMEvent.clientX, aDOMEvent.clientY);
|
||||
|
||||
location = _CGPointMake(aDOMEvent.clientX, aDOMEvent.clientY);
|
||||
|
||||
var deltaX = 0.0,
|
||||
deltaY = 0.0,
|
||||
windowNumber = 0,
|
||||
@@ -883,7 +886,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
(aDOMEvent.ctrlKey ? CPControlKeyMask : 0) |
|
||||
(aDOMEvent.altKey ? CPAlternateKeyMask : 0) |
|
||||
(aDOMEvent.metaKey ? CPCommandKeyMask : 0);
|
||||
|
||||
|
||||
StopDOMEventPropagation = YES;
|
||||
|
||||
var theWindow = [self hitTest:location];
|
||||
@@ -1192,6 +1195,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
|
||||
[_windowLevels insertObject:aLevel atIndex:insertionIndex];
|
||||
layer._DOMElement.style.zIndex = aLevel;
|
||||
|
||||
_DOMBodyElement.appendChild(layer._DOMElement);
|
||||
}
|
||||
|
||||
|
||||
@@ -480,6 +480,12 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld,
|
||||
|
||||
- (void)willChangeValueForKey:(CPString)aKey
|
||||
{
|
||||
var superClass = [self class],
|
||||
methodSelector = @selector(willChangeValueForKey:),
|
||||
methodImp = class_getMethodImplementation(superClass, methodSelector);
|
||||
|
||||
methodImp(self, methodSelector, aKey);
|
||||
|
||||
if (!aKey)
|
||||
return;
|
||||
|
||||
@@ -490,6 +496,12 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld,
|
||||
|
||||
- (void)didChangeValueForKey:(CPString)aKey
|
||||
{
|
||||
var superClass = [self class],
|
||||
methodSelector = @selector(didChangeValueForKey:),
|
||||
methodImp = class_getMethodImplementation(superClass, methodSelector);
|
||||
|
||||
methodImp(self, methodSelector, aKey);
|
||||
|
||||
if (!aKey)
|
||||
return;
|
||||
|
||||
@@ -498,6 +510,12 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld,
|
||||
|
||||
- (void)willChange:(CPKeyValueChange)change valuesAtIndexes:(CPIndexSet)indexes forKey:(CPString)aKey
|
||||
{
|
||||
var superClass = [self class],
|
||||
methodSelector = @selector(willChange:valuesAtIndexes:forKey:),
|
||||
methodImp = class_getMethodImplementation(superClass, methodSelector);
|
||||
|
||||
methodImp(self, methodSelector, change, indexes, aKey);
|
||||
|
||||
if (!aKey)
|
||||
return;
|
||||
|
||||
@@ -508,6 +526,12 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld,
|
||||
|
||||
- (void)didChange:(CPKeyValueChange)change valuesAtIndexes:(CPIndexSet)indexes forKey:(CPString)aKey
|
||||
{
|
||||
var superClass = [self class],
|
||||
methodSelector = @selector(didChange:valuesAtIndexes:forKey:),
|
||||
methodImp = class_getMethodImplementation(superClass, methodSelector);
|
||||
|
||||
methodImp(self, methodSelector, change, indexes, aKey);
|
||||
|
||||
if (!aKey)
|
||||
return;
|
||||
|
||||
|
||||
@@ -129,8 +129,7 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
|
||||
- (void)sourceList
|
||||
{
|
||||
|
||||
var window3 = [[CPWindow alloc] initWithContentRect:CGRectMake(450, 250, 200, 400) styleMask:CPTitledWindowMask | CPResizableWindowMask];
|
||||
var window3 = [[CPWindow alloc] initWithContentRect:CGRectMake(450, 250, 500, 400) styleMask:CPTitledWindowMask | CPResizableWindowMask];
|
||||
|
||||
tableView3 = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 200.0, 500.0)];
|
||||
|
||||
@@ -150,6 +149,10 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
[column setMinWidth:50.0];
|
||||
[column setEditable:YES];
|
||||
[tableView3 addTableColumn:column];
|
||||
|
||||
var column = [[CPTableColumn alloc] initWithIdentifier:"sourcelist2"];
|
||||
[[column headerView] setStringValue:"Source List 2"];
|
||||
[tableView3 addTableColumn:column];
|
||||
|
||||
var scrollView3 = [[CPScrollView alloc] initWithFrame:[[window3 contentView] bounds]];
|
||||
[tableView3 setRowHeight:32.0];
|
||||
@@ -183,7 +186,7 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
else if (aTableView === tableView2)
|
||||
return String(dataSet2[aRow]);
|
||||
else if(aTableView === tableView3)
|
||||
return String(dataSet3[row]);
|
||||
return String(dataSet3[aRow]);
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView sortDescriptorsDidChange:(CPArray)oldDescriptors
|
||||
|
||||
Reference in new issue
Block a user