mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 06:40:59 +00:00
Header and NSCollection* source merges
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@38688 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
beccb8503d
commit
3238f42ec6
8 changed files with 167 additions and 86 deletions
|
@ -112,8 +112,14 @@ enum {
|
||||||
* Implemented by the delegate
|
* Implemented by the delegate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef GNUSTEP
|
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
||||||
|
@protocol NSAlertDelegate <NSObject>
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) && GS_PROTOCOLS_HAVE_OPTIONAL
|
||||||
|
@optional
|
||||||
|
#else
|
||||||
|
@end
|
||||||
@interface NSObject (NSAlertDelegate)
|
@interface NSObject (NSAlertDelegate)
|
||||||
|
#endif
|
||||||
- (BOOL) alertShowHelp: (NSAlert *)alert;
|
- (BOOL) alertShowHelp: (NSAlert *)alert;
|
||||||
@end
|
@end
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -263,7 +263,13 @@ APPKIT_EXPORT NSString *NSAnimationTriggerOrderOut;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@protocol NSAnimationDelegate <NSObject>
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) && GS_PROTOCOLS_HAVE_OPTIONAL
|
||||||
|
@optional
|
||||||
|
#else
|
||||||
|
@end
|
||||||
@interface NSObject (NSAnimation)
|
@interface NSObject (NSAnimation)
|
||||||
|
#endif
|
||||||
|
|
||||||
/** NSAnimation delegate method.
|
/** NSAnimation delegate method.
|
||||||
* Sent to the delegate when an animation reaches a specific progress mark. */
|
* Sent to the delegate when an animation reaches a specific progress mark. */
|
||||||
|
|
|
@ -446,7 +446,7 @@ APPKIT_EXPORT NSString *NSEventTrackingRunLoopMode;
|
||||||
* <code>NSApp</code> to use default implementations in other cases.
|
* <code>NSApp</code> to use default implementations in other cases.
|
||||||
*/
|
*/
|
||||||
@protocol NSApplicationDelegate <NSObject>
|
@protocol NSApplicationDelegate <NSObject>
|
||||||
#ifdef __OBJC2__
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) && GS_PROTOCOLS_HAVE_OPTIONAL
|
||||||
@optional
|
@optional
|
||||||
#else
|
#else
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -146,12 +146,14 @@ enum {
|
||||||
};
|
};
|
||||||
typedef NSUInteger NSImageScaling;
|
typedef NSUInteger NSImageScaling;
|
||||||
|
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
||||||
enum {
|
enum {
|
||||||
NSCellHitNone = 0,
|
NSCellHitNone = 0,
|
||||||
NSCellHitContentArea = 1 << 0,
|
NSCellHitContentArea = 1,
|
||||||
NSCellHitEditableTextArea = 1 << 1,
|
NSCellHitEditableTextArea = 2,
|
||||||
NSCellHitTrackableArea = 1 << 2,
|
NSCellHitTrackableArea = 4
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
NSBackgroundStyleLight = 0,
|
NSBackgroundStyleLight = 0,
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#import "AppKit/NSEvent.h"
|
#import "AppKit/NSEvent.h"
|
||||||
#import "AppKit/NSGraphics.h"
|
#import "AppKit/NSGraphics.h"
|
||||||
#import "AppKit/NSImage.h"
|
#import "AppKit/NSImage.h"
|
||||||
|
#import "AppKit/NSKeyValueBinding.h"
|
||||||
#import "AppKit/NSPasteboard.h"
|
#import "AppKit/NSPasteboard.h"
|
||||||
#import "AppKit/NSWindow.h"
|
#import "AppKit/NSWindow.h"
|
||||||
|
|
||||||
|
@ -94,7 +95,11 @@ static NSString *placeholderItem = nil;
|
||||||
//
|
//
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
|
if (self == [NSCollectionView class])
|
||||||
|
{
|
||||||
placeholderItem = @"Placeholder";
|
placeholderItem = @"Placeholder";
|
||||||
|
[self exposeBinding: NSContentBinding];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithFrame: (NSRect)frame
|
- (id) initWithFrame: (NSRect)frame
|
||||||
|
@ -120,7 +125,7 @@ static NSString *placeholderItem = nil;
|
||||||
|
|
||||||
- (void) _resetItemSize
|
- (void) _resetItemSize
|
||||||
{
|
{
|
||||||
if (itemPrototype)
|
if (itemPrototype && ([itemPrototype view] != nil))
|
||||||
{
|
{
|
||||||
_itemSize = [[itemPrototype view] frame].size;
|
_itemSize = [[itemPrototype view] frame].size;
|
||||||
_minItemSize = NSMakeSize (_itemSize.width, _itemSize.height);
|
_minItemSize = NSMakeSize (_itemSize.width, _itemSize.height);
|
||||||
|
@ -151,8 +156,11 @@ static NSString *placeholderItem = nil;
|
||||||
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]);
|
// I had to extract these values from the macro to get it
|
||||||
NSInteger index;
|
// working correctly.
|
||||||
|
NSInteger index = [self _indexAtPoint: oppositeOrigin];
|
||||||
|
NSInteger last = [_items count] - 1;
|
||||||
|
NSInteger lastIndexInRect = MIN(last, index);
|
||||||
|
|
||||||
for (index = firstIndexInRect; index <= lastIndexInRect; index++)
|
for (index = firstIndexInRect; index <= lastIndexInRect; index++)
|
||||||
{
|
{
|
||||||
|
@ -235,6 +243,7 @@ static NSString *placeholderItem = nil;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
[self _resetItemSize];
|
||||||
// Force recalculation of each item's frame
|
// Force recalculation of each item's frame
|
||||||
_itemSize = _minItemSize;
|
_itemSize = _minItemSize;
|
||||||
_tileWidth = -1.0;
|
_tileWidth = -1.0;
|
||||||
|
@ -475,6 +484,7 @@ static NSString *placeholderItem = nil;
|
||||||
NSRect initRect = NSMakeRect (-10000,-10000,100,100);
|
NSRect initRect = NSMakeRect (-10000,-10000,100,100);
|
||||||
[[item view] setFrame:initRect];
|
[[item view] setFrame:initRect];
|
||||||
[self addSubview: [item view]];
|
[self addSubview: [item view]];
|
||||||
|
RELEASE(item);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -484,10 +494,10 @@ static NSString *placeholderItem = nil;
|
||||||
NSCollectionViewItem *collectionItem = nil;
|
NSCollectionViewItem *collectionItem = nil;
|
||||||
if (itemPrototype)
|
if (itemPrototype)
|
||||||
{
|
{
|
||||||
ASSIGN(collectionItem, [itemPrototype copy]);
|
collectionItem = [itemPrototype copy];
|
||||||
[collectionItem setRepresentedObject: object];
|
[collectionItem setRepresentedObject: object];
|
||||||
}
|
}
|
||||||
return AUTORELEASE (collectionItem);
|
return collectionItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _removeItemsViews
|
- (void) _removeItemsViews
|
||||||
|
@ -530,6 +540,11 @@ static NSString *placeholderItem = nil;
|
||||||
_numberOfColumns = MIN(_maxNumberOfColumns, _numberOfColumns);
|
_numberOfColumns = MIN(_maxNumberOfColumns, _numberOfColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_numberOfColumns == 0)
|
||||||
|
{
|
||||||
|
_numberOfColumns = 1;
|
||||||
|
}
|
||||||
|
|
||||||
CGFloat remaining = width - _numberOfColumns * itemSize.width;
|
CGFloat remaining = width - _numberOfColumns * itemSize.width;
|
||||||
|
|
||||||
if (remaining > 0 && itemSize.width < _maxItemSize.width)
|
if (remaining > 0 && itemSize.width < _maxItemSize.width)
|
||||||
|
|
|
@ -25,50 +25,15 @@
|
||||||
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/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/NSColor.h"
|
|
||||||
#import "AppKit/NSEvent.h"
|
|
||||||
#import "AppKit/NSImage.h"
|
|
||||||
#import "AppKit/NSGraphics.h"
|
|
||||||
#import "AppKit/NSKeyValueBinding.h"
|
#import "AppKit/NSKeyValueBinding.h"
|
||||||
#import "AppKit/NSScroller.h"
|
#import "AppKit/NSTextField.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
|
||||||
|
|
||||||
|
@ -93,6 +58,12 @@
|
||||||
return (NSCollectionView *)[[self view] superview];
|
return (NSCollectionView *)[[self view] superview];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSArray *) draggingImageComponents
|
||||||
|
{
|
||||||
|
// FIXME: We don't have NSDraggingImageComponent
|
||||||
|
return [NSArray array];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setSelected:(BOOL)flag
|
- (void)setSelected:(BOOL)flag
|
||||||
{
|
{
|
||||||
if (_isSelected != flag)
|
if (_isSelected != flag)
|
||||||
|
@ -119,10 +90,7 @@
|
||||||
|
|
||||||
- (void)setTextField:(NSTextField *)aTextField
|
- (void)setTextField:(NSTextField *)aTextField
|
||||||
{
|
{
|
||||||
if (textField != aTextField)
|
ASSIGN(textField, aTextField);
|
||||||
{
|
|
||||||
textField = aTextField;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSImageView *)imageView
|
- (NSImageView *)imageView
|
||||||
|
@ -132,37 +100,102 @@
|
||||||
|
|
||||||
- (void)setImageView:(NSImageView *)anImageView
|
- (void)setImageView:(NSImageView *)anImageView
|
||||||
{
|
{
|
||||||
if (imageView != anImageView)
|
ASSIGN(imageView, anImageView);
|
||||||
{
|
|
||||||
imageView = anImageView;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithCoder:(NSCoder *)aCoder
|
- (id)initWithCoder:(NSCoder *)aCoder
|
||||||
{
|
{
|
||||||
self = [super initWithCoder:aCoder];
|
self = [super initWithCoder:aCoder];
|
||||||
|
if (nil != self)
|
||||||
if (self)
|
|
||||||
{
|
{
|
||||||
textField = [aCoder decodeObjectForKey:@"textField"];
|
if (YES == [aCoder allowsKeyedCoding])
|
||||||
imageView = [aCoder decodeObjectForKey:@"imageView"];
|
{
|
||||||
|
if ([aCoder containsValueForKey: @"textField"])
|
||||||
|
{
|
||||||
|
[self setTextField: [aCoder decodeObjectForKey: @"textField"]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
textField = [[NSTextField alloc] initWithFrame: NSMakeRect(0.0, 0.0, 100.0, 20.0)];
|
||||||
|
}
|
||||||
|
if ([aCoder containsValueForKey: @"imageView"])
|
||||||
|
{
|
||||||
|
[self setImageView: [aCoder decodeObjectForKey: @"imageView"]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imageView = [[NSImageView alloc] initWithFrame: NSMakeRect(0.0, 0.0, 100.0, 100.0)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[self setTextField: [aCoder decodeObject]];
|
||||||
|
[self setImageView: [aCoder decodeObject]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)encodeWithCoder:(NSCoder *)aCoder
|
- (void)encodeWithCoder:(NSCoder *)aCoder
|
||||||
{
|
{
|
||||||
[super encodeWithCoder:aCoder];
|
[super encodeWithCoder:aCoder];
|
||||||
[aCoder encodeObject:textField forKey:@"textField"];
|
if (YES == [aCoder allowsKeyedCoding])
|
||||||
[aCoder encodeObject:imageView forKey:@"imageView"];
|
{
|
||||||
|
[aCoder encodeObject:textField forKey:@"textField"];
|
||||||
|
[aCoder encodeObject:imageView forKey:@"imageView"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[aCoder encodeObject: textField];
|
||||||
|
[aCoder encodeObject: imageView];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) copyBindingsTo: (NSCollectionViewItem*)newItem
|
||||||
|
from: (NSView*)view
|
||||||
|
onto: (NSView*)newView
|
||||||
|
{
|
||||||
|
NSArray *exposedBindings = [view exposedBindings];
|
||||||
|
NSEnumerator *e = [exposedBindings objectEnumerator];
|
||||||
|
NSString *binding = nil;
|
||||||
|
while ((binding = [e nextObject]) != nil)
|
||||||
|
{
|
||||||
|
NSDictionary *info = [view infoForBinding: binding];
|
||||||
|
if (info != nil)
|
||||||
|
{
|
||||||
|
NSObject *target = [info objectForKey: NSObservedObjectKey];
|
||||||
|
if (target == self)
|
||||||
|
{
|
||||||
|
[newView bind: binding
|
||||||
|
toObject: newItem
|
||||||
|
withKeyPath: [info objectForKey: NSObservedKeyPathKey]
|
||||||
|
options: [info objectForKey: NSOptionsKey]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NSView *sub1 = nil;
|
||||||
|
NSEnumerator *e1 = [[view subviews] objectEnumerator];
|
||||||
|
NSView *sub2 = nil;
|
||||||
|
NSEnumerator *e2 = [[newView subviews] objectEnumerator];
|
||||||
|
while ((sub1 = [e1 nextObject]) != nil)
|
||||||
|
{
|
||||||
|
sub2 = [e2 nextObject];
|
||||||
|
[self copyBindingsTo: newItem from: sub1 onto: sub2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (id) copyWithZone:(NSZone *)zone
|
- (id) copyWithZone:(NSZone *)zone
|
||||||
{
|
{
|
||||||
|
// FIXME: Cache this data, as we need a lot of copies
|
||||||
NSData *itemAsData = [NSKeyedArchiver archivedDataWithRootObject:self];
|
NSData *itemAsData = [NSKeyedArchiver archivedDataWithRootObject:self];
|
||||||
NSCollectionViewItem *newItem = [NSKeyedUnarchiver unarchiveObjectWithData:itemAsData];
|
NSCollectionViewItem *newItem =
|
||||||
return newItem;
|
[NSKeyedUnarchiver unarchiveObjectWithData: itemAsData];
|
||||||
|
|
||||||
|
// Try to copy bindings too
|
||||||
|
[self copyBindingsTo: newItem from: [self view] onto: [newItem view]];
|
||||||
|
|
||||||
|
return RETAIN(newItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue