1  /*
     2   Copyright aswing.org, see the LICENCE.txt.
     3  */
     4  
     5  import org.aswing.ASColor;
     6  import org.aswing.Component;
     7  import org.aswing.geom.Point;
     8  import org.aswing.graphices.Graphics;
     9  import org.aswing.graphices.Pen;
    10  import org.aswing.graphices.SolidBrush;
    11  import org.aswing.Icon;
    12  import org.aswing.plaf.UIResource;
    13  import org.aswing.UIManager;
    14  
    15  /**
    16   *
    17   * @author iiley
    18   */
    19  class org.aswing.plaf.basic.frame.TitleIcon implements Icon, UIResource {
    20  	private static var width:Number = 16;
    21  	private static var height:Number = 12;
    22  	
    23  	private static var instance:Icon;
    24  	
    25  	//create shared instance
    26  	public static function createInstance():Icon{
    27  		if(instance == null){
    28  			instance = new TitleIcon();
    29  		}
    30  		return instance;
    31  	}
    32  	
    33  	public function TitleIcon(){
    34  	}
    35  	
    36  	public function getIconWidth() : Number {
    37  		return width + 2;
    38  	}
    39  
    40  	public function getIconHeight() : Number {
    41  		return height;
    42  	}
    43  
    44  	public function paintIcon(com : Component, g : Graphics, x : Number, y : Number) : Void {
    45  		//This is just for test the icon
    46  		//TODO draw a real beautiful icon for AsWing frame title
    47  		//g.fillCircleRingWithThickness(new SolidBrush(ASColor.GREEN), x + WIDTH/2, y + WIDTH/2, WIDTH/2, WIDTH/4);
    48  		var outterRect:ASColor = UIManager.getColor("Frame.activeCaptionBorder");
    49  		//var innerRect:ASColor = UIManager.getColor("Frame.inactiveCaptionBorder");
    50  		var innerRect:ASColor = new ASColor(0xFFFFFF);
    51  		
    52  		x = x + 2;
    53  		
    54  		var w4:Number = width/4;
    55  		var h23:Number = 2*height/3;
    56  		var w2:Number = width/2;
    57  		var h:Number = height;
    58  		var w:Number = width;
    59  		
    60  		var points:Array = new Array();
    61  		points.push(new Point(x, y));
    62  		points.push(new Point(x+w4, y+h));
    63  		points.push(new Point(x+w2, y+h23));
    64  		points.push(new Point(x+w4*3, y+h));
    65  		points.push(new Point(x+w, y));
    66  		points.push(new Point(x+w2, y+h23));
    67  		
    68  		g.drawPolygon(new Pen(outterRect, 2), points);
    69  		g.fillPolygon(new SolidBrush(innerRect), points);
    70  	}
    71  
    72  	public function uninstallIcon(com : Component) : Void {
    73  	}
    74  }
    75