• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
drawPageBorderWithSize: and scaled view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Custom key bindings at runtime
  • Next by Date: Cocoa Developer Wanted Sydney Australia
  • Previous by thread: Re: saving jpegs
  • Next by thread: Cocoa Developer Wanted Sydney Australia
  • Index(es):
    • Date
    • Thread