• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Dumb question: How does NSScrollView know the size of the thing it's scrolling?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Dumb question: How does NSScrollView know the size of the thing it's scrolling?
      • From: Rick Mann <email@hidden>
  • Prev by Date: Re: Dumb question: How does NSScrollView know the size of the thing it's scrolling?
  • Next by Date: Re: master-detail: binding array controller to the attribute of selection of master array controller
  • Previous by thread: Re: Dumb question: How does NSScrollView know the size of the thing it's scrolling?
  • Next by thread: Re: Dumb question: How does NSScrollView know the size of the thing it's scrolling?
  • Index(es):
    • Date
    • Thread