• 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
Re: need advice on subclassing NSScrollVIew
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: need advice on subclassing NSScrollVIew


  • Subject: Re: need advice on subclassing NSScrollVIew
  • From: Graham Cox <email@hidden>
  • Date: Fri, 20 Mar 2009 17:04:47 +1100


On 20/03/2009, at 7:39 AM, John Reppy wrote:

I'm building a viewer for event logs that needs to support a wide range
of scales (say from seconds/inch to nanoseconds/inch). I've got a custom
subclass of NSView for displaying this information, which I want to embed
in an NSScrollView. The problem that I'm faced with is that the floating-point
coordinates used by Cocoa do not have enough precision at full magnification.


I'm guessing that the best solution is to subclass NSScrollView to track the
visible rectangle's origin using doubles, but I'm not sure which NSScrollView
methods I should be overriding. Also, do I need to override NSClipView too?
Any pointers or suggestions would be appreciated.


Double's are not going to help.

The drawing coordinates are floats. Even if you could persuade NSScrollView to position your view to double precision, it will get truncated to single precision for display. You'd have to rewrite all of Quartz at 64 bit precision to see any benefit.

However, all is not lost.

A float easily exceeds a 10^9 range, so you merely need to scale everything upwards. e.g. define 1nS to be, say, 10 points, then draw everything else on that basis. You can then scale the whole view to show the timeline scale you need. Scaling the view itself is trivial, see -scaleUnitSquareToSize:

-Graham


_______________________________________________

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


  • Follow-Ups:
    • Re: need advice on subclassing NSScrollVIew
      • From: John Reppy <email@hidden>
References: 
 >need advice on subclassing NSScrollVIew (From: John Reppy <email@hidden>)

  • Prev by Date: Re: NSTableView updating checkboxes
  • Next by Date: NSScrollView like iTunes
  • Previous by thread: need advice on subclassing NSScrollVIew
  • Next by thread: Re: need advice on subclassing NSScrollVIew
  • Index(es):
    • Date
    • Thread