Control CollectionControl Inherits NSCollectionViewControlMBS
ControlInstance CollectionControl Inherits NSCollectionViewControlMBS
EventHandler Sub ItemPrepareForReuse(item as NSCollectionViewItemMBS)
System.DebugLog CurrentMethodName+ " "+ str(item.Handle)
// item will be reused, so remove it from our CollectionViewItem
Dim it As CollectionViewItem = FindCollectionViewItem(item)
If it <> Nil Then
it.NSView.removeFromSuperview
it.ViewItem = Nil
End If
End EventHandler
EventHandler Sub Open()
Me.ScrollView.autohidesScrollers = True
collectionView = Me.view
collectionView.selectable = True
collectionView.allowsMultipleSelection = True
collectionView.setBackgroundColors Array(NSColorMBS.lightGrayColor)
Dim flowLayout As New NSCollectionViewFlowLayoutMBS
flowLayout.itemSize = New NSSizeMBS(300.0, 300.0)
flowLayout.sectionInset = New NSEdgeInsetsMBS(10.0, 20.0, 10.0, 20.0)
flowLayout.minimumInteritemSpacing = 20.0
flowLayout.minimumLineSpacing = 20.0
collectionView.collectionViewLayout = flowLayout
End EventHandler
EventHandler Sub didDeselectItems(indexPaths() as NSIndexPathMBS)
// items got deselected, so we make text non-bold
System.DebugLog CurrentMethodName
For Each indexPath As NSIndexPathMBS In indexPaths
Dim item As CollectionViewItem = items(indexPath.item)
item.ImageContainer.NameField.Bold = False
Next
End EventHandler
EventHandler Sub didEndDisplayingItem(item as NSCollectionViewItemMBS, indexPath as NSIndexPathMBS)
// item left viewing area
System.DebugLog CurrentMethodName+ " "+ str(item.Handle)
End EventHandler
EventHandler Sub didSelectItems(indexPaths() as NSIndexPathMBS)
// items got selected, so we make text bold
System.DebugLog CurrentMethodName
For Each indexPath As NSIndexPathMBS In indexPaths
Dim item As CollectionViewItem = items(indexPath.item)
item.ImageContainer.NameField.Bold = true
Next
End EventHandler
EventHandler Function itemForRepresentedObject(indexPath as NSIndexPathMBS) As NSCollectionViewItemMBS
// we need an item to show an image
System.DebugLog CurrentMethodName+ " "+ str(indexPath.item)
// lookup the image item for the path.
// Could use indexPath.section if you have multiple sections
Dim item As CollectionViewItem = items(indexPath.item)
// make a new item. May recycle old items
Dim ViewItem As NSCollectionViewItemMBS = collectionView.makeItem(indexPath)
// load image if needed
item.load ViewItem
item.ImageContainer.NameField.Text = Str(indexPath.item)
Return ViewItem
Exception n As NSExceptionMBS
System.DebugLog n.message
End EventHandler
EventHandler Function numberOfItemsInSection(section as Integer) As Integer
// return number of items per section
// as we only show image list, we return number of images
Return items.Ubound+1
End EventHandler
EventHandler Function numberOfSections() As Integer
// return how many sections. This example only has one
Return 1
End EventHandler
EventHandler Sub willDisplayItem(item as NSCollectionViewItemMBS, indexPath as NSIndexPathMBS)
// item will show soon. Prepare for drawing soon
System.DebugLog CurrentMethodName + " "+ Str(item.Handle)
End EventHandler
End Control