Re: Dumb question: How does NSScrollView know the size of the thing it's scrolling?
Re: Dumb question: How does NSScrollView know the size of the thing it's scrolling?
- Subject: Re: Dumb question: How does NSScrollView know the size of the thing it's scrolling?
- From: Erik Buck <email@hidden>
- Date: Wed, 23 Jul 2008 11:49:27 -0700 (PDT)
As is the case with all NSViews, the frame of the view defines the area occupied by the view in its superview's coordinate system. The bounds of a view defines that view's own coordinate system irrespective of the frame. Therefore, if the frame size and bounds size for a particular view are different, that implies a scaling of the view's coordinate system. If the frame and bounds origins are different, that implies a translation of the view's coordinate system. Of course, a view can also use an arbitrary affine transform matrix to implement rotation, scale, translation, and skew to almost any extent.
In the case of a scrollview, the sliders are positioned and sized based on the frame of the enclosed clipview relative to the bounds of the scrollview. The clipview automatically increases its own frame to completely enclose the frame of the document view. You can do anything you want to the bounds of the document view without any effect on the clipview EXCEPT for the small fact that by default, setting the bounds of a view also resets the frame. I don't know why; that's probably convenient in some cases. I sometimes do the following to circumvent that:
NSRect oldFrame = [self frame];
[self setBounds:someRect]; // set a different bounds
[self setFrame:oldFrame]; // restore old frame so bounds and frame have different size
See http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/Coordinates/chapter_3_section_3.html#//apple_ref/doc/uid/TP40002978-CH10-SW9
http://developer.apple.com/documentation/Cocoa/Conceptual/NSScrollViewGuide/Articles/Introduction.html
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden