• 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: NSTableView - Alternating blue and white background
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView - Alternating blue and white background


  • Subject: Re: NSTableView - Alternating blue and white background
  • From: "Erik J. Barzeski" <email@hidden>
  • Date: Tue, 17 Dec 2002 14:51:01 -0500

I posted my source. Feel free to compare. I assume at this poitn that the
error most likely lies with myself. I've set the intercell spacing to 0 in
an init method, and changed the size of the font, but outside of that, I
don't know what could be different.

On 12/17/02 2:31pm, "Joe Lester" <email@hidden> wrote:
> Interesting. I use the same basic method that Dan Wood described in his
> November MacTech article in my NSTableView subclass. I've provided up to 8000
> rows to my NSTableView subclass with no visible row color misalignment. Maybe
> I'm doing something different?
>
> Here's my source. It's drifted some from the example in Dan Wood's article but
> my impression is that it should not really be that different. If there are
> rounding errors, I'd like to eliminate them, if possible:
>
> - (void)highlightSelectionInClipRect:(NSRect)clipRect
> /*"
> Overridden to draw the proper background color on the rows.
> Sends tableView:stripeColorForRow: to the data source to get
> the color for each visible row. If the data source does not
> respond, it stripes odd rows.
> "*/
> {
> //Get dims from self
> float rowHeight = [self rowHeight] + [self intercellSpacing].height;
> NSRect visibleRect = [self visibleRect];
>
> //Calculate the rect we should highlight
> NSRect highlightRect;
> highlightRect.origin = NSMakePoint(NSMinX(visibleRect),
> (int)(NSMinY(clipRect)/ rowHeight) * rowHeight);
> highlightRect.size = NSMakeSize(NSWidth(visibleRect), rowHeight );
>
> //Do the drawing
> while (NSMinY(highlightRect) < NSMaxY(clipRect))
> {
> NSColor *rowColor;
> NSRect clipedHighlightRect = NSIntersectionRect(highlightRect,
> clipRect);
> int row = (int)((NSMinY(highlightRect) + rowHeight / 2.0) / rowHeight);
>
> if ([self dataSource] &&
> [[self dataSource]
> respondsToSelector:@selector(tableView:stripeColorForRow:)])
> {
> NSColor *colorFromDataSource = [[self dataSource] tableView:self
> stripeColorForRow:row];
> rowColor = (colorFromDataSource) ? colorFromDataSource : [NSColor
> whiteColor];
> }
> else
> {
> rowColor = (0 == row % 2) ? [NSColor colorWithCalibratedRed:0.929
> green:0.953 blue:0.996 alpha:1.0] : [NSColor whiteColor];
> }
>
> [rowColor set];
> NSRectFill(clipedHighlightRect);
> highlightRect.origin.y += rowHeight;
> }
>
> [super highlightSelectionInClipRect:clipRect];
> }


--
Kindest regards,
Erik J. Barzeski

You know you're a geek when your friends are dating women whose
Web pages say this: The purpose of this page is to provide students
with a closer look at the implementation of a pipelined processor.
###################################################################
Email: erik@(anything below) AIM: iacas

http://iacas.org http://weims.net
http://techstra.net http://barzeski.com
http://cocoadevcentral.com http://soundsetcentral.com
http://freshlysqueezedsoftware.com http://applescriptcentral.com
###################################################################
_______________________________________________
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: Subject: Re: "First Run" installation of Application support stuff?
  • Next by Date: Re: NSTableView - Alternating blue and white background
  • Previous by thread: Re: NSTableView - Alternating blue and white background
  • Next by thread: Re: NSTableView - Alternating blue and white background
  • Index(es):
    • Date
    • Thread