summaryrefslogtreecommitdiffstats
path: root/Plugins/BuiltInFunctions/LiImageView.m
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2008-04-14 21:45:08 -0400
committerBrian Cully <github.20.shmit@spamgourmet.com>2008-04-14 21:45:08 -0400
commit17349a5e426dc7acf1216a3767a22f69974cbca0 (patch)
tree20029d02f07ab6257cccec36d34fb312f796e1d1 /Plugins/BuiltInFunctions/LiImageView.m
downloadliaison-17349a5e426dc7acf1216a3767a22f69974cbca0.tar.gz
liaison-17349a5e426dc7acf1216a3767a22f69974cbca0.zip
Initial commit.
Diffstat (limited to 'Plugins/BuiltInFunctions/LiImageView.m')
-rw-r--r--Plugins/BuiltInFunctions/LiImageView.m59
1 files changed, 59 insertions, 0 deletions
diff --git a/Plugins/BuiltInFunctions/LiImageView.m b/Plugins/BuiltInFunctions/LiImageView.m
new file mode 100644
index 0000000..57bc46f
--- /dev/null
+++ b/Plugins/BuiltInFunctions/LiImageView.m
@@ -0,0 +1,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