On 2012-05-04, at 10:58 PM, Ken Thomases wrote:
> On May 4, 2012, at 8:19 PM, Peter Teeson wrote:
> 
>> - (void)drawRect:(NSRect)dirtyRect
>> {
>>   // Drawing code here. 
>>   NSRect bounds = [self bounds];
>>   NSBezierPath *path = [NSBezierPath bezierPathWithRect:bounds];
>>   [path stroke];
>> }
>> 
>> In the specific case of the Cinema Display having a resolution setting of 
>> 1280 x 800
>> the rectangle is not fully drawn every time. The top and right edges are 
>> missing.
> 
> Well, I don't think you're drawing what you think you are.  The bounds rect 
> is outside of the view.  It's the exterior boundary of the view.  

> Now, when you stroke it, assuming you haven't changed the default line width 
> of NSBezierPath,

> the stroke will be 1 point wide, half a point inside the view and half 
> outside.  
> This may involve anti-aliasing or, under HiDPI, perhaps a one-pixel wide line 
> since that's half a point.
> It's probably up to the graphics driver to decide precisely how to render 
> that half-point-wide line.
> 
> Generally, if you actually want to draw just within the view's bounds, you 
> would inset the rectangle by half the line width.
> 
> Regards,
> Ken
Thanks so much Ken for that help. I am using NSInsetRect later on in my actual 
code for something else
But I did not realize that the bounds stroke was straddling the view content 
edges.
How did you learn that? 

Also I find it strange that it just happened to work at all other resolutions 
under both HiDPI and standard.
So this may be an edge case (pun intended) in the driver in mapping to the 
actual hardware.
I followed your suggestion and inset bounds by 0.5 and it works fine.

Your contribution to my education made my day. Thanks a 1E6.

Peter



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to