aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMGeometryUtils.h
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-06-04 15:35:57 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-06-04 15:35:57 +0000
commit6c2f14bc180418cfad42582be6ef1cc6a5413368 (patch)
tree3b2b46d62d4889ba0e57f0fcbbc27e400ab5a22a /Foundation/GTMGeometryUtils.h
parent8ceff783b1fd62b67c7a6301228af9f7266e183b (diff)
[Author: dmaclach]
Turns on the undeclared-selector warning. This may cause builds to fail if they are using our configs. Also cleaned up some whitespace issues. R=thomasvl DELTA=94 (71 added, 22 deleted, 1 changed)
Diffstat (limited to 'Foundation/GTMGeometryUtils.h')
-rw-r--r--Foundation/GTMGeometryUtils.h93
1 files changed, 47 insertions, 46 deletions
diff --git a/Foundation/GTMGeometryUtils.h b/Foundation/GTMGeometryUtils.h
index 5c14303..867977d 100644
--- a/Foundation/GTMGeometryUtils.h
+++ b/Foundation/GTMGeometryUtils.h
@@ -9,9 +9,9 @@
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -20,12 +20,13 @@
//
#import <Foundation/Foundation.h>
+#import <CoreGraphics/CoreGraphics.h>
#import "GTMDefines.h"
#ifdef __cplusplus
extern "C" {
#endif
-
+
enum {
GTMScaleProportionally = 0, // Fit proportionally
GTMScaleToFit, // Forced fit (distort if necessary)
@@ -53,7 +54,7 @@ typedef NSUInteger GTMRectAlignment;
//
// Args:
// rect - rectangle
-//
+//
// Returns:
// point located in the middle of min X side of rect
GTM_INLINE CGPoint GTMCGMidMinX(CGRect rect) {
@@ -64,7 +65,7 @@ GTM_INLINE CGPoint GTMCGMidMinX(CGRect rect) {
//
// Args:
// rect - rectangle
-//
+//
// Returns:
// point located in the middle of max X side of rect
GTM_INLINE CGPoint GTMCGMidMaxX(CGRect rect) {
@@ -75,7 +76,7 @@ GTM_INLINE CGPoint GTMCGMidMaxX(CGRect rect) {
//
// Args:
// rect - rectangle
-//
+//
// Returns:
// point located in the middle of max Y side of rect
GTM_INLINE CGPoint GTMCGMidMaxY(CGRect rect) {
@@ -86,7 +87,7 @@ GTM_INLINE CGPoint GTMCGMidMaxY(CGRect rect) {
//
// Args:
// rect - rectangle
-//
+//
// Returns:
// point located in the middle of min Y side of rect
GTM_INLINE CGPoint GTMCGMidMinY(CGRect rect) {
@@ -97,7 +98,7 @@ GTM_INLINE CGPoint GTMCGMidMinY(CGRect rect) {
//
// Args:
// rect - rectangle
-//
+//
// Returns:
// point located in the center of rect
GTM_INLINE CGPoint GTMCGCenter(CGRect rect) {
@@ -111,7 +112,7 @@ GTM_INLINE CGPoint GTMCGCenter(CGRect rect) {
//
// Args:
// rect - rectangle
-//
+//
// Returns:
// size of rectangle
GTM_INLINE CGSize GTMCGRectSize(CGRect rect) {
@@ -122,7 +123,7 @@ GTM_INLINE CGSize GTMCGRectSize(CGRect rect) {
//
// Args:
// size - size
-//
+//
// Returns:
// rectangle of size (origin 0,0)
GTM_INLINE CGRect GTMCGRectOfSize(CGSize size) {
@@ -134,7 +135,7 @@ GTM_INLINE CGRect GTMCGRectOfSize(CGSize size) {
/// Scales an CGRect
//
-// Args:
+// Args:
// inRect: Rect to scale
// xScale: fraction to scale (1.0 is 100%)
// yScale: fraction to scale (1.0 is 100%)
@@ -142,7 +143,7 @@ GTM_INLINE CGRect GTMCGRectOfSize(CGSize size) {
// Returns:
// Converted Rect
GTM_INLINE CGRect GTMCGRectScale(CGRect inRect, CGFloat xScale, CGFloat yScale) {
- return CGRectMake(inRect.origin.x, inRect.origin.y,
+ return CGRectMake(inRect.origin.x, inRect.origin.y,
inRect.size.width * xScale, inRect.size.height * yScale);
}
@@ -153,7 +154,7 @@ GTM_INLINE CGRect GTMCGRectScale(CGRect inRect, CGFloat xScale, CGFloat yScale)
// alignee - rect to be aligned
// aligner - rect to be aligned from
// alignment - way to align the rectangles
-CGRect GTMCGAlignRectangles(CGRect alignee, CGRect aligner,
+CGRect GTMCGAlignRectangles(CGRect alignee, CGRect aligner,
GTMRectAlignment alignment);
/// Scale rectangle
//
@@ -161,7 +162,7 @@ CGRect GTMCGAlignRectangles(CGRect alignee, CGRect aligner,
// scalee - rect to be scaled
// size - size to scale to
// scaling - way to scale the rectangle
-CGRect GTMCGScaleRectangleToSize(CGRect scalee, CGSize size,
+CGRect GTMCGScaleRectangleToSize(CGRect scalee, CGSize size,
GTMScaling scaling);
#pragma mark -
@@ -172,13 +173,13 @@ CGRect GTMCGScaleRectangleToSize(CGRect scalee, CGSize size,
// Args:
// pt1 first point
// pt2 second point
-//
+//
// Returns:
// Distance
GTM_INLINE CGFloat GTMCGDistanceBetweenPoints(CGPoint pt1, CGPoint pt2) {
CGFloat dX = pt1.x - pt2.x;
CGFloat dY = pt1.y - pt2.y;
-#if CGFLOAT_IS_DOUBLE
+#if CGFLOAT_IS_DOUBLE
return sqrt(dX * dX + dY * dY);
#else
return sqrtf(dX * dX + dY * dY);
@@ -189,7 +190,7 @@ GTM_INLINE CGFloat GTMCGDistanceBetweenPoints(CGPoint pt1, CGPoint pt2) {
// iPhone does not have NSTypes defined, only CGTypes. So no NSRect, NSPoint etc.
#pragma mark -
-// All of the conversion routines below are basically copied from the
+// All of the conversion routines below are basically copied from the
// NSGeometry header in the 10.5 sdk.
#pragma mark NS <-> CG Point Conversion
@@ -199,12 +200,12 @@ GTM_INLINE CGFloat GTMCGDistanceBetweenPoints(CGPoint pt1, CGPoint pt2) {
/// CGPoints are relative to 0,0 in lower left;
/// NSPoints are relative to 0,0 in lower left
//
-// Args:
+// Args:
// inPoint: CGPoint to convert
//
// Returns:
// Converted NSPoint
-GTM_INLINE NSPoint GTMCGPointToNSPoint(CGPoint inPoint) {
+GTM_INLINE NSPoint GTMCGPointToNSPoint(CGPoint inPoint) {
_GTMCompileAssert(sizeof(NSPoint) == sizeof(CGPoint), NSPoint_and_CGPoint_must_be_the_same_size);
union convertUnion {NSPoint ns; CGPoint cg;};
return ((union convertUnion *)&inPoint)->ns;
@@ -215,12 +216,12 @@ GTM_INLINE NSPoint GTMCGPointToNSPoint(CGPoint inPoint) {
/// CGPoints are relative to 0,0 in lower left;
/// NSPoints are relative to 0,0 in lower left
//
-// Args:
+// Args:
// inPoint: NSPoint to convert
//
// Returns:
// Converted CGPoint
-GTM_INLINE CGPoint GTMNSPointToCGPoint(NSPoint inPoint) {
+GTM_INLINE CGPoint GTMNSPointToCGPoint(NSPoint inPoint) {
_GTMCompileAssert(sizeof(NSPoint) == sizeof(CGPoint), NSPoint_and_CGPoint_must_be_the_same_size);
union convertUnion {NSPoint ns; CGPoint cg;};
return ((union convertUnion *)&inPoint)->cg;
@@ -234,7 +235,7 @@ GTM_INLINE CGPoint GTMNSPointToCGPoint(NSPoint inPoint) {
/// NSRect are relative to 0,0 in lower left;
/// CGRect are relative to 0,0 in lower left
//
-// Args:
+// Args:
// inRect: CGRect to convert
//
// Returns:
@@ -250,7 +251,7 @@ GTM_INLINE NSRect GTMCGRectToNSRect(CGRect inRect) {
/// NSRect are relative to 0,0 in lower left;
/// CGRect are relative to 0,0 in lower left
//
-// Args:
+// Args:
// inRect: NSRect to convert
//
// Returns:
@@ -267,7 +268,7 @@ GTM_INLINE CGRect GTMNSRectToCGRect(NSRect inRect) {
/// Convert from a CGSize to an NSSize.
//
-// Args:
+// Args:
// inSize: CGSize to convert
//
// Returns:
@@ -280,7 +281,7 @@ GTM_INLINE NSSize GTMCGSizeToNSSize(CGSize inSize) {
/// Convert from a NSSize to a CGSize.
//
-// Args:
+// Args:
// inSize: NSSize to convert
//
// Returns:
@@ -298,7 +299,7 @@ GTM_INLINE CGSize GTMNSSizeToCGSize(NSSize inSize) {
//
// Args:
// rect - rectangle
-//
+//
// Returns:
// point located in the middle of min X side of rect
GTM_INLINE NSPoint GTMNSMidMinX(NSRect rect) {
@@ -309,7 +310,7 @@ GTM_INLINE NSPoint GTMNSMidMinX(NSRect rect) {
//
// Args:
// rect - rectangle
-//
+//
// Returns:
// point located in the middle of max X side of rect
GTM_INLINE NSPoint GTMNSMidMaxX(NSRect rect) {
@@ -320,7 +321,7 @@ GTM_INLINE NSPoint GTMNSMidMaxX(NSRect rect) {
//
// Args:
// rect - rectangle
-//
+//
// Returns:
// point located in the middle of max Y side of rect
GTM_INLINE NSPoint GTMNSMidMaxY(NSRect rect) {
@@ -331,7 +332,7 @@ GTM_INLINE NSPoint GTMNSMidMaxY(NSRect rect) {
//
// Args:
// rect - rectangle
-//
+//
// Returns:
// point located in the middle of min Y side of rect
GTM_INLINE NSPoint GTMNSMidMinY(NSRect rect) {
@@ -342,7 +343,7 @@ GTM_INLINE NSPoint GTMNSMidMinY(NSRect rect) {
//
// Args:
// rect - rectangle
-//
+//
// Returns:
// point located in the center of rect
GTM_INLINE NSPoint GTMNSCenter(NSRect rect) {
@@ -356,7 +357,7 @@ GTM_INLINE NSPoint GTMNSCenter(NSRect rect) {
//
// Args:
// rect - rectangle
-//
+//
// Returns:
// size of rectangle
GTM_INLINE NSSize GTMNSRectSize(NSRect rect) {
@@ -367,7 +368,7 @@ GTM_INLINE NSSize GTMNSRectSize(NSRect rect) {
//
// Args:
// size - size
-//
+//
// Returns:
// rectangle of size (origin 0,0)
GTM_INLINE NSRect GTMNSRectOfSize(NSSize size) {
@@ -379,7 +380,7 @@ GTM_INLINE NSRect GTMNSRectOfSize(NSSize size) {
/// Scales an NSRect
//
-// Args:
+// Args:
// inRect: Rect to scale
// xScale: fraction to scale (1.0 is 100%)
// yScale: fraction to scale (1.0 is 100%)
@@ -387,7 +388,7 @@ GTM_INLINE NSRect GTMNSRectOfSize(NSSize size) {
// Returns:
// Converted Rect
GTM_INLINE NSRect GTMNSRectScale(NSRect inRect, CGFloat xScale, CGFloat yScale) {
- return NSMakeRect(inRect.origin.x, inRect.origin.y,
+ return NSMakeRect(inRect.origin.x, inRect.origin.y,
inRect.size.width * xScale, inRect.size.height * yScale);
}
@@ -396,12 +397,12 @@ GTM_INLINE NSRect GTMNSRectScale(NSRect inRect, CGFloat xScale, CGFloat yScale)
// Args:
// alignee - rect to be aligned
// aligner - rect to be aligned from
-GTM_INLINE NSRect GTMNSAlignRectangles(NSRect alignee, NSRect aligner,
+GTM_INLINE NSRect GTMNSAlignRectangles(NSRect alignee, NSRect aligner,
GTMRectAlignment alignment) {
return GTMCGRectToNSRect(GTMCGAlignRectangles(GTMNSRectToCGRect(alignee),
GTMNSRectToCGRect(aligner),
alignment));
-}
+}
/// Align a rectangle to another
//
@@ -410,27 +411,27 @@ GTM_INLINE NSRect GTMNSAlignRectangles(NSRect alignee, NSRect aligner,
// scaler - rect to scale to
// scaling - way to scale the rectangle
// alignment - way to align the scaled rectangle
-GTM_INLINE NSRect GTMNSScaleRectToRect(NSRect scalee,
- NSRect scaler,
+GTM_INLINE NSRect GTMNSScaleRectToRect(NSRect scalee,
+ NSRect scaler,
GTMScaling scaling,
GTMRectAlignment alignment) {
-
+
return GTMCGRectToNSRect(
GTMCGAlignRectangles(
GTMCGScaleRectangleToSize(GTMNSRectToCGRect(scalee),
GTMNSSizeToCGSize(scaler.size),
- scaling),
+ scaling),
GTMNSRectToCGRect(scaler),
alignment));
-}
-
+}
+
/// Scale rectangle
//
// Args:
// scalee - rect to be scaled
// size - size to scale to
// scaling - way to scale the rectangle
-GTM_INLINE NSRect GTMNSScaleRectangleToSize(NSRect scalee, NSSize size,
+GTM_INLINE NSRect GTMNSScaleRectangleToSize(NSRect scalee, NSSize size,
GTMScaling scaling) {
return GTMCGRectToNSRect(GTMCGScaleRectangleToSize(GTMNSRectToCGRect(scalee),
GTMNSSizeToCGSize(size),
@@ -445,16 +446,16 @@ GTM_INLINE NSRect GTMNSScaleRectangleToSize(NSRect scalee, NSSize size,
// Args:
// pt1 first point
// pt2 second point
-//
+//
// Returns:
// Distance
GTM_INLINE CGFloat GTMNSDistanceBetweenPoints(NSPoint pt1, NSPoint pt2) {
- return GTMCGDistanceBetweenPoints(GTMNSPointToCGPoint(pt1),
+ return GTMCGDistanceBetweenPoints(GTMNSPointToCGPoint(pt1),
GTMNSPointToCGPoint(pt2));
}
#endif // !GTM_IPHONE_SDK
-
+
#ifdef __cplusplus
}
#endif