• 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: Sizing an image for a tableview cell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sizing an image for a tableview cell


  • Subject: Re: Sizing an image for a tableview cell
  • From: Tito Ciuro <email@hidden>
  • Date: Sun, 25 Jul 2004 21:29:05 -0400

Thanks Chuck!

-- Tito

On 25 jul 2004, at 13:07, Chuck Soper wrote:

> Tito,
> You could use the following NSTableView delegate to draw a background
> color:
>
> - (void)tableView: (NSTableView *)tableView willDisplayCell: (id)cell
> forTableColumn: (NSTableColumn *)tableColumn row: (int)rowIndex
> {
> if (1) { // your test condition here
> [cell setDrawsBackground: YES];
> [cell setBackgroundColor: [NSColor purpleColor]]; // your color
> here
> } else {
> [cell setDrawsBackground: NO];
> [cell setBackgroundColor: [NSColor whiteColor]];
> }
> }
>
> Or, if you have NSCell subclasses then you may need to subclass your
> NSTableView and override the method below. If you take this approach
> then you won't need to use the delegate method above.
>
> - (void)drawRow:(int)rowIndex clipRect:(NSRect)clipRect
> {
> if (![self isRowSelected:rowIndex]) {
> NSRect cellRect = [self rectOfRow:rowIndex];
>
> if (1) { // your test condition here
> [[NSColor purpleColor] set]; // your color here
> NSRectFill(NSIntersectionRect(cellRect,clipRect));
> } else {
> [[NSColor whiteColor] set];
> NSRectFill(NSIntersectionRect(cellRect,clipRect));
> }
> }
>
> //draw row content
> [super drawRow:rowIndex clipRect:clipRect];
> }
>
> Chuck
>
> At 11:31 AM -0400 7/25/04, Tito Ciuro wrote:
>> Hello,
>>
>> I need to set the color of a cell which covers the entire cell bounds.
>> Each row has a different color, so in tableView:
>> objectValueForTableColumn: row:, I thought of getting the bounds of a
>> cell at a given index, create an NSImage with the desired color, and
>> return the image. The problem is that I cannot seem to obtain the size
>> of the cell, therefore I cannot create the image.
>>
>> Any ideas?
>>
>> Thanks!
>>
>> -- Tito
> _______________________________________________
> 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.

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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: 
 >Sizing an image for a tableview cell (From: Tito Ciuro <email@hidden>)
 >Re: Sizing an image for a tableview cell (From: Chuck Soper <email@hidden>)

  • Prev by Date: Re: NSMutableArray, TableView, Bindings and Sorting
  • Next by Date: Apple Pro Apps Windows
  • Previous by thread: Re: Sizing an image for a tableview cell
  • Next by thread: Array index out of bounds...
  • Index(es):
    • Date
    • Thread