Mercurial > dwindows
comparison mac/dw.m @ 2175:e2c00a7a74a1
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.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 12 Oct 2020 01:15:26 +0000 |
parents | f93d29310b14 |
children | 288416bd6d3e |
comparison
equal
deleted
inserted
replaced
2174:f93d29310b14 | 2175:e2c00a7a74a1 |
---|---|
2565 { | 2565 { |
2566 /* Get an existing cell with the MyView identifier if it exists */ | 2566 /* Get an existing cell with the MyView identifier if it exists */ |
2567 NSTableCellView *result = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self]; | 2567 NSTableCellView *result = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self]; |
2568 int index = (int)(row * [tvcols count]); | 2568 int index = (int)(row * [tvcols count]); |
2569 id celldata = [data objectAtIndex:index]; | 2569 id celldata = [data objectAtIndex:index]; |
2570 NSTextFieldCell *tcell = nil; | |
2570 | 2571 |
2571 /* There is no existing cell to reuse so create a new one */ | 2572 /* There is no existing cell to reuse so create a new one */ |
2572 if(result == nil) | 2573 if(result == nil) |
2573 { | 2574 { |
2574 /* The data is already a NSTableCellView so just return that */ | 2575 /* The data is already a NSTableCellView so just return that */ |
2575 if([celldata isMemberOfClass:[NSTableCellView class]]) | 2576 if([celldata isMemberOfClass:[NSTableCellView class]]) |
2577 { | |
2576 result = celldata; | 2578 result = celldata; |
2579 [result setFrame:NSMakeRect(0,0,tableColumn.width,0)]; | |
2580 [[result textField] setFrame:result.frame]; | |
2581 } | |
2577 else | 2582 else |
2578 { | 2583 { |
2579 /* Create the new NSTableCellView with a frame of the {0,0} with the width of the table. | 2584 /* Create the new NSTableCellView with a frame of the {0,0} with the width of the table. |
2580 * Note that the height of the frame is not really relevant, because the row height will modify the height. | 2585 * Note that the height of the frame is not really relevant, because the row height will modify the height. |
2581 */ | 2586 */ |
2582 result = [[NSTableCellView alloc] init]; | 2587 result = [[NSTableCellView alloc] initWithFrame:NSMakeRect(0,0,tableColumn.width,0)]; |
2583 | 2588 |
2584 /* The identifier of the NSTextField instance is set to MyView. | 2589 /* The identifier of the NSTextField instance is set to MyView. |
2585 * This allows the cell to be reused. | 2590 * This allows the cell to be reused. |
2586 */ | 2591 */ |
2587 [result setIdentifier:tableColumn.identifier]; | 2592 [result setIdentifier:tableColumn.identifier]; |
2589 } | 2594 } |
2590 | 2595 |
2591 /* result is now guaranteed to be valid, either as a reused cell | 2596 /* result is now guaranteed to be valid, either as a reused cell |
2592 * or as a new cell, so set the text or image | 2597 * or as a new cell, so set the text or image |
2593 */ | 2598 */ |
2594 NSTextFieldCell *tcell = [[result textField] cell]; | 2599 if([celldata isMemberOfClass:[NSImage class]]) |
2600 { | |
2601 NSImageView *iv = [result imageView]; | |
2602 if(!iv) | |
2603 { | |
2604 iv = [[[NSImageView alloc] initWithFrame:result.frame] autorelease]; | |
2605 [result setImageView:iv]; | |
2606 [result addSubview:iv]; | |
2607 } | |
2608 [iv setImage:celldata]; | |
2609 } | |
2610 if([celldata isKindOfClass:[NSString class]]) | |
2611 { | |
2612 NSTextField *tf = [result textField]; | |
2613 if(!tf) | |
2614 { | |
2615 tf = [[[NSTextField alloc] initWithFrame:result.frame] autorelease]; | |
2616 [result setTextField:tf]; | |
2617 [result addSubview:tf]; | |
2618 } | |
2619 [tf setStringValue:celldata]; | |
2620 } | |
2595 | 2621 |
2596 if([celldata isMemberOfClass:[NSImage class]]) | 2622 tcell = [[result textField] cell]; |
2597 [[result imageView] setImage:celldata]; | |
2598 if([celldata isKindOfClass:[NSString class]]) | |
2599 [[result textField] setStringValue:celldata]; | |
2600 | 2623 |
2601 /* Handle drawing alternating row colors if enabled */ | 2624 /* Handle drawing alternating row colors if enabled */ |
2602 if ((row % 2) == 0) | 2625 if ((row % 2) == 0) |
2603 { | 2626 { |
2604 if(evencolor) | 2627 if(evencolor) |
7722 lastadd = [cont lastAddPoint]; | 7745 lastadd = [cont lastAddPoint]; |
7723 } | 7746 } |
7724 | 7747 |
7725 #ifdef BUILDING_FOR_YOSEMITE | 7748 #ifdef BUILDING_FOR_YOSEMITE |
7726 browsercell = [[[NSTableCellView alloc] init] autorelease]; | 7749 browsercell = [[[NSTableCellView alloc] init] autorelease]; |
7750 [browsercell setImageView:[[[NSImageView alloc] init] autorelease]]; | |
7751 [browsercell addSubview:[browsercell imageView]]; | |
7727 [[browsercell imageView] setImage:icon]; | 7752 [[browsercell imageView] setImage:icon]; |
7728 [[browsercell textField] setStringValue:[ NSString stringWithUTF8String:filename ]]; | 7753 [browsercell setTextField:[[[NSTextField alloc] init] autorelease]]; |
7754 [browsercell addSubview:[browsercell textField]]; | |
7755 [[browsercell textField] setStringValue:[NSString stringWithUTF8String:filename]]; | |
7729 #else | 7756 #else |
7730 browsercell = [[[DWImageAndTextCell alloc] init] autorelease]; | 7757 browsercell = [[[DWImageAndTextCell alloc] init] autorelease]; |
7731 [browsercell setImage:icon]; | 7758 [browsercell setImage:icon]; |
7732 [browsercell setStringValue:[ NSString stringWithUTF8String:filename ]]; | 7759 [browsercell setStringValue:[ NSString stringWithUTF8String:filename ]]; |
7733 #endif | 7760 #endif |