On Aug 19, 2010, at 12:44, Brian Postow wrote:

> ah, so, the way to zoom is to leave the NSImageView on 
> NSImageScaleProportionallyUpOrDown, and then change the size of the frame! 
> That gives me scrollbars!

I had to go out for a while before finishing my last post, but I wanted to 
point out that you likely *don't* want to be using NSImageView at all for this. 
The problem is that you seem to want to be doing additional drawing (you 
mentioned selection rectangles) earlier, but consider that you almost certainly 
don't want such drawing to be scaled along with the image. There are 3 ways to 
deal with this:

1. Compensate for the image scale by drawing such widgetry with the reverse 
scale. This sort of works (up to the limits of floating point resolution), but 
is rather an ugly approach.

2. Draw the widgetry in a sibling view above the image view. This isn't 
actually supported fully prior to 10.6.

3. Draw the image scaled, not the image view. That is, use a custom view that 
draws the image with drawInRect... using suitably sized source and destination 
rectangles to get the correct scale. The non-image parts of the view are drawn 
independently of the scale. I'd suggest this is the only really rational 
approach.

If you're never going to have to draw anything on top of the image, then 
NSImageView is fine.

> I think I now need to add some translation when I zoom so that my image 
> doesn't migrate off the upper right of the screen... Is that the standard way 
> of doing that?

The position of the document view relative to the clip view is determined by 
the relationship of the document view frame to the bounds origin of the content 
view. (Keep in mind that both are in the same coordinate system.) The easiest 
way is to set the document view frame origin with a suitable offset. (The 
amount of the offset is usually easy to calculate. I always figure out the sign 
-- direction -- of the offset by trial and error, but I always get it exactly 
wrong when trying to figure it out in advance.)


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to