// $Author: asskoala $
// $Date: 2005/12/11 21:07:21 $
// $Revision: 1.1 $

using System;
using System.Drawing;

using Icarus.Graphics.Animation;

namespace Icarus.LUCIE
{
	/// <summary>
	/// This is a simple label that can be used to... well, label things.
	/// </summary>
	/// For those of you that have lived under a rock since before Windows 1.0 came out, a label
	/// is a piece of text that can be displayed at an arbitrary location on screen.
	/// For instance, it could be displayed next to this big red button and say something
	/// like: don't push this button!
	public class Label : AbstractComponent
	{
		/// <summary>
		/// The context used to render the label.
		/// </summary>
		private AbstractText mText;

		/// <summary>
		/// Creates a new label with black color and default font.
		/// </summary>
		/// <param name="text">The text of the label</param>
		public Label(string text) : this(text, Color.Black) { }

		/// <summary>
		/// Creates a new label with the specified color and default font.
		/// </summary>
		/// <param name="text"></param>
		/// <param name="c"></param>
		public Label(string text, Color c) : this(text, c, new Font(FontFamily.GenericSerif.Name, 12)) { }

		/// <summary>
		/// Creates a new label with the specified text, color and font. Note that the size of the label
		/// will be automagically set to fit the text. However, you still need to explicitly
		/// set the position, and make it visible and such.
		/// </summary>
		/// <param name="text">The text of the label</param>
		/// <param name="c">The color of the label</param>
		/// <param name="f">The font of the label</param>
		public Label(string text, Color c, Font f) 
		{
			mText = AnimationFactory.getInstance().makeText(text, c, f);
			this.Size = mText.GetSize();
		}

		/// <summary>
		/// The text string of the label.
		/// </summary>
		public string Text
		{
			get
			{
				return mText.GetText();
			}
		}

		protected override void RenderSelf(Rectangle coordinates, IRenderParameters parameters)
		{
			mText.Render(coordinates, parameters);
		}
	}
}
