Documentation tweaks

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14762 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2002-10-13 10:33:26 +00:00
parent ed00ac6d93
commit ebf17d372b
3 changed files with 79 additions and 80 deletions

View file

@ -46,7 +46,7 @@ static NSDictionary *nsmapping = nil;
@implementation NSBundle (NSSoundAdditions) @implementation NSBundle (NSSoundAdditions)
- (NSString *)pathForSoundResource:(NSString *)name - (NSString *) pathForSoundResource: (NSString *)name
{ {
NSString *ext = [name pathExtension]; NSString *ext = [name pathExtension];
NSString *path = nil; NSString *path = nil;
@ -75,15 +75,15 @@ static NSDictionary *nsmapping = nil;
@protocol GSSoundSvr @protocol GSSoundSvr
- (BOOL)playSound:(id)aSound; - (BOOL) playSound: (id)aSound;
- (BOOL)stopSoundWithIdentifier:(NSString *)identifier; - (BOOL) stopSoundWithIdentifier: (NSString *)identifier;
- (BOOL)pauseSoundWithIdentifier:(NSString *)identifier; - (BOOL) pauseSoundWithIdentifier: (NSString *)identifier;
- (BOOL)resumeSoundWithIdentifier:(NSString *)identifier; - (BOOL) resumeSoundWithIdentifier: (NSString *)identifier;
- (BOOL)isPlayingSoundWithIdentifier:(NSString *)identifier; - (BOOL) isPlayingSoundWithIdentifier: (NSString *)identifier;
@end @end
@ -91,32 +91,32 @@ static id<GSSoundSvr> the_server = nil;
@interface NSSound (PrivateMethods) @interface NSSound (PrivateMethods)
+ (id<GSSoundSvr>)gsnd; + (id<GSSoundSvr>) gsnd;
+ (void)localServer:(id<GSSoundSvr>)s; + (void) localServer: (id<GSSoundSvr>)s;
+ (id)lostServer:(NSNotification*)notification; + (id) lostServer: (NSNotification*)notification;
- (BOOL)getDataFromFileAtPath:(NSString *)path; - (BOOL) getDataFromFileAtPath: (NSString *)path;
- (void)setIdentifier:(NSString *)identifier; - (void) setIdentifier: (NSString *)identifier;
- (NSString *)identifier; - (NSString *) identifier;
- (float)samplingRate; - (float) samplingRate;
- (float)frameSize; - (float) frameSize;
- (long)frameCount; - (long) frameCount;
- (NSData *)data; - (NSData *) data;
@end @end
@implementation NSSound (PrivateMethods) @implementation NSSound (PrivateMethods)
#ifdef HAVE_AUDIOFILE_H #ifdef HAVE_AUDIOFILE_H
+ (id<GSSoundSvr>)gsnd + (id<GSSoundSvr>) gsnd
{ {
if (the_server == nil) if (the_server == nil)
{ {
@ -234,12 +234,12 @@ static id<GSSoundSvr> the_server = nil;
return the_server; return the_server;
} }
+ (void)localServer:(id<GSSoundSvr>)s + (void) localServer: (id<GSSoundSvr>)s
{ {
the_server = s; the_server = s;
} }
+ (id)lostServer:(NSNotification*)notification + (id) lostServer: (NSNotification*)notification
{ {
id obj = the_server; id obj = the_server;
@ -252,7 +252,7 @@ static id<GSSoundSvr> the_server = nil;
return self; return self;
} }
- (BOOL)getDataFromFileAtPath:(NSString *)path - (BOOL) getDataFromFileAtPath: (NSString *)path
{ {
AFfilehandle file; AFfilehandle file;
AFframecount framesRead; AFframecount framesRead;
@ -301,53 +301,53 @@ return NO; \
#else #else
/* No sound software */ /* No sound software */
+ (id<GSSoundSvr>)gsnd + (id<GSSoundSvr>) gsnd
{ {
return nil; return nil;
} }
+ (void)localServer:(id<GSSoundSvr>)s + (void) localServer: (id<GSSoundSvr>)s
{ {
} }
+ (id)lostServer:(NSNotification*)notification + (id) lostServer: (NSNotification*)notification
{ {
return self; return self;
} }
- (BOOL)getDataFromFileAtPath:(NSString *)path - (BOOL) getDataFromFileAtPath: (NSString *)path
{ {
NSLog(@"NSSound: No sound software installed, cannot get sound"); NSLog(@"NSSound: No sound software installed, cannot get sound");
return NO; return NO;
} }
#endif #endif
- (void)setIdentifier:(NSString *)identifier - (void) setIdentifier: (NSString *)identifier
{ {
ASSIGN (uniqueIdentifier, identifier); ASSIGN (uniqueIdentifier, identifier);
} }
- (NSString *)identifier - (NSString *) identifier
{ {
return uniqueIdentifier; return uniqueIdentifier;
} }
- (float)samplingRate - (float) samplingRate
{ {
return samplingRate; return samplingRate;
} }
- (float)frameSize - (float) frameSize
{ {
return frameSize; return frameSize;
} }
- (long)frameCount - (long) frameCount
{ {
return frameCount; return frameCount;
} }
- (NSData *)data - (NSData *) data
{ {
return data; return data;
} }
@ -356,7 +356,7 @@ return NO; \
@implementation NSSound @implementation NSSound
+ (void)initialize + (void) initialize
{ {
if (self == [NSSound class]) if (self == [NSSound class])
{ {
@ -383,7 +383,7 @@ return NO; \
} }
} }
- (void)dealloc - (void) dealloc
{ {
TEST_RELEASE (data); TEST_RELEASE (data);
if (name && self == [nameDict objectForKey: name]) if (name && self == [nameDict objectForKey: name])
@ -398,7 +398,7 @@ return NO; \
// //
// Creating an NSSound // Creating an NSSound
// //
- (id)initWithContentsOfFile:(NSString *)path byReference:(BOOL)byRef - (id) initWithContentsOfFile: (NSString *)path byReference:(BOOL)byRef
{ {
self = [super init]; self = [super init];
@ -417,19 +417,19 @@ return NO; \
return self; return self;
} }
- (id)initWithContentsOfURL:(NSURL *)url byReference:(BOOL)byRef - (id) initWithContentsOfURL: (NSURL *)url byReference:(BOOL)byRef
{ {
onlyReference = byRef; onlyReference = byRef;
return [self initWithData: [NSData dataWithContentsOfURL: url]]; return [self initWithData: [NSData dataWithContentsOfURL: url]];
} }
- (id)initWithData:(NSData *)data - (id) initWithData: (NSData *)data
{ {
[self notImplemented: _cmd]; [self notImplemented: _cmd];
return nil; return nil;
} }
- (id)initWithPasteboard:(NSPasteboard *)pasteboard - (id) initWithPasteboard: (NSPasteboard *)pasteboard
{ {
if ([NSSound canInitWithPasteboard: pasteboard] == YES) if ([NSSound canInitWithPasteboard: pasteboard] == YES)
{ {
@ -442,7 +442,7 @@ return NO; \
// //
// Playing // Playing
// //
- (BOOL)pause - (BOOL) pause
{ {
if (uniqueIdentifier) if (uniqueIdentifier)
{ {
@ -451,12 +451,12 @@ return NO; \
return NO; return NO;
} }
- (BOOL)play - (BOOL) play
{ {
return [[NSSound gsnd] playSound: self]; return [[NSSound gsnd] playSound: self];
} }
- (BOOL)resume - (BOOL) resume
{ {
if (uniqueIdentifier) if (uniqueIdentifier)
{ {
@ -465,7 +465,7 @@ return NO; \
return NO; return NO;
} }
- (BOOL)stop - (BOOL) stop
{ {
if (uniqueIdentifier) if (uniqueIdentifier)
{ {
@ -474,7 +474,7 @@ return NO; \
return NO; return NO;
} }
- (BOOL)isPlaying - (BOOL) isPlaying
{ {
if (uniqueIdentifier) if (uniqueIdentifier)
{ {
@ -486,7 +486,7 @@ return NO; \
// //
// Working with pasteboards // Working with pasteboards
// //
+ (BOOL)canInitWithPasteboard:(NSPasteboard *)pasteboard + (BOOL) canInitWithPasteboard: (NSPasteboard *)pasteboard
{ {
NSArray *pbTypes = [pasteboard types]; NSArray *pbTypes = [pasteboard types];
NSArray *myTypes = [NSSound soundUnfilteredPasteboardTypes]; NSArray *myTypes = [NSSound soundUnfilteredPasteboardTypes];
@ -494,12 +494,12 @@ return NO; \
return ([pbTypes firstObjectCommonWithArray: myTypes] != nil); return ([pbTypes firstObjectCommonWithArray: myTypes] != nil);
} }
+ (NSArray *)soundUnfilteredPasteboardTypes + (NSArray *) soundUnfilteredPasteboardTypes
{ {
return [NSArray arrayWithObjects: @"NSGeneralPboardType", nil]; return [NSArray arrayWithObjects: @"NSGeneralPboardType", nil];
} }
- (void)writeToPasteboard:(NSPasteboard *)pasteboard - (void) writeToPasteboard: (NSPasteboard *)pasteboard
{ {
NSData *d = [NSArchiver archivedDataWithRootObject: self]; NSData *d = [NSArchiver archivedDataWithRootObject: self];
@ -513,12 +513,12 @@ return NO; \
// //
// Working with delegates // Working with delegates
// //
- (id)delegate - (id) delegate
{ {
return delegate; return delegate;
} }
- (void)setDelegate:(id)aDelegate - (void) setDelegate: (id)aDelegate
{ {
delegate = aDelegate; delegate = aDelegate;
} }
@ -526,32 +526,32 @@ return NO; \
// //
// Naming Sounds // Naming Sounds
// //
+ (id)soundNamed:(NSString *)aName + (id) soundNamed: (NSString*)name
{ {
NSString *realName = [nsmapping objectForKey: aName]; NSString *realName = [nsmapping objectForKey: name];
NSSound *sound; NSSound *sound;
if (realName) if (realName)
{ {
aName = realName; name = realName;
} }
sound = (NSSound *)[nameDict objectForKey: aName]; sound = (NSSound *)[nameDict objectForKey: name];
if (sound == nil) if (sound == nil)
{ {
NSString *extension; NSString *extension;
NSString *path = nil; NSString *path = nil;
NSBundle *main_bundle; NSBundle *main_bundle;
NSArray *array; NSArray *array;
NSString *the_name = aName; NSString *the_name = name;
// FIXME: This should use [NSBundle pathForSoundResource], but this will // FIXME: This should use [NSBundle pathForSoundResource], but this will
// only allow soundUnfilteredFileTypes. // only allow soundUnfilteredFileTypes.
/* If there is no sound with that name, search in the main bundle */ /* If there is no sound with that name, search in the main bundle */
main_bundle = [NSBundle mainBundle]; main_bundle = [NSBundle mainBundle];
extension = [aName pathExtension]; extension = [name pathExtension];
if (extension != nil && [extension length] == 0) if (extension != nil && [extension length] == 0)
{ {
@ -565,14 +565,14 @@ return NO; \
{ {
/* Extension is one of the sound types /* Extension is one of the sound types
So remove from the name */ So remove from the name */
the_name = [aName stringByDeletingPathExtension]; the_name = [name stringByDeletingPathExtension];
} }
else else
{ {
/* Otherwise extension is not an sound type /* Otherwise extension is not an sound type
So leave it alone */ So leave it alone */
the_name = aName; the_name = name;
extension = nil; extension = nil;
} }
@ -655,7 +655,7 @@ return NO; \
if (sound != nil) if (sound != nil)
{ {
[sound setName: aName]; [sound setName: name];
RELEASE(sound); RELEASE(sound);
sound->onlyReference = YES; sound->onlyReference = YES;
} }
@ -667,17 +667,17 @@ return NO; \
return sound; return sound;
} }
+ (NSArray *)soundUnfilteredFileTypes + (NSArray *) soundUnfilteredFileTypes
{ {
return [NSArray arrayWithObjects: @"aiff", @"waw", @"snd", @"au", nil]; return [NSArray arrayWithObjects: @"aiff", @"waw", @"snd", @"au", nil];
} }
- (NSString *)name - (NSString *) name
{ {
return name; return name;
} }
- (BOOL)setName:(NSString *)aName - (BOOL) setName: (NSString *)aName
{ {
BOOL retained = NO; BOOL retained = NO;
@ -709,7 +709,7 @@ return NO; \
// //
// NSCoding // NSCoding
// //
- (void)encodeWithCoder:(NSCoder *)coder - (void) encodeWithCoder: (NSCoder *)coder
{ {
[coder encodeValueOfObjCType: @encode(BOOL) at: &onlyReference]; [coder encodeValueOfObjCType: @encode(BOOL) at: &onlyReference];
[coder encodeObject: name]; [coder encodeObject: name];
@ -736,7 +736,7 @@ return NO; \
[coder encodeObject: data]; [coder encodeObject: data];
} }
- (id)initWithCoder:(NSCoder*)decoder - (id) initWithCoder: (NSCoder*)decoder
{ {
[decoder decodeValueOfObjCType: @encode(BOOL) at: &onlyReference]; [decoder decodeValueOfObjCType: @encode(BOOL) at: &onlyReference];
@ -795,7 +795,7 @@ return NO; \
return self; return self;
} }
- (id)awakeAfterUsingCoder:(NSCoder *)coder - (id) awakeAfterUsingCoder: (NSCoder *)coder
{ {
return self; return self;
} }
@ -803,7 +803,7 @@ return NO; \
// //
// NSCopying // NSCopying
// //
- (id)copyWithZone:(NSZone *)zone - (id) copyWithZone: (NSZone *)zone
{ {
NSSound *newSound = (NSSound *)NSCopyObject(self, 0, zone); NSSound *newSound = (NSSound *)NSCopyObject(self, 0, zone);

View file

@ -85,9 +85,9 @@
return _increment; return _increment;
} }
- (void) setIncrement: (double)newIncrement - (void) setIncrement: (double)increment
{ {
_increment = newIncrement; _increment = increment;
} }

View file

@ -1141,42 +1141,41 @@ sizeAttributedString(NSAttributedString *str, NSString *allText, NSRange aRange)
} }
// GNUstep extensions. // GNUstep extensions.
- (NSSize) sizeRange: (NSRange) lineRange - (NSSize) sizeRange: (NSRange)aRange
{ {
return sizeAttributedString(self, [self string], lineRange); return sizeAttributedString(self, [self string], aRange);
} }
- (void) drawRange: (NSRange) lineRange atPoint: (NSPoint) point - (void) drawRange: (NSRange)aRange atPoint: (NSPoint)aPoint
{ {
NSGraphicsContext *ctxt = GSCurrentContext(); NSGraphicsContext *ctxt = GSCurrentContext();
drawAttributedString(self, [self string], lineRange, point, NO_R_MARGIN, drawAttributedString(self, [self string], aRange, aPoint, NO_R_MARGIN, ctxt);
ctxt);
} }
- (void) drawRange: (NSRange) lineRange inRect: (NSRect)rect - (void) drawRange: (NSRange)aRange inRect: (NSRect)aRect
{ {
NSPoint point; NSPoint point;
NSView *view = [NSView focusView]; NSView *view = [NSView focusView];
/* FIXME: This is an extremely lossy and temporary workaround for /* FIXME: This is an extremely lossy and temporary workaround for
the fact that we should draw only inside rect. */ the fact that we should draw only inside aRect. */
NSGraphicsContext *ctxt = GSCurrentContext(); NSGraphicsContext *ctxt = GSCurrentContext();
DPSgsave(ctxt); DPSgsave(ctxt);
NSRectClip (rect); NSRectClip (aRect);
/* /*
* Since [-drawAtPoint:] positions the top-left corner of the text at * Since [-drawAtPoint:] positions the top-left corner of the text at
* the point, we locate the top-left corner of the rectangle to do the * the point, we locate the top-left corner of the rectangle to do the
* drawing. * drawing.
*/ */
point.x = rect.origin.x; point.x = aRect.origin.x;
if ([view isFlipped]) if ([view isFlipped])
point.y = rect.origin.y; point.y = aRect.origin.y;
else else
point.y = rect.origin.y + rect.size.height; point.y = aRect.origin.y + aRect.size.height;
drawAttributedString(self, [self string], lineRange, point, rect.size.width, drawAttributedString(self, [self string], aRange, point, aRect.size.width,
ctxt); ctxt);
/* Restore matching the DPSgsave used in the temporary workaround */ /* Restore matching the DPSgsave used in the temporary workaround */
DPSgrestore(ctxt); DPSgrestore(ctxt);
@ -1230,7 +1229,7 @@ sizeAttributedString(NSAttributedString *str, NSString *allText, NSRange aRange)
} }
// GNUstep extensions. // GNUstep extensions.
- (NSSize) sizeRange: (NSRange) lineRange - (NSSize) sizeRange: (NSRange)lineRange
{ {
return sizeAttributedString(self, _textChars, lineRange); return sizeAttributedString(self, _textChars, lineRange);
} }