views:

75

answers:

1

I have an NSView in a ScrollView and I'm trying to draw an image in it. The problem is that I want the upper left corner of the image locked to the upper left corner of the frame, instead of the lower left corner, which is what the View wants me to do. I will need to be able to zoom in and out, and rotate.

currently, I have a kludge of a system where I calculate how much I have to translate my image based on the size of the image and the size of the window. In order to do this, I needed to create an extra view outside the scrollview, so that I could get the size of the window, not including decorations. Then I can calculate the size of the view based on the size of the image and the size of the window, and based on THAT, I can figure out where to translate the image to.

My only other thought was to use the isFlipped: method, but that ends up reversing my image L-R which is bad.

Is there another way I should be doing this?

+1  A: 

If you want 0,0 to be in the upper-left corner, then overriding -isFlipped to return YES is the way to go. It should not affect the coordinate systems of any subviews (I think!), but images drawn directly into the flipped view will appear upside-down unless you apply a transform to them.

View Programming Guide for Cocoa: View Geometry

zbrimhall
Yes, as I said this flips the image. Rotating by 180 deg doesn't help because then the image is reversed. and NSAffineTransform doesn't seem to have a "flip" transform.
Brian Postow
AH, scaling X by 1 and Y by -1 seems te be how you do a flip transform! exciting!
Brian Postow