# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1602409905 0 # Node ID 8a609f6748e76558b3def0ef5c8474005652e4d9 # Parent 81c50388851d1ada8086e7e8f713ec95ea719ba8 Mac: Initial code to transition from NSCell based container/tree controls. Been getting deprecation warnings about this since Yosemite 10.10 but the code has been functional so I had been ignoring it. In Big Sur 11.0 the cell based version is displaying incorrectly, instead of spending effort to fix the deprecated cell based version, investing time switching to the View based version using NSTableCellView. This code semi-works, displays briefly before getting an invalid instruction in the message loop. Committing as BUILDING_FOR_YOSEMITE1 instead of BUILDING_FOR_YOSEMITE so the code is currently disabled. diff -r 81c50388851d -r 8a609f6748e7 mac/dw.m --- a/mac/dw.m Tue Oct 06 04:41:40 2020 +0000 +++ b/mac/dw.m Sun Oct 11 09:51:45 2020 +0000 @@ -2238,6 +2238,7 @@ -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } @end +#ifndef BUILDING_FOR_YOSEMITE1 /* Subclass NSTextFieldCell for displaying image and text */ @interface DWImageAndTextCell : NSTextFieldCell { @@ -2356,6 +2357,7 @@ return cellSize; } @end +#endif /* Subclass for a Container/List type */ @interface DWContainer : NSTableView @@ -2570,7 +2572,21 @@ } -(void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - DWImageAndTextCell *bcell = cell; +#ifdef BUILDING_FOR_YOSEMITE1 + NSTableCellView *bcell = cell; + NSTextField *tcell = nil; + + /* Handle drawing image and text if necessary */ + if([cell isMemberOfClass:[NSTableCellView class]]) + { + int index = (int)(row * [tvcols count]); + NSTableCellView *browsercell = [data objectAtIndex:index]; + NSImage *img = [[browsercell imageView] image]; + [[bcell imageView] setImage:img]; + tcell = [bcell textField]; + } +#else + DWImageAndTextCell *bcell = cell, *tcell = cell; /* Handle drawing image and text if necessary */ if([cell isMemberOfClass:[DWImageAndTextCell class]]) @@ -2580,28 +2596,30 @@ NSImage *img = [browsercell image]; [bcell setImage:img]; } - if([cell isKindOfClass:[NSTextFieldCell class]]) +#endif + + if([tcell isKindOfClass:[NSTextFieldCell class]]) { /* Handle drawing alternating row colors if enabled */ if ((row % 2) == 0) { if(evencolor) { - [bcell setDrawsBackground:YES]; - [bcell setBackgroundColor:evencolor]; + [tcell setDrawsBackground:YES]; + [tcell setBackgroundColor:evencolor]; } else - [bcell setDrawsBackground:NO]; + [tcell setDrawsBackground:NO]; } else { if(oddcolor) { - [bcell setDrawsBackground:YES]; - [bcell setBackgroundColor:oddcolor]; + [tcell setDrawsBackground:YES]; + [tcell setBackgroundColor:oddcolor]; } else - [bcell setDrawsBackground:NO]; + [tcell setDrawsBackground:NO]; } } } @@ -2723,6 +2741,14 @@ for(x=0;x width) { width = thiswidth; @@ -2781,6 +2808,10 @@ for(x=0;x width) { width = thiswidth; @@ -2985,8 +3017,10 @@ if (self) { treecol = [[NSTableColumn alloc] init]; +#ifndef BUILDING_FOR_YOSEMITE1 DWImageAndTextCell *browsercell = [[[DWImageAndTextCell alloc] init] autorelease]; [treecol setDataCell:browsercell]; +#endif [self addTableColumn:treecol]; [self setOutlineTableColumn:treecol]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(treeSelectionChanged:) name:NSOutlineViewSelectionDidChangeNotification object:self]; @@ -3047,6 +3081,15 @@ } -(void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item { +#ifdef BUILDING_FOR_YOSEMITE1 + if([cell isMemberOfClass:[NSTableCellView class]]) + { + NSMutableArray *this = (NSMutableArray *)item; + NSImage *img = [this objectAtIndex:0]; + if([img isKindOfClass:[NSImage class]]) + [[(NSTableCellView*)cell imageView] setImage:img]; + } +#else if([cell isMemberOfClass:[DWImageAndTextCell class]]) { NSMutableArray *this = (NSMutableArray *)item; @@ -3054,6 +3097,7 @@ if([img isKindOfClass:[NSImage class]]) [(DWImageAndTextCell*)cell setImage:img]; } +#endif } -(BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item { return NO; } -(void)addTree:(NSMutableArray *)item and:(NSMutableArray *)parent after:(NSMutableArray *)after @@ -7386,6 +7430,9 @@ for(z=0;z