-
Notifications
You must be signed in to change notification settings - Fork 0
/
MNTableViewController.j
86 lines (53 loc) · 1.94 KB
/
MNTableViewController.j
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
81
82
83
84
85
86
// MNTableViewController
@import <AppKit/AppKit.j>
@import "MNSampleDataView.j"
@implementation MNTableViewController : CPViewController {
CPArrayController arrayController @accessors;
CPScrollView scrollView @accessors;
CPTableView tableView @accessors;
CPView dataViewPrototype @accessors;
}
- (id) initWithCibName:(CPString)aCibNameOrNil bundle:(CPBundle)aCibBundleOrNil {
self = [super initWithCibName:aCibNameOrNil bundle:aCibBundleOrNil];
if (!self) return nil;
[self mnConfigure];
return self;
}
- (id) initWithCoder:(CPCoder)aCoder {
self = [super initWithCoder:aCoder];
if (!self) return nil;
[self mnConfigure];
return self;
}
- (void) mnConfigure {
[self setArrayController:[[CPArrayController alloc] init]];
[self setDataViewPrototype:[[MNSampleDataView alloc] init]];
}
- (CPScrollView) view {
return [super view];
}
- (void) loadView {
scrollView = [[CPScrollView alloc] init];
tableView = [[CPTableView alloc] initWithFrame:[scrollView bounds]];
[tableView setDataSource:self];
[tableView setDelegate:self];
[tableView setRowHeight:32];
[tableView setColumnAutoresizingStyle:CPTableViewUniformColumnAutoresizingStyle];
[tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask];
[tableView setHeaderView:nil];
[tableView setCornerView:nil];
[scrollView setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
[scrollView setDocumentView:tableView];
[scrollView setHasHorizontalScroller:NO];
[self setView:scrollView];
var column = [[CPTableColumn alloc] initWithIdentifier:@"column"];
[column setDataView:[self dataViewPrototype]];
[tableView addTableColumn:column];
}
- (int) numberOfRowsInTableView:(CPTableView)inTableView {
return [[arrayController arrangedObjects] count] || 0;
}
- (id) tableView:(CPTableView)inTableView objectValueForTableColumn:(CPTableColumn)inTableColumn row:(int)inRow {
return [[arrayController arrangedObjects] objectAtIndex:inRow];
}
@end