// 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 GlyphItem : IEquatable<GlyphItem> {

		private IntPtr _item;
		public Pango.Item Item {
			get {
				return _item == IntPtr.Zero ? null : (Pango.Item) GLib.Opaque.GetOpaque (_item, typeof (Pango.Item), false);
			}
			set {
				_item = value == null ? IntPtr.Zero : value.Handle;
			}
		}
		private IntPtr _glyphs;
		public Pango.GlyphString Glyphs {
			get {
				return _glyphs == IntPtr.Zero ? null : (Pango.GlyphString) GLib.Opaque.GetOpaque (_glyphs, typeof (Pango.GlyphString), false);
			}
			set {
				_glyphs = value == null ? IntPtr.Zero : value.Handle;
			}
		}

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_pango_glyph_item_get_logical_widths(IntPtr raw, IntPtr text, out int logical_widths);
		static d_pango_glyph_item_get_logical_widths pango_glyph_item_get_logical_widths = FuncLoader.LoadFunction<d_pango_glyph_item_get_logical_widths>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_glyph_item_get_logical_widths"));

		public int GetLogicalWidths(string text) {
			IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<Pango.GlyphItem>());
			System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
			int logical_widths;
			IntPtr native_text = GLib.Marshaller.StringToPtrGStrdup (text);
			pango_glyph_item_get_logical_widths(this_as_native, native_text, out logical_widths);
			ReadNative (this_as_native, ref this);
			System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
			GLib.Marshaller.Free (native_text);
			return logical_widths;
		}

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_pango_glyph_item_letter_space(IntPtr raw, IntPtr text, IntPtr log_attrs, int letter_spacing);
		static d_pango_glyph_item_letter_space pango_glyph_item_letter_space = FuncLoader.LoadFunction<d_pango_glyph_item_letter_space>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_glyph_item_letter_space"));

		public void LetterSpace(string text, Pango.LogAttr log_attrs, int letter_spacing) {
			IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<Pango.GlyphItem>());
			System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
			IntPtr native_text = GLib.Marshaller.StringToPtrGStrdup (text);
			IntPtr native_log_attrs = GLib.Marshaller.StructureToPtrAlloc (log_attrs);
			pango_glyph_item_letter_space(this_as_native, native_text, native_log_attrs, letter_spacing);
			ReadNative (this_as_native, ref this);
			System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
			GLib.Marshaller.Free (native_text);
			Marshal.FreeHGlobal (native_log_attrs);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_pango_glyph_item_split(IntPtr raw, IntPtr text, int split_index);
		static d_pango_glyph_item_split pango_glyph_item_split = FuncLoader.LoadFunction<d_pango_glyph_item_split>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_glyph_item_split"));

		public Pango.GlyphItem Split(string text, int split_index) {
			IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<Pango.GlyphItem>());
			System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
			IntPtr native_text = GLib.Marshaller.StringToPtrGStrdup (text);
			IntPtr raw_ret = pango_glyph_item_split(this_as_native, native_text, split_index);
			Pango.GlyphItem ret = Pango.GlyphItem.New (raw_ret);
			ReadNative (this_as_native, ref this);
			System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
			GLib.Marshaller.Free (native_text);
			return ret;
		}

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

		public bool Equals (GlyphItem other)
		{
			return true && Item.Equals (other.Item) && Glyphs.Equals (other.Glyphs);
		}

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

		public override int GetHashCode ()
		{
			return this.GetType ().FullName.GetHashCode () ^ Item.GetHashCode () ^ Glyphs.GetHashCode ();
		}

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

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

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