scrollers display malfunction in scroll view
scrollers display malfunction in scroll view
- Subject: scrollers display malfunction in scroll view
- From: Dale Miller <email@hidden>
- Date: Fri, 20 Feb 2009 19:44:26 -0700
I have a subview of NSView which is made the document view of an
NSScrollView. The drawRect: method of the view does the following:
CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicsPort];
/* geometry calculations */
ATSUI text line drawing
The geometry calculations are based on the passed-in rect and the
visibleRect of the view. The view is also registered for bounds change
notification where the data for the geometry calculations is modified.
This works with scrolling and frame changes due to autosizing, but...
when I scroll the view or change the frame size, the scrollers on the
enclosing scroll view go gray, or leave pieces of the scroll knobs
lying around when they are moved. I'm not manipulating the context or
as far as I can see doing anything that should impact the scroll view
or its scrollers.
I managed to fix the problem by accidentally doing something which
looks wrong to me, and that's what confuses me. In an attempt to avoid
having to reset the atsui objects with the current context on every
pass through the method, I decided to do the following:
if (ctxt == nil)
ctxt = [[NSGraphicsContext currentContext] graphicsPort];
/* geometry calculations */
ATSUI text line drawing
The drawing worked fine, but the scrollers still went berserk. I
unintentionally changed the code to:
if (ctxt == nil)
{
[NSGraphicsContext saveGraphicsState]
ctxt = [[NSGraphicsContext currentContext] graphicsPort];
}
/* geometry calculations */
ATSUI text line drawing ...
/* NOTE - No restoreGraphicsStater */
Now it worked as desired - no scroller problems. But... There is no
balancing restoreGraphicsState call in the program. I don't understand
why it didn't
work, why it now works, and why the unbalanced "save" call does not
cause a problem.
Dale Miller
email@hidden
_______________________________________________
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