Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/AppKit.framework |
Availability | Available in Mac OS X v10.0 and later. |
Declared in | NSClipView.h NSMenuItem.h NSView.h |
Companion guides | |
Related sample code |
NSView
is a class that defines the basic drawing, event-handling, and printing architecture of an application. You typically don’t interact with the NSView
API directly; rather, your custom view classes inherit from NSView
and override many of its methods, which are invoked automatically by the Application Kit. If you’re not creating a custom view class, there are few methods you need to use.
Event handling
Integrated display to screen and printer
Flexible coordinate systems
Icon dragging
frame
Returns the location and size of the NSView
object.
bounds
Returns the internal origin and size of the NSView
object.
setNeedsDisplay:
Marks the NSView
object as needing to be redrawn
window
Returns the NSWindow
object that contains the NSView
object.
drawRect:
Draws the NSView
object. (All subclasses must implement this method, but it’s rarely invoked explicitly.)
The NSView
class that provides a structure for drawing, printing, and handling events.
NSView
objects (also know, simply, as view objects or views) are arranged within an NSWindow
object, in a nested hierarchy of subviews. A view object claims a rectangular region of its enclosing superview, is responsible for all drawing within that region, and is eligible to receive mouse events occurring in it as well. In addition to these major responsibilities, NSView
handles dragging of icons and works with the NSScrollView
class to support efficient scrolling.
Most of the functionality of NSView
either is automatically invoked by the Application Kit, or is available in Interface Builder. Unless you’re implementing a concrete subclass of NSView
or working intimately with the content of the view hierarchy at runtime, you don’t need to know much about this class’s interface. See “Commonly Used Methods” for methods you might use regardless.
For more information on how NSView
instances handle event and action messages, see Handling Events in Views, Handling Mouse Events in Views, and Handling Tracking-Rectangle and Cursor-Update Events in Views. For more information on displaying tooltips and contextual menus, see How Contextual Menus Work and Tooltips.
NSView
is perhaps the most important class in the Application Kit when it comes to subclassing and inheritance. Most user-interface objects you see in a Cocoa application are objects that inherit from NSView
. If you want to create an object that draws itself in a special way, or that responds to mouse clicks in a special way, you would create a custom subclass of NSView
(or of a class that inherits from NSView
). Subclassing NSView
is such a common and important procedure that several technical documents describe how to both draw in custom subclasses and respond to events in custom subclasses. See Cocoa Drawing Guide and Cocoa Event-Handling Guide (especially "Handling Events in Views" and "Handling Mouse Events in Views").
– superview
– setSubviews:
– subviews
– window
– addSubview:
– addSubview:positioned:relativeTo:
– didAddSubview:
– removeFromSuperview
– removeFromSuperviewWithoutNeedingDisplay
– replaceSubview:with:
– isDescendantOf:
– opaqueAncestor
– ancestorSharedWithView:
– sortSubviewsUsingFunction:context:
– viewDidMoveToSuperview
– viewDidMoveToWindow
– viewWillMoveToSuperview:
– viewWillMoveToWindow:
– willRemoveSubview:
– enclosingMenuItem
– convertPointToBase:
– convertPointFromBase:
– convertSizeToBase:
– convertSizeFromBase:
– convertRectToBase:
– convertRectFromBase:
– convertPoint:fromView:
– convertPoint:toView:
– convertSize:fromView:
– convertSize:toView:
– convertRect:fromView:
– convertRect:toView:
– centerScanRect:
– setPostsFrameChangedNotifications:
– postsFrameChangedNotifications
– setPostsBoundsChangedNotifications:
– postsBoundsChangedNotifications
– resizeSubviewsWithOldSize:
– resizeWithOldSuperviewSize:
– setAutoresizesSubviews:
– autoresizesSubviews
– setAutoresizingMask:
– autoresizingMask
– setNeedsDisplay:
– setNeedsDisplayInRect:
– needsDisplay
– display
– displayRect:
– displayRectIgnoringOpacity:
– displayRectIgnoringOpacity:inContext:
– displayIfNeeded
– displayIfNeededInRect:
– displayIfNeededIgnoringOpacity
– displayIfNeededInRectIgnoringOpacity:
– translateRectsNeedingDisplayInRect:by:
– isOpaque
– viewWillDraw
– setKeyboardFocusRingNeedsDisplayInRect:
+ defaultFocusRingType
– setFocusRingType:
– focusRingType
– drawRect:
– visibleRect
– canDraw
– shouldDrawColor
– getRectsBeingDrawn:count:
– needsToDrawRect:
– wantsDefaultClipping
– bitmapImageRepForCachingDisplayInRect:
– cacheDisplayInRect:toBitmapImageRep:
– inLiveResize
– preservesContentDuringLiveResize
– getRectsExposedDuringLiveResize:count:
– rectPreservedDuringLiveResize
– viewWillStartLiveResize
– viewDidEndLiveResize
– acceptsFirstMouse:
– hitTest:
– mouse:inRect:
– performKeyEquivalent:
– performMnemonic:
– mouseDownCanMoveWindow
– dragImage:at:offset:event:pasteboard:source:slideBack:
– dragFile:fromRect:slideBack:event:
– registerForDraggedTypes:
– registeredDraggedTypes
– unregisterDraggedTypes
– shouldDelayWindowOrderingForEvent:
– dragPromisedFilesOfTypes:fromRect:source:slideBack:event:
– scrollPoint:
– scrollRectToVisible:
– autoscroll:
– adjustScroll:
– scrollRect:by:
– enclosingScrollView
– scrollClipView:toPoint:
– reflectScrolledClipView:
– canBecomeKeyView
– needsPanelToBecomeKey
– setNextKeyView:
– nextKeyView
– nextValidKeyView
– previousKeyView
– previousValidKeyView
– print:
– beginPageInRect:atPlacement:
– dataWithEPSInsideRect:
– dataWithPDFInsideRect:
– printJobTitle
– pageFooter
– pageHeader
– writeEPSInsideRect:toPasteboard:
– writePDFInsideRect:toPasteboard:
– drawPageBorderWithSize:
– drawSheetBorderWithSize:
– heightAdjustLimit
– widthAdjustLimit
– adjustPageWidthNew:left:right:limit:
– adjustPageHeightNew:top:bottom:limit:
– knowsPageRange:
– rectForPage:
– locationOfPrintRect:
– setFrameCenterRotation:
– frameCenterRotation
– setAlphaValue:
– alphaValue
– setBackgroundFilters:
– backgroundFilters
– setCompositingFilter:
– compositingFilter
– setContentFilters:
– contentFilters
– setShadow:
– shadow
Returns the default focus ring type.
+ (NSFocusRingType)defaultFocusRingType
The default type of focus ring for objects of the receiver’s class. Possible return values are listed in NSFocusRingType
.
If NSFocusRingTypeDefault
is returned from the instance method focusRingType
, the receiver can invoke this class method to find out what type of focus ring is the default. The receiver is free to ignore the default setting.
NSView.h
Overridden by subclasses to return the default pop-up menu for instances of the receiving class.
+ (NSMenu *)defaultMenu
The default implementation returns nil
.
– menuForEvent:
– menu
(NSResponder
)NSView.h
Returns the currently focused NSView
object, or nil
if there is none.
+ (NSView *)focusView
NSView.h
Overridden by subclasses to return YES
if the receiver should be sent a mouseDown:
message for an initial mouse-down event, NO
if not.
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
The initial mouse-down event, which must be over the receiver in its window.
The receiver can either return a value unconditionally or use the location of theEvent to determine whether or not it wants the event. The default implementation ignores theEvent and returns NO
.
Override this method in a subclass to allow instances to respond to click-through. This allows the user to click on a view in an inactive window, activating the view with one click, instead of clicking first to make the window active and then clicking the view. Most view objects refuse a click-through attempt, so the event simply activates the window. Many control objects, however, such as instances of NSButton
and NSSlider
, do accept them, so the user can immediately manipulate the control without having to release the mouse button.
NSView.h
Establishes the cursor to be used when the mouse pointer lies within a specified region.
- (void)addCursorRect:(NSRect)aRect cursor:(NSCursor *)aCursor
A rectangle defining a region of the receiver.
An object representing a cursor.
Cursor rectangles aren’t subject to clipping by superviews, nor are they intended for use with rotated views. You should explicitly confine a cursor rectangle to the view's visible rectangle to prevent improper behavior.
This method is intended to be invoked only by the resetCursorRects
method. If invoked in any other way, the resulting cursor rectangle will be discarded the next time the view's cursor rectangles are rebuilt.
NSView.h
Adds a view to the receiver’s subviews so it’s displayed above its siblings.
- (void)addSubview:(NSView *)aView
The view to add to the receiver as a subview.
This method also sets the receiver as the next responder of aView.
The receiver retains aView. If you use removeFromSuperview
to remove aView from the view hierarchy, aView is released. If you want to keep using aView after removing it from the view hierarchy (if, for example, you are swapping through a number of views), you must retain it before invoking removeFromSuperview
.
– addSubview:positioned:relativeTo:
– subviews
– removeFromSuperview
– setNextResponder:
(NSResponder)– viewWillMoveToSuperview:
– viewWillMoveToWindow:
NSView.h
Inserts a view among the receiver’s subviews so it’s displayed immediately above or below another view.
- (void)addSubview:(NSView *)aView positioned:(NSWindowOrderingMode)place relativeTo:(NSView *)otherView
The view object to add to the receiver as a subview.
An enum
constant specifying the position of the aView
relative to otherView
. Valid values are NSWindowAbove
or NSWindowBelow
.
The other view aView
is to be positioned relative to. If otherView is nil
(or isn’t a subview of the receiver), aView is added above or below all of its new siblings.
This method also sets the receiver as the next responder of aView.
The receiver retains aView. If you use removeFromSuperview
to remove aView from the view hierarchy, aView is released. If you want to keep using aView after removing it from the view hierarchy (if, for example, you are swapping through a number of views), you must retain it before invoking removeFromSuperview
.
– addSubview:
– subviews
– removeFromSuperview
– setNextResponder:
(NSResponder
)NSView.h
Creates a tool tip for a defined area the receiver and returns a tag that identifies the tool tip rectangle.
- (NSToolTipTag)addToolTipRect:(NSRect)aRect owner:(id)anObject userData:(void *)userData
A rectangle defining the region of the receiver to associate the tool tip with.
An object from which to obtain the tool tip string. The object should either implement view:stringForToolTip:point:userData:
, or return a suitable string from its description
method. (It can therefore simply be an NSString
object.)
Any additional information you want to pass to view:stringForToolTip:point:userData:
; it is not used if anObject does not implement this method.
An integer tag identifying the tool tip; you can use this tag to remove the tool tip.
The tool tip string is obtained dynamically from anObject by invoking either the NSToolTipOwner
informal protocol method view:stringForToolTip:point:userData:
, if implemented, or the NSObject
protocol method description
.
NSView.h
Adds a given tracking area to the receiver.
- (void)addTrackingArea:(NSTrackingArea *)trackingArea
The tracking area to add to the receiver.
NSView.h
Establishes an area for tracking mouse-entered and mouse-exited events within the receiver and returns a tag that identifies the tracking rectangle.
- (NSTrackingRectTag)addTrackingRect:(NSRect)aRect owner:(id)userObject userData:(void *)userData assumeInside:(BOOL)flag
A rectangle that defines a region of the receiver for tracking mouse-entered and mouse-exited events.
The object that gets sent the event messages. It can be the receiver itself or some other object (such as an NSCursor or a custom drawing tool object), as long as it responds to both mouseEntered:
and mouseExited:
.
Data stored in the NSEvent
object for each tracking event.
If YES
, the first event will be generated when the cursor leaves aRect, regardless if the cursor is inside aRect when the tracking rectangle is added. If NO
the first event will be generated when the cursor leaves aRect if the cursor is initially inside aRect, or when the cursor enters aRect if the cursor is initially outside aRect. You usually want to set this flag to NO
.
A tag that identifies the tracking rectangle. It is stored in the associated NSEvent
objects and can be used to remove the tracking rectangle.
Tracking rectangles provide a general mechanism that can be used to trigger actions based on the cursor location (for example, a status bar or hint field that provides information on the item the cursor lies over). To simply change the cursor over a particular area, use addCursorRect:cursor:
. If you must use tracking rectangles to change the cursor, the NSCursor
class specification describes the additional methods that must be invoked to change cursors by using tracking rectangles.
On Mac OS X v10.5 and later, tracking areas provide a greater range of functionality (see addTrackingArea:
).
NSView.h
Overridden by subclasses to adjust page height during automatic pagination.
- (void)adjustPageHeightNew:(CGFloat *)newBottom top:(CGFloat)top bottom:(CGFloat)proposedBottom limit:(CGFloat)bottomLimit
Returns by indirection a new float
value for the bottom edge of the pending page rectangle in the receiver's coordinate system.
A float
value that sets the top edge of the pending page rectangle in the receiver’s coordinate system.
A float
value that sets the bottom edge of the pending page rectangle in the receiver’s coordinate system.
The topmost float value newBottom can be set to, as calculated using the return value of heightAdjustLimit
.
This method is invoked by print:
. The receiver can raise the bottom edge and return the new value in newBottom, allowing it to prevent items such as lines of text from being divided across pages. If bottomLimit is exceeded, the pagination mechanism simply uses bottomLimit for the bottom edge.
The default implementation of this method propagates the message to its subviews, allowing nested views to adjust page height for their drawing as well. An NSButton
object or other small view, for example, will nudge the bottom edge up if necessary to prevent itself from being cut in two (thereby pushing it onto an adjacent page). Subclasses should invoke super
’s implementation, if desired, after first making their own adjustments.
NSView.h
Overridden by subclasses to adjust page width during automatic pagination.
- (void)adjustPageWidthNew:(CGFloat *)newRight left:(CGFloat)left right:(CGFloat)proposedRight limit:(CGFloat)rightLimit
Returns by indirection a new float
value for the right edge of the pending page rectangle in the receiver's coordinate system.
A float
value that sets the left edge of the pending page rectangle in the receiver’s coordinate system.
A float
value that sets the right edge of the pending page rectangle in the receiver’s coordinate system.
The leftmost float
value newRight can be set to, as calculated using the return value of widthAdjustLimit
.
This method is invoked by print:
. The receiver can pull in the right edge and return the new value in newRight, allowing it to prevent items such as small images or text columns from being divided across pages. If rightLimit is exceeded, the pagination mechanism simply uses rightLimit for the right edge.
The default implementation of this method propagates the message to its subviews, allowing nested views to adjust page width for their drawing as well. An NSButton
object or other small view, for example, will nudge the right edge out if necessary to prevent itself from being cut in two (thereby pushing it onto an adjacent page). Subclasses should invoke super
’s implementation, if desired, after first making their own adjustments.
NSView.h
Overridden by subclasses to modify a given rectangle, returning the altered rectangle.
- (NSRect)adjustScroll:(NSRect)proposedVisibleRect
A rectangle defining a region of the receiver.
NSClipView
invokes this method to allow its document view to adjust its position during scrolling. For example, a custom view object that displays a table of data can adjust the origin of proposedVisibleRect so rows or columns aren’t cut off by the edge of the enclosing NSClipView
. NSView
’s implementation simply returns proposedVisibleRect.
NSClipView
only invokes this method during automatic or user controlled scrolling. Its scrollToPoint:
method doesn’t invoke this method, so you can still force a scroll to an arbitrary point.
NSView.h
Causes the receiver to maintain a private graphics state object, which encapsulates all parameters of the graphics environment.
- (void)allocateGState
If you do not invoke allocateGState
, a graphics state object is constructed from scratch each time the NSView is focused.
The receiver builds the graphics state parameters using setUpGState
, then automatically establishes this graphics state each time the focus is locked on it. A graphics state may improve performance for view objects that are focused often and need to set many parameters, but use of standard rendering operators is normally efficient enough.
Because graphics states occupy a fair amount of memory, they can actually degrade performance. Be sure to test application performance with and without the private graphics state before committing to its use.
NSView.h
Returns the opacity of the receiver
- (CGFloat)alphaValue
The current opacity of the receiver
This method returns the value of the opacity
property of the receiver’s layer. Possible values are between 0.0 (transparent) and 1.0 (opaque). The default is 1.0.
Sending this message to a view that is not managing a Core Animation layer causes an exception.
NSView.h
Returns the closest ancestor shared by the receiver and a given view.
- (NSView *)ancestorSharedWithView:(NSView *)aView
The view to test (along with the receiver) for closest shared ancestor.
The closest ancestor or nil
if there’s no such object. Returns self
if aView is identical to the receiver.
NSView.h
Returns YES
if the receiver automatically resizes its subviews using resizeSubviewsWithOldSize:
whenever its frame size changes, NO
otherwise.
- (BOOL)autoresizesSubviews
NSView.h
Returns the receiver’s autoresizing mask, which determines how it’s resized by the resizeWithOldSuperviewSize:
method.
- (NSUInteger)autoresizingMask
An integer bit mask specified by combining using the C bitwise OR operator any of the options described in “Resizing masks”
.
If the autoresizing mask is equal to NSViewNotSizable
(that is, if none of the options are set), then the receiver doesn’t resize at all in resizeWithOldSuperviewSize:
.
NSView.h
Scrolls the receiver’s closest ancestor NSClipView
object proportionally to the distance of an event that occurs outside of it.
- (BOOL)autoscroll:(NSEvent *)theEvent
An event object whose location should be expressed in the window’s base coordinate system (which it normally is), not the receiving view's.
Returns YES
if any scrolling is performed; otherwise returns NO
.
View objects that track mouse-dragged events can use this method to scroll automatically when the cursor is dragged outside of the NSClipView
object. Repeated invocations of this method (with an appropriate delay) result in continual scrolling, even when the mouse doesn’t move.
– autoscroll:
(NSClipView)– scrollPoint:
– isDescendantOf:
NSView.h
Returns the array of CoreImage filters that are applied to the receiver’s background
- (NSArray *)backgroundFilters
An array of CoreImage filters.
This method returns the value of the backgroundFilters
property of the receiver’s layer.
Sending this message to a view that is not managing a Core Animation layer causes an exception.
NSView.h
Invoked at the beginning of the printing session, this method sets up the current graphics context.
- (void)beginDocument
Note that this method may be invoked in a subthread.
Override it to configure printing related settings. You should store your settings in the object returned by NSPrintInfo
‘s sharedPrintInfo
class method, which is guaranteed to return an instance specific to the thread in which you invoke this method. If you override this method, call the superclass implementation.
NSView.h
Called at the beginning of each page, this method sets up the coordinate system so that a region inside the receiver’s bounds is translated to a specified location..
- (void)beginPageInRect:(NSRect)aRect atPlacement:(NSPoint)location
A rectangle defining the region to be translated.
A point that is the end-point of translation.
If you override this method, be sure to call the superclass implementation.
NSView.h
Returns a bitmap-representation object suitable for caching the specified portion of the receiver.
- (NSBitmapImageRep *)bitmapImageRepForCachingDisplayInRect:(NSRect)aRect
A rectangle defining the area of the receiver to be cached.
An autoreleased NSBitmapImageRep
object or nil
if the object could not be created.
Passing the visible rectangle of the receiver ([self visibleRect]
) returns a bitmap suitable for caching the current contents of the view, including all of its descendants.
NSView.h
Returns the receiver’s bounds rectangle, which expresses its location and size in its own coordinate system.
- (NSRect)bounds
By default, the origin of the returned rectangle is (0, 0) and its size matches the size of the receiver’s frame rectangle (measured in points). In Mac OS X v10.5 and later, if the receiver is being rendered into an OpenGL graphics context (using an NSOpenGLContext
object), the default bounds origin is still (0, 0) but the default bounds size is measured in pixels instead of points. Thus, for user space scale factors other than 1.0, the default size of the bounds rectangle may be bigger or smaller than the default size of the frame rectangle when drawing with OpenGL.
Important: Developers of OpenGL applications should not rely on this method converting coordinates to pixels automatically in future releases. Instead, you should convert coordinates to device space explicitly using the convertPointToBase:
, convertSizeToBase:
, or convertRectToBase:
methods or their earlier counterparts convertPoint:toView:
, convertSize:toView:
, or convertRect:toView:
.
If you explicitly change the origin or size of the bounds rectangle, this method does not return the default rectangle and instead returns the rectangle you set. If you add a rotation factor to the view, however, that factor is also reflected in the returned bounds rectangle. You can determine if a rotation factor is in effect by calling the boundsRotation
method.
NSView.h
Returns the angle, in degrees, of the receiver’s bounds rectangle relative to its frame rectangle.
- (CGFloat)boundsRotation
See the setBoundsRotation:
method description for more information on bounds rotation.
NSView.h
Draws the specified area of the receiver, and its descendants, into a provided bitmap-representation object.
- (void)cacheDisplayInRect:(NSRect)rect toBitmapImageRep:(NSBitmapImageRep *)bitmapImageRep
A rectangle defining the region to be drawn into bimapImageRep.
An NSBitmapImageRep
object. For pixel-format compatibility, bitmapImageRep should have been obtained from bitmapImageRepForCachingDisplayInRect:
.
You are responsible for initializing the bitmap to the desired configuration before calling this method. However, once initialized, you can reuse the same bitmap multiple times to refresh the cached copy of your view’s contents.
The bitmap produced by this method is transparent (that is, has an alpha value of 0) wherever the receiver and its descendants do not draw any content.
NSView.h
Returns YES
if the receiver can become key view, NO
otherwise.
- (BOOL)canBecomeKeyView
NSView.h
Returns YES
if drawing commands will produce any result, NO
otherwise.
- (BOOL)canDraw
Use this method when invoking a draw method directly along with lockFocus
and unlockFocus
, bypassing the display...
methods (which test drawing ability and perform locking for you). If this method returns NO
, you shouldn’t invoke lockFocus
or perform any drawing.
A view object can draw on-screen if it is not hidden, it is attached to a view hierarchy in a window (NSWindow
), and the window has a corresponding window device. A view object can draw during printing if it is a descendant of the view being printed.
NSView.h
Converts the corners of a specified rectangle to lie on the center of device pixels, which is useful in compensating for rendering overscanning when the coordinate system has been scaled.
- (NSRect)centerScanRect:(NSRect)aRect
The rectangle whose corners are to be converted.
The adjusted rectangle.
This method converts the given rectangle to device coordinates, adjusts the rectangle to lie in the center of the pixels, and converts the resulting rectangle back to the receiver’s coordinate system. Note that this method does not take into account any transformations performed using the NSAffineTransform
class or Quartz 2D routines.
NSView.h
Returns the CoreImage filter that is used to composite the receiver’s contents with the background
- (CIFilter *)compositingFilter
The CoreImage filter.
This method returns the value of the filters
property of the receiver’s layer.
Sending this message to a view that is not managing a Core Animation layer causes an exception.
NSView.h
Returns the array of CoreImage filters that are applied to the contents of the receiver and its sublayers.
- (NSArray *)contentFilters
An array of CoreImage filters
This method returns the value of the filters
property of the receiver’s layer.
Sending this message to a view that is not managing a Core Animation layer causes an exception.
NSView.h
Converts a point from the coordinate system of a given view to that of the receiver.
- (NSPoint)convertPoint:(NSPoint)aPoint fromView:(NSView *)aView
A point specifying a location in the coordinate system of aView
.
The view with aPoint
in its coordinate system. If aView is nil
, this method instead converts from window base coordinates. Otherwise, both aView and the receiver must belong to the same NSWindow
object.
The point converted to the coordinate system of the receiver.
NSView.h
Converts a point from the receiver’s coordinate system to that of a given view.
- (NSPoint)convertPoint:(NSPoint)aPoint toView:(NSView *)aView
A point specifying a location in the coordinate system of the receiver.
The view into whose coordinate system aPoint is to be converted. If aView is nil
, this method instead converts to window base coordinates. Otherwise, both aView and the receiver must belong to the same NSWindow
object.
The point converted to the coordinate system of aView.
NSView.h
Converts the point from the base coordinate system to the receiver’s coordinate system.
- (NSPoint)convertPointFromBase:(NSPoint)aPoint
A point specifying a location in the base coordinate system.
The point converted to the receiver’s base coordinate system.
See View Coordinate Conversion in View Programming Guide for Cocoa for a description of view coordinate to base coordinate conversion.
NSView.h
Converts the point from the receiver’s coordinate system to the base coordinate system.
- (NSPoint)convertPointToBase:(NSPoint)aPoint
A point specifying a location in the coordinate system of the receiver.
The point converted to the base coordinate system.
See View Coordinate Conversion in View Programming Guide for Cocoa for a description of view coordinate to base coordinate conversion.
NSView.h
Converts a rectangle from the coordinate system of another view to that of the receiver.
- (NSRect)convertRect:(NSRect)aRect fromView:(NSView *)aView
The rectangle in aView
's coordinate system.
The view with aRect
in its coordinate system. If aView is nil
, this method instead converts from window base coordinates. Otherwise, both aView and the receiver must belong to the same NSWindow
object.
The converted rectangle.
NSView.h
Converts a rectangle from the receiver’s coordinate system to that of another view.
- (NSRect)convertRect:(NSRect)aRect toView:(NSView *)aView
A rectangle in the receiver's coordinate system.
The view that is the target of the conversion operation. If aView is nil
, this method instead converts from window base coordinates. Otherwise, both aView and the receiver must belong to the same NSWindow
object.
The converted rectangle.
NSView.h
Converts the rectangle from the base coordinate system to the receiver’s coordinate system.
- (NSRect)convertRectFromBase:(NSRect)aRect
A rectangle in the base coordinate system
A rectangle in the receiver’s coordinate system
See View Coordinate Conversion in View Programming Guide for Cocoa for a description of view coordinate to base coordinate conversion.
NSView.h
Converts the rectangle from the receiver’s coordinate system to the base coordinate system.
- (NSRect)convertRectToBase:(NSRect)aRect
A rectangle in the receiver’s coordinate system
A rectangle in the base coordinate system
See View Coordinate Conversion in View Programming Guide for Cocoa for a description of view coordinate to base coordinate conversion.
NSView.h
Converts a size from another view’s coordinate system to that of the receiver.
- (NSSize)convertSize:(NSSize)aSize fromView:(NSView *)aView
The size (width and height) in aView's coordinate system.
The view with aSize in its coordinate system. If aView is nil
, this method instead converts from window base coordinates. Otherwise, both aView and the receiver must belong to the same NSWindow
object.
The converted size, as an NSSize
structure.
NSView.h
Converts a size from the receiver’s coordinate system to that of another view.
- (NSSize)convertSize:(NSSize)aSize toView:(NSView *)aView
The size (width and height) in the receiver's coordinate system.
The view that is the target of the conversion operation. If aView is nil
, this method instead converts from window base coordinates. Otherwise, both aView and the receiver must belong to the same NSWindow
object.
The converted size, as an NSSize
structure.
NSView.h
Converts the size from the base coordinate system to the receiver’s coordinate system.
- (NSSize)convertSizeFromBase:(NSSize)aSize
A size in the base coordinate system
The size converted to the receiver’s coordinate system.
See View Coordinate Conversion in View Programming Guide for Cocoa for a description of view coordinate to base coordinate conversion.
NSView.h
Converts the size from the receiver’s coordinate system to the base coordinate system.
- (NSSize)convertSizeToBase:(NSSize)aSize
A size in the receiver’s coordinate system
The size converted to the base coordinate system.
See View Coordinate Conversion in View Programming Guide for Cocoa for a description of view coordinate to base coordinate conversion.
NSView.h
Returns EPS data that draws the region of the receiver within a specified rectangle.
- (NSData *)dataWithEPSInsideRect:(NSRect)aRect
A rectangle defining the region.
This data can be placed on an NSPasteboard
object, written to a file, or used to create an NSImage
object.
NSView.h
Returns PDF data that draws the region of the receiver within a specified rectangle.
- (NSData *)dataWithPDFInsideRect:(NSRect)aRect
A rectangle defining the region.
This data can be placed on an NSPasteboard
object, written to a file, or used to create an NSImage
object.
NSView.h
Overridden by subclasses to perform additional actions when subviews are added to the receiver.
- (void)didAddSubview:(NSView *)subview
The view that was added as a subview.
This method is invoked by addSubview:
.
NSView.h
Invalidates all cursor rectangles set up using addCursorRect:cursor:
.
- (void)discardCursorRects
You need never invoke this method directly; neither is it typically invoked during the invalidation of cursor rectangles. NSWindow
automatically invalidates cursor rectangles in response to invalidateCursorRectsForView:
and before the receiver's cursor rectangles are reestablished using resetCursorRects
. This method is invoked just before the receiver is removed from a window and when the receiver is deallocated.
– discardCursorRects
(NSWindow)NSView.h
Displays the receiver and all its subviews if possible, invoking each the NSView
methods lockFocus
, drawRect:
, and unlockFocus
as necessary.
- (void)display
If the receiver isn’t opaque, this method backs up the view hierarchy to the first opaque ancestor, calculates the portion of the opaque ancestor covered by the receiver, and begins displaying from there.
NSView.h
Displays the receiver and all its subviews if any part of the receiver has been marked as needing display with a setNeedsDisplay:
or setNeedsDisplayInRect:
message.
- (void)displayIfNeeded
This method invokes the NSView
methods lockFocus
, drawRect:
, and unlockFocus
as necessary. If the receiver isn’t opaque, this method backs up the view hierarchy to the first opaque ancestor, calculates the portion of the opaque ancestor covered by the receiver, and begins displaying from there.
NSView.h
Acts as displayIfNeeded
, except that this method doesn’t back up to the first opaque ancestor—it simply causes the receiver and its descendants to execute their drawing code.
- (void)displayIfNeededIgnoringOpacity
NSView.h
Acts as displayIfNeeded
, confining drawing to a specified region of the receiver..
- (void)displayIfNeededInRect:(NSRect)aRect
A rectangle defining the region to be redrawn. It should be specified in the coordinate system of the receiver.
NSView.h
Acts as displayIfNeeded
, but confining drawing to aRect and not backing up to the first opaque ancestor—it simply causes the receiver and its descendants to execute their drawing code.
- (void)displayIfNeededInRectIgnoringOpacity:(NSRect)aRect
A rectangle defining the region to be redrawn. It should be specified in the coordinate system of the receiver.
NSView.h
Acts as display
, but confining drawing to a rectangular region of the receiver.
- (void)displayRect:(NSRect)aRect
A rectangle defining the region of the receiver to be redrawn; should be specified in the coordinate system of the receiver.
NSView.h
Displays the receiver but confines drawing to a specified region and does not back up to the first opaque ancestor—it simply causes the receiver and its descendants to execute their drawing code.
- (void)displayRectIgnoringOpacity:(NSRect)aRect
A rectangle defining the region of the receiver to be redrawn; should be specified in the coordinate system of the receiver.
NSView.h
Causes the receiver and its descendants to be redrawn to the specified graphics context.
- (void)displayRectIgnoringOpacity:(NSRect)aRect inContext:(NSGraphicsContext *)context
A rectangle defining the region of the receiver to be redrawn. It should be specified in the coordinate system of the receiver.
The graphics context in which drawing will occur. See the discussion below for more about this parameter.
Acts as display
, but confines drawing to aRect. This method initiates drawing with the receiver, even if the receiver is not opaque. Appropriate scaling factors for the view are obtained from context.
If the context parameter represents the context for the window containing the view, then all of the necessary transformations are applied. This includes the application of the receiver’s bounds and frame transforms along with any transforms it inherited from its ancestors. In this situation, the view is also marked as no longer needing an update for the specified rectangle.
If context specifies any other graphics context, then only the receiver’s bounds transform is applied. This means that drawing is not constrained to the view’s visible rectangle. It also means that any dirty rectangles are not cleared, since they are not being redrawn to the window.
NSView.h
Initiates a dragging operation from the receiver, allowing the user to drag a file icon to any application that has window or view objects that accept files.
- (BOOL)dragFile:(NSString *)fullPath fromRect:(NSRect)aRect slideBack:(BOOL)slideBack event:(NSEvent *)theEvent
A string that specifies the absolute path for the file that is dragged.
A rectangle that describes the position of the icon in the receiver’s coordinate system.
A Boolean that indicates whether the icon being dragged should slide back to its position in the receiver if the file isn’t accepted. The icon slides back to aRect if slideBack is YES
, the file is not accepted by the dragging destination, and the user has not disabled icon animation; otherwise it simply disappears.
The mouse-down event object from which to initiate the drag operation. In particular, its mouse location is used for the offset of the icon being dragged.
YES
if the receiver successfully initiates the dragging operation (which doesn’t necessarily mean the dragging operation concluded successfully). Otherwise returns NO
.
This method must be invoked only within an implementation of the mouseDown:
method.
See the NSDraggingSource
, NSDraggingInfo
, and NSDraggingDestination
protocol specifications for more information on dragging operations.
NSView.h
Initiates a dragging operation from the receiver, allowing the user to drag arbitrary data with a specified icon into any application that has window or view objects that accept dragged data.
- (void)dragImage:(NSImage *)anImage at:(NSPoint)imageLoc offset:(NSSize)mouseOffset event:(NSEvent *)theEvent pasteboard:(NSPasteboard *)pboard source:(id)sourceObject slideBack:(BOOL)slideBack
The NSImage
object to be dragged.
The location of the image’s lower-left corner, in the receiver’s coordinate system. It determines the placement of the dragged image under the cursor. When determining the image location you should use the mouse down coordinate, provided in theEvent, rather than the current mouse location.
The mouse’s current location relative to the mouse-down location. In Mac OS X v10.4 and later, this parameter is ignored. In earlier versions of Mac OS X, this parameter is ignored when positioning the dragged image on screen but not ignored when passing the drag location to the source in draggedImage:endedAt:operation:
.
Historically, this argument represented the difference between the mouse position when the drag operation commenced and the mouse position of the initial mouse down. If you initiated a dragging operation immediately on a mouse-down event, this offset was (0.0, 0.0). If you tested for a mouse-dragged event first, this offset was the difference between the mouse-dragged event’s location and that of the mouse-down event. Since the underlying drag machinery now takes the current mouse position into account when positioning the drag image, this argument is no longer necessary
The left mouse-down event that triggered the dragging operation (see discussion below).
The pasteboard that holds the data to be transferred to the destination (see discussion below).
An object that serves as the controller of the dragging operation. It must conform to the NSDraggingSource
informal protocol and is typically the receiver itself or its NSWindow
object.
A Boolean that determines whether the drag image should slide back if it’s rejected. The image slides back to imageLoc if slideBack is YES
and the image isn’t accepted by the dragging destination. If NO
the image doesn't slide back.
This method must be invoked only within an implementation of the mouseDown:
or mouseDragged:
methods.
Before invoking this method, you must place the data to be transferred on pboard. To do this, get the drag pasteboard object (NSDragPboard
), declare the types of the data, and then put the data on the pasteboard. This code fragment initiates a dragging operation on an image itself (that is, the image is the data to be transferred):
- (void)mouseDown:(NSEvent *)theEvent |
{ |
NSSize dragOffset = NSMakeSize(0.0, 0.0); |
NSPasteboard *pboard; |
pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; |
[pboard declareTypes:[NSArray arrayWithObject:NSTIFFPboardType] owner:self]; |
[pboard setData:[[self image] TIFFRepresentation] forType:NSTIFFPboardType]; |
[self dragImage:[self image] at:[self imageLocation] offset:dragOffset |
event:theEvent pasteboard:pboard source:self slideBack:YES]; |
return; |
} |
See the NSDraggingSource
, NSDraggingInfo
, and NSDraggingDestination
protocol specifications for more information on dragging operations.
NSView.h
Initiates a dragging operation from the receiver, allowing the user to drag one or more promised files (or directories) into any application that has window or view objects that accept promised file data.
- (BOOL)dragPromisedFilesOfTypes:(NSArray *)typeArray fromRect:(NSRect)aRect source:(id)sourceObject slideBack:(BOOL)slideBack event:(NSEvent *)theEvent
An array of file types being promised. The array elements can consist of file extensions and HFS types encoded with the NSFileTypeForHFSTypeCode
function. If promising a directory of files, only include the top directory in the array.
A rectangle that describes the position of the icon in the receiver’s coordinate system.
An object that serves as the controller of the dragging operation. It must conform to the NSDraggingSource
informal protocol, and is typically the receiver itself or its NSWindow
object.
A Boolean that indicates whether the icon being dragged should slide back to its position in the receiver if the file isn’t accepted. The icon slides back to aRect if slideBack is YES
, the promised files are not accepted by the dragging destination, and the user has not disabled icon animation; otherwise it simply disappears.
The mouse-down event object from which to initiate the drag operation. In particular, its mouse location is used for the offset of the icon being dragged.
YES
if the drag operation is initiated successfully, NO
otherwise.
This method must be invoked only within an implementation of the mouseDown:
method. As part of its implementation, this method invokes dragImage:at:offset:event:pasteboard:source:slideBack:
.
Promised files are files that do not exist, yet, but that the drag source, sourceObject, promises to create at a file system location specified by the drag destination when the drag is successfully dropped.
See Drag and Drop Programming Topics for Cocoa for more information on dragging operations.
NSView.h
Allows applications that use the Application Kit pagination facility to draw additional marks on each logical page.
- (void)drawPageBorderWithSize:(NSSize)borderSize
An NSSize
structure that defines a logical page.
The marks can be such things as alignment marks or a virtual sheet border of size borderSize. The default implementation doesn’t draw anything.
NSView.h
Overridden by subclasses to draw the receiver’s image within the passed-in rectangle.
- (void)drawRect:(NSRect)dirtyRect
A rectangle defining the dirty area of the view that requires redrawing.
The receiver can assume the focus has been locked and the coordinate transformations of its frame and bounds rectangles have been applied; all it needs to do is invoke rendering client functions.
You can avoid unnecessary drawing by paying attention to the dirtyRect parameter which defines the area that must be redrawn. The bounds of the entire view, as opposed to the dirty region, is given by [self bounds].
On Mac OS X version 10.2 and earlier, the Application Kit automatically clips any drawing you perform in this method to this rectangle. On Mac OS X version 10.3 and later, the Application Kit automatically clips drawing to a list of non-overlapping rectangles that more rigorously specify the area needing drawing. You can invoke the getRectsBeingDrawn:count:
method to retrieve this list of rectangles and use them to constrain your drawing more tightly, if you wish. Moreover, the needsToDrawRect:
method gives you a convenient way to test individual objects for intersection with the rectangles in the list. See Cocoa Drawing Guide for information and references on drawing.
The default implementation does nothing. If your custom view is a direct NSView
subclass you do not need to call super
's implementation.
Note: If a subclass returns YES
upon receiving an isOpaque
message, it must completely fill aRect with opaque content.
– display
– getRectsBeingDrawn:count:
– isFlipped
– needsToDrawRect:
– setNeedsDisplayInRect:
– shouldDrawColor
NSView.h
Allows applications that use the Application Kit pagination facility to draw additional marks on each printed sheet.
- (void)drawSheetBorderWithSize:(NSSize)borderSize
An NSSize
structure that defines a printed sheet.
The marks can be such things as crop marks or fold lines of size borderSize. This method has been deprecated.
NSView.h
Returns the menu item containing the receiver or any of its superviews in the view hierarchy.
- (NSMenuItem *)enclosingMenuItem
Returns the menu item containing the receiver or any of its superviews in the view hierarchy, or nil
if the receiver's view hierarchy is not in a menu item
NSMenuItem.h
Returns the nearest ancestor NSScrollView
object containing the receiver (not including the receiver itself); otherwise returns nil
.
- (NSScrollView *)enclosingScrollView
NSView.h
This method is invoked at the end of the printing session.
- (void)endDocument
If you override this method, call the superclass implementation.
NSView.h
Writes the end of a conforming page.
- (void)endPage
This method is invoked after each page is printed. It invokes unlockFocus
. This method also generates comments for the bounding box and page fonts, if they were specified as being at the end of the page.
NSView.h
Sets the receiver to full screen mode.
- (BOOL)enterFullScreenMode:(NSScreen *)screen withOptions:(NSDictionary *)options
The screen the receiver should cover.
A dictionary of options for the mode. For possible keys, see “Full screen mode”
.
YES
if the receiver was able to enter full screen mode, otherwise NO
.
NSView.h
Instructs the receiver to exit full screen mode.
- (void)exitFullScreenModeWithOptions:(NSDictionary *)options
A dictionary of options for the mode. For possible keys, see “Full screen mode”
.
NSView.h
Returns the type of focus ring drawn around the receiver.
- (NSFocusRingType)focusRingType
An enum
constant identifying a type of focus ring. Possible values are listed in NSFocusRingType
.
You can disable a view’s drawing of its focus ring by overriding this method to return NSFocusRingTypeNone
, or by invoking setFocusRingType:
with and argument of NSFocusRingTypeNone
. You should only disable the default drawing of a view’s focus ring if you want it to draw its own focus ring (for example, setting the background color of the view), or if the view does not have sufficient space to display a focus ring.
NSView.h
Returns the receiver’s frame rectangle, which defines its position in its superview.
- (NSRect)frame
The frame rectangle may be rotated; use the frameRotation
method to check this.
NSView.h
Returns the receiver’s rotation about the layer’s position.
- (CGFloat)frameCenterRotation
The angle of rotatation of the frame around the center of the receiver.
If the application has altered the layer’s anchorPoint
property, the behavior is undefined. Sending this message to a view that is not managing a Core Animation layer causes an exception.
NSView.h
Returns the angle, in degrees, of the receiver’s frame relative to its superview’s coordinate system.
- (CGFloat)frameRotation
NSView.h
Returns by indirection a list of non-overlapping rectangles that define the area the receiver is being asked to draw in drawRect:
.
- (void)getRectsBeingDrawn:(const NSRect **)rects count:(NSInteger *)count
On return, contains a list of non-overlapping rectangles defining areas to be drawn in. The rectangles returned in rects are in the coordinate space of the receiver.
On return, the number of rectangles in the rects
list.
An implementation of drawRect:
can use this information to test whether objects or regions within the view intersect with the rectangles in the list, and thereby avoid unnecessary drawing that would be completely clipped away.
The needsToDrawRect:
method gives you a convenient way to test individual objects for intersection with the area being drawn in drawRect:
. However, you may want to retrieve and directly inspect the rectangle list if this is a more efficient way to perform intersection testing.
You should send this message only from within a drawRect:
implementation. The aRect parameter of drawRect:
is the rectangle enclosing the returned list of rectangles; you can use it in an initial pass to reject objects that are clearly outside the area to be drawn.
NSView.h
Returns a list of rectangles indicating the newly exposed areas of the receiver.
- (void)getRectsExposedDuringLiveResize:(NSRect)exposedRects count:(NSInteger *)count
On return, contains the list of rectangles. The returned rectangles are in the coordinate space of the receiver.
Contains the number of rectangles in exposedRects; this value may be 0 and is guaranteed to be no more than 4.
If your view does not support content preservation during live resizing, the entire area of your view is returned in the exposedRects parameter. To support content preservation, override preservesContentDuringLiveResize
in your view and have your implementation return YES
.
Note: The window containing your view must also support content preservation. To enable support for this feature in your window, use the setPreservesContentDuringLiveResize:
method of NSWindow
.
If the view decreased in both height and width, the list of returned rectangles will be empty. If the view increased in both height and width and its upper-left corner stayed anchored in the same position, the list of returned rectangles will contain a vertical and horizontal component indicating the exposed area.
NSView.h
Returns the identifier for the receiver’s graphics state object, or 0 if the receiver doesn’t have a graphics state object.
- (NSInteger)gState
A view object’s graphics state object is recreated from scratch whenever the view is focused, unless the allocateGState
method has been invoked. So if the receiver hasn’t been focused or hasn’t received the allocateGState
message, this method returns 0.
Although applications rarely need to use the value returned by gState
, it can be passed to the few methods that take an object identifier as a parameter.
NSView.h
Returns the fraction (from 0.0 to 1.0) of the page that can be pushed onto the next page during automatic pagination to prevent items such as lines of text from being divided across pages.
- (CGFloat)heightAdjustLimit
This fraction is used to calculate the bottom edge limit for an adjustPageHeightNew:top:bottom:limit:
message.
NSView.h
Returns the farthest descendant of the receiver in the view hierarchy (including itself) that contains a specified point, or nil
if that point lies completely outside the receiver.
- (NSView *)hitTest:(NSPoint)aPoint
A point that is in the coordinate system of the receiver’s superview, not of the receiver itself.
A view object that is the farthest descendent of aPoint.
This method is used primarily by an NSWindow
object to determine which view should receive a mouse-down event. You’d rarely need to invoke this method, but you might want to override it to have a view object hide mouse-down events from its subviews. This method ignores hidden views.
NSView.h
Initializes and returns a newly allocated NSView
object with a specified frame rectangle.
- (id)initWithFrame:(NSRect)frameRect
The frame rectangle for the created view object.
An initialized NSView
object or nil if the object couldn't be created.
The new view object must be inserted into the view hierarchy of a window before it can be used. This method is the designated initializer for the NSView
class. Returns an initialized object.
NSView.h
A convenience method, expected to be called from drawRect:
, to assist in decisions about optimized drawing.
- (BOOL)inLiveResize
YES
if the receiver is in a live-resize operation, NO
otherwise.
NSView.h
Returns YES
if the receiver is a subview of a given view or if it’s identical to that view; otherwise, it returns NO
.
- (BOOL)isDescendantOf:(NSView *)aView
The view to test for subview relationship within the view hierarchy.
The method returns YES
if the receiver is either an immediate or distant subview of aView
.
NSView.h
Returns YES
if the receiver uses flipped drawing coordinates or NO
if it uses native coordinates.
- (BOOL)isFlipped
The default implementation returns NO
; subclasses that use flipped coordinates should override this method to return YES
.
NSView.h
Returns whether the receiver is marked as hidden.
- (BOOL)isHidden
The return value reflects the state of the receiver only, as set in Interface Builder or through the most recent setHidden:
message, and does not account for the state of the receiver’s ancestors in the view hierarchy, Thus this method returns NO
when the receiver is effectively hidden because it has a hidden ancestor. See setHidden:
for a discussion of the mechanics and implications of hidden views.
If you want to determine whether a view is effectively hidden, for whatever reason, send the isHiddenOrHasHiddenAncestor
to the view instead.
NSView.h
Returns YES
if the receiver is marked as hidden or has an ancestor in the view hierarchy that is marked as hidden; returns NO
otherwise.
- (BOOL)isHiddenOrHasHiddenAncestor
The return value reflects state set through the setHidden:
method in the receiver of one of its ancestors in the view hierarchy. It does not account for other reasons why a view might be considered hidden, such as being positioned outside its superview’s bounds, not having a window, or residing in a window that is offscreen or overlapped by another window.
NSView.h
Returns a Boolean value that indicates whether the receiver is in full screen mode.
- (BOOL)isInFullScreenMode
YES
if the receiver is in full screen mode, otherwise NO
.
NSView.h
Overridden by subclasses to return YES
if the receiver is opaque, NO
otherwise.
- (BOOL)isOpaque
A view object is opaque if it completely covers its frame rectangle when drawing itself. The default implementation performs no drawing at all and so returns NO
.
– opaqueAncestor
– displayRectIgnoringOpacity:
– displayIfNeededIgnoringOpacity
– displayIfNeededInRectIgnoringOpacity:
NSView.h
Returns YES
if the receiver or any of its ancestors has ever received a setFrameRotation:
or setBoundsRotation:
message; otherwise returns NO
.
- (BOOL)isRotatedFromBase
The intent of this information is to optimize drawing and coordinate calculation, not necessarily to reflect the exact state of the receiver’s coordinate system, so it may not reflect the actual rotation. For example, if an NSView
object is rotated to 45 degrees and later back to 0, this method still returns YES
.
NSView.h
Returns YES
if the receiver or any of its ancestors has ever had a nonzero frame or bounds rotation, or has been scaled from the window’s base coordinate system; otherwise returns NO
.
- (BOOL)isRotatedOrScaledFromBase
The intent of this information is to optimize drawing and coordinate calculation, not necessarily to reflect the exact state of the receiver’s coordinate system, so it may not reflect the actual rotation or scaling. For example, if an NSView
object is rotated to 45 degrees and later back to 0, this method still returns YES
.
– frameRotation
– boundsRotation
– centerScanRect:
– setBounds:
– setBoundsSize:
– scaleUnitSquareToSize:
NSView.h
Returns YES
if the receiver handles page boundaries, NO
otherwise.
- (BOOL)knowsPageRange:(NSRangePointer)aRange
On return, holds the page range if YES
is returned directly. Page numbers are one-based—that is pages run from one to N.
Returns NO
if the receiver uses the default auto-pagination mechanism. The default implementation returns NO
. Override this method if your class handles page boundaries.
NSView.h
Returns the Core Animation layer that the receiver as its backing store.
- (CALayer *)layer
The Core Animation layer the receiver is using as its backing store.
NSView.h
Invoked by print:
to determine the location of the region of the receiver being printed on the physical page.
- (NSPoint)locationOfPrintRect:(NSRect)aRect
A rectangle defining a region of the receiver; it is expressed in the default coordinate system of the page.
A point to be used for setting the origin for aRect, whose size the receiver can examine in order to properly place it. It is expressed in the default coordinate system of the page.
The default implementation places aRect according to the status of the NSPrintInfo
object for the print job. By default it places the image in the upper-left corner of the page, but if the NSPrintInfo
methods isHorizontallyCentered
or isVerticallyCentered
return YES
, it centers a single-page image along the appropriate axis. A multiple-page document, however, is always placed so the divided pieces can be assembled at their edges.
NSView.h
Locks the focus on the receiver, so subsequent commands take effect in the receiver’s window and coordinate system.
- (void)lockFocus
If you don’t use a display...
method to draw an NSView
object, you must invoke lockFocus
before invoking methods that send commands to the window server, and must balance it with an unlockFocus
message when finished.
Hiding or miniaturizing a one-shot window causes the backing store for that window to be released. If you don’t use the standard display mechanism to draw, you should use lockFocusIfCanDraw
rather than lockFocus
if there is a chance of drawing while the window is either miniaturized or hidden.
NSView.h
Locks the focus to the receiver atomically if the canDraw
method returns YES
and returns the value of canDraw
.
- (BOOL)lockFocusIfCanDraw
Your thread will not be preempted by other threads between the canDraw
method and the lock. This method fails to lock focus and returns NO
, when the receiver is hidden and the current context is drawing to the screen (as opposed to a printing context).
NSView.h
Locks the focus to the receiver atomically if drawing can occur in the specified graphics context.
- (BOOL)lockFocusIfCanDrawInContext:(NSGraphicsContext *)context
The graphics context in which drawing might occur. See the discussion for the implications of the type of context.
YES
if successful; otherwise, returns NO
.
Your thread will not be preempted by other threads between the canDraw
method and the lock.
If the context parameter represents the context for the window containing the view, then all of the necessary transformations are applied. This includes the application of the receiver’s bounds and frame transforms along with any transforms it inherited from its ancestors. If context specifies any other graphics context, then only the receiver’s bounds transform is applied.
Important: This method was declared in Mac OS X v10.4, but is not used in that release. It currently does nothing and returns NO
. However, it might be implemented in a future release.
NSView.h
Overridden by subclasses to return a context-sensitive pop-up menu for a given mouse-down event.
- (NSMenu *)menuForEvent:(NSEvent *)theEvent
An object representing a mouse-down event.
The receiver can use information in the mouse event, such as its location over a particular element of the receiver, to determine what kind of menu to return. For example, a text object might display a text-editing menu when the cursor lies over text and a menu for changing graphics attributes when the cursor lies over an embedded image.
The default implementation returns the receiver’s normal menu.
+ defaultMenu
– menu
(NSResponder
)NSView.h
Returns whether a region of the receiver contains a specified point, accounting for whether the receiver is flipped or not.
- (BOOL)mouse:(NSPoint)aPoint inRect:(NSRect)aRect
A point that is expressed in the receiver's coordinate system. This point generally represents the hot spot of the mouse cursor.
A rectangle that is expressed in the receiver’s coordinate system.
YES
if aRect
contains aPoint
, NO
otherwise.
Point-in-rectangle functions generally assume that the bottom edge of a rectangle is outside of the rectangle boundaries, while the upper edge is inside the boundaries. This method views aRect from the point of view of the user—that is, this method always treats the bottom edge of the rectangle as the one closest to the bottom edge of the user’s screen. By making this adjustment, this function ensures consistent mouse-detection behavior from the user’s perspective.
Never use the Foundation’s NSPointInRect
function as a substitute for this method. It doesn’t account for flipped coordinate systems.
– hitTest:
– isFlipped
NSMouseInRect
(Foundation functions)– convertPoint:fromView:
NSView.h
Returns YES
if the receiver does not need to handle a mouse down and can pass it through to superviews; NO
if it needs to handle the mouse down.
- (BOOL)mouseDownCanMoveWindow
This allows iApp-type applications to determine the region by which a window can be moved. By default, this method returns NO
if the view is opaque; otherwise, it returns YES
. Subclasses can override this method to return a different value.
NSView.h
Returns YES
if the receiver needs to be displayed, as indicated using setNeedsDisplay:
and setNeedsDisplayInRect:
; returns NO
otherwise.
- (BOOL)needsDisplay
The displayIfNeeded...
methods check this status to avoid unnecessary drawing, and all display methods clear this status to indicate that the view object is up to date.
NSView.h
Overridden by subclasses to return YES
if the receiver requires its panel, which might otherwise avoid becoming key, to become the key window so that it can handle keyboard input.
- (BOOL)needsPanelToBecomeKey
Such a subclass should also override acceptsFirstResponder
to return YES
. The default implementation returns NO
.
– becomesKeyOnlyIfNeeded
(NSPanel
)NSView.h
Returns whether the specified rectangle intersects any part of the area that the receiver is being asked to draw.
- (BOOL)needsToDrawRect:(NSRect)aRect
A rectangle defining a region of the receiver.
You typically send this message from within a drawRect:
implementation. It gives you a convenient way to determine whether any part of a given graphical entity might need to be drawn. It is optimized to efficiently reject any rectangle that lies outside the bounding box of the area the receiver is being asked to draw in drawRect:
.
NSView.h
Returns the view object following the receiver in the key view loop, or nil
if there is none.
- (NSView *)nextKeyView
This view should, if possible, be made first responder when the user navigates forward from the receiver using keyboard interface control.
– nextValidKeyView
– setNextKeyView:
– previousKeyView
– previousValidKeyView
– selectNextKeyView:
(NSWindow
)– selectKeyViewFollowingView:
(NSWindow
)– selectPreviousKeyView:
(NSWindow
)– selectKeyViewPrecedingView:
(NSWindow
)NSView.h
Returns the closest view object in the key view loop that follows the receiver and actually accepts first responder status, or nil
if there is none.
- (NSView *)nextValidKeyView
This method ignores hidden views when it determines the next valid key view.
– nextKeyView
– setNextKeyView:
– previousKeyView
– previousValidKeyView
– selectNextKeyView:
(NSWindow
)– selectKeyViewFollowingView:
(NSWindow
)– selectPreviousKeyView:
(NSWindow
)– selectKeyViewPrecedingView:
(NSWindow
)– setHidden:
NSView.h
Returns the receiver’s closest opaque ancestor (including the receiver itself).
- (NSView *)opaqueAncestor
– isOpaque
– displayRectIgnoringOpacity:
– displayIfNeededIgnoringOpacity
– displayIfNeededInRectIgnoringOpacity:
NSView.h
Returns a default footer string that includes the current page number and page count.
- (NSAttributedString *)pageFooter
A printable view class can override this method to substitute its own content in place of the default value. You should not need to call this method directly. The printing system calls it once per page during printing.
Footers are generated only if the user defaults contain the key NSPrintHeaderAndFooter
with the value YES
.
NSView.h
Returns a default header string that includes the print job title and date.
- (NSAttributedString *)pageHeader
Typically, the print job title is the same as the window title. A printable view class can override this method to substitute its own content in place of the default value. You should not need to call this method directly. The printing system calls it once per page during printing.
Headers are generated only if the user defaults contain the key NSPrintHeaderAndFooter
with the value YES
.
NSView.h
Implemented by subclasses to respond to key equivalents (also known as keyboard shortcuts).
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
The key-down event object representing a key equivalent.
YES
if theEvent is a key equivalent that the receiver handled, NO
if it is not a key equivalent that it should handle.
If the receiver’s key equivalent is the same as the characters of the key-down event theEvent, as returned by charactersIgnoringModifiers
, the receiver should take the appropriate action and return YES
. Otherwise, it should return the result of invoking super
’s implementation. The default implementation of this method simply passes the message down the view hierarchy (from superviews to subviews) and returns NO
if none of the receiver’s subviews responds YES
.
– performMnemonic:
– keyDown:
(NSWindow
)NSView.h
Implemented by subclasses to respond to mnemonics.
- (BOOL)performMnemonic:(NSString *)aString
A string representing the mnemonic to handle.
If the receiver’s mnemonic is the same as the characters of the string aString, the receiver should take the appropriate action and return YES
. Otherwise, it should return the result of invoking super
’s implementation. The default implementation of this method simply passes the message down the view hierarchy (from superviews to subviews) and returns NO
if none of the receiver’s subviews responds YES
. Mnemonics are not supported in Mac OS X.
– performKeyEquivalent:
– keyDown:
(NSWindow
)NSView.h
Returns YES
if the receiver posts notifications to the default notification center whenever its bounds rectangle changes; returns NO
otherwise.
- (BOOL)postsBoundsChangedNotifications
See setPostsBoundsChangedNotifications:
for a list of methods that result in notifications.
NSView.h
Returns YES
if the receiver posts notifications to the default notification center whenever its frame rectangle changes; returns NO
otherwise.
- (BOOL)postsFrameChangedNotifications
See setPostsBoundsChangedNotifications:
for a list of methods that result in notifications.
NSView.h
Returns YES
if the view supports the optimization of live-resize operations by preserving content that has not moved; otherwise, returns NO
.
- (BOOL)preservesContentDuringLiveResize
The default is NO
. If your view supports the content preservation feature, you should override this method and have your implementation return YES
.
Content preservation lets your view decide what to redraw during a live resize operation. If your view supports this feature, you should also provide a custom implementation of setFrameSize:
that invalidates the portions of your view that actually need to be redrawn.
For information on how to implement this feature in your views, see Cocoa Performance Guidelines.
NSView.h
Returns the view object preceding the receiver in the key view loop, or nil
if there is none.
- (NSView *)previousKeyView
This view should, if possible, be made first responder when the user navigates backward from the receiver using keyboard interface control.
– previousValidKeyView
– nextKeyView
– nextValidKeyView
– setNextKeyView:
– selectNextKeyView:
(NSWindow
)– selectKeyViewFollowingView:
(NSWindow
)– selectPreviousKeyView:
(NSWindow
)– selectKeyViewPrecedingView:
(NSWindow
)NSView.h
Returns the closest view object in the key view loop that precedes the receiver and actually accepts first responder status, or nil
if there is none.
- (NSView *)previousValidKeyView
This method ignores hidden views when it determines the previous valid key view.
– previousKeyView
– nextValidKeyView
– nextKeyView
– setNextKeyView:
– selectNextKeyView:
(NSWindow
)– selectKeyViewFollowingView:
(NSWindow
)– selectPreviousKeyView:
(NSWindow
)– selectKeyViewPrecedingView:
(NSWindow
)– setHidden:
NSView.h
This action method opens the Print panel, and if the user chooses an option other than canceling, prints the receiver and all its subviews to the device specified in the Print panel.
- (void)print:(id)sender
The object that sent the message.
NSView.h
Returns the receiver’s print job title.
- (NSString *)printJobTitle
The default implementation first tries the window’s NSDocument
display name (displayName
), then the window’s title.
NSView.h
Implemented by subclasses to determine the portion of the receiver to be printed for the page number page.
- (NSRect)rectForPage:(NSInteger)pageNumber
An integer indicating a page number. Page numbers are one-based—that is pages run from one to N.
A rectangle defining the region of the receiver to be printed for pageNumber. This method returns NSZeroRect
if pageNumber is outside the receiver’s bounds.
If the receiver responded YES
to an earlier knowsPageRange:
message, this method is invoked for each page it specified in the out parameters of that message. The receiver is later made to display this rectangle in order to generate the image for this page.
If an NSView
object responds NO
to knowsPageRange:
, this method isn’t invoked by the printing mechanism.
NSView.h
Returns the rectangle identifying the portion of your view that did not change during a live resize operation.
- (NSRect)rectPreservedDuringLiveResize
The returned rectangle is in the coordinate system of your view and reflects the space your view previously occupied. This rectangle may be smaller or the same size as your view’s current bounds, depending on whether the view grew or shrunk.
If your view does not support content preservation during live resizing, the returned rectangle will be empty. To support content preservation, override preservesContentDuringLiveResize
in your view and have your implementation return YES
.
Note: The window containing your view must also support content preservation. To enable support for this feature in your window, use the setPreservesContentDuringLiveResize:
method of NSWindow
.
NSView.h
Notifies a clip view’s superview that either the clip view’s bounds rectangle or the document view’s frame rectangle has changed, and that any indicators of the scroll position need to be adjusted.
- (void)reflectScrolledClipView:(NSClipView *)aClipView
The NSClipView
object whose superview is to be notified.
NSScrollView
implements this method to update its NSScroller
objects.
NSClipView.h
Returns the array of pasteboard drag types that the view can accept.
- (NSArray *)registeredDraggedTypes
This method returns the types registered by calling registerForDraggedTypes:
. Each element of the array is a global string constant; see "Constants" for descriptions of the pasteboard string constants. The returned elements are in no particular order, but the array is guaranteed not to contain duplicate entries.
NSView.h
Registers the pasteboard types that the receiver will accept as the destination of an image-dragging session.
- (void)registerForDraggedTypes:(NSArray *)pboardTypes
An array of pasteboard types, each a global string constant. See "Constants
" for descriptions of the pasteboard string constants.
Registering an NSView
object for dragged types automatically makes it a candidate destination object for a dragging session. As such, it must properly implement some or all of the NSDraggingDestination
protocol methods. As a convenience, NSView
provides default implementations of these methods. See the NSDraggingDestination
protocol specification for details.
NSView.h
Frees the receiver’s graphics state object, if it has one.
- (void)releaseGState
NSView.h
Removes all tool tips assigned to the receiver.
- (void)removeAllToolTips
This method operates on tool tips created using either addToolTipRect:owner:userData:
or setToolTip:
.
NSView.h
Completely removes a cursor rectangle from the receiver.
- (void)removeCursorRect:(NSRect)aRect cursor:(NSCursor *)aCursor
A rectangle defining a region of the receiver. Must match a value previously specified using addCursorRect:cursor:
.
An object representing a cursor. Must match a value previously specified using addCursorRect:cursor:
.
You should rarely need to use this method. resetCursorRects
, which is invoked any time cursor rectangles need to be rebuilt, should establish only the cursor rectangles needed. If you implement resetCursorRects
in this way, you can then simply modify the state that resetCursorRects
uses to build its cursor rectangles and then invoke the NSWindow
method invalidateCursorRectsForView:
.
NSView.h
Unlinks the receiver from its superview and its window, removes it from the responder chain, and invalidates its cursor rectangles.
- (void)removeFromSuperview
The receiver is also released; if you plan to reuse it, be sure to retain it before sending this message and to release it as appropriate when adding it as a subview of another NSView
.
Never invoke this method during display.
NSView.h
Unlinks the receiver from its superview and its window and removes it from the responder chain, but does not invalidate its cursor rectangles to cause redrawing.
- (void)removeFromSuperviewWithoutNeedingDisplay
The receiver is also released; if you plan to reuse it, be sure to retain it before sending this message and to release it as appropriate when adding it as a subview of another view.
Unlike its counterpart, removeFromSuperview
, this method can be safely invoked during display.
NSView.h
Removes the tool tip identified by specified tag.
- (void)removeToolTip:(NSToolTipTag)tag
An integer tag that is the value returned by a previous addToolTipRect:owner:userData:
message.
NSView.h
Removes a given tracking area from the receiver.
- (void)removeTrackingArea:(NSTrackingArea *)trackingArea
The tracking area to remove from the receiver.
NSView.h
Removes the tracking rectangle identified by a tag.
- (void)removeTrackingRect:(NSTrackingRectTag)aTag
An integer value identifying a tracking rectangle. It was returned by a previously sent addTrackingRect:owner:userData:assumeInside:
message.
NSView.h
Invalidates the receiver’s graphics state object, if it has one.
- (void)renewGState
The receiver's graphics state object will be regenerated using setUpGState
the next time the receiver is focused for drawing
NSView.h
Replaces one of the receiver’s subviews with another view.
- (void)replaceSubview:(NSView *)oldView with:(NSView *)newView
The view to be replaced by newView
. May not be nil
.
The view to replace oldView
. May not be nil
.
This method does nothing if oldView is not a subview of the receiver.
Neither oldView nor newView may be nil
, and the behavior is undefined if either of these parameters is nil
.
This method causes oldView to be released; if you plan to reuse it, be sure to retain it before sending this message and to release it as appropriate when adding it as a subview of another NSView.
NSView.h
Overridden by subclasses to define their default cursor rectangles.
- (void)resetCursorRects
A subclass’s implementation must invoke addCursorRect:cursor:
for each cursor rectangle it wants to establish. The default implementation does nothing.
Application code should never invoke this method directly; it’s invoked automatically as described in "Handling Tracking-Rectangle and Cursor-Update Events in Views." Use the invalidateCursorRectsForView:
method instead to explicitly rebuild cursor rectangles.
NSView.h
Informs the receiver’s subviews that the receiver’s bounds rectangle size has changed.
- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize
The previous size of the receiver's bounds rectangle.
If the receiver is configured to autoresize its subviews, this method is automatically invoked by any method that changes the receiver’s frame size.
The default implementation sends resizeWithOldSuperviewSize:
to the receiver’s subviews with oldBoundsSize as the argument. You shouldn’t invoke this method directly, but you can override it to define a specific retiling behavior.
NSView.h
Informs the receiver that the bounds size of its superview has changed.
- (void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize
The previous size of the superview's bounds rectangle.
This method is normally invoked automatically from resizeSubviewsWithOldSize:
.
The default implementation resizes the receiver according to the autoresizing options listed under the setAutoresizingMask:
method description. You shouldn’t invoke this method directly, but you can override it to define a specific resizing behavior.
NSView.h
Rotates the receiver’s bounds rectangle by a specified degree value around the origin of the coordinate system, (0.0, 0.0).
- (void)rotateByAngle:(CGFloat)angle
A float
value specifying the angle of rotation, in degrees.
See the setBoundsRotation:
method description for more information. This method neither redisplays the receiver nor marks it as needing display. You must do this yourself with display
or setNeedsDisplay:
.
This method posts an NSViewBoundsDidChangeNotification
to the default notification center if the receiver is configured to do so.
NSView.h
Scales the receiver’s coordinate system so that the unit square scales to the specified dimensions.
- (void)scaleUnitSquareToSize:(NSSize)newUnitSize
An NSSize
structure specifying the new unit size.
For example, a newUnitSize of (0.5, 1.0) causes the receiver’s horizontal coordinates to be halved, in turn doubling the width of its bounds rectangle. Note that scaling is performed from the origin of the coordinate system, (0.0, 0.0), not the origin of the bounds rectangle; as a result, both the origin and size of the bounds rectangle are changed. The frame rectangle remains unchanged.
This method neither redisplays the receiver nor marks it as needing display. You must do this yourself with display
or setNeedsDisplay:
.
This method posts an NSViewBoundsDidChangeNotification
to the default notification center if the receiver is configured to do so.
NSView.h
Notifies the superview of a clip view that the clip view needs to reset the origin of its bounds rectangle.
- (void)scrollClipView:(NSClipView *)aClipView toPoint:(NSPoint)newOrigin
The NSClipView
object whose superview is to be notified.
A point that specifies the new origin of the clip view's bounds rectangle.
The superview of aClipView should then send a scrollToPoint:
message to aClipView with newOrigin as the argument. This mechanism is provided so the NSClipView
object's superview can coordinate scrolling of multiple tiled clip views.
– scrollToPoint:
(NSClipView)NSClipView.h
Scrolls the receiver’s closest ancestor NSClipView
object so a point in the receiver lies at the origin of the clip view's bounds rectangle.
- (void)scrollPoint:(NSPoint)aPoint
The point in the receiver to scroll to.
– autoscroll:
– scrollToPoint:
(NSClipView
)– isDescendantOf:
NSView.h
Copies the visible portion of the receiver’s rendered image within a region and lays that portion down again at a specified offset .
- (void)scrollRect:(NSRect)aRect by:(NSSize)offset
A rectangle defining a region of the receiver.
A NSSize
structure that specifies an offset from from aRect’s origin.
This method is useful during scrolling or translation of the coordinate system to efficiently move as much of the receiver’s rendered image as possible without requiring it to be redrawn, following these steps:
Invoke scrollRect:by:
to copy the rendered image.
Move the view object’s origin or scroll it within its superview.
Calculate the newly exposed rectangles and invoke either setNeedsDisplay:
or setNeedsDisplayInRect:
to draw them.
You should rarely need to use this method, however. The scrollPoint:
, scrollRectToVisible:
, and autoscroll:
methods automatically perform optimized scrolling.
NSView.h
Scrolls the receiver’s closest ancestor NSClipView
object the minimum distance needed so a specified region of the receiver becomes visible in the clip view.
- (BOOL)scrollRectToVisible:(NSRect)aRect
The rectangle to be made visible in the clip view.
YES
if any scrolling is performed; otherwise returns NO
.
– autoscroll:
– scrollToPoint:
(NSClipView)– isDescendantOf:
NSView.h
Sets the opacity of the receiver.
- (void)setAlphaValue:(CGFloat)viewAlpha
The desired opacity of the receiver.
This method sets the value of the opacity
property of the receiver’s layer. Possible values are between 0.0 (transparent) and 1.0 (opaque). The default is 1.0.
Sending this message to a view that is not managing a Core Animation layer causes an exception.
NSView.h
Determines whether the receiver automatically resizes its subviews when its frame size changes.
- (void)setAutoresizesSubviews:(BOOL)flag
If YES
, the receiver invokes resizeSubviewsWithOldSize:
whenever its frame size changes; if NO
, it doesn’t.
View objects do autoresize their subviews by default.
NSView.h
Determines how the receiver’s resizeWithOldSuperviewSize:
method changes its frame rectangle.
- (void)setAutoresizingMask:(NSUInteger)mask
An integer bit mask. mask can be specified by combining using the C bitwise OR operator any of the options described in “Resizing masks”
.
Where more than one option along an axis is set, resizeWithOldSuperviewSize:
by default distributes the size difference as evenly as possible among the flexible portions. For example, if NSViewWidthSizable
and NSViewMaxXMargin
are set and the superview’s width has increased by 10.0 units, the receiver’s frame and right margin are each widened by 5.0 units.
NSView.h
An array of CoreImage filters that are applied to the receiver’s background.
- (void)setBackgroundFilters:(NSArray *)filters
An array of CoreImage filters.
This method sets the value of the backgroundFilters
property of the receiver’s layer.
Sending this message to a view that is not managing a Core Animation layer causes an exception.
NSView.h
Sets the receiver’s bounds rectangle.
- (void)setBounds:(NSRect)boundsRect
A rectangle defining the new bounds of the receiver.
The bounds rectangle determines the origin and scale of the receiver’s coordinate system within its frame rectangle. This method neither redisplays the receiver nor marks it as needing display. You must do this yourself with display
or setNeedsDisplay:
.
This method posts an NSViewBoundsDidChangeNotification
to the default notification center if the receiver is configured to do so.
After calling this method, NSView
creates an internal transform (or appends these changes to an existing internal transform) to convert from frame coordinates to bounds coordinates in your view. As long as the width-to-height ratio of the two coordinate systems remains the same, your content appears normal. If the ratios differ, your content may appear skewed.
– bounds
– setBoundsRotation:
– setBoundsOrigin:
– setBoundsSize:
– setFrame:
– setPostsBoundsChangedNotifications:
NSView.h
Sets the origin of the receiver’s bounds rectangle to a specified point,
- (void)setBoundsOrigin:(NSPoint)newOrigin
A point specifying the new bounds origin of the receiver.
In setting the new bounds origin, this method effectively shifts the receiver's coordinate system so newOrigin lies at the origin of the receiver’s frame rectangle. It neither redisplays the receiver nor marks it as needing display. You must do this yourself with display
or setNeedsDisplay:
.
This method posts an NSViewBoundsDidChangeNotification
to the default notification center if the receiver is configured to do so.
After calling this method, NSView
creates an internal transform (or appends these changes to an existing internal transform) to convert from frame coordinates to bounds coordinates in your view. As long as the width-to-height ratio of the two coordinate systems remains the same, your content appears normal. If the ratios differ, your content may appear skewed.
– translateOriginToPoint:
– bounds
– setBoundsRotation:
– setBounds:
– setBoundsSize:
– setPostsBoundsChangedNotifications:
NSView.h
Sets the rotation of the receiver’s bounds rectangle to a specific degree value.
- (void)setBoundsRotation:(CGFloat)angle
A float
value specifying the angle of rotation, in degrees.
Positive values indicate counterclockwise rotation, negative clockwise. Rotation is performed around the coordinate system origin, (0.0, 0.0), which need not coincide with that of the frame rectangle or the bounds rectangle. This method neither redisplays the receiver nor marks it as needing display. You must do this yourself with display
or setNeedsDisplay:
.
This method posts an NSViewBoundsDidChangeNotification
to the default notification center if the receiver is configured to do so.
Bounds rotation affects the orientation of the drawing within the view object’s frame rectangle, but not the orientation of the frame rectangle itself. Also, for a rotated bounds rectangle to enclose all the visible areas of its view object—that is, to guarantee coverage over the frame rectangle—it must also contain some areas that aren’t visible. This can cause unnecessary drawing to be requested, which may affect performance. It may be better in many cases to rotate the coordinate system in the drawRect:
method rather than use this method.
After calling this method, NSView
creates an internal transform (or appends these changes to an existing internal transform) to convert from frame coordinates to bounds coordinates in your view. As long as the width-to-height ratio of the two coordinate systems remains the same, your content appears normal. If the ratios differ, your content may appear skewed.
NSView.h
Sets the size of the receiver’s bounds rectangle to specified dimensions, inversely scaling its coordinate system relative to its frame rectangle.
- (void)setBoundsSize:(NSSize)newSize
An NSSize
structure specifying the new width and height of the receiver's bounds rectangle.
For example, a view object with a frame size of (100.0, 100.0) and a bounds size of (200.0, 100.0) draws half as wide along the x axis. This method neither redisplays the receiver nor marks it as needing display. You must do this yourself with display
or setNeedsDisplay:
.
This method posts an NSViewBoundsDidChangeNotification
to the default notification center if the receiver is configured to do so.
After calling this method, NSView
creates an internal transform (or appends these changes to an existing internal transform) to convert from frame coordinates to bounds coordinates in your view. As long as the width-to-height ratio of the two coordinate systems remains the same, your content appears normal. If the ratios differ, your content may appear skewed.
NSView.h
Sets a CoreImage filter that is used to composite the receiver’s contents with the background.
- (void)setCompositingFilter:(CIFilter *)filter
A CoreImage filter.
This method sets the value of the compositingFilter
property of the receiver’s layer.
Sending this message to a view that is not managing a Core Animation layer causes an exception.
NSView.h
Sets the array of CoreImage filters that are applied to the contents of the receiver and its sublayers.
- (void)setContentFilters:(NSArray *)filters
An array of CoreImage filters.
This method sets the value of the filters
property of the receiver’s layer.
Sending this message to a view that is not managing a Core Animation layer causes an exception.
NSView.h
Sets the type of focus ring to be drawn around the receiver.
- (void)setFocusRingType:(NSFocusRingType)focusRingType
An enum
constant identifying a type of focus ring. Possible values are listed in NSFocusRingType
. You can specify NSFocusRingTypeNone
to indicate you do not want your view to have a focus ring.
This method only sets the desired focus ring type and does not cause the view to draw the actual focus ring. You are responsible for drawing the focus ring in your view’s drawRect: method whenever your view is made the first responder.
NSView.h
Sets the receiver’s frame rectangle to the specified rectangle.
- (void)setFrame:(NSRect)frameRect
The new frame rectangle for the view.
This method, in setting the frame rectangle, repositions and resizes the receiver within the coordinate system of its superview. It neither redisplays the receiver nor marks it as needing display. You must do this yourself with display
or setNeedsDisplay:
.
This method posts an NSViewFrameDidChangeNotification
to the default notification center if the receiver is configured to do so.
If your view does not use a custom bounds rectangle, this method also sets your view bounds to match the size of the new frame. You specify a custom bounds rectangle by calling setBounds:
, setBoundsOrigin:
, setBoundsRotation:
, or setBoundsSize:
explicitly. Once set, NSView creates an internal transform to convert from frame coordinates to bounds coordinates. As long as the width-to-height ratio of the two coordinate systems remains the same, your content appears normal. If the ratios differ, your content may appear skewed.
NSView.h
Rotates the frame of the receiver about the layer’s position.
- (void)setFrameCenterRotation:(CGFloat)angle
The angle to rotate the frame around the center of the receiver.
If the application has altered the layer’s anchorPoint
property, the behavior is undefined. Sending this message to a view that is not managing a Core Animation layer causes an exception.
NSView.h
Sets the origin of the receiver’s frame rectangle to the specified point, effectively repositioning it within its superview.
- (void)setFrameOrigin:(NSPoint)newOrigin
The point that is the new origin of the receiver's frame.
This method neither redisplays the receiver nor marks it as needing display. You must do this yourself with display
or setNeedsDisplay:
.
This method posts an NSViewFrameDidChangeNotification
to the default notification center if the receiver is configured to do so.
NSView.h
Sets the rotation of the receiver’s frame rectangle to a specified degree value, rotating it within its superview without affecting its coordinate system.
- (void)setFrameRotation:(CGFloat)angle
A float
value indicating the degree of rotation.
Positive values indicate counterclockwise rotation, negative clockwise. Rotation is performed around the origin of the frame rectangle.
This method neither redisplays the receiver nor marks it as needing display. You must do this yourself with display
or setNeedsDisplay:
.
This method posts an NSViewFrameDidChangeNotification
to the default notification center if the receiver is configured to do so.
NSView.h
Sets the size of the receiver’s frame rectangle to the specified dimensions, resizing it within its superview without affecting its coordinate system.
- (void)setFrameSize:(NSSize)newSize
An NSSize
structure specifying the new height and width of the frame rectangle.
This method neither redisplays the receiver nor marks it as needing display. You must do this yourself with display
or setNeedsDisplay:
.
This method posts an NSViewFrameDidChangeNotification
to the default notification center if the receiver is configured to do so.
In Mac OS X version 10.4 and later, you can override this method to support content preservation during live resizing. In your overridden implementation, include some conditional code to be executed only during a live resize operation. Your code must invalidate any portions of your view that need to be redrawn.
NSView.h
Sets whether the receiver is hidden.
- (void)setHidden:(BOOL)flag
YES
if the receiver is to be hidden, NO
otherwise.
A hidden view disappears from its window and does not receive input events. It remains in its superview’s list of subviews, however, and participates in autoresizing as usual. The Application Kit also disables any cursor rectangle, tool-tip rectangle, or tracking rectangle associated with a hidden view. Hiding a view with subviews has the effect of hiding those subviews and any view descendants they might have. This effect is implicit and does not alter the hidden state of the receiver’s descendants as reported by isHidden
.
Hiding the view that is the window’s current first responder causes the view’s next valid key view (nextValidKeyView
) to become the new first responder. A hidden view remains in the nextKeyView
chain of views it was previously part of, but is ignored during keyboard navigation.
NSView.h
Invalidates the area around the focus ring.
- (void)setKeyboardFocusRingNeedsDisplayInRect:(NSRect)rect
The rectangle of the control or cell defining the area around the focus ring. rect will be expanded to include the focus ring for invalidation.
NSView.h
Sets the Core Animation layer that the receiver uses for layer-backing to the specified layer.
- (void)setLayer:(CALayer *)newLayer
A Core Animation layer to use as the receiver’s backing store.
NSView.h
Controls whether the receiver's entire bounds is marked as needing display.
- (void)setNeedsDisplay:(BOOL)flag
If YES
, marks the receiver’s entire bounds as needing display; if NO
, marks it as not needing display.
Whenever the data or state used for drawing a view object changes, the view should be sent a setNeedsDisplay: message. NSView
objects marked as needing display are automatically redisplayed on each pass through the application’s event loop. (View objects that need to redisplay before the event loop comes around can of course immediately be sent the appropriate display...
method.)
NSView.h
Marks the region of the receiver within the specified rectangle as needing display, increasing the receiver’s existing invalid region to include it.
- (void)setNeedsDisplayInRect:(NSRect)invalidRect
The rectangular region of the receiver to mark as invalid; it should be specified in the coordinate system of the receiver.
A later displayIfNeeded...
method will then perform drawing only within the invalid region. View objects marked as needing display are automatically redisplayed on each pass through the application’s event loop. (View objects that need to redisplay before the event loop comes around can of course immediately be sent the appropriate display...
method.)
NSView.h
Inserts a specified view object after the receiver in the key view loop of the receiver’s window.
- (void)setNextKeyView:(NSView *)aView
The NSView
object to insert.
NSView.h
Controls whether the receiver informs observers when its bounds rectangle changes.
- (void)setPostsBoundsChangedNotifications:(BOOL)flag
If YES
, the receiver will post notifications to the default notification center whenever its bounds rectangle changes; if flag is NO
it won’t.
Note that if flag is YES
and bounds notifications are suppressed, when the bounds change notification is reenabled the view will immediately post a single such notification if its bounds changed during this time. This will happen even if there has been no net change in the view's bounds.
The following methods can result in notification posting:
NSView.h
Controls whether the receiver informs observers when its frame rectangle changes.
- (void)setPostsFrameChangedNotifications:(BOOL)flag
If YES
, the receiver will post notifications to the default notification center whenever its frame rectangle changes; if flag is NO
it won’t.
Note that if flag is YES
and frame notifications are suppressed, when the frame change notification is reenabled the view will immediately post a single such notification if its frame changed during this time. This will happen even if there has been no net change in the view's frame.
The following methods can result in notification posting:
NSView.h
Sets the shadow drawn by the receiver.
- (void)setShadow:(NSShadow *)shadow
An instance of NSShadow
.
This method sets the shadowColor
,shadowOffset
, shadowOpacity
and shadowRadius
properties of the receiver’s layer.
Sending this message to a view that is not managing a Core Animation layer causes an exception.
NSView.h
Sets the receiver’s subviews to the specified subviews.
- (void)setSubviews:(NSArray *)newSubviews
An array of subviews. The newSubviews array can consist of existing subviews of the receiver or other views that have nil
as their superview. If newSubviews is nil
, or contains duplicated views, or if any of its members have a superview other than nil
or the reciever, an invalid argument exception is thrown.
Using this method you can: reorder the receiver’s existing subviews, add or remove subviews en masse, replace all of the receiver’s subviews with a new set of subviews, or remove all the receiver’s subviews.
Given a valid array of views in newSubviews
, setSubviews:
performs any required sorting of the subviews array, as well as sending any addSubview:
and removeFromSuperview
messages as necessary to leave the receiver with the requested new array of subviews. Any member of newSubviews that isn't already a subview of the receiver is added. Any member of the view's existing subviews
array that isn't in newSubviews is removed. And any views that are in both subviews
and newSubviews are moved in the subviews array as needed, without being removed and re-added.
This method marks the affected view and window areas as needing display.
NSView.h
Sets the tool tip text for the view to string.
- (void)setToolTip:(NSString *)string
A string that contains the text to use for the tool tip. If nil
, it cancels tool tip display for the view.
NSView.h
Overridden by subclasses to (re)initialize the receiver’s graphics state object.
- (void)setUpGState
This method is automatically invoked when the graphics state object created using allocateGState
needs to be initialized. The default implementation does nothing. Your subclass can override it to set the current font, line width, or any other graphics state parameter except coordinate transformations and the clipping path—these are established by the frame and bounds rectangles and by methods such as scaleUnitSquareToSize:
and translateOriginToPoint:
. Note that drawRect:
can further transform the coordinate system and clipping path for whatever temporary effects it needs.
NSView.h
Specifes whether the receiver and its subviews use a Core Animation layer as a backing store.
- (void)setWantsLayer:(BOOL)flag
YES
if the receiver and its subviews should use a Core Animation layer as its backing store, otherwise NO
.
NSView.h
Returns the shadow drawn by the receiver
- (NSShadow *)shadow
An instance of NSShadow that is created using the shadowColor
,shadowOffset
, shadowOpacity
and shadowRadius
properties of the receiver’s layer.
Sending this message to a view that is not managing a Core Animation layer causes an exception.
NSView.h
Overridden by subclasses to allow the user to drag images from the receiver without its window moving forward and possibly obscuring the destination and without activating the application.
- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)theEvent
An object representing an initial mouse-down event.
If this method returns YES
, the normal window-ordering and activation mechanism is delayed (not necessarily prevented) until the next mouse-up event. If it returns NO
, then normal ordering and activation occur.
Never invoke this method directly; it’s invoked automatically for each mouse-down event directed at the NSView.
An NSView
subclass that allows dragging should implement this method to return YES
if theEvent is potentially the beginning of a dragging session or of some other context where window ordering isn’t appropriate. This method is invoked before a mouseDown:
message for theEvent is sent. The default implementation returns NO
.
If, after delaying window ordering, the receiver actually initiates a dragging session or similar operation, it should also send a preventWindowOrdering
message to NSApp
, which completely prevents the window from ordering forward and the activation from becoming active. preventWindowOrdering
is sent automatically by the NSView
dragImage:...
and dragFile:...
methods.
NSView.h
Returns NO
if the receiver is being drawn in an NSWindow
object (as opposed, for example, to being printed) and the window object can’t store color; otherwise returns YES
.
- (BOOL)shouldDrawColor
A view object can base its drawing behavior on the return value of this method to improve its appearance in grayscale windows.
– drawRect:
– canStoreColor
(NSWindow)NSView.h
Orders the receiver's immediate subviews using the specified comparator function.
- (void)sortSubviewsUsingFunction:(NSComparisonResult (*)(id, id, void *))compare context:(void *)context
A pointer to the comparator function. This function must take as arguments two subviews to be ordered and contextual data (supplied in context which may be arbitrary data used to help in the comparison. The comparator function should return NSOrderedAscending
if the first subview should be ordered lower, NSOrderedDescending
if the second subview should be ordered lower, and NSOrderedSame
if their ordering isn’t important.
Arbitrary data that might help the comparator function compare
in its decisions.
sortedArrayUsingFunction:context:
(NSArray
)NSView.h
Return the receiver’s immediate subviews.
- (NSArray *)subviews
Returns an array containing the receiver’s subviews.
The order of the subviews may be considered as being back-to-front, but this does not imply invalidation and drawing behavior. The order is based on the order of the receiver's subviews as specified in the nib file from which they were unarchived or the programmatic interface for modifying the receiver's subview list. This ordering is also the reverse of the order in which hit-testing is done.
Note: The contents of this array may change at any time. If you intend to manipulate this array you should copy it rather than simply retain.
NSView.h
Returns the receiver’s superview, or nil
if it has none.
- (NSView *)superview
When applying this method iteratively or recursively, be sure to compare the returned view object to the content view of the window to avoid proceeding out of the view hierarchy.
NSView.h
Returns the receiver’s tag, an integer that you can use to identify view objects in your application.
- (NSInteger)tag
The default implementation returns –1. Subclasses can override this method to provide individual tags, possibly adding storage and a setTag:
method (which NSView
doesn’t define).
NSView.h
Returns the text for the view’s tool tip.
- (NSString *)toolTip
The tool tip text or nil
if the view doesn’t currently display tool tip text
NSView.h
Returns an array of the receiver’s tracking areas.
- (NSArray *)trackingAreas
An array of the receiver’s tracking areas (instances of NSTrackingArea
). If the receiver has no tracking areas, returns an empty array.
NSView.h
Translates the receiver’s coordinate system so that its origin moves to a new location.
- (void)translateOriginToPoint:(NSPoint)newOrigin
A point that specifies the new origin.
In the process, the origin of the receiver’s bounds rectangle is shifted by (–
newOrigin.x
, –
newOrigin.y
). This method neither redisplays the receiver nor marks it as needing display. You must do this yourself with display
or setNeedsDisplay:
.
Note the difference between this method and setting the bounds origin. Translation effectively moves the image inside the bounds rectangle, while setting the bounds origin effectively moves the rectangle over the image. The two are in a sense inverse, although translation is cumulative, and setting the bounds origin is absolute.
This method posts an NSViewBoundsDidChangeNotification
to the default notification center if the receiver is configured to do so.
NSView.h
Translates the display rectangles by the specified delta.
- (void)translateRectsNeedingDisplayInRect:(NSRect)clipRectby:(NSSize)delta
A rectangle defining the region of the receiver, typically the receiver’s bounds.
A NSSize structure that specifies an offset from from aRect’s origin.
The method is similar to the scrollRect:by: method:
It collects the receiving view's dirty rectangles.
Clears all dirty rectangles in the intersection of clipRect and the view's bounds.
Shifts the retrieved rectangles by the delta offset.
Clips the result to the intersection of clipRect and the view's bounds
Draws the resultant rectangles in the view.
The developer must ensure that clipRect and delta are pixel-aligned in order to guarantee correct drawing. See View Coordinate Conversion in View Programming Guide for Cocoa for a description of how to pixel-align view coordinates.
Note: In most cases developers should use the scrollRect:by:
method instead.
NSView.h
Balances an earlier lockFocus
or lockFocusIfCanDraw
message; restoring the focus to the previously focused view is necessary.
- (void)unlockFocus
Raises an NSInvalidArgumentException
if invoked on the wrong view.
NSView.h
Unregisters the receiver as a possible destination in a dragging session.
- (void)unregisterDraggedTypes
NSView.h
Invoked automatically when the view’s geometry changes such that its tracking areas need to be recalculated.
- (void)updateTrackingAreas
You should override this method to remove out of date tracking areas and add recomputed tracking areas; your implementation should call super
.
NSView.h
Informs the receiver of the end of a live resize.
- (void)viewDidEndLiveResize
In the simple case, a view is sent viewWillStartLiveResize
before the first resize operation on the containing window and viewDidEndLiveResize
after the last resize operation. A view that is repeatedly added and removed from a window during live resize will receive only one viewWillStartLiveResize
(on the first time it is added to the window) and one viewDidEndLiveResize
(when the window has completed the live resize operation). This allows a superview such as NSBrowser
object to add and remove its NSMatrix
subviews during live resize without the NSMatrix
receiving multiple calls to these methods.
A view might allocate data structures to cache-drawing information in viewWillStartLiveResize
and should clean up these data structures in viewDidEndLiveResize
. In addition, a view that does optimized drawing during live resize might want to do full drawing after viewDidEndLiveResize
, although a view should not assume that it has a drawing context in viewDidEndLiveResize
(since it may have been removed from the window during live resize). A view that wants to redraw itself after live resize should call [self setNeedsDisplay:YES]
in viewDidEndLiveResize
.
A view subclass should call super
from these methods.
NSView.h
Invoked when the receiver is hidden, either directly, or in response to an ancestor being hidden.
- (void)viewDidHide
The receiver receives this message when its isHiddenOrHasHiddenAncestor
state goes from NO
to YES
. This will happen when the view or an ancestor is marked as hidden, or when the view or an ancestor is inserted into a new view hierarchy.
NSView.h
Informs the receiver that its superview has changed (possibly to nil
).
- (void)viewDidMoveToSuperview
The default implementation does nothing; subclasses can override this method to perform whatever actions are necessary.
NSView.h
Informs the receiver that it has been added to a new view hierarchy.
- (void)viewDidMoveToWindow
The default implementation does nothing; subclasses can override this method to perform whatever actions are necessary.
window
may return nil
when this method is invoked, indicating that the receiver does not currently reside in any window. This occurs when the receiver has just been removed from its superview or when the receiver has just been added to a superview that does not itself have a window. Overrides of this method may choose to ignore such cases if they are not of interest.
NSView.h
Invoked when the receiver is unhidden, either directly, or in response to an ancestor being unhidden
- (void)viewDidUnhide
The receiver receives this message when its isHiddenOrHasHiddenAncestor state goes from YES
to NO
. This can happen when the view or an ancestor is marked as not hidden, or when the view or an ancestor is removed from its containing view hierarchy.
NSView.h
Informs the receiver that it will be required to draw content.
- (void)viewWillDraw
In response to receiving one of the display... messages the receiver will recurse down the view hierarchy, sending this message to each of the views that may be involved in the display operation.
Subclasses can override this method to move or resize views, mark additional areas as requiring display, or other actions that can best be deferred until they are required for drawing. During the recursion, sending of setNeedsDisplay:
and setNeedsDisplayInRect:
messages to views in the hierarchy that's about to be drawn is valid and supported, and will affect the assessment of the total area to be rendered in that drawing pass.
A subclass’s implementation of viewWillDraw
can use the existing NSView getRectsBeingDrawn:count:
method to obtain a list of rectangles that bound the affected area, enabling it to restrict its efforts to that area.
The following is an example of a generic subclass implementation:
- (void)viewWillDraw { |
// Perform some operations before recursing for descendants. |
// Now recurse to handle all our descendants. |
// Overrides must call up to super like this. |
[super viewWillDraw]; |
// Perform some operations that might depend on descendants |
// already having had a chance to update. |
} |
NSView.h
Informs the receiver that its superview is about to change to the specified superview (which may be nil
).
- (void)viewWillMoveToSuperview:(NSView *)newSuperview
A view object that will be the new superview of the receiver.
Subclasses can override this method to perform whatever actions are necessary.
NSView.h
Informs the receiver that it’s being added to the view hierarchy of the specified window object (which may be nil
).
- (void)viewWillMoveToWindow:(NSWindow *)newWindow
A window object that will be at the root of the receiver's new view hierarchy.
Subclasses can override this method to perform whatever actions are necessary.
NSView.h
Informs the receiver of the start of a live resize.
- (void)viewWillStartLiveResize
In the simple case, a view is sent viewWillStartLiveResize
before the first resize operation on the containing window and viewDidEndLiveResize
after the last resize operation. A view that is repeatedly added and removed from a window during live resize will receive only one viewWillStartLiveResize
(on the first time it is added to the window) and one viewDidEndLiveResize
(when the window has completed the live resize operation). This allows a superview such as NSBrowser
object to add and remove its NSMatrix
subviews during live resize without the NSMatrix
object receiving multiple calls to these methods.
A view might allocate data structures to cache-drawing information in viewWillStartLiveResize
and should clean up these data structures in viewDidEndLiveResize
. In addition, a view that does optimized drawing during live resize might want to do full drawing after viewDidEndLiveResize
, although a view should not assume that it has a drawing context in viewDidEndLiveResize
(since it may have been removed from the window during live resize). A view that wants to redraw itself after live resize should call [self setNeedsDisplay:YES]
in viewDidEndLiveResize
.
A view subclass should call super
from these methods.
NSView.h
Returns the receiver’s nearest descendant (including itself) with a specific tag, or nil
if no subview has that tag.
- (id)viewWithTag:(NSInteger)aTag
An integer identifier associated with a view object.
NSView.h
Returns the portion of the receiver not clipped by its superviews.
- (NSRect)visibleRect
A rectangle defining the unclipped portion of the receiver.
Visibility for this method is defined quite simply and doesn’t account for whether other NSView
objects (or windows) overlap the receiver or whether the receiver has a window at all. This method returns NSZeroRect
if the receiver is effectively hidden.
During a printing operation the visible rectangle is further clipped to the page being imaged.
– setHidden:
– isVisible
(NSWindow)– documentVisibleRect
(NSScrollView)– documentVisibleRect
(NSClipView)NSView.h
Returns whether the Application Kit’s default clipping provided to drawRect:
implementations is in effect.
- (BOOL)wantsDefaultClipping
YES
if the default clipping is in effect, NO
otherwise. By default, this method returns YES
.
Subclasses may override this method to return NO
if they want to suppress the default clipping. They may want to do this in situations where drawing performance is critical to avoid the cost of setting up, enforcing, and cleaning up the clip path
A view that overrides this method to refuse the default clipping must either set up whatever clipping it requires or constrain its drawing exactly to the list of rectangles returned by getRectsBeingDrawn:count:
. Failing to do so could result in corruption of other drawing in the view’s window.
NSView.h
Returns a Boolean value that indicates whether the receiver is using a layer as it’s backing store.
- (BOOL)wantsLayer
YES
if the receiver is using a Core Animation layer as its backing store, otherwise NO
.
NSView.h
Returns the fraction (from 0.0 to 1.0) of the page that can be pushed onto the next page during automatic pagination to prevent items such as small images or text columns from being divided across pages.
- (CGFloat)widthAdjustLimit
This fraction is used to calculate the right edge limit for a adjustPageWidthNew:left:right:limit:
message.
NSView.h
Overridden by subclasses to perform additional actions before subviews are removed from the receiver.
- (void)willRemoveSubview:(NSView *)subview
The subview that will be removed.
This method is invoked when subview receives a removeFromSuperview
message or subview is removed from the receiver due to it being added to another view with addSubview:
.
NSView.h
Returns the receiver’s window object, or nil
if it has none.
- (NSWindow *)window
NSView.h
Writes EPS data that draws the region of the receiver within a specified rectangle onto a pasteboard.
- (void)writeEPSInsideRect:(NSRect)aRect toPasteboard:(NSPasteboard *)pboard
A rectangle defining the region.
An object representing a pasteboard.
NSView.h
Writes PDF data that draws the region of the receiver within a specified rectangle onto a pasteboard.
- (void)writePDFInsideRect:(NSRect)aRect toPasteboard:(NSPasteboard *)pboard
A rectangle defining the region.
An object representing a pasteboard.
NSView.h
These constants specify the type of a view’s border.
typedef enum _NSBorderType { NSNoBorder = 0, NSLineBorder = 1, NSBezelBorder = 2, NSGrooveBorder = 3 } NSBorderType;
NSBezelBorder
A concave border that makes the view look sunken.
Available in Mac OS X v10.0 and later.
Declared in NSView.h
.
NSGrooveBorder
A thin border that looks etched around the image.
Available in Mac OS X v10.0 and later.
Declared in NSView.h
.
NSLineBorder
A black line border around the view.
Available in Mac OS X v10.0 and later.
Declared in NSView.h
.
NSNoBorder
No border.
Available in Mac OS X v10.0 and later.
Declared in NSView.h
.
NSView.h
These constants are used by setAutoresizingMask:
.
enum { NSViewNotSizable = 0, NSViewMinXMargin = 1, NSViewWidthSizable = 2, NSViewMaxXMargin = 4, NSViewMinYMargin = 8, NSViewHeightSizable = 16, NSViewMaxYMargin = 32 };
NSViewNotSizable
The receiver cannot be resized.
Available in Mac OS X v10.0 and later.
Declared in NSView.h
.
NSViewMinXMargin
The left margin between the receiver and its superview is flexible.
Available in Mac OS X v10.0 and later.
Declared in NSView.h
.
NSViewWidthSizable
The receiver’s width is flexible.
Available in Mac OS X v10.0 and later.
Declared in NSView.h
.
NSViewMaxXMargin
The right margin between the receiver and its superview is flexible.
Available in Mac OS X v10.0 and later.
Declared in NSView.h
.
NSViewMinYMargin
The bottom margin between the receiver and its superview is flexible.
Available in Mac OS X v10.0 and later.
Declared in NSView.h
.
NSViewHeightSizable
The receiver’s height is flexible.
Available in Mac OS X v10.0 and later.
Declared in NSView.h
.
NSViewMaxYMargin
The top margin between the receiver and its superview is flexible.
Available in Mac OS X v10.0 and later.
Declared in NSView.h
.
NSView.h
This type describes the rectangle used to identify a tool tip rectangle.
typedef NSInteger NSToolTipTag;
See the methods addToolTipRect:owner:userData:
andremoveToolTip:
.
NSView.h
This type describes the rectangle used to track the mouse.
typedef NSInteger NSTrackingRectTag;
See the methods addTrackingRect:owner:userData:assumeInside:
and removeTrackingRect:
.
NSView.h
These constants are keys that you can use in the options dictionary in enterFullScreenMode:withOptions:
and exitFullScreenModeWithOptions:
.
NSString * const NSFullScreenModeAllScreens; NSString * const NSFullScreenModeSetting; NSString * const NSFullScreenModeWindowLevel;
NSFullScreenModeAllScreens
Key whose corresponding value specifies whether the view should take over all screens.
The corresponding value is an instance of NSNumber
containing a Boolean value.
Available in Mac OS X v10.5 and later.
Declared in NSView.h
.
NSFullScreenModeSetting
Key whose corresponding value specifies the the full screen mode setting.
The corresponding value is an instance of NSDictionary
that contains keys specified in Display Mode Standard Properties
and Display Mode Optional Properties
in Quartz Display Services Reference.
Available in Mac OS X v10.5 and later.
Declared in NSView.h
.
NSFullScreenModeWindowLevel
Key whose corresponding value specifies the screen mode window level.
The corresponding value is an instance of NSNumber
containing an integer value.
Available in Mac OS X v10.5 and later.
Declared in NSView.h
.
NSView.h
Posted whenever the NSView
’s bounds rectangle changes independently of the frame rectangle, if the NSView
is configured using setPostsBoundsChangedNotifications:
to post such notifications.
The notification object is the NSView
object whose bounds rectangle has changed. This notification does not contain a userInfo dictionary.
The following methods can result in notification posting:
Note that the bounds rectangle resizes automatically to track the frame rectangle. Because the primary change is that of the frame rectangle, however, setFrame:
and setFrameSize:
don’t result in a bounds-changed notification.
NSView.h
Deprecated notification that was posted for an NSView
object and each of its descendants (recursively) whenever the frame or bounds geometry of the view changed.
In Mac OS X v10.4 and later, this notification is no longer posted. In earlier version of Mac OS X, use NSViewBoundsDidChangeNotification
and NSViewFrameDidChangeNotification
instead to get the same information provided by this notification.
The notification object is the view whose geometry changed. This notification does not contain a userInfo dictionary.
NSView.h
Posted whenever the view’s frame rectangle changes, if the view is configured using setPostsFrameChangedNotifications:
to post such notifications.
The notification object is the NSView
object whose frame rectangle has changed. This notification does not contain a userInfo dictionary.
The following methods can result in notification posting:
NSView.h
Posted whenever an NSView
object recalculates its tracking areas. It is sent after the view receives updateTrackingAreas
.
NSView.h
Posted whenever an NSView
object that has attached surfaces (that is, NSOpenGLContext
objects) moves to a different screen, or other cases where the NSOpenGLContext
object needs to be updated. The notification object is the surface’s view. This notification does not contain a userInfo dictionary.
NSView.h
© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-02-04)