mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-22 22:45:52 +00:00
Merge branch 'master' into commonjs
This commit is contained in:
commit
82c71617d1
16 files changed
+245
-132
No files matched your search
@@ -530,6 +530,7 @@ CPButtonStateMixed = CPThemeState("mixed");
|
||||
[contentView setTextShadowOffset:[self currentValueForThemeAttribute:@"text-shadow-offset"]];
|
||||
[contentView setImagePosition:[self currentValueForThemeAttribute:@"image-position"]];
|
||||
[contentView setImageScaling:[self currentValueForThemeAttribute:@"image-scaling"]];
|
||||
[contentView setDimsImage:[self hasThemeState:CPThemeStateDisabled] && _imageDimsWhenDisabled];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -365,7 +365,7 @@ var LEFT_SHADOW_INSET = 3.0,
|
||||
return _isEditable;
|
||||
}
|
||||
|
||||
- (void)performDragOperation:(CPDraggingInfo)aSender
|
||||
- (BOOL)performDragOperation:(CPDraggingInfo)aSender
|
||||
{
|
||||
var images = [CPKeyedUnarchiver unarchiveObjectWithData:[[aSender draggingPasteboard] dataForType:CPImagesPboardType]];
|
||||
|
||||
@@ -374,6 +374,8 @@ var LEFT_SHADOW_INSET = 3.0,
|
||||
[self setImage:images[0]];
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -747,6 +747,9 @@ var _CPMenuBarVisible = NO,
|
||||
}
|
||||
|
||||
// Show it.
|
||||
if ([CPPlatform isBrowser])
|
||||
[menuWindow setPlatformWindow:[[aView window] platformWindow]];
|
||||
|
||||
[menuWindow orderFront:self];
|
||||
|
||||
// Track it.
|
||||
@@ -816,6 +819,9 @@ var _CPMenuBarVisible = NO,
|
||||
[menuWindow setFrameOrigin:CGRectIntersection(unconstrainedFrame, constraintRect).origin];
|
||||
}
|
||||
|
||||
if ([CPPlatform isBrowser])
|
||||
[menuWindow setPlatformWindow:[[aView window] platformWindow]];
|
||||
|
||||
[menuWindow orderFront:self];
|
||||
|
||||
[[_CPMenuManager sharedMenuManager]
|
||||
|
||||
+70
-69
@@ -36,7 +36,7 @@
|
||||
{
|
||||
[self _init];
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
{
|
||||
_textField = [[_CPImageAndTextView alloc] initWithFrame:CGRectMake(5, 1, CGRectGetWidth([self bounds]) - 10, CGRectGetHeight([self bounds]) - 1)];
|
||||
[_textField setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
|
||||
|
||||
|
||||
[_textField setLineBreakMode:CPLineBreakByTruncatingTail];
|
||||
[_textField setTextColor: [CPColor colorWithHexString: @"333333"]];
|
||||
[_textField setFont:[CPFont boldSystemFontOfSize:12.0]];
|
||||
@@ -137,7 +137,7 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
|
||||
[aCoder encodeObject:[_textField text] forKey:_CPTableColumnHeaderViewStringValueKey];
|
||||
[aCoder encodeObject:[_textField image] forKey:_CPTableColumnHeaderViewImageKey];
|
||||
[aCoder encodeObject:[_textField font] forKey:_CPTableColumnHeaderViewFontKey];
|
||||
@@ -151,13 +151,13 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
CPPoint _previousTrackingLocation;
|
||||
int _activeColumn;
|
||||
int _pressedColumn;
|
||||
|
||||
|
||||
BOOL _isResizing;
|
||||
BOOL _isDragging;
|
||||
BOOL _isTrackingColumn;
|
||||
|
||||
|
||||
float _columnOldWidth;
|
||||
|
||||
|
||||
CPTableView _tableView @accessors(property=tableView);
|
||||
}
|
||||
|
||||
@@ -167,11 +167,11 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
_previousTrackingLocation = CPPointMakeZero();
|
||||
_activeColumn = -1;
|
||||
_pressedColumn = -1;
|
||||
|
||||
|
||||
_isResizing = NO;
|
||||
_isDragging = NO;
|
||||
_isTrackingColumn = NO;
|
||||
|
||||
|
||||
_columnOldWidth = 0.0;
|
||||
|
||||
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
|
||||
@@ -195,11 +195,11 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
- (CGRect)headerRectOfColumn:(int)aColumnIndex
|
||||
{
|
||||
var headerRect = [self bounds],
|
||||
columnRect = [[self tableView] rectOfColumn:aColumnIndex];
|
||||
|
||||
columnRect = [_tableView rectOfColumn:aColumnIndex];
|
||||
|
||||
headerRect.origin.x = CPRectGetMinX(columnRect);
|
||||
headerRect.size.width = CPRectGetWidth(columnRect);
|
||||
|
||||
|
||||
return headerRect;
|
||||
}
|
||||
|
||||
@@ -223,13 +223,13 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
var headerView = [_tableView._tableColumns[_pressedColumn] headerView];
|
||||
[headerView unsetThemeState:CPThemeStateHighlighted];
|
||||
}
|
||||
|
||||
|
||||
if (column != -1)
|
||||
{
|
||||
var headerView = [_tableView._tableColumns[column] headerView];
|
||||
[headerView setThemeState:CPThemeStateHighlighted];
|
||||
}
|
||||
|
||||
|
||||
_pressedColumn = column;
|
||||
}
|
||||
|
||||
@@ -242,25 +242,27 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
{
|
||||
var type = [theEvent type],
|
||||
currentLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||
|
||||
|
||||
// Take the right columns resize tracking area into account
|
||||
currentLocation.x -= 5.0;
|
||||
|
||||
var columnIndex = [self columnAtPoint:currentLocation],
|
||||
shouldResize = [self shouldResizeTableColumn:columnIndex at:CPPointMake(currentLocation.x + 5.0, currentLocation.y)];
|
||||
|
||||
|
||||
if (type === CPLeftMouseUp)
|
||||
{
|
||||
if (shouldResize)
|
||||
[self stopResizingTableColumn:_activeColumn at:currentLocation];
|
||||
else if ([self _shouldStopTrackingTableColumn:columnIndex at:currentLocation])
|
||||
{
|
||||
[[self tableView] _didClickTableColumn:columnIndex modifierFlags:[theEvent modifierFlags]];
|
||||
[_tableView _didClickTableColumn:columnIndex modifierFlags:[theEvent modifierFlags]];
|
||||
[self stopTrackingTableColumn:columnIndex at:currentLocation];
|
||||
|
||||
|
||||
_isTrackingColumn = NO;
|
||||
}
|
||||
|
||||
[self _updateResizeCursor:[CPApp currentEvent]];
|
||||
|
||||
_activeColumn = CPNotFound;
|
||||
return;
|
||||
}
|
||||
@@ -269,11 +271,11 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
{
|
||||
if (columnIndex === -1)
|
||||
return;
|
||||
|
||||
|
||||
_mouseDownLocation = currentLocation;
|
||||
_activeColumn = columnIndex;
|
||||
|
||||
[[self tableView] _sendDelegateDidMouseDownInHeader:columnIndex];
|
||||
[_tableView _sendDelegateDidMouseDownInHeader:columnIndex];
|
||||
|
||||
if (shouldResize)
|
||||
[self startResizingTableColumn:columnIndex at:currentLocation];
|
||||
@@ -297,12 +299,12 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
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];
|
||||
}
|
||||
@@ -318,18 +320,18 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
{
|
||||
var columnRect = [self headerRectOfColumn:aColumnIndex],
|
||||
offset = CPPointMakeZero(),
|
||||
view = [[self tableView] _dragViewForColumn:aColumnIndex event:[CPApp currentEvent] offset:offset],
|
||||
view = [_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;
|
||||
}
|
||||
|
||||
@@ -347,28 +349,28 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
|
||||
- (BOOL)_shouldDragTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
||||
{
|
||||
return [[self tableView] allowsColumnReordering] && ABS(aPoint.x - _mouseDownLocation.x) >= 10.0;
|
||||
return [_tableView allowsColumnReordering] && ABS(aPoint.x - _mouseDownLocation.x) >= 10.0;
|
||||
}
|
||||
|
||||
- (CPRect)_headerRectOfLastVisibleColumn
|
||||
{
|
||||
var tableColumns = [[self tableView] tableColumns],
|
||||
var tableColumns = [_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],
|
||||
var tableColumns = [_tableView tableColumns],
|
||||
lastColumnRect = [self _headerRectOfLastVisibleColumn];
|
||||
activeColumnRect = [self headerRectOfColumn:_activeColumn];
|
||||
dragWindow = [theDragView window],
|
||||
@@ -395,20 +397,20 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
|
||||
- (void)_moveColumn:(int)aFromIndex toColumn:(int)aToIndex
|
||||
{
|
||||
[[self tableView] moveColumn:aFromIndex toColumn:aToIndex];
|
||||
[_tableView moveColumn:aFromIndex toColumn:aToIndex];
|
||||
_activeColumn = aToIndex;
|
||||
_pressedColumn = _activeColumn;
|
||||
|
||||
[[self tableView] _setDraggedColumn:_activeColumn];
|
||||
|
||||
[_tableView _setDraggedColumn:_activeColumn];
|
||||
}
|
||||
|
||||
- (void)draggedView:(CPView)aView beganAt:(CPPoint)aPoint
|
||||
{
|
||||
_isDragging = YES;
|
||||
|
||||
[[[[[self tableView] tableColumns] objectAtIndex:_activeColumn] headerView] setHidden:YES];
|
||||
[[self tableView] _setDraggedColumn:_activeColumn];
|
||||
|
||||
|
||||
[[[[_tableView tableColumns] objectAtIndex:_activeColumn] headerView] setHidden:YES];
|
||||
[_tableView _setDraggedColumn:_activeColumn];
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
@@ -450,11 +452,11 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
{
|
||||
_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];
|
||||
|
||||
[_tableView _setDraggedColumn:-1];
|
||||
[[[[_tableView tableColumns] objectAtIndex:_activeColumn] headerView] setHidden:NO];
|
||||
[self stopTrackingTableColumn:_activeColumn at:aLocation];
|
||||
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
@@ -462,38 +464,37 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
{
|
||||
if (_isResizing)
|
||||
return YES;
|
||||
|
||||
|
||||
if (_isTrackingColumn)
|
||||
return NO;
|
||||
|
||||
return [[self tableView] allowsColumnResizing] && CPRectContainsPoint([self _cursorRectForColumn:aColumnIndex], aPoint);
|
||||
return [_tableView allowsColumnResizing] && CPRectContainsPoint([self _cursorRectForColumn:aColumnIndex], aPoint);
|
||||
}
|
||||
|
||||
- (void)startResizingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
||||
{
|
||||
_isResizing = YES;
|
||||
|
||||
var tableColumn = [[[self tableView] tableColumns] objectAtIndex:aColumnIndex];
|
||||
|
||||
|
||||
var tableColumn = [[_tableView tableColumns] objectAtIndex:aColumnIndex];
|
||||
|
||||
[tableColumn setDisableResizingPosting:YES];
|
||||
[[self tableView] setDisableAutomaticResizing:YES];
|
||||
[_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;
|
||||
|
||||
var tableColumn = [[_tableView tableColumns] objectAtIndex:aColumnIndex],
|
||||
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;
|
||||
_tableView._lastColumnShouldSnap = NO;
|
||||
[tableColumn setWidth:newWidth];
|
||||
|
||||
|
||||
[[CPCursor resizeLeftRightCursor] set];
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
@@ -502,11 +503,11 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
|
||||
- (void)stopResizingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
||||
{
|
||||
var tableColumn = [[[self tableView] tableColumns] objectAtIndex:aColumnIndex];
|
||||
var tableColumn = [[_tableView tableColumns] objectAtIndex:aColumnIndex];
|
||||
[tableColumn _postDidResizeNotificationWithOldWidth:_columnOldWidth];
|
||||
[tableColumn setDisableResizingPosting:NO];
|
||||
[[self tableView] setDisableAutomaticResizing:NO];
|
||||
|
||||
[_tableView setDisableAutomaticResizing:NO];
|
||||
|
||||
_isResizing = NO;
|
||||
}
|
||||
|
||||
@@ -522,12 +523,12 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
var mouseLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil],
|
||||
mouseOverLocation = CGPointMake(mouseLocation.x - 5, mouseLocation.y),
|
||||
overColumn = [self columnAtPoint:mouseOverLocation];
|
||||
|
||||
|
||||
if (overColumn >= 0 && CGRectContainsPoint([self _cursorRectForColumn:overColumn], mouseLocation))
|
||||
{
|
||||
var tableColumn = [[_tableView tableColumns] objectAtIndex:overColumn],
|
||||
width = [tableColumn width];
|
||||
|
||||
|
||||
if (width == [tableColumn minWidth])
|
||||
[[CPCursor resizeRightCursor] set];
|
||||
else if (width == [tableColumn maxWidth])
|
||||
@@ -559,12 +560,12 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
{
|
||||
var tableColumns = [_tableView tableColumns],
|
||||
count = [tableColumns count];
|
||||
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var column = [tableColumns objectAtIndex:i],
|
||||
headerView = [column headerView];
|
||||
|
||||
|
||||
var frame = [self headerRectOfColumn:i];
|
||||
frame.size.height -= 0.5;
|
||||
if (i > 0)
|
||||
@@ -572,9 +573,9 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
frame.origin.x += 0.5;
|
||||
frame.size.width -= 1;
|
||||
}
|
||||
|
||||
|
||||
[headerView setFrame:frame];
|
||||
|
||||
|
||||
if([headerView superview] != self)
|
||||
[self addSubview:headerView];
|
||||
}
|
||||
@@ -601,23 +602,23 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
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, ROUND(columnMaxX) + 0.5, ROUND(CGRectGetMinY(columnToStroke)));
|
||||
CGContextAddLineToPoint(context, ROUND(columnMaxX) + 0.5, ROUND(CGRectGetMaxY(columnToStroke)));
|
||||
}
|
||||
|
||||
|
||||
CGContextClosePath(context);
|
||||
CGContextStrokePath(context);
|
||||
|
||||
|
||||
if (_isDragging)
|
||||
{
|
||||
CGContextSetFillColor(context, [CPColor grayColor]);
|
||||
|
||||
+42
-45
@@ -86,7 +86,7 @@ CPTableViewSolidVerticalGridLineMask = 1 << 0;
|
||||
CPTableViewSolidHorizontalGridLineMask = 1 << 1;
|
||||
|
||||
CPTableViewNoColumnAutoresizing = 0;
|
||||
CPTableViewUniformColumnAutoresizingStyle = 1;
|
||||
CPTableViewUniformColumnAutoresizingStyle = 1; // FIX ME: This is FUBAR
|
||||
CPTableViewSequentialColumnAutoresizingStyle = 2;
|
||||
CPTableViewReverseSequentialColumnAutoresizingStyle = 3;
|
||||
CPTableViewLastColumnOnlyAutoresizingStyle = 4;
|
||||
@@ -1283,68 +1283,63 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
return _CGRectMake(tableColumnRange.location, _CGRectGetMinY(rectOfRow), tableColumnRange.length, _CGRectGetHeight(rectOfRow));
|
||||
}
|
||||
|
||||
//FIX ME: We should refactor this!
|
||||
- (void)resizeWithOldSuperviewSize:(CGSize)aSize
|
||||
{
|
||||
[super resizeWithOldSuperviewSize:aSize];
|
||||
|
||||
|
||||
if (_disableAutomaticResizing)
|
||||
return;
|
||||
|
||||
var mask = _columnAutoResizingStyle;
|
||||
|
||||
if(mask === CPTableViewUniformColumnAutoresizingStyle)
|
||||
{
|
||||
[self _resizeAllColumnUniformlyWithOldSize:aSize];
|
||||
}
|
||||
|
||||
if(mask === CPTableViewLastColumnOnlyAutoresizingStyle)
|
||||
{
|
||||
else if(mask === CPTableViewLastColumnOnlyAutoresizingStyle)
|
||||
[self sizeLastColumnToFit];
|
||||
}
|
||||
else if(mask === CPTableViewFirstColumnOnlyAutoresizingStyle)
|
||||
[self _autoResizeFirstColumn];
|
||||
}
|
||||
|
||||
if(mask === CPTableViewFirstColumnOnlyAutoresizingStyle)
|
||||
{
|
||||
var superview = [self superview];
|
||||
- (void)_autoResizeFirstColumn
|
||||
{
|
||||
var superview = [self superview];
|
||||
|
||||
if (!superview)
|
||||
return;
|
||||
if (!superview)
|
||||
return;
|
||||
|
||||
var superviewSize = [superview bounds].size;
|
||||
var superviewSize = [superview bounds].size;
|
||||
|
||||
UPDATE_COLUMN_RANGES_IF_NECESSARY();
|
||||
UPDATE_COLUMN_RANGES_IF_NECESSARY();
|
||||
|
||||
var count = NUMBER_OF_COLUMNS();
|
||||
var count = NUMBER_OF_COLUMNS(),
|
||||
visColumns = [[CPArray alloc] init],
|
||||
totalWidth = 0,
|
||||
i = 0;
|
||||
|
||||
var visColumns = [[CPArray alloc] init];
|
||||
var totalWidth = 0;
|
||||
for(; i < count; i++)
|
||||
{
|
||||
if(![_tableColumns[i] isHidden])
|
||||
{
|
||||
[visColumns addObject:i];
|
||||
totalWidth += [_tableColumns[i] width];
|
||||
}
|
||||
}
|
||||
|
||||
for(var i=0; i < count; i++)
|
||||
{
|
||||
if(![_tableColumns[i] isHidden])
|
||||
{
|
||||
[visColumns addObject:i];
|
||||
totalWidth += [_tableColumns[i] width];
|
||||
}
|
||||
}
|
||||
count = [visColumns count];
|
||||
|
||||
count = [visColumns count];
|
||||
//if there are rows
|
||||
if (count > 0)
|
||||
{
|
||||
var columnToResize = _tableColumns[visColumns[0]];
|
||||
var newWidth = superviewSize.width - totalWidth;// - [columnToResize width];
|
||||
newWidth += [columnToResize width];
|
||||
newWidth = (newWidth < [columnToResize minWidth]) ? [columnToResize minWidth] : newWidth;
|
||||
newWidth = (newWidth > [columnToResize maxWidth]) ? [columnToResize maxWidth] : newWidth;
|
||||
|
||||
//if there are rows
|
||||
if (count > 0)
|
||||
{
|
||||
var columnToResize = _tableColumns[visColumns[0]];
|
||||
var newWidth = superviewSize.width - totalWidth;// - [columnToResize width];
|
||||
newWidth += [columnToResize width];
|
||||
newWidth = (newWidth < [columnToResize minWidth]) ? [columnToResize minWidth] : newWidth;
|
||||
newWidth = (newWidth > [columnToResize maxWidth]) ? [columnToResize maxWidth] : newWidth;
|
||||
|
||||
[columnToResize setWidth:FLOOR(newWidth)];
|
||||
}
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
[columnToResize setWidth:FLOOR(newWidth)];
|
||||
}
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)_resizeAllColumnUniformlyWithOldSize:(CGSize)oldSize
|
||||
@@ -2459,6 +2454,9 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
|
||||
- (void)highlightSelectionInClipRect:(CGRect)aRect
|
||||
{
|
||||
if (_selectionHighlightStyle === CPTableViewDraggingDestinationFeedbackStyleNone)
|
||||
return;
|
||||
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
indexes = [],
|
||||
rectSelector = @selector(rectOfRow:);
|
||||
@@ -2488,9 +2486,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
if (!count)
|
||||
return;
|
||||
|
||||
var drawGradient = (_selectionHighlightStyle === CPTableViewSelectionHighlightStyleSourceList && [_selectedRowIndexes count] >= 1);
|
||||
|
||||
var deltaHeight = 0.5 * (_gridStyleMask & CPTableViewSolidHorizontalGridLineMask);
|
||||
var drawGradient = (_selectionHighlightStyle === CPTableViewSelectionHighlightStyleSourceList && [_selectedRowIndexes count] >= 1),
|
||||
deltaHeight = 0.5 * (_gridStyleMask & CPTableViewSolidHorizontalGridLineMask);
|
||||
|
||||
CGContextBeginPath(context);
|
||||
while (count--)
|
||||
|
||||
+17
-4
@@ -69,11 +69,13 @@ CPWebViewScrollNative = 2;
|
||||
|
||||
CPString _url;
|
||||
CPString _html;
|
||||
|
||||
|
||||
Function _loadCallback;
|
||||
|
||||
|
||||
int _scrollMode;
|
||||
CGSize _scrollSize;
|
||||
|
||||
int _loadHTMLStringTimer;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CPRect)frameRect frameName:(CPString)frameName groupName:(CPString)groupName
|
||||
@@ -110,6 +112,7 @@ CPWebViewScrollNative = 2;
|
||||
_iframe.style.width = "100%";
|
||||
_iframe.style.height = "100%";
|
||||
_iframe.style.borderWidth = "0px";
|
||||
_iframe.frameBorder = "0";
|
||||
|
||||
[self setDrawsBackground:YES];
|
||||
|
||||
@@ -245,7 +248,10 @@ CPWebViewScrollNative = 2;
|
||||
|
||||
- (void)_setScrollMode:(int)aScrollMode
|
||||
{
|
||||
_scrollMode = aScrollMode;
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
_scrollMode = CPWebViewScrollNative;
|
||||
else
|
||||
_scrollMode = aScrollMode;
|
||||
|
||||
_ignoreLoadStart = YES;
|
||||
_ignoreLoadEnd = YES;
|
||||
@@ -323,8 +329,15 @@ CPWebViewScrollNative = 2;
|
||||
// clear the iframe
|
||||
_iframe.src = "";
|
||||
|
||||
if (_loadHTMLStringTimer !== nil)
|
||||
{
|
||||
window.clearTimeout(_loadHTMLStringTimer);
|
||||
_loadHTMLStringTimer = nil;
|
||||
}
|
||||
|
||||
// need to give the browser a chance to reset iframe, otherwise we'll be document.write()-ing the previous document
|
||||
window.setTimeout(function() {
|
||||
_loadHTMLStringTimer = window.setTimeout(function()
|
||||
{
|
||||
var win = [self DOMWindow];
|
||||
|
||||
win.document.write(_html);
|
||||
|
||||
@@ -74,6 +74,15 @@ var PrimaryPlatformWindow = NULL;
|
||||
return [CPSet set];
|
||||
}
|
||||
|
||||
+ (BOOL)supportsMultipleInstances
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
return !CPBrowserIsEngine(CPInternetExplorerBrowserEngine);
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (CPPlatformWindow)primaryPlatformWindow
|
||||
{
|
||||
return PrimaryPlatformWindow;
|
||||
|
||||
@@ -63,6 +63,7 @@ var HORIZONTAL_MARGIN = 3.0,
|
||||
|
||||
CPCellImagePosition _imagePosition;
|
||||
CPImageScaling _imageScaling;
|
||||
BOOL _shouldDimImage;
|
||||
|
||||
CPImage _image;
|
||||
CPString _text;
|
||||
@@ -211,6 +212,17 @@ var HORIZONTAL_MARGIN = 3.0,
|
||||
return _imageScaling;
|
||||
}
|
||||
|
||||
- (void)setDimsImage:(BOOL)shouldDim
|
||||
{
|
||||
var shouldDimImage = !!shouldDimImage;
|
||||
|
||||
if (_shouldDimImage !== shouldDimImage)
|
||||
{
|
||||
_shouldDimImage = shouldDim;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setTextColor:(CPColor)aTextColor
|
||||
{
|
||||
if (_textColor === aTextColor)
|
||||
@@ -572,6 +584,11 @@ var HORIZONTAL_MARGIN = 3.0,
|
||||
imageHeight *= scale;
|
||||
}
|
||||
|
||||
if (CPFeatureIsCompatible(CPOpacityRequiresFilterFeature))
|
||||
imageStyle.filter = @"alpha(opacity=" + _shouldDimImage ? 35 : 100 + ")";
|
||||
else
|
||||
imageStyle.opacity = _shouldDimImage ? 0.35 : 1.0;
|
||||
|
||||
_DOMImageElement.width = imageWidth;
|
||||
_DOMImageElement.height = imageHeight;
|
||||
imageStyle.width = MAX(imageWidth, 0) + "px";
|
||||
|
||||
+17
-12
@@ -269,13 +269,16 @@ var CPRunLoopLastNativeRunLoop = 0;
|
||||
|
||||
aTimer._lastNativeRunLoopsForModes[aMode] = CPRunLoopLastNativeRunLoop;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
if (!_runLoopInsuranceTimer)
|
||||
_runLoopInsuranceTimer = window.setNativeTimeout(function()
|
||||
{
|
||||
[self limitDateForMode:CPDefaultRunLoopMode];
|
||||
}, 0);
|
||||
#endif
|
||||
|
||||
// FIXME: Hack for not doing this in CommonJS
|
||||
if ([CFBundle.environments() indexOfObject:("Browser")] !== CPNotFound)
|
||||
{
|
||||
if (!_runLoopInsuranceTimer)
|
||||
_runLoopInsuranceTimer = window.setNativeTimeout(function()
|
||||
{
|
||||
[self limitDateForMode:CPDefaultRunLoopMode];
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -289,13 +292,15 @@ var CPRunLoopLastNativeRunLoop = 0;
|
||||
|
||||
_runLoopLock = YES;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
if (_runLoopInsuranceTimer)
|
||||
// FIXME: Hack for not doing this in CommonJS
|
||||
if ([CFBundle.environments() indexOfObject:("Browser")] !== CPNotFound)
|
||||
{
|
||||
window.clearNativeTimeout(_runLoopInsuranceTimer);
|
||||
_runLoopInsuranceTimer = nil;
|
||||
if (_runLoopInsuranceTimer)
|
||||
{
|
||||
window.clearNativeTimeout(_runLoopInsuranceTimer);
|
||||
_runLoopInsuranceTimer = nil;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
var now = _effectiveDate ? [_effectiveDate laterDate:[CPDate date]] : [CPDate date],
|
||||
nextFireDate = nil,
|
||||
|
||||
@@ -453,7 +453,9 @@ BundleTask.prototype.resourcesPath = function()
|
||||
|
||||
// Don't sprite images larger than 32KB, IE 8 doesn't like it.
|
||||
BundleTask.isSpritable = function(aResourcePath) {
|
||||
return isImage(aResourcePath) && FILE.size(aResourcePath) < 32768;
|
||||
return isImage(aResourcePath) && FILE.size(aResourcePath) < 32768 &&
|
||||
("data:" + mimeType(aResourcePath) + ";base64," +
|
||||
base64.encode(FILE.read(aResourcePath, "b"))).length < 32768;
|
||||
}
|
||||
|
||||
BundleTask.prototype.defineResourceTask = function(aResourcePath, aDestinationPath)
|
||||
|
||||
@@ -99,6 +99,13 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
[tableView2 setDelegate:self];
|
||||
[tableView2 setDataSource:self];
|
||||
|
||||
|
||||
var checkBox = [[CPCheckBox alloc] initWithFrame:CGRectMake(5,3,24,24)],
|
||||
checkBoxColumn = [[CPTableColumn alloc] initWithIdentifier:@"checkBox"];
|
||||
[checkBoxColumn setDataView:checkBox];
|
||||
|
||||
[tableView2 addTableColumn:checkBoxColumn];
|
||||
|
||||
var desc = [CPSortDescriptor sortDescriptorWithKey:@"self" ascending:YES];
|
||||
for (var i = 1; i <= 3; i++)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// AppController+WebPolicyDelegate.m
|
||||
// NativeHost
|
||||
//
|
||||
// Created by Francisco Tolmasky on 5/11/10.
|
||||
// Copyright 2010 280 North, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSURL+Additions.h"
|
||||
#import "AppController.h"
|
||||
|
||||
|
||||
@implementation AppController (WebPolicyDelegate)
|
||||
|
||||
- (void)webView:(WebView *)aWebView decidePolicyForNewWindowAction:(NSDictionary *)actionInformation request:(NSURLRequest *)aRequest newFrameName:(NSString *)aFrameName decisionListener:(id < WebPolicyDecisionListener >)aListener
|
||||
{
|
||||
[[NSWorkspace sharedWorkspace] openURL:[actionInformation objectForKey:WebActionOriginalURLKey]];
|
||||
[aListener ignore];
|
||||
}
|
||||
|
||||
- (void)webView:(WebView *)aWebView decidePolicyForNavigationAction:(NSDictionary *)aDictionary request:(NSURLRequest *)aRequest frame:(WebFrame *)aWebFrame decisionListener:(id <WebPolicyDecisionListener>)aDecisionListener
|
||||
{
|
||||
NSURL * requestURL = [aRequest URL];
|
||||
|
||||
if([aWebView mainFrame] != aWebFrame ||
|
||||
[[baseURL scheme] isEqualTo:[requestURL scheme]] &&
|
||||
![baseURL host] || [[baseURL host] isEqualTo:[requestURL host]] &&
|
||||
![baseURL port] || [[baseURL port] isEqualTo:[requestURL port]])
|
||||
return [aDecisionListener use];
|
||||
|
||||
[[NSWorkspace sharedWorkspace] openURL:[aDictionary objectForKey:WebActionOriginalURLKey]];
|
||||
[aDecisionListener ignore];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -27,8 +27,12 @@ extern NSString *SERVER_USER;
|
||||
NSFileHandle * stdinFileHandle;
|
||||
|
||||
NSMutableAttributedString * loggedOutput;
|
||||
|
||||
NSURL * baseURL;
|
||||
}
|
||||
|
||||
- (NSURL *)baseURL;
|
||||
|
||||
- (void)startServer;
|
||||
- (void)startCappuccinoApplication;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ int SERVER_PORT = 9191;
|
||||
NSString *SERVER_PASSWORD = nil;
|
||||
NSString *SERVER_USER = nil;
|
||||
|
||||
|
||||
@implementation AppController
|
||||
|
||||
- (id)init
|
||||
@@ -139,6 +140,11 @@ NSString *SERVER_USER = nil;
|
||||
[stdinFileHandle readInBackgroundAndNotify];
|
||||
}
|
||||
|
||||
- (NSURL *)baseURL
|
||||
{
|
||||
return baseURL;
|
||||
}
|
||||
|
||||
- (void)startCappuccinoApplication
|
||||
{
|
||||
NSString *initialURL = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NHInitialURL"];
|
||||
@@ -152,10 +158,12 @@ NSString *SERVER_USER = nil;
|
||||
initialResource = @"Application/index.html";
|
||||
|
||||
initialURL = [[NSString stringWithFormat:@"file://%@/%@", [[NSBundle mainBundle] resourcePath], initialResource] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
baseURL = [[NSURL alloc] initWithString:@"file:///"];
|
||||
}
|
||||
else if (prependServer)
|
||||
{
|
||||
initialURL = [NSString stringWithFormat:@"http://127.0.0.1:%d/%@", SERVER_PORT, initialURL];
|
||||
baseURL = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"http://127.0.0.1:%d/", SERVER_PORT]];
|
||||
}
|
||||
|
||||
NHLog(@"STARTUP", [initialURL description]);
|
||||
@@ -175,6 +183,7 @@ NSString *SERVER_USER = nil;
|
||||
[webView setUIDelegate:self];
|
||||
[webView setFrameLoadDelegate:self];
|
||||
[webView setResourceLoadDelegate:self];
|
||||
[webView setPolicyDelegate:self];
|
||||
|
||||
webViewWindow = [[NSWindow alloc] init];
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
9E43AC84104DB51400263989 /* WebScripObject+Objective-J.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E43AC83104DB51400263989 /* WebScripObject+Objective-J.m */; };
|
||||
9E44CA9D0FD798FE00860A54 /* NSURL+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E44CA9C0FD798FE00860A54 /* NSURL+Additions.m */; };
|
||||
9E4EBB4210892BDE0091C8E9 /* BridgedMethods.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E4EBB4110892BDE0091C8E9 /* BridgedMethods.m */; };
|
||||
9E52D2F9119B05EF00B831FC /* AppController+WebPolicyDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E52D2F8119B05EF00B831FC /* AppController+WebPolicyDelegate.m */; };
|
||||
9E535D05104F6F4900C119FA /* AppController+MainMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E535D04104F6F4900C119FA /* AppController+MainMenu.m */; };
|
||||
9E535D32104F73FB00C119FA /* MenuBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E535D31104F73FB00C119FA /* MenuBridge.m */; };
|
||||
9E535D37104F761F00C119FA /* MenuItemBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E535D36104F761F00C119FA /* MenuItemBridge.m */; };
|
||||
@@ -55,6 +56,7 @@
|
||||
9E44CA9C0FD798FE00860A54 /* NSURL+Additions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURL+Additions.m"; sourceTree = "<group>"; };
|
||||
9E4EBB4010892BDE0091C8E9 /* BridgedMethods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgedMethods.h; sourceTree = "<group>"; };
|
||||
9E4EBB4110892BDE0091C8E9 /* BridgedMethods.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BridgedMethods.m; sourceTree = "<group>"; };
|
||||
9E52D2F8119B05EF00B831FC /* AppController+WebPolicyDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AppController+WebPolicyDelegate.m"; sourceTree = "<group>"; };
|
||||
9E535D04104F6F4900C119FA /* AppController+MainMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AppController+MainMenu.m"; sourceTree = "<group>"; };
|
||||
9E535D30104F73FB00C119FA /* MenuBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuBridge.h; sourceTree = "<group>"; };
|
||||
9E535D31104F73FB00C119FA /* MenuBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MenuBridge.m; sourceTree = "<group>"; };
|
||||
@@ -106,6 +108,7 @@
|
||||
9ED96C881020072300D24B9C /* AppController+WebFrameLoadDelegate.m */,
|
||||
9ED96C891020072300D24B9C /* AppController+WebResourceLoadDelegate.m */,
|
||||
9ED96C871020072300D24B9C /* AppController+WebUIDelegate.m */,
|
||||
9E52D2F8119B05EF00B831FC /* AppController+WebPolicyDelegate.m */,
|
||||
9EB99C940FD8968100AA94A2 /* AppController.h */,
|
||||
9EB99C950FD8968100AA94A2 /* AppController.m */,
|
||||
9EA1BEF5107E7EE500CDE684 /* Application.h */,
|
||||
@@ -297,6 +300,7 @@
|
||||
ADCCEF6810D43C970055BDFD /* WebPasteboardProxy.m in Sources */,
|
||||
9E43AC84104DB51400263989 /* WebScripObject+Objective-J.m in Sources */,
|
||||
9E5D4F0D1090FB6E00E76B38 /* WebWindow.m in Sources */,
|
||||
9E52D2F9119B05EF00B831FC /* AppController+WebPolicyDelegate.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -110,6 +110,7 @@ CGEventRef headTapCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef e
|
||||
[webView setUIDelegate:delegate];
|
||||
[webView setFrameLoadDelegate:delegate];
|
||||
[webView setResourceLoadDelegate:delegate];
|
||||
[webView setPolicyDelegate:delegate];
|
||||
[webView setShouldCloseWithWindow:YES];
|
||||
|
||||
[shadowView addSubview:webView];
|
||||
|
||||
Reference in new issue
Block a user