NSView

Authors

Scott Christley( scottc@net-community.com )
Felipe A. Rodriguez( far@ix.netcom.com )
Ovidiu Predescu( ovidiu@net-community.com )
Richard Frith-Macdonald( richard@brainstorm.co.uk )
The view class which encapsulates all drawing functionality

Copyright: (C) (C) 1996 Free Software Foundation, Inc.

NSView

NSView is an abstract class which provides facilities for drawing in a window and receiving events. It is the superclass of many of the visual elements of the GUI.

In order to display itself, a view must be placed in a window (represented by an NSWindow object). Within the window is a hierarchy of NSViews, headed by the window's content view. Every other view in a window is a descendant of this view.

Subclasses can override drawRect: in order to implement their appearance. Other methods of NSView and NSResponder can also be overridden to handle user generated events.

NSView : NSResponder

Declared: AppKit/NSView.h

defaultMenu

+ (NSMenu*) defaultMenu;


focusView

+ (NSView*) focusView;

Return the view at the top of graphics contexts stack or nil if none is focused.


acceptsFirstMouse:

- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent;

Returns YES if the view object will accept the first click received when in an inactive window, and NO otherwise.


addCursorRect:cursor:

- (void) addCursorRect: (NSRect)aRect cursor: (NSCursor*)anObject;


addSubview:

- (void) addSubview: (NSView*)aView;

Adds aView as a subview of the receiver.


addSubview:positioned:relativeTo:

- (void) addSubview: (NSView*)aView positioned: (NSWindowOrderingMode)place relativeTo: (NSView*)otherView;


addToPageSetup

- (void) addToPageSetup;


addToolTipRect:owner:userData:

- (NSToolTipTag) addToolTipRect: (NSRect)aRect owner: (id)anObject userData: (void*)data;


addTrackingRect:owner:userData:assumeInside:

- (NSTrackingRectTag) addTrackingRect: (NSRect)aRect owner: (id)anObject userData: (void*)data assumeInside: (BOOL)flag;


adjustPageHeightNew:top:bottom:limit:

- (void) adjustPageHeightNew: (float*)newBottom top: (float)oldTop bottom: (float)oldBottom limit: (float)bottomLimit;


adjustPageWidthNew:left:right:limit:

- (void) adjustPageWidthNew: (float*)newRight left: (float)oldLeft right: (float)oldRight limit: (float)rightLimit;


adjustScroll:

- (NSRect) adjustScroll: (NSRect)newVisible;


allocateGState

- (void) allocateGState;


ancestorSharedWithView:

- (NSView*) ancestorSharedWithView: (NSView*)aView;

Returns self if aView is the receiver or aView is a subview of the receiver, the ancestor view shared by aView and the receiver, if any, aView if it is an ancestor of the receiver, otherwise returns nil.


autoresizesSubviews

- (BOOL) autoresizesSubviews;


autoresizingMask

- (unsigned int) autoresizingMask;


autoscroll:

- (BOOL) autoscroll: (NSEvent*)theEvent;


beginDocument

- (void) beginDocument;

Writes header and job information for the PostScript document. This includes at a minimum, PostScript header information. It may also include job setup information if the output is intended for a printer (i.e. not an EPS file). Most of the information for writing the header comes from the NSPrintOperation and NSPrintInfo objects associated with the current print operation. There isn't normally anything that the program needs to override at the beginning of a document, although if there is additional setup that needs to be done, you can override the NSView's methods endHeaderComments, endPrologue, beginSetup, and/or endSetup. This method calls the above methods in the listed order before or after writing the required information. For an EPS operation, the beginSetup and endSetup methods aren't used.


beginPage:label:bBox:fonts:

- (void) beginPage: (int)ordinalNum label: (NSString*)aString bBox: (NSRect)pageRect fonts: (NSString*)fontNames;


beginPageInRect:atPlacement:

- (void) beginPageInRect: (NSRect)aRect atPlacement: (NSPoint)location;


beginPageSetupRect:placement:

- (void) beginPageSetupRect: (NSRect)aRect placement: (NSPoint)location;


beginPrologueBBox:creationDate:createdBy:fonts:forWhom:pages:title:

- (void) beginPrologueBBox: (NSRect)bBox creationDate: (NSString*)dateCreated createdBy: (NSString*)anApplication fonts: (NSString*)fontNames forWhom: (NSString*)user pages: (int)numPages title: (NSString*)aTitle;


beginSetup

- (void) beginSetup;


beginTrailer

- (void) beginTrailer;


bounds

- (NSRect) bounds;


boundsRotation

- (float) boundsRotation;


canDraw

- (BOOL) canDraw;


centerScanRect:

- (NSRect) centerScanRect: (NSRect)aRect;


convertPoint:fromView:

- (NSPoint) convertPoint: (NSPoint)aPoint fromView: (NSView*)aView;


convertPoint:toView:

- (NSPoint) convertPoint: (NSPoint)aPoint toView: (NSView*)aView;


convertRect:fromView:

- (NSRect) convertRect: (NSRect)aRect fromView: (NSView*)aView;


convertRect:toView:

- (NSRect) convertRect: (NSRect)aRect toView: (NSView*)aView;


convertSize:fromView:

- (NSSize) convertSize: (NSSize)aSize fromView: (NSView*)aView;


convertSize:toView:

- (NSSize) convertSize: (NSSize)aSize toView: (NSView*)aView;


dataWithEPSInsideRect:

- (NSData*) dataWithEPSInsideRect: (NSRect)aRect;


dataWithPDFInsideRect:

- (NSData*) dataWithPDFInsideRect: (NSRect)aRect;


didAddSubview:

- (void) didAddSubview: (NSView*)subview;


discardCursorRects

- (void) discardCursorRects;


display

- (void) display;


displayIfNeeded

- (void) displayIfNeeded;


displayIfNeededIgnoringOpacity

- (void) displayIfNeededIgnoringOpacity;


displayIfNeededInRect:

- (void) displayIfNeededInRect: (NSRect)aRect;


displayIfNeededInRectIgnoringOpacity:

- (void) displayIfNeededInRectIgnoringOpacity: (NSRect)aRect;


displayRect:

- (void) displayRect: (NSRect)rect;


displayRectIgnoringOpacity:

- (void) displayRectIgnoringOpacity: (NSRect)aRect;


dragFile:fromRect:slideBack:event:

- (BOOL) dragFile: (NSString*)filename fromRect: (NSRect)rect slideBack: (BOOL)slideFlag event: (NSEvent*)event;


dragImage:at:offset:event:pasteboard:source:slideBack:

- (void) dragImage: (NSImage*)anImage at: (NSPoint)viewLocation offset: (NSSize)initialOffset event: (NSEvent*)event pasteboard: (NSPasteboard*)pboard source: (id)sourceObject slideBack: (BOOL)slideFlag;


drawPageBorderWithSize:

- (void) drawPageBorderWithSize: (NSSize)borderSize;


drawRect:

- (void) drawRect: (NSRect)rect;

This method is invoked to handle drawing inside the view. The default NSView's implementation does nothing; subclasses might override it to draw something inside the view. Since NSView's implementation is guaranteed to be empty, you should not call super's implementation when you override it in subclasses. drawRect: is invoked when the focus has already been locked on the view; you can use arbitrary postscript functions in drawRect: to draw inside your view; the coordinate system in which you draw is the view's own coordinate system (this means for example that you should refer to the rectangle covered by the view using its bounds, and not its frame). The argument of drawRect: is the rectangle which needs to be redrawn. In a lossy implementation, you can ignore the argument and redraw the whole view; if you are aiming at performance, you may want to redraw only what is inside the rectangle which needs to be redrawn; this usually improves drawing performance considerably.


drawSheetBorderWithSize:

- (void) drawSheetBorderWithSize: (NSSize)borderSize;


enclosingScrollView

- (NSScrollView*) enclosingScrollView;


endDocument

- (void) endDocument;


endHeaderComments

- (void) endHeaderComments;


endPage

- (void) endPage;


endPageSetup

- (void) endPageSetup;


endPrologue

- (void) endPrologue;


endSetup

- (void) endSetup;


endTrailer

- (void) endTrailer;


fax:

- (void) fax: (id)sender;


frame

- (NSRect) frame;


frameRotation

- (float) frameRotation;


gState

- (int) gState;

Returns an identifier that represents the view's gstate object, which is used to encapsulate drawing information about the view. Most of the time a gstate object is created from scratch when the view is focused, so if the view is not currently focused or allocateGState has not been called, then this method will


heightAdjustLimit

- (float) heightAdjustLimit;


hitTest:

- (NSView*) hitTest: (NSPoint)aPoint;

Returns the subview, lowest in the receiver's hierarchy, which contains aPoint


initWithFrame:

- (id) initWithFrame: (NSRect)frameRect;


isDescendantOf:

- (BOOL) isDescendantOf: (NSView*)aView;

Returns YES if aView is an ancestor of the receiver.


isFlipped

- (BOOL) isFlipped;


isOpaque

- (BOOL) isOpaque;


isRotatedFromBase

- (BOOL) isRotatedFromBase;


isRotatedOrScaledFromBase

- (BOOL) isRotatedOrScaledFromBase;


knowsPageRange:

- (BOOL) knowsPageRange: (NSRange*)range;


knowsPagesFirst:last:

- (BOOL) knowsPagesFirst: (int*)firstPageNum last: (int*)lastPageNum;


locationOfPrintRect:

- (NSPoint) locationOfPrintRect: (NSRect)aRect;


lockFocus

- (void) lockFocus;


lockFocusIfCanDraw

- (BOOL) lockFocusIfCanDraw;


menuForEvent:

- (NSMenu*) menuForEvent: (NSEvent*)theEvent;


mouse:inRect:

- (BOOL) mouse: (NSPoint)aPoint inRect: (NSRect)aRect;

Returns whether or not aPoint lies within aRect


needsDisplay

- (BOOL) needsDisplay;


nextKeyView

- (NSView*) nextKeyView;


nextValidKeyView

- (NSView*) nextValidKeyView;


opaqueAncestor

- (NSView*) opaqueAncestor;


performKeyEquivalent:

- (BOOL) performKeyEquivalent: (NSEvent*)theEvent;


performMnemonic:

- (BOOL) performMnemonic: (NSString*)aString;


postsBoundsChangedNotifications

- (BOOL) postsBoundsChangedNotifications;


postsFrameChangedNotifications

- (BOOL) postsFrameChangedNotifications;


previousKeyView

- (NSView*) previousKeyView;


previousValidKeyView

- (NSView*) previousValidKeyView;


print:

- (void) print: (id)sender;


printJobTitle

- (NSString*) printJobTitle;


rectForPage:

- (NSRect) rectForPage: (int)page;


reflectScrolledClipView:

- (void) reflectScrolledClipView: (NSClipView*)aClipView;


registerForDraggedTypes:

- (void) registerForDraggedTypes: (NSArray*)types;


releaseGState

- (void) releaseGState;

Frees the gstate object, if there is one. Note that the next time the view is lockFocused, the gstate will be allocated again.


removeAllToolTips

- (void) removeAllToolTips;


removeCursorRect:cursor:

- (void) removeCursorRect: (NSRect)aRect cursor: (NSCursor*)anObject;


removeFromSuperview

- (void) removeFromSuperview;


removeFromSuperviewWithoutNeedingDisplay

- (void) removeFromSuperviewWithoutNeedingDisplay;

Removes the receiver from its superviews list of subviews, by invoking the superviews [ -removeSubview: ] method.


removeSubview:

- (void) removeSubview: (NSView*)aSubview;
Standards: text p text p text


removeToolTip:

- (void) removeToolTip: (NSToolTipTag)tag;


removeTrackingRect:

- (void) removeTrackingRect: (NSTrackingRectTag)tag;


renewGState

- (void) renewGState;

Invalidates the view's gstate object so it will be set up again using setUpGState the next time the view is focused.


replaceSubview:with:

- (void) replaceSubview: (NSView*)oldView with: (NSView*)newView;

Removes oldView from the receiver and places newView in its place.


resetCursorRects

- (void) resetCursorRects;


resizeSubviewsWithOldSize:

- (void) resizeSubviewsWithOldSize: (NSSize)oldSize;


resizeWithOldSuperviewSize:

- (void) resizeWithOldSuperviewSize: (NSSize)oldSize;


rotateByAngle:

- (void) rotateByAngle: (float)angle;


scaleUnitSquareToSize:

- (void) scaleUnitSquareToSize: (NSSize)newSize;


scrollClipView:toPoint:

- (void) scrollClipView: (NSClipView*)aClipView toPoint: (NSPoint)aPoint;


scrollPoint:

- (void) scrollPoint: (NSPoint)aPoint;


scrollRect:by:

- (void) scrollRect: (NSRect)aRect by: (NSSize)delta;


scrollRectToVisible:

- (BOOL) scrollRectToVisible: (NSRect)aRect;


setAutoresizesSubviews:

- (void) setAutoresizesSubviews: (BOOL)flag;


setAutoresizingMask:

- (void) setAutoresizingMask: (unsigned int)mask;


setBounds:

- (void) setBounds: (NSRect)aRect;


setBoundsOrigin:

- (void) setBoundsOrigin: (NSPoint)newOrigin;


setBoundsRotation:

- (void) setBoundsRotation: (float)angle;


setBoundsSize:

- (void) setBoundsSize: (NSSize)newSize;


setFrame:

- (void) setFrame: (NSRect)frameRect;


setFrameOrigin:

- (void) setFrameOrigin: (NSPoint)newOrigin;


setFrameRotation:

- (void) setFrameRotation: (float)angle;


setFrameSize:

- (void) setFrameSize: (NSSize)newSize;


setNeedsDisplay:

- (void) setNeedsDisplay: (BOOL)flag;


setNeedsDisplayInRect:

- (void) setNeedsDisplayInRect: (NSRect)rect;


setNextKeyView:

- (void) setNextKeyView: (NSView*)aView;


setPostsBoundsChangedNotifications:

- (void) setPostsBoundsChangedNotifications: (BOOL)flag;


setPostsFrameChangedNotifications:

- (void) setPostsFrameChangedNotifications: (BOOL)flag;


setPreviousKeyView:

- (void) setPreviousKeyView: (NSView*)aView;


setToolTip:

- (void) setToolTip: (NSString*)string;


setUpGState

- (void) setUpGState;


shouldDelayWindowOrderingForEvent:

- (BOOL) shouldDelayWindowOrderingForEvent: (NSEvent*)anEvent;


shouldDrawColor

- (BOOL) shouldDrawColor;


sortSubviewsUsingFunction:context:

- (void) sortSubviewsUsingFunction: (int (*)(id,id,void*))compare context: (void*)context;


subviews

- (NSArray*) subviews;


superview

- (NSView*) superview;


tag

- (int) tag;


toolTip

- (NSString*) toolTip;


translateOriginToPoint:

- (void) translateOriginToPoint: (NSPoint)point;


unlockFocus

- (void) unlockFocus;


unregisterDraggedTypes

- (void) unregisterDraggedTypes;


viewDidMoveToSuperview

- (void) viewDidMoveToSuperview;


viewDidMoveToWindow

- (void) viewDidMoveToWindow;


viewWillMoveToSuperview:

- (void) viewWillMoveToSuperview: (NSView*)newSuper;

Notifies the receiver that its superview is being changed to newSuperview.


viewWillMoveToWindow:

- (void) viewWillMoveToWindow: (NSWindow*)newWindow;

Notifies the receiver that it will now be a view of newWindow. Note, this method is also used when removing a view from a window (in which case, newWindow is nil) to let all the subviews know that they have also been removed from the window.


viewWithTag:

- (id) viewWithTag: (int)aTag;


visibleRect

- (NSRect) visibleRect;


widthAdjustLimit

- (float) widthAdjustLimit;


willRemoveSubview:

- (void) willRemoveSubview: (NSView*)subview;


window

- (NSWindow*) window;

Returns the window in which the receiver resides.


writeEPSInsideRect:toPasteboard:

- (void) writeEPSInsideRect: (NSRect)rect toPasteboard: (NSPasteboard*)pasteboard;


writePDFInsideRect:toPasteboard:

- (void) writePDFInsideRect: (NSRect)aRect toPasteboard: (NSPasteboard*)pboard;


Software documentation for the NSView(PrivateMethods) category

NSView(PrivateMethods)

Declared: AppKit/NSView.h

_invalidateCoordinates

- (void) _invalidateCoordinates;


_matrixFromWindow

- (NSAffineTransform*) _matrixFromWindow;


_matrixToWindow

- (NSAffineTransform*) _matrixToWindow;


_rebuildCoordinates

- (void) _rebuildCoordinates;