-
Notifications
You must be signed in to change notification settings - Fork 24
/
JAListViewAppDelegate.m
115 lines (84 loc) · 2.82 KB
/
JAListViewAppDelegate.m
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//
// JAListViewAppDelegate.m
// JAListView
//
// Created by Josh Abernathy on 9/29/10.
// Copyright 2010 Maybe Apps. All rights reserved.
//
#import "JAListViewAppDelegate.h"
#import "DemoView.h"
#import "DemoSectionView.h"
@implementation JAListViewAppDelegate
#pragma mark NSApplicationDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
self.listView.canCallDataSourceInParallel = YES;
self.sectionedListView.canCallDataSourceInParallel = YES;
[self.listView reloadData];
[self.sectionedListView reloadData];
[self.window makeKeyAndOrderFront:nil];
}
#pragma mark JAListViewDelegate
- (void)listView:(JAListView *)list willSelectView:(JAListViewItem *)view {
if(list == self.listView) {
DemoView *demoView = (DemoView *) view;
demoView.selected = YES;
}
}
- (void)listView:(JAListView *)list didSelectView:(JAListViewItem *)view {
if(list == self.listView) {
DemoView *demoView = (DemoView *) view;
demoView.selected = NO;
}
}
- (void)listView:(JAListView *)list didUnSelectView:(JAListViewItem *)view {
if(list == self.listView) {
DemoView *demoView = (DemoView *) view;
demoView.selected = NO;
}
}
#pragma mark JAListViewDataSource
- (NSUInteger)numberOfItemsInListView:(JAListView *)listView {
return 100;
}
- (JAListViewItem *)listView:(JAListView *)listView viewAtIndex:(NSUInteger)index {
DemoView *view = [DemoView demoView];
view.text = [NSString stringWithFormat:@"Row %d", index + 1];
return view;
}
#pragma mark JASectionedListViewDataSource
- (NSUInteger)numberOfSectionsInListView:(JASectionedListView *)listView {
return 3;
}
- (NSUInteger)listView:(JASectionedListView *)listView numberOfViewsInSection:(NSUInteger)section {
if(section == 0) {
return 10;
} else if(section == 1) {
return 2;
} else if(section == 2) {
return 7;
}
return 0;
}
- (JAListViewItem *)listView:(JAListView *)listView sectionHeaderViewForSection:(NSUInteger)section {
DemoSectionView *view = [DemoSectionView demoSectionView];
view.text = [NSString stringWithFormat:@"Section %d", section + 1];
return view;
}
- (JAListViewItem *)listView:(JAListView *)listView viewForSection:(NSUInteger)section index:(NSUInteger)index {
DemoView *view = [DemoView demoView];
view.text = [NSString stringWithFormat:@"Section %d: Row %d", section + 1, index + 1];
return view;
}
#pragma mark NSSplitViewDelegate
- (void)splitViewWillResizeSubviews:(NSNotification *)aNotification {
if(listView.frame.size.width < 1) {
[listView reloadData];
} else if(sectionedListView.frame.size.width < 1) {
[sectionedListView reloadData];
}
}
#pragma mark API
@synthesize window;
@synthesize listView;
@synthesize sectionedListView;
@end