Updated Danish translation
[dasher.git] / Src / MacOSX / ZippyStringImage.m
blobdf6f8f64184d1212e389606559122849e1127022
1 //
2 //  ZippyStringImage.m
3 //  RectAl
4 //
5 //  Created by Doug Dickinson on Sat May 24 2003.
6 //  Copyright (c) 2003 Doug Dickinson (dasher AT DressTheMonkey DOT plus DOT com). All rights reserved.
7 //
9 #import <AppKit/AppKit.h>
10 #import "ZippyStringImage.h"
13 @implementation ZippyStringImage
15 - (id)initWithString:(NSString *)aString attributes:(NSDictionary *)someAttributes {
16   if (self = [super initWithString:aString attributes:someAttributes]) {
17     NSSize s = [self size];
18     if ([aString length] == 1 && s.width != 0 && s.height != 0) {
19       NSImage *m = [[NSImage alloc] initWithSize:s];
20       [m setFlipped:YES];
21       [m lockFocus];
22       [self drawAtPoint:NSMakePoint(0, 0)];
23       [m unlockFocus];
24       [self setImage:m];
25       [m release];
26     }
27   }
29   return self;
32 - (void)drawAtPoint:(NSPoint)aPoint {
33   if ([self image] != nil) {
34     NSPoint at = NSMakePoint(aPoint.x, aPoint.y + [self size].height);
35     [[self image] compositeToPoint:at operation:NSCompositeSourceAtop];
36     return;
37   }
38   
39   [super drawAtPoint:aPoint];
43 - (NSImage *)image {
44   return [[_image retain] autorelease];
47 - (void)setImage:(NSImage *)value {
48   if (_image != value) {
49     [_image release];
50     _image = [value retain];
51   }
55 - (void)dealloc {
56   [_image release];
57   [super dealloc];
60 @end