1  /*
     2   Copyright aswing.org, see the LICENCE.txt.
     3  */
     4  
     5  import org.aswing.*;
     6  import org.aswing.geom.*;
     7  import org.aswing.border.*;
     8  import org.aswing.plaf.*;
     9  import org.aswing.plaf.basic.*;
    10  import org.aswing.graphices.*;
    11  
    12  /**
    13   *
    14   * @author iiley
    15   */
    16  class org.aswing.plaf.basic.border.ButtonBorder implements Border, UIResource{
    17  	
    18      private var shadow:ASColor;
    19      private var darkShadow:ASColor;
    20      private var highlight:ASColor;
    21      private var lightHighlight:ASColor;
    22  	
    23  	private static var instance:Border;
    24  	/**
    25  	 * this make shared instance and construct when use.
    26  	 */	
    27  	public static function createInstance():Border{
    28  		if(instance == null){
    29  			instance = new ButtonBorder();
    30  		}
    31  		return instance;
    32  	}
    33  	
    34  	private function ButtonBorder(){
    35  		var table:UIDefaults = UIManager.getLookAndFeelDefaults();
    36  		this.shadow = table.getColor("Button.shadow");
    37  		this.darkShadow = table.getColor("Button.darkShadow");
    38  		this.highlight = table.getColor("Button.light");
    39  		this.lightHighlight = table.getColor("Button.highlight");
    40  	}
    41  	
    42  	/**
    43  	 * paint the ButtonBorder content.
    44  	 */
    45      public function paintBorder(c:Component, g:Graphics, bounds:Rectangle):Void{
    46      	var isPressed:Boolean = false;
    47  		if(c instanceof AbstractButton){
    48  			var model:ButtonModel = (AbstractButton(c)).getModel();
    49  			isPressed = model.isPressed() || model.isSelected();
    50  		}
    51  		BasicGraphicsUtils.drawBezel(g, bounds, isPressed, shadow,
    52                                     darkShadow, highlight, lightHighlight);
    53      }
    54  	
    55  	public function getBorderInsets(c:Component, bounds:Rectangle):Insets{
    56      	return new Insets(2, 2, 2, 2);
    57      }
    58      
    59      public function uninstallBorder(c:Component):Void{
    60      }
    61  	
    62  }
    63