Skip navigation.
 
mlRe: NSScrollView
FROM : Jonathon Mah
DATE : Tue Apr 19 20:46:07 2005

On 20 Apr 2005, at 04:09, Brian O'Brien wrote:

> Yes.. I think this helps.. :)
> I just wanted to make sure I wasn't going down the wrong path.. (Which
> I've done in the past)
> Right Now I have an NSView with N by M (rows/cols) subviews...
> I want to be able to scroll around and see a portion of these N by M
> subviews...
> I guess its my responsability to manage the displaying of these image
> based on the slider positions.. Correct?


The image view doesn't have to know it's in a scroll view. It just has
to know how to display itself as it if it were being drawn alone (not
in a scroll view). NSScrollView will handle clipping the drawing to the
right size. Your view will receive messages like [imageView
displayInRect:aRect] (or something like that), tell it that it needs to
draw itself in a certain rectangle. When you first open your app, aRect
will be the entire visible rectangle (the bit shown in the scroll
view). As the user scrolls, aRect will be the small rectangles that are
uncovered as the user scrolls the document (the bits that are just
coming into view). These rectangles are, by the way, in your view's
coordinate system (so a rect with origin (0,0) is the far top-left of
your image view, _not_ the top-left of what's currently visible in the
scroll view). So your image view doesn't need to know about the scroll
bar positions or anything; it just needs to know how to draw itself for
a specific rectangle.

(You /could/ redraw then entire view when asked to draw a rectangle,
but that'd cause a lot of unnecessary drawing and be slow.)


Jonathon Mah
<email_removed>

Related mailsAuthorDate
mlNSScrollView Brian O'Brien Apr 19, 19:31
mlRe: NSScrollView Jonathon Mah Apr 19, 20:07
mlRe: NSScrollView Brian O'Brien Apr 19, 20:39
mlRe: NSScrollView Jonathon Mah Apr 19, 20:46
mlRe: NSScrollView Mark T Apr 20, 03:12