• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
scrollers display malfunction in scroll view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Window Animation with setFrame:display:animate: Flickers
  • Next by Date: Re: Question on threads running in my Foundation tool
  • Previous by thread: Re: Window Animation with setFrame:display:animate: Flickers [solved]
  • Next by thread: Printing a list of items
  • Index(es):
    • Date
    • Thread