Skip to content

Instantly share code, notes, and snippets.

@primalmotion
Created February 22, 2010 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save primalmotion/311547 to your computer and use it in GitHub Desktop.
Save primalmotion/311547 to your computer and use it in GitHub Desktop.
// first column
@implementation TNOutlineTableColumnLabel : CPTableColumn
{
CPOutlineView _outlineView;
CPView _dataViewForOther;
CPView _dataViewForRoot;
}
- (id)initWithIdentifier:(CPString)anIdentifier outlineView:(CPOutlineView)anOutlineView
{
if (self = [super initWithIdentifier:anIdentifier])
{
_outlineView = anOutlineView;
[self setEditable:YES];
var width = 170;
[self setWidth:width];
_dataViewForRoot = [[CPTextField alloc] init];
[_dataViewForRoot setFont:[CPFont boldSystemFontOfSize:12]];
[_dataViewForRoot setTextColor:[CPColor colorWithHexString:@"5F676F"]];
[_dataViewForRoot setAutoresizingMask: CPViewWidthSizable];
_dataViewForOther = [[CPTextField alloc] init];
[_dataViewForOther setAutoresizingMask: CPViewWidthSizable];
}
return self;
}
- (id)dataViewForRow:(int)aRowIndex
{
var outlineViewItem = [_outlineView itemAtRow:aRowIndex];
var itemLevel = [_outlineView levelForItem:outlineViewItem];
if (itemLevel == 0)
{
return _dataViewForRoot;
}
else
{
return _dataViewForOther;
}
}
@end
// Second column
@implementation TNOutlineTableColumnStatus : CPTableColumn
{
CPOutlineView _outlineView;
}
- (id)initWithIdentifier:(CPString)anIdentifier outlineView:(CPOutlineView)anOutlineView
{
if (self = [super initWithIdentifier:anIdentifier])
{
_outlineView = anOutlineView;
[self setWidth:16];
}
return self;
}
- (id)dataViewForRow:(int)aRowIndex
{
var outlineViewItem = [_outlineView itemAtRow:aRowIndex];
var itemLevel = [_outlineView levelForItem:outlineViewItem];
if (itemLevel == 0)
{
return [[CPTextField alloc] initWithFrame:CGRectMake(0,0, 16, 16)];
}
else
{
var imageView = [[CPImageView alloc] initWithFrame:CGRectMake(0,0, 16, 16)];
[imageView setAutoresizingMask: CPViewWidthSizable];
[imageView setImageScaling:CPScaleProportionally];
return imageView;
}
}
@end
@implementation TNOutlineViewRoster: CPOutlineView
{
}
- (id)initWithFrame:(CPRect)aFrame
{
if (self = [super initWithFrame:aFrame])
{
[self setAutoresizingMask:CPViewHeightSizable | CPViewWidthSizable];
[self setFrameOrigin:CGPointMake(5,5)];
[self setRowHeight:20];
[self setHeaderView:null];
[self setCornerView:null];
[self setIndentationPerLevel:10];
[self setBackgroundColor:[CPColor colorWithHexString:@"D8DFE8"]];
var columnLabel = [[TNOutlineTableColumnLabel alloc] initWithIdentifier:"nickname" outlineView:self];
//[columnLabel setMinWidth:170];
[columnLabel setResizingMask:CPTableColumnAutoresizingMask];
[self addTableColumn:columnLabel];
var columnStatus = [[TNOutlineTableColumnStatus alloc] initWithIdentifier:"statusIcon" outlineView:self];
[columnStatus setResizingMask: CPTableColumnAutoresizingMask];
[self addTableColumn:columnStatus];
[self setOutlineTableColumn:columnLabel];
[self setAllowsColumnReordering:YES];
[self setAllowsColumnResizing:YES];
}
return self;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment