<?xml version="1.0" encoding="utf-8"?>
<!--

    ADOBE SYSTEMS INCORPORATED
    Copyright 2008 Adobe Systems Incorporated
    All Rights Reserved.

    NOTICE: Adobe permits you to use, modify, and distribute this file
    in accordance with the terms of the license agreement accompanying it.

-->
<!--- The Spark skin class for the border of the MX TextInput component. 

      @see mx.controls.TextInput
        
      @langversion 3.0
      @playerversion Flash 10
      @playerversion AIR 1.5
      @productversion Flex 4
-->
<local:SparkSkinForHalo xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:local="mx.skins.spark.*"
      implements="mx.core.IBorder">
    
    <fx:Script>
        <![CDATA[
        import mx.core.EdgeMetrics;
        import mx.core.IUIComponent;
        
        /* Define the skin elements that should not be colorized. */
        static private const exclusions:Array = ["background"];
        /**
         * @private
         */
        override public function get colorizeExclusions():Array {return exclusions;}
        
        /* Define the content fill items that should be colored by the "contentBackgroundColor" style. */
        static private const contentFill:Array = ["bgFill"];
        /**
         * @private
         */
        override public function get contentItems():Array {return contentFill};

        /* Define the border items.*/
        static private const borderItem:Array = ["borderStroke"];
        /**
         * @private
         */
        override protected function get borderItems():Array {return borderItem;}
        /**
         * @private
         */
        override protected function get defaultBorderItemColor():uint {return getStyle("borderColor");}
        /**
         * @private
         */
        override protected function get defaultBorderAlpha():Number {return getStyle("borderAlpha");}
        
        static private const metrics:EdgeMetrics = new EdgeMetrics(2, 2, 2, 2);
        
        /**
         * @private
         */
        public function get borderMetrics():EdgeMetrics
        {
            if (getStyle("borderStyle") == "none")
                return EdgeMetrics.EMPTY;
            
            return metrics;
        }
            
        /**
         * @private
         */
        override protected function initializationComplete():void
        {
            useChromeColor = true;
            super.initializationComplete();
        }
        
        /**
         * @private
         */
        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
        {     
            if (getStyle("borderStyle") == "none")
            {
                border.visible = false;
                shadow.visible = false;
                background.visible = false;
            }
            else
            {
                if (getStyle("borderVisible") == false)
                {
                    border.visible = false;
                    shadow.visible = false;
                    background.left = background.top = background.right = background.bottom = 0;
                    shadow.left = shadow.top = shadow.right = 0;
                }
                else
                {
                    border.visible = true;
                    shadow.visible = true;
                    background.left = background.top = background.right = background.bottom = 1;
                    shadow.left = shadow.top = shadow.right = 1;
                }
            }
            
            super.updateDisplayList(unscaledWidth, unscaledHeight);
            
            if (parent && parent is IUIComponent && !IUIComponent(parent).enabled)
                alpha = 0.5;
            else
                alpha = 1;
        }
        ]]>
    </fx:Script>
    
    <!-- border --> 
    <!--- @private -->
    <s:Rect left="0" right="0" top="0" bottom="0" id="border">
        <s:stroke>   
            <!--- @private -->
            <s:SolidColorStroke id="borderStroke" weight="1" />
        </s:stroke>
    </s:Rect>

    <!-- fill -->
    <!--- @private -->
    <s:Rect id="background" left="1" right="1" top="1" bottom="1">
        <s:fill>
            <!--- @private -->
            <s:SolidColor id="bgFill" color="0xFFFFFF" />
        </s:fill>
    </s:Rect>
    
    <!-- shadow -->
    <!--- @private -->
    <s:Rect id="shadow" left="1" top="1" right="1" height="1">
        <s:fill>
            <s:SolidColor color="0x000000" alpha="0.12" />
        </s:fill>
    </s:Rect>
</local:SparkSkinForHalo>
