mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 12:20:59 +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>
|
2013-04-17 23:54-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||||
|
|
||||||
* Headers/AppKit/NSCollectionView.h
|
* Headers/AppKit/NSCollectionView.h
|
||||||
|
|
|
@ -29,11 +29,11 @@
|
||||||
#ifndef _GNUstep_H_NSCollectionView
|
#ifndef _GNUstep_H_NSCollectionView
|
||||||
#define _GNUstep_H_NSCollectionView
|
#define _GNUstep_H_NSCollectionView
|
||||||
|
|
||||||
#import <AppKit/NSNibDeclarations.h>
|
|
||||||
#import <GNUstepBase/GSVersionMacros.h>
|
#import <GNUstepBase/GSVersionMacros.h>
|
||||||
|
|
||||||
#import <AppKit/NSView.h>
|
|
||||||
#import <AppKit/NSDragging.h>
|
#import <AppKit/NSDragging.h>
|
||||||
|
#import <AppKit/NSNibDeclarations.h>
|
||||||
|
#import <AppKit/NSView.h>
|
||||||
|
|
||||||
@class NSCollectionViewItem;
|
@class NSCollectionViewItem;
|
||||||
@class NSCollectionView;
|
@class NSCollectionView;
|
||||||
|
@ -47,17 +47,32 @@ typedef NSInteger NSCollectionViewDropOperation;
|
||||||
|
|
||||||
@protocol NSCollectionViewDelegate <NSObject>
|
@protocol NSCollectionViewDelegate <NSObject>
|
||||||
|
|
||||||
- (NSImage *)collectionView:(NSCollectionView *)collectionView draggingImageForItemsAtIndexes:(NSIndexSet *)indexes withEvent:(NSEvent *)event offset:(NSPointPointer)dragImageOffset;
|
- (NSImage *)collectionView:(NSCollectionView *)collectionView
|
||||||
- (BOOL)collectionView:(NSCollectionView *)collectionView writeItemsAtIndexes:(NSIndexSet *)indexes toPasteboard:(NSPasteboard *)pasteboard;
|
draggingImageForItemsAtIndexes:(NSIndexSet *)indexes
|
||||||
- (BOOL)collectionView:(NSCollectionView *)collectionView canDragItemsAtIndexes:(NSIndexSet *)indexes withEvent:(NSEvent *)event;
|
withEvent:(NSEvent *)event
|
||||||
- (NSDragOperation)collectionView:(NSCollectionView *)collectionView validateDrop:(id < NSDraggingInfo >)draggingInfo proposedIndex:(NSInteger *)proposedDropIndex dropOperation:(NSCollectionViewDropOperation *)proposedDropOperation;
|
offset:(NSPointPointer)dragImageOffset;
|
||||||
- (BOOL)collectionView:(NSCollectionView *)collectionView acceptDrop:(id < NSDraggingInfo >)draggingInfo index:(NSInteger)index dropOperation:(NSCollectionViewDropOperation)dropOperation;
|
- (BOOL)collectionView:(NSCollectionView *)collectionView
|
||||||
- (NSArray *)collectionView:(NSCollectionView *)collectionView namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropURL forDraggedItemsAtIndexes:(NSIndexSet *)indexes;
|
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
|
@end
|
||||||
|
|
||||||
|
|
||||||
@interface NSCollectionView : NSView
|
@interface NSCollectionView : NSView //<NSDraggingDestination, NSDraggingSource>
|
||||||
{
|
{
|
||||||
NSArray *_content;
|
NSArray *_content;
|
||||||
IBOutlet NSCollectionViewItem *itemPrototype;
|
IBOutlet NSCollectionViewItem *itemPrototype;
|
||||||
|
@ -73,13 +88,13 @@ typedef NSInteger NSCollectionViewDropOperation;
|
||||||
NSSize _itemSize;
|
NSSize _itemSize;
|
||||||
NSSize _maxItemSize;
|
NSSize _maxItemSize;
|
||||||
NSSize _minItemSize;
|
NSSize _minItemSize;
|
||||||
float _tileWidth;
|
CGFloat _tileWidth;
|
||||||
float _verticalMargin;
|
CGFloat _verticalMargin;
|
||||||
float _horizontalMargin;
|
CGFloat _horizontalMargin;
|
||||||
|
|
||||||
NSUInteger _maxNumberOfColumns;
|
NSUInteger _maxNumberOfColumns;
|
||||||
NSUInteger _maxNumberOfRows;
|
NSUInteger _maxNumberOfRows;
|
||||||
long _numberOfColumns;
|
NSUInteger _numberOfColumns;
|
||||||
|
|
||||||
NSDragOperation _draggingSourceOperationMaskForLocal;
|
NSDragOperation _draggingSourceOperationMaskForLocal;
|
||||||
NSDragOperation _draggingSourceOperationMaskForRemote;
|
NSDragOperation _draggingSourceOperationMaskForRemote;
|
||||||
|
|
|
@ -29,14 +29,16 @@
|
||||||
#ifndef _GNUstep_H_NSCollectionViewItem
|
#ifndef _GNUstep_H_NSCollectionViewItem
|
||||||
#define _GNUstep_H_NSCollectionViewItem
|
#define _GNUstep_H_NSCollectionViewItem
|
||||||
|
|
||||||
#import <AppKit/NSNibDeclarations.h>
|
|
||||||
#import <GNUstepBase/GSVersionMacros.h>
|
#import <GNUstepBase/GSVersionMacros.h>
|
||||||
#import <AppKit/NSTextField.h>
|
#import <Foundation/NSArray.h>
|
||||||
#import <AppKit/NSImageView.h>
|
|
||||||
#import <AppKit/NSView.h>
|
|
||||||
#import <AppKit/NSViewController.h>
|
|
||||||
#import <AppKit/NSCollectionView.h>
|
#import <AppKit/NSCollectionView.h>
|
||||||
#import <AppKit/NSDragging.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
|
@interface NSCollectionViewItem : NSViewController
|
||||||
|
@ -47,13 +49,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSCollectionView *)collectionView;
|
- (NSCollectionView *)collectionView;
|
||||||
|
- (NSArray *)draggingImageComponents;
|
||||||
|
|
||||||
- (void)setSelected:(BOOL)shouldBeSelected;
|
- (void)setSelected:(BOOL)shouldBeSelected;
|
||||||
- (BOOL)isSelected;
|
- (BOOL)isSelected;
|
||||||
|
|
||||||
- (NSTextField *)textField;
|
- (NSTextField *)textField;
|
||||||
- (NSImageView *)imageView;
|
|
||||||
- (void)setTextField:(NSTextField *)aTextField;
|
- (void)setTextField:(NSTextField *)aTextField;
|
||||||
|
|
||||||
|
- (NSImageView *)imageView;
|
||||||
- (void)setImageView:(NSImageView *)anImageView;
|
- (void)setImageView:(NSImageView *)anImageView;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -68,6 +68,7 @@ NSCachedImageRep.m \
|
||||||
NSCell.m \
|
NSCell.m \
|
||||||
NSClipView.m \
|
NSClipView.m \
|
||||||
NSCollectionView.m \
|
NSCollectionView.m \
|
||||||
|
NSCollectionViewItem.m \
|
||||||
NSColor.m \
|
NSColor.m \
|
||||||
NSColorList.m \
|
NSColorList.m \
|
||||||
NSColorPanel.m \
|
NSColorPanel.m \
|
||||||
|
@ -280,6 +281,7 @@ NSCachedImageRep.h \
|
||||||
NSCell.h \
|
NSCell.h \
|
||||||
NSClipView.h \
|
NSClipView.h \
|
||||||
NSCollectionView.h \
|
NSCollectionView.h \
|
||||||
|
NSCollectionViewItem.h \
|
||||||
NSColor.h \
|
NSColor.h \
|
||||||
NSColorList.h \
|
NSColorList.h \
|
||||||
NSColorPanel.h \
|
NSColorPanel.h \
|
||||||
|
|
|
@ -25,61 +25,23 @@
|
||||||
Boston, MA 02110-1301, USA.
|
Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "AppKit/NSCollectionView.h"
|
|
||||||
#import "AppKit/NSCollectionViewItem.h"
|
|
||||||
#import "Foundation/NSKeyedArchiver.h"
|
#import "Foundation/NSKeyedArchiver.h"
|
||||||
#import <Foundation/NSGeometry.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/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/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/NSApplication.h"
|
||||||
#import "AppKit/NSCell.h"
|
|
||||||
#import "AppKit/NSClipView.h"
|
#import "AppKit/NSClipView.h"
|
||||||
#import "AppKit/NSColor.h"
|
#import "AppKit/NSCollectionView.h"
|
||||||
|
#import "AppKit/NSCollectionViewItem.h"
|
||||||
#import "AppKit/NSEvent.h"
|
#import "AppKit/NSEvent.h"
|
||||||
#import "AppKit/NSImage.h"
|
|
||||||
#import "AppKit/NSGraphics.h"
|
#import "AppKit/NSGraphics.h"
|
||||||
#import "AppKit/NSKeyValueBinding.h"
|
#import "AppKit/NSImage.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/NSPasteboard.h"
|
||||||
#import "AppKit/NSDragging.h"
|
#import "AppKit/NSWindow.h"
|
||||||
#import "AppKit/NSCustomImageRep.h"
|
|
||||||
#import "AppKit/NSAttributedString.h"
|
|
||||||
#import "AppKit/NSStringDrawing.h"
|
|
||||||
#import "GNUstepGUI/GSTheme.h"
|
|
||||||
#import "GSBindingHelpers.h"
|
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static NSString* NSCollectionViewMinItemSizeKey = @"NSMinGridSize";
|
static NSString* NSCollectionViewMinItemSizeKey = @"NSMinGridSize";
|
||||||
static NSString* NSCollectionViewMaxItemSizeKey = @"NSMaxGridSize";
|
static NSString* NSCollectionViewMaxItemSizeKey = @"NSMaxGridSize";
|
||||||
//static NSString* NSCollectionViewVerticalMarginKey = @"NSCollectionViewVerticalMarginKey";
|
//static NSString* NSCollectionViewVerticalMarginKey = @"NSCollectionViewVerticalMarginKey";
|
||||||
|
@ -104,7 +66,7 @@ static NSString *placeholderItem = nil;
|
||||||
- (NSRect) _frameForRowOfItemAtIndex: (NSUInteger)theIndex;
|
- (NSRect) _frameForRowOfItemAtIndex: (NSUInteger)theIndex;
|
||||||
- (NSRect) _frameForRowsAroundItemAtIndex: (NSUInteger)theIndex;
|
- (NSRect) _frameForRowsAroundItemAtIndex: (NSUInteger)theIndex;
|
||||||
|
|
||||||
- (void) _modifySelectionWithNewIndex: (int)anIndex
|
- (void) _modifySelectionWithNewIndex: (NSUInteger)anIndex
|
||||||
direction: (int)aDirection
|
direction: (int)aDirection
|
||||||
expand: (BOOL)shouldExpand;
|
expand: (BOOL)shouldExpand;
|
||||||
|
|
||||||
|
@ -179,7 +141,7 @@ static NSString *placeholderItem = nil;
|
||||||
// TODO: Implement "use Alternating Colors"
|
// TODO: Implement "use Alternating Colors"
|
||||||
if (_backgroundColors && [_backgroundColors count] > 0)
|
if (_backgroundColors && [_backgroundColors count] > 0)
|
||||||
{
|
{
|
||||||
NSColor *bgColor = [_backgroundColors objectAtIndex:0];
|
NSColor *bgColor = [_backgroundColors objectAtIndex: 0];
|
||||||
[bgColor set];
|
[bgColor set];
|
||||||
NSRectFill(dirtyRect);
|
NSRectFill(dirtyRect);
|
||||||
}
|
}
|
||||||
|
@ -188,23 +150,23 @@ static NSString *placeholderItem = nil;
|
||||||
NSSize size = dirtyRect.size;
|
NSSize size = dirtyRect.size;
|
||||||
NSPoint oppositeOrigin = NSMakePoint (origin.x + size.width, origin.y + size.height);
|
NSPoint oppositeOrigin = NSMakePoint (origin.x + size.width, origin.y + size.height);
|
||||||
|
|
||||||
NSInteger firstIndexInRect = MAX(0, [self _indexAtPoint:origin]);
|
NSInteger firstIndexInRect = MAX(0, [self _indexAtPoint: origin]);
|
||||||
NSInteger lastIndexInRect = MIN([_items count] - 1, [self _indexAtPoint:oppositeOrigin]);
|
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,
|
// Calling itemAtIndex: will eventually instantiate the collection view item,
|
||||||
// if it hasn't been done already.
|
// if it hasn't been done already.
|
||||||
NSCollectionViewItem *collectionItem = [self itemAtIndex:index];
|
NSCollectionViewItem *collectionItem = [self itemAtIndex: index];
|
||||||
NSView *view = [collectionItem view];
|
NSView *view = [collectionItem view];
|
||||||
[view setFrame:[self frameForItemAtIndex:index]];
|
[view setFrame: [self frameForItemAtIndex: index]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
//[[NSNotificationCenter defaultCenter] removeObserver:self];
|
//[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
|
|
||||||
DESTROY (_content);
|
DESTROY (_content);
|
||||||
|
|
||||||
|
@ -228,7 +190,7 @@ static NSString *placeholderItem = nil;
|
||||||
return _allowsMultipleSelection;
|
return _allowsMultipleSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setAllowsMultipleSelection:(BOOL)flag
|
- (void) setAllowsMultipleSelection: (BOOL)flag
|
||||||
{
|
{
|
||||||
_allowsMultipleSelection = flag;
|
_allowsMultipleSelection = flag;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +203,7 @@ static NSString *placeholderItem = nil;
|
||||||
- (void) setBackgroundColors: (NSArray *)colors
|
- (void) setBackgroundColors: (NSArray *)colors
|
||||||
{
|
{
|
||||||
_backgroundColors = [colors copy];
|
_backgroundColors = [colors copy];
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *) content
|
- (NSArray *) content
|
||||||
|
@ -251,17 +213,17 @@ static NSString *placeholderItem = nil;
|
||||||
|
|
||||||
- (void) setContent: (NSArray *)content
|
- (void) setContent: (NSArray *)content
|
||||||
{
|
{
|
||||||
RELEASE (_content);
|
NSInteger i;
|
||||||
_content = [content retain];
|
|
||||||
|
ASSIGN(_content, content);
|
||||||
[self _removeItemsViews];
|
[self _removeItemsViews];
|
||||||
|
|
||||||
RELEASE (_items);
|
RELEASE (_items);
|
||||||
_items = [[NSMutableArray alloc] initWithCapacity:[_content count]];
|
_items = [[NSMutableArray alloc] initWithCapacity: [_content count]];
|
||||||
|
|
||||||
NSInteger i;
|
for (i = 0; i < [_content count]; i++)
|
||||||
for (i=0; i<[_content count]; i++)
|
|
||||||
{
|
{
|
||||||
[_items addObject:placeholderItem];
|
[_items addObject: placeholderItem];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!itemPrototype)
|
if (!itemPrototype)
|
||||||
|
@ -272,7 +234,7 @@ static NSString *placeholderItem = nil;
|
||||||
{
|
{
|
||||||
// Force recalculation of each item's frame
|
// Force recalculation of each item's frame
|
||||||
_itemSize = _minItemSize;
|
_itemSize = _minItemSize;
|
||||||
_tileWidth = -1;
|
_tileWidth = -1.0;
|
||||||
[self tile];
|
[self tile];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,11 +256,7 @@ static NSString *placeholderItem = nil;
|
||||||
|
|
||||||
- (void) setItemPrototype: (NSCollectionViewItem *)prototype
|
- (void) setItemPrototype: (NSCollectionViewItem *)prototype
|
||||||
{
|
{
|
||||||
|
|
||||||
ASSIGN(itemPrototype, prototype);
|
ASSIGN(itemPrototype, prototype);
|
||||||
// RELEASE (itemPrototype);
|
|
||||||
// itemPrototype = prototype;
|
|
||||||
// RETAIN (itemPrototype);
|
|
||||||
[self _resetItemSize];
|
[self _resetItemSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,10 +333,10 @@ static NSString *placeholderItem = nil;
|
||||||
if (!_isSelectable)
|
if (!_isSelectable)
|
||||||
{
|
{
|
||||||
NSInteger index = -1;
|
NSInteger index = -1;
|
||||||
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != NSNotFound)
|
while ((index = [_selectionIndexes indexGreaterThanIndex: index]) != NSNotFound)
|
||||||
{
|
{
|
||||||
id item = [_items objectAtIndex:index];
|
id item = [_items objectAtIndex: index];
|
||||||
if ([item respondsToSelector:@selector(setSelected:)])
|
if ([item respondsToSelector: @selector(setSelected:)])
|
||||||
{
|
{
|
||||||
[item setSelected:NO];
|
[item setSelected:NO];
|
||||||
}
|
}
|
||||||
|
@ -398,19 +356,16 @@ static NSString *placeholderItem = nil;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![_selectionIndexes isEqual:indexes])
|
if (![_selectionIndexes isEqual: indexes])
|
||||||
{
|
{
|
||||||
ASSIGN(_selectionIndexes,indexes);
|
ASSIGN(_selectionIndexes, indexes);
|
||||||
// RELEASE(_selectionIndexes);
|
|
||||||
// _selectionIndexes = indexes;
|
|
||||||
// RETAIN(_selectionIndexes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NSUInteger index = 0;
|
NSUInteger index = 0;
|
||||||
while (index < [_items count])
|
while (index < [_items count])
|
||||||
{
|
{
|
||||||
id item = [_items objectAtIndex:index];
|
id item = [_items objectAtIndex: index];
|
||||||
if ([item respondsToSelector:@selector(setSelected:)])
|
if ([item respondsToSelector: @selector(setSelected:)])
|
||||||
{
|
{
|
||||||
[item setSelected:NO];
|
[item setSelected:NO];
|
||||||
}
|
}
|
||||||
|
@ -418,13 +373,13 @@ static NSString *placeholderItem = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
index = -1;
|
index = -1;
|
||||||
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) !=
|
while ((index = [_selectionIndexes indexGreaterThanIndex: index]) !=
|
||||||
NSNotFound)
|
NSNotFound)
|
||||||
{
|
{
|
||||||
id item = [_items objectAtIndex:index];
|
id item = [_items objectAtIndex: index];
|
||||||
if ([item respondsToSelector:@selector(setSelected:)])
|
if ([item respondsToSelector: @selector(setSelected:)])
|
||||||
{
|
{
|
||||||
[item setSelected:YES];
|
[item setSelected: YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -432,16 +387,17 @@ static NSString *placeholderItem = nil;
|
||||||
- (NSRect) frameForItemAtIndex: (NSUInteger)theIndex
|
- (NSRect) frameForItemAtIndex: (NSUInteger)theIndex
|
||||||
{
|
{
|
||||||
NSRect itemFrame = NSMakeRect (0,0,0,0);
|
NSRect itemFrame = NSMakeRect (0,0,0,0);
|
||||||
NSInteger index = 0;
|
NSInteger index;
|
||||||
long count = (long)[_items count];
|
NSUInteger count = [_items count];
|
||||||
|
|
||||||
if (_maxNumberOfColumns > 0 && _maxNumberOfRows > 0)
|
|
||||||
count = MIN(count, _maxNumberOfColumns * _maxNumberOfRows);
|
|
||||||
|
|
||||||
CGFloat x = _horizontalMargin;
|
CGFloat x = _horizontalMargin;
|
||||||
CGFloat y = -_itemSize.height;
|
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)
|
if (index % _numberOfColumns == 0)
|
||||||
{
|
{
|
||||||
|
@ -452,10 +408,12 @@ static NSString *placeholderItem = nil;
|
||||||
if (index == theIndex)
|
if (index == theIndex)
|
||||||
{
|
{
|
||||||
NSInteger draggingOffset = 0;
|
NSInteger draggingOffset = 0;
|
||||||
|
|
||||||
if (_draggingOnIndex != NSNotFound)
|
if (_draggingOnIndex != NSNotFound)
|
||||||
{
|
{
|
||||||
NSInteger draggingOnRow = (_draggingOnIndex / _numberOfColumns);
|
NSInteger draggingOnRow = (_draggingOnIndex / _numberOfColumns);
|
||||||
NSInteger currentIndexRow = (theIndex / _numberOfColumns);
|
NSInteger currentIndexRow = (theIndex / _numberOfColumns);
|
||||||
|
|
||||||
if (draggingOnRow == currentIndexRow)
|
if (draggingOnRow == currentIndexRow)
|
||||||
{
|
{
|
||||||
if (index < _draggingOnIndex)
|
if (index < _draggingOnIndex)
|
||||||
|
@ -479,34 +437,34 @@ static NSString *placeholderItem = nil;
|
||||||
|
|
||||||
- (NSRect) _frameForRowOfItemAtIndex: (NSUInteger)theIndex
|
- (NSRect) _frameForRowOfItemAtIndex: (NSUInteger)theIndex
|
||||||
{
|
{
|
||||||
NSRect itemFrame = [self frameForItemAtIndex: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 (0, itemFrame.origin.y, [self bounds].size.width, itemFrame.size.height);
|
||||||
return NSMakeRect (origin.x, origin.y, size.width, size.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the frame of an item's row with the row above and the row below
|
// Returns the frame of an item's row with the row above and the row below
|
||||||
- (NSRect) _frameForRowsAroundItemAtIndex: (NSUInteger)theIndex
|
- (NSRect) _frameForRowsAroundItemAtIndex: (NSUInteger)theIndex
|
||||||
{
|
{
|
||||||
NSRect itemRowFrame = [self _frameForRowOfItemAtIndex:theIndex];
|
NSRect itemRowFrame = [self _frameForRowOfItemAtIndex: theIndex];
|
||||||
CGFloat y = MAX (0, itemRowFrame.origin.y - itemRowFrame.size.height);
|
CGFloat y = MAX (0, itemRowFrame.origin.y - itemRowFrame.size.height);
|
||||||
CGFloat height = MIN (itemRowFrame.size.height * 3, [self bounds].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
|
- (NSCollectionViewItem *) itemAtIndex: (NSUInteger)index
|
||||||
{
|
{
|
||||||
id item = [_items objectAtIndex:index];
|
id item = [_items objectAtIndex: index];
|
||||||
|
|
||||||
if (item == placeholderItem)
|
if (item == placeholderItem)
|
||||||
{
|
{
|
||||||
item = [self newItemForRepresentedObject:[_content objectAtIndex:index]];
|
item = [self newItemForRepresentedObject: [_content objectAtIndex: index]];
|
||||||
[_items replaceObjectAtIndex:index withObject:item];
|
[_items replaceObjectAtIndex: index withObject: item];
|
||||||
if ([[self selectionIndexes] containsIndex:index])
|
if ([[self selectionIndexes] containsIndex: index])
|
||||||
{
|
{
|
||||||
[item setSelected:YES];
|
[item setSelected: YES];
|
||||||
}
|
}
|
||||||
[self addSubview:[item view]];
|
[self addSubview: [item view]];
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -517,7 +475,7 @@ static NSString *placeholderItem = nil;
|
||||||
if (itemPrototype)
|
if (itemPrototype)
|
||||||
{
|
{
|
||||||
ASSIGN(collectionItem, [itemPrototype copy]);
|
ASSIGN(collectionItem, [itemPrototype copy]);
|
||||||
[collectionItem setRepresentedObject:object];
|
[collectionItem setRepresentedObject: object];
|
||||||
}
|
}
|
||||||
return AUTORELEASE (collectionItem);
|
return AUTORELEASE (collectionItem);
|
||||||
}
|
}
|
||||||
|
@ -527,14 +485,16 @@ static NSString *placeholderItem = nil;
|
||||||
if (!_items)
|
if (!_items)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
long count = [_items count];
|
NSUInteger count = [_items count];
|
||||||
|
|
||||||
while (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];
|
[[item view] removeFromSuperview];
|
||||||
[[_items objectAtIndex:count] setSelected:NO];
|
[item setSelected: NO];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -561,7 +521,6 @@ static NSString *placeholderItem = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGFloat remaining = width - _numberOfColumns * itemSize.width;
|
CGFloat remaining = width - _numberOfColumns * itemSize.width;
|
||||||
BOOL itemsNeedSizeUpdate = NO;
|
|
||||||
|
|
||||||
if (remaining > 0 && itemSize.width < _maxItemSize.width)
|
if (remaining > 0 && itemSize.width < _maxItemSize.width)
|
||||||
{
|
{
|
||||||
|
@ -578,11 +537,10 @@ static NSString *placeholderItem = nil;
|
||||||
if (!NSEqualSizes(_itemSize, itemSize))
|
if (!NSEqualSizes(_itemSize, itemSize))
|
||||||
{
|
{
|
||||||
_itemSize = itemSize;
|
_itemSize = itemSize;
|
||||||
itemsNeedSizeUpdate = YES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NSInteger index = 0;
|
NSInteger index;
|
||||||
long count = (long)[_items count];
|
NSUInteger count = [_items count];
|
||||||
|
|
||||||
if (_maxNumberOfColumns > 0 && _maxNumberOfRows > 0)
|
if (_maxNumberOfColumns > 0 && _maxNumberOfRows > 0)
|
||||||
{
|
{
|
||||||
|
@ -593,7 +551,7 @@ static NSString *placeholderItem = nil;
|
||||||
(_numberOfColumns + 1));
|
(_numberOfColumns + 1));
|
||||||
CGFloat y = -itemSize.height;
|
CGFloat y = -itemSize.height;
|
||||||
|
|
||||||
for (; index < count; ++index)
|
for (index = 0; index < count; ++index)
|
||||||
{
|
{
|
||||||
if (index % _numberOfColumns == 0)
|
if (index % _numberOfColumns == 0)
|
||||||
{
|
{
|
||||||
|
@ -603,15 +561,15 @@ static NSString *placeholderItem = nil;
|
||||||
|
|
||||||
id superview = [self superview];
|
id superview = [self superview];
|
||||||
CGFloat proposedHeight = y + itemSize.height + _verticalMargin;
|
CGFloat proposedHeight = y + itemSize.height + _verticalMargin;
|
||||||
if ([superview isKindOfClass:[NSClipView class]])
|
if ([superview isKindOfClass: [NSClipView class]])
|
||||||
{
|
{
|
||||||
NSSize superviewSize = [superview bounds].size;
|
NSSize superviewSize = [superview bounds].size;
|
||||||
proposedHeight = MAX(superviewSize.height, proposedHeight);
|
proposedHeight = MAX(superviewSize.height, proposedHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
_tileWidth = width;
|
_tileWidth = width;
|
||||||
[self setFrameSize:NSMakeSize(width, proposedHeight)];
|
[self setFrameSize: NSMakeSize(width, proposedHeight)];
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) resizeSubviewsWithOldSize: (NSSize)aSize
|
- (void) resizeSubviewsWithOldSize: (NSSize)aSize
|
||||||
|
@ -629,29 +587,23 @@ static NSString *placeholderItem = nil;
|
||||||
|
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
if([aCoder allowsKeyedCoding])
|
if ([aCoder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
_items = [NSMutableArray array];
|
|
||||||
_content = [NSArray array];
|
|
||||||
|
|
||||||
_itemSize = NSMakeSize(0, 0);
|
_itemSize = NSMakeSize(0, 0);
|
||||||
|
|
||||||
_minItemSize = [aCoder decodeSizeForKey:NSCollectionViewMinItemSizeKey];
|
|
||||||
_maxItemSize = [aCoder decodeSizeForKey:NSCollectionViewMaxItemSizeKey];
|
|
||||||
|
|
||||||
_maxNumberOfRows = [aCoder decodeInt64ForKey:NSCollectionViewMaxNumberOfRowsKey];
|
|
||||||
_maxNumberOfColumns = [aCoder decodeInt64ForKey:NSCollectionViewMaxNumberOfColumnsKey];
|
|
||||||
|
|
||||||
//_verticalMargin = [aCoder decodeFloatForKey:NSCollectionViewVerticalMarginKey];
|
|
||||||
|
|
||||||
_isSelectable = [aCoder decodeBoolForKey:NSCollectionViewSelectableKey];
|
|
||||||
_allowsMultipleSelection = [aCoder decodeBoolForKey:NSCollectionViewAllowsMultipleSelectionKey];
|
|
||||||
|
|
||||||
[self setBackgroundColors:[aCoder decodeObjectForKey:NSCollectionViewBackgroundColorsKey]];
|
|
||||||
|
|
||||||
_tileWidth = -1.0;
|
_tileWidth = -1.0;
|
||||||
|
|
||||||
_selectionIndexes = [NSIndexSet indexSet];
|
_minItemSize = [aCoder decodeSizeForKey: NSCollectionViewMinItemSizeKey];
|
||||||
|
_maxItemSize = [aCoder decodeSizeForKey: NSCollectionViewMaxItemSizeKey];
|
||||||
|
|
||||||
|
_maxNumberOfRows = [aCoder decodeInt64ForKey: NSCollectionViewMaxNumberOfRowsKey];
|
||||||
|
_maxNumberOfColumns = [aCoder decodeInt64ForKey: NSCollectionViewMaxNumberOfColumnsKey];
|
||||||
|
|
||||||
|
//_verticalMargin = [aCoder decodeFloatForKey: NSCollectionViewVerticalMarginKey];
|
||||||
|
|
||||||
|
_isSelectable = [aCoder decodeBoolForKey: NSCollectionViewSelectableKey];
|
||||||
|
_allowsMultipleSelection = [aCoder decodeBoolForKey: NSCollectionViewAllowsMultipleSelectionKey];
|
||||||
|
|
||||||
|
[self setBackgroundColors: [aCoder decodeObjectForKey: NSCollectionViewBackgroundColorsKey]];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -664,32 +616,32 @@ static NSString *placeholderItem = nil;
|
||||||
|
|
||||||
- (void) encodeWithCoder: (NSCoder *)aCoder
|
- (void) encodeWithCoder: (NSCoder *)aCoder
|
||||||
{
|
{
|
||||||
[super encodeWithCoder:aCoder];
|
[super encodeWithCoder: aCoder];
|
||||||
if([aCoder allowsKeyedCoding])
|
if ([aCoder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
if (!NSEqualSizes(_minItemSize, NSMakeSize(0, 0)))
|
if (!NSEqualSizes(_minItemSize, NSMakeSize(0, 0)))
|
||||||
{
|
{
|
||||||
[aCoder encodeSize:_minItemSize forKey:NSCollectionViewMinItemSizeKey];
|
[aCoder encodeSize: _minItemSize forKey: NSCollectionViewMinItemSizeKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NSEqualSizes(_maxItemSize, NSMakeSize(0, 0)))
|
if (!NSEqualSizes(_maxItemSize, NSMakeSize(0, 0)))
|
||||||
{
|
{
|
||||||
[aCoder encodeSize:_maxItemSize forKey:NSCollectionViewMaxItemSizeKey];
|
[aCoder encodeSize: _maxItemSize forKey: NSCollectionViewMaxItemSizeKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
[aCoder encodeInt64:_maxNumberOfRows
|
[aCoder encodeInt64: _maxNumberOfRows
|
||||||
forKey:NSCollectionViewMaxNumberOfRowsKey];
|
forKey: NSCollectionViewMaxNumberOfRowsKey];
|
||||||
[aCoder encodeInt64:_maxNumberOfColumns
|
[aCoder encodeInt64: _maxNumberOfColumns
|
||||||
forKey:NSCollectionViewMaxNumberOfColumnsKey];
|
forKey: NSCollectionViewMaxNumberOfColumnsKey];
|
||||||
|
|
||||||
[aCoder encodeBool:_isSelectable
|
[aCoder encodeBool: _isSelectable
|
||||||
forKey:NSCollectionViewSelectableKey];
|
forKey: NSCollectionViewSelectableKey];
|
||||||
[aCoder encodeBool:_allowsMultipleSelection
|
[aCoder encodeBool: _allowsMultipleSelection
|
||||||
forKey:NSCollectionViewAllowsMultipleSelectionKey];
|
forKey: NSCollectionViewAllowsMultipleSelectionKey];
|
||||||
|
|
||||||
//[aCoder encodeCGFloat:_verticalMargin forKey:NSCollectionViewVerticalMarginKey];
|
//[aCoder encodeCGFloat: _verticalMargin forKey: NSCollectionViewVerticalMarginKey];
|
||||||
[aCoder encodeObject:_backgroundColors
|
[aCoder encodeObject: _backgroundColors
|
||||||
forKey:NSCollectionViewBackgroundColorsKey];
|
forKey: NSCollectionViewBackgroundColorsKey];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -700,10 +652,9 @@ static NSString *placeholderItem = nil;
|
||||||
{
|
{
|
||||||
NSPoint initialLocation = [theEvent locationInWindow];
|
NSPoint initialLocation = [theEvent locationInWindow];
|
||||||
NSPoint location = [self convertPoint: initialLocation fromView: nil];
|
NSPoint location = [self convertPoint: initialLocation fromView: nil];
|
||||||
NSInteger index = [self _indexAtPoint:location];
|
NSInteger index = [self _indexAtPoint: location];
|
||||||
NSEvent *lastEvent = theEvent;
|
NSEvent *lastEvent = theEvent;
|
||||||
BOOL done = NO;
|
BOOL done = NO;
|
||||||
|
|
||||||
NSUInteger eventMask = (NSLeftMouseUpMask
|
NSUInteger eventMask = (NSLeftMouseUpMask
|
||||||
| NSLeftMouseDownMask
|
| NSLeftMouseDownMask
|
||||||
| NSLeftMouseDraggedMask
|
| NSLeftMouseDraggedMask
|
||||||
|
@ -726,14 +677,14 @@ static NSString *placeholderItem = nil;
|
||||||
if (fabs(mouseLocationWin.x - initialLocation.x) >= 2
|
if (fabs(mouseLocationWin.x - initialLocation.x) >= 2
|
||||||
|| fabs(mouseLocationWin.y - initialLocation.y) >= 2)
|
|| fabs(mouseLocationWin.y - initialLocation.y) >= 2)
|
||||||
{
|
{
|
||||||
if ([self _startDragOperationWithEvent:theEvent clickedIndex:index])
|
if ([self _startDragOperationWithEvent: theEvent clickedIndex: index])
|
||||||
{
|
{
|
||||||
done = YES;
|
done = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NSLeftMouseUp:
|
case NSLeftMouseUp:
|
||||||
[self _selectWithEvent:theEvent index:index];
|
[self _selectWithEvent: theEvent index: index];
|
||||||
done = YES;
|
done = YES;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -743,31 +694,31 @@ static NSString *placeholderItem = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _selectWithEvent:(NSEvent *)theEvent index:(NSUInteger)index
|
- (void) _selectWithEvent: (NSEvent *)theEvent index: (NSUInteger)index
|
||||||
{
|
{
|
||||||
NSMutableIndexSet *currentIndexSet = [[NSMutableIndexSet alloc] initWithIndexSet:[self selectionIndexes]];
|
NSMutableIndexSet *currentIndexSet = [[NSMutableIndexSet alloc] initWithIndexSet: [self selectionIndexes]];
|
||||||
|
|
||||||
if (_isSelectable && (index < [_items count]))
|
if (_isSelectable && (index < [_items count]))
|
||||||
{
|
{
|
||||||
if (_allowsMultipleSelection
|
if (_allowsMultipleSelection
|
||||||
&& (([theEvent modifierFlags] & NSControlKeyMask) || ([theEvent modifierFlags] & NSShiftKeyMask)))
|
&& (([theEvent modifierFlags] & NSControlKeyMask)
|
||||||
|
|| ([theEvent modifierFlags] & NSShiftKeyMask)))
|
||||||
{
|
{
|
||||||
if ([theEvent modifierFlags] & NSControlKeyMask)
|
if ([theEvent modifierFlags] & NSControlKeyMask)
|
||||||
{
|
{
|
||||||
if ([currentIndexSet containsIndex:index])
|
if ([currentIndexSet containsIndex: index])
|
||||||
{
|
{
|
||||||
[currentIndexSet removeIndex:index];
|
[currentIndexSet removeIndex: index];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[currentIndexSet addIndex:index];
|
[currentIndexSet addIndex: index];
|
||||||
}
|
}
|
||||||
[self setSelectionIndexes:currentIndexSet];
|
[self setSelectionIndexes: currentIndexSet];
|
||||||
}
|
}
|
||||||
else if ([theEvent modifierFlags] & NSShiftKeyMask)
|
else if ([theEvent modifierFlags] & NSShiftKeyMask)
|
||||||
{
|
{
|
||||||
long firstSelectedIndex = [currentIndexSet firstIndex];
|
NSUInteger firstSelectedIndex = [currentIndexSet firstIndex];
|
||||||
NSRange selectedRange;
|
NSRange selectedRange;
|
||||||
|
|
||||||
if (firstSelectedIndex == NSNotFound)
|
if (firstSelectedIndex == NSNotFound)
|
||||||
|
@ -782,21 +733,19 @@ static NSString *placeholderItem = nil;
|
||||||
{
|
{
|
||||||
selectedRange = NSMakeRange(firstSelectedIndex, (index - firstSelectedIndex + 1));
|
selectedRange = NSMakeRange(firstSelectedIndex, (index - firstSelectedIndex + 1));
|
||||||
}
|
}
|
||||||
[currentIndexSet addIndexesInRange:selectedRange];
|
[currentIndexSet addIndexesInRange: selectedRange];
|
||||||
[self setSelectionIndexes:currentIndexSet];
|
[self setSelectionIndexes: currentIndexSet];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[self setSelectionIndexes:[NSIndexSet indexSetWithIndex:index]];
|
[self setSelectionIndexes: [NSIndexSet indexSetWithIndex: index]];
|
||||||
}
|
}
|
||||||
[[self window] makeFirstResponder:self];
|
[[self window] makeFirstResponder: self];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[self setSelectionIndexes:[NSIndexSet indexSet]];
|
[self setSelectionIndexes: [NSIndexSet indexSet]];
|
||||||
}
|
}
|
||||||
RELEASE (currentIndexSet);
|
RELEASE (currentIndexSet);
|
||||||
}
|
}
|
||||||
|
@ -817,17 +766,17 @@ static NSString *placeholderItem = nil;
|
||||||
|
|
||||||
- (void) keyDown: (NSEvent *)theEvent
|
- (void) keyDown: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
[self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
|
[self interpretKeyEvents: [NSArray arrayWithObject: theEvent]];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) moveUp: (id)sender
|
-(void) moveUp: (id)sender
|
||||||
{
|
{
|
||||||
[self _moveUpAndExpandSelection:NO];
|
[self _moveUpAndExpandSelection: NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) moveUpAndModifySelection: (id)sender
|
-(void) moveUpAndModifySelection: (id)sender
|
||||||
{
|
{
|
||||||
[self _moveUpAndExpandSelection:YES];
|
[self _moveUpAndExpandSelection: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _moveUpAndExpandSelection: (BOOL)shouldExpand
|
- (void) _moveUpAndExpandSelection: (BOOL)shouldExpand
|
||||||
|
@ -835,20 +784,20 @@ static NSString *placeholderItem = nil;
|
||||||
NSInteger index = [[self selectionIndexes] firstIndex];
|
NSInteger index = [[self selectionIndexes] firstIndex];
|
||||||
if (index != NSNotFound && (index - _numberOfColumns) >= 0)
|
if (index != NSNotFound && (index - _numberOfColumns) >= 0)
|
||||||
{
|
{
|
||||||
[self _modifySelectionWithNewIndex:index - _numberOfColumns
|
[self _modifySelectionWithNewIndex: index - _numberOfColumns
|
||||||
direction:-1
|
direction: -1
|
||||||
expand:shouldExpand];
|
expand: shouldExpand];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) moveDown: (id)sender
|
-(void) moveDown: (id)sender
|
||||||
{
|
{
|
||||||
[self _moveDownAndExpandSelection:NO];
|
[self _moveDownAndExpandSelection: NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) moveDownAndModifySelection: (id)sender
|
-(void) moveDownAndModifySelection: (id)sender
|
||||||
{
|
{
|
||||||
[self _moveDownAndExpandSelection:YES];
|
[self _moveDownAndExpandSelection: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) _moveDownAndExpandSelection: (BOOL)shouldExpand
|
-(void) _moveDownAndExpandSelection: (BOOL)shouldExpand
|
||||||
|
@ -856,71 +805,71 @@ static NSString *placeholderItem = nil;
|
||||||
NSInteger index = [[self selectionIndexes] lastIndex];
|
NSInteger index = [[self selectionIndexes] lastIndex];
|
||||||
if (index != NSNotFound && (index + _numberOfColumns) < [_items count])
|
if (index != NSNotFound && (index + _numberOfColumns) < [_items count])
|
||||||
{
|
{
|
||||||
[self _modifySelectionWithNewIndex:index + _numberOfColumns
|
[self _modifySelectionWithNewIndex: index + _numberOfColumns
|
||||||
direction:1
|
direction: 1
|
||||||
expand:shouldExpand];
|
expand: shouldExpand];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) moveLeft: (id)sender
|
-(void) moveLeft: (id)sender
|
||||||
{
|
{
|
||||||
[self _moveLeftAndExpandSelection:NO];
|
[self _moveLeftAndExpandSelection: NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) moveLeftAndModifySelection: (id)sender
|
-(void) moveLeftAndModifySelection: (id)sender
|
||||||
{
|
{
|
||||||
[self _moveLeftAndExpandSelection:YES];
|
[self _moveLeftAndExpandSelection: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) moveBackwardAndModifySelection: (id)sender
|
-(void) moveBackwardAndModifySelection: (id)sender
|
||||||
{
|
{
|
||||||
[self _moveLeftAndExpandSelection:YES];
|
[self _moveLeftAndExpandSelection: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) _moveLeftAndExpandSelection: (BOOL)shouldExpand
|
-(void) _moveLeftAndExpandSelection: (BOOL)shouldExpand
|
||||||
{
|
{
|
||||||
NSInteger index = [[self selectionIndexes] firstIndex];
|
NSUInteger index = [[self selectionIndexes] firstIndex];
|
||||||
if (index != NSNotFound && index != 0)
|
if (index != NSNotFound && index != 0)
|
||||||
{
|
{
|
||||||
[self _modifySelectionWithNewIndex:index-1 direction:-1 expand:shouldExpand];
|
[self _modifySelectionWithNewIndex: index - 1 direction: -1 expand: shouldExpand];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) moveRight: (id)sender
|
-(void) moveRight: (id)sender
|
||||||
{
|
{
|
||||||
[self _moveRightAndExpandSelection:NO];
|
[self _moveRightAndExpandSelection: NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) moveRightAndModifySelection: (id)sender
|
-(void) moveRightAndModifySelection: (id)sender
|
||||||
{
|
{
|
||||||
[self _moveRightAndExpandSelection:YES];
|
[self _moveRightAndExpandSelection: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) moveForwardAndModifySelection: (id)sender
|
-(void) moveForwardAndModifySelection: (id)sender
|
||||||
{
|
{
|
||||||
[self _moveRightAndExpandSelection:YES];
|
[self _moveRightAndExpandSelection: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) _moveRightAndExpandSelection: (BOOL)shouldExpand
|
-(void) _moveRightAndExpandSelection: (BOOL)shouldExpand
|
||||||
{
|
{
|
||||||
NSInteger index = [[self selectionIndexes] lastIndex];
|
NSUInteger index = [[self selectionIndexes] lastIndex];
|
||||||
if (index != NSNotFound && index != ([_items count] - 1))
|
if (index != NSNotFound && index != ([_items count] - 1))
|
||||||
{
|
{
|
||||||
[self _modifySelectionWithNewIndex:index+1 direction:1 expand:shouldExpand];
|
[self _modifySelectionWithNewIndex: index + 1 direction: 1 expand: shouldExpand];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _modifySelectionWithNewIndex: (int)anIndex
|
- (void) _modifySelectionWithNewIndex: (NSUInteger)anIndex
|
||||||
direction: (int)aDirection
|
direction: (int)aDirection
|
||||||
expand: (BOOL)shouldExpand
|
expand: (BOOL)shouldExpand
|
||||||
{
|
{
|
||||||
anIndex = MIN (MAX (anIndex, 0), [_items count] - 1);
|
anIndex = MIN(MAX(anIndex, 0), [_items count] - 1);
|
||||||
|
|
||||||
if (_allowsMultipleSelection && shouldExpand)
|
if (_allowsMultipleSelection && shouldExpand)
|
||||||
{
|
{
|
||||||
NSMutableIndexSet *newIndexSet = [[NSMutableIndexSet alloc] initWithIndexSet:_selectionIndexes];
|
NSMutableIndexSet *newIndexSet = [[NSMutableIndexSet alloc] initWithIndexSet: _selectionIndexes];
|
||||||
NSInteger firstIndex = [newIndexSet firstIndex];
|
NSUInteger firstIndex = [newIndexSet firstIndex];
|
||||||
NSInteger lastIndex = [newIndexSet lastIndex];
|
NSUInteger lastIndex = [newIndexSet lastIndex];
|
||||||
if (aDirection == -1)
|
if (aDirection == -1)
|
||||||
{
|
{
|
||||||
[newIndexSet addIndexesInRange:NSMakeRange (anIndex, firstIndex - anIndex + 1)];
|
[newIndexSet addIndexesInRange:NSMakeRange (anIndex, firstIndex - anIndex + 1)];
|
||||||
|
@ -929,21 +878,21 @@ static NSString *placeholderItem = nil;
|
||||||
{
|
{
|
||||||
[newIndexSet addIndexesInRange:NSMakeRange (lastIndex, anIndex - lastIndex + 1)];
|
[newIndexSet addIndexesInRange:NSMakeRange (lastIndex, anIndex - lastIndex + 1)];
|
||||||
}
|
}
|
||||||
[self setSelectionIndexes:newIndexSet];
|
[self setSelectionIndexes: newIndexSet];
|
||||||
RELEASE (newIndexSet);
|
RELEASE (newIndexSet);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[self setSelectionIndexes:[NSIndexSet indexSetWithIndex:anIndex]];
|
[self setSelectionIndexes: [NSIndexSet indexSetWithIndex: anIndex]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self scrollRectToVisible:[self frameForItemAtIndex:anIndex]];
|
[self scrollRectToVisible: [self frameForItemAtIndex: anIndex]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* MARK: Drag & Drop */
|
/* MARK: Drag & Drop */
|
||||||
|
|
||||||
-(NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal
|
-(NSDragOperation) draggingSourceOperationMaskForLocal: (BOOL)isLocal
|
||||||
{
|
{
|
||||||
if (isLocal)
|
if (isLocal)
|
||||||
{
|
{
|
||||||
|
@ -955,8 +904,8 @@ static NSString *placeholderItem = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)setDraggingSourceOperationMask:(NSDragOperation)mask
|
-(void) setDraggingSourceOperationMask: (NSDragOperation)mask
|
||||||
forLocal:(BOOL)isLocal
|
forLocal: (BOOL)isLocal
|
||||||
{
|
{
|
||||||
if (isLocal)
|
if (isLocal)
|
||||||
{
|
{
|
||||||
|
@ -968,49 +917,50 @@ static NSString *placeholderItem = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) _startDragOperationWithEvent:(NSEvent*)event
|
- (BOOL) _startDragOperationWithEvent: (NSEvent*)event
|
||||||
clickedIndex:(NSUInteger)index
|
clickedIndex: (NSUInteger)index
|
||||||
{
|
{
|
||||||
NSIndexSet *dragIndexes = _selectionIndexes;
|
NSIndexSet *dragIndexes = _selectionIndexes;
|
||||||
if (![dragIndexes containsIndex:index]
|
|
||||||
|
if (![dragIndexes containsIndex: index]
|
||||||
&& (index < [_items count]))
|
&& (index < [_items count]))
|
||||||
{
|
{
|
||||||
dragIndexes = [NSIndexSet indexSetWithIndex:index];
|
dragIndexes = [NSIndexSet indexSetWithIndex: index];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![dragIndexes count])
|
if (![dragIndexes count])
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
if (![delegate respondsToSelector:@selector(collectionView:writeItemsAtIndexes:toPasteboard:)])
|
if (![delegate respondsToSelector: @selector(collectionView:writeItemsAtIndexes:toPasteboard:)])
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
if ([delegate respondsToSelector:@selector(collectionView:canDragItemsAtIndexes:withEvent:)])
|
if ([delegate respondsToSelector: @selector(collectionView:canDragItemsAtIndexes:withEvent:)])
|
||||||
{
|
{
|
||||||
if (![delegate collectionView:self
|
if (![delegate collectionView: self
|
||||||
canDragItemsAtIndexes:dragIndexes
|
canDragItemsAtIndexes: dragIndexes
|
||||||
withEvent:event])
|
withEvent: event])
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NSPoint downPoint = [event locationInWindow];
|
NSPoint downPoint = [event locationInWindow];
|
||||||
NSPoint convertedDownPoint = [self convertPoint:downPoint fromView:nil];
|
NSPoint convertedDownPoint = [self convertPoint: downPoint fromView: nil];
|
||||||
|
|
||||||
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
|
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName: NSDragPboard];
|
||||||
if ([self _writeItemsAtIndexes:dragIndexes toPasteboard:pasteboard])
|
if ([self _writeItemsAtIndexes:dragIndexes toPasteboard: pasteboard])
|
||||||
{
|
{
|
||||||
NSImage *dragImage = [self draggingImageForItemsAtIndexes:dragIndexes
|
NSImage *dragImage = [self draggingImageForItemsAtIndexes: dragIndexes
|
||||||
withEvent:event
|
withEvent: event
|
||||||
offset:NULL];
|
offset: NULL];
|
||||||
|
|
||||||
[self dragImage:dragImage
|
[self dragImage: dragImage
|
||||||
at:convertedDownPoint
|
at: convertedDownPoint
|
||||||
offset:NSMakeSize(0,0)
|
offset: NSMakeSize(0,0)
|
||||||
event:event
|
event: event
|
||||||
pasteboard:pasteboard
|
pasteboard: pasteboard
|
||||||
source:self
|
source: self
|
||||||
slideBack:YES];
|
slideBack: YES];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -1021,31 +971,31 @@ clickedIndex:(NSUInteger)index
|
||||||
withEvent: (NSEvent *)event
|
withEvent: (NSEvent *)event
|
||||||
offset: (NSPointPointer)dragImageOffset
|
offset: (NSPointPointer)dragImageOffset
|
||||||
{
|
{
|
||||||
if ([delegate respondsToSelector:@selector(collectionView:draggingImageForItemsAtIndexes:withEvent:offset:)])
|
if ([delegate respondsToSelector: @selector(collectionView:draggingImageForItemsAtIndexes:withEvent:offset:)])
|
||||||
{
|
{
|
||||||
return [delegate collectionView:self
|
return [delegate collectionView: self
|
||||||
draggingImageForItemsAtIndexes:indexes
|
draggingImageForItemsAtIndexes: indexes
|
||||||
withEvent:event
|
withEvent: event
|
||||||
offset:dragImageOffset];
|
offset: dragImageOffset];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return [[NSImage alloc] initWithData:[self dataWithPDFInsideRect:[self bounds]]];
|
return [[NSImage alloc] initWithData: [self dataWithPDFInsideRect: [self bounds]]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) _writeItemsAtIndexes: (NSIndexSet *)indexes
|
- (BOOL) _writeItemsAtIndexes: (NSIndexSet *)indexes
|
||||||
toPasteboard: (NSPasteboard *)pasteboard
|
toPasteboard: (NSPasteboard *)pasteboard
|
||||||
{
|
{
|
||||||
if (![delegate respondsToSelector:@selector(collectionView:writeItemsAtIndexes:toPasteboard:)])
|
if (![delegate respondsToSelector: @selector(collectionView:writeItemsAtIndexes:toPasteboard:)])
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return [delegate collectionView:self
|
return [delegate collectionView: self
|
||||||
writeItemsAtIndexes:indexes
|
writeItemsAtIndexes: indexes
|
||||||
toPasteboard:pasteboard];
|
toPasteboard: pasteboard];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,10 +1009,10 @@ clickedIndex:(NSUInteger)index
|
||||||
{
|
{
|
||||||
NSDragOperation result = NSDragOperationNone;
|
NSDragOperation result = NSDragOperationNone;
|
||||||
|
|
||||||
if ([delegate respondsToSelector:@selector(collectionView:validateDrop:proposedIndex:dropOperation:)])
|
if ([delegate respondsToSelector: @selector(collectionView:validateDrop:proposedIndex:dropOperation:)])
|
||||||
{
|
{
|
||||||
NSPoint location = [self convertPoint: [sender draggingLocation] fromView: nil];
|
NSPoint location = [self convertPoint: [sender draggingLocation] fromView: nil];
|
||||||
NSInteger index = [self _indexAtPoint:location];
|
NSInteger index = [self _indexAtPoint: location];
|
||||||
index = (index > [_items count] - 1) ? [_items count] - 1 : index;
|
index = (index > [_items count] - 1) ? [_items count] - 1 : index;
|
||||||
_draggingOnIndex = index;
|
_draggingOnIndex = index;
|
||||||
|
|
||||||
|
@ -1072,16 +1022,16 @@ clickedIndex:(NSUInteger)index
|
||||||
|
|
||||||
// TODO: We currently don't do anything with the proposedIndex & dropOperation that
|
// TODO: We currently don't do anything with the proposedIndex & dropOperation that
|
||||||
// may get altered by the delegate.
|
// may get altered by the delegate.
|
||||||
result = [delegate collectionView:self
|
result = [delegate collectionView: self
|
||||||
validateDrop:sender
|
validateDrop: sender
|
||||||
proposedIndex:proposedIndex
|
proposedIndex: proposedIndex
|
||||||
dropOperation:dropOperation];
|
dropOperation: dropOperation];
|
||||||
|
|
||||||
if (result == NSDragOperationNone)
|
if (result == NSDragOperationNone)
|
||||||
{
|
{
|
||||||
_draggingOnIndex = NSNotFound;
|
_draggingOnIndex = NSNotFound;
|
||||||
}
|
}
|
||||||
[self setNeedsDisplayInRect:[self _frameForRowsAroundItemAtIndex:index]];
|
[self setNeedsDisplayInRect: [self _frameForRowsAroundItemAtIndex: index]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -1089,43 +1039,44 @@ clickedIndex:(NSUInteger)index
|
||||||
|
|
||||||
- (NSDragOperation) draggingEntered: (id<NSDraggingInfo>)sender
|
- (NSDragOperation) draggingEntered: (id<NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
return [self _draggingEnteredOrUpdated:sender];
|
return [self _draggingEnteredOrUpdated: sender];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) draggingExited: (id<NSDraggingInfo>)sender
|
- (void) draggingExited: (id<NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
[self setNeedsDisplayInRect:[self _frameForRowsAroundItemAtIndex:_draggingOnIndex]];
|
[self setNeedsDisplayInRect: [self _frameForRowsAroundItemAtIndex: _draggingOnIndex]];
|
||||||
_draggingOnIndex = NSNotFound;
|
_draggingOnIndex = NSNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDragOperation) draggingUpdated: (id<NSDraggingInfo>)sender
|
- (NSDragOperation) draggingUpdated: (id<NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
return [self _draggingEnteredOrUpdated:sender];
|
return [self _draggingEnteredOrUpdated: sender];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
_draggingOnIndex = NSNotFound;
|
|
||||||
NSPoint location = [self convertPoint: [sender draggingLocation] fromView: nil];
|
NSPoint location = [self convertPoint: [sender draggingLocation] fromView: nil];
|
||||||
NSInteger index = [self _indexAtPoint:location];
|
NSInteger index = [self _indexAtPoint: location];
|
||||||
[self setNeedsDisplayInRect:[self _frameForRowsAroundItemAtIndex:index]];
|
|
||||||
|
_draggingOnIndex = NSNotFound;
|
||||||
|
[self setNeedsDisplayInRect: [self _frameForRowsAroundItemAtIndex: index]];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
|
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
NSPoint location = [self convertPoint: [sender draggingLocation] fromView: nil];
|
NSPoint location = [self convertPoint: [sender draggingLocation] fromView: nil];
|
||||||
NSInteger index = [self _indexAtPoint:location];
|
NSInteger index = [self _indexAtPoint: location];
|
||||||
index = (index > [_items count] - 1) ? [_items count] - 1 : index;
|
index = (index > [_items count] - 1) ? [_items count] - 1 : index;
|
||||||
|
|
||||||
BOOL result = NO;
|
BOOL result = NO;
|
||||||
if ([delegate respondsToSelector:@selector(collectionView:acceptDrop:index:dropOperation:)])
|
if ([delegate respondsToSelector: @selector(collectionView:acceptDrop:index:dropOperation:)])
|
||||||
{
|
{
|
||||||
// TODO: dropOperation should be retrieved from the validateDrop delegate method.
|
// TODO: dropOperation should be retrieved from the validateDrop delegate method.
|
||||||
result = [delegate collectionView:self
|
result = [delegate collectionView: self
|
||||||
acceptDrop:sender
|
acceptDrop: sender
|
||||||
index:index
|
index: index
|
||||||
dropOperation:NSCollectionViewDropOn];
|
dropOperation: NSCollectionViewDropOn];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,75 +25,44 @@
|
||||||
Boston, MA 02110-1301, USA.
|
Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "AppKit/NSCollectionViewItem.h"
|
#import <Foundation/NSArray.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/NSKeyedArchiver.h>
|
||||||
|
|
||||||
#import "AppKit/NSTableView.h"
|
#import "AppKit/NSCollectionView.h"
|
||||||
#import "AppKit/NSApplication.h"
|
#import "AppKit/NSCollectionViewItem.h"
|
||||||
#import "AppKit/NSCell.h"
|
#import "AppKit/NSImageView.h"
|
||||||
#import "AppKit/NSClipView.h"
|
#import "AppKit/NSTextField.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>
|
|
||||||
|
|
||||||
@implementation NSCollectionViewItem
|
@implementation NSCollectionViewItem
|
||||||
|
|
||||||
- (void)awakeFromNib
|
- (void) awakeFromNib
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isSelected
|
- (BOOL) isSelected
|
||||||
{
|
{
|
||||||
return _isSelected;
|
return _isSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
DESTROY (textField);
|
DESTROY(textField);
|
||||||
DESTROY (imageView);
|
DESTROY(imageView);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSCollectionView *)collectionView
|
- (NSCollectionView *) collectionView
|
||||||
{
|
{
|
||||||
return (NSCollectionView *)[[self view] superview];
|
return (NSCollectionView *)[[self view] superview];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setSelected:(BOOL)flag
|
- (NSArray *) draggingImageComponents
|
||||||
|
{
|
||||||
|
// FIXME: We don't have NSDraggingImageComponent
|
||||||
|
return [NSArray array];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setSelected: (BOOL)flag
|
||||||
{
|
{
|
||||||
if (_isSelected != flag)
|
if (_isSelected != flag)
|
||||||
{
|
{
|
||||||
|
@ -101,23 +70,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)representedObject
|
- (id) representedObject
|
||||||
{
|
{
|
||||||
return [super representedObject];
|
return [super representedObject];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setRepresentedObject:(id)anObject
|
- (void) setRepresentedObject: (id)anObject
|
||||||
{
|
{
|
||||||
[super setRepresentedObject:anObject];
|
[super setRepresentedObject:anObject];
|
||||||
//[textField setStringValue:[self representedObject]];
|
//[textField setStringValue:[self representedObject]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTextField *)textField
|
- (NSTextField *) textField
|
||||||
{
|
{
|
||||||
return textField;
|
return textField;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTextField:(NSTextField *)aTextField
|
- (void) setTextField: (NSTextField *)aTextField
|
||||||
{
|
{
|
||||||
if (textField != aTextField)
|
if (textField != aTextField)
|
||||||
{
|
{
|
||||||
|
@ -125,12 +94,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSImageView *)imageView
|
- (NSImageView *) imageView
|
||||||
{
|
{
|
||||||
return imageView;
|
return imageView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setImageView:(NSImageView *)anImageView
|
- (void) setImageView: (NSImageView *)anImageView
|
||||||
{
|
{
|
||||||
if (imageView != anImageView)
|
if (imageView != anImageView)
|
||||||
{
|
{
|
||||||
|
@ -138,15 +107,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithCoder:(NSCoder *)aCoder
|
- (id) initWithCoder: (NSCoder *)aCoder
|
||||||
{
|
{
|
||||||
self = [super initWithCoder:aCoder];
|
self = [super initWithCoder: aCoder];
|
||||||
if (nil != self)
|
if (nil != self)
|
||||||
{
|
{
|
||||||
if(YES == [aCoder allowsKeyedCoding])
|
if (YES == [aCoder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
textField = [aCoder decodeObjectForKey:@"textField"];
|
textField = [aCoder decodeObjectForKey: @"textField"];
|
||||||
imageView = [aCoder decodeObjectForKey:@"imageView"];
|
imageView = [aCoder decodeObjectForKey: @"imageView"];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -159,24 +128,24 @@
|
||||||
|
|
||||||
- (void)encodeWithCoder:(NSCoder *)aCoder
|
- (void)encodeWithCoder:(NSCoder *)aCoder
|
||||||
{
|
{
|
||||||
[super encodeWithCoder:aCoder];
|
[super encodeWithCoder: aCoder];
|
||||||
if(YES == [aCoder allowsKeyedCoding])
|
if (YES == [aCoder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
[aCoder encodeObject:textField forKey:@"textField"];
|
[aCoder encodeObject: textField forKey: @"textField"];
|
||||||
[aCoder encodeObject:imageView forKey:@"imageView"];
|
[aCoder encodeObject: imageView forKey: @"imageView"];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[aCoder encodeObject:textField];
|
[aCoder encodeObject: textField];
|
||||||
[aCoder encodeObject:imageView]
|
[aCoder encodeObject: imageView];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) copyWithZone:(NSZone *)zone
|
- (id) copyWithZone: (NSZone *)zone
|
||||||
{
|
{
|
||||||
NSData *itemAsData = [NSKeyedArchiver archivedDataWithRootObject:self];
|
NSData *itemAsData = [NSKeyedArchiver archivedDataWithRootObject: self];
|
||||||
NSCollectionViewItem *newItem =
|
NSCollectionViewItem *newItem =
|
||||||
[NSKeyedUnarchiver unarchiveObjectWithData:itemAsData];
|
[NSKeyedUnarchiver unarchiveObjectWithData: itemAsData];
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2884,12 +2884,12 @@ byExtendingSelection: (BOOL)flag
|
||||||
|
|
||||||
- (NSIndexSet *) selectedColumnIndexes
|
- (NSIndexSet *) selectedColumnIndexes
|
||||||
{
|
{
|
||||||
return _selectedColumns;
|
return [[_selectedColumns copy] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSIndexSet *) selectedRowIndexes
|
- (NSIndexSet *) selectedRowIndexes
|
||||||
{
|
{
|
||||||
return _selectedRows;
|
return [[_selectedRows copy] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) deselectColumn: (NSInteger)columnIndex
|
- (void) deselectColumn: (NSInteger)columnIndex
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue