mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 06:51:44 +00:00
Add changes for Xib reading and some minor cleanup for NSCollectionView
This commit is contained in:
parent
8572458a5d
commit
a90ddfc9c5
2 changed files with 34 additions and 8 deletions
|
@ -43,14 +43,18 @@
|
|||
#import "AppKit/NSBrowserCell.h"
|
||||
#import "AppKit/NSButtonCell.h"
|
||||
#import "AppKit/NSCell.h"
|
||||
#import "AppKit/NSCollectionView.h"
|
||||
#import "AppKit/NSCollectionViewLayout.h"
|
||||
#import "AppKit/NSClipView.h"
|
||||
#import "AppKit/NSFormCell.h"
|
||||
#import "AppKit/NSGridView.h"
|
||||
#import "AppKit/NSImage.h"
|
||||
#import "AppKit/NSLayoutConstraint.h"
|
||||
#import "AppKit/NSMatrix.h"
|
||||
#import "AppKit/NSMenu.h"
|
||||
#import "AppKit/NSMenuItem.h"
|
||||
#import "AppKit/NSNib.h"
|
||||
#import "AppKit/NSPageController.h"
|
||||
#import "AppKit/NSParagraphStyle.h"
|
||||
#import "AppKit/NSPathCell.h"
|
||||
#import "AppKit/NSPopUpButton.h"
|
||||
|
@ -66,8 +70,6 @@
|
|||
#import "AppKit/NSTabView.h"
|
||||
#import "AppKit/NSToolbarItem.h"
|
||||
#import "AppKit/NSView.h"
|
||||
#import "AppKit/NSLayoutConstraint.h"
|
||||
#import "AppKit/NSPageController.h"
|
||||
#import "GSCodingFlags.h"
|
||||
|
||||
#define DEBUG_XIB5 0
|
||||
|
@ -3539,6 +3541,14 @@ didStartElement: (NSString*)elementName
|
|||
{
|
||||
hasValue = [self containsValueForKey: [XmlKeyMapTable objectForKey: key]];
|
||||
}
|
||||
else if ([@"NSCollectionViewBackgroundColorsKey" isEqualToString: key])
|
||||
{
|
||||
hasValue = [currentElement elementForKey: @"primaryBackgroundColor"] != nil;
|
||||
}
|
||||
else if ([@"NSCollectionViewLayout" isEqualToString: key])
|
||||
{
|
||||
hasValue = [currentElement elementForKey: @"collectionViewLayout"] != nil;
|
||||
}
|
||||
else if (([@"NSIntercellSpacingHeight" isEqualToString: key]) ||
|
||||
([@"NSIntercellSpacingWidth" isEqualToString: key]))
|
||||
{
|
||||
|
|
|
@ -440,6 +440,7 @@ static NSString *placeholderItem = nil;
|
|||
- (void) setCollectionViewLayout: (NSCollectionViewLayout *)layout
|
||||
{
|
||||
ASSIGN(_collectionViewLayout, layout);
|
||||
[self reloadData];
|
||||
}
|
||||
|
||||
- (NSRect) frameForItemAtIndex: (NSUInteger)theIndex
|
||||
|
@ -690,6 +691,7 @@ static NSString *placeholderItem = nil;
|
|||
|
||||
if ([aCoder containsValueForKey: NSCollectionViewBackgroundColorsKey])
|
||||
{
|
||||
NSLog(@"******** loading colors");
|
||||
[self setBackgroundColors: [aCoder decodeObjectForKey: NSCollectionViewBackgroundColorsKey]];
|
||||
}
|
||||
|
||||
|
@ -1322,6 +1324,7 @@ static NSString *placeholderItem = nil;
|
|||
|
||||
- (void) setDataSource: (id<NSCollectionViewDataSource>)dataSource
|
||||
{
|
||||
NSLog(@"Adding data source %@", dataSource);
|
||||
_dataSource = dataSource;
|
||||
[self reloadData];
|
||||
}
|
||||
|
@ -1362,24 +1365,37 @@ static NSString *placeholderItem = nil;
|
|||
{
|
||||
NSInteger ns = [self numberOfSections];
|
||||
NSInteger cs = 0;
|
||||
|
||||
|
||||
NSLog(@"reloading data... number of sections = %ld, %@", ns, _collectionViewLayout);
|
||||
for (cs = 0; cs < ns; cs++)
|
||||
{
|
||||
NSInteger ni = [self numberOfItemsInSection: cs];
|
||||
NSInteger ci = 0;
|
||||
|
||||
NSLog(@"current section = %ld", cs);
|
||||
|
||||
for (ci = 0; ci < ni; ci++)
|
||||
{
|
||||
NSIndexPath *p = nil;
|
||||
NSCollectionViewItem *item = [_dataSource collectionView: self itemForRepresentedObjectAtIndexPath: p];
|
||||
NSIndexPath *p = [NSIndexPath indexPathForItem: ci inSection: cs];
|
||||
NSCollectionViewItem *item =
|
||||
[_dataSource collectionView: self itemForRepresentedObjectAtIndexPath: p];
|
||||
NSNib *nib = [self _nibForClass: [item class]];
|
||||
BOOL loaded = [nib instantiateWithOwner: item
|
||||
topLevelObjects: NULL];
|
||||
|
||||
if (loaded)
|
||||
if (!loaded)
|
||||
{
|
||||
NSLog(@"Could not load model %@", nib);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSView *v = [item view];
|
||||
NSLog(@"%@",v);
|
||||
NSCollectionViewLayoutAttributes *attrs =
|
||||
[_collectionViewLayout layoutAttributesForItemAtIndexPath: p];
|
||||
NSRect f = [attrs frame];
|
||||
|
||||
// set position of item based on currently selected layout...
|
||||
[v setFrame: f];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1411,7 +1427,7 @@ static NSString *placeholderItem = nil;
|
|||
{
|
||||
NSInteger n = 0;
|
||||
|
||||
if ([_dataSource respondsToSelector: @selector(numberOfsectionsInCollectionView:)])
|
||||
if ([_dataSource respondsToSelector: @selector(numberOfSectionsInCollectionView:)])
|
||||
{
|
||||
n = [_dataSource numberOfSectionsInCollectionView: self];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue