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

namespace Css.Properties{
	
	/// <summary>
	/// Represents the text-orientation: css property.
	/// </summary>
	
	public class TextOrientation:CssProperty{
		
		public static TextOrientation GlobalProperty;
		
		public TextOrientation(){
			GlobalProperty=this;
			Inherits=true;
			InitialValueText="mixed";
		}
		
		public override string[] GetProperties(){
			return new string[]{"text-orientation"};
		}
		
		public override ApplyState Apply(ComputedStyle style,Value value){
			
			int orient=TextOrientationMode.Mixed;
			
			if(value!=null){
				
				switch(value.Text){
					case "upright":
						orient=TextOrientationMode.Upright;
					break;
					case "sideways":
					case "sideways-left":
					case "sideways-right":
						orient=TextOrientationMode.Sideways;
					break;
					default:
					case "mixed":
						orient=TextOrientationMode.Mixed;
					break;
				}
				
			}
			
			if(orient==TextOrientationMode.Mixed){
				
				// Delete:
				style.Properties.Remove(GlobalProperty);
				
			}else{
				
				// Write the value to the style:
				style[GlobalProperty]=new Css.Units.CachedIntegerUnit(value,orient);
				
			}
			
			// If we've got a writing system property, reset it:
			SparkWritingSystem.GlobalProperty.UpdateMap(style);
			
			style.RequestLayout();
			
			// Ok!
			return ApplyState.ReloadValue;
			
		}
		
	}
	
}



