mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +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
|
@ -50,6 +50,9 @@ GS_EXPORT_CLASS
|
|||
NSUInteger _hash;
|
||||
NSUInteger _length;
|
||||
NSUInteger *_indexes;
|
||||
|
||||
NSInteger _item;
|
||||
NSInteger _section;
|
||||
#endif
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
|
@ -72,6 +75,23 @@ GS_EXPORT_CLASS
|
|||
*/
|
||||
+ (id) indexPathWithIndexes: (NSUInteger*)indexes length: (NSUInteger)length;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11,GS_API_LATEST)
|
||||
/**
|
||||
* Return a path containing an item number and section.
|
||||
*/
|
||||
+ (NSIndexPath *) indexPathForItem: (NSInteger)item inSection: (NSInteger)section;
|
||||
|
||||
/**
|
||||
* Return an index number identifying an item in a collection view
|
||||
*/
|
||||
- (NSInteger) item;
|
||||
|
||||
/**
|
||||
* Return an index number identifying a section in a collection view
|
||||
*/
|
||||
- (NSInteger) section;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Compares other with the receiver.<br />
|
||||
* Returns NSOrderedSame if the two are identical.<br />
|
||||
|
|
|
@ -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…
Reference in a new issue