Author: mlytwyn
Date: Fri Jun 26 02:29:04 2015
New Revision: 38688
URL: http://svn.gna.org/viewcvs/gnustep?rev=38688&view=rev
Log:
Header and NSCollection* source merges
Modified:
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSAlert.h
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSAnimation.h
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSApplication.h
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCell.h
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCollectionView.h
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCollectionViewItem.h
libs/gui/branches/gnustep_testplant_branch/Source/NSCollectionView.m
libs/gui/branches/gnustep_testplant_branch/Source/NSCollectionViewItem.m
Modified: libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSAlert.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSAlert.h?rev=38688&r1=38687&r2=38688&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSAlert.h
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSAlert.h Fri Jun
26 02:29:04 2015
@@ -112,8 +112,14 @@
* 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
Modified:
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSAnimation.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSAnimation.h?rev=38688&r1=38687&r2=38688&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSAnimation.h
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSAnimation.h
Fri Jun 26 02:29:04 2015
@@ -263,7 +263,13 @@
@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. */
Modified:
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSApplication.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSApplication.h?rev=38688&r1=38687&r2=38688&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSApplication.h
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSApplication.h
Fri Jun 26 02:29:04 2015
@@ -446,7 +446,7 @@
* <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
Modified: libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCell.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCell.h?rev=38688&r1=38687&r2=38688&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCell.h
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCell.h Fri Jun
26 02:29:04 2015
@@ -146,12 +146,14 @@
};
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,
Modified:
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCollectionView.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCollectionView.h?rev=38688&r1=38687&r2=38688&view=diff
==============================================================================
---
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCollectionView.h
(original)
+++
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCollectionView.h
Fri Jun 26 02:29:04 2015
@@ -29,11 +29,11 @@
#ifndef _GNUstep_H_NSCollectionView
#define _GNUstep_H_NSCollectionView
-#import <AppKit/NSNibDeclarations.h>
#import <GNUstepBase/GSVersionMacros.h>
+#import <AppKit/NSDragging.h>
+#import <AppKit/NSNibDeclarations.h>
#import <AppKit/NSView.h>
-#import <AppKit/NSDragging.h>
@class NSCollectionViewItem;
@class NSCollectionView;
@@ -47,17 +47,32 @@
@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 @@
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;
Modified:
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCollectionViewItem.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCollectionViewItem.h?rev=38688&r1=38687&r2=38688&view=diff
==============================================================================
---
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCollectionViewItem.h
(original)
+++
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSCollectionViewItem.h
Fri Jun 26 02:29:04 2015
@@ -29,14 +29,16 @@
#ifndef _GNUstep_H_NSCollectionViewItem
#define _GNUstep_H_NSCollectionViewItem
+#import <GNUstepBase/GSVersionMacros.h>
+#import <Foundation/NSArray.h>
+
+#import <AppKit/NSCollectionView.h>
+#import <AppKit/NSDragging.h>
+#import <AppKit/NSImageView.h>
#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 <AppKit/NSCollectionView.h>
-#import <AppKit/NSDragging.h>
@interface NSCollectionViewItem : NSViewController
@@ -47,13 +49,15 @@
}
- (NSCollectionView *)collectionView;
+- (NSArray *)draggingImageComponents;
- (void)setSelected:(BOOL)shouldBeSelected;
- (BOOL)isSelected;
- (NSTextField *)textField;
+- (void)setTextField:(NSTextField *)aTextField;
+
- (NSImageView *)imageView;
-- (void)setTextField:(NSTextField *)aTextField;
- (void)setImageView:(NSImageView *)anImageView;
@end
Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSCollectionView.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSCollectionView.m?rev=38688&r1=38687&r2=38688&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/NSCollectionView.m
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/NSCollectionView.m
Fri Jun 26 02:29:04 2015
@@ -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 @@
//
+ (void) initialize
{
+ if (self == [NSCollectionView class])
+ {
placeholderItem = @"Placeholder";
+ [self exposeBinding: NSContentBinding];
+}
}
- (id) initWithFrame: (NSRect)frame
@@ -120,7 +125,7 @@
- (void) _resetItemSize
{
- if (itemPrototype)
+ if (itemPrototype && ([itemPrototype view] != nil))
{
_itemSize = [[itemPrototype view] frame].size;
_minItemSize = NSMakeSize (_itemSize.width, _itemSize.height);
@@ -151,8 +156,11 @@
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 @@
}
else
{
+ [self _resetItemSize];
// Force recalculation of each item's frame
_itemSize = _minItemSize;
_tileWidth = -1.0;
@@ -475,6 +484,7 @@
NSRect initRect = NSMakeRect (-10000,-10000,100,100);
[[item view] setFrame:initRect];
[self addSubview: [item view]];
+ RELEASE(item);
}
return item;
}
@@ -484,10 +494,10 @@
NSCollectionViewItem *collectionItem = nil;
if (itemPrototype)
{
- ASSIGN(collectionItem, [itemPrototype copy]);
+ collectionItem = [itemPrototype copy];
[collectionItem setRepresentedObject: object];
}
- return AUTORELEASE (collectionItem);
+ return collectionItem;
}
- (void) _removeItemsViews
@@ -528,6 +538,11 @@
if (_maxNumberOfColumns > 0)
{
_numberOfColumns = MIN(_maxNumberOfColumns, _numberOfColumns);
+ }
+
+ if (_numberOfColumns == 0)
+ {
+ _numberOfColumns = 1;
}
CGFloat remaining = width - _numberOfColumns * itemSize.width;
Modified:
libs/gui/branches/gnustep_testplant_branch/Source/NSCollectionViewItem.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSCollectionViewItem.m?rev=38688&r1=38687&r2=38688&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/NSCollectionViewItem.m
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/NSCollectionViewItem.m
Fri Jun 26 02:29:04 2015
@@ -25,50 +25,15 @@
Boston, MA 02110-1301, USA.
*/
+#import <Foundation/NSArray.h>
+#import <Foundation/NSDictionary.h>
+#import <Foundation/NSKeyedArchiver.h>
+
+#import "AppKit/NSCollectionView.h"
#import "AppKit/NSCollectionViewItem.h"
-
-#import <Foundation/NSAutoreleasePool.h>
-#import <Foundation/NSDebug.h>
-#import <Foundation/NSDictionary.h>
-#import <Foundation/NSEnumerator.h>
-#import <Foundation/NSException.h>
-#import <Foundation/NSFormatter.h>
-#import <Foundation/NSIndexSet.h>
-#import <Foundation/NSKeyValueCoding.h>
-#import <Foundation/NSNotification.h>
-#import <Foundation/NSSet.h>
-#import <Foundation/NSSortDescriptor.h>
-#import <Foundation/NSUserDefaults.h>
-#import <Foundation/NSValue.h>
-#import <Foundation/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/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,50 +90,112 @@
- (void)setTextField:(NSTextField *)aTextField
{
- if (textField != aTextField)
- {
- textField = aTextField;
+ ASSIGN(textField, aTextField);
+}
+
+- (NSImageView *)imageView
+{
+ return imageView;
+}
+
+- (void)setImageView:(NSImageView *)anImageView
+{
+ ASSIGN(imageView, anImageView);
+}
+
+- (id)initWithCoder:(NSCoder *)aCoder
+{
+ self = [super initWithCoder:aCoder];
+ if (nil != self)
+ {
+ 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)];
+ }
}
-}
-
-- (NSImageView *)imageView
-{
- return imageView;
-}
-
-- (void)setImageView:(NSImageView *)anImageView
-{
- if (imageView != anImageView)
- {
- imageView = anImageView;
+ else
+ {
+ [self setTextField: [aCoder decodeObject]];
+ [self setImageView: [aCoder decodeObject]];
}
-}
-
-- (id)initWithCoder:(NSCoder *)aCoder
-{
- self = [super initWithCoder:aCoder];
-
- if (self)
- {
- textField = [aCoder decodeObjectForKey:@"textField"];
- imageView = [aCoder decodeObjectForKey:@"imageView"];
- }
-
+ }
return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder
{
[super encodeWithCoder:aCoder];
- [aCoder encodeObject:textField forKey:@"textField"];
- [aCoder encodeObject:imageView forKey:@"imageView"];
-}
+ 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
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs