mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Add necessary methods to NSIndexPath to support NSCollectionView with layouts. Needed item,section information in NSIndexPath object
This commit is contained in:
parent
ea1575b63c
commit
f42def6ea5
2 changed files with 61 additions and 0 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue