• 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: row bg color in NSOutlineView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: row bg color in NSOutlineView


  • Subject: Re: row bg color in NSOutlineView
  • From: "John C. Randolph" <email@hidden>
  • Date: Sat, 22 Dec 2001 02:36:48 -0800

On Friday, December 21, 2001, at 10:29 PM, jgo wrote:

>> jcr wrote:
>>> On Friday, 2001 December 21 at 04:03, Raphael Sebbe wrote:
>>> What is the best way of setting the background color in an
>>> outline view, per row, based on item kind? I tried some custom
>>> data cells (NSTextFieldCell) but its background color is
>>> ignored (or changed to white just before drawing?)...
>>>
>>> Also, if that can help, I use a custom NSTableColumn subclass.
>>
>> To save storage, NSTableView reuses cells to draw multiple items.
>
> Are they that massive? I thought that part of the idea of cells
> is that they're lighter than views.

Well,

(gdb) p (int) sizeof(NSTextFieldCell)
$1 = 48
(gdb) p (int) sizeof(NSView)
$2 = 80

Cells are generally smaller storage-wise than views, but you
might have hundreds of items in a table view, and it's just not
necessary to have a cell for each of them. (especially
considering that only subset of those items is likely to be
visible at any given time.)

>> The docs say:
>>
>> - (void)tableView:(NSTableView *)aTableView
>> willDisplayCell:(id)aCell forTableColumn:(NSTableColumn
>> *)aTableColumn row:(int)rowIndex
>>
>> Informs the delegate that aTableView will display the cell at
>> rowIndex in aTableColumn using aCell. The delegate can modify
>> the display attributes of aCell to alter the appearance of the
>> cell. Because aCell is reused for every row in aTableColumn, the
>> delegate must set the display attributes both when drawing
>> special cells and when drawing normal cells.
>
> I don't quite get this. If one can set the cell for a specific
> point in the table (column & row), then it must not be getting
> re-used everywhere.

It's not like NSMatrix: You can't set the cell for a given row
and column. You can get notified before a cell is used to
draw an item, and based on what item is being drawn, you can
alter the cell's display characteristics.

-jcr

I almost had a psychic girlfriend, but she left me before we
met. -- Steven Wright


References: 
 >Re: row bg color in NSOutlineView (From: jgo <email@hidden>)

  • Prev by Date: Re: row bg color in NSOutlineView
  • Next by Date: Re: row bg color in NSOutlineView
  • Previous by thread: Re: row bg color in NSOutlineView
  • Next by thread: Re: row bg color in NSOutlineView
  • Index(es):
    • Date
    • Thread