forked from davidcann/deepDropUpload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DCFileDropCollectionViewItemView.j
executable file
·83 lines (67 loc) · 2.39 KB
/
DCFileDropCollectionViewItemView.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
@import <AppKit/CPView.j>
@import "DCFileDropController.j"
@import "DCFileUploadManager.j"
@implementation DCFileDropCollectionViewItemView : CPView {
CPTextField nameField;
}
- (id)initWithFrame:(CGRect)theFrame {
self = [super initWithFrame:theFrame];
nameField = [[CPTextField alloc] initWithFrame:[self bounds]];
[nameField setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[nameField setLineBreakMode:CPLineBreakByTruncatingTail];
[nameField setAlignment:CPCenterTextAlignment];
[nameField setVerticalAlignment:CPCenterVerticalTextAlignment];
[nameField setFont:[CPFont systemFontOfSize:12.0]];
[nameField setValue:[CPColor whiteColor] forThemeAttribute:@"text-color" inState:CPThemeStateSelectedDataView];
[self addSubview:nameField];
return self;
}
- (void)setSelected:(BOOL)isSelected {
if (isSelected) {
[self setThemeState:CPThemeStateSelected];
} else {
[self unsetThemeState:CPThemeStateSelected];
}
}
- (void)setThemeState:(CPThemeState)aState {
[super setThemeState:aState];
[nameField setThemeState:aState];
if (aState === CPThemeStateSelected) {
[self setBackgroundColor:[CPColor colorWithRed:0.356 green:0.557 blue:0.691 alpha:1.000]];
[nameField setTextColor:[CPColor whiteColor]];
}
}
- (void)unsetThemeState:(CPThemeState)aState {
[super unsetThemeState:aState];
[nameField unsetThemeState:aState];
if (aState === CPThemeStateSelected) {
[self setBackgroundColor:[CPColor clearColor]];
[nameField setTextColor:[CPColor blackColor]];
}
}
- (void)setRepresentedObject:(Object)anObject {
[nameField setStringValue:anObject];
}
- (id)initWithCoder:(CPCoder)aCoder {
self = [super initWithCoder:aCoder];
nameField = [aCoder decodeObjectForKey:"nameField"];
var fileDropUploadController = [[DCFileDropController alloc]
initWithView:self
dropDelegate:self
uploadURL:[CPURL URLWithString:@"upload.php"]
uploadManager:[DCFileUploadManager sharedManager]];
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder {
[super encodeWithCoder:aCoder];
[aCoder encodeObject:nameField forKey:"nameField"];
}
// ******************** DCFileDropControllerDropDelegate *********************
- (void)fileDropUploadController:(DCFileDropController)theController setState:(BOOL)visible {
if (visible) {
[self setBackgroundColor:[CPColor colorWithRed:1.0 green:1.0 blue:0.0 alpha:0.7]];
} else {
[self setBackgroundColor:[CPColor clearColor]];
}
}
@end