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