On Aug 20, 2010, at 06:46, Brian Postow wrote:

> If I don't want to be using NSImageView, what DO I want to be using? I 
> started out trying to use IKImageView, but that is  swatting a fly with a 
> bazooka. It takes like 2 seconds to draw the image because its doing lots of 
> thumbnailing and stuff that I don't need... is there another kind of 
> imageview I should use?

Given a scroll view architecture, your document view can be a single view, or 
the parent of an entire sub-hierarchy of views (Kyle's suggestion). 

If you're going to use a sub-hierarchy, then using a NSImageView within it is 
fine and probably convenient. (It doesn't do anything that you can't do 
yourself in a couple of lines of code, but a saving is a saving.)

If you're going to use a single view, then you'd use a custom NSView, and draw 
all of the pieces in the right order within its 'drawRect:'. The part of the 
view that's occupied by the image would be drawn with [NSImage drawInRect...], 
for example. You *could* make your custom view a subclass of NSImageView, but 
in this case there's no point that I can see.

Unlike IKImageView, NSImageView doesn't encapsulate a lot of behavior. 
(Offhand, all I can think of is: scaling, optionally drawing a border, and 
drawing a background when there's no image.) It's *mostly* a convenience for 
adding images to XIBs in IB without having to write any code, but with your 
scaling requirements you're already committed to writing UI glue code. So I'm 
suggesting you shouldn't feel obliged to use NSImageView at all, unless it 
genuinely saves you some effort.

> Ok,. Since the NSImageView wants to always center the image in the bounds 
> rect, that should make the translation (moving the origin) not too hard, yes?

Yes, though I'd say it differently. What's important is the size of the 
document view, and where its frame is positioned within the bounds rect of the 
content (clip) view. That's because zooming has an impact on the limits and 
scroll position of the scroll bars.


_______________________________________________

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