deskflow/src/lib/platform/OSXDragView.m

150 lines
3.2 KiB
Mathematica
Raw Normal View History

/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2013 - 2016 Symless Ltd.
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
#import "platform/OSXDragView.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wobjc-protocol-property-synthesis"
#pragma clang diagnostic ignored "-Wprotocol"
2014-11-11 13:51:47 +00:00
@implementation OSXDragView
2014-02-25 15:03:43 +00:00
@dynamic draggingFormation;
@dynamic animatesToDestination;
@dynamic numberOfValidItemsForDrop;
2024-12-18 01:42:03 +00:00
- (id)initWithFrame:(NSRect)frame
{
2024-12-18 01:42:03 +00:00
self = [super initWithFrame:frame];
m_dropTarget = [[NSMutableString alloc] initWithCapacity:0];
m_dragFileExt = [[NSMutableString alloc] initWithCapacity:0];
return self;
}
2024-12-18 01:42:03 +00:00
- (void)drawRect:(NSRect)dirtyRect
{
}
2024-12-18 01:42:03 +00:00
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
{
2024-12-18 01:42:03 +00:00
return YES;
}
2024-12-18 01:42:03 +00:00
- (void)mouseDown:(NSEvent *)theEvent
{
2024-12-18 01:42:03 +00:00
NSLog(@"cocoa mouse down");
NSPoint dragPosition;
NSRect imageLocation;
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:m_dragFileExt]
fromRect:imageLocation
source:self
slideBack:NO
event:theEvent];
}
2024-12-18 01:42:03 +00:00
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
{
2024-12-18 01:42:03 +00:00
[m_dropTarget setString:@""];
[m_dropTarget appendString:dropDestination.path];
NSLog(@"cocoa drop target: %@", m_dropTarget);
return nil;
}
2024-12-18 01:42:03 +00:00
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag
{
2024-12-18 01:42:03 +00:00
return NSDragOperationCopy;
}
2024-12-18 01:42:03 +00:00
- (CFStringRef)getDropTarget
{
2024-12-18 01:42:03 +00:00
NSMutableString *string;
string = [[NSMutableString alloc] initWithCapacity:0];
[string appendString:m_dropTarget];
return (CFStringRef)string;
}
2024-12-18 01:42:03 +00:00
- (void)clearDropTarget
{
2024-12-18 01:42:03 +00:00
[m_dropTarget setString:@""];
}
2024-12-18 01:42:03 +00:00
- (void)setFileExt:(NSString *)ext
2014-04-17 17:25:41 +00:00
{
2024-12-18 01:42:03 +00:00
[ext retain];
[m_dragFileExt release];
m_dragFileExt = ext;
NSLog(@"drag file ext: %@", m_dragFileExt);
2014-04-17 17:25:41 +00:00
}
2024-12-18 01:42:03 +00:00
- (NSWindow *)draggingDestinationWindow
2014-02-25 15:03:43 +00:00
{
2024-12-18 01:42:03 +00:00
return nil;
2014-02-25 15:03:43 +00:00
}
2024-12-18 01:42:03 +00:00
- (NSDragOperation)draggingSourceOperationMask
2014-02-25 15:03:43 +00:00
{
2024-12-18 01:42:03 +00:00
return NSDragOperationCopy;
2014-02-25 15:03:43 +00:00
}
- (NSPoint)draggingLocation
{
2024-12-18 01:42:03 +00:00
NSPoint point;
return point;
2014-02-25 15:03:43 +00:00
}
- (NSPoint)draggedImageLocation
{
2024-12-18 01:42:03 +00:00
NSPoint point;
return point;
2014-02-25 15:03:43 +00:00
}
- (NSImage *)draggedImage
{
2024-12-18 01:42:03 +00:00
return nil;
2014-02-25 15:03:43 +00:00
}
- (NSPasteboard *)draggingPasteboard
{
2024-12-18 01:42:03 +00:00
return nil;
2014-02-25 15:03:43 +00:00
}
- (id)draggingSource
{
2024-12-18 01:42:03 +00:00
return nil;
2014-02-25 15:03:43 +00:00
}
- (NSInteger)draggingSequenceNumber
{
2024-12-18 01:42:03 +00:00
return 0;
2014-02-25 15:03:43 +00:00
}
- (void)slideDraggedImageTo:(NSPoint)screenPoint
{
}
2024-12-18 01:42:03 +00:00
- (NSDragOperation)draggingSession:(NSDraggingSession *)session
sourceOperationMaskForDraggingContext:(NSDraggingContext)context
2014-02-25 15:03:43 +00:00
{
2024-12-18 01:42:03 +00:00
return NSDragOperationCopy;
2014-02-25 15:03:43 +00:00
}
2024-12-18 01:42:03 +00:00
- (void)enumerateDraggingItemsWithOptions:(NSDraggingItemEnumerationOptions)enumOpts
forView:(NSView *)view
classes:(NSArray *)classArray
searchOptions:(NSDictionary *)searchOptions
usingBlock:(void (^)(NSDraggingItem *draggingItem, NSInteger idx, BOOL *stop))block
2014-02-25 15:03:43 +00:00
{
}
@end