mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 03:01:00 +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
|
||||
*/
|
||||
|
||||
#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)
|
||||
#endif
|
||||
- (BOOL) alertShowHelp: (NSAlert *)alert;
|
||||
@end
|
||||
#endif
|
||||
|
|
|
@ -263,7 +263,13 @@ APPKIT_EXPORT NSString *NSAnimationTriggerOrderOut;
|
|||
|
||||
@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)
|
||||
#endif
|
||||
|
||||
/** NSAnimation delegate method.
|
||||
* 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.
|
||||
*/
|
||||
@protocol NSApplicationDelegate <NSObject>
|
||||
#ifdef __OBJC2__
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) && GS_PROTOCOLS_HAVE_OPTIONAL
|
||||
@optional
|
||||
#else
|
||||
@end
|
||||
|
|
|
@ -146,12 +146,14 @@ enum {
|
|||
};
|
||||
typedef NSUInteger NSImageScaling;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
||||
enum {
|
||||
NSCellHitNone = 0,
|
||||
NSCellHitContentArea = 1 << 0,
|
||||
NSCellHitEditableTextArea = 1 << 1,
|
||||
NSCellHitTrackableArea = 1 << 2,
|
||||
NSCellHitContentArea = 1,
|
||||
NSCellHitEditableTextArea = 2,
|
||||
NSCellHitTrackableArea = 4
|
||||
};
|
||||
#endif
|
||||
|
||||
enum {
|
||||
NSBackgroundStyleLight = 0,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#import "AppKit/NSEvent.h"
|
||||
#import "AppKit/NSGraphics.h"
|
||||
#import "AppKit/NSImage.h"
|
||||
#import "AppKit/NSKeyValueBinding.h"
|
||||
#import "AppKit/NSPasteboard.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
|
||||
|
@ -94,7 +95,11 @@ static NSString *placeholderItem = nil;
|
|||
//
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSCollectionView class])
|
||||
{
|
||||
placeholderItem = @"Placeholder";
|
||||
[self exposeBinding: NSContentBinding];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithFrame: (NSRect)frame
|
||||
|
@ -120,7 +125,7 @@ static NSString *placeholderItem = nil;
|
|||
|
||||
- (void) _resetItemSize
|
||||
{
|
||||
if (itemPrototype)
|
||||
if (itemPrototype && ([itemPrototype view] != nil))
|
||||
{
|
||||
_itemSize = [[itemPrototype view] frame].size;
|
||||
_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);
|
||||
|
||||
NSInteger firstIndexInRect = MAX(0, [self _indexAtPoint: origin]);
|
||||
NSInteger lastIndexInRect = MIN([_items count] - 1, [self _indexAtPoint: oppositeOrigin]);
|
||||
NSInteger index;
|
||||
// I had to extract these values from the macro to get it
|
||||
// working correctly.
|
||||
NSInteger index = [self _indexAtPoint: oppositeOrigin];
|
||||
NSInteger last = [_items count] - 1;
|
||||
NSInteger lastIndexInRect = MIN(last, index);
|
||||
|
||||
for (index = firstIndexInRect; index <= lastIndexInRect; index++)
|
||||
{
|
||||
|
@ -235,6 +243,7 @@ static NSString *placeholderItem = nil;
|
|||
}
|
||||
else
|
||||
{
|
||||
[self _resetItemSize];
|
||||
// Force recalculation of each item's frame
|
||||
_itemSize = _minItemSize;
|
||||
_tileWidth = -1.0;
|
||||
|
@ -475,6 +484,7 @@ static NSString *placeholderItem = nil;
|
|||
NSRect initRect = NSMakeRect (-10000,-10000,100,100);
|
||||
[[item view] setFrame:initRect];
|
||||
[self addSubview: [item view]];
|
||||
RELEASE(item);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
@ -484,10 +494,10 @@ static NSString *placeholderItem = nil;
|
|||
NSCollectionViewItem *collectionItem = nil;
|
||||
if (itemPrototype)
|
||||
{
|
||||
ASSIGN(collectionItem, [itemPrototype copy]);
|
||||
collectionItem = [itemPrototype copy];
|
||||
[collectionItem setRepresentedObject: object];
|
||||
}
|
||||
return AUTORELEASE (collectionItem);
|
||||
return collectionItem;
|
||||
}
|
||||
|
||||
- (void) _removeItemsViews
|
||||
|
@ -530,6 +540,11 @@ static NSString *placeholderItem = nil;
|
|||
_numberOfColumns = MIN(_maxNumberOfColumns, _numberOfColumns);
|
||||
}
|
||||
|
||||
if (_numberOfColumns == 0)
|
||||
{
|
||||
_numberOfColumns = 1;
|
||||
}
|
||||
|
||||
CGFloat remaining = width - _numberOfColumns * itemSize.width;
|
||||
|
||||
if (remaining > 0 && itemSize.width < _maxItemSize.width)
|
||||
|
|
|
@ -25,50 +25,15 @@
|
|||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#import "AppKit/NSCollectionViewItem.h"
|
||||
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSArray.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 "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/NSCollectionView.h"
|
||||
#import "AppKit/NSCollectionViewItem.h"
|
||||
#import "AppKit/NSImageView.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/NSTextField.h"
|
||||
|
||||
@implementation NSCollectionViewItem
|
||||
|
||||
|
@ -93,6 +58,12 @@
|
|||
return (NSCollectionView *)[[self view] superview];
|
||||
}
|
||||
|
||||
- (NSArray *) draggingImageComponents
|
||||
{
|
||||
// FIXME: We don't have NSDraggingImageComponent
|
||||
return [NSArray array];
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)flag
|
||||
{
|
||||
if (_isSelected != flag)
|
||||
|
@ -119,10 +90,7 @@
|
|||
|
||||
- (void)setTextField:(NSTextField *)aTextField
|
||||
{
|
||||
if (textField != aTextField)
|
||||
{
|
||||
textField = aTextField;
|
||||
}
|
||||
ASSIGN(textField, aTextField);
|
||||
}
|
||||
|
||||
- (NSImageView *)imageView
|
||||
|
@ -132,37 +100,102 @@
|
|||
|
||||
- (void)setImageView:(NSImageView *)anImageView
|
||||
{
|
||||
if (imageView != anImageView)
|
||||
{
|
||||
imageView = anImageView;
|
||||
}
|
||||
ASSIGN(imageView, anImageView);
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(NSCoder *)aCoder
|
||||
{
|
||||
self = [super initWithCoder:aCoder];
|
||||
|
||||
if (self)
|
||||
if (nil != self)
|
||||
{
|
||||
textField = [aCoder decodeObjectForKey:@"textField"];
|
||||
imageView = [aCoder decodeObjectForKey:@"imageView"];
|
||||
if (YES == [aCoder allowsKeyedCoding])
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
if (YES == [aCoder allowsKeyedCoding])
|
||||
{
|
||||
[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
|
||||
{
|
||||
// FIXME: Cache this data, as we need a lot of copies
|
||||
NSData *itemAsData = [NSKeyedArchiver archivedDataWithRootObject:self];
|
||||
NSCollectionViewItem *newItem = [NSKeyedUnarchiver unarchiveObjectWithData:itemAsData];
|
||||
return newItem;
|
||||
NSCollectionViewItem *newItem =
|
||||
[NSKeyedUnarchiver unarchiveObjectWithData: itemAsData];
|
||||
|
||||
// Try to copy bindings too
|
||||
[self copyBindingsTo: newItem from: [self view] onto: [newItem view]];
|
||||
|
||||
return RETAIN(newItem);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue