Re: NSRulerView flexibility
Re: NSRulerView flexibility
- Subject: Re: NSRulerView flexibility
- From: David Harper <email@hidden>
- Date: Thu, 25 Oct 2007 13:05:54 -0400 (EDT)
Hello again,
Thanks a lot for the suggestion, it really got us started on implementing ruler views the way we envision them.
It's very interesting (although poorly documented) how NSRulerView's drawRect method copies and shifts* the contents up or down implicitly such that the rectangle passed into drawRect is only the small rectangle at the bottom or top that needs "filling." By dynamically adjusting the origin of the ruler views, we were able to eliminate the strange artifact drawing that occurs when attempting to redraw the whole ruler.
Now our problem is the lack of communication between the NSScrollView and its rulerViews. Due to the fact that we have found autoscroll's default behavior insufficient, we implemented an overridden autoscroll method that actually scrolls the clipview while the mouse is still inside the clipview, depending on the distance to the edge of the view. We do this by creating an NSTimer with an arbitrary interval and updating a class variable representing scroll speed depending on the mouse drag's location.
with the following 3 lines of code...
NSScrollView *s = [self enclosingScrollView];
[[s contentView] scrollToPoint:o2];
[s reflectScrolledClipView:[s contentView]];
... we were able to get the scroll bars to correspond to the result of the autoscroll. However, the RULERS are not updated when autoscrolling occurs. The scrollview knows about the rulerviews, and the rulerviews' clientview are set to the scrollview's clipview.
I would expect that the scrollview, since it contains the rulerviews, would take care of updating the rulerviews' positions in reflectScrolledClipView by appropriately scrolling and updating the rulerview. This is not the case.
I've tried calling setNeedsDisplayInRect:r where r is the rectangle containing bottom or top dy pixels of the view where dy is the amount scrolled, but this doesn't work either, because it seems that drawRect is invoked only after the shifting (see * above) has already occured.
Any ideas Steve?
I really appreciate the help so far. Thanks again,
-Dave H.
Steve Shepard <email@hidden> wrote: It is possible to do what you are asking (see the rulers in Storyist),
but there is some work involved. The class to subclass is NSRulerView
and you'll do most of your custom drawing in
drawHashMarksAndLabelsInRect:
I had to override some private methods to get this to draw without
artifacts when scrolled.
-Steve
www.storyist.com
_______________________________________________
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