Skip navigation.
 
mlMore on getting NSProgressIndicators in an NSTableView
FROM : Simone Manganelli
DATE : Mon Nov 18 18:55:01 2002

I've made a little progress on getting NSProgressIndicators to display
in an NSTableView (through an NSImage), but I'm still having trouble.

Here's the code I've implemented so far:

- (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];
}

This gets called to set the state of the NSProgressIndicator and then,
theoretically, to draw it to an NSImage and store that image in this
class.

At startup, the column gets initialized with an NSImageCell through the
awakeFromNib method like so:

    theTableColumn = [tableViewTotal
tableColumnWithIdentifier:@"theProgBarImage"];
    theDataCell = [[NSImageCell alloc] init];
    [theTableColumn setDataCell:theDataCell];
    [theDataCell release];

The problem is, all that displays in the column is a blank image.  I'm
thinking it's a problem with the first code snippit, since I added an
NSLog item into the method that sends the NSImage to the NSTableView
dataSource, and the method DOES get called.

Any ideas?  I would like to get this fixed ASAP, if anyone has any
ideas.

Also, any more help with the NSScanner difference on Mac OS X 10.1.x
and 10.2.x would be much appreciated.

-- Simone Manganelli


Related mailsAuthorDate
No related mails found.