![]() |
API 0.9.5
|
#import <CPView.h>
CPView is a 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 CPViews, 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.
- (BOOL) acceptsFirstMouse: | (CPEvent) | anEvent |
- (void) addSubview: | (CPView) | aSubview |
- (void) addSubview: | (CPView) | aSubview | |
positioned: | (CPWindowOrderingMode) | anOrderingMode | |
relativeTo: | (CPView) | anotherView | |
Makes aSubview
a subview of the receiver. It is positioned relative to anotherView
aSubview | the view to add as a subview |
anOrderingMode | specifies aSubview's ordering relative to anotherView |
anotherView | aSubview will be positioned relative to this argument |
- (CGRect) adjustScroll: | (CGRect) | proposedVisibleRect |
- (float) alphaValue |
- (BOOL) autoresizesSubviews |
- (unsigned) autoresizingMask |
- (BOOL) autoscroll: | (CPEvent) | anEvent |
Reimplemented in CPClipView.
- (CPColor) backgroundColor |
- (CGRect) bounds |
- (CGPoint) center |
- (CGPoint) convertPoint: | (CGPoint) | aPoint | |
fromView: | (CPView) | aView | |
- (CGPoint) convertPoint: | (CGPoint) | aPoint | |
toView: | (CPView) | aView | |
- (CGPoint) convertPointFromBase: | (CGPoint) | aPoint |
- (CGPoint) convertPointToBase: | (CGPoint) | aPoint |
- (CGRect) convertRect: | (CGRect) | aRect | |
fromView: | (CPView) | aView | |
- (CGRect) convertRect: | (CGRect) | aRect | |
toView: | (CPView) | aView | |
- (CGRect) convertRectFromBase: | (CGRect) | aRect |
- (CGRect) convertRectToBase: | (CGRect) | aRect |
- (CGSize) convertSize: | (CGSize) | aSize | |
fromView: | (CPView) | aView | |
- (CGSize) convertSize: | (CGSize) | aSize | |
toView: | (CPView) | aView | |
Reimplemented in CPButton, CPButtonBar, CPLevelIndicator, CPScroller, CPSegmentedControl, CPSlider, and CPTextField.
- (id) currentValueForThemeAttribute: | (CPString) | aName |
Reimplemented in CPScroller.
+ (CPString) defaultThemeClass |
Reimplemented in CPAlert, CPButton, CPButtonBar, CPCheckBox, CPPopUpButton, CPRadio, CPScroller, CPScrollView, CPSearchField, CPSegmentedControl, CPSlider, CPSplitView, CPStepper, CPTableHeaderView, CPTableView, CPTextField, and CPTokenField.
- (void) didAddSubview: | (CPView) | aSubview |
Called when the receiver has added aSubview
to it's child views.
aSubview | the view that was added |
Reimplemented in CPSplitView.
- (void) display |
- (void) displayIfNeeded |
- (void) displayRect: | (CPRect) | 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.
anImage | the image to be dragged |
aLocation | the lower-left corner coordinate of anImage |
mouseOffset | the distance from the -mouseDown : location and the current location |
anEvent | the -mouseDown : that triggered the drag |
aPasteboard | the pasteboard that holds the drag data |
aSourceObject | the drag operation controller |
slideBack | 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 | |
Initiates a drag operation from the receiver to another view that accepts dragged data.
aView | the view to be dragged |
aLocation | the top-left corner coordinate of aView |
mouseOffset | the distance from the -mouseDown : location and the current location |
anEvent | the -mouseDown : that triggered the drag |
aPasteboard | the pasteboard that holds the drag data |
aSourceObject | the drag operation controller |
slideBack | Whether the view should 'slide back' if the drag is rejected |
- (void) drawRect: | (CPRect) | aRect |
Draws the receiver into aRect
. This method should be overridden by subclasses.
aRect | the area that should be drawn into |
Reimplemented in CPBox, and CPScrollView.
- (CPMenuItem) enclosingMenuItem |
- (CPScrollView) enclosingScrollView |
Returns the CPScrollView containing the receiver.
- (void) encodeWithCoder: | (CPCoder) | aCoder |
Archives the view to a coder.
aCoder | the object into which the view's data will be archived. |
Reimplemented from CPResponder.
Reimplemented in CPBox, CPBrowser, CPButton, CPButtonBar, CPClipView, CPCollectionView, CPColorWell, CPControl, CPImageView, CPLevelIndicator, CPOutlineView, CPProgressIndicator, CPRadio, CPScroller, CPScrollView, CPSearchField, CPSegmentedControl, CPSlider, CPSplitView, CPStepper, CPTableHeaderView, CPTableView, CPTabView, CPTextField, CPTokenField, and CPWebView.
- (BOOL) enterFullScreenMode |
- (BOOL) enterFullScreenMode: | (CPScreen) | aScreen | |
withOptions: | (CPDictionary) | options | |
- (void) exitFullScreenMode |
- (void) exitFullScreenModeWithOptions: | (CPDictionary) | options |
- (CGRect) frame |
- (CPView) hitTest: | (CPPoint) | aPoint |
Tests whether a point is contained within this view, or one of its subviews.
aPoint | the point to test |
Reimplemented in CPLevelIndicator.
- (BOOL) hitTests |
+ (void) initialize |
Reimplemented in CPControl, CPImageView, CPLevelIndicator, CPProgressIndicator, CPScrollView, CPSearchField, CPShadowView, and CPSplitView.
- (id) initWithCoder: | (CPCoder) | aCoder |
Initializes the view from an archive.
aCoder | the coder from which to initialize |
Reimplemented from CPResponder.
Reimplemented in CPBox, CPBrowser, CPButton, CPButtonBar, CPClipView, CPCollectionView, CPColorWell, CPControl, CPImageView, CPLevelIndicator, CPOutlineView, CPPopUpButton, CPProgressIndicator, CPRadio, CPScroller, CPScrollView, CPSearchField, CPSegmentedControl, CPSlider, CPSplitView, CPStepper, CPTableHeaderView, CPTableView, CPTabView, CPTextField, CPTokenField, and CPWebView.
- (id) initWithFrame: | (CGRect) | aFrame |
Initializes the receiver for usage with the specified bounding rectangle
Reimplemented in CPAccordionView, CPBrowser, CPButton, CPButtonBar, CPCheckBox, CPCollectionView, CPColorWell, CPControl, CPFlashView, CPImageView, CPLevelIndicator, CPOutlineView, CPPopUpButton, CPProgressIndicator, CPRadio, CPScroller, CPScrollView, CPSearchField, CPSegmentedControl, CPShadowView, CPSlider, CPSplitView, CPStepper, CPTableHeaderView, CPTableView, CPTabView, and CPTextField.
- (BOOL) isDescendantOf: | (CPView) | aView |
- (BOOL) isFlipped |
- (BOOL) isHiddenOrHasHiddenAncestor |
- (BOOL) isInFullScreenMode |
- (BOOL) isOpaque |
Returns whether the receiver is completely opaque. By default, returns NO
.
Reimplemented in CPSearchField.
- (CALayer) layer |
- (void) layoutSubviews |
Reimplemented in CPAccordionView, CPButton, CPButtonBar, CPImageView, CPLevelIndicator, CPScroller, CPSegmentedControl, CPSlider, CPSplitView, CPStepper, CPTableHeaderView, CPTableView, CPTextField, and CPTokenField.
- (void) lockFocus |
Reimplemented in CPCollectionView, and CPTableView.
- (void) mouseDown: | (CPEvent) | anEvent |
Notifies the receiver that the user has clicked the mouse down in its area.
anEvent | contains information about the click |
Reimplemented from CPResponder.
Reimplemented in CPButton, CPCollectionView, CPColorWell, CPControl, CPFlashView, CPImageView, CPLevelIndicator, CPPopUpButton, CPScroller, CPSearchField, CPSegmentedControl, CPSplitView, CPTableHeaderView, CPTabView, CPTextField, and CPTokenField.
- (BOOL) mouseDownCanMoveWindow |
- (BOOL) needsPanelToBecomeKey |
Returns YES
if this view requires a panel to become key. Normally only text fields, so this returns NO
.
Reimplemented in CPTextField.
- (BOOL) performKeyEquivalent: | (CPEvent) | anEvent |
Overridden by subclasses to handle a key equivalent.
If the receiver’s key equivalent is the same as the characters of the key-down event theEvent, as returned by [anEvent 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
.
anEvent | An event object that represents the key equivalent pressed |
YES
if theEvent is a key equivalent that the receiver handled, NO
if it is not a key equivalent that it should handle. Reimplemented from CPResponder.
Reimplemented in CPButton.
- (BOOL) postsBoundsChangedNotifications |
- (BOOL) postsFrameChangedNotifications |
- (CGRect) rectForEphemeralSubviewNamed: | (CPString) | aViewName |
Reimplemented in CPButton, CPButtonBar, CPLevelIndicator, CPScroller, CPSegmentedControl, CPSlider, and CPTextField.
- (void) reflectScrolledClipView: | (CPClipView) | aClipView |
Notifies the receiver (superview of a CPClipView) that the clip view bounds or the document view bounds have changed.
aClipView | the clip view of the superview being notified |
Reimplemented in CPScrollView.
- (CPArray) registeredDraggedTypes |
- (void) registerForDraggedTypes: | (CPArray) | pasteboardTypes |
- (void) removeFromSuperview |
Removes the receiver from it's container view and window. Does nothing if there's no container view.
Reimplemented in CPTokenField.
- (void) resizeSubviewsWithOldSize: | (CGSize) | aSize |
Initiates -superviewSizeChanged
: messages to subviews.
aSize | the size for the subviews |
Reimplemented in CPClipView, CPCollectionView, and CPScrollView.
- (void) resizeWithOldSuperviewSize: | (CGSize) | aSize |
Notifies subviews that the superview changed size.
aSize | the size of the old superview |
Reimplemented in CPTableView.
- (void) rightMouseDown: | (CPEvent) | anEvent |
Notifies the receiver that the user has clicked the right mouse down in its area.
anEvent | contains information about the right click |
Reimplemented from CPResponder.
Reimplemented in CPPopUpButton.
- (void) scrollClipView: | (CPClipView) | aClipView | |
toPoint: | (CGPoint) | aPoint | |
- (void) scrollPoint: | (CGPoint) | aPoint |
- (void) scrollRect: | (CGRect) | aRect | |
by: | (float) | anAmount | |
- (BOOL) scrollRectToVisible: | (CGRect) | aRect |
Scrolls the nearest ancestor CPClipView a minimum amount so aRect
can become visible.
aRect | the area to become visible |
NO
otherwise. - (void) setAlphaValue: | (float) | anAlphaValue |
- (void) setAutoresizesSubviews: | (BOOL) | aFlag |
Specifies whether the receiver view should automatically resize its subviews when its -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 |
- (void) setBackgroundColor: | (CPColor) | aColor |
- (void) setBounds: | (CGRect) | bounds |
- (void) setBoundsOrigin: | (CGPoint) | aPoint |
Sets the location of the receiver inside its frame. The method posts a CPViewBoundsDidChangeNotification to the default notification center if the receiver is configured to do so.
aPoint | the new location for the receiver |
Reimplemented in CPClipView, and CPTableView.
- (void) setBoundsSize: | (CGSize) | aSize |
Sets the receiver's size inside its frame. The method posts a CPViewBoundsDidChangeNotification to the default notification center if the receiver is configured to do so.
aSize | the new size for the receiver |
Reimplemented in CPTableView.
- (void) setCenter: | (CGPoint) | aPoint |
Moves the center of the receiver's frame to the provided point. The point is defined in the superview's coordinate system. The method posts a 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) 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. The method also posts an 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 notification is posted).
aFrame | the rectangle specifying the new origin and size of the receiver |
Reimplemented in CPStepper.
- (void) setFrameOrigin: | (CGPoint) | aPoint |
Sets the receiver's frame origin to the provided point. The point is defined in the superview's coordinate system. The method posts a 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 |
Reimplemented in CPTableView.
- (void) setFrameSize: | (CGSize) | aSize |
Sets the receiver's frame size. If 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 |
Reimplemented in CPAccordionView, CPButtonBar, CPProgressIndicator, CPScroller, CPSlider, CPSplitView, and CPTableView.
- (void) setHidden: | (BOOL) | aFlag |
- (void) setHitTests: | (BOOL) | shouldHitTest |
- (void) setLayer: | (CALayer) | aLayer |
- (void) setNeedsDisplay: | (BOOL) | aFlag |
Marks the entire view as dirty, and needing a redraw.
Reimplemented in CPTableView.
- (void) setNeedsDisplayInRect: | (CPRect) | aRect |
- (void) setPostsBoundsChangedNotifications: | (BOOL) | shouldPostBoundsChangedNotifications |
Sets whether the receiver posts a 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 |
Sets whether the receiver posts a 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) setTheme: | (CPTheme) | aTheme |
- (void) setValue: | (id) | aValue | |
forThemeAttribute: | (CPString) | aName | |
- (void) setValue: | (id) | aValue | |
forThemeAttribute: | (CPString) | aName | |
inState: | (CPThemeState) | aState | |
- (void) setWantsLayer: | (BOOL) | aFlag |
- (CPArray) subviews |
- (CPView) superview |
+ (CPDictionary) themeAttributes |
Reimplemented in CPAlert, CPButton, CPButtonBar, CPControl, CPScroller, CPScrollView, CPSegmentedControl, CPSlider, CPSplitView, CPStepper, CPTableHeaderView, CPTableView, and CPTextField.
- (void) unlockFocus |
- (void) unregisterDraggedTypes |
- (id) valueForThemeAttribute: | (CPString) | aName | |
inState: | (CPThemeState) | aState | |
- (void) viewDidHide |
Called when the return value of isHiddenOrHasHiddenAncestor becomes YES, e.g. when this view becomes hidden due to a setHidden:YES message to itself or to one of its superviews.
Note: in the current implementation, viewDidHide may be called multiple times if additional superviews are hidden, even if isHiddenOrHasHiddenAncestor was already YES.
- (void) viewDidMoveToSuperview |
- (void) viewDidMoveToWindow |
Called when the receiver has been moved to a new CPWindow.
Reimplemented in CPSplitView, and CPTokenField.
- (void) viewDidUnhide |
Called when the return value of isHiddenOrHasHiddenAncestor becomes NO, e.g. when this view stops being hidden due to a setHidden:NO message to itself or to one of its superviews.
Note: in the current implementation, viewDidUnhide may be called multiple times if additional superviews are unhidden, even if isHiddenOrHasHiddenAncestor was already NO.
Reimplemented in CPWebView.
- (void) viewWillDraw |
Reimplemented in CPSplitView.
- (void) viewWillMoveToSuperview: | (CPView) | aView |
Called when the receiver is about to be moved to a new view.
aView | the view to which the receiver will be moved |
Reimplemented in CPSearchField, and CPTableView.
- (void) viewWillMoveToWindow: | (CPWindow) | aWindow |
- (CGRect) visibleRect |
- (BOOL) wantsLayer |
- (void) willRemoveSubview: | (CPView) | aView |
Called when the receiver is about to be remove one of its subviews.
aView | the view that will be removed |
Reimplemented in CPSplitView.
- (CPWindow) window |