using CPF.Mac.CoreGraphics;
using CPF.Mac.Foundation;
using CPF.Mac.ObjCRuntime;
using System;
using System.ComponentModel;

namespace CPF.Mac.CoreAnimation
{
	[Register("CATransformLayer", true)]
	public class CATransformLayer : CALayer
	{
		private static readonly IntPtr selLayerHandle = Selector.GetHandle("layer");

		private static readonly IntPtr selHitTest_Handle = Selector.GetHandle("hitTest:");

		private static readonly IntPtr class_ptr = Class.GetHandle("CATransformLayer");

		public override IntPtr ClassHandle => class_ptr;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		[Export("init")]
		public CATransformLayer()
			: base(NSObjectFlag.Empty)
		{
			if (IsDirectBinding)
			{
				base.Handle = Messaging.IntPtr_objc_msgSend(base.Handle, Selector.Init);
			}
			else
			{
				base.Handle = Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, Selector.Init);
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		[Export("initWithCoder:")]
		public CATransformLayer(NSCoder coder)
			: base(NSObjectFlag.Empty)
		{
			if (IsDirectBinding)
			{
				base.Handle = Messaging.IntPtr_objc_msgSend_IntPtr(base.Handle, Selector.InitWithCoder, coder.Handle);
			}
			else
			{
				base.Handle = Messaging.IntPtr_objc_msgSendSuper_IntPtr(base.SuperHandle, Selector.InitWithCoder, coder.Handle);
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		public CATransformLayer(NSObjectFlag t)
			: base(t)
		{
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		public CATransformLayer(IntPtr handle)
			: base(handle)
		{
		}

		[Export("layer")]
		public new static CALayer Create()
		{
			return (CALayer)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend(class_ptr, selLayerHandle));
		}

		[Export("hitTest:")]
		public new virtual CALayer HitTest(CGPoint thePoint)
		{
			if (IsDirectBinding)
			{
				return (CALayer)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend_CGPoint(base.Handle, selHitTest_Handle, thePoint));
			}
			return (CALayer)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSendSuper_CGPoint(base.SuperHandle, selHitTest_Handle, thePoint));
		}
	}
}
