Skip to content

Instantly share code, notes, and snippets.

@mikecsh
Created January 22, 2011 16:43
Show Gist options
  • Save mikecsh/791232 to your computer and use it in GitHub Desktop.
Save mikecsh/791232 to your computer and use it in GitHub Desktop.
Cappuccino CPTableView Issues
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
CPTableView _tableView;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
// Create a CPScrollView that will contain the CPTableView
var scrollView = [[CPScrollView alloc] initWithFrame:[contentView frame]];
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[scrollView setHasHorizontalScroller:YES];
// Create the CPTableView
_tableView = [[CPTableView alloc] initWithFrame:[scrollView bounds]];
[_tableView setDataSource:self];
[_tableView setUsesAlternatingRowBackgroundColors:YES];
// Uncomment this line to test vertical scrollbar issue..
//[_tableView setHeaderView:nil];
// Add some columns
for (var columnIndex=0; columnIndex < 25; ++columnIndex)
{
var column = [[CPTableColumn alloc] initWithIdentifier:[columnIndex]];
[[column headerView] setStringValue:@"Test Header"];
[column setWidth:100.0];
[_tableView addTableColumn:column];
}
// View hierarchy
[scrollView setDocumentView:_tableView];
[contentView addSubview:scrollView];
[theWindow orderFront:self];
}
- (int)numberOfRowsInTableView:(CPTableView)tableView
{
return 500;
}
- (id)tableView:(CPTableView)tableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row
{
return @"Test Data";
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment