Submitted patch to NSImageView to handle target and action.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@18424 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2004-01-15 23:57:54 +00:00
parent aee95ba5dd
commit 49e8f3f2ec
3 changed files with 57 additions and 1 deletions

View file

@ -1,3 +1,10 @@
2004-01-16 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSImageView.h: Added ivars for traget and action.
* Source/NSImageView.m: Implemented target and action handling and
sending of the action when an image gets dropped on the
view. Patch by Kazunobu Kuriyama (kazunobu.kuriyama@nifty.com)
2004-01-15 Serg Stoyan <stoyan@on.com.ua>
* Images/common_MiniWindowTile.m: New file.

View file

@ -31,6 +31,8 @@
@interface NSImageView : NSControl
{
id _target;
SEL _action;
}
- (NSImage *)image;

View file

@ -46,7 +46,7 @@ static Class imageCellClass;
{
if (self == [NSImageView class])
{
[self setVersion: 1];
[self setVersion: 2];
imageCellClass = [NSImageCell class];
usedCellClass = imageCellClass;
}
@ -193,6 +193,7 @@ static Class imageCellClass;
else
{
[self setImage: image];
[self sendAction: _action to: _target];
RELEASE(image);
return YES;
}
@ -237,5 +238,51 @@ static Class imageCellClass;
return NSDragOperationCopy;
}
//
// Target and Action
//
// Target and action are handled by NSImageView itself, not its own cell.
//
- (id) target
{
return _target;
}
- (void) setTarget: (id)anObject
{
_target = anObject;
}
- (SEL) action
{
return _action;
}
- (void) setAction: (SEL)aSelector
{
_action = aSelector;
}
//
// NSCoding Protocol
//
- (void) encodeWithCoder: (NSCoder *)aCoder
{
[super encodeWithCoder: aCoder];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
}
- (id) initWithCoder: (NSCoder *)aDecoder
{
self = [super initWithCoder: aDecoder];
if ([aDecoder versionForClassName: @"NSImageView"] >= 2)
{
_target = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_action];
}
return self;
}
@end