1  /*
     2   Copyright aswing.org, see the LICENCE.txt.
     3  */
     4  import org.aswing.ASColor;
     5  import org.aswing.border.Border;
     6  import org.aswing.Component;
     7  import org.aswing.geom.Rectangle;
     8  import org.aswing.graphices.Graphics;
     9  import org.aswing.graphices.SolidBrush;
    10  import org.aswing.Insets;
    11  import org.aswing.plaf.UIResource;
    12  import org.aswing.UIManager;
    13  import org.aswing.JFrame;
    14  
    15  /**
    16   *
    17   * @author iiley
    18   */
    19  class org.aswing.plaf.basic.border.FrameBorder implements Border, UIResource {
    20  	
    21  	private static var BAR:Number = 2;
    22  	
    23  	private var activeColor:ASColor;
    24  	private var inactiveColor:ASColor;
    25  	
    26  	public function FrameBorder(){
    27  		activeColor   = UIManager.getColor("Frame.activeCaptionBorder");
    28  		inactiveColor = UIManager.getColor("Frame.inactiveCaptionBorder");   
    29  	}
    30  	
    31  	public function paintBorder(c : Component, g : Graphics, bounds : Rectangle) : Void {
    32  		var frame:JFrame = JFrame(c);
    33  		var color:ASColor = frame.isActive() ? activeColor : inactiveColor;
    34  		
    35  		//fill alpha rect
    36  		g.beginFill(new SolidBrush(new ASColor(color.getRGB(), 40)));
    37  		g.roundRect(bounds.x, bounds.y+BAR, bounds.width, bounds.height-BAR, 4, 4, 0, 0);
    38      	g.rectangle(bounds.x+BAR, bounds.y+BAR+1, bounds.height-BAR*2, bounds.height-BAR-2);
    39      	g.endFill();
    40      	
    41  		//border
    42  		g.beginFill(new SolidBrush(color));
    43  		g.roundRect(bounds.x+BAR, bounds.y, bounds.width-BAR*2, bounds.height-BAR, 5,5,0,0);
    44  		g.roundRect(bounds.x+BAR+1, bounds.y+1, bounds.width-BAR*2-2, bounds.height-BAR-2, 5,5,0,0);
    45  		g.endFill();
    46  		//highlight
    47  		g.beginFill(new SolidBrush(color.brighter(0.9)));
    48  		g.roundRect(bounds.x+BAR+1, bounds.y+1, bounds.width-BAR*2-2, bounds.height-BAR-2, 5,5,0,0);	
    49  		g.roundRect(bounds.x+BAR+2, bounds.y+2, bounds.width-BAR*2-4, bounds.height-BAR-4, 4,4,0,0);
    50  		g.endFill();
    51  	}
    52  	
    53  	public function getBorderInsets(c : Component, bounds : Rectangle) : Insets {
    54  		return new Insets(2, BAR+2, BAR+2, BAR+2);;
    55  	}
    56  
    57  	public function uninstallBorder(c : Component) : Void {
    58  	}
    59  	
    60  
    61  }
    62