jsmecham (owner)

Revisions

gist: 217654 Download_button fork
public
Public Clone URL: git://gist.github.com/217654.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * 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