1// 2// PXCanvasPrintView.m 3// Pixen-XCode 4// 5// Created by Joe Osborn on Tue Jul 13 2004. 6// Copyright (c) 2004 Open Sword Group. All rights reserved. 7// 8 9#import "PXCanvasPrintView.h" 10#import "PXCanvas.h" 11 12@implementation PXCanvasPrintView 13 14 15+ viewForCanvas:aCanvas 16{ 17 return [[[self alloc] initWithCanvas:aCanvas] autorelease]; 18} 19 20- (id)initWithCanvas:aCanvas 21{ 22 [super initWithFrame:NSMakeRect(0, 0, [aCanvas size].width, [aCanvas size].height)]; 23 canvas = [aCanvas retain]; 24 return self; 25} 26 27- (void)dealloc 28{ 29 [canvas release]; 30 [super dealloc]; 31} 32 33- (void)drawRect:(NSRect)rect 34{ 35 //find and apply the proper transform for the paper size 36 float scale = [[[[[NSPrintOperation currentOperation] printInfo] dictionary] objectForKey:NSPrintScalingFactor] floatValue]; 37 id transform = [NSAffineTransform transform]; 38 [transform scaleXBy:scale yBy:scale]; 39 [transform concat]; 40 [canvas drawRect:rect fixBug:NO]; 41 [transform invert]; 42 [transform concat]; 43} 44 45@end 46