NSView : Background bitmap drawing issue
NSView : Background bitmap drawing issue
- Subject: NSView : Background bitmap drawing issue
- From: Alexander Bokovikov <email@hidden>
- Date: Mon, 15 Feb 2010 14:26:01 +0500
I've written a subclass of NSView, which draws a NSImage, as the
background. All is working, but the only problem is in different
behavior on different Macs / OS versions. Here is the drawing code:
@interface BGSkinView : NSView {
NSImage *bg;
BOOL isLeo, isSnowLeo;
}
......................
- (void)drawRect:(NSRect)rect {
NSGraphicsContext *ctx;
CGFloat y;
ctx = [NSGraphicsContext currentContext];
[ctx saveGraphicsState];
y = [self bounds].size.height;
///////////////////////////////////////////////////////////////////////////////////////
if (!isLeo)
y++;
///////////////////////////////////////////////////////////////////////////////////////
[ctx setPatternPhase:NSMakePoint(0, y)];
//
[[NSColor colorWithPatternImage:bg] set];
NSRectFill([self bounds]);
//
[ctx restoreGraphicsState];
}
isLeo is true on 10.5 and isSnowLeo is true on 10.6
I tested this code on my Mac with both 10.4, 10.5 and 10.6 and have
got a shift of the image for one pixel down on 10.4 and 10.6.
Therefore I've added the condition, selected above. But now I've got a
report from another 10.6 Mac, where my code shifts the background for
one pixel up. Thus, my patch with y++ should be disabled there.
As far as I understand, this effect is caused not by OS version, but
by some graphic subsystem feature. Could anybody tell me, what is this
one-pixel shift? Maybe it's some border, drawn outside of my view,
which I don't see?
Any help would be appreciated.
Thanks.
_______________________________________________
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