mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 02:51:00 +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
5fa907104e
commit
eff9d720a9
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>
|
2015-03-08 Germán Arias <germanandre@gmx.es>
|
||||||
|
|
||||||
* Source/NSPrinter.m (-loadPPDAtPath:symbolValues:inclusionSet:):
|
* Source/NSPrinter.m (-loadPPDAtPath:symbolValues:inclusionSet:):
|
||||||
|
|
|
@ -48,6 +48,8 @@
|
||||||
if (self == [NSArrayController class])
|
if (self == [NSArrayController class])
|
||||||
{
|
{
|
||||||
[self exposeBinding: NSContentArrayBinding];
|
[self exposeBinding: NSContentArrayBinding];
|
||||||
|
[self setKeys: [NSArray arrayWithObjects: NSContentBinding, NSContentObjectBinding, nil]
|
||||||
|
triggerChangeNotificationsForDependentKey: @"arrangedObjects"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +57,6 @@
|
||||||
{
|
{
|
||||||
if ((self = [super initWithContent: content]) != nil)
|
if ((self = [super initWithContent: content]) != nil)
|
||||||
{
|
{
|
||||||
[self setAutomaticallyRearrangesObjects: YES];
|
|
||||||
[self rearrangeObjects];
|
[self rearrangeObjects];
|
||||||
[self setSelectsInsertedObjects: YES];
|
[self setSelectsInsertedObjects: YES];
|
||||||
}
|
}
|
||||||
|
@ -83,42 +84,76 @@
|
||||||
|
|
||||||
- (void) addObject: (id)obj
|
- (void) addObject: (id)obj
|
||||||
{
|
{
|
||||||
|
[self willChangeValueForKey: NSContentBinding];
|
||||||
[_content addObject: obj];
|
[_content addObject: obj];
|
||||||
if ([self automaticallyRearrangesObjects])
|
if ([self automaticallyRearrangesObjects])
|
||||||
{
|
{
|
||||||
[self rearrangeObjects];
|
[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
|
- (void) addObjects: (NSArray*)obj
|
||||||
{
|
{
|
||||||
|
[self willChangeValueForKey: NSContentBinding];
|
||||||
[_content addObjectsFromArray: obj];
|
[_content addObjectsFromArray: obj];
|
||||||
if ([self automaticallyRearrangesObjects])
|
if ([self automaticallyRearrangesObjects])
|
||||||
{
|
{
|
||||||
[self rearrangeObjects];
|
[self rearrangeObjects];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// FIXME: Should check whether _arranged_objects is mutable
|
||||||
|
ASSIGN(_arranged_objects, [_arranged_objects arrayByAddingObjectsFromArray: obj]);
|
||||||
|
}
|
||||||
if ([self selectsInsertedObjects])
|
if ([self selectsInsertedObjects])
|
||||||
{
|
{
|
||||||
[self addSelectedObjects: obj];
|
[self addSelectedObjects: obj];
|
||||||
}
|
}
|
||||||
|
[self didChangeValueForKey: NSContentBinding];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) removeObject: (id)obj
|
- (void) removeObject: (id)obj
|
||||||
{
|
{
|
||||||
|
[self willChangeValueForKey: NSContentBinding];
|
||||||
[_content removeObject: obj];
|
[_content removeObject: obj];
|
||||||
|
[self removeSelectedObjects: [NSArray arrayWithObject: obj]];
|
||||||
if ([self automaticallyRearrangesObjects])
|
if ([self automaticallyRearrangesObjects])
|
||||||
{
|
{
|
||||||
[self rearrangeObjects];
|
[self rearrangeObjects];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// FIXME
|
||||||
|
//[_arranged_objects removeObject: obj];
|
||||||
|
}
|
||||||
|
[self didChangeValueForKey: NSContentBinding];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) removeObjects: (NSArray*)obj
|
- (void) removeObjects: (NSArray*)obj
|
||||||
{
|
{
|
||||||
|
[self willChangeValueForKey: NSContentBinding];
|
||||||
[_content removeObjectsInArray: obj];
|
[_content removeObjectsInArray: obj];
|
||||||
|
[self removeSelectedObjects: obj];
|
||||||
if ([self automaticallyRearrangesObjects])
|
if ([self automaticallyRearrangesObjects])
|
||||||
{
|
{
|
||||||
[self rearrangeObjects];
|
[self rearrangeObjects];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// FIXME
|
||||||
|
//[_arranged_objects removeObjectsInArray: obj];
|
||||||
|
}
|
||||||
|
[self didChangeValueForKey: NSContentBinding];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) canInsert
|
- (BOOL) canInsert
|
||||||
|
@ -136,7 +171,7 @@
|
||||||
{
|
{
|
||||||
id new = [self newObject];
|
id new = [self newObject];
|
||||||
|
|
||||||
[_content addObject: new];
|
[self addObject: new];
|
||||||
RELEASE(new);
|
RELEASE(new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,10 +426,10 @@ atArrangedObjectIndexes: (NSIndexSet*)idx
|
||||||
[self removeObjects: [_arranged_objects objectsAtIndexes: idx]];
|
[self removeObjects: [_arranged_objects objectsAtIndexes: idx]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)bind: (NSString *)binding
|
- (void) bind: (NSString *)binding
|
||||||
toObject: (id)anObject
|
toObject: (id)anObject
|
||||||
withKeyPath: (NSString *)keyPath
|
withKeyPath: (NSString *)keyPath
|
||||||
options: (NSDictionary *)options
|
options: (NSDictionary *)options
|
||||||
{
|
{
|
||||||
if ([binding isEqual: NSContentArrayBinding])
|
if ([binding isEqual: NSContentArrayBinding])
|
||||||
{
|
{
|
||||||
|
@ -441,6 +476,7 @@ atArrangedObjectIndexes: (NSIndexSet*)idx
|
||||||
[coder encodeBool: [self selectsInsertedObjects] forKey: @"NSSelectsInsertedObjects"];
|
[coder encodeBool: [self selectsInsertedObjects] forKey: @"NSSelectsInsertedObjects"];
|
||||||
[coder encodeBool: [self clearsFilterPredicateOnInsertion] forKey:
|
[coder encodeBool: [self clearsFilterPredicateOnInsertion] forKey:
|
||||||
@"NSClearsFilterPredicateOnInsertion"];
|
@"NSClearsFilterPredicateOnInsertion"];
|
||||||
|
[coder encodeBool: [self automaticallyRearrangesObjects] forKey: @"NSAutomaticallyRearrangesObjects"];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -476,6 +512,11 @@ atArrangedObjectIndexes: (NSIndexSet*)idx
|
||||||
[self setClearsFilterPredicateOnInsertion:
|
[self setClearsFilterPredicateOnInsertion:
|
||||||
[coder decodeBoolForKey: @"NSClearsFilterPredicateOnInsertion"]];
|
[coder decodeBoolForKey: @"NSClearsFilterPredicateOnInsertion"]];
|
||||||
}
|
}
|
||||||
|
if ([coder containsValueForKey: @"NSAutomaticallyRearrangesObjects"])
|
||||||
|
{
|
||||||
|
[self setAutomaticallyRearrangesObjects:
|
||||||
|
[coder decodeBoolForKey: @"NSAutomaticallyRearrangesObjects"]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -522,11 +522,16 @@ static NSString *placeholderItem = nil;
|
||||||
NSSize itemSize = NSMakeSize(_minItemSize.width, _minItemSize.height);
|
NSSize itemSize = NSMakeSize(_minItemSize.width, _minItemSize.height);
|
||||||
|
|
||||||
_numberOfColumns = MAX(1.0, floor(width / itemSize.width));
|
_numberOfColumns = MAX(1.0, floor(width / itemSize.width));
|
||||||
|
|
||||||
if (_maxNumberOfColumns > 0)
|
if (_maxNumberOfColumns > 0)
|
||||||
{
|
{
|
||||||
_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;
|
||||||
|
|
||||||
|
|
|
@ -88,10 +88,7 @@
|
||||||
|
|
||||||
- (void) setTextField: (NSTextField *)aTextField
|
- (void) setTextField: (NSTextField *)aTextField
|
||||||
{
|
{
|
||||||
if (textField != aTextField)
|
ASSIGN(textField, aTextField);
|
||||||
{
|
|
||||||
textField = aTextField;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSImageView *) imageView
|
- (NSImageView *) imageView
|
||||||
|
@ -101,10 +98,14 @@
|
||||||
|
|
||||||
- (void) setImageView: (NSImageView *)anImageView
|
- (void) setImageView: (NSImageView *)anImageView
|
||||||
{
|
{
|
||||||
if (imageView != anImageView)
|
ASSIGN(imageView, anImageView);
|
||||||
{
|
}
|
||||||
imageView = anImageView;
|
|
||||||
}
|
- (NSView *) view
|
||||||
|
{
|
||||||
|
// FIXME
|
||||||
|
[[self textField] setStringValue: [self representedObject]];
|
||||||
|
return [self textField];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder *)aCoder
|
- (id) initWithCoder: (NSCoder *)aCoder
|
||||||
|
@ -114,13 +115,27 @@
|
||||||
{
|
{
|
||||||
if (YES == [aCoder allowsKeyedCoding])
|
if (YES == [aCoder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
textField = [aCoder decodeObjectForKey: @"textField"];
|
if ([aCoder containsValueForKey: @"textField"])
|
||||||
imageView = [aCoder decodeObjectForKey: @"imageView"];
|
{
|
||||||
|
[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
|
else
|
||||||
{
|
{
|
||||||
textField = [aCoder decodeObject];
|
[self setTextField: [aCoder decodeObject]];
|
||||||
imageView = [aCoder decodeObject];
|
[self setImageView: [aCoder decodeObject]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue