NSView

NSView Mac OS X 10.0

This is the Cocoa interface to Mac OS X's graphics APIs, including Quartz 2D, OpenGL (using NSOpenGLView), and QuickDraw (using NSQuickDrawView). Anything that is drawn to screen in Cocoa is done so within a view object. Developers can implement custom drawing behavior by subclassing NSView and overriding the drawRect: method. See Chapter 3 for more information on how views relate to other classes in the AppKit.

figs/cocn_15114.gif

@interface NSView : NSResponder
 // Initializers
   - (id)initWithFrame:(NSRect)frameRect;
 // Accessor Methods
   - (void)setBoundsSize:(NSSize)newSize;
   - (void)setFrameOrigin:(NSPoint)newOrigin;
   - (void)setFrame:(NSRect)frameRect;
   - (NSRect)frame;
   - (void)setAutoresizingMask:(unsigned int)mask;
   - (unsigned int)autoresizingMask;
   - (void)setUpGState;
   - (void)setBoundsRotation:(float)angle;
   - (float)boundsRotation;
   - (void)setAutoresizesSubviews:(BOOL)flag;
   - (BOOL)autoresizesSubviews;
   - (void)setNeedsDisplayInRect:(NSRect)invalidRect;
   - (void)setBoundsOrigin:(NSPoint)newOrigin;
   - (void)setFrameRotation:(float)angle;
   - (float)frameRotation;
   - (void)setNeedsDisplay:(BOOL)flag;
   - (BOOL)needsDisplay;
   - (void)setToolTip:(NSString *)string;
   - (NSString *)toolTip;
   - (void)setFrameSize:(NSSize)newSize;
   - (void)setBounds:(NSRect)aRect;
   - (NSRect)bounds;
   - (void)setPostsFrameChangedNotifications:(BOOL)flag;
   - (BOOL)postsFrameChangedNotifications;
   - (void)setPostsBoundsChangedNotifications:(BOOL)flag;
   - (BOOL)postsBoundsChangedNotifications;
 // Class Methods
   + (NSMenu *)defaultMenu;
   + (NSView *)focusView;
 // Instance Methods
   - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent;
   - (NSView *)ancestorSharedWithView:(NSView *)aView;
   - (void)addSubview:(NSView *)aView;
   - (void)addSubview:(NSView *)aView positioned:(NSWindowOrderingMode)place relativeTo:(NSView *)otherView;
   - (void)allocateGState;
   - (NSToolTipTag)addToolTipRect:(NSRect)aRect owner:(id)anObject userData:(void *)data;
   - (void)addCursorRect:(NSRect)aRect cursor:(NSCursor *)anObj;
   - (NSTrackingRectTag)addTrackingRect:(NSRect)aRect owner:(id)anObject userData:(void *)data
        assumeInside:(BOOL)flag;
   - (BOOL)autoscroll:(NSEvent *)theEvent;
   - (void)beginDocument;
   - (void)beginPageInRect:(NSRect)aRect atPlacement:(NSPoint)location;
   - (BOOL)canDraw;
   - (void)adjustPageHeightNew:(float *)newBottom top:(float)oldTop bottom:(float)oldBottom
        limit:(float)bottomLimit;
   - (void)adjustPageWidthNew:(float *)newRight left:(float)oldLeft right:(float)oldRight limit:(float)rightLimit;
   - (NSRect)adjustScroll:(NSRect)newVisible;
   - (NSRect)centerScanRect:(NSRect)aRect;
   - (NSPoint)convertPoint:(NSPoint)aPoint fromView:(NSView *)aView;
   - (NSPoint)convertPoint:(NSPoint)aPoint toView:(NSView *)aView;
   - (NSRect)convertRect:(NSRect)aRect fromView:(NSView *)aView;
   - (NSRect)convertRect:(NSRect)aRect toView:(NSView *)aView;
   - (NSSize)convertSize:(NSSize)aSize fromView:(NSView *)aView;
   - (NSSize)convertSize:(NSSize)aSize toView:(NSView *)aView;
   - (NSData *)dataWithEPSInsideRect:(NSRect)rect;
   - (NSData *)dataWithPDFInsideRect:(NSRect)rect;
   - (void)didAddSubview:(NSView *)subview;
   - (void)discardCursorRects;
   - (void)display;
   - (void)displayIfNeeded;
   - (void)displayIfNeededIgnoringOpacity;
   - (void)displayIfNeededInRect:(NSRect)rect;
   - (void)displayIfNeededInRectIgnoringOpacity:(NSRect)rect;
   - (void)displayRect:(NSRect)rect;
   - (void)displayRectIgnoringOpacity:(NSRect)rect;
   - (void)drawPageBorderWithSize:(NSSize)borderSize;
   - (void)drawRect:(NSRect)rect;
   - (void)drawSheetBorderWithSize:(NSSize)borderSize;
   - (NSScrollView *)enclosingScrollView;
   - (void)endDocument;
   - (void)endPage;
   - (int)gState;
   - (float)heightAdjustLimit;
   - (NSView *)hitTest:(NSPoint)aPoint;
   - (BOOL)inLiveResize;
   - (BOOL)isDescendantOf:(NSView *)aView;
   - (BOOL)isFlipped;
   - (BOOL)isOpaque;
   - (BOOL)isRotatedFromBase;
   - (BOOL)isRotatedOrScaledFromBase;
   - (BOOL)knowsPageRange:(NSRangePointer)range;
   - (NSPoint)locationOfPrintRect:(NSRect)aRect;
   - (void)lockFocus;
   - (BOOL)lockFocusIfCanDraw;
   - (NSMenu *)menuForEvent:(NSEvent *)event;
   - (BOOL)mouse:(NSPoint)aPoint inRect:(NSRect)aRect;
   - (BOOL)mouseDownCanMoveWindow;
   - (BOOL)needsPanelToBecomeKey;
   - (NSView *)opaqueAncestor;
   - (BOOL)performKeyEquivalent:(NSEvent *)theEvent;
   - (void)print:(id)sender;
   - (NSString *)printJobTitle;
   - (NSRect)rectForPage:(int)page;
   - (void)reflectScrolledClipView:(NSClipView *)aClipView;
   - (void)releaseGState;
   - (void)removeAllToolTips;
   - (void)removeCursorRect:(NSRect)aRect cursor:(NSCursor *)anObj;
   - (void)removeFromSuperview;
   - (void)removeFromSuperviewWithoutNeedingDisplay;
   - (void)removeToolTip:(NSToolTipTag)tag;
   - (void)removeTrackingRect:(NSTrackingRectTag)tag;
   - (void)renewGState;
   - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView;
   - (void)resetCursorRects;
   - (void)resizeSubviewsWithOldSize:(NSSize)oldSize;
   - (void)resizeWithOldSuperviewSize:(NSSize)oldSize;
   - (void)rotateByAngle:(float)angle;
   - (void)scaleUnitSquareToSize:(NSSize)newUnitSize;
   - (void)scrollClipView:(NSClipView *)aClipView toPoint:(NSPoint)aPoint;
   - (void)scrollPoint:(NSPoint)aPoint;
   - (void)scrollRect:(NSRect)aRect by:(NSSize)delta;
   - (BOOL)scrollRectToVisible:(NSRect)aRect;
   - (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)theEvent;
   - (BOOL)shouldDrawColor;
   - (void)sortSubviewsUsingFunction:(int (*)(id, id, void *))compare context:(void *)context;
   - (NSArray *)subviews;
   - (NSView *)superview;
   - (int)tag;
   - (void)translateOriginToPoint:(NSPoint)translation;
   - (void)unlockFocus;
   - (void)viewDidEndLiveResize;
   - (void)viewDidMoveToSuperview;
   - (void)viewDidMoveToWindow;
   - (void)viewWillMoveToSuperview:(NSView *)newSuperview;
   - (void)viewWillMoveToWindow:(NSWindow *)newWindow;
   - (void)viewWillStartLiveResize;
   - (id)viewWithTag:(int)aTag;
   - (NSRect)visibleRect;
   - (float)widthAdjustLimit;
   - (void)willRemoveSubview:(NSView *)subview;
   - (NSWindow *)window;
   - (void)writeEPSInsideRect:(NSRect)rect toPasteboard:(NSPasteboard *)pasteboard;
   - (void)writePDFInsideRect:(NSRect)rect toPasteboard:(NSPasteboard *)pasteboard;
// Notifications
   NSViewBoundsDidChangeNotification;
   NSViewFocusDidChangeNotification;
   NSViewFrameDidChangeNotification;
   NSViewGlobalFrameDidChangeNotification;

Subclasses

NSBox, NSClipView, NSControl, NSMenuView, NSMovieView, NSOpenGLView, NSProgressIndicator, NSQuickDrawView, NSRulerView, NSScrollView, NSSplitView, NSTabView, NSTableHeaderView, NSText



    Part II: API Quick Reference
    Chapter 13. Foundation Classes