tagging release
[dasher.git] / trunk / Src / MacOSX / TextDocument.m
blob5ae7d22f1d38a066c154d531bb83ea6b07b2cdcb
1 //
2 //  TextDocument.m
3 //
4 //  Created by Doug Dickinson on Sun Jun 01 2003.
5 //  Copyright (c) 2003 Doug Dickinson (dasher@DressTheMonkey.plus.com). All rights reserved.
6 //
8 #import "TextDocument.h"
9 #import "PreferencesController.h"
11 @implementation TextDocument
13 - (id)init
15   self = [super init];
16   if (self) {
17   }
18   return self;
21 - (NSString *)windowNibName
23   return @"TextDocument";
26 - (void)windowControllerDidLoadNib:(NSWindowController *) aController
28   NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
29   [super windowControllerDidLoadNib:aController];
30   [textUI setFont:[NSFont fontWithName:[defaults stringForKey:EDIT_FONT] size:(float)[defaults integerForKey:EDIT_FONT_SIZE]]];
31   [textUI setString:[[[NSString alloc] initWithData:[self fileContents] encoding:NSMacOSRomanStringEncoding] autorelease]];
32   [self setFileContents:nil];
35 - (NSData *)dataRepresentationOfType:(NSString *)aType
37   return [[textUI string] dataUsingEncoding:NSMacOSRomanStringEncoding];
40 - (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
42   [self setFileContents:data];
43   return YES;
46 - (NSData *)fileContents {
47   return _fileContents;
50 - (void)setFileContents:(NSData *)newFileContents {
51   if (_fileContents != newFileContents) {
52     NSData *oldValue = _fileContents;
53     _fileContents = [newFileContents retain];
54     [oldValue release];
55   }
58 - (NSTextView *)textUI
60   return textUI;
63 - (void)dealloc
65   [_fileContents release];
66   [super dealloc];
69 @end