1  /*
     2   Copyright aswing.org, see the LICENCE.txt.
     3  */
     4   
     5  import org.aswing.*;
     6  import org.aswing.plaf.*;
     7  import org.aswing.plaf.basic.*;
     8  import org.aswing.geom.*;
     9  import org.aswing.graphices.*;
    10   
    11  /**
    12   *
    13   * @author iiley
    14   */
    15  class org.aswing.plaf.asw.ASWingToggleButtonUI extends BasicToggleButtonUI{
    16  	/*shared instance*/
    17  	private static var asWingToggleButtonUI:ASWingToggleButtonUI;
    18  	
    19      public static function createInstance(c:Component):ComponentUI {
    20      	if(asWingToggleButtonUI == null){
    21      		asWingToggleButtonUI = new ASWingToggleButtonUI();
    22      	}
    23          return asWingToggleButtonUI;
    24      }
    25      
    26      public function ASWingToggleButtonUI(){
    27      	super();
    28      }
    29      
    30      /**
    31       * Paint gradient background for AsWing LAF Buttons.
    32       */
    33      private function paintBackGround(com:Component, g:Graphics, b:Rectangle):Void{
    34      	if(com.isOpaque()){
    35  	    	var c:AbstractButton = AbstractButton(com);
    36  			if(c.getModel().isSelected() || c.getModel().isPressed()){
    37  	    		g.fillRectangle(new SolidBrush(com.getBackground().darker(0.9)), b.x, b.y, b.width, b.height);
    38  			}else{
    39  				org.aswing.plaf.asw.ASWingButtonUI.paintASWingLAFButtonBackGround(c, g, b);
    40  			}
    41      	}
    42      }    
    43  }
    44