diff -r a59acc683080 -r 4e567e11f45f Source/Piece.m --- a/Source/Piece.m Thu May 29 15:04:06 2008 -0700 +++ b/Source/Piece.m Mon Jul 07 15:47:42 2008 -0700 @@ -27,13 +27,23 @@ @implementation Piece +- (id) init +{ + self = [super init]; + if (self != nil) { + self.zPosition = kPieceZ; + } + return self; +} + + + - (id) initWithImageNamed: (NSString*)imageName scale: (CGFloat)scale { - self = [super init]; + self = [self init]; if (self != nil) { [self setImageNamed: imageName scale: scale]; - self.zPosition = kPieceZ; } return self; } @@ -124,4 +134,29 @@ } +#if ! TARGET_OS_IPHONE + +// An image from another app can be dragged onto a Piece to change its background pattern. + +- (NSDragOperation)draggingEntered:(id )sender +{ + if( CanGetCGImageFromPasteboard([sender draggingPasteboard]) ) + return NSDragOperationCopy; + else + return NSDragOperationNone; +} + +- (BOOL)performDragOperation:(id )sender +{ + CGImageRef image = GetCGImageFromPasteboard([sender draggingPasteboard],sender); + if( image ) { + [self setValue: (id)image ofStyleProperty: @"contents"]; + return YES; + } else + return NO; +} + +#endif + + @end