* Headers/AppKit/NSImageView.h,

* Source/NSImageView.m: Protect image drag with new ivar that
gets set via a new GNUstep extension method.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34580 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2012-01-18 21:03:37 +00:00
parent 7da6d417a7
commit 62f2a5af94
3 changed files with 43 additions and 11 deletions

View file

@ -1,3 +1,9 @@
2012-01-18 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSImageView.h,
* Source/NSImageView.m: Protect image drag with new ivar that gets
set via a new GNUstep extension method.
2012-01-15 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSImageCell.m (-drawInteriorWithFrame:inView:):

View file

@ -1,4 +1,4 @@
/*
/* -*-objc-*-
NSImageView.h
Copyright (C) 1996 Free Software Foundation, Inc.
@ -36,7 +36,11 @@
{
id _target;
SEL _action;
BOOL _allowsCutCopyPaste;
struct GSImageViewFlagsType {
// total 32 bits. 30 bits left.
unsigned allowsCutCopyPaste: 1;
unsigned initiatesDrag: 1;
} _ivflags;
}
- (NSImage *)image;
@ -62,4 +66,13 @@
@end
#if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
//
// Methods that are GNUstep extensions
//
@interface NSImageView (GNUstep)
- (BOOL)initiatesDrag;
- (void)setInitiatesDrag: (BOOL)flag;
@end
#endif
#endif /* _GNUstep_H_NSImageView */

View file

@ -160,29 +160,29 @@ static Class imageCellClass;
- (BOOL) allowsCutCopyPaste
{
return _allowsCutCopyPaste;
return _ivflags.allowsCutCopyPaste;
}
- (void) setAllowsCutCopyPaste: (BOOL)flag
{
_allowsCutCopyPaste = flag;
_ivflags.allowsCutCopyPaste = flag;
}
- (void) delete: (id)sender
{
if (_allowsCutCopyPaste)
if ([self allowsCutCopyPaste])
[self setImage: nil];
}
- (void) deleteBackward: (id)sender
{
if (_allowsCutCopyPaste)
if ([self allowsCutCopyPaste])
[self setImage: nil];
}
- (void) copy: (id)sender
{
if (_allowsCutCopyPaste)
if ([self allowsCutCopyPaste])
{
NSImage *anImage = [self image];
@ -201,7 +201,7 @@ static Class imageCellClass;
- (void) cut: (id)sender
{
if (_allowsCutCopyPaste)
if ([self allowsCutCopyPaste])
{
[self copy: sender];
[self setImage: nil];
@ -210,7 +210,7 @@ static Class imageCellClass;
- (void) paste: (id)sender
{
if (_allowsCutCopyPaste)
if ([self allowsCutCopyPaste])
{
// paste from pasteboard
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
@ -228,7 +228,7 @@ static Class imageCellClass;
{
SEL action = [anItem action];
if (_allowsCutCopyPaste)
if ([self allowsCutCopyPaste])
{
if (sel_isEqual(action, @selector(cut:)) ||
sel_isEqual(action, @selector(copy:)) ||
@ -307,7 +307,7 @@ static Class imageCellClass;
- (void) mouseDown: (NSEvent*)theEvent
{
if ([self isEditable])
if ([self initiatesDrag])
{
NSPasteboard *pboard;
NSImage *anImage = [self image];
@ -418,3 +418,16 @@ static Class imageCellClass;
@end
@implementation NSImageView (GNUstep)
- (BOOL)initiatesDrag
{
return _ivflags.initiatesDrag;
}
- (void)setInitiatesDrag: (BOOL)flag
{
_ivflags.initiatesDrag = flag;
}
@end