diff --git a/TableTest/AppController.j b/TableTest/AppController.j new file mode 100644 index 000000000..97e6e1ba4 --- /dev/null +++ b/TableTest/AppController.j @@ -0,0 +1,109 @@ + +import +import + +CPLogRegister(CPLogConsole); + +@implementation AppController : CPObject +{ + CPTableView _tableView; + CPArray _data; + 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]; + + _data = [1, 2]; + + _tableView = [[CPTableView alloc] initWithFrame:[view bounds]]; + //[_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]; + [iconColumn setDataView:iconView]; + + [_tableView addTableColumn:iconColumn]; + + for (var i = 1; i <= 10; i++) + { + var column = [[CPTableColumn alloc] initWithIdentifier:String(i)]; + + [[column headerView] setStringValue:"Number"]; + [[column headerView] sizeToFit]; + [column setWidth:[[column headerView] frame].size.width]; + + [_tableView addTableColumn:column]; + } + + var scrollView = [[CPScrollView alloc] initWithFrame:[view bounds]]; + + [scrollView setDocumentView:_tableView]; + [scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; + + [view addSubview:scrollView]; + + [_tableView setDelegate:self]; + [_tableView setDataSource:self]; + + _iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)]; +} + +- (int)numberOfRowsInTableView:(CPTableView)tableView +{ + return 7000000; +} + +- (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 diff --git a/TableTest/Info.plist b/TableTest/Info.plist new file mode 100644 index 000000000..78ac6aab8 --- /dev/null +++ b/TableTest/Info.plist @@ -0,0 +1,12 @@ + + + + + CPApplicationDelegateClass + AppController + CPBundleName + TableTest + CPPrincipalClass + CPApplication + + diff --git a/TableTest/Rakefile b/TableTest/Rakefile new file mode 100644 index 000000000..26682d25f --- /dev/null +++ b/TableTest/Rakefile @@ -0,0 +1,25 @@ + +require 'objective-j' +require 'objective-j/bundletask' + +if !ENV['CONFIG'] + ENV['CONFIG'] = 'Debug' +end + +ObjectiveJ::BundleTask.new(:TableTest) do |t| + t.name = 'TableTest' + t.identifier = 'com.yourcompany.TableTest' + t.version = '1.0' + t.author = 'Your Company' + t.email = 'feedback @nospam@ yourcompany.com' + t.summary = 'TableTest' + t.sources = FileList['*.j'] + t.resources = FileList['Resources/*'] + t.index_file = 'index.html' + t.info_plist = 'Info.plist' + t.build_path = File.join('Build', ENV['CONFIG'], 'TableTest') + t.flag = '-DDEBUG' if ENV['CONFIG'] == 'Debug' + t.flag = '-O' if ENV['CONFIG'] == 'Release' +end + +task :default => [:TableTest] diff --git a/TableTest/Resources/spinner.gif b/TableTest/Resources/spinner.gif new file mode 100644 index 000000000..06dbc2bc2 Binary files /dev/null and b/TableTest/Resources/spinner.gif differ diff --git a/TableTest/index-debug.html b/TableTest/index-debug.html new file mode 100644 index 000000000..9bb71cc81 --- /dev/null +++ b/TableTest/index-debug.html @@ -0,0 +1,69 @@ + + + + + + + + TableTest + + + + + + + + + + + + +
+ + + +
+ + + diff --git a/TableTest/index.html b/TableTest/index.html new file mode 100644 index 000000000..9965f27f7 --- /dev/null +++ b/TableTest/index.html @@ -0,0 +1,69 @@ + + + + + + + + TableTest + + + + + + + + + + + + +
+ + + +
+ + + + diff --git a/TableTest/main.j b/TableTest/main.j new file mode 100755 index 000000000..ee431dc77 --- /dev/null +++ b/TableTest/main.j @@ -0,0 +1,18 @@ +/* + * AppController.j + * TableTest + * + * Created by You on June 7, 2009. + * Copyright 2009, Your Company All rights reserved. + */ + +@import +@import + +@import "AppController.j" + + +function main(args, namedArgs) +{ + CPApplicationMain(args, namedArgs); +}