CPObjectCPResponder
CPView
@implementation CPView : CPResponder
CPView
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
CPWindow
object). Within the window is a hierarchy of CPView
s,
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 CPView
and CPResponder
can
also be overridden to handle user generated events.
Method Summary | |
---|---|
-(id) | initWithCoder:(CPCoder)aCoder Initializes the view from an archive. |
-(id) | initWithFrame:(CGRect)aFrame Initializes the receiver for usage with the specified bounding rectangle. |
-(id) | NS_initWithCoder:(CPCoder)aCoder |
-(BOOL) | acceptsFirstMouse:(CPEvent)anEvent Returns whether the receiver should be sent a mouseDown: message for anEvent . |
-(void) | addSubview:(CPView)aSubview Makes the argument a subview of the receiver. |
-(void) | addSubview:(CPView)aSubview positioned:(CPWindowOrderingMode)anOrderingMode relativeTo:(CPView)anotherView Makes aSubview a subview of the receiver. |
-(CGRect) | adjustScroll:(CGRect)proposedVisibleRect Subclasses can override this to modify the visible rectangle after a scrolling operation. |
-(float) | alphaValue Returns the alpha value of the receiver. |
-(BOOL) | autoresizesSubviews Reports whether the receiver automatically resizes its subviews when its frame size changes. |
-(unsigned) | autoresizingMask Returns the bit mask options for resizing behavior. |
-(BOOL) | autoscroll:(CPEvent)anEvent FIXME Not yet implemented. |
-(CPColor) | backgroundColor Returns the background color of the receiver. |
-(CGRect) | bounds Returns the receiver's bounds. |
-(CGPoint) | convertPoint:(CGPoint)aPoint fromView:(CPView)aView Converts aPoint from the coordinate space of aView to the coordinate space of the receiver. |
-(CGPoint) | convertPoint:(CGPoint)aPoint toView:(CPView)aView Converts aPoint from the receiver's coordinate space to the coordinate space of aView . |
-(CGRect) | convertRect:(CGRect)aRect fromView:(CPView)aView Converts aRect from aView 's coordinate space to the receiver's space. |
-(CGRect) | convertRect:(CGRect)aRect toView:(CPView)aView Converts aRect from the receiver's coordinate space to aView 's coordinate space. |
-(CGSize) | convertSize:(CGSize)aSize fromView:(CPView)aView Convert's aSize from aView 's coordinate space to the receiver's coordinate space. |
-(CGSize) | convertSize:(CGSize)aSize toView:(CPView)aView Convert's aSize from the receiver's coordinate space to aView 's coordinate space. |
-(void) | didAddSubview:(CPView)aSubview Called when the receiver has added aSubview to it's child views. |
-(void) | display Draws the entire area of the receiver as defined by its bounds . |
-(void) | displayIfNeeded Displays the receiver and any of its subviews that need to be displayed. |
-(void) | displayIfNeededInRect:(CGRect)aRect |
-(void) | displayRect:(CPRect)aRect Draws the receiver into the area defined by aRect . |
-(void) | displayRectIgnoringOpacity:(CGRect)aRect inContext:(CPGraphicsContext)aGraphicsContext |
-(void) | dragImage:(CPImage)anImage at:(CGPoint)aLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack Initiates a drag operation from the receiver to another view that accepts dragged data. |
-(void) | dragView:(CPView)aView at:(CPPoint)aLocation offset:(CPSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack Initiates a drag operation from the receiver to another view that accepts dragged data. |
-(void) | drawRect:(CPRect)aRect Draws the receiver into aRect . |
-(CPMenuItem) | enclosingMenuItem Returns the menu item containing the receiver or one of its ancestor views. |
-(CPScrollView) | enclosingScrollView Returns the CPScrollView containing the receiver. |
-(void) | encodeWithCoder:(CPCoder)aCoder Archives the view to a coder. |
-(BOOL) | enterFullScreenMode:(CPScreen)aScreen withOptions:(CPDictionary)options Puts the receiver into full screen mode. |
-(void) | exitFullScreenModeWithOptions:(CPDictionary)options The receiver should exit full screen mode. |
-(CGRect) | frame Returns the receiver's frame. |
-(CPView) | hitTest:(CPPoint)aPoint Tests whether a point is contained within this view, or one of its subviews. |
-(BOOL) | hitTests Returns whether or not the view responds to hit tests. |
-(BOOL) | isDescendantOf:(CPView)aView Returns YES if the receiver is, or is a descendant of, aView . |
-(BOOL) | isFlipped Returns whether the view is flipped. |
-(BOOL) | isHidden Returns YES if the receiver is hidden. |
-(BOOL) | isHiddenOrHasHiddenAncestor Returns YES if the receiver is hidden, or one
of it's ancestor views is hidden. |
-(BOOL) | isInFullScreenMode Returns YES if the receiver is currently in full screen mode. |
-(BOOL) | isOpaque Returns whether the receiver is completely opaque. |
-(CALayer) | layer Returns the core animation layer used by the receiver. |
-(void) | lockFocus Locks focus on the receiver, so drawing commands apply to it. |
-(void) | mouseDown:(CPEvent)anEvent Notifies the receiver that the user has clicked the mouse down in its area. |
-(BOOL) | mouseDownCanMoveWindow Returns YES if mouse events aren't needed by the receiver and can be sent to the superview. |
-(BOOL) | needsDisplay |
-(BOOL) | postsBoundsChangedNotifications Returns YES if the receiver posts a
CPViewBoundsDidChangeNotification when its
bounds is changed. |
-(BOOL) | postsFrameChangedNotifications Returns YES if the receiver posts a CPViewFrameDidChangeNotification if its frame is changed. |
-(void) | reflectScrolledClipView:(CPClipView)aClipView Notifies the receiver (superview of a CPClipView )
that the clip view bounds or the document view bounds have changed. |
-(void) | registerForDraggedTypes:(CPArray)pasteboardTypes Sets the receiver's list of acceptable data types for a dragging operation. |
-(CPArray) | registeredDraggedTypes Returns an array of all types the receiver accepts for dragging operations. |
-(void) | removeFromSuperview Removes the receiver from it's container view and window. |
-(void) | replaceSubview:(CPView)aSubview with:(CPView)aView Replaces the specified child view with another view. |
-(void) | resizeSubviewsWithOldSize:(CGSize)aSize Initiates superviewSizeChanged: messages to subviews. |
-(void) | resizeWithOldSuperviewSize:(CGSize)aSize Notifies subviews that the superview changed size. |
-(void) | scrollClipView:(CPClipView)aClipView toPoint:(CGPoint)aPoint Scrolls the clip view to a specified point. |
-(void) | scrollPoint:(CGPoint)aPoint Changes the receiver's frame origin to a 'constrained' aPoint . |
-(BOOL) | scrollRectToVisible:(CGRect)aRect Scrolls the nearest ancestor CPClipView a minimum amount so aRect can become visible. |
-(void) | scrollRect:(CGRect)aRect by:(float)anAmount Should be overridden by subclasses. |
-(void) | setAlphaValue:(float)anAlphaValue Sets the opacity of the receiver. |
-(void) | setAutoresizesSubviews:(BOOL)aFlag Specifies whether the receiver view should automatically resize its subviews when its setFrameSize: method receives a change. |
-(void) | setAutoresizingMask:(unsigned)aMask Determines automatic resizing behavior. |
-(void) | setBackgroundColor:(CPColor)aColor Sets the background color of the receiver. |
-(void) | setBounds:(CGRect)bounds Sets the receiver's bounds. |
-(void) | setBoundsOrigin:(CGPoint)aPoint Sets the location of the receiver inside its frame. |
-(void) | setBoundsSize:(CGSize)aSize Sets the receiver's size inside its frame. |
-(void) | setFrame:(CGRect)aFrame Sets the frame size of the receiver to the dimensions and origin of the provided rectangle in the coordinate system of the superview. |
-(void) | setFrameOrigin:(CGPoint)aPoint Sets the receiver's frame origin to the provided point. |
-(void) | setFrameSize:(CGSize)aSize Sets the receiver's frame size. |
-(void) | setHidden:(BOOL)aFlag Sets whether the receiver should be hidden. |
-(void) | setHitTests:(BOOL)shouldHitTest Set whether or not the view should respond to hit tests. |
-(void) | setLayer:(CALayer)aLayer Sets the core animation layer to be used by this receiver. |
-(void) | setNeedsDisplay:(BOOL)aFlag Marks the entire view as dirty, and needing a redraw. |
-(void) | setNeedsDisplayInRect:(CPRect)aRect Marks the area denoted by aRect as dirty, and initiates a redraw on it. |
-(void) | setPostsBoundsChangedNotifications:(BOOL)shouldPostBoundsChangedNotifications Sets whether the receiver posts a CPViewBoundsDidChangeNotification notification
to the default notification center when its bounds is changed. |
-(void) | setPostsFrameChangedNotifications:(BOOL)shouldPostFrameChangedNotifications Sets whether the receiver posts a CPViewFrameDidChangeNotification notification
to the default notification center when its frame is changed. |
-(void) | setWantsLayer:(BOOL)aFlag Sets whether the receiver wants a core animation layer. |
-(CPArray) | subviews Returns an array of all the views contained as direct children of the receiver. |
-(CPView) | superview Returns the container view of the receiver. |
-(void) | unlockFocus Takes focus away from the receiver, and restores it to the previous view. |
-(void) | unregisterDraggedTypes Resets the array of acceptable data types for a dragging operation. |
-(void) | viewDidMoveToSuperview Called when the receiver's superview has changed. |
-(void) | viewDidMoveToWindow Called when the receiver has been moved to a new CPWindow . |
-(void) | viewWillMoveToSuperview:(CPView)aView Called when the receiver is about to be moved to a new view. |
-(void) | viewWillMoveToWindow:(CPWindow)aWindow Called when the receiver is about to be moved to a new window. |
-(CGRect) | visibleRect Returns the rectangle of the receiver not clipped by its superview. |
-(BOOL) | wantsLayer Returns YES if the receiver uses a CALayer . |
-(void) | willRemoveSubview:(CPView)aView Called when the receiver is about to be remove one of its subviews. |
-(CPWindow) | window Returns the window containing this receiver. |
Method Detail |
---|
-(id)initWithCoder:(CPCoder)aCoder
aCoder
- the coder from which to initialize-(id)initWithFrame:(CGRect)aFrame
aFrame
-(id)NS_initWithCoder:(CPCoder)aCoder
aCoder
-(BOOL)acceptsFirstMouse:(CPEvent)anEvent
mouseDown:
message for anEvent
.YES
by default.anEvent
YES
, if the view object accepts first mouse-down event. NO
, otherwise.
-(void)addSubview:(CPView)aSubview
aSubview
- the CPView
to make a subview-(void)addSubview:(CPView)aSubview positioned:(CPWindowOrderingMode)anOrderingMode relativeTo:(CPView)anotherView
aSubview
a subview of the receiver. It is positioned relative to anotherView
aSubview
- the view to add as a subviewanOrderingMode
- specifies aSubview
's ordering relative to anotherView
anotherView
- aSubview
will be positioned relative to this argument-(CGRect)adjustScroll:(CGRect)proposedVisibleRect
proposedVisibleRect
- the rectangle to alter-(float)alphaValue
-(BOOL)autoresizesSubviews
YES
means it resizes its subviews on a frame size change.
-(unsigned)autoresizingMask
-(BOOL)autoscroll:(CPEvent)anEvent
anEvent
-(CPColor)backgroundColor
-(CGRect)bounds
-(CGPoint)convertPoint:(CGPoint)aPoint fromView:(CPView)aView
aPoint
from the coordinate space of aView
to the coordinate space of the receiver.aPoint
- the point to convertaView
- the view space to convert from-(CGPoint)convertPoint:(CGPoint)aPoint toView:(CPView)aView
aPoint
from the receiver's coordinate space to the coordinate space of aView
.aPoint
- the point to convertaView
- the coordinate space to which the point will be converted-(CGRect)convertRect:(CGRect)aRect fromView:(CPView)aView
aRect
from aView
's coordinate space to the receiver's space.aRect
- the rectangle to convertaView
- the coordinate space from which to convert-(CGRect)convertRect:(CGRect)aRect toView:(CPView)aView
aRect
from the receiver's coordinate space to aView
's coordinate space.aRect
- the rectangle to convertaView
- the coordinate space to which the rectangle will be converted-(CGSize)convertSize:(CGSize)aSize fromView:(CPView)aView
aSize
from aView
's coordinate space to the receiver's coordinate space.aSize
- the size to convertaView
- the coordinate space to convert from-(CGSize)convertSize:(CGSize)aSize toView:(CPView)aView
aSize
from the receiver's coordinate space to aView
's coordinate space.aSize
- the size to convertaView
-(void)didAddSubview:(CPView)aSubview
aSubview
to it's child views.aSubview
- the view that was added-(void)display
bounds
.-(void)displayIfNeeded
-(void)displayIfNeededInRect:(CGRect)aRect
aRect
-(void)displayRect:(CPRect)aRect
aRect
.aRect
- the area to be drawn-(void)displayRectIgnoringOpacity:(CGRect)aRect inContext:(CPGraphicsContext)aGraphicsContext
aRect
aGraphicsContext
-(void)dragImage:(CPImage)anImage at:(CGPoint)aLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
anImage
- the image to be draggedaLocation
- the lower-left corner coordinate of anImage
mouseOffset
- the distance from the mouseDown:
location and the current locationanEvent
- the mouseDown:
that triggered the dragaPasteboard
aSourceObject
- the drag operation controllerslideBack
- Whether the image should 'slide back' if the drag is rejected-(void)dragView:(CPView)aView at:(CPPoint)aLocation offset:(CPSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
aView
- the view to be draggedaLocation
- the lower-left corner coordinate of aView
mouseOffset
- the distance from the mouseDown:
location and the current locationanEvent
- the mouseDown:
that triggered the dragaPasteboard
aSourceObject
- the drag operation controllerslideBack
- Whether the view should 'slide back' if the drag is rejected-(void)drawRect:(CPRect)aRect
aRect
. This method should be overridden by subclasses.aRect
- the area that should be drawn into-(CPMenuItem)enclosingMenuItem
nil
if the view or one of its ancestors wasn't found
-(CPScrollView)enclosingScrollView
CPScrollView
containing the receiver.CPScrollView
containing the receiver.
-(void)encodeWithCoder:(CPCoder)aCoder
aCoder
- the object into which the view's data will be archived.-(BOOL)enterFullScreenMode:(CPScreen)aScreen withOptions:(CPDictionary)options
aScreen
- the that should be usedoptions
- configuration options-(void)exitFullScreenModeWithOptions:(CPDictionary)options
options
- configurations options-(CGRect)frame
-(CPView)hitTest:(CPPoint)aPoint
aPoint
- the point to test-(BOOL)hitTests
YES
if this view listens to hitTest messages, NO
otherwise.
-(BOOL)isDescendantOf:(CPView)aView
YES
if the receiver is, or is a descendant of, aView
.aView
- the view to test for ancestry-(BOOL)isFlipped
YES
if the view is flipped. NO
, otherwise.
-(BOOL)isHidden
YES
if the receiver is hidden.-(BOOL)isHiddenOrHasHiddenAncestor
YES
if the receiver is hidden, or one
of it's ancestor views is hidden. NO
, otherwise.-(BOOL)isInFullScreenMode
YES
if the receiver is currently in full screen mode.-(BOOL)isOpaque
NO
.-(CALayer)layer
-(void)lockFocus
-(void)mouseDown:(CPEvent)anEvent
anEvent
- contains information about the click-(BOOL)mouseDownCanMoveWindow
YES
if mouse events aren't needed by the receiver and can be sent to the superview. The
default implementation returns NO
if the view is opaque.-(BOOL)needsDisplay
-(BOOL)postsBoundsChangedNotifications
YES
if the receiver posts a
CPViewBoundsDidChangeNotification
when its
bounds is changed.-(BOOL)postsFrameChangedNotifications
YES
if the receiver posts a CPViewFrameDidChangeNotification
if its frame is changed.-(void)reflectScrolledClipView:(CPClipView)aClipView
CPClipView
)
that the clip view bounds or the document view bounds have changed.aClipView
- the clip view of the superview being notified-(void)registerForDraggedTypes:(CPArray)pasteboardTypes
pasteboardTypes
- an array of CPPasteboard
s-(CPArray)registeredDraggedTypes
CPPasteBoard
s
-(void)removeFromSuperview
-(void)replaceSubview:(CPView)aSubview with:(CPView)aView
aSubview
- the view to replaceaView
- the replacement view-(void)resizeSubviewsWithOldSize:(CGSize)aSize
superviewSizeChanged:
messages to subviews.aSize
- the size for the subviews-(void)resizeWithOldSuperviewSize:(CGSize)aSize
aSize
- the size of the old superview-(void)scrollClipView:(CPClipView)aClipView toPoint:(CGPoint)aPoint
aClipView
aPoint
-(void)scrollPoint:(CGPoint)aPoint
aPoint
.aPoint
- the proposed frame origin-(BOOL)scrollRectToVisible:(CGRect)aRect
CPClipView
a minimum amount so aRect
can become visible.aRect
- the area to become visibleNO
otherwise.
-(void)scrollRect:(CGRect)aRect by:(float)anAmount
aRect
anAmount
-(void)setAlphaValue:(float)anAlphaValue
anAlphaValue
- an alpha value ranging from 0.0 to 1.0.-(void)setAutoresizesSubviews:(BOOL)aFlag
setFrameSize:
method receives a change.aFlag
- If YES
, then subviews will automatically be resized
when this view is resized. NO
means the views will not
be resized automatically.-(void)setAutoresizingMask:(unsigned)aMask
aMask
- a bit mask with options-(void)setBackgroundColor:(CPColor)aColor
aColor
- the new color for the receiver's background-(void)setBounds:(CGRect)bounds
CPViewBoundsDidChangeNotification
to the default notification center if the receiver is configured to do so.bounds
- the new bounds-(void)setBoundsOrigin:(CGPoint)aPoint
CPViewBoundsDidChangeNotification
to the
default notification center if the receiver is configured to do so.aPoint
- the new location for the receiver-(void)setBoundsSize:(CGSize)aSize
CPViewBoundsDidChangeNotification
to the default
notification center if the receiver is configured to do so.aSize
- the new size for the receiver-(void)setFrame:(CGRect)aFrame
CPViewFrameDidChangeNotification
to the notification
center if the receiver is configured to do so. If the frame is the same as the current frame, the method simply
returns (and no notificaion is posted).aFrame
- the rectangle specifying the new origin and size of the receiver-(void)setFrameOrigin:(CGPoint)aPoint
CPViewFrameDidChangeNotification
to the default notification center if the receiver
is configured to do so. If the specified origin is the same as the frame's current origin, the method will
simply return (and no notification will be posted).aPoint
- the new origin point-(void)setFrameSize:(CGSize)aSize
aSize
is the same as the frame's current dimensions, this
method simply returns. The method posts a CPViewFrameDidChangeNotification
to the
default notification center if the receiver is configured to do so.aSize
- the new size for the frame-(void)setHidden:(BOOL)aFlag
aFlag
- YES
makes the receiver hidden.-(void)setHitTests:(BOOL)shouldHitTest
shouldHitTest
- should be YES
if this view should respond to hit tests, NO
otherwise.-(void)setLayer:(CALayer)aLayer
aLayer
-(void)setNeedsDisplay:(BOOL)aFlag
aFlag
-(void)setNeedsDisplayInRect:(CPRect)aRect
aRect
as dirty, and initiates a redraw on it.aRect
- the area that needs to be redrawn-(void)setPostsBoundsChangedNotifications:(BOOL)shouldPostBoundsChangedNotifications
CPViewBoundsDidChangeNotification
notification
to the default notification center when its bounds is changed. The default is NO
.
Methods that could cause a bounds change notification are:
setBounds: setBoundsSize: setBoundsOrigin:
shouldPostBoundsChangedNotifications
- YES
makes the receiver post
notifications on bounds changes-(void)setPostsFrameChangedNotifications:(BOOL)shouldPostFrameChangedNotifications
CPViewFrameDidChangeNotification
notification
to the default notification center when its frame is changed. The default is NO
.
Methods that could cause a frame change notification are:
setFrame: setFrameSize: setFrameOrigin:
shouldPostFrameChangedNotifications
- YES
makes the receiver post
notifications on frame changes (size or origin)-(void)setWantsLayer:(BOOL)aFlag
aFlag
-(CPArray)subviews
CPView
s
-(CPView)superview
-(void)unlockFocus
-(void)unregisterDraggedTypes
-(void)viewDidMoveToSuperview
-(void)viewDidMoveToWindow
CPWindow
.-(void)viewWillMoveToSuperview:(CPView)aView
aView
- the view to which the receiver will be moved-(void)viewWillMoveToWindow:(CPWindow)aWindow
aWindow
- the window to which the receiver will be moved.-(CGRect)visibleRect
-(BOOL)wantsLayer
YES
if the receiver uses a CALayer
YES
if the receiver uses a CALayer
-(void)willRemoveSubview:(CPView)aView
aView
- the view that will be removed-(CPWindow)window
Created on Sat Sep 13 14:15:43 PDT 2008