[Previous]
[Up]
[Next]
NSView
Authors
- Richard Frith-Macdonald
-
- James Dessart
-
- Nicola Pero
-
Version: $Revision$
Date: $Date$
Declared in: Gui/NSView.h
Inherits from: NSResponder
Conforms to: NSCoding
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.
Instance Variables
Methods
Class Methods
+ (NSMenu*) defaultMenu;
As of yet, unimplemented.
+ (NSView*) focusView;
Returns the view which currently has the focus.
Instances Methods
- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent;
Returns YES
if the view object will accept the first click
received when in an inactive window, and NO
otherwise.
- (void) addCursorRect: (NSRect)aRect cursor: (NSCursor*)aCursor;
- (void) addSubview: (NSView*)aView;
Adds aView as a subview of the receiver.
- (void) addSubview: (NSView*)aView positioned: (NSWindowOrderingMode)place relativeTo: (NSView*)otherView;
- (void) addToPageSetup;
- (NSTrackingRectTag) addTrackingRect: (NSRect)aRect owner: (id)anObject userData: (void*)userData assumeInside: (BOOL)flag;
- (void) adjustPageHeightNew: (float*)newBottom top: (float)top bottom: (float)proposedBottom;
- (void) adjustPageWidthNew: (float*)newRight left: (float)left right: (float)proposedRight;
- (NSRect) adjustScroll: (NSRect)proposedVisibleRect;
- (void) allocateGState;
Tell the view to maintain a private gstate object which
encapsulates all the information about drawing, such as coordinate
transforms, line widths, etc. If you do not invoke this method,
a gstate object is constructed each time the view is lockFocused.
Allocating a private gstate may improve the performance of views
that are focused a lot and have a lot of customized drawing
parameters.
View subclasses should override the setUpGstate method to set these
custom parameters.
- (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
.
- (BOOL) autoresizesSubviews;
- (unsigned int) autoresizingMask;
- (BOOL) autoscroll: (NSEvent*)theEvent;
- (void) beginPage: (int)ordinalNum label: (NSString *)aString bBox: (NSRect)pageRect;
- (void) beginPageSetupRect: (NSRect)aRect placement: (NSPoint)location;
- (void) beginPrologueBBox: (NSRect)boundingBox creationDate: (NSString*)dateCreated createdBy: (NSString *)anApplication fonts: (NSString*)fontNames forWhom: (NSString *)user pages: (int)numPages;
- (void) beginSetup;
- (void) beginTrailer;
- (NSRect) bounds;
- (float) boundsRotation;
- (BOOL) canDraw;
- (NSRect) centerScanRect: (NSRect)aRect;
- (NSPoint) convertPoint: (NSPoint)aPoint fromView: (NSView*)aView;
- (NSPoint) convertPoint: (NSPoint)aPoint;
- (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)aRect;
- (void) discardCursorRects;
- (void) display;
- (void) displayIfNeeded;
- (void) displayIfNeededIgnoringOpacity;
- (void) displayIfNeededInRect: (NSRect)aRect;
- (void) displayIfNeededInRectIgnoringOpacity: (NSRect)aRect;
- (void) displayRect: (NSRect)aRect;
- (void) displayRectIgnoringOpacity: (NSRect)aRect;
- (BOOL) dragFile: (NSString*)fullPath fromRect: (NSRect)aRect slideBack: (BOOL)slideBack;
- (void) dragImage: (NSImage*)anImage at: (NSPoint)imageLoc offset: (NSSize)mouseOffset event: (NSEvent *)theEvent pasteboard: (NSPasteboard*)pboard source: (id)sourceObject slideBack: (BOOL)slideBack;
- (void) drawPageBorderWithSize: (NSSize)borderSize;
- (void) drawRect: (NSRect)aRect;
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.
- (void) drawSheetBorderWithSize: (NSSize)borderSize;
- (NSScrollView*) enclosingScrollView;
- (void) endHeaderComments;
- (void) endPage;
- (void) endPageSetup;
- (void) endPrologue;
- (void) endSetup;
- (void) endTrailer;
- (void) fax: (id)sender;
- (NSRect) frame;
- (float) frameRotation;
- (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
return 0.
- (float) heightAdjustLimit;
- (NSView*) hitTest: (NSPoint)aPoint;
Returns the subview, lowest in the receiver's hierarchy, which contains
aPoint
- (id) initWithFrame: (NSRect)frameRect;
- (NSInterfaceStyle) interfaceStyle;
- (BOOL) isDescendantOf: (NSView*)aView;
Returns YES
if aView is an ancestor of the receiver.
- (BOOL) isFlipped;
- (BOOL) isOpaque;
- (BOOL) isRotatedFromBase;
- (BOOL) isRotatedOrScaledFromBase;
- (BOOL) knowsPageRange: (NSRangePointer)range;
- (BOOL) knowsPagesFirst: (int*)firstPageNum;
- (NSPoint) locationOfPrintRect: (NSRect)aRect;
- (void) lockFocus;
- (NSMenu*) menuForEvent: (NSEvent*)theEvent;
As of yet, unimplemented.
- (BOOL) mouse: (NSPoint)aPoint inRect: (NSRect)aRect;
Returns whether or not aPoint lies within aRect.
- (BOOL) needsDisplay;
- (BOOL) needsPanelToBecomeKey;
- (NSView*) nextKeyView;
- (NSView*) nextValidKeyView;
- (NSView*) opaqueAncestor;
- (BOOL) performKeyEquivalent: (NSEvent*)theEvent;
- (BOOL) performMnemonic: (NSString*)aString;
- (BOOL) postsBoundsChangedNotifications;
- (BOOL) postsFrameChangedNotifications;
- (NSView*) previousKeyView;
- (NSView*) previousValidKeyView;
- (void) print: (id)sender;
- (NSRect) rectForPage: (int)pageNumber;
- (void) reflectScrolledClipView: (NSClipView*)aClipView;
- (void) registerForDraggedTypes: (NSArray*)pboardTypes;
- (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.
- (void) removeCursorRect: (NSRect)aRect cursor: (NSCursor*)aCursor;
- (void) removeFromSuperview;
Removes the receiver from its superviews list of subviews,
by invoking the superviews [-removeSubview:] method, and
marks the rectangle that the reciever occupied in the
superview as needing redisplay.
This is dangerous to use during display, since it alters the
rectangles needing display.
- (void) removeFromSuperviewWithoutNeedingDisplay;
Removes the receiver from its superviews list of subviews,
by invoking the superviews [-removeSubview:] method.
- (void) removeSubview: (NSView*)aView;
Standards: NotMacOS-X NotOpenStep
Removes the view from the receivers list of subviews
and from the responder chain.
Also invokes [aView -viewWillMoveToWindow: nil] to handle
removal of aView (and recursively, its children) from its
window - performing tidyup by invalidating cursor rects etc.
- (void) removeTrackingRect: (NSTrackingRectTag)aTag;
- (void) renewGState;
Invalidates the view's gstate object so it will be set up
again using setUpGState the next time the view is focused.
- (void) replaceSubview: (NSView*)oldView with: (NSView*)newView;
Removes oldView from the receiver and places newView in its place.
- (void) resetCursorRects;
- (void) resizeSubviewsWithOldSize: (NSSize)oldFrameSize;
- (void) resizeWithOldSuperviewSize: (NSSize)oldFrameSize;
- (void) rotateByAngle: (float)angle;
- (void) scaleUnitSquareToSize: (NSSize)newUnitSize;
- (void) scrollClipView: (NSClipView*)aClipView;
- (void) scrollPoint: (NSPoint)aPoint;
- (void) scrollRect: (NSRect)aRect;
- (BOOL) scrollRectToVisible: (NSRect)aRect;
- (void) setAutoresizesSubviews: (BOOL)flag;
- (void) setAutoresizingMask: (unsigned int)mask;
- (void) setBounds: (NSRect)boundsRect;
- (void) setBoundsOrigin: (NSPoint)newOrigin;
- (void) setBoundsRotation: (float)angle;
- (void) setBoundsSize: (NSSize)newSize;
- (void) setFrame: (NSRect)frameRect;
- (void) setFrameOrigin: (NSPoint)newOrigin;
- (void) setFrameRotation: (float)angle;
- (void) setFrameSize: (NSSize)newSize;
- (void) setInterfaceStyle: (NSInterfaceStyle)interfaceStyle;
- (void) setNeedsDisplay: (BOOL)flag;
- (void) setNeedsDisplayInRect: (NSRect)invalidRect;
- (void) setNextKeyView: (NSView*)aView;
- (void) setPostsBoundsChangedNotifications: (BOOL)flag;
- (void) setPostsFrameChangedNotifications: (BOOL)flag;
- (void) setToolTip: (NSString*)string;
- (void) setUpGState;
- (BOOL) shouldDelayWindowOrderingForEvent: (NSEvent*)theEvent;
- (BOOL) shouldDrawColor;
- (void) sortSubviewsUsingFunction: (int (*)(id,id,void*))compare context: (void*)context;
- (NSArray*) subviews;
- (NSView*) superview;
- (int) tag;
- (NSString*) toolTip;
- (void) translateOriginToPoint: (NSPoint)newOrigin;
- (void) unlockFocus;
- (void) unregisterDraggedTypes;
- (void) viewWillMoveToSuperview: (NSView*)newSuperview;
Notifies the receiver that its superview is being changed to
newSuperview.
- (void) viewWillMoveToWindow: (NSWindow*)newWindow;
Notifies the receiver that it will now be a view of newWindow.
- (id) viewWithTag: (int)aTag;
- (NSRect) visibleRect;
- (float) widthAdjustLimit;
- (NSWindow*) window;
Returns the window in which the receiver resides.
- (void) writeEPSInsideRect: (NSRect)aRect toPasteboard: (NSPasteboard*)pboard;