From 61486546048e73e118e0155883f2304767eeb956 Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Thu, 4 Nov 2010 23:01:28 -0400 Subject: [PATCH] Added convertTo/FromBase methods for completeness (and convenience). --- AppKit/CPView.j | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 3ad7649b2..bee9f420f 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -1566,6 +1566,16 @@ var CPViewFlags = { }, return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(aView, self)); } +/*! + Converts the point from the base coordinate system to the receiver’s coordinate system. + @param aPoint A point specifying a location in the base coordinate system + @return The point converted to the receiver’s base coordinate system +*/ +- (CGPoint)convertPointFromBase:(CGPoint)aPoint +{ + return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(nil, self)); +} + /*! Converts \c aPoint from the receiver's coordinate space to the coordinate space of \c aView. @param aPoint the point to convert @@ -1577,6 +1587,16 @@ var CPViewFlags = { }, return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(self, aView)); } +/*! + Converts the point from the receiver’s coordinate system to the base coordinate system. + @param aPoint A point specifying a location in the coordinate system of the receiver + @return The point converted to the base coordinate system +*/ +- (CGPoint)convertPointToBase:(CGPoint)aPoint +{ + return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(self, nil)); +} + /*! Convert's \c aSize from \c aView's coordinate space to the receiver's coordinate space. @param aSize the size to convert @@ -1610,6 +1630,16 @@ var CPViewFlags = { }, return CGRectApplyAffineTransform(aRect, _CPViewGetTransform(aView, self)); } +/*! + Converts the rectangle from the base coordinate system to the receiver’s coordinate system. + @param aRect A rectangle specifying a location in the base coordinate system + @return The rectangle converted to the receiver’s base coordinate system +*/ +- (CGRect)convertRectFromBase:(CGRect)aRect +{ + return CGRectApplyAffineTransform(aRect, _CPViewGetTransform(nil, self)); +} + /*! Converts \c aRect from the receiver's coordinate space to \c aView's coordinate space. @param aRect the rectangle to convert @@ -1621,6 +1651,16 @@ var CPViewFlags = { }, return CGRectApplyAffineTransform(aRect, _CPViewGetTransform(self, aView)); } +/*! + Converts the rectangle from the receiver’s coordinate system to the base coordinate system. + @param aRect A rectangle specifying a location in the coordinate system of the receiver + @return The rectangle converted to the base coordinate system +*/ +- (CGRect)convertRectToBase:(CGRect)aRect +{ + return CGRectApplyAffineTransform(aRect, _CPViewGetTransform(self, nil)); +} + /*! Sets whether the receiver posts a CPViewFrameDidChangeNotification notification to the default notification center when its frame is changed. The default is \c NO.