• 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: Raphael Sebbe <email@hidden>
  • Date: Fri, 21 Dec 2001 15:11:20 +0100

For reference,

What I needed was :

1)- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex

in fact its NSOutlineView equivalent:

- (void)outlineView:(NSOutlineView *)outlineView
willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn
item:(id)item

(thanks John)

2) Tell the data cell to draw its background, and set its color
[cell setDrawsBackground: YES];
[cell setBackgroundColor:[NSColor orangeColor]];

(thanks Stiphane)

3) Remove intercell white space (between columns):
[outlineView setIntercellSpacing:NSMakeSize(0, 1)];

Raphael

On Friday, December 21, 2001, at 01:22 PM, John C. Randolph wrote:

> On Friday, December 21, 2001, at 04:03 AM, Raphael Sebbe wrote:
>
>> Hello all,
>>
>> 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 ?). Attributed string is not what I want
>> because it won't cover the entire row (just the text).
>>
>> Also, if that can help, I use a custom NSTableColumn subclass.
>
> To save storage, NSTableView reuses cells to draw multiple items.
>
> 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.
>
> -jcr
>
> [Objc retain];
> _______________________________________________
> 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.


References: 
 >Re: row bg color in NSOutlineView (From: "John C. Randolph" <email@hidden>)

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