Fixed TableTest for IE.

This commit is contained in:
Randall Luecke
2010-03-28 15:04:40 -07:00
committed by Francisco Ryan Tolmasky I
parent cb6ef75283
commit c11bf5aae1
+52 -112
View File
@@ -1,12 +1,6 @@
@import <Foundation/CPObject.j>
@import <Foundation/CPIndexSet.j>
@import <AppKit/CPTableColumn.j>
@import <AppKit/CPTableView.j>
tableTestDragType = @"CPTableViewTestDragType";
CPLogRegister(CPLogConsole);
@implementation AppController : CPObject
{
@@ -20,6 +14,7 @@ CPLogRegister(CPLogConsole);
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
dataSet1 = [],
dataSet2 = [],
dataSet3 = [];
@@ -31,40 +26,40 @@ CPLogRegister(CPLogConsole);
dataSet3[i - 1] = [CPNumber numberWithInt:i+20];
}
var window1 = [[CPWindow alloc] initWithContentRect:CGRectMake(50, 50, 500, 400) styleMask:CPTitledWindowMask | CPResizableWindowMask],
view = [window1 contentView];
[view setBackgroundColor:[CPColor whiteColor]];
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(50,50,400,400) styleMask:CPClosableWindowMask],
contentView = [theWindow contentView];
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 setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask];
[tableView setVerticalMotionCanBeginDrag:NO];
[tableView setDraggingDestinationFeedbackStyle:CPTableViewDropOn];
[tableView registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
[tableView setColumnAutoresizingStyle:CPTableViewLastColumnOnlyAutoresizingStyle];
[tableView setDelegate:self];
[tableView setDataSource:self];
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
[iconView setImageScaling:CPScaleNone];
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
[iconColumn setWidth:32.0];
[iconColumn setMinWidth:32.0];
[iconColumn setDataView:iconView];
[tableView addTableColumn:iconColumn];
iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)];
var desc = [CPSortDescriptor sortDescriptorWithKey:@"self" ascending:YES];
for (var i = 1; i <= 2; i++)
{
var column = [[CPTableColumn alloc] initWithIdentifier:String(i)];
[column setSortDescriptorPrototype:desc];
[[column headerView] setStringValue:"Number "+i];
[[column headerView] setStringValue:"Number " + i];
[column setMinWidth:50.0];
[column setMaxWidth:500.0];
@@ -74,24 +69,14 @@ CPLogRegister(CPLogConsole);
[tableView addTableColumn:column];
}
[tableView setColumnAutoresizingStyle:CPTableViewLastColumnOnlyAutoresizingStyle];
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([view bounds]), CGRectGetHeight([view bounds]))];
[tableView setRowHeight:22.0];
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([contentView bounds]), CGRectGetHeight([contentView bounds]))];
[scrollView setDocumentView:tableView];
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[view addSubview:scrollView];
[contentView addSubview:scrollView];
[scrollView setAutohidesScrollers:YES];
[tableView setDelegate:self];
[tableView setDataSource:self];
[tableView setVerticalMotionCanBeginDrag:NO];
[tableView setDraggingDestinationFeedbackStyle:CPTableViewDropOn];
[tableView registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
[window1 setAcceptsMouseMovedEvents:YES];
[window1 orderFront:self];
[theWindow orderFront:self];
[self newWindow];
[self sourceList];
}
@@ -106,39 +91,22 @@ CPLogRegister(CPLogConsole);
[tableView2 setAllowsMultipleSelection:YES];
[tableView2 setUsesAlternatingRowBackgroundColors:YES];
[tableView2 setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask];
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
[iconView setImageScaling:CPScaleNone];
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
[iconColumn setWidth:32.0];
[iconColumn setMinWidth:32.0];
[iconColumn setDataView:iconView];
[iconColumn setResizingMask:CPTableColumnNoResizing];
//[tableView2 addTableColumn:iconColumn];
iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)];
var textDataView = [CPTextField new];
[textDataView setValue:[CPColor whiteColor] forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[textDataView setValue:[CPFont systemFontOfSize:12] forThemeAttribute:@"font" inState:CPThemeStateSelected];
[tableView2 setVerticalMotionCanBeginDrag:NO];
[tableView2 registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
[tableView2 setDraggingDestinationFeedbackStyle:CPTableViewDropAbove];
[tableView2 setDelegate:self];
[tableView2 setDataSource:self];
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:i*75];
[column setMinWidth:50.0];
[column setDataView:textDataView];
[column setEditable:YES];
[tableView2 addTableColumn:column];
@@ -153,14 +121,8 @@ CPLogRegister(CPLogConsole);
[[window2 contentView] addSubview:scrollView];
[scrollView setAutohidesScrollers:YES];
//[scrollView setAutohidesScrollers:YES];
[tableView2 setDelegate:self];
[tableView2 setDataSource:self];
[tableView2 setVerticalMotionCanBeginDrag:NO];
[tableView2 registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
[tableView2 setDraggingDestinationFeedbackStyle:CPTableViewDropAbove];
[window2 orderFront:self];
}
@@ -176,19 +138,19 @@ CPLogRegister(CPLogConsole);
[tableView3 setUsesAlternatingRowBackgroundColors:NO];
[tableView3 setGridStyleMask:CPTableViewGridNone];
[tableView3 setSelectionHighlightStyle:CPTableViewSelectionHighlightStyleSourceList];
[tableView3 setColumnAutoresizingStyle:CPTableViewUniformColumnAutoresizingStyle];
[tableView3 setVerticalMotionCanBeginDrag:NO];
[tableView3 setDelegate:self];
[tableView3 setDataSource:self];
var column = [[CPTableColumn alloc] initWithIdentifier:"sourcelist"];
[[column headerView] setStringValue:"Source List"];
[column setWidth:200.0];
[column setMinWidth:50.0];
[column setEditable:YES];
[tableView3 addTableColumn:column];
[tableView3 setColumnAutoresizingStyle:CPTableViewUniformColumnAutoresizingStyle];
var scrollView3 = [[CPScrollView alloc] initWithFrame:[[window3 contentView] bounds]];
[tableView3 setRowHeight:32.0];
[scrollView3 setDocumentView:tableView3];
@@ -197,15 +159,8 @@ CPLogRegister(CPLogConsole);
[[window3 contentView] addSubview:scrollView3];
[scrollView3 setAutohidesScrollers:YES];
[tableView3 setDelegate:self];
[tableView3 setDataSource:self];
[tableView3 setVerticalMotionCanBeginDrag:NO];
//[tableView3 registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
//[tableView3 setDraggingDestinationFeedbackStyle:CPTableViewDropAbove];*/
[window3 orderFront:self];
[window3 orderFront:self];
}
- (int)numberOfRowsInTableView:(CPTableView)atableView
@@ -218,37 +173,30 @@ CPLogRegister(CPLogConsole);
return dataSet3.length;
}
- (id)tableView:(CPTableView)atableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row
- (id)tableView:(CPTableView)aTableView objectValueForTableColumn:(CPTableColumn)aColumn row:(int)aRow
{
if(atableView === tableView)
{
if ([tableColumn identifier] === "icons")
return iconImage;
else
return String(dataSet1[row]);
}
else if(atableView === tableView2)
{
if ([tableColumn identifier] === "icons")
return iconImage;
else
return String(dataSet2[row]);
}
else if(atableView === tableView3)
{
if ([tableColumn identifier] === "icons")
return iconImage;
else
return String(dataSet3[row]);
}
if ([aColumn identifier] === "icons")
return iconImage;
if (aTableView === tableView)
return String(dataSet1[aRow]);
else if (aTableView === tableView2)
return String(dataSet2[aRow]);
else if(aTableView === tableView3)
return String(dataSet3[row]);
}
- (id)tableView:(CPTableView)tableView heightOfRow:(int)row
- (void)tableView:(CPTableView)aTableView sortDescriptorsDidChange:(CPArray)oldDescriptors
{
return 50;
CPLogConsole(_cmd + [oldDescriptors description]);
var newDescriptors = [aTableView sortDescriptors];
[(aTableView === tableView) ? dataSet1:dataSet2 sortUsingDescriptors:newDescriptors];
[aTableView reloadData];
}
- (void)tableViewSelectionIsChanging:(CPNotification)aNotification
{
CPLog.debug(@"changing! %@", [aNotification description]);
@@ -261,13 +209,13 @@ CPLogRegister(CPLogConsole);
- (BOOL)tableView:(CPTableView)aTableView shouldSelectRow:(int)rowIndex
{
//CPLog.debug(@"tableView:shouldSelectRow");
CPLog.debug(@"tableView:shouldSelectRow");
return true;
}
- (BOOL)selectionShouldChangeInTableView:(CPTableView)aTableView
{
//CPLog.debug(@"selectionShouldChangeInTableView");
CPLog.debug(@"selectionShouldChangeInTableView");
return YES;
}
@@ -285,14 +233,6 @@ CPLogRegister(CPLogConsole);
{
CPLogConsole(_cmd + [notification description]);
}
//- (CPIndexSet)tableView:(CPTableView)tableView selectionIndexesForProposedSelection:(CPIndexSet)proposedSelectionIndexes
//{
// CPLog.debug(@"selectionIndexesForProposedSelection %@", [proposedSelectionIndexes description]);
// return proposedSelectionIndexes;
//}
- (BOOL)tableView:(CPTableView)aTableView shouldEditTableColumn:(CPTableColumn)tableColumn row:(int)row
{
if(aTableView === tableView3)
@@ -405,7 +345,7 @@ CPLogRegister(CPLogConsole);
- (void)tableView:(CPTableView)aTableView didClickTableColumn:(CPTableColumn)aColumn
{
console.log("table: "+aTableView+" clicked column: "+aColumn);
CPLog.debug("table: "+aTableView+" clicked column: "+aColumn);
}
@end