Re: NSCell drawing flipped ?
Re: NSCell drawing flipped ?
- Subject: Re: NSCell drawing flipped ?
- From: Andrew Platzer <email@hidden>
- Date: Tue, 15 May 2001 11:40:50 -0700
On Tuesday, May 15, 2001, at 06:45 , Stiphane Sudre wrote:
I'm getting a funny result by doing this: the image is drawn flipped
(vertically).
Yet when I'm using this same code on a Subclass of a NSView, the image
is correctly drawn.
To get a non flipped rendering, I need to call:
if ([tImage isFlipped]==NO) {
[tImage setFlipped:YES];
}
Strange, uh ?
Important information: I'm using this cell in a NSTableView containing
NSTextField Cell and NSImageCell too.
If the view is flipped, then -[NSImage drawAtPoint:] will draw the image
upside down. If you don't want to do anything strange, use
compositeToPoint: instead. That method always draws the image right side
up regardless of the current transform for old Display PostScript
compatibility. You will have to transform the origin though:
[tImage compositeToPoint:NSMakePoint(cellFrame.origin.x,
cellFrame.origin.y
+ (cellFrame.size.height - CELL_ICON_HEIGHT) * 0.5
+ ([view isFlipped] ? CELL_ICON_HEIGHT : 0))
operation:NSCompositeSourceOver];
Using setFlipped: is fine or you could use NSAffineTransform to adjust
the coordinate system right side up again before drawing.
Andrew
________________________________________________________________
A n d r e w P l a t z e r
A p p l i c a t i o n F r a m e w o r k s
A p p l e