On Aug 18, 2010, at 7:07 PM, Quincey Morris wrote:

> On Aug 18, 2010, at 15:01, Brian Postow wrote:
> 
>> The two things that IKImageView gave me that I'm having trouble making 
>> NSImageView do a similar thing are 1) zooming and 2) the mouse-tools.
>> 
>> 1) I can see how to use scaleUnitSquareToSize to zoom, but that doesn't tell 
>> me the CURRENT zoom, so that if I want to, say zoom into 1-1 mode (one image 
>> pixel = one screen pixel assuming 72DPI screen) or I want to know how zoomed 
>> in I currently am, I can't seem to figure this out...
> 
> You'll likely do much better to track the current *desired* display scale, 
> and make the image conform to that, rather than vice versa. Even if you want 
> to have a "zoom to fit" function or mode, there's still a desired display 
> factor derived from the ratio of the size of the image vs the size of the 
> space you have to display it in.
> 

so, are you suggesting that I manually control the "zoom-to-fit"  
functionality, and change the size of the image as the window changes size 
myself so I can keep track of the "desired display scale"? or is there some 
other way of getting that?

>> 2) I don't see how to change the mouse cursor, or make a select box, or 
>> implement the grab tool... can someone point me at some sample code for this?
> 
> For changing the mouse cursor, NSTrackingArea/cursorUpdate: is the best bet. 
> Selection boxes are just a matter of drawing in a view placed above your 
> image view OR (probably simpler once you get into this) not using NSImageView 
> at all, but a custom view that's responsible for drawing both the image and 
> the selection box. Or possibly you can use CALayers, but the custom view is 
> probably easier for this.
> 
> The grabber tool is harder, because you need to implement autoscroll, which 
> turns out to be a lot kinkier than it seems like it ought to be.
> 

I was afraid of that

>> Also, and this WASN'T easy on IKImageView, but with a lot of help, I got it 
>> to work, but is there a trick to getting the scrollView to function? 
>> Currently, I zoom in, and it doesn't make the scroll bars appear.
>> 
>> I made the view by creating an NSScrollView, and then changing the content 
>> view of the scrollview to be NSImageView... 
> 
> If you really did that, don't. The actual "content" of the scroll view is its 
> document view, not its content view. The content view is the view that clips 
> the document view, and you shouldn't mess with that unnecessarily.
> 

So, the content view should go INSIDE the document view? I should have 3 views? 
a scrollview, a document view and an NSImageView?


Brian Postow
Senior Software Engineer
Acordex Imaging Systems

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to