drawPageBorderWithSize: and scaled view
drawPageBorderWithSize: and scaled view
- Subject: drawPageBorderWithSize: and scaled view
- From: Allen Smith <email@hidden>
- Date: Thu, 16 Mar 2006 13:04:26 -0800
I have a view which is scaled down, and I am attempting to adorn its
printed output using -drawPageBorderWithSize:. When drawing my
adornments, I find the drawing is scaled by the same factor as the
view (which is good) but is being clipped by the unscaled size of the
page (which is really bad).
For example, if I set the view like this:
[view scaleUnitSquareToSize:NSMakeSize(0.5, 1.0)];
[view print:nil];
and the view has the following method defined in its class:
- (void)drawPageBorderWithSize:(NSSize)borderSize
{
NSRect originalFrame = [self frame];
[self setFrame:NSMakeRect(0,0, borderSize.width, borderSize.height)];
[self lockFocus];
[[NSColor redColor] set];
NSRectFill([self bounds]);
[self unlockFocus];
[self setFrame:originalFrame];
}
Then I have a red strip covering exactly half my page. However, I was
fully expecting that to paint my entire page red. After all, my view
is being scaled by altering the *bounds*, then I am setting the
*frame* to encompass the entire page.
I was doing fine under Panther, but the scaling and clipping has
obviously changed dramatically under Tiger. My current workaround in -
drawPageBorderWithSize: involves using NSAffineTransformation to
unscale the coordinate system, setting the frame, locking focus, then
using another affine transformation to rescale the coordinates. It's
ugly, but it allows me to draw scaled graphics on the full page area.
Is there a better way?
Allen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden