2004-12-05 20:52:36 +00:00
|
|
|
/* GormSound.m
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Free Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
|
|
|
* Date: Dec 2004
|
|
|
|
*
|
|
|
|
* This file is part of GNUstep.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-11-05 23:44:36 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-12-05 20:52:36 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-05-26 03:37:38 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
2004-12-05 20:52:36 +00:00
|
|
|
*/
|
|
|
|
|
2019-11-03 01:57:39 +00:00
|
|
|
#include <Foundation/Foundation.h>
|
|
|
|
#include <AppKit/AppKit.h>
|
|
|
|
|
|
|
|
#include <InterfaceBuilder/InterfaceBuilder.h>
|
|
|
|
|
2004-12-05 20:52:36 +00:00
|
|
|
#include "GormSound.h"
|
|
|
|
|
|
|
|
// sound proxy object...
|
|
|
|
@implementation GormSound
|
2004-12-07 05:23:00 +00:00
|
|
|
+ (GormSound*) soundForPath: (NSString *)aPath
|
2004-12-05 20:52:36 +00:00
|
|
|
{
|
2005-01-04 04:52:46 +00:00
|
|
|
return [GormSound soundForPath: aPath inWrapper: NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (GormSound*) soundForPath: (NSString *)aPath inWrapper: (BOOL)flag
|
|
|
|
{
|
|
|
|
return AUTORELEASE([[GormSound alloc] initWithPath: aPath inWrapper: flag]);
|
2004-12-07 05:23:00 +00:00
|
|
|
}
|
|
|
|
|
2006-06-05 02:12:00 +00:00
|
|
|
+ (GormSound*)soundForData: (NSData *)aData withFileName: (NSString *)aName inWrapper: (BOOL)flag
|
|
|
|
{
|
|
|
|
return AUTORELEASE([[GormSound alloc] initWithData: aData withFileName: aName inWrapper: flag]);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithData: (NSData *)aData withFileName: (NSString *)aName inWrapper: (BOOL)flag
|
|
|
|
{
|
|
|
|
if((self = [super initWithData: aData withFileName: aName inWrapper: flag]))
|
|
|
|
{
|
|
|
|
// ASSIGN(sound, AUTORELEASE([[NSImage alloc] initWithData: aData]));
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2005-01-04 04:52:46 +00:00
|
|
|
- (id) initWithName: (NSString *)aName
|
|
|
|
path: (NSString *)aPath
|
|
|
|
inWrapper: (BOOL)flag
|
2004-12-05 20:52:36 +00:00
|
|
|
{
|
2005-03-02 02:27:55 +00:00
|
|
|
if((self = [super initWithName: aName path: aPath inWrapper: flag]) != nil)
|
|
|
|
{
|
|
|
|
NSSound *sound = [[NSSound alloc] initWithContentsOfFile: aPath
|
|
|
|
byReference: YES];
|
|
|
|
|
|
|
|
[(NSSound *)sound setName: aName]; // cache the sound under the given name.
|
|
|
|
}
|
2004-12-05 20:52:36 +00:00
|
|
|
return self;
|
|
|
|
}
|
2005-07-28 04:01:24 +00:00
|
|
|
@end
|
2004-12-05 20:52:36 +00:00
|
|
|
|
2005-07-28 04:01:24 +00:00
|
|
|
@implementation GormSound (IBObjectAdditions)
|
2004-12-05 20:52:36 +00:00
|
|
|
- (NSString *)inspectorClassName
|
|
|
|
{
|
|
|
|
return @"GormSoundInspector";
|
|
|
|
}
|
|
|
|
|
2005-04-14 04:40:48 +00:00
|
|
|
- (NSString *) classInspectorClassName
|
2004-12-05 20:52:36 +00:00
|
|
|
{
|
|
|
|
return @"GormNotApplicableInspector";
|
|
|
|
}
|
|
|
|
|
2005-04-14 04:40:48 +00:00
|
|
|
- (NSString *) connectInspectorClassName
|
2004-12-05 20:52:36 +00:00
|
|
|
{
|
|
|
|
return @"GormNotApplicableInspector";
|
|
|
|
}
|
|
|
|
|
2005-04-14 04:40:48 +00:00
|
|
|
- (NSString *) objectNameForInspectorTitle
|
|
|
|
{
|
|
|
|
return @"Sound";
|
|
|
|
}
|
|
|
|
|
2005-03-02 02:27:55 +00:00
|
|
|
- (NSImage *) imageForViewer
|
2004-12-05 20:52:36 +00:00
|
|
|
{
|
2005-03-02 02:27:55 +00:00
|
|
|
static NSImage *image = nil;
|
2005-01-22 17:16:16 +00:00
|
|
|
|
2005-03-02 02:27:55 +00:00
|
|
|
if (image == nil)
|
|
|
|
{
|
2023-06-14 10:18:24 +00:00
|
|
|
NSBundle *bundle = [NSBundle bundleForClass: [self class]];
|
2005-03-02 02:27:55 +00:00
|
|
|
NSString *bpath = [bundle pathForImageResource: @"GormSound"];
|
2005-01-22 17:16:16 +00:00
|
|
|
|
2005-03-02 02:27:55 +00:00
|
|
|
image = [[NSImage alloc] initWithContentsOfFile: bpath];
|
|
|
|
}
|
|
|
|
return image;
|
2005-01-22 17:16:16 +00:00
|
|
|
}
|
2004-12-05 20:52:36 +00:00
|
|
|
@end
|