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:
Adam Fedor 2001-12-11 04:31:08 +00:00
parent 6cb538313c
commit 6923231b25
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>
* Source/NSCell.m ([-setStringValue:]): Use a NSDebugMLLog to warn

View file

@ -204,7 +204,7 @@
<term>GraphicCompositing</term>
<desc>
<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
to get alpha colors to work when compositing images. This
may slow down drawing of images, but it is generally

View file

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

View file

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