bug with NSCopyBits ?
bug with NSCopyBits ?
- Subject: bug with NSCopyBits ?
- From: Christopher Lloyd <email@hidden>
- Date: Fri, 02 Nov 2001 04:09:07 -0500
Sorry if this is a repeat, but I am having a problem with NSCopyBits in
conjunction with a view allocated gState. If I allocate a gState for the
view and use NSCopyBits, the bits are copied from coordinates in the view's
window's gState, not the view's gState as would be expected. The
destination point is in the view's coordinates which is expected. The
following view subclass illustrates the unexpected behaviour, center the
view in a window with a lot of space around the view.
This is on 10.1, I recently upgraded and *believe* this worked as expected
on 10.0.x. The workaround is to use the view's window's gState and do the
coordinate translation.
Is this a bug or am I misinterpreting something?
Thanks,
Chris
@implementation MyView
-initWithFrame:(NSRect)frame {
[super initWithFrame:frame];
[self allocateGState];
return self;
}
-(void)drawRect:(NSRect)rect {
NSRect bounds=[self bounds];
NSRect fill=bounds;
NSPoint point=NSMakePoint(0,10);
fill.size.width/=2;
[[NSColor blackColor] set];
NSRectFill(fill);
fill.origin.x+=fill.size.width;
[[NSColor whiteColor] set];
NSRectFill(fill);
// This has the desired result with the view's gState...
NSCopyBits([self gState],[self convertRect:bounds toView:nil],point);
// ...but this is what used to work and what one would expect
NSCopyBits([self gState],bounds,point);
}
@end