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

namespace Gtk {

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

#region Autogenerated code
	public partial class Scale : Gtk.Range {

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_scale_new(int orientation, IntPtr adjustment);
		static d_gtk_scale_new gtk_scale_new = FuncLoader.LoadFunction<d_gtk_scale_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_scale_new"));

		public Scale (Gtk.Orientation orientation, Gtk.Adjustment adjustment) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (Scale)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				names.Add ("adjustment");
				vals.Add (new GLib.Value (adjustment));
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			Raw = gtk_scale_new((int) orientation, adjustment == null ? IntPtr.Zero : adjustment.Handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_scale_new_with_range(int orientation, double min, double max, double step);
		static d_gtk_scale_new_with_range gtk_scale_new_with_range = FuncLoader.LoadFunction<d_gtk_scale_new_with_range>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_scale_new_with_range"));

		public Scale (Gtk.Orientation orientation, double min, double max, double step) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (Scale)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			Raw = gtk_scale_new_with_range((int) orientation, min, max, step);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_scale_set_digits(IntPtr raw, int digits);
		static d_gtk_scale_set_digits gtk_scale_set_digits = FuncLoader.LoadFunction<d_gtk_scale_set_digits>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_scale_set_digits"));

		[GLib.Property ("digits")]
		public int Digits {
			get  {
				int raw_ret = gtk_scale_get_digits(Handle);
				int ret = raw_ret;
				return ret;
			}
			set  {
				gtk_scale_set_digits(Handle, value);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_scale_get_draw_value(IntPtr raw);
		static d_gtk_scale_get_draw_value gtk_scale_get_draw_value = FuncLoader.LoadFunction<d_gtk_scale_get_draw_value>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_scale_get_draw_value"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_scale_set_draw_value(IntPtr raw, bool draw_value);
		static d_gtk_scale_set_draw_value gtk_scale_set_draw_value = FuncLoader.LoadFunction<d_gtk_scale_set_draw_value>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_scale_set_draw_value"));

		[GLib.Property ("draw-value")]
		public bool DrawValue {
			get  {
				bool raw_ret = gtk_scale_get_draw_value(Handle);
				bool ret = raw_ret;
				return ret;
			}
			set  {
				gtk_scale_set_draw_value(Handle, value);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_scale_get_has_origin(IntPtr raw);
		static d_gtk_scale_get_has_origin gtk_scale_get_has_origin = FuncLoader.LoadFunction<d_gtk_scale_get_has_origin>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_scale_get_has_origin"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_scale_set_has_origin(IntPtr raw, bool has_origin);
		static d_gtk_scale_set_has_origin gtk_scale_set_has_origin = FuncLoader.LoadFunction<d_gtk_scale_set_has_origin>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_scale_set_has_origin"));

		[GLib.Property ("has-origin")]
		public bool HasOrigin {
			get  {
				bool raw_ret = gtk_scale_get_has_origin(Handle);
				bool ret = raw_ret;
				return ret;
			}
			set  {
				gtk_scale_set_has_origin(Handle, value);
			}
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_scale_set_value_pos(IntPtr raw, int pos);
		static d_gtk_scale_set_value_pos gtk_scale_set_value_pos = FuncLoader.LoadFunction<d_gtk_scale_set_value_pos>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_scale_set_value_pos"));

		[GLib.Property ("value-pos")]
		public Gtk.PositionType ValuePos {
			get  {
				int raw_ret = gtk_scale_get_value_pos(Handle);
				Gtk.PositionType ret = (Gtk.PositionType) raw_ret;
				return ret;
			}
			set  {
				gtk_scale_set_value_pos(Handle, (int) value);
			}
		}

		[Obsolete]
		public int SliderLength {
			get {
				var val = (int)StyleGetProperty("slider-length");
				return val;
			}
		}

		[Obsolete]
		public int ValueSpacing {
			get {
				var val = (int)StyleGetProperty("value-spacing");
				return val;
			}
		}

		[GLib.Signal("format-value")]
		public event Gtk.FormatValueHandler FormatValue {
			add {
				this.AddSignalHandler ("format-value", value, typeof (Gtk.FormatValueArgs));
			}
			remove {
				this.RemoveSignalHandler ("format-value", value);
			}
		}

		static FormatValueNativeDelegate FormatValue_cb_delegate;
		static FormatValueNativeDelegate FormatValueVMCallback {
			get {
				if (FormatValue_cb_delegate == null)
					FormatValue_cb_delegate = new FormatValueNativeDelegate (FormatValue_cb);
				return FormatValue_cb_delegate;
			}
		}

		static void OverrideFormatValue (GLib.GType gtype)
		{
			OverrideFormatValue (gtype, FormatValueVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr FormatValueNativeDelegate (IntPtr inst, double value);

		static IntPtr FormatValue_cb (IntPtr inst, double value)
		{
			try {
				Scale __obj = GLib.Object.GetObject (inst, false) as Scale;
				string __result;
				__result = __obj.OnFormatValue (value);
				return GLib.Marshaller.StringToPtrGStrdup(__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gtk.Scale), ConnectionMethod="OverrideFormatValue")]
		protected virtual string OnFormatValue (double value)
		{
			return InternalFormatValue (value);
		}

		private string InternalFormatValue (double value)
		{
			FormatValueNativeDelegate unmanaged = class_abi.BaseOverride<FormatValueNativeDelegate>(this.LookupGType(), "format_value");
			if (unmanaged == null) return null;

			IntPtr __result = unmanaged (this.Handle, value);
			return GLib.Marshaller.PtrToStringGFree(__result);
		}

		static DrawValueNativeDelegate DrawValue_cb_delegate;
		static DrawValueNativeDelegate DrawValueVMCallback {
			get {
				if (DrawValue_cb_delegate == null)
					DrawValue_cb_delegate = new DrawValueNativeDelegate (DrawValue_cb);
				return DrawValue_cb_delegate;
			}
		}

		static void OverrideDrawValue (GLib.GType gtype)
		{
			OverrideDrawValue (gtype, DrawValueVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void DrawValueNativeDelegate (IntPtr inst);

		static void DrawValue_cb (IntPtr inst)
		{
			try {
				Scale __obj = GLib.Object.GetObject (inst, false) as Scale;
				__obj.OnDrawValue ();
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gtk.Scale), ConnectionMethod="OverrideDrawValue")]
		protected virtual void OnDrawValue ()
		{
			InternalDrawValue ();
		}

		private void InternalDrawValue ()
		{
			DrawValueNativeDelegate unmanaged = class_abi.BaseOverride<DrawValueNativeDelegate>(this.LookupGType(), "draw_value");
			if (unmanaged == null) return;

			unmanaged (this.Handle);
		}

		static GetLayoutOffsetsNativeDelegate GetLayoutOffsets_cb_delegate;
		static GetLayoutOffsetsNativeDelegate GetLayoutOffsetsVMCallback {
			get {
				if (GetLayoutOffsets_cb_delegate == null)
					GetLayoutOffsets_cb_delegate = new GetLayoutOffsetsNativeDelegate (GetLayoutOffsets_cb);
				return GetLayoutOffsets_cb_delegate;
			}
		}

		static void OverrideGetLayoutOffsets (GLib.GType gtype)
		{
			OverrideGetLayoutOffsets (gtype, GetLayoutOffsetsVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void GetLayoutOffsetsNativeDelegate (IntPtr inst, out int x, out int y);

		static void GetLayoutOffsets_cb (IntPtr inst, out int x, out int y)
		{
			try {
				Scale __obj = GLib.Object.GetObject (inst, false) as Scale;
				__obj.OnGetLayoutOffsets (out x, out y);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gtk.Scale), ConnectionMethod="OverrideGetLayoutOffsets")]
		protected virtual void OnGetLayoutOffsets (out int x, out int y)
		{
			InternalGetLayoutOffsets (out x, out y);
		}

		private void InternalGetLayoutOffsets (out int x, out int y)
		{
			GetLayoutOffsetsNativeDelegate unmanaged = class_abi.BaseOverride<GetLayoutOffsetsNativeDelegate>(this.LookupGType(), "get_layout_offsets");
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			unmanaged (this.Handle, out x, out y);
		}


		// 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("format_value"
							, Gtk.Range.class_abi.Fields
							, (uint) sizeof( IntPtr ) // format_value
							, null
							, "draw_value"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("draw_value"
							, -1
							, (uint) sizeof( IntPtr ) // draw_value
							, "format_value"
							, "get_layout_offsets"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("get_layout_offsets"
							, -1
							, (uint) sizeof( IntPtr ) // get_layout_offsets
							, "draw_value"
							, "_gtk_reserved1"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved1"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved1
							, "get_layout_offsets"
							, "_gtk_reserved2"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved2"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved2
							, "_gtk_reserved1"
							, "_gtk_reserved3"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved3"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved3
							, "_gtk_reserved2"
							, "_gtk_reserved4"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved4"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved4
							, "_gtk_reserved3"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_scale_add_mark(IntPtr raw, double value, int position, IntPtr markup);
		static d_gtk_scale_add_mark gtk_scale_add_mark = FuncLoader.LoadFunction<d_gtk_scale_add_mark>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_scale_add_mark"));

		public void AddMark(double value, Gtk.PositionType position, string markup) {
			IntPtr native_markup = GLib.Marshaller.StringToPtrGStrdup (markup);
			gtk_scale_add_mark(Handle, value, (int) position, native_markup);
			GLib.Marshaller.Free (native_markup);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_scale_clear_marks(IntPtr raw);
		static d_gtk_scale_clear_marks gtk_scale_clear_marks = FuncLoader.LoadFunction<d_gtk_scale_clear_marks>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_scale_clear_marks"));

		public void ClearMarks() {
			gtk_scale_clear_marks(Handle);
		}

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

		public Pango.Layout Layout { 
			get {
				IntPtr raw_ret = gtk_scale_get_layout(Handle);
				Pango.Layout ret = GLib.Object.GetObject(raw_ret) as Pango.Layout;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_scale_get_layout_offsets(IntPtr raw, out int x, out int y);
		static d_gtk_scale_get_layout_offsets gtk_scale_get_layout_offsets = FuncLoader.LoadFunction<d_gtk_scale_get_layout_offsets>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_scale_get_layout_offsets"));

		public void GetLayoutOffsets(out int x, out int y) {
			gtk_scale_get_layout_offsets(Handle, out x, out y);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_scale_get_type();
		static d_gtk_scale_get_type gtk_scale_get_type = FuncLoader.LoadFunction<d_gtk_scale_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_scale_get_type"));

		public static new GLib.GType GType { 
			get {
				IntPtr raw_ret = gtk_scale_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 (new List<GLib.AbiField>{ 
						new GLib.AbiField("priv"
							, Gtk.Range.abi_info.Fields
							, (uint) sizeof( IntPtr ) // priv
							, null
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
