package  grid
{
	import fl.controls.listClasses.CellRenderer;
	import fl.controls.listClasses.ICellRenderer;
	import fl.controls.listClasses.ListData;
	
	/**
	 * Custom cell renderer. Alternates cell background colour basing on the row index
	 * @author Maxim
	 */
	public class AlternatingRowColors extends CellRenderer implements ICellRenderer 
	{
		
		public function AlternatingRowColors() 
		{
			super();
			
		}
		
		
		public static function getStyleDefinition():Object 
		{
			return CellRenderer.getStyleDefinition();
		}
		
		override protected function drawBackground():void 
		{
			if (_listData.index % 2 == 0) {
				setStyle("upSkin", CellRenderer_upSkinGray);
				setStyle("overSkin", CellRenderer_upSkinGray);
				setStyle("downSkin", CellRenderer_upSkinGray);
				setStyle("selectedUpSkin", CellRenderer_upSkinGray);
				setStyle("selectedOverSkin", CellRenderer_upSkinGray);
				setStyle("selectedDownSkin", CellRenderer_upSkinGray);
			}else {
				setStyle("upSkin", CellRenderer_upSkinWhite); 
				setStyle("overSkin", CellRenderer_upSkinWhite);
				setStyle("downSkin", CellRenderer_upSkinWhite);
				setStyle("selectedUpSkin", CellRenderer_upSkinWhite);
				setStyle("selectedOverSkin", CellRenderer_upSkinWhite);
				setStyle("selectedDownSkin", CellRenderer_upSkinWhite);
			}
			super.drawBackground();
		}
		
	}

}