blob: 57bc46f05a727faf6bcb7d9137cdc43c3846a9bd (
plain)
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
|
#import "LiImageView.h"
@implementation LiImageView
- (NSArray *)namesOfPromisedFilesDroppedAtDestination: (NSURL *)dropDestination
{
NSFileManager *defaultManager;
NSString *imageDir, *path, *filename;
int suffix;
[LiLog logAsDebug: @"[LiImageView names..Desitination: %@]", dropDestination];
imageDir = [dropDestination path];
defaultManager = [NSFileManager defaultManager];
for (suffix = 0; suffix < 100; suffix++) {
filename = [NSString stringWithFormat: @"LiaisonIcon%02d.tiff", suffix];
path = [imageDir stringByAppendingPathComponent: filename];
if ([defaultManager fileExistsAtPath: path] == NO) {
[LiLog logAsDebug: @"\tsaving to path: %@", path];
break;
}
}
if (suffix < 100) {
if ([defaultManager createFileAtPath: path
contents: [[self image] TIFFRepresentation]
attributes: nil] == NO) {
return nil;
}
} else
return nil;
return [NSArray arrayWithObject: filename];
}
- (void)mouseDown: (NSEvent *)theEvent
{
NSPoint dragPosition;
NSRect imageLocation;
[[NSApp keyWindow] makeFirstResponder: self];
dragPosition = [self convertPoint: [theEvent locationInWindow]
fromView: nil];
dragPosition.x -= 16;
dragPosition.y -= 16;
imageLocation.origin = dragPosition;
imageLocation.size = NSMakeSize(32,32);
[self dragPromisedFilesOfTypes: [NSArray arrayWithObject: @"tiff"]
fromRect: imageLocation source: self
slideBack: YES event: theEvent];
}
- (void)mouseDragged: (NSEvent *)anEvent
{
[LiLog logAsDebug: @"[LiImageView mouseDragged]"];
[super mouseDragged: anEvent];
}
@end
|