NSView scaling
NSView scaling
- Subject: NSView scaling
- From: Loukas Kalenderidis <email@hidden>
- Date: Wed, 29 Aug 2007 09:54:17 +1000
Hi guys,
I have a custom NSView subclass that draws a representation of an
HPGL document (points, lines, polygons). The graph needs to be scaled
to fit within a frame as more points are added, but I don't want the
line weight to change as it is scaled.
I first implemented this by calculating the necessary scale factor,
using an NSAffineTransformation to scale the NSBezierCurve for each
shape, then calling NSBezierCurve's stroke method to draw it. This
was working fine until I decided to add some rulers to the view by
enclosing it in an NSScrollView with rulers attached - the
documentView's coordinates system determines the scale of the rulers.
I changed the implementation to use the view's scaleUnitSquareToSize
method to scale the view. The rulers scale correctly, but obviously
the line weight changes as the whole view is scaled after drawing
rather than just the coordinates of the points being scaled and
_then_ drawn with a set line weight.
My question has a few parts:
1) Can I scale the view without changing the line weight of stuff
drawn inside the view?
2) What do I need to overload in my NSView subclass to return a
different scale to the NSRulerView?
3) Which of these methods would be better?
I'm sure this stuff is documented _somewhere_ but I couldn't find
anything relevant.
Thanks hackers,
Loukas
_______________________________________________
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