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

namespace Vortex.SceneFramework.Gui {
	
	/// <summary>
	/// Very simple widget which can contain multi-line text with special alignment
	/// </summary>
	public class Label : ViewNode, ITextNode {
		private string _text = "";

		/// <summary>
		/// Gets or sets the label text.
		/// </summary>
		/// <value>The label text.</value>
		public virtual string Text {
			get { return _text; }
			set {
				if (null == value) throw new ArgumentNullException("Text");
				if (_text != value) {
					_text = value;
					if (null != OnChangeText) {
						OnChangeText(this);
					}
				}
			}
		}

		/// <summary>
		/// Label drawing method
		/// </summary>
		/// <param name="canvas">The canvas to use for label drawing.</param>
		protected override void Draw(Canvas2D canvas) {
			//only existing text can be drawn
			if (!string.IsNullOrEmpty(Text)) {
				DrawText(canvas, BoundingBox, Text);
			}
		}

		#region Events

		/// <summary>
		/// Occurs when label text is changed.
		/// </summary>
		public event GraphEventHandler OnChangeText;

		#endregion
	}
}
