Re: drawing border of NSPopUpButtonCell drawInteriorWithFrame:inView:
Re: drawing border of NSPopUpButtonCell drawInteriorWithFrame:inView:
- Subject: Re: drawing border of NSPopUpButtonCell drawInteriorWithFrame:inView:
- From: Shane <email@hidden>
- Date: Sat, 29 May 2010 00:20:19 -0500
>> [path moveToPoint:NSMakePoint(cellFrame.origin.x, cellFrame.size.height)];
>> [path lineToPoint:NSMakePoint(cellFrame.size.width, cellFrame.size.height)];
>
>
> If cellFrame = {500, 300, 120, 20}
>
> You're drawing from {500, 20} to {120, 20}
>
I have four NSView cell's (so I have four data table header cells,
i.e. 4 columns), and here's the cellFrame values as output by the
NSLog statement above.
x:249 y:0 width:367 height:17
x:146 y:0 width:103 height:17
x:43 y:0 width:103 height:17
x:0 y:0 width:43 height:17
This seems correct. My first cell is trying to draw from x=0 with a width of 43.
My second cell is trying to draw from x=43 with a width of 103.
Third cell is drawing from x=146 with width of 103.
And fourth cell is drawing from x=249 with width of 367.
Yet, it's like each border is overwriting itself starting from 0 (the
leftmost cell).
- (void) drawInteriorWithFrame:(NSRect) cellFrame inView:(NSView *) controlView
{
NSLog(@"x:%g y:%g width:%g height:%g", cellFrame.origin.x,
cellFrame.origin.y, cellFrame.size.width, cellFrame.size.height);
[[NSColor whiteColor] set];
[[NSBezierPath bezierPathWithRect:cellFrame] fill];
NSBezierPath *path = [NSBezierPath bezierPath];
[path moveToPoint:NSMakePoint(cellFrame.origin.x, cellFrame.size.height)];
[path lineToPoint:NSMakePoint(cellFrame.size.width, cellFrame.size.height)];
[[NSColor darkGrayColor] setStroke];
[path stroke];
[super drawInteriorWithFrame:cellFrame inView:controlView];
return;
}
The image attachment on the previous email shows that the line from
the first cell is actually length 103 and it should only be length 43
to cover just that first cell, so I believe somehow it is overwriting
and starting from 0, though the x origin shows otherwise.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden