mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
131 lines
3.7 KiB
Plaintext
131 lines
3.7 KiB
Plaintext
|
|
@import <Foundation/CPObject.j>
|
|
|
|
@import <Foundation/CPIndexSet.j>
|
|
@import <AppKit/CPTableColumn.j>
|
|
@import <AppKit/CPTableView.j>
|
|
|
|
|
|
CPLogRegister(CPLogConsole);
|
|
|
|
@implementation AppController : CPObject
|
|
{
|
|
CPTableView tableView;
|
|
CPImage iconImage;
|
|
}
|
|
|
|
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
|
{
|
|
var view = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 100.0)];
|
|
|
|
[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 setAllowsMultipleSelection:YES];
|
|
[tableView setUsesAlternatingRowBackgroundColors:YES];
|
|
[tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask];
|
|
|
|
// [tableView setBackgroundColor:[CPColor blueColor]];
|
|
|
|
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
|
|
|
|
[iconView setImageScaling:CPScaleNone];
|
|
|
|
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
|
|
|
|
[iconColumn setWidth:32.0];
|
|
[iconColumn setDataView:iconView];
|
|
|
|
[tableView addTableColumn:iconColumn];
|
|
|
|
iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)];
|
|
|
|
var textDataView = [CPTextField new];
|
|
|
|
// [textDataView setBackgroundColor:[[CPColor redColor] colorWithAlphaComponent:0.5]];
|
|
|
|
for (var i = 1; i <= 10; i++)
|
|
{
|
|
var column = [[CPTableColumn alloc] initWithIdentifier:String(i)];
|
|
|
|
[[column headerView] setStringValue:"Number "+i];
|
|
[[column headerView] sizeToFit];
|
|
//[column setWidth:[[column headerView] frame].size.width + 20];
|
|
|
|
[column setWidth:200.0];
|
|
|
|
[column setDataView:textDataView];
|
|
|
|
[tableView addTableColumn:column];
|
|
}
|
|
|
|
[tableView selectColumnIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0,2)] byExtendingSelection:YES];
|
|
|
|
var scrollView = [[CPScrollView alloc] initWithFrame:[view bounds]];
|
|
|
|
[scrollView setDocumentView:tableView];
|
|
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
|
|
|
[view addSubview:scrollView];
|
|
|
|
[scrollView setAutohidesScrollers:YES];
|
|
|
|
[tableView setDelegate:self];
|
|
[tableView setDataSource:self];
|
|
}
|
|
|
|
- (int)numberOfRowsInTableView:(CPTableView)tableView
|
|
{
|
|
return 700000;
|
|
}
|
|
|
|
- (id)tableView:(CPTableView)tableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row
|
|
{
|
|
if ([tableColumn identifier] === "icons")
|
|
return iconImage;
|
|
else
|
|
return String((row + 1) * [[tableColumn identifier] intValue]);
|
|
}
|
|
/*
|
|
- (id)tableView:(CPTableView)tableView heightOfRow:(int)row
|
|
{
|
|
//CPLog.info("heightOfRow:"+row);
|
|
return 20.0 + ROUND(row * 0.5);
|
|
}
|
|
*/
|
|
//- (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;
|
|
|
|
return true;
|
|
}
|
|
|
|
- (BOOL)selectionShouldChangeInTableView:(CPTableView)aTableView
|
|
{
|
|
//CPLog.debug(@"selectionShouldChangeInTableView");
|
|
return YES;
|
|
}
|
|
|
|
//- (CPIndexSet)tableView:(CPTableView)tableView selectionIndexesForProposedSelection:(CPIndexSet)proposedSelectionIndexes
|
|
//{
|
|
// CPLog.debug(@"selectionIndexesForProposedSelection %@", [proposedSelectionIndexes description]);
|
|
// return proposedSelectionIndexes;
|
|
//}
|
|
|
|
@end
|