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

namespace Atk {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class ComponentAdapter : GLib.GInterfaceAdapter, Atk.IComponent {

		[StructLayout (LayoutKind.Sequential)]
		struct AtkComponentIface {
			public AddFocusHandlerNativeDelegate AddFocusHandler;
			public ContainsNativeDelegate Contains;
			public RefAccessibleAtPointNativeDelegate RefAccessibleAtPoint;
			public GetExtentsNativeDelegate GetExtents;
			public GetPositionNativeDelegate GetPosition;
			public GetSizeNativeDelegate GetSize;
			public GrabFocusNativeDelegate GrabFocus;
			public RemoveFocusHandlerNativeDelegate RemoveFocusHandler;
			public SetExtentsNativeDelegate SetExtents;
			public SetPositionNativeDelegate SetPosition;
			public SetSizeNativeDelegate SetSize;
			public GetLayerNativeDelegate GetLayer;
			public GetMdiZorderNativeDelegate GetMdiZorder;
			IntPtr BoundsChanged;
			public GetAlphaNativeDelegate GetAlpha;
		}

		static AtkComponentIface iface;

		static ComponentAdapter ()
		{
			GLib.GType.Register (_gtype, typeof (ComponentAdapter));
			iface.AddFocusHandler = new AddFocusHandlerNativeDelegate (AddFocusHandler_cb);
			iface.Contains = new ContainsNativeDelegate (Contains_cb);
			iface.RefAccessibleAtPoint = new RefAccessibleAtPointNativeDelegate (RefAccessibleAtPoint_cb);
			iface.GetExtents = new GetExtentsNativeDelegate (GetExtents_cb);
			iface.GetPosition = new GetPositionNativeDelegate (GetPosition_cb);
			iface.GetSize = new GetSizeNativeDelegate (GetSize_cb);
			iface.GrabFocus = new GrabFocusNativeDelegate (GrabFocus_cb);
			iface.RemoveFocusHandler = new RemoveFocusHandlerNativeDelegate (RemoveFocusHandler_cb);
			iface.SetExtents = new SetExtentsNativeDelegate (SetExtents_cb);
			iface.SetPosition = new SetPositionNativeDelegate (SetPosition_cb);
			iface.SetSize = new SetSizeNativeDelegate (SetSize_cb);
			iface.GetLayer = new GetLayerNativeDelegate (GetLayer_cb);
			iface.GetMdiZorder = new GetMdiZorderNativeDelegate (GetMdiZorder_cb);
			iface.GetAlpha = new GetAlphaNativeDelegate (GetAlpha_cb);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate uint AddFocusHandlerNativeDelegate (IntPtr inst, AtkSharp.FocusHandlerNative handler);

		static uint AddFocusHandler_cb (IntPtr inst, AtkSharp.FocusHandlerNative handler)
		{
			try {
				IComponentImplementor __obj = GLib.Object.GetObject (inst, false) as IComponentImplementor;
				uint __result;
				AtkSharp.FocusHandlerInvoker handler_invoker = new AtkSharp.FocusHandlerInvoker (handler);
				__result = __obj.AddFocusHandler (handler_invoker.Handler);
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool ContainsNativeDelegate (IntPtr inst, int x, int y, int coord_type);

		static bool Contains_cb (IntPtr inst, int x, int y, int coord_type)
		{
			try {
				IComponentImplementor __obj = GLib.Object.GetObject (inst, false) as IComponentImplementor;
				bool __result;
				__result = __obj.Contains (x, y, (Atk.CoordType) coord_type);
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr RefAccessibleAtPointNativeDelegate (IntPtr inst, int x, int y, int coord_type);

		static IntPtr RefAccessibleAtPoint_cb (IntPtr inst, int x, int y, int coord_type)
		{
			try {
				IComponentImplementor __obj = GLib.Object.GetObject (inst, false) as IComponentImplementor;
				Atk.Object __result;
				__result = __obj.RefAccessibleAtPoint (x, y, (Atk.CoordType) coord_type);
				return __result == null ? IntPtr.Zero : __result.OwnedHandle;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void GetExtentsNativeDelegate (IntPtr inst, out int x, out int y, out int width, out int height, int coord_type);

		static void GetExtents_cb (IntPtr inst, out int x, out int y, out int width, out int height, int coord_type)
		{
			try {
				IComponentImplementor __obj = GLib.Object.GetObject (inst, false) as IComponentImplementor;
				__obj.GetExtents (out x, out y, out width, out height, (Atk.CoordType) coord_type);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void GetSizeNativeDelegate (IntPtr inst, out int width, out int height);

		static void GetSize_cb (IntPtr inst, out int width, out int height)
		{
			try {
				IComponentImplementor __obj = GLib.Object.GetObject (inst, false) as IComponentImplementor;
				__obj.GetSize (out width, out height);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool GrabFocusNativeDelegate (IntPtr inst);

		static bool GrabFocus_cb (IntPtr inst)
		{
			try {
				IComponentImplementor __obj = GLib.Object.GetObject (inst, false) as IComponentImplementor;
				bool __result;
				__result = __obj.GrabFocus ();
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void RemoveFocusHandlerNativeDelegate (IntPtr inst, uint handler_id);

		static void RemoveFocusHandler_cb (IntPtr inst, uint handler_id)
		{
			try {
				IComponentImplementor __obj = GLib.Object.GetObject (inst, false) as IComponentImplementor;
				__obj.RemoveFocusHandler (handler_id);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool SetExtentsNativeDelegate (IntPtr inst, int x, int y, int width, int height, int coord_type);

		static bool SetExtents_cb (IntPtr inst, int x, int y, int width, int height, int coord_type)
		{
			try {
				IComponentImplementor __obj = GLib.Object.GetObject (inst, false) as IComponentImplementor;
				bool __result;
				__result = __obj.SetExtents (x, y, width, height, (Atk.CoordType) coord_type);
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool SetPositionNativeDelegate (IntPtr inst, int x, int y, int coord_type);

		static bool SetPosition_cb (IntPtr inst, int x, int y, int coord_type)
		{
			try {
				IComponentImplementor __obj = GLib.Object.GetObject (inst, false) as IComponentImplementor;
				bool __result;
				__result = __obj.SetPosition (x, y, (Atk.CoordType) coord_type);
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool SetSizeNativeDelegate (IntPtr inst, int width, int height);

		static bool SetSize_cb (IntPtr inst, int width, int height)
		{
			try {
				IComponentImplementor __obj = GLib.Object.GetObject (inst, false) as IComponentImplementor;
				bool __result;
				__result = __obj.SetSize (width, height);
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int GetLayerNativeDelegate (IntPtr inst);

		static int GetLayer_cb (IntPtr inst)
		{
			try {
				IComponentImplementor __obj = GLib.Object.GetObject (inst, false) as IComponentImplementor;
				Atk.Layer __result;
				__result = __obj.Layer;
				return (int) __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int GetMdiZorderNativeDelegate (IntPtr inst);

		static int GetMdiZorder_cb (IntPtr inst)
		{
			try {
				IComponentImplementor __obj = GLib.Object.GetObject (inst, false) as IComponentImplementor;
				int __result;
				__result = __obj.MdiZorder;
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate double GetAlphaNativeDelegate (IntPtr inst);

		static double GetAlpha_cb (IntPtr inst)
		{
			try {
				IComponentImplementor __obj = GLib.Object.GetObject (inst, false) as IComponentImplementor;
				double __result;
				__result = __obj.Alpha;
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		static int class_offset = 2 * IntPtr.Size;

		static void Initialize (IntPtr ptr, IntPtr data)
		{
			IntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset);
			AtkComponentIface native_iface = (AtkComponentIface) Marshal.PtrToStructure (ifaceptr, typeof (AtkComponentIface));
			native_iface.AddFocusHandler = iface.AddFocusHandler;
			native_iface.Contains = iface.Contains;
			native_iface.RefAccessibleAtPoint = iface.RefAccessibleAtPoint;
			native_iface.GetExtents = iface.GetExtents;
			native_iface.GetPosition = iface.GetPosition;
			native_iface.GetSize = iface.GetSize;
			native_iface.GrabFocus = iface.GrabFocus;
			native_iface.RemoveFocusHandler = iface.RemoveFocusHandler;
			native_iface.SetExtents = iface.SetExtents;
			native_iface.SetPosition = iface.SetPosition;
			native_iface.SetSize = iface.SetSize;
			native_iface.GetLayer = iface.GetLayer;
			native_iface.GetMdiZorder = iface.GetMdiZorder;
			native_iface.GetAlpha = iface.GetAlpha;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}

		GLib.Object implementor;

		public ComponentAdapter ()
		{
			InitHandler = new GLib.GInterfaceInitHandler (Initialize);
		}

		public ComponentAdapter (IComponentImplementor implementor)
		{
			if (implementor == null)
				throw new ArgumentNullException ("implementor");
			else if (!(implementor is GLib.Object))
				throw new ArgumentException ("implementor must be a subclass of GLib.Object");
			this.implementor = implementor as GLib.Object;
		}

		public ComponentAdapter (IntPtr handle)
		{
			if (!_gtype.IsInstance (handle))
				throw new ArgumentException ("The gobject doesn't implement the GInterface of this adapter", "handle");
			implementor = GLib.Object.GetObject (handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_atk_component_get_type();
		static d_atk_component_get_type atk_component_get_type = FuncLoader.LoadFunction<d_atk_component_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_component_get_type"));

		private static GLib.GType _gtype = new GLib.GType (atk_component_get_type ());

		public static GLib.GType GType {
			get {
				return _gtype;
			}
		}

		public override GLib.GType GInterfaceGType {
			get {
				return _gtype;
			}
		}

		public override IntPtr Handle {
			get {
				return implementor.Handle;
			}
		}

		public IntPtr OwnedHandle {
			get {
				return implementor.OwnedHandle;
			}
		}

		public static IComponent GetObject (IntPtr handle, bool owned)
		{
			GLib.Object obj = GLib.Object.GetObject (handle, owned);
			return GetObject (obj);
		}

		public static IComponent GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj is IComponentImplementor)
				return new ComponentAdapter (obj as IComponentImplementor);
			else if (obj as IComponent == null)
				return new ComponentAdapter (obj.Handle);
			else
				return obj as IComponent;
		}

		public IComponentImplementor Implementor {
			get {
				return implementor as IComponentImplementor;
			}
		}

		[GLib.Signal("bounds_changed")]
		public event Atk.BoundsChangedHandler BoundsChanged {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("bounds_changed", value, typeof (Atk.BoundsChangedArgs));
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("bounds_changed", value);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate uint d_atk_component_add_focus_handler(IntPtr raw, AtkSharp.FocusHandlerNative handler);
		static d_atk_component_add_focus_handler atk_component_add_focus_handler = FuncLoader.LoadFunction<d_atk_component_add_focus_handler>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_component_add_focus_handler"));

		[Obsolete]
		public uint AddFocusHandler(Atk.FocusHandler handler) {
			AtkSharp.FocusHandlerWrapper handler_wrapper = new AtkSharp.FocusHandlerWrapper (handler);
			uint raw_ret = atk_component_add_focus_handler(Handle, handler_wrapper.NativeDelegate);
			uint ret = raw_ret;
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_atk_component_contains(IntPtr raw, int x, int y, int coord_type);
		static d_atk_component_contains atk_component_contains = FuncLoader.LoadFunction<d_atk_component_contains>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_component_contains"));

		public bool Contains(int x, int y, Atk.CoordType coord_type) {
			bool raw_ret = atk_component_contains(Handle, x, y, (int) coord_type);
			bool ret = raw_ret;
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate double d_atk_component_get_alpha(IntPtr raw);
		static d_atk_component_get_alpha atk_component_get_alpha = FuncLoader.LoadFunction<d_atk_component_get_alpha>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_component_get_alpha"));

		public double Alpha { 
			get {
				double raw_ret = atk_component_get_alpha(Handle);
				double ret = raw_ret;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_atk_component_get_extents(IntPtr raw, out int x, out int y, out int width, out int height, int coord_type);
		static d_atk_component_get_extents atk_component_get_extents = FuncLoader.LoadFunction<d_atk_component_get_extents>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_component_get_extents"));

		public void GetExtents(out int x, out int y, out int width, out int height, Atk.CoordType coord_type) {
			atk_component_get_extents(Handle, out x, out y, out width, out height, (int) coord_type);
		}

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

		public Atk.Layer Layer { 
			get {
				int raw_ret = atk_component_get_layer(Handle);
				Atk.Layer ret = (Atk.Layer) raw_ret;
				return ret;
			}
		}

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

		public int MdiZorder { 
			get {
				int raw_ret = atk_component_get_mdi_zorder(Handle);
				int ret = raw_ret;
				return ret;
			}
		}

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

		[Obsolete]
		public void GetPosition(out int x, out int y, Atk.CoordType coord_type) {
			atk_component_get_position(Handle, out x, out y, (int) coord_type);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_atk_component_get_size(IntPtr raw, out int width, out int height);
		static d_atk_component_get_size atk_component_get_size = FuncLoader.LoadFunction<d_atk_component_get_size>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_component_get_size"));

		[Obsolete]
		public void GetSize(out int width, out int height) {
			atk_component_get_size(Handle, out width, out height);
		}

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

		public bool GrabFocus() {
			bool raw_ret = atk_component_grab_focus(Handle);
			bool ret = raw_ret;
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_atk_component_ref_accessible_at_point(IntPtr raw, int x, int y, int coord_type);
		static d_atk_component_ref_accessible_at_point atk_component_ref_accessible_at_point = FuncLoader.LoadFunction<d_atk_component_ref_accessible_at_point>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_component_ref_accessible_at_point"));

		public Atk.Object RefAccessibleAtPoint(int x, int y, Atk.CoordType coord_type) {
			IntPtr raw_ret = atk_component_ref_accessible_at_point(Handle, x, y, (int) coord_type);
			Atk.Object ret = GLib.Object.GetObject(raw_ret, true) as Atk.Object;
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_atk_component_remove_focus_handler(IntPtr raw, uint handler_id);
		static d_atk_component_remove_focus_handler atk_component_remove_focus_handler = FuncLoader.LoadFunction<d_atk_component_remove_focus_handler>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_component_remove_focus_handler"));

		[Obsolete]
		public void RemoveFocusHandler(uint handler_id) {
			atk_component_remove_focus_handler(Handle, handler_id);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_atk_component_set_extents(IntPtr raw, int x, int y, int width, int height, int coord_type);
		static d_atk_component_set_extents atk_component_set_extents = FuncLoader.LoadFunction<d_atk_component_set_extents>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_component_set_extents"));

		public bool SetExtents(int x, int y, int width, int height, Atk.CoordType coord_type) {
			bool raw_ret = atk_component_set_extents(Handle, x, y, width, height, (int) coord_type);
			bool ret = raw_ret;
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_atk_component_set_position(IntPtr raw, int x, int y, int coord_type);
		static d_atk_component_set_position atk_component_set_position = FuncLoader.LoadFunction<d_atk_component_set_position>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_component_set_position"));

		public bool SetPosition(int x, int y, Atk.CoordType coord_type) {
			bool raw_ret = atk_component_set_position(Handle, x, y, (int) coord_type);
			bool ret = raw_ret;
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_atk_component_set_size(IntPtr raw, int width, int height);
		static d_atk_component_set_size atk_component_set_size = FuncLoader.LoadFunction<d_atk_component_set_size>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_component_set_size"));

		public bool SetSize(int width, int height) {
			bool raw_ret = atk_component_set_size(Handle, width, height);
			bool ret = raw_ret;
			return ret;
		}

#endregion
	}
}
