Add necessary methods to NSIndexPath to support NSCollectionView with layouts. Needed item,section information in NSIndexPath object

This commit is contained in:
Gregory John Casamento 2022-03-03 02:26:33 -05:00
parent ea1575b63c
commit f42def6ea5
2 changed files with 61 additions and 0 deletions

View file

@ -40,6 +40,27 @@ static Class myClass = 0;
static NSIndexPath *empty = nil;
static NSIndexPath *dummy = nil;
@interface NSIndexPath (__GNUstepPrivate__)
- (void) _setSection: (NSInteger)section;
- (void) _setItem: (NSInteger)item;
@end
@implementation NSIndexPath (__GNUstepPrivate__)
- (void) _setSection: (NSInteger)section
{
_section = section;
}
- (void) _setItem: (NSInteger)item
{
_item = item;
}
@end
@implementation NSIndexPath
+ (id) allocWithZone: (NSZone*)aZone
@ -64,6 +85,16 @@ static NSIndexPath *dummy = nil;
return AUTORELEASE(o);
}
+ (NSIndexPath *) indexPathForItem: (NSInteger)item inSection: (NSInteger)section;
{
id o = [self allocWithZone: NSDefaultMallocZone()];
[o _setItem: item];
[o _setSection: section];
return AUTORELEASE(o);
}
+ (void) initialize
{
if (empty == nil)
@ -198,6 +229,16 @@ static NSIndexPath *dummy = nil;
}
}
- (NSInteger) item
{
return _item;
}
- (NSInteger) section
{
return _section;
}
- (void) getIndexes: (NSUInteger*)aBuffer
{
memcpy(aBuffer, _indexes, _length * sizeof(NSUInteger));