Re: Cutsom NSRulerView : strange problems with drawing
Re: Cutsom NSRulerView : strange problems with drawing
- Subject: Re: Cutsom NSRulerView : strange problems with drawing
- From: Eric MORAND <email@hidden>
- Date: Tue, 22 May 2007 09:58:14 +0200
Hi again,
I just discovere an even stangest behavior. If I only subclass
drawRect this way...
- (void)drawRect:(NSRect)rect
{
NSFrameRect([self bounds]);
}
...it doesn't work as expected : only the area covered by rect is
"framed", and not the entire bounds area.
Le 22 mai 07 à 09:51, Eric MORAND a écrit :
Hi list,
I'm trying to subclass NSRulerView to display custom informations,
and am facing a strange problem when I subclass the draw... methods.
Here is my implementation of draw... methods :
- (void)drawBackgroundInRect:(NSRect)rect
{
NSLog (@"drawBackgroundInRect");
NSRect backgroundRect = NSZeroRect;
NSRect bottomBorderRect = NSZeroRect;
NSDivideRect([self bounds], &bottomBorderRect, &backgroundRect,
1.0, NSMaxYEdge);
// Fond
[[NSColor colorWithDeviceRed:194.0/255.0 green:194.0/255.0 blue:
194.0/255.0 alpha:1.0] set];
[NSBezierPath fillRect:backgroundRect];
// Bordure inferieure
[[NSColor colorWithDeviceRed:119.0/255.0 green:119.0/255.0 blue:
119.0/255.0 alpha:1.0] set];
[NSBezierPath fillRect:bottomBorderRect];
}
- (void)drawHashMarksAndLabelsInRect:(NSRect)rect
{
NSLog (@"drawHashMarksAndLabelsInRect");
// Test : only display a mark at bounds origin, just to see what
happens
NSBezierPath * aPath = [NSBezierPath bezierPathWithRect:NSMakeRect
(NSMinX([self bounds]), 0.0, 1.0, 10.0)];
[[NSColor colorWithDeviceRed:119.0/255.0 green:119.0/255.0 blue:
119.0/255.0 alpha:1.0] set];
[aPath fill];
}
Every time I scroll the associated scroll view, the
drawBackgroundInRect method is called, correctly filling the
background, and then the drawHashMarksAndLabelsInRect method is
called.
The problem is that the hash mark supposed to draw at bounds origin
is not drawn when I scroll to the right...and is drawn multiple
times when I scroll to the left ! Even so the entire bounds area
has already been filled by drawBackgroundInRect.
Can someone help me on this ?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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