mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 03:21:04 +00:00
* Source/NSCollectionView.m (-tile): Prevent _numberOfColumns
from being 0. * Source/NSArrayController.m: Revert last change and add proper handling of arrangeObjects for many cases. * Source/NSCollectionViewItem.m: Fix reference counting. Add method -view to have something to display. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@38387 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
954ab51922
commit
f54ce64d99
4 changed files with 89 additions and 19 deletions
|
@ -1,3 +1,12 @@
|
|||
2015-03-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSCollectionView.m (-tile): Prevent _numberOfColumns from
|
||||
being 0.
|
||||
* Source/NSArrayController.m: Revert last change and add proper
|
||||
handling of arrangeObjects for many cases.
|
||||
* Source/NSCollectionViewItem.m: Fix reference counting. Add
|
||||
method -view to have something to display.
|
||||
|
||||
2015-03-08 Germán Arias <germanandre@gmx.es>
|
||||
|
||||
* Source/NSPrinter.m (-loadPPDAtPath:symbolValues:inclusionSet:):
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
if (self == [NSArrayController class])
|
||||
{
|
||||
[self exposeBinding: NSContentArrayBinding];
|
||||
[self setKeys: [NSArray arrayWithObjects: NSContentBinding, NSContentObjectBinding, nil]
|
||||
triggerChangeNotificationsForDependentKey: @"arrangedObjects"];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +57,6 @@
|
|||
{
|
||||
if ((self = [super initWithContent: content]) != nil)
|
||||
{
|
||||
[self setAutomaticallyRearrangesObjects: YES];
|
||||
[self rearrangeObjects];
|
||||
[self setSelectsInsertedObjects: YES];
|
||||
}
|
||||
|
@ -83,42 +84,76 @@
|
|||
|
||||
- (void) addObject: (id)obj
|
||||
{
|
||||
[self willChangeValueForKey: NSContentBinding];
|
||||
[_content addObject: obj];
|
||||
if ([self automaticallyRearrangesObjects])
|
||||
{
|
||||
[self rearrangeObjects];
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: Should check whether _arranged_objects is mutable
|
||||
ASSIGN(_arranged_objects, [_arranged_objects arrayByAddingObject: obj]);
|
||||
}
|
||||
if ([self selectsInsertedObjects])
|
||||
{
|
||||
[self addSelectedObjects: [NSArray arrayWithObject: obj]];
|
||||
}
|
||||
[self didChangeValueForKey: NSContentBinding];
|
||||
}
|
||||
|
||||
- (void) addObjects: (NSArray*)obj
|
||||
{
|
||||
[self willChangeValueForKey: NSContentBinding];
|
||||
[_content addObjectsFromArray: obj];
|
||||
if ([self automaticallyRearrangesObjects])
|
||||
{
|
||||
[self rearrangeObjects];
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: Should check whether _arranged_objects is mutable
|
||||
ASSIGN(_arranged_objects, [_arranged_objects arrayByAddingObjectsFromArray: obj]);
|
||||
}
|
||||
if ([self selectsInsertedObjects])
|
||||
{
|
||||
[self addSelectedObjects: obj];
|
||||
}
|
||||
[self didChangeValueForKey: NSContentBinding];
|
||||
}
|
||||
|
||||
- (void) removeObject: (id)obj
|
||||
{
|
||||
[self willChangeValueForKey: NSContentBinding];
|
||||
[_content removeObject: obj];
|
||||
[self removeSelectedObjects: [NSArray arrayWithObject: obj]];
|
||||
if ([self automaticallyRearrangesObjects])
|
||||
{
|
||||
[self rearrangeObjects];
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME
|
||||
//[_arranged_objects removeObject: obj];
|
||||
}
|
||||
[self didChangeValueForKey: NSContentBinding];
|
||||
}
|
||||
|
||||
- (void) removeObjects: (NSArray*)obj
|
||||
{
|
||||
[self willChangeValueForKey: NSContentBinding];
|
||||
[_content removeObjectsInArray: obj];
|
||||
[self removeSelectedObjects: obj];
|
||||
if ([self automaticallyRearrangesObjects])
|
||||
{
|
||||
[self rearrangeObjects];
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME
|
||||
//[_arranged_objects removeObjectsInArray: obj];
|
||||
}
|
||||
[self didChangeValueForKey: NSContentBinding];
|
||||
}
|
||||
|
||||
- (BOOL) canInsert
|
||||
|
@ -136,7 +171,7 @@
|
|||
{
|
||||
id new = [self newObject];
|
||||
|
||||
[_content addObject: new];
|
||||
[self addObject: new];
|
||||
RELEASE(new);
|
||||
}
|
||||
|
||||
|
@ -391,10 +426,10 @@ atArrangedObjectIndexes: (NSIndexSet*)idx
|
|||
[self removeObjects: [_arranged_objects objectsAtIndexes: idx]];
|
||||
}
|
||||
|
||||
- (void)bind: (NSString *)binding
|
||||
toObject: (id)anObject
|
||||
withKeyPath: (NSString *)keyPath
|
||||
options: (NSDictionary *)options
|
||||
- (void) bind: (NSString *)binding
|
||||
toObject: (id)anObject
|
||||
withKeyPath: (NSString *)keyPath
|
||||
options: (NSDictionary *)options
|
||||
{
|
||||
if ([binding isEqual: NSContentArrayBinding])
|
||||
{
|
||||
|
@ -441,6 +476,7 @@ atArrangedObjectIndexes: (NSIndexSet*)idx
|
|||
[coder encodeBool: [self selectsInsertedObjects] forKey: @"NSSelectsInsertedObjects"];
|
||||
[coder encodeBool: [self clearsFilterPredicateOnInsertion] forKey:
|
||||
@"NSClearsFilterPredicateOnInsertion"];
|
||||
[coder encodeBool: [self automaticallyRearrangesObjects] forKey: @"NSAutomaticallyRearrangesObjects"];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -476,6 +512,11 @@ atArrangedObjectIndexes: (NSIndexSet*)idx
|
|||
[self setClearsFilterPredicateOnInsertion:
|
||||
[coder decodeBoolForKey: @"NSClearsFilterPredicateOnInsertion"]];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSAutomaticallyRearrangesObjects"])
|
||||
{
|
||||
[self setAutomaticallyRearrangesObjects:
|
||||
[coder decodeBoolForKey: @"NSAutomaticallyRearrangesObjects"]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -522,11 +522,16 @@ static NSString *placeholderItem = nil;
|
|||
NSSize itemSize = NSMakeSize(_minItemSize.width, _minItemSize.height);
|
||||
|
||||
_numberOfColumns = MAX(1.0, floor(width / itemSize.width));
|
||||
|
||||
|
||||
if (_maxNumberOfColumns > 0)
|
||||
{
|
||||
_numberOfColumns = MIN(_maxNumberOfColumns, _numberOfColumns);
|
||||
}
|
||||
|
||||
if (_numberOfColumns == 0)
|
||||
{
|
||||
_numberOfColumns = 1;
|
||||
}
|
||||
|
||||
CGFloat remaining = width - _numberOfColumns * itemSize.width;
|
||||
|
||||
|
|
|
@ -88,10 +88,7 @@
|
|||
|
||||
- (void) setTextField: (NSTextField *)aTextField
|
||||
{
|
||||
if (textField != aTextField)
|
||||
{
|
||||
textField = aTextField;
|
||||
}
|
||||
ASSIGN(textField, aTextField);
|
||||
}
|
||||
|
||||
- (NSImageView *) imageView
|
||||
|
@ -101,10 +98,14 @@
|
|||
|
||||
- (void) setImageView: (NSImageView *)anImageView
|
||||
{
|
||||
if (imageView != anImageView)
|
||||
{
|
||||
imageView = anImageView;
|
||||
}
|
||||
ASSIGN(imageView, anImageView);
|
||||
}
|
||||
|
||||
- (NSView *) view
|
||||
{
|
||||
// FIXME
|
||||
[[self textField] setStringValue: [self representedObject]];
|
||||
return [self textField];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder *)aCoder
|
||||
|
@ -114,13 +115,27 @@
|
|||
{
|
||||
if (YES == [aCoder allowsKeyedCoding])
|
||||
{
|
||||
textField = [aCoder decodeObjectForKey: @"textField"];
|
||||
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
|
||||
{
|
||||
textField = [aCoder decodeObject];
|
||||
imageView = [aCoder decodeObject];
|
||||
[self setTextField: [aCoder decodeObject]];
|
||||
[self setImageView: [aCoder decodeObject]];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
|
|
Loading…
Reference in a new issue