32 {
33
34 __nilptr_safe(_cachedBitmap);
35
36 if (_present != 0 && switchbegin == 0) {
38 }
39
40
41
42 canvas.setRenderHint(RenderHint.Antialiasing, true);
43
44 bool bReCreateCached = false;
45 if (_cachedBitmap == nilptr ) {
46 bReCreateCached = true;
49 bReCreateCached = true;
51 }
52 try{
53 if (bReCreateCached) {
55 }
56
57 if (_bForceRedraw) {
59 QPainter _canvas = new QPainter(_cachedBitmap);
60 _canvas.setCompositionMode(CompositionMode.CompositionMode_Source);
61 _canvas.fillRect(0, 0,
width(),
height(), 0, QBrush.Style.SolidPattern);
62 _canvas.setRenderHint(RenderHint.Antialiasing, true);
63
64
65 double padding =
dip2px(3.f);
66
67
68 double r = (
height() / 2.f) - padding ;
69
70 QPainter.Paint paint = new QPainter.Paint();
71
72
73 QRect rect = new QRect();
74 rect.left = rect.top = (padding / 2);
75 rect.right =
width() - (padding / 2);
76 rect.bottom =
height() - (padding / 2);
77 double rxy = rect.height() / 2.f;
78
79 paint.setStyle(QPainter.Paint.FILL_AND_STROKE);
81 paint.setStrokeWidth(1.f);
82
83 _canvas.drawRoundedRect(rect, (int)rxy, (int)rxy,paint);
84
85 QRect disablerect = new QRect(rect);
90
91 if (disablerect.right > disablerect.left && disablerect.bottom > disablerect.top) {
92 paint.setStyle(QPainter.Paint.FILL);
93
94 double rate =
Math.
min(1.f,(1.f -_present));
95 int alpha = (int) (0xff * rate);
96 if (alpha > 0xCE) {
97 alpha = 0xCE;
98 } else if (alpha < 0) {
99 alpha = 0;
100 }
101 alpha <<= 24;
102 paint.setColor(0x00ffffff | alpha);
103 _canvas.drawRoundedRect(disablerect, (int)rxy, (int)rxy,paint);
104 }
105
106
107 if (_present != 0.f) {
108 paint.setStyle(QPainter.Paint.FILL);
109 QRect avarect = new QRect(rect);
111
114 int dist = (0xffffff - rgbValue);
115
116 int _rv = (int) (((dist>>16) & 0xff) * rate);
117 int _gv = (int) (((dist>>8) & 0xff) * rate);
118 int _bv = (int) ((dist & 0xff) * rate);
119
120 int newclr = (_rv<<16) | (_gv << 8) | _bv;
121 int colordis = (int) (switchOnColor + newclr);
122 paint.setColor(colordis);
123 _canvas.drawRoundedRect(avarect,(int)rxy, (int)rxy,paint);
124 }
125
126 paint.setStyle(QPainter.Paint.FILL);
127 paint.setColor(0xffffffff);
128
130
131
132
133
134 paint.setStrokeWidth(0.f);
135 paint.setStyle(QPainter.Paint.STROKE);
136 paint.setColor(0xffdedede);
137
139 }
141
142
143 canvas.drawImage(_cachedBitmap, 0, 0);
144 } else {
145 canvas.drawImage(_cachedBitmap, 0, 0);
146 }
148
149 }
150 }
static final int min(int, int)
int dip2px(double dpValue)