using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Vortex.Wrapper.Direct3D;

namespace Vortex.Drawing {
	/// <summary>
	/// Defines event callback for drawing targets
	/// </summary>
	public delegate void DrawingTargetEventHandler(IDrawingTarget drawingTarget);


	/// <summary>
	/// Internal information about drawing target
	/// </summary>
	public sealed class TargetData {
		private Direct3DSurface9 _backBuffer;
		private Direct3DSurface9 _zBuffer;

		internal TargetData(Direct3DSurface9 backBuffer, Direct3DSurface9 zBuffer) {
			_backBuffer = backBuffer;
			_zBuffer = zBuffer;
		}

		internal Direct3DSurface9 BackBuffer {
			get { return _backBuffer; }
		}

		internal Direct3DSurface9 ZBuffer {
			get { return _zBuffer; }
		}
	}

	/// <summary>
	/// Interface which defines drawing target instance. Drawing target should provide target surface and Canvas to draw on it
	/// </summary>
	public interface IDrawingTarget {

		/// <summary>
		/// Gets the instance of canvas to draw on this target.
		/// </summary>
		/// <value>The canvas instance.</value>
		Canvas2D Canvas {
			get;
		}

		/// <summary>
		/// Gets the size of drawing target in pixels.
		/// </summary>
		/// <value>The size in pixels.</value>
		Size Size {
			get;
		}

		/// <summary>
		/// Returns the target pixel format of target.
		/// </summary>
		/// <value>The pixel format.</value>
		PixelFormat Format {
			get;
		}

		/// <summary>
		/// Gets a value indicating whether drawing target has Z buffer and supports Z-Effects.
		/// </summary>
		/// <value>
		/// 	<c>true</c> if this target has Z buffer; otherwise, <c>false</c>.
		/// </value>
		bool HasZBuffer {
			get;
		}

		/// <summary>
		/// Gets the drawing target internal data.
		/// </summary>
		/// <value>The drawing target data.</value>
		TargetData TargetData {
			get;
		}

		/// <summary>
		/// Occurs when drawing target surface is created.
		/// </summary>
		event DrawingTargetEventHandler OnCreateSurface;

		/// <summary>
		/// Occurs when drawing target surface is destroyed.
		/// </summary>
		event DrawingTargetEventHandler OnDestroySurface;

		/// <summary>
		/// Occurs when drawing target was resized. It is invoke after the new surface is created.
		/// </summary>
		event DrawingTargetEventHandler OnResizeSurface;

	}

}
