• 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
Re: NSProgressIndicator and other controls in a cell in an NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSProgressIndicator and other controls in a cell in an NSTableView


  • Subject: Re: NSProgressIndicator and other controls in a cell in an NSTableView
  • From: Brian Webster <email@hidden>
  • Date: Tue, 7 Aug 2001 13:55:04 -0500

On Tuesday, August 7, 2001, at 11:23 AM, cocoa-dev-
email@hidden wrote:

on 01-08-07 17.50, l.m.orchard at email@hidden wrote:

Anyway, the next question I have it... okay I can display 0-100% in the
table view in text, but can I somehow stick an NSProgressIndicator in
there instead? And maybe even have a small "Cancel" button in the next
column? Or is this just not a good idea at all?

Since NSProgressIndicator is a View and not a control, it doesn't have a
cell counterpart. If it had, you could use that to send to NSTableColumn's
setDataCell: and everything would be great (chances are you would then have
had to change only a very few lines from your string approach, and it would
work.)

Now, that isn't the case. You will have to make a NSCell subclass and make
that draw a progress view according to its own value.

One semi-cheap hack that I've done before is to create an NSCell subclass that draws itself by inserting an NSView as a subview of the enclosing control. The code goes a little something like this:

@interface ViewCell : NSCell
{
NSView *myView;
}

-(id)initWithView:(NSView*)view;

@end

@implementation ViewCell

-(void)drawInteriorWithFrame:(NSRect)frame inView:(NSView*)controlView
{
[controlView addSubview:myView];
[myVIew setFrame:frame];
}

@end

When I did this, I was working with an NSMatrix and not table view, so there may be issues with scrolling, inserting the view more than once, keeping the view in the right place, etc.

Another way I could think of doing it would be to keep a progress indicator off-screen somewhere, and then pull the bar out as an image, perhaps creating an NSBitmapImageRep with -initWithFocusedViewRect: and then just use an NSImageCell to display the created image. This approach might have performance problems, though, but I thought I'd throw it out as a possibility. It might end up being easiest just to draw your own progress indicator in your own NSCell subclass.

--
Brian Webster
email@hidden
http://www.owlnet.rice.edu/~bwebster


  • Prev by Date: Re: Retained items and autorelease pool
  • Next by Date: Re: question about forward declarations
  • Previous by thread: Re: Retained items and autorelease pool
  • Next by thread: Re: question about forward declarations
  • Index(es):
    • Date
    • Thread