Improve NSDragging protocol handling

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11699 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 2001-12-11 04:31:08 +00:00
parent 14e5b05871
commit 1a4b92fb34
6 changed files with 94 additions and 135 deletions

View file

@ -1,3 +1,18 @@
2001-12-09 Willem Rein Oudshoorn <woudshoo@xs4all.nl>
* Source/NSWindow.m (GSPerformVoidDragSelector): rewritten to not
rely on category on NSObject
(GSPerformDragSelector): rewritten to not rely on category on
NSObject
([NSWindow -sendEvent:]): fixed bug in handling of informal
draggingDestination protocol
* Headers/AppKit/NSWindow.h (NSCoding>): added instance variable
_lastDragOperationMask
* Source/GNUmakefile (libgnustep-gui_OBJC_FILES): Removed obsolete
NSObjectProtocols.m file
Tue Dec 11 00:08:38 2001 Nicola Pero <n.pero@mi.flashnet.it> Tue Dec 11 00:08:38 2001 Nicola Pero <n.pero@mi.flashnet.it>
* Source/NSCell.m ([-setStringValue:]): Use a NSDebugMLLog to warn * Source/NSCell.m ([-setStringValue:]): Use a NSDebugMLLog to warn

View file

@ -204,7 +204,7 @@
<term>GraphicCompositing</term> <term>GraphicCompositing</term>
<desc> <desc>
<p> <p>
A boolean value which defaults to <code>NO</code>. If set to A boolean value which defaults to <code>YES</code>. If set to
<code>YES</code>, then the application uses various tricks <code>YES</code>, then the application uses various tricks
to get alpha colors to work when compositing images. This to get alpha colors to work when compositing images. This
may slow down drawing of images, but it is generally may slow down drawing of images, but it is generally

View file

@ -116,6 +116,7 @@ APPKIT_EXPORT NSSize NSTokenSize;
id _delegate; id _delegate;
id _fieldEditor; id _fieldEditor;
id _lastDragView; id _lastDragView;
int _lastDragOperationMask;
int _windowNum; int _windowNum;
int _gstate; int _gstate;
NSColor *_backgroundColor; NSColor *_backgroundColor;

View file

@ -100,7 +100,6 @@ NSMenuItem.m \
NSMenuItemCell.m \ NSMenuItemCell.m \
NSOpenPanel.m \ NSOpenPanel.m \
NSOutlineView.m \ NSOutlineView.m \
NSObjectProtocols.m \
NSPageLayout.m \ NSPageLayout.m \
NSPanel.m \ NSPanel.m \
NSParagraphStyle.m \ NSParagraphStyle.m \

View file

@ -1,97 +0,0 @@
/*
NSObjectProtocols.h
Various informal protocols.
Copyright (C) 1999 Free Software Foundation, Inc.
Author: Adam Fedor <fedor@gnu.org>
Date: Jul 1999
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include <AppKit/NSDragging.h>
@implementation NSObject (NSDraggingDestination)
//
// Before the Image is Released
//
- (NSDragOperation) draggingEntered: (id <NSDraggingInfo>)sender
{
return NSDragOperationNone;
}
- (NSDragOperation) draggingUpdated: (id <NSDraggingInfo>)sender
{
return NSDragOperationNone;
}
- (void) draggingExited: (id <NSDraggingInfo>)sender
{
}
//
// After the Image is Released
//
- (BOOL) prepareForDragOperation: (id <NSDraggingInfo>)sender
{
return NO;
}
- (BOOL) performDragOperation: (id <NSDraggingInfo>)sender
{
return NO;
}
- (void) concludeDragOperation: (id <NSDraggingInfo>)sender
{
}
@end
@implementation NSObject (NSDraggingSource)
//
// Querying the Source
//
- (NSDragOperation) draggingSourceOperationMaskForLocal: (BOOL)isLocal
{
return NSDragOperationNone;
}
- (BOOL) ignoreModifierKeysWhileDragging
{
return NO;
}
//
// Informing the Source
//
- (void) draggedImage: (NSImage*)image
beganAt: (NSPoint)screenPoint
{
}
- (void) draggedImage: (NSImage*)image
endedAt: (NSPoint)screenPoint
deposited: (BOOL)didDeposit
{
}
@end

View file

@ -2742,17 +2742,41 @@ resetCursorRectsForView(NSView *theView)
break; break;
#define GSPerformDragSelector(view, sel, info, action) \ #define GSPerformDragSelector(view, sel, info, action) \
if (view == _contentView && _delegate) \ do { \
action = (int)[_delegate performSelector: sel withObject: \ id target; \
info]; \ if (view == _contentView && _delegate) \
else \ { \
action = (int)[view performSelector: sel withObject: info] target = _delegate; \
#define GSPerformVoidDragSelector(view, sel, info) \ } \
if (view == _contentView && _delegate) \ else \
[_delegate performSelector: sel withObject: info]; \ { \
else \ target= view; \
[view performSelector: sel withObject: info] } \
\
if ([target respondsToSelector: sel]) \
{ \
action = (int)[target performSelector: sel withObject: info]; \
} \
} while (0)
#define GSPerformVoidDragSelector(view, sel, info) \
do { \
id target; \
if (view == _contentView && _delegate) \
{ \
target = _delegate; \
} \
else \
{ \
target= view; \
} \
\
if ([target respondsToSelector: sel]) \
{ \
[target performSelector: sel withObject: info]; \
} \
} while (0)
case GSAppKitDraggingEnter: case GSAppKitDraggingEnter:
case GSAppKitDraggingUpdate: case GSAppKitDraggingUpdate:
@ -2766,27 +2790,39 @@ resetCursorRectsForView(NSView *theView)
@selector(draggingExited:), dragInfo); @selector(draggingExited:), dragInfo);
} }
_f.accepts_drag = GSViewAcceptsDrag(v, dragInfo); _f.accepts_drag = GSViewAcceptsDrag(v, dragInfo);
if (_lastDragView != v && _f.accepts_drag) if (_f.accepts_drag)
{ {
GSPerformDragSelector(v, @selector(draggingEntered:), if (_lastDragView != v)
dragInfo, action); {
} action = NSDragOperationNone;
else GSPerformDragSelector(v, @selector(draggingEntered:),
{ dragInfo, action);
GSPerformDragSelector(v, @selector(draggingUpdated:), }
dragInfo, action); else
} {
e = [NSEvent otherEventWithType: NSAppKitDefined action = _lastDragOperationMask;
location: [theEvent locationInWindow] GSPerformDragSelector(v, @selector(draggingUpdated:),
modifierFlags: 0 dragInfo, action);
timestamp: 0 }
windowNumber: _windowNum }
context: GSCurrentContext() else
subtype: GSAppKitDraggingStatus {
data1: [theEvent data1] action = NSDragOperationNone;
data2: action]; }
[GSCurrentContext() _postExternalEvent: e];
_lastDragView = v; e = [NSEvent otherEventWithType: NSAppKitDefined
location: [theEvent locationInWindow]
modifierFlags: 0
timestamp: 0
windowNumber: _windowNum
context: GSCurrentContext()
subtype: GSAppKitDraggingStatus
data1: [theEvent data1]
data2: action];
_lastDragOperationMask = action;
[GSCurrentContext() _postExternalEvent: e];
_lastDragView = v;
break; break;
case GSAppKitDraggingStatus: case GSAppKitDraggingStatus:
@ -2798,10 +2834,10 @@ resetCursorRectsForView(NSView *theView)
dragInfo = [GSCurrentContext() _dragInfo]; dragInfo = [GSCurrentContext() _dragInfo];
if (_lastDragView && _f.accepts_drag) if (_lastDragView && _f.accepts_drag)
{ {
GSPerformDragSelector(_lastDragView, GSPerformVoidDragSelector(_lastDragView,
@selector(draggingExited:), dragInfo, @selector(draggingExited:), dragInfo);
action);
} }
_lastDragOperationMask = NSDragOperationNone;
_lastDragView = nil; _lastDragView = nil;
break; break;
@ -2809,11 +2845,14 @@ resetCursorRectsForView(NSView *theView)
if (_lastDragView && _f.accepts_drag) if (_lastDragView && _f.accepts_drag)
{ {
dragInfo = [GSCurrentContext() _dragInfo]; dragInfo = [GSCurrentContext() _dragInfo];
GSPerformDragSelector(_lastDragView,
action = NO;
GSPerformDragSelector(_lastDragView,
@selector(prepareForDragOperation:), @selector(prepareForDragOperation:),
dragInfo, action); dragInfo, action);
if (action) if (action)
{ {
action = NO;
GSPerformDragSelector(_lastDragView, GSPerformDragSelector(_lastDragView,
@selector(performDragOperation:), @selector(performDragOperation:),
dragInfo, action); dragInfo, action);
@ -2825,6 +2864,7 @@ resetCursorRectsForView(NSView *theView)
dragInfo); dragInfo);
} }
} }
_lastDragOperationMask = NSDragOperationNone;
_lastDragView = nil; _lastDragView = nil;
e = [NSEvent otherEventWithType: NSAppKitDefined e = [NSEvent otherEventWithType: NSAppKitDefined
location: [theEvent locationInWindow] location: [theEvent locationInWindow]
@ -2839,6 +2879,7 @@ resetCursorRectsForView(NSView *theView)
break; break;
case GSAppKitDraggingFinished: case GSAppKitDraggingFinished:
_lastDragOperationMask = NSDragOperationNone;
_lastDragView = nil; _lastDragView = nil;
NSDebugLLog(@"NSDragging", NSDebugLLog(@"NSDragging",
@"Internal: dropped GSAppKitDraggingFinished event"); @"Internal: dropped GSAppKitDraggingFinished event");