Merge branch 'jake' into enstore_jake

Conflicts:
	AppKit/CPTableView.j
This commit is contained in:
Klaas Pieter Annema
2010-02-01 11:07:42 +01:00
29 changed files with 451 additions and 148 deletions
+10
View File
@@ -8,6 +8,16 @@
{
}
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
if (self)
[self setNeedsLayout];
return self;
}
+ (CPString)themeClass
{
return @"button-bar";
+7 -1
View File
@@ -333,6 +333,8 @@
while (count--)
{
[[_items[count] view] removeFromSuperview];
[_items[count] setSelected:NO];
_cachedItems.push(_items[count]);
}
@@ -351,7 +353,11 @@
[self addSubview:[_items[index] view]];
}
index = CPNotFound;
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound)
[_items[index] setSelected:YES];
[self tile];
}
+25 -34
View File
@@ -104,17 +104,14 @@ var CPProgressIndicatorSpinningStyleColors = nil,
for (; start <= end; ++start)
{
CPProgressIndicatorBezelBorderViewPool[start] = [];
CPProgressIndicatorBezelBorderViewPool[start][CPMiniControlSize] = [];
CPProgressIndicatorBezelBorderViewPool[start][CPSmallControlSize] = [];
CPProgressIndicatorBezelBorderViewPool[start][CPRegularControlSize] = [];
}
CPProgressIndicatorClassName = [self className];
CPProgressIndicatorStyleIdentifiers = [];
CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle] = @"Bar";
CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorSpinningStyle] = @"Spinny";
CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle] = @"HUDBar";
@@ -126,30 +123,20 @@ var CPProgressIndicatorSpinningStyleColors = nil,
CPProgressIndicatorStyleSizes = [];
// Bar Sttyle
var prefix = CPProgressIndicatorClassName + @"BezelBorder" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle];
var prefixes = [
CPProgressIndicatorClassName + @"BezelBorder" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle],
CPProgressIndicatorClassName + @"Bar" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle],
CPProgressIndicatorClassName + @"BezelBorder" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle],
CPProgressIndicatorClassName + @"Bar" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle]
];
CPProgressIndicatorStyleSizes[prefix + regularIdentifier] = [_CGSizeMake(3.0, 15.0), _CGSizeMake(1.0, 15.0), _CGSizeMake(3.0, 15.0)];
CPProgressIndicatorStyleSizes[prefix + smallIdentifier] = [_CGSizeMake(3.0, 15.0), _CGSizeMake(1.0, 15.0), _CGSizeMake(3.0, 15.0)];
CPProgressIndicatorStyleSizes[prefix + miniIdentifier] = [_CGSizeMake(3.0, 15.0), _CGSizeMake(1.0, 15.0), _CGSizeMake(3.0, 15.0)];
prefix = CPProgressIndicatorClassName + @"Bar" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle];
CPProgressIndicatorStyleSizes[prefix + regularIdentifier] = _CGSizeMake(1.0, 9.0);
CPProgressIndicatorStyleSizes[prefix + smallIdentifier] = _CGSizeMake(1.0, 9.0);
CPProgressIndicatorStyleSizes[prefix + miniIdentifier] = _CGSizeMake(1.0, 9.0);
// HUD Bar Style
prefix = CPProgressIndicatorClassName + @"BezelBorder" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle];
CPProgressIndicatorStyleSizes[prefix + regularIdentifier] = [_CGSizeMake(3.0, 15.0), _CGSizeMake(1.0, 15.0), _CGSizeMake(3.0, 15.0)];
CPProgressIndicatorStyleSizes[prefix + smallIdentifier] = [_CGSizeMake(3.0, 15.0), _CGSizeMake(1.0, 15.0), _CGSizeMake(3.0, 15.0)];
CPProgressIndicatorStyleSizes[prefix + miniIdentifier] = [_CGSizeMake(3.0, 15.0), _CGSizeMake(1.0, 15.0), _CGSizeMake(3.0, 15.0)];
prefix = CPProgressIndicatorClassName + @"Bar" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle];
CPProgressIndicatorStyleSizes[prefix + regularIdentifier] = _CGSizeMake(1.0, 9.0);
CPProgressIndicatorStyleSizes[prefix + smallIdentifier] = _CGSizeMake(1.0, 9.0);
CPProgressIndicatorStyleSizes[prefix + miniIdentifier] = _CGSizeMake(1.0, 9.0);
for (var i = 0, count = prefixes.length; i<count; i++)
{
var prefix = prefixes[i];
CPProgressIndicatorStyleSizes[prefix + regularIdentifier] = [_CGSizeMake(3.0, 16.0), _CGSizeMake(1.0, 16.0), _CGSizeMake(3.0, 16.0)];
CPProgressIndicatorStyleSizes[prefix + smallIdentifier] = [_CGSizeMake(3.0, 16.0), _CGSizeMake(1.0, 16.0), _CGSizeMake(3.0, 16.0)];
CPProgressIndicatorStyleSizes[prefix + miniIdentifier] = [_CGSizeMake(3.0, 16.0), _CGSizeMake(1.0, 16.0), _CGSizeMake(3.0, 16.0)];
}
}
- (id)initWithFrame:(CGRect)aFrame
@@ -428,21 +415,25 @@ var CPProgressIndicatorSpinningStyleColors = nil,
if (!_barView)
{
_barView = [[CPView alloc] initWithFrame:CGRectMake(2.0, 2.0, 0.0, 9.0)];
[_barView setBackgroundColor:[CPColor redColor]];
_barView = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 16.0)];
[self addSubview:_barView];
}
[_barView setBackgroundColor:_CPControlColorWithPatternImage(
[_barView setBackgroundColor:_CPControlThreePartImagePattern(
NO,
CPProgressIndicatorStyleSizes,
CPProgressIndicatorClassName,
@"Bar",
CPProgressIndicatorStyleIdentifiers[_style],
_CPControlIdentifierForControlSize(_controlSize))];
[_barView setFrameSize:CGSizeMake(CGRectGetWidth([self bounds]) * (_doubleValue - _minValue) / (_maxValue - _minValue) - 4.0, 9.0)];
var width = CGRectGetWidth([self bounds]),
barWidth = width * ((_doubleValue - _minValue) / (_maxValue - _minValue));
if (barWidth > 0.0 && barWidth < 4.0)
barWidth = 4.0;
[_barView setFrameSize:CGSizeMake(barWidth, 16.0)];
}
/* @ignore */
+1 -2
View File
@@ -71,8 +71,7 @@ CPTableColumnUserResizingMask = 2;
[self setIdentifier:anIdentifier];
var header = [CPTextField new];
[header setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 23.0))]];
var header = [[_CPTableColumnHeaderView alloc] initWithFrame:CGRectMakeZero()];
[self setHeaderView:header];
var textDataView = [[CPTextField alloc] init];
+198 -30
View File
@@ -23,12 +23,67 @@
@import "CPTableColumn.j"
@import "CPTableView.j"
@import "CPView.j"
var CPThemeStatePressed = CPThemeState("pressed");
@implementation _CPTableColumnHeaderView : CPView
{
CPTextField _textField;
}
- (void)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
_textField = [[CPTextField alloc] initWithFrame:[self bounds]];
[_textField setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
[self addSubview:_textField];
}
return self;
}
- (void)layoutSubviews
{
var themeState = [self themeState];
if((themeState & CPThemeStateSelected) && (themeState & CPThemeStatePressed))
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview-highlighted-pressed.png", CGSizeMake(1.0, 22.0))]];
else if (themeState == CPThemeStateSelected)
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview-highlighted.png", CGSizeMake(1.0, 22.0))]];
else if (themeState == CPThemeStatePressed)
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview-pressed.png", CGSizeMake(1.0, 22.0))]];
else
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
}
- (void)setStringValue:(CPString)string
{
[_textField setStringValue:string];
}
- (CPString)stringValue
{
return [_textField stringValue];
}
- (void)textField
{
return _textField;
}
- (void)sizeToFit
{
[_textField sizeToFit];
}
@end
@implementation CPTableHeaderView : CPView
{
int _resizedColumn @accessors(readonly, property=resizedColumn);
int _draggedColumn @accessors(readonly, property=draggedColumn);
int _pressedColumn @accessors(readonly, property=pressedColumn);
float _draggedDistance @accessors(readonly, property=draggedDistance);
@@ -43,7 +98,9 @@
{
_resizedColumn = CPNotFound;
_draggedColumn = CPNotFound;
_pressedColumn = CPNotFound;
_draggedDistance = 0.0;
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
}
return self;
@@ -94,52 +151,163 @@
return bounds;
}
- (CPRect)_resizeRectBeforeColumn:(CPInteger)column
{
var rect = [self headerRectOfColumn:column];
rect.origin.x -= 10;
rect.size.width = 20;
return rect;
}
- (void)_setPressedColumn:(CPInteger)column
{
if (_pressedColumn != CPNotFound)
{
var headerView = [_tableView._tableColumns[_pressedColumn] headerView];
[headerView unsetThemeState:CPThemeStatePressed];
}
if (column != CPNotFound)
{
var headerView = [_tableView._tableColumns[column] headerView];
[headerView setThemeState:CPThemeStatePressed];
}
_pressedColumn = column;
}
- (void)mouseDown:(CPEvent)theEvent
{
var location = [self convertPoint:[theEvent locationInWindow] fromView:nil],
aPoint = CGPointMakeCopy(location),
clickedColumn = [self columnAtPoint:aPoint];
if (clickedColumn == -1)
return;
// Error, can't find var CPTableViewDelegate_tableView_mouseDownInHeaderOfTableColumn_ !?
if (_tableView._implementedDelegateMethods & (1 << 6))
[[_tableView delegate] tableView:_tableView
mouseDownInHeaderOfTableColumn:[[_tableView tableColumns] objectAtIndex:clickedColumn]];
[self _setPressedColumn:clickedColumn];
}
- (void)mouseUp:(CPEvent)theEvent
{
var location = [self convertPoint:[theEvent locationInWindow] fromView:nil],
clickedColumn = [self columnAtPoint:location];
[self _setPressedColumn:CPNotFound];
if (clickedColumn == -1)
return;
if ([_tableView allowsColumnSelection])
{
if ([theEvent modifierFlags] & CPCommandKeyMask)
{
if ([_tableView isColumnSelected:clickedColumn])
[_tableView deselectColumn:clickedColumn];
else if ([_tableView allowsMultipleSelection] == YES)
[_tableView selectColumnIndexes:[CPIndexSet indexSetWithIndex:clickedColumn] byExtendingSelection:YES];
}
else if ([theEvent modifierFlags] & CPShiftKeyMask)
{
// should be from clickedColumn to lastClickedColum with extending:(direction == previous selection)
var selectedIndexes = [_tableView selectedColumnIndexes],
startColumn = MIN(clickedColumn, [selectedIndexes lastIndex]),
endColumn = MAX(clickedColumn, [selectedIndexes firstIndex]);
[_tableView selectColumnIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(startColumn, endColumn - startColumn + 1)] byExtendingSelection:YES];
}
else
[_tableView selectColumnIndexes:[CPIndexSet indexSetWithIndex:clickedColumn] byExtendingSelection:NO];
}
}
- (void)layoutSubviews
{
var tableColumns = [_tableView tableColumns],
count = [tableColumns count],
columnRect = [self bounds],
spacing = [_tableView intercellSpacing];
for (i = 0; i < count; ++i)
var tableColumns = [_tableView tableColumns],
count = [tableColumns count];
for (var i = 0; i < count; i++)
{
var column = [tableColumns objectAtIndex:i],
headerView = [column headerView];
columnRect.size.width = [column width] + spacing.width;
[headerView setFrame:columnRect];
columnRect.origin.x += [column width] + spacing.width;
[self addSubview:headerView];
var frame = [self headerRectOfColumn:i];
frame.size.height -= 0.5;
if (i > 0)
{
frame.origin.x += 0.5;
frame.size.width -= 1;
}
[headerView setFrame:frame];
if([headerView superview] != self)
[self addSubview:headerView];
}
}
- (void)drawRect:(CGRect)aRect
{
[[_tableView gridColor] setStroke];
var context = [[CPGraphicsContext currentContext] graphicsPort],
exposedColumnIndexes = exposedColumnIndexes = [_tableView columnIndexesInRect:aRect],
columnsArray = [];
exposedColumnIndexes = [_tableView columnIndexesInRect:aRect],
columnsArray = [],
tableColumns = [_tableView tableColumns],
exposedTableColumns = _tableView._exposedColumns,
firstIndex = [exposedTableColumns firstIndex],
exposedRange = CPMakeRange(firstIndex, [exposedTableColumns lastIndex] - firstIndex + 1);
[exposedColumnIndexes getIndexes:columnsArray maxCount:-1 inIndexRange:nil];
CGContextSetLineWidth(context, 1);
CGContextSetStrokeColor(context, [_tableView gridColor]);
[exposedColumnIndexes getIndexes:columnsArray maxCount:-1 inIndexRange:exposedRange];
var columnArrayIndex = 0,
columnArrayCount = columnsArray.length;
for(; columnArrayIndex < columnArrayCount; ++columnArrayIndex)
columnArrayCount = columnsArray.length,
columnMaxX;
CGContextBeginPath(context);
for(; columnArrayIndex < columnArrayCount; columnArrayIndex++)
{
// grab each column rect and add horizontal lines
var columnToStroke = [self headerRectOfColumn:columnArrayIndex];
CGContextBeginPath(context);
CGContextMoveToPoint(context, ROUND(columnToStroke.origin.x + columnToStroke.size.width) + 0.5, ROUND(columnToStroke.origin.y) + 0.5);
CGContextAddLineToPoint(context, ROUND(columnToStroke.origin.x + columnToStroke.size.width) + 0.5, ROUND(columnToStroke.origin.y + columnToStroke.size.height) + 0.5);
CGContextSetLineWidth(context, 1);
CGContextStrokePath(context);
// 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);
/*
var maxY = CGRectGetMaxY([self bounds]);
// draw normal gradient for remaining space
if (supportsCanvasGradient)
{
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);
*/
}
@end
+179 -37
View File
@@ -122,6 +122,13 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
@end
/*!
@ingroup appkit
@class CPTableView
CPTableView object displays record-oriented data in a table and allows the user to edit values and resize and rearrange columns.
A CPTableView requires you to set a dataSource which implements numberOfRowsInTableView: and tableView:objectValueForTableColumn:row:
*/
@implementation CPTableView : CPControl
{
id _dataSource;
@@ -146,6 +153,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
//Configuring Behavior
BOOL _allowsColumnReordering;
BOOL _allowsColumnResizing;
BOOL _allowsColumnSelection;
BOOL _allowsMultipleSelection;
BOOL _allowsEmptySelection;
@@ -266,6 +274,11 @@ window.setTimeout(function(){
return self;
}
/*!
Sets the receiverÕs data source to a given object.
@param anObject The data source for the receiver. The object must implement the appropriate methods.
*/
- (void)setDataSource:(id)aDataSource
{
if (_dataSource === aDataSource)
@@ -303,6 +316,9 @@ window.setTimeout(function(){
[self reloadData];
}
/*!
Returns the object that provides the data displayed by the receiver.
*/
- (id)dataSource
{
return _dataSource;
@@ -310,6 +326,11 @@ window.setTimeout(function(){
//Loading Data
/*!
Reloads the data for only the specified rows and columns.
@param rowIndexes The indexes of the rows to update.
@param columnIndexes The indexes of the columns to update.
*/
- (void)reloadDataForRowIndexes:(CPIndexSet)rowIndexes columnIndexes:(CPIndexSet)columnIndexes
{
[self reloadData];
@@ -317,7 +338,10 @@ window.setTimeout(function(){
// [_previouslyExposedColumns removeIndexes:columnIndexes];
}
/*!
Reloads the data for all rows and columns.
*/
- (void)reloadData
{
if (!_dataSource)
@@ -334,7 +358,10 @@ window.setTimeout(function(){
}
//Target-action Behavior
/*!
Sets the message sent to the target when the user double-clicks an uneditable cell or a column header to a given selector.
@param aSelector The message the receiver sends to its target when the user double-clicks an uneditable cell or a column header.
*/
- (void)setDoubleAction:(SEL)anAction
{
_doubleAction = anAction;
@@ -371,6 +398,10 @@ window.setTimeout(function(){
return _allowsColumnResizing;
}
/*!
Controls whether the user can select more than one row or column at a time.
@param aFlag YES to allow the user to select multiple rows or columns, otherwise NO.
*/
- (void)setAllowsMultipleSelection:(BOOL)shouldAllowMultipleSelection
{
_allowsMultipleSelection = !!shouldAllowMultipleSelection;
@@ -381,6 +412,10 @@ window.setTimeout(function(){
return _allowsMultipleSelection;
}
/*!
Controls whether the receiver allows zero rows or columns to be selected.
@param aFlag YES if an empty selection is allowed, otherwise NO.
*/
- (void)setAllowsEmptySelection:(BOOL)shouldAllowEmptySelection
{
_allowsEmptySelection = !!shouldAllowEmptySelection;
@@ -391,6 +426,11 @@ window.setTimeout(function(){
return _allowsEmptySelection;
}
/*!
Controls whether the user can select an entire column by clicking its header.
@param aFlag YES to allow the user to select columns, otherwise NO.
*/
- (void)setAllowsColumnSelection:(BOOL)shouldAllowColumnSelection
{
_allowsColumnSelection = !!shouldAllowColumnSelection;
@@ -439,13 +479,12 @@ window.setTimeout(function(){
return _rowHeight;
}
/*!
Sets whether the receiver uses the standard alternating row colors for its background.
@param aFlag YES to specify standard alternating row colors for the background, NO to specify a solid color.
*/
- (void)setUsesAlternatingRowBackgroundColors:(BOOL)shouldUseAlternatingRowBackgroundColors
{
// TODO:need to look at how one actually sets the alternating row, a tip at:
// http://forums.macnn.com/79/developer-center/228347/nstableview-alternating-row-colors/
// otherwise this may not be feasible or may introduce an additional change req'd in CP
// we'd probably need to iterate through rowId % 2 == 0 and setBackgroundColor with
// whatever the alternating row color is.
_usesAlternatingRowBackgroundColors = shouldUseAlternatingRowBackgroundColors;
}
@@ -454,6 +493,11 @@ window.setTimeout(function(){
return _usesAlternatingRowBackgroundColors;
}
/*!
Sets the colors for the rows as they alternate. The number of colors can be arbitrary. By deafult these colors are white and light blue.
@param anArray an array of CPColors
*/
- (void)setAlternatingRowBackgroundColors:(CPArray)alternatingRowBackgroundColors
{
if ([_alternatingRowBackgroundColors isEqual:alternatingRowBackgroundColors])
@@ -490,6 +534,11 @@ window.setTimeout(function(){
}
}
/*!
Sets the highlight color for rows. By default this color is blue.
@param aColor a CPColor
*/
- (void)setSelectionHightlightColor:(CPColor)aColor
{
_selectionHightlightColor = aColor;
@@ -505,6 +554,10 @@ window.setTimeout(function(){
* - setIndicatorImage:inTableColumn:
*/
/*!
Sets the grid color in the non highlighted state.
@param aColor a CPColor
*/
- (void)setGridColor:(CPColor)aColor
{
if (_gridColor === aColor)
@@ -520,6 +573,11 @@ window.setTimeout(function(){
return _gridColor;
}
/*!
Sets the grid style mask to specify if no grid lines, vertical grid lines, or horizontal grid lines should be displayed.
@param gridType The grid style mask. CPTableViewGridNone, CPTableViewSolidVerticalGridLineMask, CPTableViewSolidHorizontalGridLineMask
*/
- (void)setGridStyleMask:(unsigned)aGrideStyleMask
{
if (_gridStyleMask === aGrideStyleMask)
@@ -537,6 +595,10 @@ window.setTimeout(function(){
//Column Management
/*!
Adds a given column as the last column of the receiver.
@param aColumn The column to add to the receiver.
*/
- (void)addTableColumn:(CPTableColumn)aTableColumn
{
[_tableColumns addObject:aTableColumn];
@@ -550,6 +612,10 @@ window.setTimeout(function(){
[self setNeedsLayout];
}
/*!
Removes a given column from the receiver.
@param aTableColumn The column to remove from the receiver.
*/
- (void)removeTableColumn:(CPTableColumn)aTableColumn
{
if ([aTableColumn tableView] !== self)
@@ -576,6 +642,12 @@ window.setTimeout(function(){
[self setNeedsLayout];
}
/*!
Moves the column and heading at a given index to a new given index.
@param columnIndex The current index of the column to move.
@param newIndex The new index for the moved column.
*/
- (void)moveColumn:(unsigned)fromIndex toColumn:(unsigned)toIndex
{
fromIndex = +fromIndex;
@@ -628,6 +700,12 @@ window.setTimeout(function(){
}
//Selecting Columns and Rows
/*!
Sets the column selection using indexes.
@param columns a CPIndexSet of columns to select
@param aFlag should extend the selection thereby retaining the previous selection
*/
- (void)selectColumnIndexes:(CPIndexSet)columns byExtendingSelection:(BOOL)shouldExtendSelection
{
// If we're out of range, just return
@@ -656,6 +734,11 @@ window.setTimeout(function(){
[self _noteSelectionDidChange];
}
/*!
Sets the row selection using indexes.
@param rows a CPIndexSet of rows to select
@param aFlag should extend the selection thereby retaining the previous selection
*/
- (void)selectRowIndexes:(CPIndexSet)rows byExtendingSelection:(BOOL)shouldExtendSelection
{
if ([rows isEqualToIndexSet:_selectedRowIndexes] || (([rows firstIndex] != CPNotFound && [rows firstIndex] < 0) || [rows lastIndex] >= [self numberOfRows]))
@@ -768,13 +851,17 @@ window.setTimeout(function(){
- (void)deselectColumn:(CPInteger)aColumn
{
[_selectedColumnIndexes removeIndex:aColumn];
var selectedColumnIndexes = [_selectedColumnIndexes copy];
[selectedColumnIndexes removeIndex:aColumn];
[self selectColumnIndexes:selectedColumnIndexes byExtendingSelection:NO];
[self _noteSelectionDidChange];
}
- (void)deselectRow:(CPInteger)aRow
{
[_selectedRowIndexes removeIndex:aRow];
var selectedRowIndexes = [_selectedRowIndexes copy];
[selectedRowIndexes removeIndex:aRow];
[self selectColumnIndexes:selectedRowIndexes byExtendingSelection:NO];
[self _noteSelectionDidChange];
}
@@ -808,6 +895,10 @@ window.setTimeout(function(){
* - allowsTypeSelect
* - setAllowsTypeSelect:
*/
/*!
Deselects all rows
*/
- (void)deselectAll
{
[self selectRowIndexes:[CPIndexSet indexSet] byExtendingSelection:NO];
@@ -955,6 +1046,11 @@ window.setTimeout(function(){
// Complexity:
// O(1)
/*!
Returns a range of indices for the rows that lie wholly or partially within the vertical boundaries of a given rectangle.
@param aRect A rectangle in the coordinate system of the receiver.
*/
- (CPRange)rowsInRect:(CGRect)aRect
{
// If we have no rows, then we won't intersect anything.
@@ -985,6 +1081,11 @@ window.setTimeout(function(){
// Complexity:
// O(lg Columns) if table view contains no hidden columns
// O(Columns) if table view contains hidden columns
/*!
Returns the indexes of the receiverÕs columns that intersect the specified rectangle.
@param aRect A rectangle in the coordinate system of the receiver.
*/
- (CPIndexSet)columnIndexesInRect:(CGRect)aRect
{
var column = MAX(0, [self columnAtPoint:_CGPointMake(aRect.origin.x, 0.0)]),
@@ -1180,6 +1281,10 @@ window.setTimeout(function(){
}
/*!
Sets the column autoresizing style of the receiver to a given style.
@param aStyle The column autoresizing style for the receiver. CPTableViewNoColumnAutoresizing, CPTableViewUniformColumnAutoresizingStyle, CPTableViewLastColumnOnlyAutoresizingStyle, CPTableViewFirstColumnOnlyAutoresizingStyle
*/
- (void)setColumnAutoresizingStyle:(unsigned)style
{
//FIX ME: CPTableViewSequentialColumnAutoresizingStyle and CPTableViewReverseSequentialColumnAutoresizingStyle are not yet implemented
@@ -1191,6 +1296,9 @@ window.setTimeout(function(){
return _columnAutoResizingStyle;
}
/*!
Resizes the last column if thereÕs room so the receiver fits exactly within its enclosing clip view.
*/
- (void)sizeLastColumnToFit
{
var superview = [self superview];
@@ -1265,11 +1373,19 @@ window.setTimeout(function(){
* - scrollColumnToVisible:
*/
/*!
Scrolls the receiver vertically in an enclosing NSClipView so the row specified by rowIndex is visible.
@param aRowIndex the index of the row to scroll to.
*/
- (void)scrollRowToVisible:(int)rowIndex
{
[self scrollRectToVisible:[self rectOfRow:rowIndex]];
}
/*!
Scrolls the receiver and header view horizontally in an enclosing NSClipView so the column specified by columnIndex is visible.
@param aColumnIndex the index of the column to scroll to.
*/
- (void)scrollColumnToVisible:(int)columnIndex
{
[self scrollRectToVisible:[self rectOfColumn:columnIndex]];
@@ -1429,6 +1545,11 @@ window.setTimeout(function(){
* - setVerticalMotionCanBeginDrag:
* - verticalMotionCanBeginDrag
*/
/*!
Returns whether the receiver allows dragging the rows at rowIndexes with a drag initiated at mousedDownPoint.
@param rowIndexes an index set of rows to be dragged
@param aPoint the point at which the mouse was clicked.
*/
- (BOOL)canDragRowsWithIndexes:(CPIndexSet)rowIndexes atPoint:(CGPoint)mouseDownPoint
{
return YES;
@@ -1500,8 +1621,8 @@ window.setTimeout(function(){
_dragOperationDefaultMask = mask;
}
/*
this should be called inside tableView:validateDrop:... method
/*!
This should be called inside tableView:validateDrop:... method
either drop on or above,
specify the row as -1 to select the whole table for drop on
*/
@@ -1517,16 +1638,16 @@ window.setTimeout(function(){
_retargetedDropOperation = operation;
}
/*
can be:
/*!
sets the feedback style for when the table is the destination of a drag operation
Can be:
None
Regular
Source List
FIX ME: this should vary up the highlight color, currently nothing is being done with it
*/
- (void)setDraggingDestinationFeedbackStyle:(CPTableViewDraggingDestinationFeedbackStyle)aStyle
{
//FIX ME: this should vary up the highlight color, currently nothing is being done with it
_destinationDragStyle = aStyle;
}
@@ -1535,6 +1656,10 @@ window.setTimeout(function(){
return _destinationDragStyle;
}
/*!
Sets whether vertical motion is treated as a drag or selection change to flag.
@param aFlag If flag is NO then vertical motion will not start a drag. The default is YES.
*/
- (void)setVerticalMotionCanBeginDrag:(BOOL)aFlag
{
_verticalMotionCanDrag = aFlag;
@@ -1818,7 +1943,10 @@ window.setTimeout(function(){
}
- (void)_drawRect:(CGRect)aRect
{
{
// FIX ME: All three of these methods will likely need to be rewritten for 1.0
// We've got grid drawing in highlightSelection and crap everywhere.
var exposedRect = [self _exposedRect];
[self drawBackgroundInClipRect:exposedRect];
@@ -1854,7 +1982,7 @@ window.setTimeout(function(){
// CGContextFillRect(context, CGRectIntersection(aRect, fillRect));
// console.profile("row-paint");
var exposedRows = [self rowsInRect:aRect],
firstRow = exposedRows.location,
firstRow = exposedRows.location -1,
lastRow = CPMaxRange(exposedRows) - 1,
colorIndex = MIN(exposedRows.length, colorCount),
heightFilled = 0.0;
@@ -2022,33 +2150,34 @@ window.setTimeout(function(){
CGContextBeginPath(context);
gridStyleMask = [self gridStyleMask];
for(var i=0; i < count2-1; i++)
for(var i=0; i < count2; i++)
{
var rect = [self rectOfRow:indexes[i]],
minX = _CGRectGetMinX(rect) - 0.5,
maxX = _CGRectGetMaxX(rect) - 0.5,
minY = _CGRectGetMinY(rect) - 0.5,
maxY = _CGRectGetMaxY(rect) - 0.5;
var rect = objj_msgSend(self, rectSelector, indexes[i]),
minX = CGRectGetMinX(rect) - 0.5,
maxX = CGRectGetMaxX(rect) - 0.5,
minY = CGRectGetMinY(rect) - 0.5,
maxY = CGRectGetMaxY(rect) - 0.5;
//FIX ME: if there are vertical lines we need to make them white too...
/*if (gridStyleMask & CPTableViewSolidVerticalGridLineMask)
if ([_selectedRowIndexes count] >= 1 && gridStyleMask & CPTableViewSolidVerticalGridLineMask)
{
var exposedColumns = [self columnIndexesInRect:aRect],
columnIndexes = [],
exposedColumns2 = CPMakeRange([exposedColumns firstIndex], [exposedColumns lastIndex] - firstColumn + 1);
[exposedColumns getIndexes:columnIndexes maxCount:-1 inIndexRange:exposedColumns2],
columnCount = [exposedColumns count];
for(var c = 0; c < columnCount - 1; c++)
exposedColumnIndexes = [],
firstExposedColumn = [exposedColumns firstIndex],
exposedRange = CPMakeRange(firstExposedColumn, [exposedColumns lastIndex] - firstExposedColumn + 1);
[exposedColumns getIndexes:exposedColumnIndexes maxCount:-1 inIndexRange:exposedRange];
var exposedColumnCount = [exposedColumnIndexes count];
for(var c = firstExposedColumn; c < exposedColumnCount; c++)
{
var colRect = [self rectOfColumn:columnIndexes[c]],
colX = _CGRectGetMaxX(rect) - 0.5;
console.log("colX");
//console.log(columnIndexes);
var colRect = [self rectOfColumn:exposedColumnIndexes[c]],
colX = CGRectGetMaxX(colRect) + 0.5;
//console.log(colX);
CGContextMoveToPoint(context, colX, minY);
CGContextAddLineToPoint(context, colX, maxY);
}
}*/
}
CGContextMoveToPoint(context, minX, maxY);
CGContextAddLineToPoint(context, maxX, maxY);
@@ -2121,12 +2250,17 @@ window.setTimeout(function(){
*/
/*
@ignore
*/
- (BOOL)tracksMouseOutsideOfFrame
{
return YES;
}
/* ignore */
/*
@ignore
*/
- (BOOL)startTrackingAt:(CGPoint)aPoint
{
var row = [self rowAtPoint:aPoint];
@@ -2160,6 +2294,9 @@ window.setTimeout(function(){
return YES;
}
/*
@ignore
*/
- (void)trackMouse:(CPEvent)anEvent
{
// Prevent CPControl from eating the mouse events when we are in a drag session
@@ -2169,7 +2306,9 @@ window.setTimeout(function(){
[CPApp sendEvent:anEvent];
}
/* ignore */
/*
@ignore
*/
- (BOOL)continueTracking:(CGPoint)lastPoint at:(CGPoint)aPoint
{
var row = [self rowAtPoint:aPoint];
@@ -2244,6 +2383,9 @@ window.setTimeout(function(){
return YES;
}
/*!
@ignore
*/
- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
{
_isSelectingSession = NO;
+17 -2
View File
@@ -21,9 +21,11 @@
*/
CPPlatformDidClearBodyElementNotification = @"CPPlatformDidClearBodyElementNotification";
CPPlatformWillClearBodyElementNotification = @"CPPlatformWillClearBodyElementNotification";
var screenNeedsInitialization = NO,
mainBodyElement = nil;
mainBodyElement = nil,
elementRemovalTest = new RegExp("\\bcpdontremove\\b", "g");
@implementation CPPlatform : CPBasePlatform
{
@@ -91,10 +93,23 @@ var screenNeedsInitialization = NO,
screenNeedsInitialization = NO;
[[CPNotificationCenter defaultCenter]
postNotificationName:CPPlatformWillClearBodyElementNotification
object:self];
var bodyElement = [self mainBodyElement];
// Get rid of any of the original contents of the page.
bodyElement.innerHTML = "";
var children = bodyElement.childNodes,
length = children.length;
while (length--)
{
var element = children[length];
if (!element.className || element.className.match(elementRemovalTest) === null)
bodyElement.removeChild(element);
}
bodyElement.style.overflow = "hidden";
if (document.documentElement)
+9 -27
View File
@@ -22,8 +22,8 @@
#include "../CoreGraphics/CGGeometry.h"
var DOMSpanElement = nil,
DOMIFrameElement = nil,
DefaultFont = nil;
@implementation CPPlatformString : CPBasePlatformString
@@ -33,17 +33,11 @@ var DOMSpanElement = nil,
+ (void)bootstrap
{
[self createDOMElements];
[[CPNotificationCenter defaultCenter]
addObserver:self
selector:@selector(platformDidClearBodyElement:)
name:CPPlatformDidClearBodyElementNotification
object:CPPlatform];
}
+ (void)createDOMElements
{
var DOMIFrameElement = document.createElement("iframe");
DOMIFrameElement = document.createElement("iframe");
// necessary for Safari caching bug:
DOMIFrameElement.name = "iframe_" + FLOOR(RAND() * 10000);
DOMIFrameElement.style.position = "absolute";
@@ -54,6 +48,7 @@ var DOMSpanElement = nil,
DOMIFrameElement.style.borderWidth = "0px";
DOMIFrameElement.style.overflow = "hidden";
DOMIFrameElement.style.zIndex = 100000000000;
DOMIFrameElement.className = "cpdontremove";
var bodyElement = [CPPlatform mainBodyElement];
@@ -80,11 +75,6 @@ var DOMSpanElement = nil,
DOMDivElement.appendChild(DOMSpanElement);
}
+ (void)platformDidClearBodyElement:(CPNotification)aNotification
{
[self createDOMElements];
}
+ (CGSize)sizeOfString:(CPString)aString withFont:(CPFont)aFont forWidth:(float)aWidth
{
if (!aFont)
@@ -97,33 +87,25 @@ var DOMSpanElement = nil,
var style = DOMSpanElement.style;
if (aWidth === NULL)
if (!aWidth)
{
style.width = "";
style.whiteSpace = "pre";
}
else
{
style.width = ROUND(aWidth) + "px";
if (document.attachEvent)
style.wordWrap = "break-word";
else
{
style.whiteSpace = "-o-pre-wrap";
style.whiteSpace = "-pre-wrap";
style.whiteSpace = "-moz-pre-wrap";
style.whiteSpace = "pre-wrap";
}
style.wordWrap = "break-word";
style.whiteSpace = "-o-pre-wrap";
style.whiteSpace = "-pre-wrap";
style.whiteSpace = "-moz-pre-wrap";
style.whiteSpace = "pre-wrap";
}
style.font = [aFont cssString];
if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature))
DOMSpanElement.innerText = aString;
else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature))
DOMSpanElement.textContent = aString;
+2 -13
View File
@@ -239,6 +239,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
_DOMFocusElement.style.zIndex = "-1000";
_DOMFocusElement.style.opacity = "0";
_DOMFocusElement.style.filter = "alpha(opacity=0)";
_DOMFocusElement.className = "cpdontremove";
_DOMBodyElement.appendChild(_DOMFocusElement);
@@ -248,6 +249,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
_DOMPasteboardElement.style.position = "absolute";
_DOMPasteboardElement.style.top = "-10000px";
_DOMPasteboardElement.style.zIndex = "999";
_DOMPasteboardElement.className = "cpdontremove";
_DOMBodyElement.appendChild(_DOMPasteboardElement);
@@ -255,11 +257,6 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
_DOMPasteboardElement.blur();
}
- (void)platformDidClearBodyElement:(CPNotification)aNotification
{
[self createDOMElements];
}
- (void)registerDOMWindow
{
var theDocument = _DOMWindow.document;
@@ -273,14 +270,6 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
_DOMBodyElement.webkitTouchCallout = "none";
[self createDOMElements];
if (window === _DOMWindow)
[[CPNotificationCenter defaultCenter]
addObserver:self
selector:@selector(platformDidClearBodyElement:)
name:CPPlatformDidClearBodyElementNotification
object:CPPlatform];
[self _addLayers];
var theClass = [self class],
Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 B

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 B

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

+3 -2
View File
@@ -37,6 +37,7 @@ CPLogRegister(CPLogConsole);
tableView = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 500.0, 500.0)];//[view bounds]];
[tableView setAllowsMultipleSelection:YES];
[tableView setAllowsColumnSelection:YES];
[tableView setUsesAlternatingRowBackgroundColors:YES];
[tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask];
@@ -68,7 +69,7 @@ CPLogRegister(CPLogConsole);
// [textDataView setBackgroundColor:[[CPColor redColor] colorWithAlphaComponent:0.5]];
for (var i = 1; i <= 3; i++)
for (var i = 1; i <= 2; i++)
{
var column = [[CPTableColumn alloc] initWithIdentifier:String(i)];
@@ -85,7 +86,7 @@ CPLogRegister(CPLogConsole);
//[tableView selectColumnIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0,2)] byExtendingSelection:YES];
[tableView setColumnAutoresizingStyle:CPTableViewUniformColumnAutoresizingStyle];
// [tableView setColumnAutoresizingStyle:CPTableViewUniformColumnAutoresizingStyle];
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([view bounds]), CGRectGetHeight([view bounds]))];
[tableView setRowHeight:22.0];