Re: Getting NSProgressIndicators in an NSTableView
Re: Getting NSProgressIndicators in an NSTableView
- Subject: Re: Getting NSProgressIndicators in an NSTableView
- From: Simone Manganelli <email@hidden>
- Date: Mon, 18 Nov 2002 13:09:18 -0800
OK, here's the thing. I tried doing this, but all I'm getting is a
blank image in the column.
Here's the code that creates the NSImage of a progress indicator:
- (void)setProgBarImage:(NSNumber *)memUsage withMaxValue:(NSNumber
*)theMaxValue
{
NSProgressIndicator *theProgressIndicator;
[theProgBarImage release];
theProgBarImage = [[NSImage alloc] initWithSize:NSMakeSize(60,12)];
[theProgBarImage lockFocus];
theProgressIndicator = [[NSProgressIndicator alloc] init];
[theProgressIndicator setFrame:NSMakeRect(0,0,60,12)];
[theProgressIndicator setMaxValue:[theMaxValue doubleValue]];
[theProgressIndicator setDoubleValue:[memUsage doubleValue]];
[theProgressIndicator stopAnimation:nil];
[theProgressIndicator drawRect:NSMakeRect(0,0,60,12)];
[theProgBarImage unlockFocus];
[theProgressIndicator release];
}
Here's the code that is run on startup in an awakeFromNib method, since
I see no way of setting a column to have image cells via Interface
Builder in the nib:
theTableColumn = [tableViewTotal
tableColumnWithIdentifier:@"theProgBarImage"];
theDataCell = [[NSImageCell alloc] init];
[theTableColumn setDataCell:theDataCell];
[theDataCell release];
When the NSTableView wants the images for the columns, it just calls
the method "theProgBarImage", since that is the columns identifier.
But I don't get anything in the columns. So what am I doing wrong?
-- Simone Manganelli
On Monday, Nov 18, 2002, at 09:38 US/Pacific, matt neuburg wrote:
On Sat, 16 Nov 2002 19:07:05 -0800, Simone Manganelli <email@hidden>
said:
I've got a problem. I want to get some progress indicators in an
NSTableView, with a column dedicated to just progress indicators with
different data.
I understand that this is possible by using image cells, but I'm not
sure where to start. I was told that I could make an array of
NSImages
that I could then feed through the dataSource of the NSTableView so
that it is displayed.
Is there a way to produce an NSProgressIndicator as an image that I
could then fit into an array of images? If so, what's the easiest way
to do this. If not, what other method can I use? Will I have to draw
an image myself?
That's what I ended up doing. This is a very easy approach because if
a column's datacell is an imagecell, then the value you return as
objectValueForTableColumn simply is the image. If you search the
archives you'll find several other solutions, mostly involving
overriding the way the cell draws itself, but this felt rather
over-elaborate to me so I didn't bother to try it. m.
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.