Use represented object

This commit is contained in:
Gregory John Casamento 2020-05-06 10:38:24 -04:00
parent 7764903d6d
commit 0e7f729f1f
4 changed files with 21 additions and 21 deletions

View file

@ -969,6 +969,7 @@
if (s == NSPathStyleStandard || s == NSPathStyleNavigationBar)
{
/*
if (s == NSPathStyleNavigationBar)
{
[[NSColor lightGrayColor] set];
@ -976,7 +977,7 @@
[[NSColor controlShadowColor] set];
NSFrameRectWithWidth(f, 1);
}
*/
// Modify positions...
textFrame.origin.x += 25.0; // the width of the image plus a few pixels.
textFrame.origin.y += 3.0; // center with the image...

View file

@ -3236,10 +3236,6 @@ didStartElement: (NSString*)elementName
hasValue = [currentElement attributeForKey: @"alternateTitle"] != nil;
hasValue |= [currentElement attributeForKey: @"alternateImage"] != nil;
}
else if ([@"NSPathStyle" isEqualToString: key])
{
hasValue = [currentElement attributeForKey: @"pathStyle"] != nil;
}
else if ([@"NSPathComponentCells" isEqualToString: key])
{
hasValue = [currentElement elementForKey: @"url"] != nil;

View file

@ -118,13 +118,6 @@ Class pathComponentCellClass;
ASSIGNCOPY(_backgroundColor, color);
}
- (void) setObjectValue: (id)obj
{
NSLog(@"Called");
[super setObjectValue: obj];
[self setURL: obj];
}
+ (Class) pathComponentCellClass
{
return pathComponentCellClass;
@ -185,12 +178,12 @@ Class pathComponentCellClass;
- (NSURL *) URL
{
return _url;
return [self objectValue];
}
- (void) setURL: (NSURL *)url
{
ASSIGNCOPY(_url, url);
[self setObjectValue: url];
[self setPathComponentCells: [NSPathCell _generateCellsForURL: url]];
}
@ -228,12 +221,12 @@ Class pathComponentCellClass;
- (id) initWithCoder: (NSCoder *)coder
{
self = [super initWithCoder: coder];
if ([coder allowsKeyedCoding])
{
[self setPathStyle: NSPathStyleStandard];
// if ([coder containsValueForKey: @"NSPathStyle"]) // can't seem to find it in the contains method,
// but it does when I decode it... not sure why.
if ([coder containsValueForKey: @"NSPathStyle"])
{
[self setPathStyle: [coder decodeIntegerForKey: @"NSPathStyle"]];
}
@ -242,6 +235,14 @@ Class pathComponentCellClass;
{
[self setPathComponentCells: [coder decodeObjectForKey: @"NSPathComponentCells"]];
}
if ([coder containsValueForKey: @"NSContents"])
{
[self setObjectValue: [coder decodeObjectForKey: @"NSContents"]];
}
NSLog(@"OBJECTVALUE = %@", [self objectValue]);
}
else
{
@ -255,6 +256,7 @@ Class pathComponentCellClass;
- (void) encodeWithCoder: (NSCoder *)coder
{
[super encodeWithCoder: coder];
if ([coder allowsKeyedCoding])
{
[coder encodeInteger: [self pathStyle]

View file

@ -272,11 +272,7 @@ static NSNotificationCenter *nc = nil;
- (void) _doMenuAction: (id)sender
{
NSArray *cells = [self pathComponentCells];
NSUInteger c = [cells count];
NSUInteger i = [[sender menu] indexOfItem: sender];
NSUInteger ci = (c - i) + 1;
NSPathComponentCell *cc = [cells objectAtIndex: ci];
NSPathComponentCell *cc = (NSPathComponentCell *)[sender representedObject];
[_cell _setClickedPathComponentCell: cc];
if ([[self cell] action])
@ -351,6 +347,7 @@ static NSNotificationCenter *nc = nil;
[i setTitle: s];
[i setTarget: self];
[i setAction: @selector(_doMenuAction:)];
[i setRepresentedObject: c];
[menu insertItem: i
atIndex: 0];
@ -369,6 +366,9 @@ static NSNotificationCenter *nc = nil;
[menu insertItem: i
atIndex: 0];
RELEASE(i);
[self setMenu: menu];
RELEASE(menu);
if (_delegate)
{
@ -497,6 +497,7 @@ static NSNotificationCenter *nc = nil;
- (void) encodeWithCoder: (NSCoder *)coder
{
[super encodeWithCoder: coder];
if ([coder allowsKeyedCoding])
{
[coder encodeObject: [self backgroundColor]