• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Image and Text Cell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Image and Text Cell


  • Subject: Image and Text Cell
  • From: Henry Maddocks <email@hidden>
  • Date: Tue, 9 Nov 2004 11:44:29 +1300

I've been struggling with this for days and I have to admit defeat:(

I'm trying to create an outline view that shows a file icon and file name in each cell. I started by following some sample code from cocoadev which used an NSBrowserCell but couldn't get it to work so I borrowed some code from the Apple Drag and Drop example and that behaved exactly the same. All I get is the file name text as set in objectValueForTableColumn. One thing I have noticed though is that when breaking in willDisplayOutlineCell the isa of cell is NSButtonCell and not ImageAndTextCell though the _dataCell of tableColumn is ImageAndTextCell. There must be something fundamental I'm doing wrong.

Can anyone offer any advice?

TIA

Henry

Code follows.

- (void) awakeFromNib
{
NSTableColumn* tableColumn = [FileSystemView tableColumnWithIdentifier:@"repository"];
ImageAndTextCell* imageAndTextCell = [[[ImageAndTextCell alloc] init] autorelease];
// [browserCell setLeaf: YES];
[tableColumn setDataCell:imageAndTextCell];
}


- (id) outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
NSString* path;

nil == item)
{
path = [NSString stringWithFormat:@"%@ (%u)",[folderList getFolderName], [folderList subFileCount]];
}
else
{
path = [NSString stringWithFormat:@"%@ (%u)",[item getFolderName], [item subFileCount]];
}


return path;
}

- (void) outlineView:(NSOutlineView *)outlineView willDisplayOutlineCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
if ([[tableColumn identifier] isEqualToString:@"repository"])
{
NSImage* theIcon = [[[NSWorkspace sharedWorkspace] iconForFile:[item getFolderPath]] retain];

nil == theIcon)
{
theIcon = [[NSWorkspace sharedWorkspace] iconForFileType:[[item getFolderPath] pathExtension]];
}

[theIcon setSize:NSMakeSize(16.0, 16.0)];
[cell setImage:theIcon];
}
}

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Image and Text Cell
      • From: Glenn Andreas <email@hidden>
  • Prev by Date: Custom cell working with cocoa bindings in tableview?
  • Next by Date: Re: New Spotlight Info
  • Previous by thread: Custom cell working with cocoa bindings in tableview?
  • Next by thread: Re: Image and Text Cell
  • Index(es):
    • Date
    • Thread