Inherits from NSView
Declared in CNGridView.h

Overview

CNGridView is a (wanna be) replacement for NSCollectionView. It has full delegate and dataSource support with method calls like known from NSTableView/UITableView.

The use of CNGridView is just simple as possible.

Tasks

Managing the Delegate and the Data Source

  •   delegate

    Property for the receiver’s delegate.

    property
  •   dataSource

    Property for the receiver’s data source.

    property

Configuring the GridView

Creating GridView Items

Managing the Content

Managing Selections

Reloading GridView Data

Properties

allowsMultipleSelection

Property that indicates whether the grid view should allow multiple item selection or not.

@property (nonatomic, assign) BOOL allowsMultipleSelection

Parameters

YES

The grid view allows multiple item selection.

NO

The grid view don’t allow multiple item selection.

Discussion

If you have this property set to YES with actually many selected items, all these items will be unselect on setting allowsMultipleSelection to NO.

Declared In

CNGridView.h

allowsMultipleSelectionWithDrag

Property indicates if the mouse drag operation can be used to select multiple items.

@property (nonatomic, assign) BOOL allowsMultipleSelectionWithDrag

Parameters

YES

The grid view allows multiple item selection with mouse drag.

NO

The grid view don’t allow multiple item selection with mouse drag.

Discussion

If you have this property set to YES you must also set allowsMultipleSelection

Declared In

CNGridView.h

allowsSelection

Property for setting whether the grid view allows item selection or not.

@property (nonatomic, assign) BOOL allowsSelection

Discussion

The default value is YES.

Declared In

CNGridView.h

backgroundColor

Property for the background color of the grid view.

@property (nonatomic, strong) NSColor *backgroundColor

Discussion

This color (or pattern image) will be assigned to the enclosing scroll view. In the phase of initializing CNGridView will
send the enclosing scroll view a setDrawsBackground message with YES as parameter value. So it’s guaranteed the background
will be drawn even if you forgot to set this flag in interface builder.

If you don’t use this property, the default value is [NSColor controlColor].

Declared In

CNGridView.h

dataSource

Property for the receiver’s data source.

@property (nonatomic, weak) IBOutlet id<CNGridViewDataSource> dataSource

Declared In

CNGridView.h

delegate

Property for the receiver’s delegate.

@property (nonatomic, weak) IBOutlet id<CNGridViewDelegate> delegate

Declared In

CNGridView.h

gridViewTitle

Property for a title of the grid view.

@property (nonatomic, strong) NSString *gridViewTitle

Discussion

The default value is nil.

Declared In

CNGridView.h

itemContextMenu

NSMenu to use when an item or the selected items are right clicked

@property (nonatomic, weak) IBOutlet NSMenu *itemContextMenu

Declared In

CNGridView.h

itemSize

Property for setting the grid view item size.

@property (nonatomic, assign) NSSize itemSize

Discussion

You can set this property programmatically to any value you want. On each change of this value CNGridView will automatically
refresh the entire visible grid view with an animation effect.

Declared In

CNGridView.h

scrollElasticity

Property for setting the elasticity of the enclosing NSScrollView.

@property (nonatomic, assign) BOOL scrollElasticity

Parameters

YES

Elasticity is on.

NO

Elasticity is off.

Discussion

This property will set and overwrite the values from Interface Builder. There is no horizontal-vertical distinction.
The default value is YES.

Declared In

CNGridView.h

useHover

@property (nonatomic, assign) BOOL useHover

Declared In

CNGridView.h

useSelectionRing

@property (nonatomic, assign) BOOL useSelectionRing

Declared In

CNGridView.h

Instance Methods

deSelectItem:

Removes selection for the specified item

- (void)deSelectItem:(CNGridViewItem *)theItem

Declared In

CNGridView.h

dequeueReusableItemWithIdentifier:

Returns a reusable grid view item object located by its identifier.

- (id)dequeueReusableItemWithIdentifier:(NSString *)identifier

Parameters

identifier

A string identifying the grid view item object to be reused. This parameter must not be nil.

Return Value

A CNGridViewItem object with the associated identifier or nil if no such object exists in the reusable queue.

Declared In

CNGridView.h

deselectAllItems

Deselects all the selected items in the grid

- (void)deselectAllItems

Declared In

CNGridView.h

numberOfVisibleItems

Returns the number of currently visible items of CNGridView.

- (NSUInteger)numberOfVisibleItems

Discussion

The returned value of this method is subject to continous variation. It depends on the actual size of its view and will be calculated in realtime.

Declared In

CNGridView.h

reloadData

Reloads all the items on the grid from the data source

- (void)reloadData

Declared In

CNGridView.h

selectAllItems

Selects all the items in the grid

- (void)selectAllItems

Declared In

CNGridView.h

selectItem:

Selects the specified item

- (void)selectItem:(CNGridViewItem *)theItem

Declared In

CNGridView.h

selectItemsWithBlock:

Selects all the items in the grid and passes each item to the specified block

- (void)selectItemsWithBlock:(CNGridViewSelectItem)blockSelector

Declared In

CNGridView.h

selectedIndexes

Returns an index set of the selected items

- (NSIndexSet *)selectedIndexes

Declared In

CNGridView.h

selectedItems

Returns an array of the selected CNGridViewSelectItem items.

- (NSArray *)selectedItems

Declared In

CNGridView.h

visibleIndexes

Indexes of all the visible items

- (NSIndexSet *)visibleIndexes

Declared In

CNGridView.h