mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 15:11:00 +00:00
* Source/NSTableView.m (-selectedColumnIndexes,
* -selectedRowIndexes): Return an autoreleased copy of the corresponding ivar. Returning a reference to the ivar leads to issues (and behavior different from Cocoa) when iterating thru the indexsets if at a time they would be being altered. Patch by Frank LeGrand (flegrand@testplant.com). * Source/GNUmakefile: Add NSCollectionViewItem. * Headers/AppKit/NSCollectionView.h, * Headers/AppKit/NSCollectionViewItem.h, * Source/NSCollectionViewItem.m, * Source/NSCollectionView.m: Bring closer to the GNUstep coding * standard. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36551 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
06c706a7c8
commit
ab56e573e7
7 changed files with 336 additions and 382 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2013-04-21 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSTableView.m (-selectedColumnIndexes, -selectedRowIndexes): Return an
|
||||
autoreleased copy of the corresponding ivar. Returning a reference to the ivar
|
||||
leads to issues (and behavior different from Cocoa) when iterating thru the
|
||||
indexsets if at a time they would be being altered.
|
||||
Patch by Frank LeGrand (flegrand@testplant.com).
|
||||
* Source/GNUmakefile: Add NSCollectionViewItem.
|
||||
* Headers/AppKit/NSCollectionView.h,
|
||||
* Headers/AppKit/NSCollectionViewItem.h,
|
||||
* Source/NSCollectionViewItem.m,
|
||||
* Source/NSCollectionView.m: Bring closer to the GNUstep coding standard.
|
||||
|
||||
2013-04-17 23:54-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Headers/AppKit/NSCollectionView.h
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
#ifndef _GNUstep_H_NSCollectionView
|
||||
#define _GNUstep_H_NSCollectionView
|
||||
|
||||
#import <AppKit/NSNibDeclarations.h>
|
||||
#import <GNUstepBase/GSVersionMacros.h>
|
||||
|
||||
#import <AppKit/NSView.h>
|
||||
#import <AppKit/NSDragging.h>
|
||||
#import <AppKit/NSNibDeclarations.h>
|
||||
#import <AppKit/NSView.h>
|
||||
|
||||
@class NSCollectionViewItem;
|
||||
@class NSCollectionView;
|
||||
|
@ -47,17 +47,32 @@ typedef NSInteger NSCollectionViewDropOperation;
|
|||
|
||||
@protocol NSCollectionViewDelegate <NSObject>
|
||||
|
||||
- (NSImage *)collectionView:(NSCollectionView *)collectionView draggingImageForItemsAtIndexes:(NSIndexSet *)indexes withEvent:(NSEvent *)event offset:(NSPointPointer)dragImageOffset;
|
||||
- (BOOL)collectionView:(NSCollectionView *)collectionView writeItemsAtIndexes:(NSIndexSet *)indexes toPasteboard:(NSPasteboard *)pasteboard;
|
||||
- (BOOL)collectionView:(NSCollectionView *)collectionView canDragItemsAtIndexes:(NSIndexSet *)indexes withEvent:(NSEvent *)event;
|
||||
- (NSDragOperation)collectionView:(NSCollectionView *)collectionView validateDrop:(id < NSDraggingInfo >)draggingInfo proposedIndex:(NSInteger *)proposedDropIndex dropOperation:(NSCollectionViewDropOperation *)proposedDropOperation;
|
||||
- (BOOL)collectionView:(NSCollectionView *)collectionView acceptDrop:(id < NSDraggingInfo >)draggingInfo index:(NSInteger)index dropOperation:(NSCollectionViewDropOperation)dropOperation;
|
||||
- (NSArray *)collectionView:(NSCollectionView *)collectionView namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropURL forDraggedItemsAtIndexes:(NSIndexSet *)indexes;
|
||||
- (NSImage *)collectionView:(NSCollectionView *)collectionView
|
||||
draggingImageForItemsAtIndexes:(NSIndexSet *)indexes
|
||||
withEvent:(NSEvent *)event
|
||||
offset:(NSPointPointer)dragImageOffset;
|
||||
- (BOOL)collectionView:(NSCollectionView *)collectionView
|
||||
writeItemsAtIndexes:(NSIndexSet *)indexes
|
||||
toPasteboard:(NSPasteboard *)pasteboard;
|
||||
- (BOOL)collectionView:(NSCollectionView *)collectionView
|
||||
canDragItemsAtIndexes:(NSIndexSet *)indexes
|
||||
withEvent:(NSEvent *)event;
|
||||
- (NSDragOperation)collectionView:(NSCollectionView *)collectionView
|
||||
validateDrop:(id < NSDraggingInfo >)draggingInfo
|
||||
proposedIndex:(NSInteger *)proposedDropIndex
|
||||
dropOperation:(NSCollectionViewDropOperation *)proposedDropOperation;
|
||||
- (BOOL)collectionView:(NSCollectionView *)collectionView
|
||||
acceptDrop:(id < NSDraggingInfo >)draggingInfo
|
||||
index:(NSInteger)index
|
||||
dropOperation:(NSCollectionViewDropOperation)dropOperation;
|
||||
- (NSArray *)collectionView:(NSCollectionView *)collectionView
|
||||
namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropURL
|
||||
forDraggedItemsAtIndexes:(NSIndexSet *)indexes;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface NSCollectionView : NSView
|
||||
@interface NSCollectionView : NSView //<NSDraggingDestination, NSDraggingSource>
|
||||
{
|
||||
NSArray *_content;
|
||||
IBOutlet NSCollectionViewItem *itemPrototype;
|
||||
|
@ -73,13 +88,13 @@ typedef NSInteger NSCollectionViewDropOperation;
|
|||
NSSize _itemSize;
|
||||
NSSize _maxItemSize;
|
||||
NSSize _minItemSize;
|
||||
float _tileWidth;
|
||||
float _verticalMargin;
|
||||
float _horizontalMargin;
|
||||
CGFloat _tileWidth;
|
||||
CGFloat _verticalMargin;
|
||||
CGFloat _horizontalMargin;
|
||||
|
||||
NSUInteger _maxNumberOfColumns;
|
||||
NSUInteger _maxNumberOfRows;
|
||||
long _numberOfColumns;
|
||||
NSUInteger _numberOfColumns;
|
||||
|
||||
NSDragOperation _draggingSourceOperationMaskForLocal;
|
||||
NSDragOperation _draggingSourceOperationMaskForRemote;
|
||||
|
|
|
@ -29,14 +29,16 @@
|
|||
#ifndef _GNUstep_H_NSCollectionViewItem
|
||||
#define _GNUstep_H_NSCollectionViewItem
|
||||
|
||||
#import <AppKit/NSNibDeclarations.h>
|
||||
#import <GNUstepBase/GSVersionMacros.h>
|
||||
#import <AppKit/NSTextField.h>
|
||||
#import <AppKit/NSImageView.h>
|
||||
#import <AppKit/NSView.h>
|
||||
#import <AppKit/NSViewController.h>
|
||||
#import <Foundation/NSArray.h>
|
||||
|
||||
#import <AppKit/NSCollectionView.h>
|
||||
#import <AppKit/NSDragging.h>
|
||||
#import <AppKit/NSImageView.h>
|
||||
#import <AppKit/NSNibDeclarations.h>
|
||||
#import <AppKit/NSTextField.h>
|
||||
#import <AppKit/NSView.h>
|
||||
#import <AppKit/NSViewController.h>
|
||||
|
||||
|
||||
@interface NSCollectionViewItem : NSViewController
|
||||
|
@ -47,13 +49,15 @@
|
|||
}
|
||||
|
||||
- (NSCollectionView *)collectionView;
|
||||
- (NSArray *)draggingImageComponents;
|
||||
|
||||
- (void)setSelected:(BOOL)shouldBeSelected;
|
||||
- (BOOL)isSelected;
|
||||
|
||||
- (NSTextField *)textField;
|
||||
- (NSImageView *)imageView;
|
||||
- (void)setTextField:(NSTextField *)aTextField;
|
||||
|
||||
- (NSImageView *)imageView;
|
||||
- (void)setImageView:(NSImageView *)anImageView;
|
||||
|
||||
@end
|
||||
|
|
|
@ -68,6 +68,7 @@ NSCachedImageRep.m \
|
|||
NSCell.m \
|
||||
NSClipView.m \
|
||||
NSCollectionView.m \
|
||||
NSCollectionViewItem.m \
|
||||
NSColor.m \
|
||||
NSColorList.m \
|
||||
NSColorPanel.m \
|
||||
|
@ -280,6 +281,7 @@ NSCachedImageRep.h \
|
|||
NSCell.h \
|
||||
NSClipView.h \
|
||||
NSCollectionView.h \
|
||||
NSCollectionViewItem.h \
|
||||
NSColor.h \
|
||||
NSColorList.h \
|
||||
NSColorPanel.h \
|
||||
|
|
|
@ -25,61 +25,23 @@
|
|||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#import "AppKit/NSCollectionView.h"
|
||||
#import "AppKit/NSCollectionViewItem.h"
|
||||
#import "Foundation/NSKeyedArchiver.h"
|
||||
#import <Foundation/NSGeometry.h>
|
||||
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSFormatter.h>
|
||||
#import <Foundation/NSIndexSet.h>
|
||||
#import <Foundation/NSKeyValueCoding.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSSet.h>
|
||||
#import <Foundation/NSSortDescriptor.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#import <Foundation/NSKeyedArchiver.h>
|
||||
#import <Foundation/NSTimer.h>
|
||||
|
||||
#import "AppKit/NSView.h"
|
||||
#import "AppKit/NSAnimation.h"
|
||||
#import "AppKit/NSNibLoading.h"
|
||||
#import "AppKit/NSTableView.h"
|
||||
#import "AppKit/NSApplication.h"
|
||||
#import "AppKit/NSCell.h"
|
||||
#import "AppKit/NSClipView.h"
|
||||
#import "AppKit/NSColor.h"
|
||||
#import "AppKit/NSCollectionView.h"
|
||||
#import "AppKit/NSCollectionViewItem.h"
|
||||
#import "AppKit/NSEvent.h"
|
||||
#import "AppKit/NSImage.h"
|
||||
#import "AppKit/NSGraphics.h"
|
||||
#import "AppKit/NSKeyValueBinding.h"
|
||||
#import "AppKit/NSScroller.h"
|
||||
#import "AppKit/NSScrollView.h"
|
||||
#import "AppKit/NSTableColumn.h"
|
||||
#import "AppKit/NSTableHeaderView.h"
|
||||
#import "AppKit/NSText.h"
|
||||
#import "AppKit/NSTextFieldCell.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
#import "AppKit/PSOperators.h"
|
||||
#import "AppKit/NSCachedImageRep.h"
|
||||
#import "AppKit/NSImage.h"
|
||||
#import "AppKit/NSPasteboard.h"
|
||||
#import "AppKit/NSDragging.h"
|
||||
#import "AppKit/NSCustomImageRep.h"
|
||||
#import "AppKit/NSAttributedString.h"
|
||||
#import "AppKit/NSStringDrawing.h"
|
||||
#import "GNUstepGUI/GSTheme.h"
|
||||
#import "GSBindingHelpers.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
||||
|
||||
|
||||
static NSString* NSCollectionViewMinItemSizeKey = @"NSMinGridSize";
|
||||
static NSString* NSCollectionViewMaxItemSizeKey = @"NSMaxGridSize";
|
||||
//static NSString* NSCollectionViewVerticalMarginKey = @"NSCollectionViewVerticalMarginKey";
|
||||
|
@ -104,7 +66,7 @@ static NSString *placeholderItem = nil;
|
|||
- (NSRect) _frameForRowOfItemAtIndex: (NSUInteger)theIndex;
|
||||
- (NSRect) _frameForRowsAroundItemAtIndex: (NSUInteger)theIndex;
|
||||
|
||||
- (void) _modifySelectionWithNewIndex: (int)anIndex
|
||||
- (void) _modifySelectionWithNewIndex: (NSUInteger)anIndex
|
||||
direction: (int)aDirection
|
||||
expand: (BOOL)shouldExpand;
|
||||
|
||||
|
@ -190,9 +152,9 @@ static NSString *placeholderItem = nil;
|
|||
|
||||
NSInteger firstIndexInRect = MAX(0, [self _indexAtPoint: origin]);
|
||||
NSInteger lastIndexInRect = MIN([_items count] - 1, [self _indexAtPoint: oppositeOrigin]);
|
||||
NSInteger index = firstIndexInRect;
|
||||
NSInteger index;
|
||||
|
||||
for (; index <= lastIndexInRect; index++)
|
||||
for (index = firstIndexInRect; index <= lastIndexInRect; index++)
|
||||
{
|
||||
// Calling itemAtIndex: will eventually instantiate the collection view item,
|
||||
// if it hasn't been done already.
|
||||
|
@ -251,14 +213,14 @@ static NSString *placeholderItem = nil;
|
|||
|
||||
- (void) setContent: (NSArray *)content
|
||||
{
|
||||
RELEASE (_content);
|
||||
_content = [content retain];
|
||||
NSInteger i;
|
||||
|
||||
ASSIGN(_content, content);
|
||||
[self _removeItemsViews];
|
||||
|
||||
RELEASE (_items);
|
||||
_items = [[NSMutableArray alloc] initWithCapacity: [_content count]];
|
||||
|
||||
NSInteger i;
|
||||
for (i = 0; i < [_content count]; i++)
|
||||
{
|
||||
[_items addObject: placeholderItem];
|
||||
|
@ -272,7 +234,7 @@ static NSString *placeholderItem = nil;
|
|||
{
|
||||
// Force recalculation of each item's frame
|
||||
_itemSize = _minItemSize;
|
||||
_tileWidth = -1;
|
||||
_tileWidth = -1.0;
|
||||
[self tile];
|
||||
}
|
||||
}
|
||||
|
@ -294,11 +256,7 @@ static NSString *placeholderItem = nil;
|
|||
|
||||
- (void) setItemPrototype: (NSCollectionViewItem *)prototype
|
||||
{
|
||||
|
||||
ASSIGN(itemPrototype, prototype);
|
||||
// RELEASE (itemPrototype);
|
||||
// itemPrototype = prototype;
|
||||
// RETAIN (itemPrototype);
|
||||
[self _resetItemSize];
|
||||
}
|
||||
|
||||
|
@ -401,9 +359,6 @@ static NSString *placeholderItem = nil;
|
|||
if (![_selectionIndexes isEqual: indexes])
|
||||
{
|
||||
ASSIGN(_selectionIndexes, indexes);
|
||||
// RELEASE(_selectionIndexes);
|
||||
// _selectionIndexes = indexes;
|
||||
// RETAIN(_selectionIndexes);
|
||||
}
|
||||
|
||||
NSUInteger index = 0;
|
||||
|
@ -432,16 +387,17 @@ static NSString *placeholderItem = nil;
|
|||
- (NSRect) frameForItemAtIndex: (NSUInteger)theIndex
|
||||
{
|
||||
NSRect itemFrame = NSMakeRect (0,0,0,0);
|
||||
NSInteger index = 0;
|
||||
long count = (long)[_items count];
|
||||
|
||||
if (_maxNumberOfColumns > 0 && _maxNumberOfRows > 0)
|
||||
count = MIN(count, _maxNumberOfColumns * _maxNumberOfRows);
|
||||
|
||||
NSInteger index;
|
||||
NSUInteger count = [_items count];
|
||||
CGFloat x = _horizontalMargin;
|
||||
CGFloat y = -_itemSize.height;
|
||||
|
||||
for (; index < count; ++index)
|
||||
if (_maxNumberOfColumns > 0 && _maxNumberOfRows > 0)
|
||||
{
|
||||
count = MIN(count, _maxNumberOfColumns * _maxNumberOfRows);
|
||||
}
|
||||
|
||||
for (index = 0; index < count; ++index)
|
||||
{
|
||||
if (index % _numberOfColumns == 0)
|
||||
{
|
||||
|
@ -452,10 +408,12 @@ static NSString *placeholderItem = nil;
|
|||
if (index == theIndex)
|
||||
{
|
||||
NSInteger draggingOffset = 0;
|
||||
|
||||
if (_draggingOnIndex != NSNotFound)
|
||||
{
|
||||
NSInteger draggingOnRow = (_draggingOnIndex / _numberOfColumns);
|
||||
NSInteger currentIndexRow = (theIndex / _numberOfColumns);
|
||||
|
||||
if (draggingOnRow == currentIndexRow)
|
||||
{
|
||||
if (index < _draggingOnIndex)
|
||||
|
@ -480,9 +438,8 @@ static NSString *placeholderItem = nil;
|
|||
- (NSRect) _frameForRowOfItemAtIndex: (NSUInteger)theIndex
|
||||
{
|
||||
NSRect itemFrame = [self frameForItemAtIndex: theIndex];
|
||||
NSPoint origin = NSMakePoint (0, itemFrame.origin.y);
|
||||
NSSize size = NSMakeSize([self bounds].size.width, itemFrame.size.height);
|
||||
return NSMakeRect (origin.x, origin.y, size.width, size.height);
|
||||
|
||||
return NSMakeRect (0, itemFrame.origin.y, [self bounds].size.width, itemFrame.size.height);
|
||||
}
|
||||
|
||||
// Returns the frame of an item's row with the row above and the row below
|
||||
|
@ -491,13 +448,14 @@ static NSString *placeholderItem = nil;
|
|||
NSRect itemRowFrame = [self _frameForRowOfItemAtIndex: theIndex];
|
||||
CGFloat y = MAX (0, itemRowFrame.origin.y - itemRowFrame.size.height);
|
||||
CGFloat height = MIN (itemRowFrame.size.height * 3, [self bounds].size.height);
|
||||
NSRect rowsRect = NSMakeRect(0, y, itemRowFrame.size.width, height);
|
||||
return rowsRect;
|
||||
|
||||
return NSMakeRect(0, y, itemRowFrame.size.width, height);
|
||||
}
|
||||
|
||||
- (NSCollectionViewItem *) itemAtIndex: (NSUInteger)index
|
||||
{
|
||||
id item = [_items objectAtIndex: index];
|
||||
|
||||
if (item == placeholderItem)
|
||||
{
|
||||
item = [self newItemForRepresentedObject: [_content objectAtIndex: index]];
|
||||
|
@ -527,14 +485,16 @@ static NSString *placeholderItem = nil;
|
|||
if (!_items)
|
||||
return;
|
||||
|
||||
long count = [_items count];
|
||||
NSUInteger count = [_items count];
|
||||
|
||||
while (count--)
|
||||
{
|
||||
if ([[_items objectAtIndex:count] respondsToSelector:@selector(view)])
|
||||
id item = [_items objectAtIndex: count];
|
||||
|
||||
if ([item respondsToSelector: @selector(view)])
|
||||
{
|
||||
[[[_items objectAtIndex:count] view] removeFromSuperview];
|
||||
[[_items objectAtIndex:count] setSelected:NO];
|
||||
[[item view] removeFromSuperview];
|
||||
[item setSelected: NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -561,7 +521,6 @@ static NSString *placeholderItem = nil;
|
|||
}
|
||||
|
||||
CGFloat remaining = width - _numberOfColumns * itemSize.width;
|
||||
BOOL itemsNeedSizeUpdate = NO;
|
||||
|
||||
if (remaining > 0 && itemSize.width < _maxItemSize.width)
|
||||
{
|
||||
|
@ -578,11 +537,10 @@ static NSString *placeholderItem = nil;
|
|||
if (!NSEqualSizes(_itemSize, itemSize))
|
||||
{
|
||||
_itemSize = itemSize;
|
||||
itemsNeedSizeUpdate = YES;
|
||||
}
|
||||
|
||||
NSInteger index = 0;
|
||||
long count = (long)[_items count];
|
||||
NSInteger index;
|
||||
NSUInteger count = [_items count];
|
||||
|
||||
if (_maxNumberOfColumns > 0 && _maxNumberOfRows > 0)
|
||||
{
|
||||
|
@ -593,7 +551,7 @@ static NSString *placeholderItem = nil;
|
|||
(_numberOfColumns + 1));
|
||||
CGFloat y = -itemSize.height;
|
||||
|
||||
for (; index < count; ++index)
|
||||
for (index = 0; index < count; ++index)
|
||||
{
|
||||
if (index % _numberOfColumns == 0)
|
||||
{
|
||||
|
@ -631,10 +589,8 @@ static NSString *placeholderItem = nil;
|
|||
{
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
_items = [NSMutableArray array];
|
||||
_content = [NSArray array];
|
||||
|
||||
_itemSize = NSMakeSize(0, 0);
|
||||
_tileWidth = -1.0;
|
||||
|
||||
_minItemSize = [aCoder decodeSizeForKey: NSCollectionViewMinItemSizeKey];
|
||||
_maxItemSize = [aCoder decodeSizeForKey: NSCollectionViewMaxItemSizeKey];
|
||||
|
@ -648,10 +604,6 @@ static NSString *placeholderItem = nil;
|
|||
_allowsMultipleSelection = [aCoder decodeBoolForKey: NSCollectionViewAllowsMultipleSelectionKey];
|
||||
|
||||
[self setBackgroundColors: [aCoder decodeObjectForKey: NSCollectionViewBackgroundColorsKey]];
|
||||
|
||||
_tileWidth = -1.0;
|
||||
|
||||
_selectionIndexes = [NSIndexSet indexSet];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -703,7 +655,6 @@ static NSString *placeholderItem = nil;
|
|||
NSInteger index = [self _indexAtPoint: location];
|
||||
NSEvent *lastEvent = theEvent;
|
||||
BOOL done = NO;
|
||||
|
||||
NSUInteger eventMask = (NSLeftMouseUpMask
|
||||
| NSLeftMouseDownMask
|
||||
| NSLeftMouseDraggedMask
|
||||
|
@ -750,8 +701,8 @@ static NSString *placeholderItem = nil;
|
|||
if (_isSelectable && (index < [_items count]))
|
||||
{
|
||||
if (_allowsMultipleSelection
|
||||
&& (([theEvent modifierFlags] & NSControlKeyMask) || ([theEvent modifierFlags] & NSShiftKeyMask)))
|
||||
|
||||
&& (([theEvent modifierFlags] & NSControlKeyMask)
|
||||
|| ([theEvent modifierFlags] & NSShiftKeyMask)))
|
||||
{
|
||||
if ([theEvent modifierFlags] & NSControlKeyMask)
|
||||
{
|
||||
|
@ -767,7 +718,7 @@ static NSString *placeholderItem = nil;
|
|||
}
|
||||
else if ([theEvent modifierFlags] & NSShiftKeyMask)
|
||||
{
|
||||
long firstSelectedIndex = [currentIndexSet firstIndex];
|
||||
NSUInteger firstSelectedIndex = [currentIndexSet firstIndex];
|
||||
NSRange selectedRange;
|
||||
|
||||
if (firstSelectedIndex == NSNotFound)
|
||||
|
@ -791,8 +742,6 @@ static NSString *placeholderItem = nil;
|
|||
[self setSelectionIndexes: [NSIndexSet indexSetWithIndex: index]];
|
||||
}
|
||||
[[self window] makeFirstResponder: self];
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -879,7 +828,7 @@ static NSString *placeholderItem = nil;
|
|||
|
||||
-(void) _moveLeftAndExpandSelection: (BOOL)shouldExpand
|
||||
{
|
||||
NSInteger index = [[self selectionIndexes] firstIndex];
|
||||
NSUInteger index = [[self selectionIndexes] firstIndex];
|
||||
if (index != NSNotFound && index != 0)
|
||||
{
|
||||
[self _modifySelectionWithNewIndex: index - 1 direction: -1 expand: shouldExpand];
|
||||
|
@ -903,14 +852,14 @@ static NSString *placeholderItem = nil;
|
|||
|
||||
-(void) _moveRightAndExpandSelection: (BOOL)shouldExpand
|
||||
{
|
||||
NSInteger index = [[self selectionIndexes] lastIndex];
|
||||
NSUInteger index = [[self selectionIndexes] lastIndex];
|
||||
if (index != NSNotFound && index != ([_items count] - 1))
|
||||
{
|
||||
[self _modifySelectionWithNewIndex: index + 1 direction: 1 expand: shouldExpand];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _modifySelectionWithNewIndex: (int)anIndex
|
||||
- (void) _modifySelectionWithNewIndex: (NSUInteger)anIndex
|
||||
direction: (int)aDirection
|
||||
expand: (BOOL)shouldExpand
|
||||
{
|
||||
|
@ -919,8 +868,8 @@ static NSString *placeholderItem = nil;
|
|||
if (_allowsMultipleSelection && shouldExpand)
|
||||
{
|
||||
NSMutableIndexSet *newIndexSet = [[NSMutableIndexSet alloc] initWithIndexSet: _selectionIndexes];
|
||||
NSInteger firstIndex = [newIndexSet firstIndex];
|
||||
NSInteger lastIndex = [newIndexSet lastIndex];
|
||||
NSUInteger firstIndex = [newIndexSet firstIndex];
|
||||
NSUInteger lastIndex = [newIndexSet lastIndex];
|
||||
if (aDirection == -1)
|
||||
{
|
||||
[newIndexSet addIndexesInRange:NSMakeRange (anIndex, firstIndex - anIndex + 1)];
|
||||
|
@ -972,6 +921,7 @@ static NSString *placeholderItem = nil;
|
|||
clickedIndex: (NSUInteger)index
|
||||
{
|
||||
NSIndexSet *dragIndexes = _selectionIndexes;
|
||||
|
||||
if (![dragIndexes containsIndex: index]
|
||||
&& (index < [_items count]))
|
||||
{
|
||||
|
@ -1105,9 +1055,10 @@ clickedIndex:(NSUInteger)index
|
|||
|
||||
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
_draggingOnIndex = NSNotFound;
|
||||
NSPoint location = [self convertPoint: [sender draggingLocation] fromView: nil];
|
||||
NSInteger index = [self _indexAtPoint: location];
|
||||
|
||||
_draggingOnIndex = NSNotFound;
|
||||
[self setNeedsDisplayInRect: [self _frameForRowsAroundItemAtIndex: index]];
|
||||
return YES;
|
||||
}
|
||||
|
|
|
@ -25,50 +25,13 @@
|
|||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#import "AppKit/NSCollectionViewItem.h"
|
||||
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSFormatter.h>
|
||||
#import <Foundation/NSIndexSet.h>
|
||||
#import <Foundation/NSKeyValueCoding.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSSet.h>
|
||||
#import <Foundation/NSSortDescriptor.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSKeyedArchiver.h>
|
||||
|
||||
#import "AppKit/NSTableView.h"
|
||||
#import "AppKit/NSApplication.h"
|
||||
#import "AppKit/NSCell.h"
|
||||
#import "AppKit/NSClipView.h"
|
||||
#import "AppKit/NSColor.h"
|
||||
#import "AppKit/NSEvent.h"
|
||||
#import "AppKit/NSImage.h"
|
||||
#import "AppKit/NSGraphics.h"
|
||||
#import "AppKit/NSKeyValueBinding.h"
|
||||
#import "AppKit/NSScroller.h"
|
||||
#import "AppKit/NSScrollView.h"
|
||||
#import "AppKit/NSTableColumn.h"
|
||||
#import "AppKit/NSTableHeaderView.h"
|
||||
#import "AppKit/NSText.h"
|
||||
#import "AppKit/NSTextFieldCell.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
#import "AppKit/PSOperators.h"
|
||||
#import "AppKit/NSCachedImageRep.h"
|
||||
#import "AppKit/NSPasteboard.h"
|
||||
#import "AppKit/NSDragging.h"
|
||||
#import "AppKit/NSCustomImageRep.h"
|
||||
#import "AppKit/NSAttributedString.h"
|
||||
#import "AppKit/NSStringDrawing.h"
|
||||
#import "GNUstepGUI/GSTheme.h"
|
||||
#import "GSBindingHelpers.h"
|
||||
|
||||
#include <math.h>
|
||||
#import "AppKit/NSCollectionView.h"
|
||||
#import "AppKit/NSCollectionViewItem.h"
|
||||
#import "AppKit/NSImageView.h"
|
||||
#import "AppKit/NSTextField.h"
|
||||
|
||||
@implementation NSCollectionViewItem
|
||||
|
||||
|
@ -93,6 +56,12 @@
|
|||
return (NSCollectionView *)[[self view] superview];
|
||||
}
|
||||
|
||||
- (NSArray *) draggingImageComponents
|
||||
{
|
||||
// FIXME: We don't have NSDraggingImageComponent
|
||||
return [NSArray array];
|
||||
}
|
||||
|
||||
- (void) setSelected: (BOOL)flag
|
||||
{
|
||||
if (_isSelected != flag)
|
||||
|
@ -168,7 +137,7 @@
|
|||
else
|
||||
{
|
||||
[aCoder encodeObject: textField];
|
||||
[aCoder encodeObject:imageView]
|
||||
[aCoder encodeObject: imageView];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2884,12 +2884,12 @@ byExtendingSelection: (BOOL)flag
|
|||
|
||||
- (NSIndexSet *) selectedColumnIndexes
|
||||
{
|
||||
return _selectedColumns;
|
||||
return [[_selectedColumns copy] autorelease];
|
||||
}
|
||||
|
||||
- (NSIndexSet *) selectedRowIndexes
|
||||
{
|
||||
return _selectedRows;
|
||||
return [[_selectedRows copy] autorelease];
|
||||
}
|
||||
|
||||
- (void) deselectColumn: (NSInteger)columnIndex
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue