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