// 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 ColorChooserWidget : Gtk.Box, Gtk.IColorChooser {

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

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

		public ColorChooserWidget () : base (IntPtr.Zero)
		{
			if (GetType () != typeof (ColorChooserWidget)) {
				CreateNativeObject (Array.Empty<string> (), Array.Empty<GLib.Value> ());
				return;
			}
			Raw = gtk_color_chooser_widget_new();
		}

		[GLib.Property ("show-editor")]
		public bool ShowEditor {
			get {
				GLib.Value val = GetProperty ("show-editor");
				bool ret = (bool) val;
				val.Dispose ();
				return ret;
			}
			set {
				GLib.Value val = new GLib.Value(value);
				SetProperty("show-editor", val);
				val.Dispose ();
			}
		}


		// 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("_gtk_reserved1"
							, Gtk.Box.class_abi.Fields
							, (uint) sizeof( IntPtr ) // _gtk_reserved1
							, null
							, "_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"
							, "_gtk_reserved5"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved5"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved5
							, "_gtk_reserved4"
							, "_gtk_reserved6"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved6"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved6
							, "_gtk_reserved5"
							, "_gtk_reserved7"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved7"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved7
							, "_gtk_reserved6"
							, "_gtk_reserved8"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved8"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved8
							, "_gtk_reserved7"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_color_chooser_add_palette(IntPtr raw, int orientation, int colors_per_line, int n_colors, IntPtr colors);
		static d_gtk_color_chooser_add_palette gtk_color_chooser_add_palette = FuncLoader.LoadFunction<d_gtk_color_chooser_add_palette>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_color_chooser_add_palette"));

		public void AddPalette(Gtk.Orientation orientation, int colors_per_line, int n_colors, Gdk.RGBA colors) {
			IntPtr native_colors = GLib.Marshaller.StructureToPtrAlloc (colors);
			gtk_color_chooser_add_palette(Handle, (int) orientation, colors_per_line, n_colors, native_colors);
			Marshal.FreeHGlobal (native_colors);
		}

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

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

		[GLib.Property ("rgba")]
		public Gdk.RGBA Rgba {
			get  {
				Gdk.RGBA color;
				IntPtr native_color = Marshal.AllocHGlobal (Marshal.SizeOf<Gdk.RGBA>());
				gtk_color_chooser_get_rgba(Handle, native_color);
				color = Gdk.RGBA.New (native_color);
				Marshal.FreeHGlobal (native_color);
				return color;
			}
			set  {
				IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
				gtk_color_chooser_set_rgba(Handle, native_value);
				Marshal.FreeHGlobal (native_value);
			}
		}

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

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

		[GLib.Property ("use-alpha")]
		public bool UseAlpha {
			get  {
				bool raw_ret = gtk_color_chooser_get_use_alpha(Handle);
				bool ret = raw_ret;
				return ret;
			}
			set  {
				gtk_color_chooser_set_use_alpha(Handle, value);
			}
		}

		[GLib.Signal("color-activated")]
		public event Gtk.ColorActivatedHandler ColorActivated {
			add {
				this.AddSignalHandler ("color-activated", value, typeof (Gtk.ColorActivatedArgs));
			}
			remove {
				this.RemoveSignalHandler ("color-activated", value);
			}
		}

		static ColorActivatedNativeDelegate ColorActivated_cb_delegate;
		static ColorActivatedNativeDelegate ColorActivatedVMCallback {
			get {
				if (ColorActivated_cb_delegate == null)
					ColorActivated_cb_delegate = new ColorActivatedNativeDelegate (ColorActivated_cb);
				return ColorActivated_cb_delegate;
			}
		}

		static void OverrideColorActivated (GLib.GType gtype)
		{
			OverrideColorActivated (gtype, ColorActivatedVMCallback);
		}

		static void OverrideColorActivated (GLib.GType gtype, ColorActivatedNativeDelegate callback)
		{
			OverrideVirtualMethod (gtype, "color-activated", callback);
		}
		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void ColorActivatedNativeDelegate (IntPtr inst, IntPtr color);

		static void ColorActivated_cb (IntPtr inst, IntPtr color)
		{
			try {
				Gtk.ColorChooserWidget __obj = GLib.Object.GetObject (inst, false) as Gtk.ColorChooserWidget;
				__obj.OnColorActivated (Gdk.RGBA.New (color));
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gtk.ColorChooserWidget), ConnectionMethod="OverrideColorActivated")]
		protected virtual void OnColorActivated (Gdk.RGBA color)
		{
			InternalColorActivated (color);
		}

		private void InternalColorActivated (Gdk.RGBA color)
		{
			GLib.Value ret = GLib.Value.Empty;
			GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
			GLib.Value[] vals = new GLib.Value [2];
			vals [0] = new GLib.Value (this);
			inst_and_params.Append (vals [0]);
			vals [1] = new GLib.Value (color);
			inst_and_params.Append (vals [1]);
			g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
			foreach (GLib.Value v in vals)
				v.Dispose ();
		}


		// 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.Box.abi_info.Fields
							, (uint) sizeof( IntPtr ) // priv
							, null
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
