Class CPCollectionView

CPObject
    extended byCPResponder
        extended byCPView
            extended byCPCollectionView

@implementation CPCollectionView : CPView

This class presents an array of content as a grid of views.


Method Summary
-(id)initWithFrame:(CGRect)aFrame
          Initializes the receiver for usage with the specified bounding rectangle.
-(BOOL)acceptsFirstResponder
          Returns YES by default.
-(BOOL)allowsMultipleSelection
          Returns YES if the user can select multiple items, NO otherwise.
-(CPArray)content
          Returns the collection view content array.
-(id)delegate
          Returns the collection view's delegate.
-(BOOL)isFirstResponder
          Returns whether the receiver is currently the first responder.
-(BOOL)isSelected
          Returns YES if the collection view is selected, and NO otherwise.
-(CPCollectionViewItem)itemPrototype
          Returns the current item prototype.
-(CPArray)items
          Returns the collection view items.
-(CGSize)maxItemSize
          Returns the current maximum item size.
-(unsigned)maxNumberOfColumns
          Returns the maximum number of columns.
-(unsigned)maxNumberOfRows
          Returns the maximum number of rows.
-(CGSize)minItemSize
          Returns the current minimum item size.
-(void)mouseDown:(CPEvent)anEvent
          Notifies the receiver that the user has clicked the mouse down in its area.
-(void)mouseDragged:(CPEvent)anEvent
          Notifies the receiver that the user has initiated a drag over it.
-(void)mouseUp:(CPEvent)anEvent
          Notifies the receiver that the user has released the left mouse button.
-(CPCollectionViewItem)newItemForRepresentedObject:(id)anObject
          Returns a collection view item for anObject.
-(void)pasteboard:(CPPasteboard)aPasteboard provideDataForType:(CPString)aType
          Places the selected items on the specified pasteboard.
-(void)resizeSubviewsWithOldSize:(CGSize)aSize
          Initiates superviewSizeChanged: messages to subviews.
-(CPIndexSet)selectionIndexes
          Returns a set of the selected indices.
-(void)setAllowsMultipleSelection:(BOOL)shouldAllowMultipleSelection
          Sets whether the user can select multiple items.
-(void)setContent:(CPArray)anArray
          Sets the content of the collection view to the content in anArray.
-(void)setDelegate:(id)aDelegate
          Sets the collection view's delegate.
-(void)setItemPrototype:(CPCollectionViewItem)anItem
          Sets the item prototype to anItem.
-(void)setMaxItemSize:(CGSize)aSize
          Sets the maximum item size.
-(void)setMaxNumberOfColumns:(unsigned)aMaxNumberOfColumns
          Sets the maximum number of columns.
-(void)setMaxNumberOfRows:(unsigned)aMaxNumberOfRows
          Sets the maximum number of rows.
-(void)setMinItemSize:(CGSize)aSize
          Sets the minimum size for an item.
-(void)setSelectable:(BOOL)isSelectable
          Sets whether the user is allowed to select items.
-(void)setSelectionIndexes:(CPIndexSet)anIndexSet
          Sets the selected items based on the provided indices.
-(void)setVerticalMargin:(float)aVerticalMargin

Methods inherited from class CPObject
initialize, alloc, class, instanceMethodForSelector, instancesRespondToSelector, isSubclassOfClass, load, new, setVersion, superclass, version, init, autorelease, awakeAfterUsingCoder, class, classForCoder, classForKeyedArchiver, className, copy, dealloc, description, doesNotRecognizeSelector, forwardInvocation, hash, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableCopy, performSelector, performSelector, performSelector, release, replacementObjectForArchiver, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, retain, self, superclass

Methods inherited from class CPResponder
acceptsFirstResponder, becomeFirstResponder, deleteBackward, doCommandBySelector, insertLineBreak, insertText, interpretKeyEvents, keyDown, keyUp, menu, mouseDown, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseUp, nextResponder, noResponderFor, performKeyEquivalent, resignFirstResponder, scrollWheel, setMenu, setNextResponder, tryToPerform, undoManager

Methods inherited from class CPView
initWithFrame, acceptsFirstMouse, addSubview, addSubview, adjustScroll, alphaValue, autoresizesSubviews, autoresizingMask, autoscroll, backgroundColor, bounds, convertPoint, convertPoint, convertRect, convertRect, convertSize, convertSize, didAddSubview, display, displayIfNeeded, displayIfNeededInRect, displayRect, displayRectIgnoringOpacity, dragImage, dragView, drawRect, enclosingMenuItem, enclosingScrollView, enterFullScreenMode, exitFullScreenModeWithOptions, frame, hitTest, hitTests, isDescendantOf, isFlipped, isHidden, isHiddenOrHasHiddenAncestor, isInFullScreenMode, isOpaque, lockFocus, mouseDown, mouseDownCanMoveWindow, needsDisplay, postsBoundsChangedNotifications, postsFrameChangedNotifications, reflectScrolledClipView, registerForDraggedTypes, registeredDraggedTypes, removeFromSuperview, replaceSubview, resizeSubviewsWithOldSize, resizeWithOldSuperviewSize, scrollClipView, scrollPoint, scrollRectToVisible, scrollRect, setAlphaValue, setAutoresizesSubviews, setAutoresizingMask, setBackgroundColor, setBounds, setBoundsOrigin, setBoundsSize, setFrame, setFrameOrigin, setFrameSize, setHidden, setHitTests, setNeedsDisplay, setNeedsDisplayInRect, setPostsBoundsChangedNotifications, setPostsFrameChangedNotifications, subviews, superview, unlockFocus, unregisterDraggedTypes, viewDidMoveToSuperview, viewDidMoveToWindow, viewWillMoveToSuperview, viewWillMoveToWindow, visibleRect, willRemoveSubview, window

Delegate Method Summary
-(void)collectionViewDidChangeSelection:(CPCollectionView)collectionView
          Called when the selection in the collection view has changed.
-(void)collectionView:(CPCollectionView)collectionView didDoubleClickOnItemAtIndex:(int)index
          Called when the user double-clicks on an item in the collection view.
-(CPData)collectionView:(CPCollectionView)collectionView dataForItemsAtIndexes:(CPIndexSet)indices forType:(CPString)aType
          Invoked to obtain data for a set of indices.
-(CPArray)collectionView:(CPCollectionView)collectionView dragTypesForItemsAtIndexes:(CPIndexSet)indices
          Invoked to obtain the data types supported by the specified indices for placement on the pasteboard.


Method Detail

initWithFrame

-(id)initWithFrame:(CGRect)aFrame
Initializes the receiver for usage with the specified bounding rectangle
Parameters:
aFrame
Returns:
the initialized view

acceptsFirstResponder

-(BOOL)acceptsFirstResponder
Returns YES by default.

allowsMultipleSelection

-(BOOL)allowsMultipleSelection
Returns YES if the user can select multiple items, NO otherwise.

content

-(CPArray)content
Returns the collection view content array

delegate

-(id)delegate
Returns the collection view's delegate

isFirstResponder

-(BOOL)isFirstResponder
Returns whether the receiver is currently the first responder.

isSelected

-(BOOL)isSelected
Returns YES if the collection view is selected, and NO otherwise.

itemPrototype

-(CPCollectionViewItem)itemPrototype
Returns the current item prototype

items

-(CPArray)items
Returns the collection view items.

maxItemSize

-(CGSize)maxItemSize
Returns the current maximum item size.

maxNumberOfColumns

-(unsigned)maxNumberOfColumns
Returns the maximum number of columns

maxNumberOfRows

-(unsigned)maxNumberOfRows
Returns the maximum number of rows.

minItemSize

-(CGSize)minItemSize
Returns the current minimum item size

mouseDown

-(void)mouseDown:(CPEvent)anEvent
Notifies the receiver that the user has clicked the mouse down in its area.
Parameters:
anEvent - contains information about the click

mouseDragged

-(void)mouseDragged:(CPEvent)anEvent
Notifies the receiver that the user has initiated a drag over it. A drag is a mouse movement while the left button is down.
Parameters:
anEvent - contains information about the drag

mouseUp

-(void)mouseUp:(CPEvent)anEvent
Notifies the receiver that the user has released the left mouse button.
Parameters:
anEvent - contains information about the release

newItemForRepresentedObject

-(CPCollectionViewItem)newItemForRepresentedObject:(id)anObject
Returns a collection view item for anObject.
Parameters:
anObject - the object to be represented.

pasteboard

-(void)pasteboard:(CPPasteboard)aPasteboard provideDataForType:(CPString)aType
Places the selected items on the specified pasteboard. The items are requested from the collection's delegate.
Parameters:
aPasteboard - the pasteboard to put the items on
aType - the format the pasteboard data

resizeSubviewsWithOldSize

-(void)resizeSubviewsWithOldSize:(CGSize)aSize
Initiates superviewSizeChanged: messages to subviews.
Parameters:
aSize - the size for the subviews

selectionIndexes

-(CPIndexSet)selectionIndexes
Returns a set of the selected indices.

setAllowsMultipleSelection

-(void)setAllowsMultipleSelection:(BOOL)shouldAllowMultipleSelection
Sets whether the user can select multiple items.
Parameters:
shouldAllowMultipleSelection - YES allows the user to select multiple items

setContent

-(void)setContent:(CPArray)anArray
Sets the content of the collection view to the content in anArray. This array can be of any type, and each element will be passed to the setRepresentedObject: method. It's the responsibility of your custom collection view item to interpret the object.
Parameters:
anArray - the content array

setDelegate

-(void)setDelegate:(id)aDelegate
Sets the collection view's delegate
Parameters:
aDelegate - the new delegate

setItemPrototype

-(void)setItemPrototype:(CPCollectionViewItem)anItem
Sets the item prototype to anItem
Parameters:
anItem - the new item prototype

setMaxItemSize

-(void)setMaxItemSize:(CGSize)aSize
Sets the maximum item size.
Parameters:
aSize - the new maximum item size

setMaxNumberOfColumns

-(void)setMaxNumberOfColumns:(unsigned)aMaxNumberOfColumns
Sets the maximum number of columns.
Parameters:
aMaxNumberOfColumns - the new maximum number of columns

setMaxNumberOfRows

-(void)setMaxNumberOfRows:(unsigned)aMaxNumberOfRows
Sets the maximum number of rows.
Parameters:
aMaxNumberOfRows - the new maximum number of rows

setMinItemSize

-(void)setMinItemSize:(CGSize)aSize
Sets the minimum size for an item
Parameters:
aSize - the new minimum item size

setSelectable

-(void)setSelectable:(BOOL)isSelectable
Sets whether the user is allowed to select items
Parameters:
isSelectable - YES allows the user to select items.

setSelectionIndexes

-(void)setSelectionIndexes:(CPIndexSet)anIndexSet
Sets the selected items based on the provided indices.
Parameters:
anIndexSet - the set of items to be selected

setVerticalMargin

-(void)setVerticalMargin:(float)aVerticalMargin
Parameters:
aVerticalMargin

Delegate Method Detail

collectionViewDidChangeSelection

-(void)collectionViewDidChangeSelection:(CPCollectionView)collectionView
Called when the selection in the collection view has changed.
Parameters:
collectionView - the collection view who's selection changed

collectionView

-(void)collectionView:(CPCollectionView)collectionView didDoubleClickOnItemAtIndex:(int)index
Called when the user double-clicks on an item in the collection view.
Parameters:
collectionView - the collection view that received the double-click
index - the index of the item that received the double-click

collectionView

-(CPData)collectionView:(CPCollectionView)collectionView dataForItemsAtIndexes:(CPIndexSet)indices forType:(CPString)aType
Invoked to obtain data for a set of indices.
Parameters:
collectionView - the collection view to obtain data for
indices - the indices to return data for
aType - the data type
Returns:
a data object containing the index items

collectionView

-(CPArray)collectionView:(CPCollectionView)collectionView dragTypesForItemsAtIndexes:(CPIndexSet)indices
Invoked to obtain the data types supported by the specified indices for placement on the pasteboard.
Parameters:
collectionView - the collection view the items reside in
indices - the indices to obtain drag types
Returns:
an array of drag types (CPString)

Created on Sat Sep 13 14:15:43 PDT 2008