# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1602465326 0 # Node ID e2c00a7a74a1a0efeaf56d427f91d110218ee396 # Parent f93d29310b147ee2e3b40f7ed15a770200d594aa Mac: Seems like we need to create the NSImageView and NSTextField separately and add them to the NSTableCellView as needed. The interface inspector now seems to show the correct information, but sadly nothing is still being displayed. diff -r f93d29310b14 -r e2c00a7a74a1 mac/dw.m --- a/mac/dw.m Sun Oct 11 21:43:41 2020 +0000 +++ b/mac/dw.m Mon Oct 12 01:15:26 2020 +0000 @@ -2567,19 +2567,24 @@ NSTableCellView *result = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self]; int index = (int)(row * [tvcols count]); id celldata = [data objectAtIndex:index]; + NSTextFieldCell *tcell = nil; /* There is no existing cell to reuse so create a new one */ if(result == nil) { /* The data is already a NSTableCellView so just return that */ if([celldata isMemberOfClass:[NSTableCellView class]]) + { result = celldata; + [result setFrame:NSMakeRect(0,0,tableColumn.width,0)]; + [[result textField] setFrame:result.frame]; + } else { /* Create the new NSTableCellView with a frame of the {0,0} with the width of the table. * Note that the height of the frame is not really relevant, because the row height will modify the height. */ - result = [[NSTableCellView alloc] init]; + result = [[NSTableCellView alloc] initWithFrame:NSMakeRect(0,0,tableColumn.width,0)]; /* The identifier of the NSTextField instance is set to MyView. * This allows the cell to be reused. @@ -2591,12 +2596,30 @@ /* result is now guaranteed to be valid, either as a reused cell * or as a new cell, so set the text or image */ - NSTextFieldCell *tcell = [[result textField] cell]; + if([celldata isMemberOfClass:[NSImage class]]) + { + NSImageView *iv = [result imageView]; + if(!iv) + { + iv = [[[NSImageView alloc] initWithFrame:result.frame] autorelease]; + [result setImageView:iv]; + [result addSubview:iv]; + } + [iv setImage:celldata]; + } + if([celldata isKindOfClass:[NSString class]]) + { + NSTextField *tf = [result textField]; + if(!tf) + { + tf = [[[NSTextField alloc] initWithFrame:result.frame] autorelease]; + [result setTextField:tf]; + [result addSubview:tf]; + } + [tf setStringValue:celldata]; + } - if([celldata isMemberOfClass:[NSImage class]]) - [[result imageView] setImage:celldata]; - if([celldata isKindOfClass:[NSString class]]) - [[result textField] setStringValue:celldata]; + tcell = [[result textField] cell]; /* Handle drawing alternating row colors if enabled */ if ((row % 2) == 0) @@ -7724,8 +7747,12 @@ #ifdef BUILDING_FOR_YOSEMITE browsercell = [[[NSTableCellView alloc] init] autorelease]; + [browsercell setImageView:[[[NSImageView alloc] init] autorelease]]; + [browsercell addSubview:[browsercell imageView]]; [[browsercell imageView] setImage:icon]; - [[browsercell textField] setStringValue:[ NSString stringWithUTF8String:filename ]]; + [browsercell setTextField:[[[NSTextField alloc] init] autorelease]]; + [browsercell addSubview:[browsercell textField]]; + [[browsercell textField] setStringValue:[NSString stringWithUTF8String:filename]]; #else browsercell = [[[DWImageAndTextCell alloc] init] autorelease]; [browsercell setImage:icon];