This repository has been archived by the owner on Oct 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
DCFileDropTableViewController.j
84 lines (66 loc) · 2.55 KB
/
DCFileDropTableViewController.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
@import <AppKit/CPPanel.j>
@import "DCFileDropRowView.j"
@implementation DCFileDropTableViewController : CPPanel {
CPArray list;
CPTableView tableView @accessors;
CPScrollView scrollView @accessors;
CPView view @accessors;
}
- (id)init {
self = [super init];
if (self) {
list = [[CPArray alloc] init];
[list addObject:@"Drop Row One"];
[list addObject:@"Drop Row Two"];
[list addObject:@"Drop Row Three"];
[list addObject:@"Drop Row Four"];
[list addObject:@"Drop Row Five"];
// create the table view
tableView = [[CPTableView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[tableView setDataSource:self];
[tableView setDelegate:self];
var dataRowView = [[DCFileDropRowView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
var column = [[CPTableColumn alloc] initWithIdentifier:"uploads"];
[[column headerView] setStringValue:"Example Drop Table"];
[column setWidth:220.0];
[column setMinWidth:50.0];
[column setEditable:NO];
[column setDataView:dataRowView];
[tableView addTableColumn:column];
[tableView setColumnAutoresizingStyle:CPTableViewLastColumnOnlyAutoresizingStyle];
[tableView setRowHeight:40.0];
//[tableView setSelectionHighlightStyle:CPTableViewSelectionHighlightStyleNone];
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(1, 1, 98, 98)];
[scrollView setDocumentView:tableView];
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[scrollView setHasHorizontalScroller:NO];
var view = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[view setBackgroundColor:[CPColor lightGrayColor]];
[view addSubview:scrollView];
var fileDropUploadController = [[DCFileDropController alloc]
initWithView:tableView
dropDelegate:self
uploadURL:[CPURL URLWithString:@"upload.php"]
uploadManager:[DCFileUploadManager sharedManager]];
}
return self;
}
// ******************** CPTableView Delegate *********************
- (void)tableViewSelectionDidChange:(CPNotification)aNotification {
var selectedRow = [tableView selectedRow];
}
- (id)tableView:(CPTableView)aTableView objectValueForTableColumn:(int)aColumn row:(int)aRow {
return [list objectAtIndex:aRow];
}
- (int)numberOfRowsInTableView:(CPTableView)aTableView {
return [list count];
}
// ******************** DCFileDropControllerDropDelegate *********************
- (void)fileDropUploadController:(DCFileDropController)theController setState:(BOOL)visible {
if (visible) {
[tableView setBackgroundColor:[CPColor greenColor]];
} else {
[tableView setBackgroundColor:[CPColor whiteColor]];
}
}
@end