/*
* AppController.j
* Focus
*
* Created by You on October 23, 2009.
* Copyright 2009, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@import <AppKit/CPOutlineView.j>
@implementation AppController : CPObject
{
CPWindow window; //this "outlet" is connected automatically by the Cib
CPView sidebar;
CPOutlineView outlineView;
CPMutableArray items;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
}
- (void)awakeFromCib
{
// This is called when the application is done loading.
var items = [CPMutableArray array];
for (var i=0; i< 40; i++)
{
item = [CPString stringWithString:@"Some Text"];
[items addObject:item];
}
// This is called when the cib is done loading.
// You can implement this method on any object instantiated from a Cib.
// It's a useful hook for setting up current UI values, and other things.
CPLogRegister(CPLogConsole);
// OutlineView
var outlineView = [[CPOutlineView alloc] initWithFrame:CGRectMake(0,0,200,500)];
[outlineView setSelectionHighlightStyle:CPTableViewSelectionHighlightStyleSourceList];
[outlineView setDelegate:self];
[outlineView setDataSource:self];
[sidebar addSubview:outlineView];
// In this case, we want the window from Cib to become our full browser window
[window setFullBridge:YES];
}
- (id)outlineView:(CPOutlineView)outlineView child:(int)index ofItem:(id)item
{
CPLog("outlineView:child:ofItem:");
return [items objectAtIndex:0];
}
- (BOOL)outlineView:(CPOutlineView)outlineView isItemExpandable:(id)item
{
CPLog("outlineView:isItemExpandable:");
return YES;
}
- (int)outlineView:(CPOutlineView)outlineView numberOfChildrenOfItem:(id)item
{
CPLog("outlineView:numberOfChildrenOfItem:");
return 10;
}
- (id)outlineView:(CPOutlineView)outlineView objectValueForTableColumn:(CPTableColumn)tableColumn byItem:(id)item
{
CPLog("outlineView:objectValueForTableColumn:byItem:");
return [items objectAtIndex:0];
}
@end