TableTest

This commit is contained in:
tlrobinson
2009-06-07 14:58:24 -07:00
parent 7ca3473b64
commit e7e804cae3
7 changed files with 302 additions and 0 deletions
+109
View File
@@ -0,0 +1,109 @@
import <Foundation/CPObject.j>
import <AppKit/CPTableView.j>
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
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CPApplicationDelegateClass</key>
<string>AppController</string>
<key>CPBundleName</key>
<string>TableTest</string>
<key>CPPrincipalClass</key>
<string>CPApplication</string>
</dict>
</plist>
+25
View File
@@ -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]
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

+69
View File
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
index-debug.html
TableTest
Created by You on June 7, 2009.
Copyright 2009, Your Company All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>TableTest</title>
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script src = "Frameworks/Debug/Objective-J/Objective-J.js" type = "text/javascript"></script>
<style type = "text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="loadingcontainer" style=" background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading TableTest...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</body>
</html>
+69
View File
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
index.html
TableTest
Created by You on June 7, 2009.
Copyright 2009, Your Company All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>TableTest</title>
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script src = "Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></script>
<style type = "text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="loadingcontainer" style=" background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading TableTest...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
/*
* AppController.j
* TableTest
*
* Created by You on June 7, 2009.
* Copyright 2009, Your Company All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}