home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula
/
nebula.bin
/
SourceCode
/
Palettes
/
Clocks
/
Inspectors.subproj
/
SoundWell.m
< prev
Wrap
Text File
|
1992-12-09
|
3KB
|
119 lines
//------------------------------------------------------------------------------------------------
//
// SoundWell
//
// Inherits From: View
//
// Declared In: SoundWell.h
//
// Disclaimer
//
// You may freely copy, distribute and reuse this software and its
// associated documentation. I disclaim any warranty of any kind,
// expressed or implied, as to its fitness for any particular use.
//
//------------------------------------------------------------------------------------------------
#import "SoundWell.h"
@implementation SoundWell
//------------------------------------------------------------------------------------------------
// Initialization and Freeing
//------------------------------------------------------------------------------------------------
- initFrame: (const NXRect*) frameRect
{
[super initFrame:frameRect];
[self setCell: [[ActionCell allocFromZone:[self zone]] init]];
[self registerForDraggedTypes:&NXFilenamePboardType count:1];
return self;
}
- free
{
if (sound) [sound free];
return [super free];
}
//------------------------------------------------------------------------------------------------
// Accessing Image
//------------------------------------------------------------------------------------------------
- sound: aSound
{
sound = aSound;
return self;
}
- sound
{
return sound;
}
//------------------------------------------------------------------------------------------------
// Action Methods
//------------------------------------------------------------------------------------------------
- play: sender
{
[sound play];
return self;
}
//------------------------------------------------------------------------------------------------
// Drawing
//------------------------------------------------------------------------------------------------
- drawSelf: (const NXRect *)rects :(int)count
{
NXSetColor ([[self window] backgroundColor]);
NXRectFill (&bounds);
return self;
}
//------------------------------------------------------------------------------------------------
// Dragging
//------------------------------------------------------------------------------------------------
- (NXDragOperation) draggingEntered:dragSource
{
return NX_DragOperationCopy;
}
- (BOOL) performDragOperation:dragSource
{
char* pathString;
char* data;
int length;
id aPboard = [dragSource draggingPasteboard];
[aPboard readType:NXFilenamePboardType data:&data length:&length];
if ((pathString = index (data, '\t'))) *pathString = '\0';
if ((pathString = rindex (data, '.')))
if (NXOrderStrings (pathString + 1, "snd", YES, -1, NULL) == 0)
{
sound = [[Sound allocFromZone: [self zone]] initFromSoundfile: data];
[sound play];
[aPboard deallocatePasteboardData:data length:length];
return YES;
}
[aPboard deallocatePasteboardData:data length:length];
return NO;
}
- concludeDragOperation:dragSource
{
[[self target] perform:[self action] with:self];
return self;
}
@end