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

namespace Pango {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;

#region Autogenerated code
	[StructLayout(LayoutKind.Sequential)]
	public partial struct Color : IEquatable<Color> {

		public ushort Red;
		public ushort Green;
		public ushort Blue;

		public static Pango.Color Zero = new Pango.Color ();

		public static Pango.Color New(IntPtr raw) {
			if (raw == IntPtr.Zero)
				return Pango.Color.Zero;
			return (Pango.Color) Marshal.PtrToStructure (raw, typeof (Pango.Color));
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_pango_color_get_type();
		static d_pango_color_get_type pango_color_get_type = FuncLoader.LoadFunction<d_pango_color_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_color_get_type"));

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_pango_color_parse(IntPtr raw, IntPtr spec);
		static d_pango_color_parse pango_color_parse = FuncLoader.LoadFunction<d_pango_color_parse>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_color_parse"));

		public bool Parse(string spec) {
			IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<Pango.Color>());
			System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
			IntPtr native_spec = GLib.Marshaller.StringToPtrGStrdup (spec);
			bool raw_ret = pango_color_parse(this_as_native, native_spec);
			bool ret = raw_ret;
			ReadNative (this_as_native, ref this);
			System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
			GLib.Marshaller.Free (native_spec);
			return ret;
		}

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

		public override string ToString() {
			IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<Pango.Color>());
			System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
			IntPtr raw_ret = pango_color_to_string(this_as_native);
			string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
			ReadNative (this_as_native, ref this);
			System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
			return ret;
		}

		static void ReadNative (IntPtr native, ref Pango.Color target)
		{
			target = New (native);
		}

		public bool Equals (Color other)
		{
			return true && Red.Equals (other.Red) && Green.Equals (other.Green) && Blue.Equals (other.Blue);
		}

		public override bool Equals (object other)
		{
			return other is Color && Equals ((Color) other);
		}

		public override int GetHashCode ()
		{
			return this.GetType ().FullName.GetHashCode () ^ Red.GetHashCode () ^ Green.GetHashCode () ^ Blue.GetHashCode ();
		}

		public static explicit operator GLib.Value (Pango.Color boxed)
		{
			GLib.Value val = GLib.Value.Empty;
			val.Init (Pango.Color.GType);
			val.Val = boxed;
			return val;
		}

		public static explicit operator Pango.Color (GLib.Value val)
		{
			return (Pango.Color) val.Val;
		}

		[Obsolete("This is a no-op")]
		public Pango.Color Copy() {
			return this;
		}
#endregion
	}
}
