API 0.9.5
CPCollectionView Class Reference

#import <CPCollectionView.h>

Inheritance diagram for CPCollectionView:

List of all members.

Instance Methods

(BOOL) - acceptsFirstResponder
(BOOL) - allowsEmptySelection
(BOOL) - allowsMultipleSelection
(void) - awakeFromCib
(CPArray- backgroundColors
(CPArray- content
(id) - delegate
(void) - deleteBackward:
(void) - encodeWithCoder:
(CGRect) - frameForItemAtIndex:
(CGRect) - frameForItemsAtIndexes:
(id) - initWithCoder:
(id) - initWithFrame:
(BOOL) - isFirstResponder
(BOOL) - isSelectable
(CPCollectionViewItem- itemAtIndex:
(CPCollectionViewItem- itemPrototype
(CPArray- items
(void) - keyDown:
(CGSize) - maxItemSize
(unsigned) - maxNumberOfColumns
(unsigned) - maxNumberOfRows
(CPMenu- menuForEvent:
(CGSize) - minItemSize
(void) - mouseDown:
(void) - mouseDragged:
(void) - mouseUp:
(void) - moveDown:
(void) - moveDownAndModifySelection:
(void) - moveLeft:
(void) - moveLeftAndModifySelection:
(void) - moveRight:
(void) - moveRightAndModifySelection:
(void) - moveUp:
(void) - moveUpAndModifySelection:
(CPCollectionViewItem- newItemForRepresentedObject:
(unsigned) - numberOfColumns
(unsigned) - numberOfRows
(void) - pasteboard:provideDataForType:
(CGRect) - rectForItemAtIndex:
(CGRect) - rectForItemsAtIndexes:
(void) - reloadContent
(void) - resizeSubviewsWithOldSize:
(CPIndexSet- selectionIndexes
(void) - setAllowsEmptySelection:
(void) - setAllowsMultipleSelection:
(void) - setBackgroundColors:
(void) - setContent:
(void) - setDelegate:
(void) - setItemPrototype:
(void) - setMaxItemSize:
(void) - setMaxNumberOfColumns:
(void) - setMaxNumberOfRows:
(void) - setMinItemSize:
(void) - setSelectable:
(void) - setSelectionIndexes:
(void) - setVerticalMargin:
(void) - tile
(float) - verticalMargin

Detailed Description

This class displays an array as a grid of objects, where each object is represented by a view. The view is controlled by creating a CPCollectionViewItem and specifying its view, then setting that item as the collection view prototype.

Delegate Methods

-(void)collectionViewDidChangeSelection:(CPCollectionView)collectionView; Called when the selection in the collection view has changed.

Parameters:
collectionViewthe collection view who's selection changed

-(void)collectionView:(CPCollectionView)collectionView didDoubleClickOnItemAtIndex:(int)index; Called when the user double-clicks on an item in the collection view.

Parameters:
collectionViewthe collection view that received the double-click
indexthe index of the item that received the double-click

-(CPData)collectionView:(CPCollectionView)collectionView dataForItemsAtIndexes:(CPIndexSet)indices forType:(CPString)aType; Invoked to obtain data for a set of indices.

Parameters:
collectionViewthe collection view to obtain data for
indicesthe indices to return data for
aTypethe data type
Returns:
a data object containing the index items

-(CPArray)collectionView:(CPCollectionView)collectionView dragTypesForItemsAtIndexes:(CPIndexSet)indices; Invoked to obtain the data types supported by the specified indices for placement on the pasteboard.

Parameters:
collectionViewthe collection view the items reside in
indicesthe indices to obtain drag types
Returns:
an array of drag types (CPString)

Definition at line 2 of file CPCollectionView.h.


Method Documentation

- (BOOL) acceptsFirstResponder

Returns YES by default.

Reimplemented from CPResponder.

Definition at line 220 of file CPCollectionView.j.

- (BOOL) allowsEmptySelection

Returns YES if the user can select no items, NO otherwise.

Definition at line 308 of file CPCollectionView.j.

- (BOOL) allowsMultipleSelection

Returns YES if the user can select multiple items, NO otherwise.

Definition at line 325 of file CPCollectionView.j.

- (void) awakeFromCib

Reimplemented from CPObject.

Definition at line 957 of file CPCollectionView.j.

- (CPArray) backgroundColors

Definition at line 612 of file CPCollectionView.j.

- (CPArray) content

Returns the collection view content array

Definition at line 253 of file CPCollectionView.j.

- (id) delegate

Returns the collection view's delegate

Definition at line 759 of file CPCollectionView.j.

- (void) deleteBackward: (id)  sender

Definition at line 903 of file CPCollectionView.j.

- (void) encodeWithCoder: (CPCoder aCoder

Archives the view to a coder.

Parameters:
aCoderthe object into which the view's data will be archived.

Reimplemented from CPView.

Definition at line 1008 of file CPCollectionView.j.

- (CGRect) frameForItemAtIndex: (unsigned)  anIndex

Definition at line 791 of file CPCollectionView.j.

- (CGRect) frameForItemsAtIndexes: (CPIndexSet anIndexSet

Definition at line 796 of file CPCollectionView.j.

- (id) initWithCoder: (CPCoder aCoder

Initializes the view from an archive.

Parameters:
aCoderthe coder from which to initialize
Returns:
the initialized view

Reimplemented from CPView.

Definition at line 972 of file CPCollectionView.j.

- (id) initWithFrame: (CGRect)  aFrame

Initializes the receiver for usage with the specified bounding rectangle

Returns:
the initialized view

Reimplemented from CPView.

Definition at line 97 of file CPCollectionView.j.

- (BOOL) isFirstResponder

Returns whether the receiver is currently the first responder.

Definition at line 228 of file CPCollectionView.j.

- (BOOL) isSelectable

Returns YES if the collection view is selectable, and NO otherwise.

Definition at line 291 of file CPCollectionView.j.

- (CPCollectionViewItem) itemAtIndex: (unsigned)  anIndex

Definition at line 786 of file CPCollectionView.j.

- (CPCollectionViewItem) itemPrototype

Returns the current item prototype

Definition at line 185 of file CPCollectionView.j.

- (CPArray) items

Returns the collection view items.

Definition at line 261 of file CPCollectionView.j.

- (void) keyDown: (CPEvent anEvent

Notifies the receiver that the user has pressed a key.

Parameters:
anEventinformation about the key press

Reimplemented from CPResponder.

Definition at line 918 of file CPCollectionView.j.

- (CGSize) maxItemSize

Returns the current maximum item size.

Definition at line 588 of file CPCollectionView.j.

- (unsigned) maxNumberOfColumns

Returns the maximum number of columns

Definition at line 527 of file CPCollectionView.j.

- (unsigned) maxNumberOfRows

Returns the maximum number of rows.

Definition at line 505 of file CPCollectionView.j.

- (CPMenu) menuForEvent: (CPEvent theEvent

Reimplemented from CPView.

Definition at line 767 of file CPCollectionView.j.

- (CGSize) minItemSize

Returns the current minimum item size

Definition at line 566 of file CPCollectionView.j.

- (void) mouseDown: (CPEvent anEvent

Notifies the receiver that the user has clicked the mouse down in its area.

Parameters:
anEventcontains information about the click

Reimplemented from CPView.

Definition at line 623 of file CPCollectionView.j.

- (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:
anEventcontains information about the drag

Reimplemented from CPResponder.

Definition at line 666 of file CPCollectionView.j.

- (void) mouseUp: (CPEvent anEvent

Notifies the receiver that the user has released the left mouse button.

Parameters:
anEventcontains information about the release

Reimplemented from CPResponder.

Definition at line 617 of file CPCollectionView.j.

- (void) moveDown: (id)  sender

Definition at line 875 of file CPCollectionView.j.

- (void) moveDownAndModifySelection: (id)  sender

Definition at line 880 of file CPCollectionView.j.

- (void) moveLeft: (id)  sender

Definition at line 847 of file CPCollectionView.j.

- (void) moveLeftAndModifySelection: (id)  sender

Definition at line 856 of file CPCollectionView.j.

- (void) moveRight: (id)  sender

Definition at line 865 of file CPCollectionView.j.

- (void) moveRightAndModifySelection: (id)  sender

Definition at line 870 of file CPCollectionView.j.

- (void) moveUp: (id)  sender

Definition at line 885 of file CPCollectionView.j.

- (void) moveUpAndModifySelection: (id)  sender

Definition at line 894 of file CPCollectionView.j.

- (CPCollectionViewItem) newItemForRepresentedObject: (id)  anObject

Returns a collection view item for anObject.

Parameters:
anObjectthe object to be represented.

Definition at line 194 of file CPCollectionView.j.

- (unsigned) numberOfColumns

Returns the current number of columns

Definition at line 544 of file CPCollectionView.j.

- (unsigned) numberOfRows

Returns the current number of rows

Definition at line 535 of file CPCollectionView.j.

- (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:
aPasteboardthe pasteboard to put the items on
aTypethe format the pasteboard data

Definition at line 716 of file CPCollectionView.j.

- (CGRect) rectForItemAtIndex: (int)  anIndex

Definition at line 927 of file CPCollectionView.j.

- (CGRect) rectForItemsAtIndexes: (CPIndexSet anIndexSet

Definition at line 936 of file CPCollectionView.j.

- (void) reloadContent

Definition at line 367 of file CPCollectionView.j.

- (void) resizeSubviewsWithOldSize: (CGSize)  aSize

Initiates -superviewSizeChanged: messages to subviews.

Parameters:
aSizethe size for the subviews

Reimplemented from CPView.

Definition at line 482 of file CPCollectionView.j.

- (CPIndexSet) selectionIndexes

Returns a set of the selected indices.

Definition at line 361 of file CPCollectionView.j.

- (void) setAllowsEmptySelection: (BOOL)  shouldAllowEmptySelection

Sets whether the user may have no items selected. If YES, mouse clicks not on any item will empty the current selection. The first item will also start off as selected.

Parameters:
shouldAllowMultipleSelectionYES allows the user to select multiple items

Definition at line 300 of file CPCollectionView.j.

- (void) setAllowsMultipleSelection: (BOOL)  shouldAllowMultipleSelection

Sets whether the user can select multiple items.

Parameters:
shouldAllowMultipleSelectionYES allows the user to select multiple items

Definition at line 317 of file CPCollectionView.j.

- (void) setBackgroundColors: (CPArray backgroundColors

Definition at line 593 of file CPCollectionView.j.

- (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:
anArraythe content array

Definition at line 240 of file CPCollectionView.j.

- (void) setDelegate: (id)  aDelegate

Sets the collection view's delegate

Parameters:
aDelegatethe new delegate

Definition at line 751 of file CPCollectionView.j.

- (void) setItemPrototype: (CPCollectionViewItem anItem

Sets the item prototype to anItem

The item prototype should implement the CPCoding protocol because the item is copied by archiving and unarchiving the prototypal view.

Example:

       MyCustomView : CPCollectionViewItem
      {
          CPArray   items;
      }
  • (id)initWithFrame:aFrame { self = [super initWithFrame:aFrame]; if (self) { items = []; } return self; }
  • (id)initWithCoder:aCoder { self = [super initWithCoder:aCoder]; items = [aCoder decodeObjectForKey:"KEY"]; return self; }
  • (void)encodeWithCoder:aCoder { [aCoder encodeObject:items forKey:"KEY"]; [super encodeWithCoder:aCoder]; }
      
    

This will allow the collection view to create multiple 'clean' copies of the item prototype which will maintain the original values for item and all of the properties archived by the super class.

Parameters:
anItemthe new item prototype

Definition at line 172 of file CPCollectionView.j.

- (void) setMaxItemSize: (CGSize)  aSize

Sets the maximum item size.

Parameters:
aSizethe new maximum item size

Definition at line 575 of file CPCollectionView.j.

- (void) setMaxNumberOfColumns: (unsigned)  aMaxNumberOfColumns

Sets the maximum number of columns.

Parameters:
aMaxNumberOfColumnsthe new maximum number of columns

Definition at line 514 of file CPCollectionView.j.

- (void) setMaxNumberOfRows: (unsigned)  aMaxNumberOfRows

Sets the maximum number of rows.

Parameters:
aMaxNumberOfRowsthe new maximum number of rows

Definition at line 492 of file CPCollectionView.j.

- (void) setMinItemSize: (CGSize)  aSize

Sets the minimum size for an item

Parameters:
aSizethe new minimum item size

Definition at line 553 of file CPCollectionView.j.

- (void) setSelectable: (BOOL)  isSelectable

Sets whether the user is allowed to select items

Parameters:
isSelectableYES allows the user to select items.

Definition at line 271 of file CPCollectionView.j.

- (void) setSelectionIndexes: (CPIndexSet anIndexSet

Sets the selected items based on the provided indices.

Parameters:
anIndexSetthe set of items to be selected

Definition at line 334 of file CPCollectionView.j.

- (void) setVerticalMargin: (float)  aVerticalMargin

Sets the collection view's vertical spacing between elements.

Parameters:
aVerticalMarginthe number of pixels to place between elements

Definition at line 728 of file CPCollectionView.j.

- (void) tile

Definition at line 404 of file CPCollectionView.j.

- (float) verticalMargin

Gets the collection view's current vertical spacing between elements.

Definition at line 742 of file CPCollectionView.j.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Defines