Files
cappuccino/Tests/Manual/CPOutlineViewViewBasedCibTest/AppController.j
T
cacaodevandAparajita Fishman 7225e7e038 New: deprecate -tableView:dataViewForTableColumn:row: and -outlineView:dataViewForTableColumn:item:
-tableView:dataViewForTableColumn:row: and -outlineView:dataViewForTableColumn:item: are deprecated in favor of ...viewForTableColumn:...

Using the previous delegate API and not caching the view with an identifier was degrading performance. With this change, developers are encouraged to use the new caching system and the CPTableView method -makeViewWithIdentifier:owner: to get the view.

Also fixed a condition where a view-based outline view was not always asking for the view from its delegate. In some circumstances, an outline view could be considered as view-based instead of cell-based.

Test for deprecated delegate methods in CPOutlineViewViewBasedCib and TableTest/ViewBased examples.

Fixes #1823
2013-03-15 08:16:02 -04:00

69 lines
1.4 KiB
Plaintext

/*
* AppController.j
* CPOutlineViewViewBasedCibTest
*
* Created by You on April 11, 2012.
* Copyright 2012, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
CPLogRegister(CPLogConsole);
@implementation AppController : CPObject
{
@outlet CPWindow theWindow;
@outlet CPOutlineView outlineView;
}
- (void)awakeFromCib
{
[theWindow setFullPlatformWindow:YES];
}
- (int)outlineView:(id)oview numberOfChildrenOfItem:(id)item
{
return 3;
}
- (id)outlineView:(id)oview child:(int)childnum ofItem:(id)item
{
return [CPObject new];
}
- (BOOL)outlineView:(id)oview isItemExpandable:(id)item
{
return YES;
}
-(id)outlineView:(id)oview dataViewForTableColumn:(id)tableColumn item:(id)item
{
var identifier = [tableColumn identifier];
if (identifier == @"first" && [oview parentForItem:item] == nil)
identifier = @"firstRoot";
var view = [oview makeViewWithIdentifier:identifier owner:self];
[[view textField] setStringValue:@"Item <" + [item UID] + ">"];
if (identifier = @"firstRoot")
{
var expandButton = [view viewWithTag:1000];
[expandButton setState:[outlineView isItemExpanded:item]];
}
return view;
}
- (IBAction)expand:(id)sender
{
var row = [outlineView rowForView:sender],
item = [outlineView itemAtRow:row];
if ([outlineView isItemExpanded:item])
[outlineView collapseItem:item];
else
[outlineView expandItem:item];
}
@end