Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/AppKit.framework |
Availability | Available in Mac OS X v10.5 and later. |
Companion guide | |
Declared in | NSCollectionView.h |
NSCollectionView
class displays an array of content as a grid of views. The views are specified using the NSCollectionViewItem
class which makes loadings nibs containing the view easy, and supports bindings.
– setSelectable:
– isSelectable
– setAllowsMultipleSelection:
– allowsMultipleSelection
– setSelectionIndexes:
– selectionIndexes
– setMaxNumberOfRows:
– maxNumberOfRows
– setMaxNumberOfColumns:
– maxNumberOfColumns
– setMinItemSize:
– minItemSize
– setMaxItemSize:
– maxItemSize
Returns a Boolean value that indicates whether the receiver allows the user to select more than one item at a time.
- (BOOL)allowsMultipleSelection
YES
if the receiver allows the user to select more than one column or row at a time, otherwise NO
.
NSCollectionView.h
Return the receiver’s background colors.
- (NSArray *)backgroundColors
Returns an array containing the receiver’s background colors.
NSCollectionView.h
Returns the receiver’s content object.
- (NSArray *)content
An array containing the receiver’s content.
This property is observable using key-value observing.
NSCollectionView.h
Returns the receiver’s delegate.
- (id < NSCollectionViewDelegate >)delegate
The receiver’s delegate object.
NSCollectionView.h
This method computes and returns an image to use for dragging.
- (NSImage *)draggingImageForItemsAtIndexes:(NSIndexSet *)indexes withEvent:(NSEvent *)event offset:(NSPointPointer)dragImageOffset
The index set of the items to be dragged.
Mouse drag event.
An in/out parameter that will initially be set to NSZeroPoint
. it can be modified to reposition the returned image. A dragImageOffset of NSZeroPoint
will cause the image to be centered under the mouse.
An image containing a rendering of the visible portions of the views for each item.
You can override the default image by subclassing NSCollectionView and overriding this method, or by implementing the collectionView:draggingImageForItemsAtIndexes:withEvent:offset:
delegate method, it will be preferred over this method.
NSCollectionView.h
Returns the frame of the collection view item at the specified index.
- (NSRect)frameForItemAtIndex:(NSUInteger)index
The index of the collection view item.
Returns the frame calculated by the receiver where it intends to place the subview for the NSCollectionViewItem
at the given index. The rectangle is returned in the receiver’s coordinate system.
You can use this method in the collectionView:draggingImageForItemsAtIndexes:withEvent:offset:
method to determine which views are in the visible portion of the enclosing scroll view.
Overriding this method will have no effect on the receiver's subview layout.
NSCollectionView.h
Returns whether the receiver is the first responder.
- (BOOL)isFirstResponder
YES
if the receiver is the first responder, otherwise NO
.
This method is fully key-value observing compliant.
NSCollectionView.h
Returns a Boolean value that indicates whether the receiver allows the user to select items, NO
if it doesn’t.
- (BOOL)isSelectable
YES
if the receiver allows the user to select items, otherwise NO
.
NSCollectionView.h
Returns the collection view item for the represented object at the specified index.
- (NSCollectionViewItem *)itemAtIndex:(NSUInteger)index
The index of the collection view item.
An instance of NSCollectionViewItem
.
Rather than using the NSCollectionViewItem
instance returned by this method to determine the frame of the collection item’s view you should use frameForItemAtIndex:
, it is significantly more efficient.
NSCollectionView.h
Returns the receiver’s collection view item prototype.
- (NSCollectionViewItem *)itemPrototype
The receiver’s collection view item prototype.
NSCollectionView.h
Returns the maximum size used to display individual collection view items in the grid
- (NSSize)maxItemSize
The maximum size, measured in points, used to display individual collection view items.
NSCollectionView.h
Returns the maximum number of columns the receiver will display.
- (NSUInteger)maxNumberOfColumns
The maximum number of columns the receiver will display.
NSCollectionView.h
Returns the maximum number of rows the receiver will display.
- (NSUInteger)maxNumberOfRows
The maximum number of rows the receiver will display.
NSCollectionView.h
Returns the minimum size used to display individual collection view items in the grid.
- (NSSize)minItemSize
The minimum size, measured in points, used to display individual collection view items.
NSCollectionView.h
Returns the collection view item that is used for the specified object.
- (NSCollectionViewItem *)newItemForRepresentedObject:(id)object
The content object that the collection view item will represent.
An initialized collection view item with the specified object and the appropriate view set. The collection view item should not be autoreleased.
Subclasses can override this method if the collection view items are not generated from a prototype or if the prototype view needs to be modified. The subclass is responsible for setting the view
and representedObject
of the new collection view item.
NSCollectionView.h
Returns an index set containing the indexes of the receiver’s currently selected objects in the content array.
- (NSIndexSet *)selectionIndexes
An index set containing the indexes of the receiver’s currently selected objects in the content array.
This property is observable using key-value observing.
NSCollectionView.h
Controls whether the user can select multiple items at a time.
- (void)setAllowsMultipleSelection:(BOOL)flag
YES
to allow the user to select multiple items, otherwise NO
.
NSCollectionView.h
Sets the receiver's background colors to the specified array of colors.
- (void)setBackgroundColors:(NSArray *)colors
An array containing the background colors for the receiver.
Passing an empty array or nil
resets the background colors to their default values provided by controlAlternatingRowBackgroundColors
.
NSCollectionView.h
Sets the receiver’s content array.
- (void)setContent:(NSArray *)content
An array containing the receiver’s content.
The content array can also be provided by creating a binding between the receiver’s NSContentBinding
and an array controller’s arrangedObjects
method.
NSCollectionView.h
Sets the receiver’s delegate.
- (void)setDelegate:(id < NSCollectionViewDelegate >)aDelegate
The delegate object for the receiver. The delegate must conform to the NSCollectionViewDelegate Protocol
protocol.
NSCollectionView.h
Configures the default value returned from draggingSourceOperationMaskForLocal:
.
- (void)setDraggingSourceOperationMask:(NSDragOperation)dragOperationMask forLocal:(BOOL)localDestination
The types of drag operations allowed.
If YES
, mask applies when the drag destination object is in the same application as the receiver; if NO
, mask applies when the destination object is outside the receiver’s application.
By default, this method returns NSDragOperationEvery
when localDestination is YES
and NSDragOperationNone
when localDestination is NO
. NSCollectionView
will save the values you set for each localDestination value.
You typically will invoke this method, and not override it.
NSCollectionView.h
Sets the receiver’s item prototype to the specified collection view item.
- (void)setItemPrototype:(NSCollectionViewItem *)prototype
The collection view item used as the prototype by the receiver.
NSCollectionView.h
Sets the maximum size used to display individual collection view items in the grid.
- (void)setMaxItemSize:(NSSize)size
The new maximum size, measured in points, with which to display individual collection view items.
Setting the size to (0,0) specifies no maximum grid size. The default is (0.0). If the view in the receiver’s collection view item prototype is resizable you should set this to the maximum size that the view should be displayed using.
NSCollectionView.h
Sets the maximum number of columns the receiver will display
- (void)setMaxNumberOfColumns:(NSUInteger)number
The maximum number of columns the receiver will display.
Setting to 0 specifies no maximum number of columns. Defaults to 0.
It is possible for a NSCollectionView
instance to specify both the maximum number of rows and a maximum number of columns. If the number of content objects exceeds the number of displayable items (n=maxNumberOfRows
* maxNumberOfColumns
) only the first n items of the content array are displayed.
NSCollectionView.h
Sets the maximum number of rows the receiver will display.
- (void)setMaxNumberOfRows:(NSUInteger)number
The maximum number of rows the receiver can display.
Setting to 0 specifies no maximum number of rows. Defaults to 0.
It is possible for a NSCollectionView
instance to specify both the maximum number of rows and a maximum number of columns. If the number of content objects exceeds the number of displayable items (n=maxNumberOfRows
* maxNumberOfColumns
) only the first n items of the content array are displayed.
NSCollectionView.h
Sets the minimum size used to display individual layout items in the grid.
- (void)setMinItemSize:(NSSize)size
The new minimum size, measured in points, with which to display individual layout items.
The default is (0.0). If the view in the receiver’s collection view item prototype is resizable you should set this to the minimum size that the view should be displayed using.
NSCollectionView.h
Controls whether the receiver allows the user to select items.
- (void)setSelectable:(BOOL)flag
If flag is YES
, the receiver allows the user to select items; if flag is NO
, it doesn’t.
You can set selections programmatically regardless of this setting.
NSCollectionView.h
Sets the receiver’s selection using the specified indexes.
- (void)setSelectionIndexes:(NSIndexSet *)indexes
The set of selection indexes for the receiver.
To select all the receiver’s objects, indexes should be an index set with indexes [0...count -1]. To deselect all indexes, pass an empty index set.
NSCollectionView.h
These constants specify if acceptance of a drop should be at the item it is dropped on or before the item. These constants are used by the collectionView:acceptDrop:index:dropOperation:
and collectionView:validateDrop:proposedIndex:dropOperation:
methods in NSCollectionViewDelegate Protocol
enum { NSCollectionViewDropOn = 0, NSCollectionViewDropBefore = 1, }; typedef NSInteger NSCollectionViewDropOperation;
NSCollectionViewDropOn
The drop occurs at the collection view item to which the item was dragged.
Available in Mac OS X v10.6 and later.
Declared in NSCollectionView.h
.
NSCollectionViewDropBefore
The drop occurs above the collection view item to which the item was dragged..
Available in Mac OS X v10.6 and later.
Declared in NSCollectionView.h
.
Last updated: 2009-11-17