diff --git a/AppKit/CPTableColumn.j b/AppKit/CPTableColumn.j index d4f964723..b22ebd87b 100644 --- a/AppKit/CPTableColumn.j +++ b/AppKit/CPTableColumn.j @@ -177,7 +177,7 @@ CPTableColumnUserResizingMask = 1 << 1; _maxWidth = aMaxWidth; var width = [self width], - newWidth = MAX(width, [self maxWidth]); + newWidth = MIN(width, [self maxWidth]); if (width !== newWidth) [self setWidth:newWidth]; diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 3ce56c2a0..8a496e176 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -1365,8 +1365,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; if (newSize > 0) { - newSize = (newSize < [columnToResize minWidth]) ? [columnToResize minWidth] : newSize; - newSize = (newSize > [columnToResize maxWidth]) ? [columnToResize maxWidth] : newSize; + newSize = MAX([columnToResize minWidth], newSize); + newSize = MIN([columnToResize maxWidth], newSize); [columnToResize setWidth:newSize]; } } diff --git a/AppKit/_CPCornerView.j b/AppKit/_CPCornerView.j index 633e1bcac..af78c6b90 100644 --- a/AppKit/_CPCornerView.j +++ b/AppKit/_CPCornerView.j @@ -15,4 +15,21 @@ return self; } +- (void)drawRect:(CGRect)aRect +{ + var context = [[CPGraphicsContext currentContext] graphicsPort]; + + CGContextSetStrokeColor(context, [CPColor colorWithHexString:@"dce0e2"]); + + var points = [ + CGPointMake(aRect.origin.x, aRect.origin.y), + CGPointMake(aRect.origin.x + aRect.size.width, aRect.origin.y), + + CGPointMake(aRect.origin.x, aRect.origin.y + 0.5), + CGPointMake(aRect.origin.x, aRect.origin.y + aRect.size.height) + ]; + + CGContextStrokeLineSegments(context, points, 2); +} + @end diff --git a/Tests/Manual/TableTest/AppController.j b/Tests/Manual/TableTest/AppController.j index 313907c9b..4b474c364 100644 --- a/Tests/Manual/TableTest/AppController.j +++ b/Tests/Manual/TableTest/AppController.j @@ -28,21 +28,18 @@ CPLogRegister(CPLogConsole); dataSet2[i - 1] = [CPNumber numberWithInt:i+10]; } - var window1 = [[CPWindow alloc] initWithContentRect:CGRectMake(50, 50, 500, 400) styleMask:CPTitledWindowMask], + var window1 = [[CPWindow alloc] initWithContentRect:CGRectMake(50, 50, 500, 400) styleMask:CPTitledWindowMask | CPResizableWindowMask], view = [window1 contentView]; [view setBackgroundColor:[CPColor whiteColor]]; - //[view enterFullScreenMode:nil withOptions:nil]; - tableView = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 500.0, 500.0)];//[view bounds]]; + tableView = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 500.0, 500.0)]; [tableView setAllowsMultipleSelection:YES]; [tableView setAllowsColumnSelection:YES]; [tableView setUsesAlternatingRowBackgroundColors:YES]; [tableView setAlternatingRowBackgroundColors:[[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"], [CPColor colorWithHexString:@"f4e7ff"]]]; [tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask]; - -// [tableView setBackgroundColor:[CPColor blueColor]]; var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)]; @@ -58,18 +55,6 @@ CPLogRegister(CPLogConsole); iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)]; -// [textDataView setFrameSize:CGSizeMake(200,32)]; - // [textDataView setValue:CGInsetMake(9.0, 7.0, 5.0, 8.0) forThemeAttribute:@"content-inset"]; - //[textDataView setValue:CGInsetMake(9.0, 7.0, 5.0, 8.0) forThemeAttribute:@"content-inset"]; - //[textDataView setValue:CGInsetMake(4.0, 4.0, 3.0, 4.0) forThemeAttribute:@"bezel-inset"]; -// [textDataView setValue:CGInsetMake(2, 0, 0, 0) forThemeAttribute:@"focus-inset"]; - // [textDataView setValue:CGInsetMake(0, 0, 0, 0) forThemeAttribute:@"focus-inset" inState:CPThemeStateBezeled|CPThemeStateEditing]; - - //[textDataView setValue:CGSizeMake(1,1) forThemeAttribute:@"text-shadow-offset"]; - //[textDataView setValue:[CPColor blackColor] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateHighlighted]; - -// [textDataView setBackgroundColor:[[CPColor redColor] colorWithAlphaComponent:0.5]]; - var desc = [CPSortDescriptor sortDescriptorWithKey:@"self" ascending:YES]; for (var i = 1; i <= 2; i++) { @@ -78,18 +63,14 @@ CPLogRegister(CPLogConsole); [[column headerView] setStringValue:"Number "+i]; [column setMinWidth:50.0]; - [column setMaxWidth:250.0]; + [column setMaxWidth:500.0]; [column setWidth:200.0]; [column setEditable:YES]; [tableView addTableColumn:column]; } - - //[tableView._tableColumns[1] setSortDescriptorPrototype:desc]; - - //[tableView selectColumnIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0,2)] byExtendingSelection:YES]; - // [tableView setColumnAutoresizingStyle:CPTableViewUniformColumnAutoresizingStyle]; + [tableView setColumnAutoresizingStyle:CPTableViewLastColumnOnlyAutoresizingStyle]; var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([view bounds]), CGRectGetHeight([view bounds]))]; [tableView setRowHeight:22.0]; @@ -106,10 +87,6 @@ CPLogRegister(CPLogConsole); [tableView setDraggingDestinationFeedbackStyle:CPTableViewDropOn]; [tableView registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]]; - //[tableView scrollColumnToVisible:7]; - //[tableView scrollRowToVisible:100]; - - //[tableView sizeLastColumnToFit]; [window1 orderFront:self]; [self newWindow]; } @@ -119,13 +96,12 @@ CPLogRegister(CPLogConsole); var window2 = [[CPWindow alloc] initWithContentRect:CGRectMake(450, 50, 500, 400) styleMask:CPTitledWindowMask | CPResizableWindowMask]; - tableView2 = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 500.0, 500.0)];//[view bounds]]; + tableView2 = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 500.0, 500.0)]; [tableView2 setAllowsMultipleSelection:YES]; [tableView2 setUsesAlternatingRowBackgroundColors:YES]; [tableView2 setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask]; -// [tableView setBackgroundColor:[CPColor blueColor]]; var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)]; @@ -143,26 +119,15 @@ CPLogRegister(CPLogConsole); iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)]; var textDataView = [CPTextField new]; -// [textDataView setFrameSize:CGSizeMake(200,32)]; - // [textDataView setValue:CGInsetMake(9.0, 7.0, 5.0, 8.0) forThemeAttribute:@"content-inset"]; - //[textDataView setValue:CGInsetMake(9.0, 7.0, 5.0, 8.0) forThemeAttribute:@"content-inset"]; - //[textDataView setValue:CGInsetMake(4.0, 4.0, 3.0, 4.0) forThemeAttribute:@"bezel-inset"]; -// [textDataView setValue:CGInsetMake(2, 0, 0, 0) forThemeAttribute:@"focus-inset"]; - // [textDataView setValue:CGInsetMake(0, 0, 0, 0) forThemeAttribute:@"focus-inset" inState:CPThemeStateBezeled|CPThemeStateEditing]; [textDataView setValue:[CPColor whiteColor] forThemeAttribute:@"text-color" inState:CPThemeStateHighlighted]; [textDataView setValue:[CPFont systemFontOfSize:12] forThemeAttribute:@"font" inState:CPThemeStateHighlighted]; - //[textDataView setValue:CGSizeMake(1,1) forThemeAttribute:@"text-shadow-offset"]; - //[textDataView setValue:[CPColor blackColor] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateHighlighted]; - -// [textDataView setBackgroundColor:[[CPColor redColor] colorWithAlphaComponent:0.5]]; var desc = [CPSortDescriptor sortDescriptorWithKey:@"self" ascending:YES]; for (var i = 1; i <= 3; i++) { var column = [[CPTableColumn alloc] initWithIdentifier:String(i)]; - //[column setSortDescriptorPrototype:desc]; [[column headerView] setStringValue:"Number "+i]; [column setWidth:200.0]; @@ -173,8 +138,6 @@ CPLogRegister(CPLogConsole); [tableView2 addTableColumn:column]; } - - //[tableView selectColumnIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0,2)] byExtendingSelection:YES]; [tableView2 setColumnAutoresizingStyle:CPTableViewUniformColumnAutoresizingStyle]; @@ -229,26 +192,20 @@ CPLogRegister(CPLogConsole); return 50; } -//- (void)tableViewSelectionIsChanging:(CPNotification)aNotification -//{ -// CPLog.debug(@"changing! %@", [aNotification description]); -//} -// -//- (void)tableViewSelectionDidChange:(CPNotification)aNotification -//{ -// CPLog.debug(@"did change! %@", [aNotification description]); -//} +- (void)tableViewSelectionIsChanging:(CPNotification)aNotification +{ + CPLog.debug(@"changing! %@", [aNotification description]); +} + +- (void)tableViewSelectionDidChange:(CPNotification)aNotification +{ + CPLog.debug(@"did change! %@", [aNotification description]); +} - (BOOL)tableView:(CPTableView)aTableView shouldSelectRow:(int)rowIndex { - //CPLog.debug(@"shouldSelectRow %d", rowIndex); - //for (var i = 2, sqrt = SQRT(rowIndex+1); i <= sqrt; i++) - // if ((rowIndex+1) % i === 0) - //return false; - // if(rowIndex % 2 == 1) - // return true; - // else - return true; + //CPLog.debug(@"tableView:shouldSelectRow"); + return true; } - (BOOL)selectionShouldChangeInTableView:(CPTableView)aTableView @@ -320,9 +277,6 @@ CPLogRegister(CPLogConsole); proposedRow:(CPInteger)row proposedDropOperation:(CPTableViewDropOperation)operation { - // console.log([aTableView rectOfRow:0]); - //console.log(row) - [[aTableView window] orderFront:nil]; if(aTableView === tableView)