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
/
DCFileDropRowView.j
executable file
·72 lines (57 loc) · 1.92 KB
/
DCFileDropRowView.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
@import <AppKit/CPView.j>
@import "DCFileDropController.j"
@import "DCFileUploadManager.j"
@implementation DCFileDropRowView : CPView {
CPTextField nameField;
}
- (id)initWithFrame:(CGRect)theFrame {
self = [super initWithFrame:theFrame];
nameField = [[CPTextField alloc] initWithFrame:CGRectMake(
theFrame.origin.x + 10,
theFrame.origin.y,
theFrame.size.width - 20,
40)];
[nameField setAutoresizingMask:CPViewWidthSizable | CPViewMaxYMargin];
[nameField setLineBreakMode:CPLineBreakByTruncatingTail];
[nameField setVerticalAlignment:CPCenterVerticalTextAlignment];
[nameField setFont:[CPFont systemFontOfSize:12.0]];
[nameField setValue:[CPColor whiteColor] forThemeAttribute:@"text-color" inState:CPThemeStateSelectedDataView];
[self addSubview:nameField];
return self;
}
- (void)setThemeState:(CPThemeState)aState
{
[super setThemeState:aState];
[nameField setThemeState:aState];
}
- (void)unsetThemeState:(CPThemeState)aState
{
[super unsetThemeState:aState];
[nameField unsetThemeState:aState];
}
- (void)setObjectValue:(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