Class

NSClipView

An object that clips a document view to a scroll view's frame.

Declaration

@interface NSClipView : NSView

Overview

An NSClipView holds the document view of an NSScrollView, clipping the document view to its frame, handling the details of scrolling in an efficient manner, and updating the NSScrollView when the document view’s size or position changes.

You don’t typically use the NSClipView class directly; it’s provided primarily as the scrolling machinery for the NSScrollView class. However, you might use the NSClipView class to implement a class similar to NSScrollView.

Interaction with NSScrollView

When using an NSClipView within an NSScrollView (the usual configuration), you should access the NSScrollView properties that control background drawing state, rather than accessing these properties of the NSClipView. This recommendation applies to the following properties:

The NSClipView methods are intended for when the NSClipView is used independently of a containing NSScrollView. In the usual case, NSScrollView should be allowed to manage the background-drawing properties of its associated NSClipView.

There is only one background-drawing state per NSScrollView/NSClipView pair. The two objects do not maintain independent and distinct drawsBackground and backgroundColor properties; rather, the accessors for these properties on NSScrollView largely defer to the associated NSClipView and allow the NSClipView to maintain the state. Note that this state is not cached by the NSScrollView object.

It is also important to note that setting drawsBackground to NO in an NSScrollView has the added effect of setting the NSClipView property copiesOnScroll to NO. The side effect of setting the drawsBackground property directly to the NSClipView is the appearance of “trails” (vestiges of previous drawing) in the document view as it is scrolled.

Topics

Setting the Document View

documentView

The clip view’s document view.

Scrolling

- scrollToPoint:

Changes the origin of the clip view’s bounds rectangle to newOrigin.

- autoscroll:

Scrolls the clip view proportionally to theEvent’s distance outside of it.

- constrainScrollPoint:

Returns a scroll point adjusted from the proposed new origin, if necessary, to guarantee the view will lie within its document view.

Deprecated
- constrainBoundsRect:

Constrains the bounds of the clip view while the user is magnifying and scrolling.

Determining Scrolling Efficiency

copiesOnScroll

A Boolean value that indicates if the clip view copies rendered images while scrolling.

Deprecated

Accessing the Content Insets

contentInsets

The distance that the content view is inset from the enclosing scroll view.

automaticallyAdjustsContentInsets

A Boolean value that indicates if the clip view automatically accounts for other scroll view subviews.

Accessing the Visible Portion

documentRect

The rectangle defining the document view’s frame, adjusted to the size of the clip view if the document view is smaller.

documentVisibleRect

The exposed rectangle of the clip view’s document view, in the document view’s own coordinate system.

Setting the Document Cursor

documentCursor

The cursor object used when the pointer lies over the view.

Working with Background Color

drawsBackground

A Boolean value that indicates if the clip view draws its background color.

backgroundColor

The color of the clip view’s background.

Overriding NSView Methods

- viewBoundsChanged:

Handles an NSViewBoundsDidChangeNotification, passed in the aNotification argument, by updating a containing NSScrollView based on the new bounds.

- viewFrameChanged:

Handles an NSViewFrameDidChangeNotification, passed in the aNotification argument, by updating a containing NSScrollView based on the new frame.

Relationships

Inherits From

See Also

Views

NSScrollView

A view that displays a portion of a document view and provides scroll bars that allow the user to move the document view within the scroll view.

NSScroller

An object that controls scrolling of a document view within a scroll view or other type of container view.