All pastes #193352 Raw Edit

Anonymous

public text v1 · immutable
·published 2006-10-06 20:09 UTC
rendered paste body
- (void)drawSign:(NSString*)s centeredIn:(NSRect)r withColor:(NSColor*)color
{
	// NSLog(@"Bounds in DrawSign: %@", NSStringFromRect(r));
	NSPoint stringOrigin;
	NSSize stringSize;
	NSMutableDictionary *attributes = [NSMutableDictionary new];
	
	[attributes setObject:[NSFont fontWithName:@"Helvetica" size:(r.size.height-20)]
								 forKey:NSFontAttributeName];
	[attributes setObject:color
								 forKey:NSForegroundColorAttributeName];
	
	stringSize = [s sizeWithAttributes:attributes];
	stringOrigin.x = r.origin.x + (r.size.width - stringSize.width)/2.0;
	stringOrigin.y = r.origin.y + (r.size.height - stringSize.height)/2.0;
	[s drawAtPoint:stringOrigin withAttributes:attributes];
	[attributes release];
	[s release];
}