PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Tests/Manual/TableTest/TableCibTest/AppController.j

http://github.com/cacaodev/cappuccino
Unknown | 67 lines | 54 code | 13 blank | 0 comment | 0 complexity | e010a91bc5a0bd937ec65d62f8ce668c MD5 | raw file
 1/*
 2 * AppController.j
 3 * TableCibTest
 4 *
 5 * Created by Francisco Tolmasky on July 5, 2009.
 6 * Copyright 2009, 280 North, Inc. All rights reserved.
 7 */
 8
 9@import <Foundation/CPObject.j>
10@import "../../CPTrace.j"
11
12CPLogRegister(CPLogConsole);
13
14@implementation AppController : CPObject
15{
16    CPWindow    theWindow; //this "outlet" is connected automatically by the Cib
17    CPImage     iconImage;
18}
19
20- (void)applicationDidFinishLaunching:(CPNotification)aNotification
21{
22    // This is called when the application is done loading.
23    iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino-project.org/img/favicon.ico" size:CGSizeMake(16,16)];
24
25    var averager = moving_averager(50);
26
27    CPTrace("CPTableView", "load", function(receiver, selector, args, duration)
28    {
29        if (duration)
30            console.log(receiver + " " + selector + " in " + averager(duration));
31    });
32
33    CPTrace("CPTableHeaderView", "_startDraggingTableColumn:at:");
34}
35
36- (void)awakeFromCib
37{
38    // This is called when the cib is done loading.
39    // You can implement this method on any object instantiated from a Cib.
40    // It's a useful hook for setting up current UI values, and other things.
41
42    // In this case, we want the window from Cib to become our full browser window
43    [theWindow setFullPlatformWindow:YES];
44}
45
46- (int)numberOfRowsInTableView:(CPTableView)tableView
47{
48    return 100000;
49}
50
51- (id)tableView:(CPTableView)tableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(CPInteger)row
52{
53    if ([tableColumn identifier] === "icons")
54        return iconImage;
55    else
56        return String((row + 1) * [[tableColumn identifier] intValue]);
57}
58
59- (BOOL)tableView:(CPTableView)tableView shouldReorderColumn:(CPInteger)columnIndex toColumn:(CPInteger)newColumnIndex
60{
61    if (columnIndex === 0 || newColumnIndex === 4)
62        return NO;
63    else
64        return YES;
65}
66
67@end