1  import org.aswing.ASColor;
     2  import org.aswing.Component;
     3  import org.aswing.geom.Dimension;
     4  import org.aswing.geom.Rectangle;
     5  import org.aswing.graphices.GradientBrush;
     6  import org.aswing.graphices.Graphics;
     7  import org.aswing.graphices.SolidBrush;
     8  import org.aswing.plaf.basic.BasicTextComponentUI;
     9  import org.aswing.plaf.ComponentUI;
    10  import org.aswing.UIManager;
    11  
    12  /**
    13   * @author Tomato
    14   */
    15  class org.aswing.plaf.basic.BasicTextAreaUI extends BasicTextComponentUI {
    16  
    17  	private static var textUI:BasicTextAreaUI;
    18  	
    19  	private var highlight:ASColor;
    20  	private var shadow:ASColor;
    21  	
    22  	public static function createInstance(c:Component):ComponentUI {
    23  		if(textUI == null){
    24  			textUI = new BasicTextAreaUI();
    25  		}
    26  		return textUI;
    27  	}
    28  	
    29  	public function BasicTextAreaUI(){
    30  		super();
    31  		highlight = UIManager.getColor("TextArea.highlight");
    32  		shadow = UIManager.getColor("TextArea.shadow");		
    33  	}
    34  	
    35  	//override this to the sub component's prefix
    36      private function getPropertyPrefix():String {
    37          return "TextArea.";
    38      }
    39  
    40  	public function paint(c:Component , g:Graphics , r:Rectangle):Void{
    41  		super.paint(c, g, r);
    42  	}
    43      
    44      private function paintBackGround(c:Component, g:Graphics, r:Rectangle):Void{
    45      	if(c.isOpaque()  && c.isEnabled()){
    46  			var x:Number = r.x;
    47  			var y:Number = r.y;
    48  			var w:Number = r.width;
    49  			var h:Number = r.height;
    50  			g.fillRectangle(new SolidBrush(c.getBackground()), x,y,w,h);
    51  			
    52  			var colors:Array = [0xF7F7F7, c.getBackground().getRGB()];
    53  			var alphas:Array = [50, 0];
    54  			var ratios:Array = [0, 100];
    55  			var matrix:Object = {matrixType:"box", x:x, y:y, w:w, h:h, r:(90/180)*Math.PI};        
    56  		    var brush:GradientBrush=new GradientBrush(GradientBrush.LINEAR, colors, alphas, ratios, matrix);
    57  		    g.fillRectangle(brush,x,y,w,h);
    58  		    
    59      	}
    60      	
    61      }
    62      
    63      /**
    64       * Return null, make it to count in JTextFiled's countPreferredSize method.
    65       */
    66      public function getPreferredSize(c:Component):Dimension{
    67      	return null;
    68      }
    69  }