diff options
author | thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2008-06-13 19:21:50 +0000 |
---|---|---|
committer | thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2008-06-13 19:21:50 +0000 |
commit | c53ec5520e39096e0804ce8d89a21378c0904481 (patch) | |
tree | d36a0055b59b1376d86c4ba4a01f9c479c2101a7 /Foundation/GTMGeometryUtils.m | |
parent | 80d493da05c8d461d74bfaa919ffc487be03ffe6 (diff) |
Landing a log of AppleScript/AppleEvent support code.
Landing GTMHTTPServer as a simple server but mainly for use in unittesting.
_GTMCompileAssert for doing compile time assertions to GTMDefines.h
Lots of improvments for UnitTesting, Dave's gonna put up a wiki page shortly with the full details of what can be done.
Diffstat (limited to 'Foundation/GTMGeometryUtils.m')
-rw-r--r-- | Foundation/GTMGeometryUtils.m | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/Foundation/GTMGeometryUtils.m b/Foundation/GTMGeometryUtils.m index 0e893ff..9ac2933 100644 --- a/Foundation/GTMGeometryUtils.m +++ b/Foundation/GTMGeometryUtils.m @@ -25,26 +25,26 @@ // aligner - rect to be aligned to // alignment - alignment to be applied to alignee based on aligner -NSRect GTMAlignRectangles(NSRect alignee, NSRect aligner, GTMRectAlignment alignment) { +CGRect GTMCGAlignRectangles(CGRect alignee, CGRect aligner, GTMRectAlignment alignment) { switch (alignment) { case GTMRectAlignTop: - alignee.origin.x = aligner.origin.x + (NSWidth(aligner) * .5f - NSWidth(alignee) * .5f); - alignee.origin.y = aligner.origin.y + NSHeight(aligner) - NSHeight(alignee); + alignee.origin.x = aligner.origin.x + (CGRectGetWidth(aligner) * .5f - CGRectGetWidth(alignee) * .5f); + alignee.origin.y = aligner.origin.y + CGRectGetHeight(aligner) - CGRectGetHeight(alignee); break; case GTMRectAlignTopLeft: alignee.origin.x = aligner.origin.x; - alignee.origin.y = aligner.origin.y + NSHeight(aligner) - NSHeight(alignee); + alignee.origin.y = aligner.origin.y + CGRectGetHeight(aligner) - CGRectGetHeight(alignee); break; case GTMRectAlignTopRight: - alignee.origin.x = aligner.origin.x + NSWidth(aligner) - NSWidth(alignee); - alignee.origin.y = aligner.origin.y + NSHeight(aligner) - NSHeight(alignee); + alignee.origin.x = aligner.origin.x + CGRectGetWidth(aligner) - CGRectGetWidth(alignee); + alignee.origin.y = aligner.origin.y + CGRectGetHeight(aligner) - CGRectGetHeight(alignee); break; case GTMRectAlignLeft: alignee.origin.x = aligner.origin.x; - alignee.origin.y = aligner.origin.y + (NSHeight(aligner) * .5f - NSHeight(alignee) * .5f); + alignee.origin.y = aligner.origin.y + (CGRectGetHeight(aligner) * .5f - CGRectGetHeight(alignee) * .5f); break; case GTMRectAlignBottomLeft: @@ -53,40 +53,40 @@ NSRect GTMAlignRectangles(NSRect alignee, NSRect aligner, GTMRectAlignment align break; case GTMRectAlignBottom: - alignee.origin.x = aligner.origin.x + (NSWidth(aligner) * .5f - NSWidth(alignee) * .5f); + alignee.origin.x = aligner.origin.x + (CGRectGetWidth(aligner) * .5f - CGRectGetWidth(alignee) * .5f); alignee.origin.y = aligner.origin.y; break; case GTMRectAlignBottomRight: - alignee.origin.x = aligner.origin.x + NSWidth(aligner) - NSWidth(alignee); + alignee.origin.x = aligner.origin.x + CGRectGetWidth(aligner) - CGRectGetWidth(alignee); alignee.origin.y = aligner.origin.y; break; case GTMRectAlignRight: - alignee.origin.x = aligner.origin.x + NSWidth(aligner) - NSWidth(alignee); - alignee.origin.y = aligner.origin.y + (NSHeight(aligner) * .5f - NSHeight(alignee) * .5f); + alignee.origin.x = aligner.origin.x + CGRectGetWidth(aligner) - CGRectGetWidth(alignee); + alignee.origin.y = aligner.origin.y + (CGRectGetHeight(aligner) * .5f - CGRectGetHeight(alignee) * .5f); break; default: case GTMRectAlignCenter: - alignee.origin.x = aligner.origin.x + (NSWidth(aligner) * .5f - NSWidth(alignee) * .5f); - alignee.origin.y = aligner.origin.y + (NSHeight(aligner) * .5f - NSHeight(alignee) * .5f); + alignee.origin.x = aligner.origin.x + (CGRectGetWidth(aligner) * .5f - CGRectGetWidth(alignee) * .5f); + alignee.origin.y = aligner.origin.y + (CGRectGetHeight(aligner) * .5f - CGRectGetHeight(alignee) * .5f); break; } return alignee; } -NSRect GTMScaleRectangleToSize(NSRect scalee, NSSize size, GTMScaling scaling) { +CGRect GTMCGScaleRectangleToSize(CGRect scalee, CGSize size, GTMScaling scaling) { switch (scaling) { case GTMScaleProportionally: { - CGFloat height = NSHeight(scalee); - CGFloat width = NSWidth(scalee); + CGFloat height = CGRectGetHeight(scalee); + CGFloat width = CGRectGetWidth(scalee); if (isnormal(height) && isnormal(width) && (height > size.height || width > size.width)) { CGFloat horiz = size.width / width; CGFloat vert = size.height / height; CGFloat newScale = horiz < vert ? horiz : vert; - scalee = GTMNSRectScale(scalee, newScale, newScale); + scalee = GTMCGRectScale(scalee, newScale, newScale); } break; } |