diff dstep/foundation/NSGeometry.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 19885b43130e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/foundation/NSGeometry.d	Mon Aug 03 15:23:15 2009 +0200
@@ -0,0 +1,153 @@
+/**
+ * Copyright: Copyright (c) 2009 Jacob Carlborg.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 3, 2009 
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
+ */
+module dstep.foundation.NSGeometry;
+
+import dstep.AvailabilityMacros;
+import dstep.applicationservices.coregraphics.CGBase;
+import dstep.applicationservices.coregraphics.CGGeometry;
+import dstep.foundation.NSCoder;
+import dstep.foundation.NSString;
+import dstep.foundation.NSValue;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc : id;
+
+import bindings = dstep.foundation.NSGeometry_bindings;
+
+alias CGPoint NSPoint;
+alias NSPoint* NSPointPointer;
+alias NSPoint* NSPointArray;
+alias CGSize NSSize;
+alias NSSize* NSSizePointer;
+alias NSSize* NSSizeArray;
+alias CGRect NSRect;
+alias NSRect* NSRectPointer;
+alias NSRect* NSRectArray;
+alias NSUInteger NSRectEdge;
+
+extern (C)
+{
+	extern
+	{
+		const NSPoint NSZeroPoint;
+		const NSSize NSZeroSize;
+		const NSRect NSZeroRect;
+	}
+}
+
+template TNSGeometryCoding ()
+{
+	void encodePoint (NSPoint point)
+	{
+		return invokeObjcSelf!(void, "encodePoint:", NSPoint)(point);
+	}
+
+	NSPoint decodePoint ()
+	{
+		return invokeObjcSelf!(NSPoint, "decodePoint");
+	}
+
+	void encodeSize (NSSize size)
+	{
+		return invokeObjcSelf!(void, "encodeSize:", NSSize)(size);
+	}
+
+	NSSize decodeSize ()
+	{
+		return invokeObjcSelf!(NSSize, "decodeSize");
+	}
+
+	void encodeRect (NSRect rect)
+	{
+		return invokeObjcSelf!(void, "encodeRect:", NSRect)(rect);
+	}
+
+	NSRect decodeRect ()
+	{
+		return invokeObjcSelf!(NSRect, "decodeRect");
+	}
+}
+
+template TNSValueGeometryExtensions ()
+{
+	static NSValue valueWithPoint (NSPoint point)
+	{
+		return invokeObjcSelfClass!(NSValue, "valueWithPoint:", NSPoint)(point);
+	}
+
+	static NSValue valueWithSize (NSSize size)
+	{
+		return invokeObjcSelfClass!(NSValue, "valueWithSize:", NSSize)(size);
+	}
+
+	static NSValue valueWithRect (NSRect rect)
+	{
+		return invokeObjcSelfClass!(NSValue, "valueWithRect:", NSRect)(rect);
+	}
+
+	NSPoint pointValue ()
+	{
+		return invokeObjcSelf!(NSPoint, "pointValue");
+	}
+
+	NSSize sizeValue ()
+	{
+		return invokeObjcSelf!(NSSize, "sizeValue");
+	}
+
+	NSRect rectValue ()
+	{
+		return invokeObjcSelf!(NSRect, "rectValue");
+	}
+}
+
+NSString NSStringFromPoint (NSPoint aPoint)
+{
+	return Bridge.invokeObjcFunction!(NSString, bindings.NSStringFromPoint, NSPoint)(aPoint);
+}
+
+NSString NSStringFromSize (NSSize aSize)
+{
+	return Bridge.invokeObjcFunction!(NSString, bindings.NSStringFromSize, NSSize)(aSize);
+}
+
+NSString NSStringFromRect (NSRect aRect)
+{
+	return Bridge.invokeObjcFunction!(NSString, bindings.NSStringFromRect, NSRect)(aRect);
+}
+
+NSPoint NSPointFromString (NSString aString)
+{
+	return Bridge.invokeObjcFunction!(NSPoint, bindings.NSPointFromString, NSString)(aString);
+}
+
+NSSize NSSizeFromString (NSString aString)
+{
+	return Bridge.invokeObjcFunction!(NSSize, bindings.NSSizeFromString, NSString)(aString);
+}
+
+NSRect NSRectFromString (NSString aString)
+{
+	return Bridge.invokeObjcFunction!(NSRect, bindings.NSRectFromString, NSString)(aString);
+}
+
+extern (C)
+{
+	bool NSEqualPoints (NSPoint aPoint, NSPoint bPoint);
+	bool NSEqualSizes (NSSize aSize, NSSize bSize);
+	bool NSEqualRects (NSRect aRect, NSRect bRect);
+	bool NSIsEmptyRect (NSRect aRect);
+	NSRect NSInsetRect (NSRect aRect, CGFloat dX, CGFloat dY);
+	NSRect NSIntegralRect (NSRect aRect);
+	NSRect NSUnionRect (NSRect aRect, NSRect bRect);
+	NSRect NSIntersectionRect (NSRect aRect, NSRect bRect);
+	NSRect NSOffsetRect (NSRect aRect, CGFloat dX, CGFloat dY);
+	void NSDivideRect (NSRect inRect, NSRect* slice, NSRect* rem, CGFloat amount, int edge);
+	bool NSPointInRect (NSPoint aPoint, NSRect aRect);
+	bool NSMouseInRect (NSPoint aPoint, NSRect aRect, bool flipped);
+	bool NSContainsRect (NSRect aRect, NSRect bRect);
+	bool NSIntersectsRect (NSRect aRect, NSRect bRect);
+}
\ No newline at end of file