view dstep/quartzcore/CAConstraintLayoutManager.d @ 16:19885b43130e

Huge update, the bridge actually works now
author Jacob Carlborg <doob@me.com>
date Sun, 03 Jan 2010 22:06:11 +0100
parents
children b9de51448c6b
line wrap: on
line source

/**
 * Copyright: Copyright (c) 2009 Jacob Carlborg.
 * Authors: Jacob Carlborg
 * Version: Initial created: Sep 24, 2009 
 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
 */
module dstep.quartzcore.CAConstraintLayoutManager;

import dstep.applicationservices.coregraphics.CGBase;
import dstep.foundation.NSCoder;
import dstep.foundation.NSObject;
import dstep.foundation.NSString;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;

alias int CAConstraintAttribute;

enum _CAConstraintAttribute

{
	kCAConstraintMinX,
	kCAConstraintMidX,
	kCAConstraintMaxX,
	kCAConstraintWidth,
	kCAConstraintMinY,
	kCAConstraintMidY,
	kCAConstraintMaxY,
	kCAConstraintHeight
}

class CAConstraintLayoutManager : NSObject
{
	mixin (ObjcWrap);

	static Object layoutManager ()
	{
		return invokeObjcSelfClass!(Object, "layoutManager");
	}
}

class CAConstraint : NSObject, INSCoding
{
	mixin (ObjcWrap);

	static Object constraintWithAttribute (int attr, NSString srcId, int srcAttr, CGFloat m, CGFloat c)
	{
		return invokeObjcSelfClass!(Object, "constraintWithAttribute:relativeTo:attribute:scale:offset:", int, NSString, int, CGFloat, CGFloat)(attr, srcId, srcAttr, m, c);
	}

	static Object constraintWithAttribute (int attr, NSString srcId, int srcAttr, CGFloat c)
	{
		return invokeObjcSelfClass!(Object, "constraintWithAttribute:relativeTo:attribute:offset:", int, NSString, int, CGFloat)(attr, srcId, srcAttr, c);
	}

	static Object constraintWithAttribute (int attr, NSString srcId, int srcAttr)
	{
		return invokeObjcSelfClass!(Object, "constraintWithAttribute:relativeTo:attribute:", int, NSString, int)(attr, srcId, srcAttr);
	}

	CAConstraint initWithAttribute (int attr, NSString srcId, int srcAttr, CGFloat m, CGFloat c)
	{
		id result = invokeObjcSelf!(id, "initWithAttribute:relativeTo:attribute:scale:offset:", int, NSString, int, CGFloat, CGFloat)(attr, srcId, srcAttr, m, c);
		return result is this.objcObject ? this : (result !is null ? new CAConstraint(result) : null);
	}

	this (int attr, NSString srcId, int srcAttr, CGFloat m, CGFloat c)
	{
		super(CAConstraint.alloc.initWithAttribute(attr, srcId, srcAttr, m, c).objcObject);
	}
	
	void encodeWithCoder (NSCoder aCoder)
	{
		return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
	}
	
	CAConstraint initWithCoder (NSCoder aDecoder)
	{
		return invokeObjcSelf!(CAConstraint, "initWithCoder:", NSCoder)(aDecoder);
	}

}

const TCAConstraintLayoutManager = `

	void addConstraint (CAConstraint c)
	{
		return invokeObjcSelf!(void, "addConstraint:", CAConstraint)(c);
	}

	//mixin ObjcBindMethod!(addConstraint, "addConstraint:");

`;