• 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
Problems with displaying NSProgressIndicator in custom cell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems with displaying NSProgressIndicator in custom cell


  • Subject: Problems with displaying NSProgressIndicator in custom cell
  • From: Nikita Zhuk <email@hidden>
  • Date: Thu, 13 Mar 2003 14:41:44 +0200

Hi,

I'm having some problems with cell subclass, which should display
indeterminate NSProgressIndicator inside the NSTableView's cell.
Because these cells with progress indicators are displayed only on
some rows (not all), I have decided to make a following solution:

TableView uses my own NSTableColumn subclass as one of its column
(let's call it "MultiDataTableColumn"). It keeps a list of rows which
should display a cell with progress indicator. The problem is: custom
cell is drawn (bordered, as it should), but progress indicator is not
displayed. Below is code which should describe my implementation:

@interface MultiDataTableColumn : NSTableColumn
{
// a list of rows which will be displayed with progressindicators
NSMutableSet *progressRows;
}

- (id)init;
- (id)dataCellForRow:(int)row;
- (void)addProgressIndex:(int)row; // simply adds new row index to the list.
@end

Now, dataCellForRow checks if the row is in that list, and returns
the special cell (with progressindicator). If not, the normal cell is
returned (from message to superclass)

- (id)dataCellForRow:(int)row
{
if (!progressRows) // for the first run
progressRows = [[NSMutableSet setWithCapacity:5] retain];

if (([progressRows count] > 0) && ([progressRows
containsObject:[NSNumber numberWithInt:row]]))
return [[[ProgressIndicatorCell alloc]init] autorelease];
return [super dataCellForRow: row];
}


Things should be done right this far. The problem is probably at
ProgressIndicatorCell class, which is subclass of NSTextFieldCell:

@interface ProgressIndicatorCell : NSTextFieldCell
{
NSProgressIndicator *_offScreenProgressBar; // created at init time
}
- (id)init;
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
- (NSSize)cellSize;


The init method simply inits progressbar:

- (id)init
{
[super init];
_offScreenProgressBar = [[NSProgressIndicator alloc]init];
[_offScreenProgressBar setIndeterminate: YES];
[_offScreenProgressBar setDoubleValue: 100];
[self setBordered:YES];
return self;
}

So problem must be in drawWithFrame:

- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
if (_offScreenProgressBar != nil)
{
[_offScreenProgressBar setFrame:cellFrame];
[_offScreenProgressBar display];
}
[super drawWithFrame:cellFrame inView:controlView];
}

So what code should I add to make _offScreenProgressBar appear in my
custom cell? Any help would be greatly
appreciated.


--

******************************
* Nikita Zhuk
* MacZ Software & Frozdesign
* WWW:
* http://www.maczsoftware.com
* http://www.frozdesign.com
* E-mail: email@hidden
******************************
_______________________________________________
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.

  • Prev by Date: Asynchronously writing to a file?
  • Next by Date: NSScrollView bug(s)?
  • Previous by thread: Re: Asynchronously writing to a file?
  • Next by thread: NSScrollView bug(s)?
  • Index(es):
    • Date
    • Thread