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

namespace Gst.Video {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class VideoOverlayAdapter : GLib.GInterfaceAdapter, Gst.Video.IVideoOverlay {

		[StructLayout (LayoutKind.Sequential)]
		struct GstVideoOverlayInterface {
			public ExposeNativeDelegate Expose;
			public HandleEventsNativeDelegate HandleEvents;
			public SetRenderRectangleNativeDelegate SetRenderRectangle;
			public SetWindowHandleNativeDelegate SetWindowHandle;
		}

		static GstVideoOverlayInterface iface;

		static VideoOverlayAdapter ()
		{
			GLib.GType.Register (_gtype, typeof (VideoOverlayAdapter));
			iface.Expose = new ExposeNativeDelegate (Expose_cb);
			iface.HandleEvents = new HandleEventsNativeDelegate (HandleEvents_cb);
			iface.SetRenderRectangle = new SetRenderRectangleNativeDelegate (SetRenderRectangle_cb);
			iface.SetWindowHandle = new SetWindowHandleNativeDelegate (SetWindowHandle_cb);
		}

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void HandleEventsNativeDelegate (IntPtr inst, bool handle_events);

		static void HandleEvents_cb (IntPtr inst, bool handle_events)
		{
			try {
				IVideoOverlayImplementor __obj = GLib.Object.GetObject (inst, false) as IVideoOverlayImplementor;
				__obj.HandleEvents (handle_events);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

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

		static void SetRenderRectangle_cb (IntPtr inst, int x, int y, int width, int height)
		{
			try {
				IVideoOverlayImplementor __obj = GLib.Object.GetObject (inst, false) as IVideoOverlayImplementor;
				__obj.SetRenderRectangle (x, y, width, height);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SetWindowHandleNativeDelegate (IntPtr inst, IntPtr handle);

		static void SetWindowHandle_cb (IntPtr inst, IntPtr handle)
		{
			try {
				IVideoOverlayImplementor __obj = GLib.Object.GetObject (inst, false) as IVideoOverlayImplementor;
				__obj.WindowHandle = handle;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		static int class_offset = 2 * IntPtr.Size;

		static void Initialize (IntPtr ptr, IntPtr data)
		{
			IntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset);
			GstVideoOverlayInterface native_iface = (GstVideoOverlayInterface) Marshal.PtrToStructure (ifaceptr, typeof (GstVideoOverlayInterface));
			native_iface.Expose = iface.Expose;
			native_iface.HandleEvents = iface.HandleEvents;
			native_iface.SetRenderRectangle = iface.SetRenderRectangle;
			native_iface.SetWindowHandle = iface.SetWindowHandle;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}

		GLib.Object implementor;

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

		public VideoOverlayAdapter (IVideoOverlayImplementor 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 VideoOverlayAdapter (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);
		}

		[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_video_overlay_get_type();

		private static GLib.GType _gtype = new GLib.GType (gst_video_overlay_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 IVideoOverlay GetObject (IntPtr handle, bool owned)
		{
			GLib.Object obj = GLib.Object.GetObject (handle, owned);
			return GetObject (obj);
		}

		public static IVideoOverlay GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj is IVideoOverlayImplementor)
				return new VideoOverlayAdapter (obj as IVideoOverlayImplementor);
			else if (obj as IVideoOverlay == null)
				return new VideoOverlayAdapter (obj.Handle);
			else
				return obj as IVideoOverlay;
		}

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

		[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_video_overlay_set_property(IntPtr _object, int last_prop_id, uint property_id, IntPtr value);

		public static bool SetProperty(GLib.Object _object, int last_prop_id, uint property_id, GLib.Value value) {
			IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
			bool raw_ret = gst_video_overlay_set_property(_object == null ? IntPtr.Zero : _object.Handle, last_prop_id, property_id, native_value);
			bool ret = raw_ret;
			Marshal.FreeHGlobal (native_value);
			return ret;
		}

		[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_video_overlay_expose(IntPtr raw);

		public void Expose() {
			gst_video_overlay_expose(Handle);
		}

		[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_video_overlay_got_window_handle(IntPtr raw, IntPtr handle);

		public void GotWindowHandle(IntPtr handle) {
			gst_video_overlay_got_window_handle(Handle, handle);
		}

		[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_video_overlay_handle_events(IntPtr raw, bool handle_events);

		public void HandleEvents(bool handle_events) {
			gst_video_overlay_handle_events(Handle, handle_events);
		}

		[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_video_overlay_prepare_window_handle(IntPtr raw);

		public void PrepareWindowHandle() {
			gst_video_overlay_prepare_window_handle(Handle);
		}

		[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_video_overlay_set_render_rectangle(IntPtr raw, int x, int y, int width, int height);

		public bool SetRenderRectangle(int x, int y, int width, int height) {
			bool raw_ret = gst_video_overlay_set_render_rectangle(Handle, x, y, width, height);
			bool ret = raw_ret;
			return ret;
		}

		[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_video_overlay_set_window_handle(IntPtr raw, IntPtr handle);

		public IntPtr WindowHandle { 
			set {
				gst_video_overlay_set_window_handle(Handle, value);
			}
		}

#endregion
	}
}