//--------------------------------------
//               PowerUI
//
//        For documentation or 
//    if you have any issues, visit
//        powerUI.kulestar.com
//
//    Copyright  2013 Kulestar Ltd
//          www.kulestar.com
//--------------------------------------

using System;


namespace Css.Units{
	
	/// <summary>
	/// Represents an instance of a viewport relative value, e.g. vw.
	/// </summary>
	
	public class ViewPortWidthUnit:ViewPortUnit{
		
		public override float DisplayNumber{
			get{
				return (RawValue * 100f);
			}
		}
		
		public override string ToString(){
			return DisplayNumber+"vw";
		}
		
		public override void OnValueReady(CssLexer lexer){
			// Map to 0-1 range:
			RawValue /= 100f;
		}
		
		public override float GetDecimal(RenderableData context,CssProperty property){
			
			return RawValue * context.Document.Viewport.Width;
			
		}
		
		protected override Value Clone(){
			ViewPortWidthUnit result=new ViewPortWidthUnit();
			result.RawValue=RawValue;
			return result;
		}
		
		public override string[] PostText{
			get{
				return new string[]{"vw"};
			}
		}
		
	}
	
}



