Move _applyBindingsToCell:atRow: to NSTableColumn

This commit is contained in:
Gregory John Casamento 2024-08-07 22:55:14 -04:00
parent 21d0bc906e
commit d8c4c14018
3 changed files with 92 additions and 92 deletions

View file

@ -147,9 +147,11 @@ static NSImage *unexpandable = nil;
- (id) _prototypeCellViewFromTableColumn: (NSTableColumn *)tb;
- (void) _drawCellViewRow: (NSInteger)rowIndex
clipRect: (NSRect)clipRect;
@end
@interface NSTableColumn (Private)
- (void) _applyBindingsToCell: (NSCell *)cell
forTableColumn: (NSTableColumn *)tb
row: (NSInteger)index;
atRow: (NSInteger)index;
@end
@interface NSTreeNode (Private_NSOutlineView)
@ -1985,9 +1987,8 @@ Also returns the child index relative to this parent. */
forTableColumn: (NSTableColumn *)tb
row: (NSInteger)index
{
[self _applyBindingsToCell: cell
forTableColumn: tb
row: index];
[tb _applyBindingsToCell: cell
atRow: index];
if (_del_responds)
{

View file

@ -654,6 +654,85 @@ to YES. */
return [_headerCell stringValue];
}
- (void) _applyBindingsToCell: (NSCell *)cell
atRow: (NSInteger)index
{
GSKeyValueBinding *theBinding = nil;
NSFont *font = nil;
theBinding = [GSKeyValueBinding getBinding: NSEditableBinding
forObject: self];
if (theBinding != nil)
{
id result = nil;
BOOL flag = NO;
result = [(NSArray *)[theBinding destinationValue]
objectAtIndex: index];
flag = [result boolValue];
[cell setEditable: flag];
}
theBinding = [GSKeyValueBinding getBinding: NSEnabledBinding
forObject: self];
if (theBinding != nil)
{
id result = nil;
BOOL flag = NO;
result = [(NSArray *)[theBinding destinationValue]
objectAtIndex: index];
flag = [result boolValue];
[cell setEnabled: flag];
}
/* Font bindings... According to Apple documentation, if the
* font binding is available, then name, size, and other
* font related bindings are ignored. Otherwise they are
* used
*/
theBinding = [GSKeyValueBinding getBinding: NSFontBinding
forObject: self];
if (theBinding != nil)
{
font = [(NSArray *)[theBinding destinationValue]
objectAtIndex: index];
}
else
{
NSString *fontName = nil;
CGFloat fontSize = 0.0;
theBinding = [GSKeyValueBinding getBinding: NSFontNameBinding
forObject: self];
if (theBinding != nil)
{
fontName = [(NSArray *)[theBinding destinationValue]
objectAtIndex: index];
}
if (fontName != nil)
{
theBinding = [GSKeyValueBinding getBinding: NSFontSizeBinding
forObject: self];
if (theBinding != nil)
{
id num = [(NSArray *)[theBinding destinationValue]
objectAtIndex: index];
fontSize = [num doubleValue];
}
font = [NSFont fontWithName: fontName
size: fontSize];
}
}
if (font != nil)
{
[cell setFont: font];
}
}
- (void) setValue: (id)anObject forKey: (NSString*)aKey
{
if ([aKey isEqual: NSValueBinding])
@ -667,7 +746,8 @@ to YES. */
}
else if ([aKey isEqual: NSEditableBinding])
{
// FIXME
NSNumber *v = [anObject valueForKey: NSEditableBinding];
_is_editable = [v boolValue];
}
else
{
@ -688,8 +768,7 @@ to YES. */
}
else if ([aKey isEqual: NSEditableBinding])
{
// FIXME
return [NSNumber numberWithBool: YES];
return [NSNumber numberWithBool: _is_editable];
}
else
{

View file

@ -183,6 +183,8 @@ typedef struct _tableViewFlags
@interface NSTableColumn (Private)
- (NSArray *) _prototypeCellViews;
- (void) _applyBindingsToCell: (NSCell *)cell
atRow: (NSInteger)index;
@end
/*
@ -6875,94 +6877,12 @@ For a more detailed explanation, -setSortDescriptors:. */
return [cell isEditable];
}
}
- (void) _applyBindingsToCell: (NSCell *)cell
forTableColumn: (NSTableColumn *)tb
row: (NSInteger)index
{
GSKeyValueBinding *theBinding = nil;
NSFont *font = nil;
theBinding = [GSKeyValueBinding getBinding: NSEditableBinding
forObject: tb];
if (theBinding != nil)
{
id result = nil;
BOOL flag = NO;
result = [(NSArray *)[theBinding destinationValue]
objectAtIndex: index];
flag = [result boolValue];
[cell setEditable: flag];
}
theBinding = [GSKeyValueBinding getBinding: NSEnabledBinding
forObject: tb];
if (theBinding != nil)
{
id result = nil;
BOOL flag = NO;
result = [(NSArray *)[theBinding destinationValue]
objectAtIndex: index];
flag = [result boolValue];
[cell setEnabled: flag];
}
/* Font bindings... According to Apple documentation, if the
* font binding is available, then name, size, and other
* font related bindings are ignored. Otherwise they are
* used
*/
theBinding = [GSKeyValueBinding getBinding: NSFontBinding
forObject: tb];
if (theBinding != nil)
{
font = [(NSArray *)[theBinding destinationValue]
objectAtIndex: index];
}
else
{
NSString *fontName = nil;
CGFloat fontSize = 0.0;
theBinding = [GSKeyValueBinding getBinding: NSFontNameBinding
forObject: tb];
if (theBinding != nil)
{
fontName = [(NSArray *)[theBinding destinationValue]
objectAtIndex: index];
}
if (fontName != nil)
{
theBinding = [GSKeyValueBinding getBinding: NSFontSizeBinding
forObject: tb];
if (theBinding != nil)
{
id num = [(NSArray *)[theBinding destinationValue]
objectAtIndex: index];
fontSize = [num doubleValue];
}
font = [NSFont fontWithName: fontName
size: fontSize];
}
}
if (font != nil)
{
[cell setFont: font];
}
}
- (void) _willDisplayCell: (NSCell*)cell
forTableColumn: (NSTableColumn *)tb
row: (NSInteger)index
{
[self _applyBindingsToCell: cell
forTableColumn: tb
row: index];
[tb _applyBindingsToCell: cell
atRow: index];
if (_del_responds)
{