mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Added dragging patch by Yen-Ju Chen.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25092 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
cc412d3a43
commit
3b4aca0261
3 changed files with 113 additions and 78 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,10 @@
|
|||
2007-04-27 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/AppKit/NSDragging.h: Added a few MacOSX 10.2 methods
|
||||
* Source/GSSlideView.m: (-_handleDrag:slidePoint:): Call new
|
||||
MacOSX method on destionation when available.
|
||||
Patch by Yen-Ju Chen <yjchenx@gmail.com>
|
||||
|
||||
2007-04-27 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSTableView.m (-editColumn::row:withEvent:select:): Set
|
||||
|
@ -200,9 +207,9 @@
|
|||
|
||||
2007-03-09 Sergii Stoian <stoyan255@yahoo.com>
|
||||
|
||||
* Source/GSSlideView.m: (- _slideFrom:to:): Calcuate number of
|
||||
steps wrt image size.
|
||||
* Source/GSDragView.m: (- slideDraggedImageTo:): Ditto.
|
||||
* Source/GSSlideView.m: (- _slideFrom:to:): Calcuate number of
|
||||
steps wrt image size.
|
||||
* Source/GSDragView.m: (- slideDraggedImageTo:): Ditto.
|
||||
|
||||
2007-03-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
@class NSWindow;
|
||||
@class NSPasteboard;
|
||||
@class NSImage;
|
||||
@class NSURL;
|
||||
|
||||
typedef enum _NSDragOperation {
|
||||
NSDragOperationNone = 0,
|
||||
|
@ -45,7 +46,7 @@ typedef enum _NSDragOperation {
|
|||
NSDragOperationMove = 16,
|
||||
NSDragOperationDelete = 32,
|
||||
NSDragOperationAll = 63,
|
||||
NSDragOperationEvery = NSDragOperationAll
|
||||
NSDragOperationEvery = 0xffff
|
||||
} NSDragOperation;
|
||||
|
||||
@protocol NSDraggingInfo
|
||||
|
@ -71,6 +72,9 @@ typedef enum _NSDragOperation {
|
|||
//
|
||||
- (void)slideDraggedImageTo:(NSPoint)screenPoint;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
|
||||
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination;
|
||||
#endif
|
||||
@end
|
||||
|
||||
@interface NSObject (NSDraggingDestination)
|
||||
|
@ -91,6 +95,8 @@ typedef enum _NSDragOperation {
|
|||
|
||||
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
||||
- (void)draggingEnded: (id <NSDraggingInfo>)sender;
|
||||
#endif
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
||||
- (BOOL)wantsPeriodicDraggingUpdates;
|
||||
#endif
|
||||
@end
|
||||
|
@ -115,10 +121,13 @@ typedef enum _NSDragOperation {
|
|||
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
||||
- (void)draggedImage: (NSImage*)image
|
||||
endedAt: (NSPoint)screenPoint
|
||||
operation: (NSDragOperation)operation;
|
||||
operation: (NSDragOperation)operation;
|
||||
- (void)draggedImage: (NSImage*)image
|
||||
movedTo: (NSPoint)screenPoint;
|
||||
#endif
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
|
||||
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination;
|
||||
#endif
|
||||
@end
|
||||
|
||||
#endif // _GNUstep_H_NSDragging
|
||||
|
|
|
@ -208,6 +208,10 @@ static GSDragView *sharedDragView = nil;
|
|||
return loc;
|
||||
}
|
||||
|
||||
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
|
||||
{
|
||||
return [[self draggingSource] namesOfPromisedFilesDroppedAtDestination: dropDestination];
|
||||
}
|
||||
|
||||
- (BOOL) isDragging
|
||||
{
|
||||
|
@ -306,25 +310,25 @@ static GSDragView *sharedDragView = nil;
|
|||
NSDragOperation action = [theEvent data2];
|
||||
|
||||
if (destExternal)
|
||||
{
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (action != targetMask)
|
||||
{
|
||||
targetMask = action;
|
||||
[self _setCursor];
|
||||
}
|
||||
}
|
||||
if (action != targetMask)
|
||||
{
|
||||
targetMask = action;
|
||||
[self _setCursor];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) sendExternalEvent: (GSAppKitSubtype)subtype
|
||||
action: (NSDragOperation)action
|
||||
position: (NSPoint)eventLocation
|
||||
timestamp: (NSTimeInterval)time
|
||||
toWindow: (int)dWindowNumber
|
||||
action: (NSDragOperation)action
|
||||
position: (NSPoint)eventLocation
|
||||
timestamp: (NSTimeInterval)time
|
||||
toWindow: (int)dWindowNumber
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -334,7 +338,7 @@ static GSDragView *sharedDragView = nil;
|
|||
set, if there is a native window, but no GNUstep window at this location.
|
||||
*/
|
||||
- (NSWindow*) windowAcceptingDnDunder: (NSPoint)mouseLocation
|
||||
windowRef: (int*)mouseWindowRef
|
||||
windowRef: (int*)mouseWindowRef
|
||||
{
|
||||
int win;
|
||||
|
||||
|
@ -363,8 +367,8 @@ static GSDragView *sharedDragView = nil;
|
|||
- all instance variables pertaining to moving the window are initialized
|
||||
*/
|
||||
- (void) _setupWindowFor: (NSImage*)anImage
|
||||
mousePosition: (NSPoint)mPoint
|
||||
imagePosition: (NSPoint)iPoint
|
||||
mousePosition: (NSPoint)mPoint
|
||||
imagePosition: (NSPoint)iPoint
|
||||
{
|
||||
NSSize imageSize;
|
||||
|
||||
|
@ -678,21 +682,21 @@ static GSDragView *sharedDragView = nil;
|
|||
[cursorBeforeDrag set];
|
||||
NSDebugLLog(@"NSDragging", @"sending dnd drop\n");
|
||||
if (!destExternal)
|
||||
{
|
||||
[self _sendLocalEvent: GSAppKitDraggingDrop
|
||||
action: 0
|
||||
position: NSZeroPoint
|
||||
timestamp: [theEvent timestamp]
|
||||
toWindow: destWindow];
|
||||
}
|
||||
{
|
||||
[self _sendLocalEvent: GSAppKitDraggingDrop
|
||||
action: 0
|
||||
position: NSZeroPoint
|
||||
timestamp: [theEvent timestamp]
|
||||
toWindow: destWindow];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self sendExternalEvent: GSAppKitDraggingDrop
|
||||
action: 0
|
||||
position: NSZeroPoint
|
||||
timestamp: [theEvent timestamp]
|
||||
toWindow: targetWindowRef];
|
||||
}
|
||||
{
|
||||
[self sendExternalEvent: GSAppKitDraggingDrop
|
||||
action: 0
|
||||
position: NSZeroPoint
|
||||
timestamp: [theEvent timestamp]
|
||||
toWindow: targetWindowRef];
|
||||
}
|
||||
deposited = YES;
|
||||
}
|
||||
else
|
||||
|
@ -707,7 +711,21 @@ static GSDragView *sharedDragView = nil;
|
|||
}
|
||||
|
||||
if ([dragSource respondsToSelector:
|
||||
@selector(draggedImage:endedAt:deposited:)])
|
||||
@selector(draggedImage:endedAt:operation:)])
|
||||
{
|
||||
NSPoint point;
|
||||
|
||||
point = [theEvent locationInWindow];
|
||||
// Convert from mouse cursor coordinate to image coordinate
|
||||
point.x -= offset.width;
|
||||
point.y -= offset.height;
|
||||
point = [[theEvent window] convertBaseToScreen: point];
|
||||
[dragSource draggedImage: [self draggedImage]
|
||||
endedAt: point
|
||||
operation: targetMask & dragMask & operationMask];
|
||||
}
|
||||
else if ([dragSource respondsToSelector:
|
||||
@selector(draggedImage:endedAt:deposited:)])
|
||||
{
|
||||
NSPoint point;
|
||||
|
||||
|
@ -717,8 +735,8 @@ static GSDragView *sharedDragView = nil;
|
|||
point.y -= offset.height;
|
||||
point = [[theEvent window] convertBaseToScreen: point];
|
||||
[dragSource draggedImage: [self draggedImage]
|
||||
endedAt: point
|
||||
deposited: deposited];
|
||||
endedAt: point
|
||||
deposited: deposited];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -737,7 +755,7 @@ static GSDragView *sharedDragView = nil;
|
|||
{
|
||||
case GSAppKitWindowMoved:
|
||||
case GSAppKitWindowResized:
|
||||
case GSAppKitRegionExposed:
|
||||
case GSAppKitRegionExposed:
|
||||
/*
|
||||
* Keep window up-to-date with its current position.
|
||||
*/
|
||||
|
@ -763,9 +781,9 @@ static GSDragView *sharedDragView = nil;
|
|||
break;
|
||||
|
||||
case GSAppKitWindowFocusIn:
|
||||
case GSAppKitWindowFocusOut:
|
||||
case GSAppKitWindowLeave:
|
||||
case GSAppKitWindowEnter:
|
||||
case GSAppKitWindowFocusOut:
|
||||
case GSAppKitWindowLeave:
|
||||
case GSAppKitWindowEnter:
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -780,29 +798,29 @@ static GSDragView *sharedDragView = nil;
|
|||
case NSLeftMouseDown:
|
||||
case NSLeftMouseUp:
|
||||
newPosition = [[theEvent window] convertBaseToScreen:
|
||||
[theEvent locationInWindow]];
|
||||
[theEvent locationInWindow]];
|
||||
break;
|
||||
case NSFlagsChanged:
|
||||
if ([self _updateOperationMask: theEvent])
|
||||
{
|
||||
// If flags change, send update to allow
|
||||
// destination to take note.
|
||||
if (destWindow)
|
||||
// If flags change, send update to allow
|
||||
// destination to take note.
|
||||
if (destWindow)
|
||||
{
|
||||
[self _sendLocalEvent: GSAppKitDraggingUpdate
|
||||
action: dragMask & operationMask
|
||||
position: newPosition
|
||||
timestamp: [theEvent timestamp]
|
||||
toWindow: destWindow];
|
||||
}
|
||||
else
|
||||
{
|
||||
action: dragMask & operationMask
|
||||
position: newPosition
|
||||
timestamp: [theEvent timestamp]
|
||||
toWindow: destWindow];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self sendExternalEvent: GSAppKitDraggingUpdate
|
||||
action: dragMask & operationMask
|
||||
position: newPosition
|
||||
timestamp: [theEvent timestamp]
|
||||
toWindow: targetWindowRef];
|
||||
}
|
||||
action: dragMask & operationMask
|
||||
position: newPosition
|
||||
timestamp: [theEvent timestamp]
|
||||
toWindow: targetWindowRef];
|
||||
}
|
||||
[self _setCursor];
|
||||
}
|
||||
break;
|
||||
|
@ -836,7 +854,7 @@ static GSDragView *sharedDragView = nil;
|
|||
destWindow = [self windowAcceptingDnDunder: dragPosition
|
||||
windowRef: &mouseWindowRef];
|
||||
|
||||
// If we have are not hovering above a window that we own
|
||||
// If we are not hovering above a window that we own
|
||||
// we are dragging to an external application.
|
||||
destExternal = (mouseWindowRef != 0) && (destWindow == nil);
|
||||
|
||||
|
@ -858,18 +876,18 @@ static GSDragView *sharedDragView = nil;
|
|||
if (oldDestWindow != nil)
|
||||
{
|
||||
[self _sendLocalEvent: GSAppKitDraggingExit
|
||||
action: dragMask & operationMask
|
||||
position: NSZeroPoint
|
||||
action: dragMask & operationMask
|
||||
position: NSZeroPoint
|
||||
timestamp: dragSequence
|
||||
toWindow: oldDestWindow];
|
||||
toWindow: oldDestWindow];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self sendExternalEvent: GSAppKitDraggingExit
|
||||
action: dragMask & operationMask
|
||||
position: NSZeroPoint
|
||||
timestamp: dragSequence
|
||||
toWindow: targetWindowRef];
|
||||
action: dragMask & operationMask
|
||||
position: NSZeroPoint
|
||||
timestamp: dragSequence
|
||||
toWindow: targetWindowRef];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -891,21 +909,22 @@ static GSDragView *sharedDragView = nil;
|
|||
// same window, sending update
|
||||
NSDebugLLog(@"NSDragging", @"sending dnd pos\n");
|
||||
|
||||
// FIXME: We should only send this when the destination wantsPeriodicDraggingUpdates
|
||||
if (destWindow != nil)
|
||||
{
|
||||
[self _sendLocalEvent: GSAppKitDraggingUpdate
|
||||
action: dragMask & operationMask
|
||||
position: dragPosition
|
||||
timestamp: dragSequence
|
||||
toWindow: destWindow];
|
||||
action: dragMask & operationMask
|
||||
position: dragPosition
|
||||
timestamp: dragSequence
|
||||
toWindow: destWindow];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self sendExternalEvent: GSAppKitDraggingUpdate
|
||||
action: dragMask & operationMask
|
||||
position: dragPosition
|
||||
timestamp: dragSequence
|
||||
toWindow: targetWindowRef];
|
||||
[self sendExternalEvent: GSAppKitDraggingUpdate
|
||||
action: dragMask & operationMask
|
||||
position: dragPosition
|
||||
timestamp: dragSequence
|
||||
toWindow: targetWindowRef];
|
||||
}
|
||||
}
|
||||
else if (mouseWindowRef != 0)
|
||||
|
@ -917,10 +936,10 @@ static GSDragView *sharedDragView = nil;
|
|||
if (destWindow != nil)
|
||||
{
|
||||
[self _sendLocalEvent: GSAppKitDraggingEnter
|
||||
action: dragMask
|
||||
position: dragPosition
|
||||
timestamp: dragSequence
|
||||
toWindow: destWindow];
|
||||
action: dragMask
|
||||
position: dragPosition
|
||||
timestamp: dragSequence
|
||||
toWindow: destWindow];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue