• 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
Re: NSCell drawing flipped ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSCell drawing flipped ? (From: Stéphane Sudre <email@hidden>)

  • Prev by Date: Re: Type/Creator Codes
  • Next by Date: Re: cmd-delete for menu doesn't work
  • Previous by thread: NSCell drawing flipped ?
  • Next by thread: Is there a way to Creating a Control Panel App using Cocoa
  • Index(es):
    • Date
    • Thread