// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace Gdk {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;
	using static GLib.AbiStructExtension;

#region Autogenerated code
	public partial class Cursor : GLib.Object {

		public Cursor (IntPtr raw) : base(raw) {}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gdk_cursor_new(int cursor_type);
		static d_gdk_cursor_new gdk_cursor_new = FuncLoader.LoadFunction<d_gdk_cursor_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_cursor_new"));

		[Obsolete]
		public Cursor (Gdk.CursorType cursor_type) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (Cursor)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				names.Add ("cursor_type");
				vals.Add (new GLib.Value (cursor_type));
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			Raw = gdk_cursor_new((int) cursor_type);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gdk_cursor_new_for_display(IntPtr display, int cursor_type);
		static d_gdk_cursor_new_for_display gdk_cursor_new_for_display = FuncLoader.LoadFunction<d_gdk_cursor_new_for_display>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_cursor_new_for_display"));

		public Cursor (Gdk.Display display, Gdk.CursorType cursor_type) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (Cursor)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				if (display != null) {
					names.Add ("display");
					vals.Add (new GLib.Value (display));
				}
				names.Add ("cursor_type");
				vals.Add (new GLib.Value (cursor_type));
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			Raw = gdk_cursor_new_for_display(display == null ? IntPtr.Zero : display.Handle, (int) cursor_type);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gdk_cursor_new_from_name(IntPtr display, IntPtr name);
		static d_gdk_cursor_new_from_name gdk_cursor_new_from_name = FuncLoader.LoadFunction<d_gdk_cursor_new_from_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_cursor_new_from_name"));

		public Cursor (Gdk.Display display, string name) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (Cursor)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				if (display != null) {
					names.Add ("display");
					vals.Add (new GLib.Value (display));
				}
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
			Raw = gdk_cursor_new_from_name(display == null ? IntPtr.Zero : display.Handle, native_name);
			GLib.Marshaller.Free (native_name);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gdk_cursor_new_from_pixbuf(IntPtr display, IntPtr pixbuf, int x, int y);
		static d_gdk_cursor_new_from_pixbuf gdk_cursor_new_from_pixbuf = FuncLoader.LoadFunction<d_gdk_cursor_new_from_pixbuf>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_cursor_new_from_pixbuf"));

		public Cursor (Gdk.Display display, Gdk.Pixbuf pixbuf, int x, int y) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (Cursor)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				if (display != null) {
					names.Add ("display");
					vals.Add (new GLib.Value (display));
				}
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			Raw = gdk_cursor_new_from_pixbuf(display == null ? IntPtr.Zero : display.Handle, pixbuf == null ? IntPtr.Zero : pixbuf.Handle, x, y);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gdk_cursor_new_from_surface(IntPtr display, IntPtr surface, double x, double y);
		static d_gdk_cursor_new_from_surface gdk_cursor_new_from_surface = FuncLoader.LoadFunction<d_gdk_cursor_new_from_surface>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_cursor_new_from_surface"));

		public Cursor (Gdk.Display display, Cairo.Surface surface, double x, double y) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (Cursor)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				if (display != null) {
					names.Add ("display");
					vals.Add (new GLib.Value (display));
				}
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			Raw = gdk_cursor_new_from_surface(display == null ? IntPtr.Zero : display.Handle, surface.Handle, x, y);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_gdk_cursor_get_cursor_type(IntPtr raw);
		static d_gdk_cursor_get_cursor_type gdk_cursor_get_cursor_type = FuncLoader.LoadFunction<d_gdk_cursor_get_cursor_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_cursor_get_cursor_type"));

		[GLib.Property ("cursor-type")]
		public Gdk.CursorType CursorType {
			get  {
				int raw_ret = gdk_cursor_get_cursor_type(Handle);
				Gdk.CursorType ret = (Gdk.CursorType) raw_ret;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gdk_cursor_get_display(IntPtr raw);
		static d_gdk_cursor_get_display gdk_cursor_get_display = FuncLoader.LoadFunction<d_gdk_cursor_get_display>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_cursor_get_display"));

		[GLib.Property ("display")]
		public Gdk.Display Display {
			get  {
				IntPtr raw_ret = gdk_cursor_get_display(Handle);
				Gdk.Display ret = GLib.Object.GetObject(raw_ret) as Gdk.Display;
				return ret;
			}
		}

		static GetSurfaceNativeDelegate GetSurface_cb_delegate;
		static GetSurfaceNativeDelegate GetSurfaceVMCallback {
			get {
				if (GetSurface_cb_delegate == null)
					GetSurface_cb_delegate = new GetSurfaceNativeDelegate (GetSurface_cb);
				return GetSurface_cb_delegate;
			}
		}

		static void OverrideGetSurface (GLib.GType gtype)
		{
			OverrideGetSurface (gtype, GetSurfaceVMCallback);
		}

		static void OverrideGetSurface (GLib.GType gtype, GetSurfaceNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("get_surface"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetSurfaceNativeDelegate (IntPtr inst, out double x_hot, out double y_hot);

		static IntPtr GetSurface_cb (IntPtr inst, out double x_hot, out double y_hot)
		{
			try {
				Cursor __obj = GLib.Object.GetObject (inst, false) as Cursor;
				Cairo.Surface __result;
				__result = __obj.OnGetSurface (out x_hot, out y_hot);
				return __result.Handle;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gdk.Cursor), ConnectionMethod="OverrideGetSurface")]
		protected virtual Cairo.Surface OnGetSurface (out double x_hot, out double y_hot)
		{
			return InternalGetSurface (out x_hot, out y_hot);
		}

		private Cairo.Surface InternalGetSurface (out double x_hot, out double y_hot)
		{
			GetSurfaceNativeDelegate unmanaged = class_abi.BaseOverride<GetSurfaceNativeDelegate>(this.LookupGType(), "get_surface");
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			IntPtr __result = unmanaged (this.Handle, out x_hot, out y_hot);
			return Cairo.Surface.Lookup (__result, true);
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _class_abi = null;
		static public unsafe new GLib.AbiStruct class_abi {
			get {
				if (_class_abi == null)
					_class_abi = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("get_surface"
							, GLib.Object.class_abi.Fields
							, (uint) sizeof( IntPtr ) // get_surface
							, null
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gdk_cursor_get_image(IntPtr raw);
		static d_gdk_cursor_get_image gdk_cursor_get_image = FuncLoader.LoadFunction<d_gdk_cursor_get_image>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_cursor_get_image"));

		public Gdk.Pixbuf Image { 
			get {
				IntPtr raw_ret = gdk_cursor_get_image(Handle);
				Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gdk_cursor_get_surface(IntPtr raw, out double x_hot, out double y_hot);
		static d_gdk_cursor_get_surface gdk_cursor_get_surface = FuncLoader.LoadFunction<d_gdk_cursor_get_surface>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_cursor_get_surface"));

		public Cairo.Surface GetSurface(out double x_hot, out double y_hot) {
			IntPtr raw_ret = gdk_cursor_get_surface(Handle, out x_hot, out y_hot);
			Cairo.Surface ret = Cairo.Surface.Lookup (raw_ret, true);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gdk_cursor_get_type();
		static d_gdk_cursor_get_type gdk_cursor_get_type = FuncLoader.LoadFunction<d_gdk_cursor_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_cursor_get_type"));

		public static new GLib.GType GType { 
			get {
				IntPtr raw_ret = gdk_cursor_get_type();
				GLib.GType ret = new GLib.GType(raw_ret);
				return ret;
			}
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _abi_info = null;
		static public unsafe new GLib.AbiStruct abi_info {
			get {
				if (_abi_info == null)
					_abi_info = new GLib.AbiStruct (GLib.Object.abi_info.Fields);

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
