1
4
5 import org.aswing.*;
6 import org.aswing.graphices.*;
7 import org.aswing.plaf.*;
8
9
13 class org.aswing.plaf.basic.icon.CheckBoxIcon implements Icon, UIResource{
14 private var shadow:ASColor;
15 private var darkShadow:ASColor;
16 private var highlight:ASColor;
17 private var lightHighlight:ASColor;
18
19 private static var instance:Icon;
20
23 public static function createInstance():Icon{
24 if(instance == null){
25 instance = new CheckBoxIcon();
26 }
27 return instance;
28 }
29
30 private function CheckBoxIcon(){
31 super();
32 var table:UIDefaults = UIManager.getLookAndFeelDefaults();
33 shadow = table.getColor("CheckBox.shadow");
34 darkShadow = table.getColor("CheckBox.darkShadow");
35 highlight = table.getColor("CheckBox.light");
36 lightHighlight = table.getColor("CheckBox.highlight");
37 }
38
39 public function getIconWidth():Number{
40 return 13;
41 }
42
43 public function getIconHeight():Number{
44 return 13;
45 }
46
47 public function paintIcon(com:Component, g:Graphics, x:Number, y:Number):Void{
48 var rb:JCheckBox = JCheckBox(com);
49 var model:ButtonModel = rb.getModel();
50 var drawDot:Boolean = model.isSelected();
51
52 var periphery:ASColor = darkShadow;
53 var middle:ASColor = darkShadow;
54 var inner:ASColor = shadow;
55 var dot:ASColor = rb.getForeground();
56
57
58 if (!model.isEnabled()) {
59 periphery = middle = inner = rb.getBackground();
60 dot = darkShadow;;
61 } else if (model.isPressed()) {
62 periphery = shadow;
63 inner = darkShadow;
64 }
65
66 var w:Number = getIconWidth();
67 var h:Number = getIconHeight();
68 var cx:Number = x + w/2;
69 var cy:Number = y + h/2;
70 var xr:Number = w/2;
71 var yr:Number = h/2;
72
73
74
75
76 var brush:SolidBrush=new SolidBrush(darkShadow);
77 g.fillRectangle(brush,x, y, w, h);
78
79 brush.setASColor(darkShadow);
80 g.fillRectangle(brush,x, y, w-1, h-1);
81
82 brush.setASColor(highlight);
83 g.fillRectangle(brush,x+1, y+1, w-2, h-2);
84
85 var colors:Array = [0xDCDBD8, 0xffffff];
86 var alphas:Array = [100, 100];
87 var ratios:Array = [0, 255];
88 var matrix:Object = {matrixType:"box", x:x+2, y:y+2, w:w-3, h:h-3, r:(45/180)*Math.PI};
89 var gbrush:GradientBrush=new GradientBrush(GradientBrush.LINEAR, colors, alphas, ratios, matrix);
90 g.fillRectangle(gbrush,x+2,y+2,w-4,h-4);
91
92 if(drawDot){
93 var pen:Pen = new Pen(dot, 2);
94 g.drawLine(pen, cx-w/2+3, cy, cx-w/2/3, cy+h/2-3);
95 g.drawLine(pen, cx-w/2/3, cy+h/2-1, cx+w/2, cy-h/2+1);
96 }
97 }
98 public function uninstallIcon(com:Component):Void{
99 }
100 }
101