* 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:
fredkiefer 2012-01-18 21:03:37 +00:00
parent 2ca95e6a5b
commit 0b99ca07c2
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> 2012-01-15 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSImageCell.m (-drawInteriorWithFrame:inView:): * Source/NSImageCell.m (-drawInteriorWithFrame:inView:):

View file

@ -1,4 +1,4 @@
/* /* -*-objc-*-
NSImageView.h NSImageView.h
Copyright (C) 1996 Free Software Foundation, Inc. Copyright (C) 1996 Free Software Foundation, Inc.
@ -36,7 +36,11 @@
{ {
id _target; id _target;
SEL _action; SEL _action;
BOOL _allowsCutCopyPaste; struct GSImageViewFlagsType {
// total 32 bits. 30 bits left.
unsigned allowsCutCopyPaste: 1;
unsigned initiatesDrag: 1;
} _ivflags;
} }
- (NSImage *)image; - (NSImage *)image;
@ -62,4 +66,13 @@
@end @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 */ #endif /* _GNUstep_H_NSImageView */

View file

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