VocalEasel/Sources/VLDocument.mm
Matthias Neeracher 2cd57a8869 Imported into SVN
2006-09-11 02:49:56 +00:00

112 lines
3.0 KiB
Plaintext

//
// MyDocument.m
// Vocalese
//
// Created by Matthias Neeracher on 12/17/05.
// Copyright __MyCompanyName__ 2005 . All rights reserved.
//
#import "VLDocument.h"
@implementation VLDocument
- (id)init
{
self = [super init];
if (self) {
// Add your subclass-specific initialization here.
// If an error occurs here, send a [self release] message and return nil.
song = new VLSong;
}
return self;
}
- (void) dealloc
{
delete song;
[super dealloc];
}
- (VLSong *) song
{
return song;
}
- (NSNumber *) songKey
{
const VLProperties & prop = song->fProperties.front();
return [NSNumber numberWithInt: (prop.fKey << 8) | (prop.fMode & 0xFF)];
}
- (void) setKey:(int)key transpose:(BOOL)transpose
{
VLProperties & prop = song->fProperties.front();
prop.fKey = key >> 8;
prop.fMode= key & 0xFF;
}
- (NSNumber *) songTime
{
const VLProperties & prop = song->fProperties.front();
return [NSNumber numberWithInt: (prop.fTime.fNum << 8) | prop.fTime.fDenom];
}
- (void) setTimeNum:(int)num denom:(int)denom
{
VLProperties & prop = song->fProperties.front();
prop.fTime = VLFraction(num, denom);
}
- (NSNumber *) songDivisions
{
const VLProperties & prop = song->fProperties.front();
return [NSNumber numberWithInt: prop.fDivisions];
}
- (void) setDivisions:(int)divisions
{
VLProperties & prop = song->fProperties.front();
prop.fDivisions = divisions;
}
- (NSString *)windowNibName
{
// Override returning the nib file name of the document
// If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
return @"VLDocument";
}
- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
[super windowControllerDidLoadNib:aController];
// Add any code here that needs to be executed once the windowController has loaded the document's window.
}
- (NSData *)dataRepresentationOfType:(NSString *)aType
{
// Insert code here to write your document from the given data. You can also choose to override -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead.
// For applications targeted for Tiger or later systems, you should use the new Tiger API -dataOfType:error:. In this case you can also choose to override -writeToURL:ofType:error:, -fileWrapperOfType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead.
return nil;
}
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
{
// Insert code here to read your document from the given data. You can also choose to override -loadFileWrapperRepresentation:ofType: or -readFromFile:ofType: instead.
// For applications targeted for Tiger or later systems, you should use the new Tiger API readFromData:ofType:error:. In this case you can also choose to override -readFromURL:ofType:error: or -readFromFileWrapper:ofType:error: instead.
return YES;
}
@end