author | sandman <sandman> | 2002-11-28 00:37:59 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-28 00:37:59 (UTC) |
commit | 0d508bf39ad43aa06c9cd395dd382d8e00dfbf3a (patch) (unidiff) | |
tree | f4a225c3236b2608c1127e62750c4106e35bfd66 | |
parent | 57ad30fb514428e068142e31ee40aa1615291123 (diff) | |
download | opie-0d508bf39ad43aa06c9cd395dd382d8e00dfbf3a.zip opie-0d508bf39ad43aa06c9cd395dd382d8e00dfbf3a.tar.gz opie-0d508bf39ad43aa06c9cd395dd382d8e00dfbf3a.tar.bz2 |
Some checks for null pixmaps (qtmail seems to create a scrollbar with
width and height == -1 when you tap "New mailbox")
-rw-r--r-- | noncore/styles/theme/ogfxeffect.cpp | 22 | ||||
-rw-r--r-- | noncore/styles/theme/othemestyle.cpp | 6 |
2 files changed, 17 insertions, 11 deletions
diff --git a/noncore/styles/theme/ogfxeffect.cpp b/noncore/styles/theme/ogfxeffect.cpp index 2071a67..90b45fe 100644 --- a/noncore/styles/theme/ogfxeffect.cpp +++ b/noncore/styles/theme/ogfxeffect.cpp | |||
@@ -1,483 +1,485 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> | 2 | Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> |
3 | (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org> | 3 | (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org> |
4 | (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> | 4 | (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> |
5 | 5 | ||
6 | */ | 6 | */ |
7 | 7 | ||
8 | // $Id$ | 8 | // $Id$ |
9 | 9 | ||
10 | #include <qimage.h> | 10 | #include <qimage.h> |
11 | #include <qpainter.h> | 11 | #include <qpainter.h> |
12 | 12 | ||
13 | #include <qpe/qmath.h> | 13 | #include <qpe/qmath.h> |
14 | 14 | ||
15 | #include "ogfxeffect.h" | 15 | #include "ogfxeffect.h" |
16 | 16 | ||
17 | #include <cstdlib> | 17 | #include <cstdlib> |
18 | #include <cmath> | 18 | #include <cmath> |
19 | 19 | ||
20 | //====================================================================== | 20 | //====================================================================== |
21 | // | 21 | // |
22 | // Gradient effects | 22 | // Gradient effects |
23 | // | 23 | // |
24 | //====================================================================== | 24 | //====================================================================== |
25 | 25 | ||
26 | 26 | ||
27 | QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca, | 27 | QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca, |
28 | const QColor &cb, GradientType eff, int ncols) | 28 | const QColor &cb, GradientType eff, int ncols) |
29 | { | 29 | { |
30 | QImage image = gradient(pixmap.size(), ca, cb, eff, ncols); | 30 | if ( !pixmap. isNull ( )) { |
31 | pixmap.convertFromImage(image); | 31 | QImage image = gradient(pixmap.size(), ca, cb, eff, ncols); |
32 | 32 | pixmap.convertFromImage(image); | |
33 | } | ||
33 | return pixmap; | 34 | return pixmap; |
34 | } | 35 | } |
35 | 36 | ||
36 | QImage OGfxEffect::gradient(const QSize &size, const QColor &ca, | 37 | QImage OGfxEffect::gradient(const QSize &size, const QColor &ca, |
37 | const QColor &cb, GradientType eff, int /*ncols*/) | 38 | const QColor &cb, GradientType eff, int /*ncols*/) |
38 | { | 39 | { |
39 | int rDiff, gDiff, bDiff; | 40 | int rDiff, gDiff, bDiff; |
40 | int rca, gca, bca, rcb, gcb, bcb; | 41 | int rca, gca, bca, rcb, gcb, bcb; |
41 | 42 | ||
42 | QImage image(size, 32); | 43 | QImage image(size, 32); |
43 | 44 | ||
44 | if (size.width() == 0 || size.height() == 0) { | 45 | if (size.width() == 0 || size.height() == 0) { |
45 | qDebug ( "WARNING: OGfxEffect::gradient: invalid image" ); | 46 | qDebug ( "WARNING: OGfxEffect::gradient: invalid image" ); |
46 | return image; | 47 | return image; |
47 | } | 48 | } |
48 | 49 | ||
49 | register int x, y; | 50 | register int x, y; |
50 | 51 | ||
51 | rDiff = (rcb = cb.red()) - (rca = ca.red()); | 52 | rDiff = (rcb = cb.red()) - (rca = ca.red()); |
52 | gDiff = (gcb = cb.green()) - (gca = ca.green()); | 53 | gDiff = (gcb = cb.green()) - (gca = ca.green()); |
53 | bDiff = (bcb = cb.blue()) - (bca = ca.blue()); | 54 | bDiff = (bcb = cb.blue()) - (bca = ca.blue()); |
54 | 55 | ||
55 | if( eff == VerticalGradient || eff == HorizontalGradient ){ | 56 | if( eff == VerticalGradient || eff == HorizontalGradient ){ |
56 | 57 | ||
57 | uint *p; | 58 | uint *p; |
58 | uint rgb; | 59 | uint rgb; |
59 | 60 | ||
60 | register int rl = rca << 16; | 61 | register int rl = rca << 16; |
61 | register int gl = gca << 16; | 62 | register int gl = gca << 16; |
62 | register int bl = bca << 16; | 63 | register int bl = bca << 16; |
63 | 64 | ||
64 | if( eff == VerticalGradient ) { | 65 | if( eff == VerticalGradient ) { |
65 | 66 | ||
66 | int rcdelta = ((1<<16) / size.height()) * rDiff; | 67 | int rcdelta = ((1<<16) / size.height()) * rDiff; |
67 | int gcdelta = ((1<<16) / size.height()) * gDiff; | 68 | int gcdelta = ((1<<16) / size.height()) * gDiff; |
68 | int bcdelta = ((1<<16) / size.height()) * bDiff; | 69 | int bcdelta = ((1<<16) / size.height()) * bDiff; |
69 | 70 | ||
70 | for ( y = 0; y < size.height(); y++ ) { | 71 | for ( y = 0; y < size.height(); y++ ) { |
71 | p = (uint *) image.scanLine(y); | 72 | p = (uint *) image.scanLine(y); |
72 | 73 | ||
73 | rl += rcdelta; | 74 | rl += rcdelta; |
74 | gl += gcdelta; | 75 | gl += gcdelta; |
75 | bl += bcdelta; | 76 | bl += bcdelta; |
76 | 77 | ||
77 | rgb = qRgb( (rl>>16), (gl>>16), (bl>>16) ); | 78 | rgb = qRgb( (rl>>16), (gl>>16), (bl>>16) ); |
78 | 79 | ||
79 | for( x = 0; x < size.width(); x++ ) { | 80 | for( x = 0; x < size.width(); x++ ) { |
80 | *p = rgb; | 81 | *p = rgb; |
81 | p++; | 82 | p++; |
82 | } | 83 | } |
83 | } | 84 | } |
84 | 85 | ||
85 | } | 86 | } |
86 | else { // must be HorizontalGradient | 87 | else { // must be HorizontalGradient |
87 | 88 | ||
88 | unsigned int *o_src = (unsigned int *)image.scanLine(0); | 89 | unsigned int *o_src = (unsigned int *)image.scanLine(0); |
89 | unsigned int *src = o_src; | 90 | unsigned int *src = o_src; |
90 | 91 | ||
91 | int rcdelta = ((1<<16) / size.width()) * rDiff; | 92 | int rcdelta = ((1<<16) / size.width()) * rDiff; |
92 | int gcdelta = ((1<<16) / size.width()) * gDiff; | 93 | int gcdelta = ((1<<16) / size.width()) * gDiff; |
93 | int bcdelta = ((1<<16) / size.width()) * bDiff; | 94 | int bcdelta = ((1<<16) / size.width()) * bDiff; |
94 | 95 | ||
95 | for( x = 0; x < size.width(); x++) { | 96 | for( x = 0; x < size.width(); x++) { |
96 | 97 | ||
97 | rl += rcdelta; | 98 | rl += rcdelta; |
98 | gl += gcdelta; | 99 | gl += gcdelta; |
99 | bl += bcdelta; | 100 | bl += bcdelta; |
100 | 101 | ||
101 | *src++ = qRgb( (rl>>16), (gl>>16), (bl>>16)); | 102 | *src++ = qRgb( (rl>>16), (gl>>16), (bl>>16)); |
102 | } | 103 | } |
103 | 104 | ||
104 | src = o_src; | 105 | src = o_src; |
105 | 106 | ||
106 | // Believe it or not, manually copying in a for loop is faster | 107 | // Believe it or not, manually copying in a for loop is faster |
107 | // than calling memcpy for each scanline (on the order of ms...). | 108 | // than calling memcpy for each scanline (on the order of ms...). |
108 | // I think this is due to the function call overhead (mosfet). | 109 | // I think this is due to the function call overhead (mosfet). |
109 | 110 | ||
110 | for (y = 1; y < size.height(); ++y) { | 111 | for (y = 1; y < size.height(); ++y) { |
111 | 112 | ||
112 | p = (unsigned int *)image.scanLine(y); | 113 | p = (unsigned int *)image.scanLine(y); |
113 | src = o_src; | 114 | src = o_src; |
114 | for(x=0; x < size.width(); ++x) | 115 | for(x=0; x < size.width(); ++x) |
115 | *p++ = *src++; | 116 | *p++ = *src++; |
116 | } | 117 | } |
117 | } | 118 | } |
118 | } | 119 | } |
119 | 120 | ||
120 | else { | 121 | else { |
121 | 122 | ||
122 | float rfd, gfd, bfd; | 123 | float rfd, gfd, bfd; |
123 | float rd = rca, gd = gca, bd = bca; | 124 | float rd = rca, gd = gca, bd = bca; |
124 | 125 | ||
125 | unsigned char *xtable[3]; | 126 | unsigned char *xtable[3]; |
126 | unsigned char *ytable[3]; | 127 | unsigned char *ytable[3]; |
127 | 128 | ||
128 | unsigned int w = size.width(), h = size.height(); | 129 | unsigned int w = size.width(), h = size.height(); |
129 | xtable[0] = new unsigned char[w]; | 130 | xtable[0] = new unsigned char[w]; |
130 | xtable[1] = new unsigned char[w]; | 131 | xtable[1] = new unsigned char[w]; |
131 | xtable[2] = new unsigned char[w]; | 132 | xtable[2] = new unsigned char[w]; |
132 | ytable[0] = new unsigned char[h]; | 133 | ytable[0] = new unsigned char[h]; |
133 | ytable[1] = new unsigned char[h]; | 134 | ytable[1] = new unsigned char[h]; |
134 | ytable[2] = new unsigned char[h]; | 135 | ytable[2] = new unsigned char[h]; |
135 | w*=2, h*=2; | 136 | w*=2, h*=2; |
136 | 137 | ||
137 | if ( eff == DiagonalGradient || eff == CrossDiagonalGradient) { | 138 | if ( eff == DiagonalGradient || eff == CrossDiagonalGradient) { |
138 | // Diagonal dgradient code inspired by BlackBox (mosfet) | 139 | // Diagonal dgradient code inspired by BlackBox (mosfet) |
139 | // BlackBox dgradient is (C) Brad Hughes, <bhughes@tcac.net> and | 140 | // BlackBox dgradient is (C) Brad Hughes, <bhughes@tcac.net> and |
140 | // Mike Cole <mike@mydot.com>. | 141 | // Mike Cole <mike@mydot.com>. |
141 | 142 | ||
142 | rfd = (float)rDiff/w; | 143 | rfd = (float)rDiff/w; |
143 | gfd = (float)gDiff/w; | 144 | gfd = (float)gDiff/w; |
144 | bfd = (float)bDiff/w; | 145 | bfd = (float)bDiff/w; |
145 | 146 | ||
146 | int dir; | 147 | int dir; |
147 | for (x = 0; x < size.width(); x++, rd+=rfd, gd+=gfd, bd+=bfd) { | 148 | for (x = 0; x < size.width(); x++, rd+=rfd, gd+=gfd, bd+=bfd) { |
148 | dir = eff == DiagonalGradient? x : size.width() - x - 1; | 149 | dir = eff == DiagonalGradient? x : size.width() - x - 1; |
149 | xtable[0][dir] = (unsigned char) rd; | 150 | xtable[0][dir] = (unsigned char) rd; |
150 | xtable[1][dir] = (unsigned char) gd; | 151 | xtable[1][dir] = (unsigned char) gd; |
151 | xtable[2][dir] = (unsigned char) bd; | 152 | xtable[2][dir] = (unsigned char) bd; |
152 | } | 153 | } |
153 | rfd = (float)rDiff/h; | 154 | rfd = (float)rDiff/h; |
154 | gfd = (float)gDiff/h; | 155 | gfd = (float)gDiff/h; |
155 | bfd = (float)bDiff/h; | 156 | bfd = (float)bDiff/h; |
156 | rd = gd = bd = 0; | 157 | rd = gd = bd = 0; |
157 | for (y = 0; y < size.height(); y++, rd+=rfd, gd+=gfd, bd+=bfd) { | 158 | for (y = 0; y < size.height(); y++, rd+=rfd, gd+=gfd, bd+=bfd) { |
158 | ytable[0][y] = (unsigned char) rd; | 159 | ytable[0][y] = (unsigned char) rd; |
159 | ytable[1][y] = (unsigned char) gd; | 160 | ytable[1][y] = (unsigned char) gd; |
160 | ytable[2][y] = (unsigned char) bd; | 161 | ytable[2][y] = (unsigned char) bd; |
161 | } | 162 | } |
162 | 163 | ||
163 | for (y = 0; y < size.height(); y++) { | 164 | for (y = 0; y < size.height(); y++) { |
164 | unsigned int *scanline = (unsigned int *)image.scanLine(y); | 165 | unsigned int *scanline = (unsigned int *)image.scanLine(y); |
165 | for (x = 0; x < size.width(); x++) { | 166 | for (x = 0; x < size.width(); x++) { |
166 | scanline[x] = qRgb(xtable[0][x] + ytable[0][y], | 167 | scanline[x] = qRgb(xtable[0][x] + ytable[0][y], |
167 | xtable[1][x] + ytable[1][y], | 168 | xtable[1][x] + ytable[1][y], |
168 | xtable[2][x] + ytable[2][y]); | 169 | xtable[2][x] + ytable[2][y]); |
169 | } | 170 | } |
170 | } | 171 | } |
171 | } | 172 | } |
172 | 173 | ||
173 | else if (eff == RectangleGradient || | 174 | else if (eff == RectangleGradient || |
174 | eff == PyramidGradient || | 175 | eff == PyramidGradient || |
175 | eff == PipeCrossGradient || | 176 | eff == PipeCrossGradient || |
176 | eff == EllipticGradient) | 177 | eff == EllipticGradient) |
177 | { | 178 | { |
178 | int rSign = rDiff>0? 1: -1; | 179 | int rSign = rDiff>0? 1: -1; |
179 | int gSign = gDiff>0? 1: -1; | 180 | int gSign = gDiff>0? 1: -1; |
180 | int bSign = bDiff>0? 1: -1; | 181 | int bSign = bDiff>0? 1: -1; |
181 | 182 | ||
182 | rfd = (float)rDiff / size.width(); | 183 | rfd = (float)rDiff / size.width(); |
183 | gfd = (float)gDiff / size.width(); | 184 | gfd = (float)gDiff / size.width(); |
184 | bfd = (float)bDiff / size.width(); | 185 | bfd = (float)bDiff / size.width(); |
185 | 186 | ||
186 | rd = (float)rDiff/2; | 187 | rd = (float)rDiff/2; |
187 | gd = (float)gDiff/2; | 188 | gd = (float)gDiff/2; |
188 | bd = (float)bDiff/2; | 189 | bd = (float)bDiff/2; |
189 | 190 | ||
190 | for (x = 0; x < size.width(); x++, rd-=rfd, gd-=gfd, bd-=bfd) | 191 | for (x = 0; x < size.width(); x++, rd-=rfd, gd-=gfd, bd-=bfd) |
191 | { | 192 | { |
192 | xtable[0][x] = (unsigned char) abs((int)rd); | 193 | xtable[0][x] = (unsigned char) abs((int)rd); |
193 | xtable[1][x] = (unsigned char) abs((int)gd); | 194 | xtable[1][x] = (unsigned char) abs((int)gd); |
194 | xtable[2][x] = (unsigned char) abs((int)bd); | 195 | xtable[2][x] = (unsigned char) abs((int)bd); |
195 | } | 196 | } |
196 | 197 | ||
197 | rfd = (float)rDiff/size.height(); | 198 | rfd = (float)rDiff/size.height(); |
198 | gfd = (float)gDiff/size.height(); | 199 | gfd = (float)gDiff/size.height(); |
199 | bfd = (float)bDiff/size.height(); | 200 | bfd = (float)bDiff/size.height(); |
200 | 201 | ||
201 | rd = (float)rDiff/2; | 202 | rd = (float)rDiff/2; |
202 | gd = (float)gDiff/2; | 203 | gd = (float)gDiff/2; |
203 | bd = (float)bDiff/2; | 204 | bd = (float)bDiff/2; |
204 | 205 | ||
205 | for (y = 0; y < size.height(); y++, rd-=rfd, gd-=gfd, bd-=bfd) | 206 | for (y = 0; y < size.height(); y++, rd-=rfd, gd-=gfd, bd-=bfd) |
206 | { | 207 | { |
207 | ytable[0][y] = (unsigned char) abs((int)rd); | 208 | ytable[0][y] = (unsigned char) abs((int)rd); |
208 | ytable[1][y] = (unsigned char) abs((int)gd); | 209 | ytable[1][y] = (unsigned char) abs((int)gd); |
209 | ytable[2][y] = (unsigned char) abs((int)bd); | 210 | ytable[2][y] = (unsigned char) abs((int)bd); |
210 | } | 211 | } |
211 | unsigned int rgb; | 212 | unsigned int rgb; |
212 | int h = (size.height()+1)>>1; | 213 | int h = (size.height()+1)>>1; |
213 | for (y = 0; y < h; y++) { | 214 | for (y = 0; y < h; y++) { |
214 | unsigned int *sl1 = (unsigned int *)image.scanLine(y); | 215 | unsigned int *sl1 = (unsigned int *)image.scanLine(y); |
215 | unsigned int *sl2 = (unsigned int *)image.scanLine(QMAX(size.height()-y-1, y)); | 216 | unsigned int *sl2 = (unsigned int *)image.scanLine(QMAX(size.height()-y-1, y)); |
216 | 217 | ||
217 | int w = (size.width()+1)>>1; | 218 | int w = (size.width()+1)>>1; |
218 | int x2 = size.width()-1; | 219 | int x2 = size.width()-1; |
219 | 220 | ||
220 | for (x = 0; x < w; x++, x2--) { | 221 | for (x = 0; x < w; x++, x2--) { |
221 | rgb = 0; | 222 | rgb = 0; |
222 | if (eff == PyramidGradient) { | 223 | if (eff == PyramidGradient) { |
223 | rgb = qRgb(rcb-rSign*(xtable[0][x]+ytable[0][y]), | 224 | rgb = qRgb(rcb-rSign*(xtable[0][x]+ytable[0][y]), |
224 | gcb-gSign*(xtable[1][x]+ytable[1][y]), | 225 | gcb-gSign*(xtable[1][x]+ytable[1][y]), |
225 | bcb-bSign*(xtable[2][x]+ytable[2][y])); | 226 | bcb-bSign*(xtable[2][x]+ytable[2][y])); |
226 | } | 227 | } |
227 | if (eff == RectangleGradient) { | 228 | if (eff == RectangleGradient) { |
228 | rgb = qRgb(rcb - rSign * | 229 | rgb = qRgb(rcb - rSign * |
229 | QMAX(xtable[0][x], ytable[0][y]) * 2, | 230 | QMAX(xtable[0][x], ytable[0][y]) * 2, |
230 | gcb - gSign * | 231 | gcb - gSign * |
231 | QMAX(xtable[1][x], ytable[1][y]) * 2, | 232 | QMAX(xtable[1][x], ytable[1][y]) * 2, |
232 | bcb - bSign * | 233 | bcb - bSign * |
233 | QMAX(xtable[2][x], ytable[2][y]) * 2); | 234 | QMAX(xtable[2][x], ytable[2][y]) * 2); |
234 | } | 235 | } |
235 | if (eff == PipeCrossGradient) { | 236 | if (eff == PipeCrossGradient) { |
236 | rgb = qRgb(rcb - rSign * | 237 | rgb = qRgb(rcb - rSign * |
237 | QMIN(xtable[0][x], ytable[0][y]) * 2, | 238 | QMIN(xtable[0][x], ytable[0][y]) * 2, |
238 | gcb - gSign * | 239 | gcb - gSign * |
239 | QMIN(xtable[1][x], ytable[1][y]) * 2, | 240 | QMIN(xtable[1][x], ytable[1][y]) * 2, |
240 | bcb - bSign * | 241 | bcb - bSign * |
241 | QMIN(xtable[2][x], ytable[2][y]) * 2); | 242 | QMIN(xtable[2][x], ytable[2][y]) * 2); |
242 | } | 243 | } |
243 | if (eff == EllipticGradient) { | 244 | if (eff == EllipticGradient) { |
244 | rgb = qRgb(rcb - rSign * | 245 | rgb = qRgb(rcb - rSign * |
245 | (int)sqrt((xtable[0][x]*xtable[0][x] + | 246 | (int)sqrt((xtable[0][x]*xtable[0][x] + |
246 | ytable[0][y]*ytable[0][y])*2.0), | 247 | ytable[0][y]*ytable[0][y])*2.0), |
247 | gcb - gSign * | 248 | gcb - gSign * |
248 | (int)sqrt((xtable[1][x]*xtable[1][x] + | 249 | (int)sqrt((xtable[1][x]*xtable[1][x] + |
249 | ytable[1][y]*ytable[1][y])*2.0), | 250 | ytable[1][y]*ytable[1][y])*2.0), |
250 | bcb - bSign * | 251 | bcb - bSign * |
251 | (int)sqrt((xtable[2][x]*xtable[2][x] + | 252 | (int)sqrt((xtable[2][x]*xtable[2][x] + |
252 | ytable[2][y]*ytable[2][y])*2.0)); | 253 | ytable[2][y]*ytable[2][y])*2.0)); |
253 | } | 254 | } |
254 | 255 | ||
255 | sl1[x] = sl2[x] = rgb; | 256 | sl1[x] = sl2[x] = rgb; |
256 | sl1[x2] = sl2[x2] = rgb; | 257 | sl1[x2] = sl2[x2] = rgb; |
257 | } | 258 | } |
258 | } | 259 | } |
259 | } | 260 | } |
260 | 261 | ||
261 | delete [] xtable[0]; | 262 | delete [] xtable[0]; |
262 | delete [] xtable[1]; | 263 | delete [] xtable[1]; |
263 | delete [] xtable[2]; | 264 | delete [] xtable[2]; |
264 | delete [] ytable[0]; | 265 | delete [] ytable[0]; |
265 | delete [] ytable[1]; | 266 | delete [] ytable[1]; |
266 | delete [] ytable[2]; | 267 | delete [] ytable[2]; |
267 | } | 268 | } |
268 | return image; | 269 | return image; |
269 | } | 270 | } |
270 | 271 | ||
271 | 272 | ||
272 | //====================================================================== | 273 | //====================================================================== |
273 | // | 274 | // |
274 | // Blend effects | 275 | // Blend effects |
275 | // | 276 | // |
276 | //====================================================================== | 277 | //====================================================================== |
277 | 278 | ||
278 | 279 | ||
279 | QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity, | 280 | QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity, |
280 | const QColor &bgnd, GradientType eff, | 281 | const QColor &bgnd, GradientType eff, |
281 | bool anti_dir, int /*ncols*/) | 282 | bool anti_dir, int /*ncols*/) |
282 | { | 283 | { |
283 | QImage image = pixmap.convertToImage(); | 284 | if ( !pixmap. isNull ( )) { |
284 | OGfxEffect::blend(image, initial_intensity, bgnd, eff, anti_dir); | 285 | QImage image = pixmap.convertToImage(); |
285 | 286 | OGfxEffect::blend(image, initial_intensity, bgnd, eff, anti_dir); | |
286 | if ( pixmap. depth ( ) <= 8 ) | ||
287 | image. convertDepth ( pixmap. depth ( )); | ||
288 | 287 | ||
289 | pixmap.convertFromImage(image); | 288 | if ( pixmap. depth ( ) <= 8 ) |
289 | image. convertDepth ( pixmap. depth ( )); | ||
290 | 290 | ||
291 | return pixmap; | 291 | pixmap.convertFromImage(image); |
292 | } | ||
293 | return pixmap; | ||
292 | } | 294 | } |
293 | 295 | ||
294 | 296 | ||
295 | QImage& OGfxEffect::blend(QImage &image, float initial_intensity, | 297 | QImage& OGfxEffect::blend(QImage &image, float initial_intensity, |
296 | const QColor &bgnd, GradientType eff, | 298 | const QColor &bgnd, GradientType eff, |
297 | bool anti_dir) | 299 | bool anti_dir) |
298 | { | 300 | { |
299 | if (image.width() == 0 || image.height() == 0) { | 301 | if (image.width() == 0 || image.height() == 0) { |
300 | qDebug ( "Invalid image\n" ); | 302 | qDebug ( "Invalid image\n" ); |
301 | return image; | 303 | return image; |
302 | } | 304 | } |
303 | 305 | ||
304 | int r_bgnd = bgnd.red(), g_bgnd = bgnd.green(), b_bgnd = bgnd.blue(); | 306 | int r_bgnd = bgnd.red(), g_bgnd = bgnd.green(), b_bgnd = bgnd.blue(); |
305 | int r, g, b; | 307 | int r, g, b; |
306 | int ind; | 308 | int ind; |
307 | 309 | ||
308 | unsigned int xi, xf, yi, yf; | 310 | unsigned int xi, xf, yi, yf; |
309 | unsigned int a; | 311 | unsigned int a; |
310 | 312 | ||
311 | // check the boundaries of the initial intesity param | 313 | // check the boundaries of the initial intesity param |
312 | float unaffected = 1; | 314 | float unaffected = 1; |
313 | if (initial_intensity > 1) initial_intensity = 1; | 315 | if (initial_intensity > 1) initial_intensity = 1; |
314 | if (initial_intensity < -1) initial_intensity = -1; | 316 | if (initial_intensity < -1) initial_intensity = -1; |
315 | if (initial_intensity < 0) { | 317 | if (initial_intensity < 0) { |
316 | unaffected = 1. + initial_intensity; | 318 | unaffected = 1. + initial_intensity; |
317 | initial_intensity = 0; | 319 | initial_intensity = 0; |
318 | } | 320 | } |
319 | 321 | ||
320 | 322 | ||
321 | float intensity = initial_intensity; | 323 | float intensity = initial_intensity; |
322 | float var = 1. - initial_intensity; | 324 | float var = 1. - initial_intensity; |
323 | 325 | ||
324 | if (anti_dir) { | 326 | if (anti_dir) { |
325 | initial_intensity = intensity = 1.; | 327 | initial_intensity = intensity = 1.; |
326 | var = -var; | 328 | var = -var; |
327 | } | 329 | } |
328 | 330 | ||
329 | register int x, y; | 331 | register int x, y; |
330 | 332 | ||
331 | unsigned int *data = (unsigned int *)image.bits(); | 333 | unsigned int *data = (unsigned int *)image.bits(); |
332 | 334 | ||
333 | if( eff == VerticalGradient || eff == HorizontalGradient ) { | 335 | if( eff == VerticalGradient || eff == HorizontalGradient ) { |
334 | 336 | ||
335 | // set the image domain to apply the effect to | 337 | // set the image domain to apply the effect to |
336 | xi = 0, xf = image.width(); | 338 | xi = 0, xf = image.width(); |
337 | yi = 0, yf = image.height(); | 339 | yi = 0, yf = image.height(); |
338 | if (eff == VerticalGradient) { | 340 | if (eff == VerticalGradient) { |
339 | if (anti_dir) yf = (int)(image.height() * unaffected); | 341 | if (anti_dir) yf = (int)(image.height() * unaffected); |
340 | else yi = (int)(image.height() * (1 - unaffected)); | 342 | else yi = (int)(image.height() * (1 - unaffected)); |
341 | } | 343 | } |
342 | else { | 344 | else { |
343 | if (anti_dir) xf = (int)(image.width() * unaffected); | 345 | if (anti_dir) xf = (int)(image.width() * unaffected); |
344 | else xi = (int)(image.height() * (1 - unaffected)); | 346 | else xi = (int)(image.height() * (1 - unaffected)); |
345 | } | 347 | } |
346 | 348 | ||
347 | var /= (eff == VerticalGradient?yf-yi:xf-xi); | 349 | var /= (eff == VerticalGradient?yf-yi:xf-xi); |
348 | 350 | ||
349 | for (y = yi; y < (int)yf; y++) { | 351 | for (y = yi; y < (int)yf; y++) { |
350 | intensity = eff == VerticalGradient? intensity + var : | 352 | intensity = eff == VerticalGradient? intensity + var : |
351 | initial_intensity; | 353 | initial_intensity; |
352 | for (x = xi; x < (int)xf ; x++) { | 354 | for (x = xi; x < (int)xf ; x++) { |
353 | if (eff == HorizontalGradient) intensity += var; | 355 | if (eff == HorizontalGradient) intensity += var; |
354 | ind = x + image.width() * y ; | 356 | ind = x + image.width() * y ; |
355 | r = qRed (data[ind]) + (int)(intensity * | 357 | r = qRed (data[ind]) + (int)(intensity * |
356 | (r_bgnd - qRed (data[ind]))); | 358 | (r_bgnd - qRed (data[ind]))); |
357 | g = qGreen(data[ind]) + (int)(intensity * | 359 | g = qGreen(data[ind]) + (int)(intensity * |
358 | (g_bgnd - qGreen(data[ind]))); | 360 | (g_bgnd - qGreen(data[ind]))); |
359 | b = qBlue (data[ind]) + (int)(intensity * | 361 | b = qBlue (data[ind]) + (int)(intensity * |
360 | (b_bgnd - qBlue (data[ind]))); | 362 | (b_bgnd - qBlue (data[ind]))); |
361 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 363 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
362 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 364 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
363 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 365 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
364 | a = qAlpha(data[ind]); | 366 | a = qAlpha(data[ind]); |
365 | data[ind] = qRgba(r, g, b, a); | 367 | data[ind] = qRgba(r, g, b, a); |
366 | } | 368 | } |
367 | } | 369 | } |
368 | } | 370 | } |
369 | else if (eff == DiagonalGradient || eff == CrossDiagonalGradient) { | 371 | else if (eff == DiagonalGradient || eff == CrossDiagonalGradient) { |
370 | float xvar = var / 2 / image.width(); // / unaffected; | 372 | float xvar = var / 2 / image.width(); // / unaffected; |
371 | float yvar = var / 2 / image.height(); // / unaffected; | 373 | float yvar = var / 2 / image.height(); // / unaffected; |
372 | float tmp; | 374 | float tmp; |
373 | 375 | ||
374 | for (x = 0; x < image.width() ; x++) { | 376 | for (x = 0; x < image.width() ; x++) { |
375 | tmp = xvar * (eff == DiagonalGradient? x : image.width()-x-1); | 377 | tmp = xvar * (eff == DiagonalGradient? x : image.width()-x-1); |
376 | for (y = 0; y < image.height() ; y++) { | 378 | for (y = 0; y < image.height() ; y++) { |
377 | intensity = initial_intensity + tmp + yvar * y; | 379 | intensity = initial_intensity + tmp + yvar * y; |
378 | ind = x + image.width() * y ; | 380 | ind = x + image.width() * y ; |
379 | r = qRed (data[ind]) + (int)(intensity * | 381 | r = qRed (data[ind]) + (int)(intensity * |
380 | (r_bgnd - qRed (data[ind]))); | 382 | (r_bgnd - qRed (data[ind]))); |
381 | g = qGreen(data[ind]) + (int)(intensity * | 383 | g = qGreen(data[ind]) + (int)(intensity * |
382 | (g_bgnd - qGreen(data[ind]))); | 384 | (g_bgnd - qGreen(data[ind]))); |
383 | b = qBlue (data[ind]) + (int)(intensity * | 385 | b = qBlue (data[ind]) + (int)(intensity * |
384 | (b_bgnd - qBlue (data[ind]))); | 386 | (b_bgnd - qBlue (data[ind]))); |
385 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 387 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
386 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 388 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
387 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 389 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
388 | a = qAlpha(data[ind]); | 390 | a = qAlpha(data[ind]); |
389 | data[ind] = qRgba(r, g, b, a); | 391 | data[ind] = qRgba(r, g, b, a); |
390 | } | 392 | } |
391 | } | 393 | } |
392 | } | 394 | } |
393 | 395 | ||
394 | else if (eff == RectangleGradient || eff == EllipticGradient) { | 396 | else if (eff == RectangleGradient || eff == EllipticGradient) { |
395 | float xvar; | 397 | float xvar; |
396 | float yvar; | 398 | float yvar; |
397 | 399 | ||
398 | for (x = 0; x < image.width() / 2 + image.width() % 2; x++) { | 400 | for (x = 0; x < image.width() / 2 + image.width() % 2; x++) { |
399 | xvar = var / image.width() * (image.width() - x*2/unaffected-1); | 401 | xvar = var / image.width() * (image.width() - x*2/unaffected-1); |
400 | for (y = 0; y < image.height() / 2 + image.height() % 2; y++) { | 402 | for (y = 0; y < image.height() / 2 + image.height() % 2; y++) { |
401 | yvar = var / image.height() * (image.height() - y*2/unaffected -1); | 403 | yvar = var / image.height() * (image.height() - y*2/unaffected -1); |
402 | 404 | ||
403 | if (eff == RectangleGradient) | 405 | if (eff == RectangleGradient) |
404 | intensity = initial_intensity + QMAX(xvar, yvar); | 406 | intensity = initial_intensity + QMAX(xvar, yvar); |
405 | else | 407 | else |
406 | intensity = initial_intensity + qSqrt(xvar * xvar + yvar * yvar); | 408 | intensity = initial_intensity + qSqrt(xvar * xvar + yvar * yvar); |
407 | if (intensity > 1) intensity = 1; | 409 | if (intensity > 1) intensity = 1; |
408 | if (intensity < 0) intensity = 0; | 410 | if (intensity < 0) intensity = 0; |
409 | 411 | ||
410 | //NW | 412 | //NW |
411 | ind = x + image.width() * y ; | 413 | ind = x + image.width() * y ; |
412 | r = qRed (data[ind]) + (int)(intensity * | 414 | r = qRed (data[ind]) + (int)(intensity * |
413 | (r_bgnd - qRed (data[ind]))); | 415 | (r_bgnd - qRed (data[ind]))); |
414 | g = qGreen(data[ind]) + (int)(intensity * | 416 | g = qGreen(data[ind]) + (int)(intensity * |
415 | (g_bgnd - qGreen(data[ind]))); | 417 | (g_bgnd - qGreen(data[ind]))); |
416 | b = qBlue (data[ind]) + (int)(intensity * | 418 | b = qBlue (data[ind]) + (int)(intensity * |
417 | (b_bgnd - qBlue (data[ind]))); | 419 | (b_bgnd - qBlue (data[ind]))); |
418 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 420 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
419 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 421 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
420 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 422 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
421 | a = qAlpha(data[ind]); | 423 | a = qAlpha(data[ind]); |
422 | data[ind] = qRgba(r, g, b, a); | 424 | data[ind] = qRgba(r, g, b, a); |
423 | 425 | ||
424 | //NE | 426 | //NE |
425 | ind = image.width() - x - 1 + image.width() * y ; | 427 | ind = image.width() - x - 1 + image.width() * y ; |
426 | r = qRed (data[ind]) + (int)(intensity * | 428 | r = qRed (data[ind]) + (int)(intensity * |
427 | (r_bgnd - qRed (data[ind]))); | 429 | (r_bgnd - qRed (data[ind]))); |
428 | g = qGreen(data[ind]) + (int)(intensity * | 430 | g = qGreen(data[ind]) + (int)(intensity * |
429 | (g_bgnd - qGreen(data[ind]))); | 431 | (g_bgnd - qGreen(data[ind]))); |
430 | b = qBlue (data[ind]) + (int)(intensity * | 432 | b = qBlue (data[ind]) + (int)(intensity * |
431 | (b_bgnd - qBlue (data[ind]))); | 433 | (b_bgnd - qBlue (data[ind]))); |
432 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 434 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
433 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 435 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
434 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 436 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
435 | a = qAlpha(data[ind]); | 437 | a = qAlpha(data[ind]); |
436 | data[ind] = qRgba(r, g, b, a); | 438 | data[ind] = qRgba(r, g, b, a); |
437 | } | 439 | } |
438 | } | 440 | } |
439 | 441 | ||
440 | //CT loop is doubled because of stupid central row/column issue. | 442 | //CT loop is doubled because of stupid central row/column issue. |
441 | // other solution? | 443 | // other solution? |
442 | for (x = 0; x < image.width() / 2; x++) { | 444 | for (x = 0; x < image.width() / 2; x++) { |
443 | xvar = var / image.width() * (image.width() - x*2/unaffected-1); | 445 | xvar = var / image.width() * (image.width() - x*2/unaffected-1); |
444 | for (y = 0; y < image.height() / 2; y++) { | 446 | for (y = 0; y < image.height() / 2; y++) { |
445 | yvar = var / image.height() * (image.height() - y*2/unaffected -1); | 447 | yvar = var / image.height() * (image.height() - y*2/unaffected -1); |
446 | 448 | ||
447 | if (eff == RectangleGradient) | 449 | if (eff == RectangleGradient) |
448 | intensity = initial_intensity + QMAX(xvar, yvar); | 450 | intensity = initial_intensity + QMAX(xvar, yvar); |
449 | else | 451 | else |
450 | intensity = initial_intensity + qSqrt(xvar * xvar + yvar * yvar); | 452 | intensity = initial_intensity + qSqrt(xvar * xvar + yvar * yvar); |
451 | if (intensity > 1) intensity = 1; | 453 | if (intensity > 1) intensity = 1; |
452 | if (intensity < 0) intensity = 0; | 454 | if (intensity < 0) intensity = 0; |
453 | 455 | ||
454 | //SW | 456 | //SW |
455 | ind = x + image.width() * (image.height() - y -1) ; | 457 | ind = x + image.width() * (image.height() - y -1) ; |
456 | r = qRed (data[ind]) + (int)(intensity * | 458 | r = qRed (data[ind]) + (int)(intensity * |
457 | (r_bgnd - qRed (data[ind]))); | 459 | (r_bgnd - qRed (data[ind]))); |
458 | g = qGreen(data[ind]) + (int)(intensity * | 460 | g = qGreen(data[ind]) + (int)(intensity * |
459 | (g_bgnd - qGreen(data[ind]))); | 461 | (g_bgnd - qGreen(data[ind]))); |
460 | b = qBlue (data[ind]) + (int)(intensity * | 462 | b = qBlue (data[ind]) + (int)(intensity * |
461 | (b_bgnd - qBlue (data[ind]))); | 463 | (b_bgnd - qBlue (data[ind]))); |
462 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 464 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
463 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 465 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
464 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 466 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
465 | a = qAlpha(data[ind]); | 467 | a = qAlpha(data[ind]); |
466 | data[ind] = qRgba(r, g, b, a); | 468 | data[ind] = qRgba(r, g, b, a); |
467 | 469 | ||
468 | //SE | 470 | //SE |
469 | ind = image.width()-x-1 + image.width() * (image.height() - y - 1) ; | 471 | ind = image.width()-x-1 + image.width() * (image.height() - y - 1) ; |
470 | r = qRed (data[ind]) + (int)(intensity * | 472 | r = qRed (data[ind]) + (int)(intensity * |
471 | (r_bgnd - qRed (data[ind]))); | 473 | (r_bgnd - qRed (data[ind]))); |
472 | g = qGreen(data[ind]) + (int)(intensity * | 474 | g = qGreen(data[ind]) + (int)(intensity * |
473 | (g_bgnd - qGreen(data[ind]))); | 475 | (g_bgnd - qGreen(data[ind]))); |
474 | b = qBlue (data[ind]) + (int)(intensity * | 476 | b = qBlue (data[ind]) + (int)(intensity * |
475 | (b_bgnd - qBlue (data[ind]))); | 477 | (b_bgnd - qBlue (data[ind]))); |
476 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 478 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
477 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 479 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
478 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 480 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
479 | a = qAlpha(data[ind]); | 481 | a = qAlpha(data[ind]); |
480 | data[ind] = qRgba(r, g, b, a); | 482 | data[ind] = qRgba(r, g, b, a); |
481 | } | 483 | } |
482 | } | 484 | } |
483 | } | 485 | } |
diff --git a/noncore/styles/theme/othemestyle.cpp b/noncore/styles/theme/othemestyle.cpp index a820efb..98e7253 100644 --- a/noncore/styles/theme/othemestyle.cpp +++ b/noncore/styles/theme/othemestyle.cpp | |||
@@ -60,425 +60,429 @@ public: | |||
60 | p.setClipRegion( event->region().intersect(frameRect()) ); | 60 | p.setClipRegion( event->region().intersect(frameRect()) ); |
61 | drawFrame( &p); | 61 | drawFrame( &p); |
62 | p.restore(); | 62 | p.restore(); |
63 | } | 63 | } |
64 | if ( event->rect().intersects( contentsRect() )) { | 64 | if ( event->rect().intersects( contentsRect() )) { |
65 | p.setClipRegion( event->region().intersect( contentsRect() ) ); | 65 | p.setClipRegion( event->region().intersect( contentsRect() ) ); |
66 | 66 | ||
67 | int x, y, w, h; | 67 | int x, y, w, h; |
68 | contentsRect ( ). rect ( &x, &y, &w, &h ); | 68 | contentsRect ( ). rect ( &x, &y, &w, &h ); |
69 | 69 | ||
70 | int prog = progress ( ); | 70 | int prog = progress ( ); |
71 | int total = totalSteps ( ); | 71 | int total = totalSteps ( ); |
72 | if ( prog < 0 ) | 72 | if ( prog < 0 ) |
73 | prog = 0; | 73 | prog = 0; |
74 | if ( total <= 0 ) | 74 | if ( total <= 0 ) |
75 | total = 1; | 75 | total = 1; |
76 | int perc = prog * 100 / total; | 76 | int perc = prog * 100 / total; |
77 | 77 | ||
78 | style-> drawProgressBar ( &p, x, y, w, h, colorGroup ( ), perc ); | 78 | style-> drawProgressBar ( &p, x, y, w, h, colorGroup ( ), perc ); |
79 | 79 | ||
80 | if ( progress ( ) >= 0 && totalSteps ( ) > 0 ) { | 80 | if ( progress ( ) >= 0 && totalSteps ( ) > 0 ) { |
81 | QString pstr; | 81 | QString pstr; |
82 | pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); | 82 | pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); |
83 | p. setPen ( colorGroup().text());//g.highlightedText ( )); | 83 | p. setPen ( colorGroup().text());//g.highlightedText ( )); |
84 | p. drawText (x,y,w-1,h-1,AlignCenter,pstr); | 84 | p. drawText (x,y,w-1,h-1,AlignCenter,pstr); |
85 | } | 85 | } |
86 | } | 86 | } |
87 | } | 87 | } |
88 | }; | 88 | }; |
89 | 89 | ||
90 | 90 | ||
91 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) | 91 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) |
92 | 92 | ||
93 | OThemeStyle::OThemeStyle( const QString &configFile ) | 93 | OThemeStyle::OThemeStyle( const QString &configFile ) |
94 | : OThemeBase( configFile ) | 94 | : OThemeBase( configFile ) |
95 | { | 95 | { |
96 | setScrollBarExtent( getSBExtent(), getSBExtent() ); | 96 | setScrollBarExtent( getSBExtent(), getSBExtent() ); |
97 | setButtonDefaultIndicatorWidth( 0 ); // We REALLY should support one, see drawPushButton() below! | 97 | setButtonDefaultIndicatorWidth( 0 ); // We REALLY should support one, see drawPushButton() below! |
98 | } | 98 | } |
99 | 99 | ||
100 | OThemeStyle::~OThemeStyle() | 100 | OThemeStyle::~OThemeStyle() |
101 | {} | 101 | {} |
102 | 102 | ||
103 | void OThemeStyle::polish( QApplication * /*app*/ ) | 103 | void OThemeStyle::polish( QApplication * /*app*/ ) |
104 | { | 104 | { |
105 | qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &OThemeStyle::drawMenuBarItem); | 105 | qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &OThemeStyle::drawMenuBarItem); |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | void OThemeStyle::polish( QPalette &p ) | 109 | void OThemeStyle::polish( QPalette &p ) |
110 | { | 110 | { |
111 | oldPalette = p; | 111 | oldPalette = p; |
112 | 112 | ||
113 | QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background ); | 113 | QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background ); |
114 | 114 | ||
115 | if ( bgcolor. isValid ( )) | 115 | if ( bgcolor. isValid ( )) |
116 | bg = bgcolor; | 116 | bg = bgcolor; |
117 | 117 | ||
118 | if ( isColor ( Background )) | 118 | if ( isColor ( Background )) |
119 | bg = colorGroup ( oldPalette. active ( ), Background )-> background ( ); | 119 | bg = colorGroup ( oldPalette. active ( ), Background )-> background ( ); |
120 | 120 | ||
121 | p = QPalette ( bg, bg ); | 121 | p = QPalette ( bg, bg ); |
122 | 122 | ||
123 | if ( isPixmap( Background ) ) | 123 | if ( isPixmap( Background ) ) |
124 | p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background ))); | 124 | p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background ))); |
125 | 125 | ||
126 | if ( fgcolor. isValid ( )) { | 126 | if ( fgcolor. isValid ( )) { |
127 | p. setColor ( QColorGroup::Foreground, fgcolor ); | 127 | p. setColor ( QColorGroup::Foreground, fgcolor ); |
128 | p. setColor ( QColorGroup::ButtonText, fgcolor ); | 128 | p. setColor ( QColorGroup::ButtonText, fgcolor ); |
129 | } | 129 | } |
130 | if ( selfgcolor. isValid ( )) | 130 | if ( selfgcolor. isValid ( )) |
131 | p. setColor ( QColorGroup::HighlightedText, selfgcolor ); | 131 | p. setColor ( QColorGroup::HighlightedText, selfgcolor ); |
132 | if ( selbgcolor. isValid ( )) | 132 | if ( selbgcolor. isValid ( )) |
133 | p. setColor ( QColorGroup::Highlight, selbgcolor ); | 133 | p. setColor ( QColorGroup::Highlight, selbgcolor ); |
134 | if ( winfgcolor. isValid ( )) | 134 | if ( winfgcolor. isValid ( )) |
135 | p. setColor ( QColorGroup::Text, winfgcolor ); | 135 | p. setColor ( QColorGroup::Text, winfgcolor ); |
136 | if ( winbgcolor. isValid ( )) | 136 | if ( winbgcolor. isValid ( )) |
137 | p. setColor ( QColorGroup::Base, winbgcolor ); | 137 | p. setColor ( QColorGroup::Base, winbgcolor ); |
138 | 138 | ||
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | void OThemeStyle::unPolish( QApplication *app ) | 142 | void OThemeStyle::unPolish( QApplication *app ) |
143 | { | 143 | { |
144 | qt_set_draw_menu_bar_impl ( 0 ); | 144 | qt_set_draw_menu_bar_impl ( 0 ); |
145 | app->setPalette( oldPalette, true ); | 145 | app->setPalette( oldPalette, true ); |
146 | } | 146 | } |
147 | 147 | ||
148 | void OThemeStyle::polish( QWidget *w ) | 148 | void OThemeStyle::polish( QWidget *w ) |
149 | { | 149 | { |
150 | if ( !w->isTopLevel() ) { | 150 | if ( !w->isTopLevel() ) { |
151 | if ( w->inherits( "QGroupBox" ) | 151 | if ( w->inherits( "QGroupBox" ) |
152 | || w->inherits( "QTabWidget" ) ) { | 152 | || w->inherits( "QTabWidget" ) ) { |
153 | w->setAutoMask( TRUE ); | 153 | w->setAutoMask( TRUE ); |
154 | return ; | 154 | return ; |
155 | } | 155 | } |
156 | if ( w->inherits( "QLabel" ) | 156 | if ( w->inherits( "QLabel" ) |
157 | || w->inherits( "QSlider" ) | 157 | || w->inherits( "QSlider" ) |
158 | || w->inherits( "QButton" ) | 158 | || w->inherits( "QButton" ) |
159 | || w->inherits( "QProgressBar" ) | 159 | || w->inherits( "QProgressBar" ) |
160 | ) { | 160 | ) { |
161 | w->setBackgroundOrigin( QWidget::ParentOrigin ); | 161 | w->setBackgroundOrigin( QWidget::ParentOrigin ); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | if ( w->inherits( "QPopupMenu" ) ) { | 164 | if ( w->inherits( "QPopupMenu" ) ) { |
165 | popupPalette = w->palette(); | 165 | popupPalette = w->palette(); |
166 | if ( isColor( MenuItem ) || isColor( MenuItemDown ) ) { | 166 | if ( isColor( MenuItem ) || isColor( MenuItemDown ) ) { |
167 | QPalette newPal( w->palette() ); | 167 | QPalette newPal( w->palette() ); |
168 | w->setPalettePropagation( QWidget::SamePalette ); | 168 | w->setPalettePropagation( QWidget::SamePalette ); |
169 | if ( isColor( MenuItem ) ) { | 169 | if ( isColor( MenuItem ) ) { |
170 | newPal.setNormal( *colorGroup( newPal.normal(), MenuItem ) ); | 170 | newPal.setNormal( *colorGroup( newPal.normal(), MenuItem ) ); |
171 | newPal.setDisabled( *colorGroup( newPal.normal(), MenuItem ) ); | 171 | newPal.setDisabled( *colorGroup( newPal.normal(), MenuItem ) ); |
172 | } | 172 | } |
173 | if ( isColor( MenuItemDown ) ) | 173 | if ( isColor( MenuItemDown ) ) |
174 | newPal.setActive( *colorGroup( newPal.active(), MenuItemDown ) ); | 174 | newPal.setActive( *colorGroup( newPal.active(), MenuItemDown ) ); |
175 | w->setPalette( newPal ); | 175 | w->setPalette( newPal ); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | else if ( w->inherits( "QCheckBox" ) ) { | 178 | else if ( w->inherits( "QCheckBox" ) ) { |
179 | if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) ) { | 179 | if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) ) { |
180 | QPalette newPal( w->palette() ); | 180 | QPalette newPal( w->palette() ); |
181 | w->setPalettePropagation( QWidget::SamePalette ); | 181 | w->setPalettePropagation( QWidget::SamePalette ); |
182 | if ( isColor( IndicatorOff ) ) { | 182 | if ( isColor( IndicatorOff ) ) { |
183 | newPal.setNormal( *colorGroup( newPal.normal(), IndicatorOff ) ); | 183 | newPal.setNormal( *colorGroup( newPal.normal(), IndicatorOff ) ); |
184 | newPal.setDisabled( *colorGroup( newPal.normal(), IndicatorOff ) ); | 184 | newPal.setDisabled( *colorGroup( newPal.normal(), IndicatorOff ) ); |
185 | } | 185 | } |
186 | if ( isColor( IndicatorOn ) ) | 186 | if ( isColor( IndicatorOn ) ) |
187 | newPal.setActive( *colorGroup( newPal.active(), IndicatorOn ) ); | 187 | newPal.setActive( *colorGroup( newPal.active(), IndicatorOn ) ); |
188 | w->setPalette( newPal ); | 188 | w->setPalette( newPal ); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | else if ( w->inherits( "QRadioButton" ) ) { | 191 | else if ( w->inherits( "QRadioButton" ) ) { |
192 | if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) ) { | 192 | if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) ) { |
193 | QPalette newPal( w->palette() ); | 193 | QPalette newPal( w->palette() ); |
194 | w->setPalettePropagation( QWidget::SamePalette ); | 194 | w->setPalettePropagation( QWidget::SamePalette ); |
195 | if ( isColor( ExIndicatorOff ) ) { | 195 | if ( isColor( ExIndicatorOff ) ) { |
196 | newPal.setNormal( *colorGroup( newPal.normal(), ExIndicatorOff ) ); | 196 | newPal.setNormal( *colorGroup( newPal.normal(), ExIndicatorOff ) ); |
197 | newPal.setDisabled( *colorGroup( newPal.normal(), | 197 | newPal.setDisabled( *colorGroup( newPal.normal(), |
198 | ExIndicatorOff ) ); | 198 | ExIndicatorOff ) ); |
199 | } | 199 | } |
200 | if ( isColor( ExIndicatorOn ) ) | 200 | if ( isColor( ExIndicatorOn ) ) |
201 | newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOn ) ); | 201 | newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOn ) ); |
202 | w->setPalette( newPal ); | 202 | w->setPalette( newPal ); |
203 | } | 203 | } |
204 | } | 204 | } |
205 | else if ( w-> inherits ( "QProgressBar" ) ) { | 205 | else if ( w-> inherits ( "QProgressBar" ) ) { |
206 | w-> installEventFilter ( this ); | 206 | w-> installEventFilter ( this ); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | void OThemeStyle::unPolish( QWidget* w ) | 210 | void OThemeStyle::unPolish( QWidget* w ) |
211 | { | 211 | { |
212 | if ( !w->isTopLevel() ) { | 212 | if ( !w->isTopLevel() ) { |
213 | if ( w->inherits( "QGroupBox" ) | 213 | if ( w->inherits( "QGroupBox" ) |
214 | || w->inherits( "QTabWidget" ) ) { | 214 | || w->inherits( "QTabWidget" ) ) { |
215 | w->setAutoMask( FALSE ); | 215 | w->setAutoMask( FALSE ); |
216 | return ; | 216 | return ; |
217 | } | 217 | } |
218 | if ( w->inherits( "QLabel" ) | 218 | if ( w->inherits( "QLabel" ) |
219 | || w->inherits( "QSlider" ) | 219 | || w->inherits( "QSlider" ) |
220 | || w->inherits( "QButton" ) | 220 | || w->inherits( "QButton" ) |
221 | || w->inherits( "QProgressBar" ) | 221 | || w->inherits( "QProgressBar" ) |
222 | ) { | 222 | ) { |
223 | w->setBackgroundOrigin( QWidget::WidgetOrigin ); | 223 | w->setBackgroundOrigin( QWidget::WidgetOrigin ); |
224 | } | 224 | } |
225 | } | 225 | } |
226 | if ( w->inherits( "QPopupMenu" ) ) | 226 | if ( w->inherits( "QPopupMenu" ) ) |
227 | w->unsetPalette(); | 227 | w->unsetPalette(); |
228 | else if ( w->inherits( "QCheckBox" ) ) | 228 | else if ( w->inherits( "QCheckBox" ) ) |
229 | w->unsetPalette(); | 229 | w->unsetPalette(); |
230 | else if ( w->inherits( "QRadioButton" ) ) | 230 | else if ( w->inherits( "QRadioButton" ) ) |
231 | w->unsetPalette(); | 231 | w->unsetPalette(); |
232 | else if ( w-> inherits ( "QProgressBar" ) ) | 232 | else if ( w-> inherits ( "QProgressBar" ) ) |
233 | w-> removeEventFilter ( this ); | 233 | w-> removeEventFilter ( this ); |
234 | } | 234 | } |
235 | 235 | ||
236 | bool OThemeStyle::eventFilter ( QObject *obj, QEvent *ev ) | 236 | bool OThemeStyle::eventFilter ( QObject *obj, QEvent *ev ) |
237 | { | 237 | { |
238 | // only QProgressBar so far | 238 | // only QProgressBar so far |
239 | 239 | ||
240 | if ( ev-> type ( ) == QEvent::Paint ) { | 240 | if ( ev-> type ( ) == QEvent::Paint ) { |
241 | HackProgressBar *pb = (HackProgressBar *) obj; | 241 | HackProgressBar *pb = (HackProgressBar *) obj; |
242 | pb-> paint ((QPaintEvent *) ev, this ); | 242 | pb-> paint ((QPaintEvent *) ev, this ); |
243 | return true; | 243 | return true; |
244 | } | 244 | } |
245 | return false; | 245 | return false; |
246 | } | 246 | } |
247 | 247 | ||
248 | void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h, | 248 | void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h, |
249 | const QColorGroup &g, bool sunken, bool | 249 | const QColorGroup &g, bool sunken, bool |
250 | rounded, WidgetType type, const QBrush * ) | 250 | rounded, WidgetType type, const QBrush * ) |
251 | { | 251 | { |
252 | if ( w <= 0 || h <= 0 ) | ||
253 | return; | ||
254 | |||
252 | int offset = borderPixmap( type ) ? 0 : decoWidth( type ); | 255 | int offset = borderPixmap( type ) ? 0 : decoWidth( type ); |
253 | QPen oldPen = p->pen(); | 256 | QPen oldPen = p->pen(); |
254 | 257 | ||
255 | // handle reverse bevel here since it uses decowidth differently | 258 | // handle reverse bevel here since it uses decowidth differently |
256 | if ( gradientHint( type ) == GrReverseBevel ) { | 259 | if ( gradientHint( type ) == GrReverseBevel ) { |
257 | int i; | 260 | int i; |
258 | bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h, | 261 | bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h, |
259 | Qt::CopyROP, true ); | 262 | Qt::CopyROP, true ); |
260 | p->setPen( g.text() ); | 263 | p->setPen( g.text() ); |
261 | for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 ) | 264 | for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 ) |
262 | p->drawRect( x, y, w, h ); | 265 | p->drawRect( x, y, w, h ); |
263 | } | 266 | } |
264 | // same with KDE style borders | 267 | // same with KDE style borders |
265 | else if ( !borderPixmap( type ) && shade() == KDE ) { | 268 | else if ( !borderPixmap( type ) && shade() == KDE ) { |
266 | qDrawWinButton( p, x, y, w, h, g, sunken ); | 269 | qDrawWinButton( p, x, y, w, h, g, sunken ); |
267 | if ( isPixmap( type ) ) | 270 | if ( isPixmap( type ) ) |
268 | p->drawTiledPixmap( x + 4, y + 4, w - 6, h - 6, | 271 | p->drawTiledPixmap( x + 4, y + 4, w - 6, h - 6, |
269 | *scalePixmap( w - 6, h - 6, | 272 | *scalePixmap( w - 6, h - 6, |
270 | type ) ); | 273 | type ) ); |
271 | else | 274 | else |
272 | p->fillRect( x + 4, y + 4, w - 6, h - offset * 6, | 275 | p->fillRect( x + 4, y + 4, w - 6, h - offset * 6, |
273 | g.brush( QColorGroup::Button ) ); | 276 | g.brush( QColorGroup::Button ) ); |
274 | 277 | ||
275 | } | 278 | } |
276 | else { | 279 | else { |
277 | if ( ( w - offset * 2 ) > 0 && ( h - offset * 2 ) > 0 ) { | 280 | if ( ( w - offset * 2 ) > 0 && ( h - offset * 2 ) > 0 ) { |
278 | if ( isPixmap( type ) ) | 281 | if ( isPixmap( type ) ) |
279 | if ( rounded ) | 282 | if ( rounded ) |
280 | p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) ); | 283 | p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) ); |
281 | else | 284 | else |
282 | p->drawTiledPixmap( x + offset, y + offset, w - offset * 2, | 285 | p->drawTiledPixmap( x + offset, y + offset, w - offset * 2, |
283 | h - offset * 2, | 286 | h - offset * 2, |
284 | *scalePixmap( w - offset * 2, h - offset * 2, | 287 | *scalePixmap( w - offset * 2, h - offset * 2, |
285 | type ) ); | 288 | type ) ); |
286 | else | 289 | else |
287 | p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2, | 290 | p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2, |
288 | g.brush( QColorGroup::Button ) ); | 291 | g.brush( QColorGroup::Button ) ); |
289 | } | 292 | } |
290 | if ( borderPixmap( type ) ) | 293 | if ( borderPixmap( type ) ) { |
291 | bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h, | 294 | bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h, |
292 | Qt::CopyROP, false ); | 295 | Qt::CopyROP, false ); |
296 | } | ||
293 | else | 297 | else |
294 | drawShade( p, x, y, w, h, g, sunken, rounded, | 298 | drawShade( p, x, y, w, h, g, sunken, rounded, |
295 | highlightWidth( type ), borderWidth( type ), shade() ); | 299 | highlightWidth( type ), borderWidth( type ), shade() ); |
296 | } | 300 | } |
297 | p->setPen( oldPen ); | 301 | p->setPen( oldPen ); |
298 | } | 302 | } |
299 | 303 | ||
300 | void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h, | 304 | void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h, |
301 | const QColorGroup &g, bool sunken, | 305 | const QColorGroup &g, bool sunken, |
302 | const QBrush *fill ) | 306 | const QBrush *fill ) |
303 | { | 307 | { |
304 | drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ? | 308 | drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ? |
305 | PushButtonDown : PushButton, fill ); | 309 | PushButtonDown : PushButton, fill ); |
306 | } | 310 | } |
307 | 311 | ||
308 | void OThemeStyle::drawPushButton( QPushButton* btn, QPainter *p ) | 312 | void OThemeStyle::drawPushButton( QPushButton* btn, QPainter *p ) |
309 | { | 313 | { |
310 | bool sunken = btn->isOn() || btn->isDown(); | 314 | bool sunken = btn->isOn() || btn->isDown(); |
311 | int diw = buttonDefaultIndicatorWidth(); | 315 | int diw = buttonDefaultIndicatorWidth(); |
312 | drawBaseButton( p, diw, diw, btn->width() - 2 * diw, btn->height() - 2 * diw, | 316 | drawBaseButton( p, diw, diw, btn->width() - 2 * diw, btn->height() - 2 * diw, |
313 | *colorGroup( btn->colorGroup(), sunken ? PushButtonDown : | 317 | *colorGroup( btn->colorGroup(), sunken ? PushButtonDown : |
314 | PushButton ), sunken, roundButton(), | 318 | PushButton ), sunken, roundButton(), |
315 | sunken ? PushButtonDown : PushButton, NULL ); | 319 | sunken ? PushButtonDown : PushButton, NULL ); |
316 | // TODO if diw, draw fancy default button indicator | 320 | // TODO if diw, draw fancy default button indicator |
317 | } | 321 | } |
318 | 322 | ||
319 | void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h, | 323 | void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h, |
320 | bool round ) | 324 | bool round ) |
321 | { | 325 | { |
322 | // round edge fills | 326 | // round edge fills |
323 | static const QCOORD btm_left_fill[] = { | 327 | static const QCOORD btm_left_fill[] = { |
324 | 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, | 328 | 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, |
325 | 1, 2, 2, 2, 3, 2, 4, 2, 2, 3, 3, 3, 4, 3, 3, 4, 4, 4 | 329 | 1, 2, 2, 2, 3, 2, 4, 2, 2, 3, 3, 3, 4, 3, 3, 4, 4, 4 |
326 | }; | 330 | }; |
327 | 331 | ||
328 | static const QCOORD btm_right_fill[] = { | 332 | static const QCOORD btm_right_fill[] = { |
329 | 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, | 333 | 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, |
330 | 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4 | 334 | 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4 |
331 | }; | 335 | }; |
332 | 336 | ||
333 | static const QCOORD top_left_fill[] = { | 337 | static const QCOORD top_left_fill[] = { |
334 | 3, 0, 4, 0, 2, 1, 3, 1, 4, 1, 1, 2, 2, 2, 3, 2, 4, 2, 0, 3, | 338 | 3, 0, 4, 0, 2, 1, 3, 1, 4, 1, 1, 2, 2, 2, 3, 2, 4, 2, 0, 3, |
335 | 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 | 339 | 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 |
336 | }; | 340 | }; |
337 | 341 | ||
338 | static const QCOORD top_right_fill[] = { | 342 | static const QCOORD top_right_fill[] = { |
339 | 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, | 343 | 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, |
340 | 3, 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 | 344 | 3, 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 |
341 | }; | 345 | }; |
342 | 346 | ||
343 | QBrush fillBrush( color1, SolidPattern ); | 347 | QBrush fillBrush( color1, SolidPattern ); |
344 | p->setPen( color1 ); | 348 | p->setPen( color1 ); |
345 | if ( round && w > 19 && h > 19 ) { | 349 | if ( round && w > 19 && h > 19 ) { |
346 | int x2 = x + w - 1; | 350 | int x2 = x + w - 1; |
347 | int y2 = y + h - 1; | 351 | int y2 = y + h - 1; |
348 | QPointArray a( QCOORDARRLEN( top_left_fill ), top_left_fill ); | 352 | QPointArray a( QCOORDARRLEN( top_left_fill ), top_left_fill ); |
349 | a.translate( 1, 1 ); | 353 | a.translate( 1, 1 ); |
350 | p->drawPoints( a ); | 354 | p->drawPoints( a ); |
351 | a.setPoints( QCOORDARRLEN( btm_left_fill ), btm_left_fill ); | 355 | a.setPoints( QCOORDARRLEN( btm_left_fill ), btm_left_fill ); |
352 | a.translate( 1, h - 6 ); | 356 | a.translate( 1, h - 6 ); |
353 | p->drawPoints( a ); | 357 | p->drawPoints( a ); |
354 | a.setPoints( QCOORDARRLEN( top_right_fill ), top_right_fill ); | 358 | a.setPoints( QCOORDARRLEN( top_right_fill ), top_right_fill ); |
355 | a.translate( w - 6, 1 ); | 359 | a.translate( w - 6, 1 ); |
356 | p->drawPoints( a ); | 360 | p->drawPoints( a ); |
357 | a.setPoints( QCOORDARRLEN( btm_right_fill ), btm_right_fill ); | 361 | a.setPoints( QCOORDARRLEN( btm_right_fill ), btm_right_fill ); |
358 | a.translate( w - 6, h - 6 ); | 362 | a.translate( w - 6, h - 6 ); |
359 | p->drawPoints( a ); | 363 | p->drawPoints( a ); |
360 | 364 | ||
361 | p->fillRect( x + 6, y, w - 12, h, fillBrush ); | 365 | p->fillRect( x + 6, y, w - 12, h, fillBrush ); |
362 | p->fillRect( x, y + 6, x + 6, h - 12, fillBrush ); | 366 | p->fillRect( x, y + 6, x + 6, h - 12, fillBrush ); |
363 | p->fillRect( x2 - 6, y + 6, x2, h - 12, fillBrush ); | 367 | p->fillRect( x2 - 6, y + 6, x2, h - 12, fillBrush ); |
364 | p->drawLine( x + 6, y, x2 - 6, y ); | 368 | p->drawLine( x + 6, y, x2 - 6, y ); |
365 | p->drawLine( x + 6, y2, x2 - 6, y2 ); | 369 | p->drawLine( x + 6, y2, x2 - 6, y2 ); |
366 | p->drawLine( x, y + 6, x, y2 - 6 ); | 370 | p->drawLine( x, y + 6, x, y2 - 6 ); |
367 | p->drawLine( x2, y + 6, x2, y2 - 6 ); | 371 | p->drawLine( x2, y + 6, x2, y2 - 6 ); |
368 | 372 | ||
369 | } | 373 | } |
370 | else | 374 | else |
371 | p->fillRect( x, y, w, h, fillBrush ); | 375 | p->fillRect( x, y, w, h, fillBrush ); |
372 | } | 376 | } |
373 | 377 | ||
374 | void OThemeStyle::drawButtonMask( QPainter *p, int x, int y, int w, int h ) | 378 | void OThemeStyle::drawButtonMask( QPainter *p, int x, int y, int w, int h ) |
375 | { | 379 | { |
376 | drawBaseMask( p, x, y, w, h, roundButton() ); | 380 | drawBaseMask( p, x, y, w, h, roundButton() ); |
377 | } | 381 | } |
378 | 382 | ||
379 | void OThemeStyle::drawComboButtonMask( QPainter *p, int x, int y, int w, int h ) | 383 | void OThemeStyle::drawComboButtonMask( QPainter *p, int x, int y, int w, int h ) |
380 | { | 384 | { |
381 | drawBaseMask( p, x, y, w, h, roundComboBox() ); | 385 | drawBaseMask( p, x, y, w, h, roundComboBox() ); |
382 | } | 386 | } |
383 | 387 | ||
384 | void OThemeStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, | 388 | void OThemeStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, |
385 | const QColorGroup &g, bool sunken, | 389 | const QColorGroup &g, bool sunken, |
386 | const QBrush * ) | 390 | const QBrush * ) |
387 | { | 391 | { |
388 | WidgetType type = sunken ? BevelDown : Bevel; | 392 | WidgetType type = sunken ? BevelDown : Bevel; |
389 | drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); | 393 | drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); |
390 | } | 394 | } |
391 | 395 | ||
392 | void OThemeStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, | 396 | void OThemeStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, |
393 | const QColorGroup &g, bool sunken, | 397 | const QColorGroup &g, bool sunken, |
394 | const QBrush * ) | 398 | const QBrush * ) |
395 | { | 399 | { |
396 | WidgetType type = sunken ? ToolButtonDown : ToolButton; | 400 | WidgetType type = sunken ? ToolButtonDown : ToolButton; |
397 | drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); | 401 | drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); |
398 | } | 402 | } |
399 | 403 | ||
400 | #if 0 | 404 | #if 0 |
401 | void OThemeStyle::drawKToolBarButton( QPainter *p, int x, int y, int w, int h, | 405 | void OThemeStyle::drawKToolBarButton( QPainter *p, int x, int y, int w, int h, |
402 | const QColorGroup &g, bool sunken, | 406 | const QColorGroup &g, bool sunken, |
403 | bool raised, bool enabled, bool popup, | 407 | bool raised, bool enabled, bool popup, |
404 | KToolButtonType type, const QString &btext, | 408 | KToolButtonType type, const QString &btext, |
405 | const QPixmap *pixmap, QFont *font, | 409 | const QPixmap *pixmap, QFont *font, |
406 | QWidget * ) | 410 | QWidget * ) |
407 | { | 411 | { |
408 | QFont tmp_font( QString::fromLatin1( "Helvetica" ), 10 ); | 412 | QFont tmp_font( QString::fromLatin1( "Helvetica" ), 10 ); |
409 | if ( font ) | 413 | if ( font ) |
410 | tmp_font = *font; | 414 | tmp_font = *font; |
411 | QFontMetrics fm( tmp_font ); | 415 | QFontMetrics fm( tmp_font ); |
412 | WidgetType widget = sunken ? ToolButtonDown : ToolButton; | 416 | WidgetType widget = sunken ? ToolButtonDown : ToolButton; |
413 | 417 | ||
414 | drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, false, | 418 | drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, false, |
415 | widget ); | 419 | widget ); |
416 | int dx, dy; | 420 | int dx, dy; |
417 | if ( type == Icon ) { // icon only | 421 | if ( type == Icon ) { // icon only |
418 | if ( pixmap ) { | 422 | if ( pixmap ) { |
419 | dx = ( w - pixmap->width() ) / 2; | 423 | dx = ( w - pixmap->width() ) / 2; |
420 | dy = ( h - pixmap->height() ) / 2; | 424 | dy = ( h - pixmap->height() ) / 2; |
421 | if ( sunken ) { | 425 | if ( sunken ) { |
422 | ++dx; | 426 | ++dx; |
423 | ++dy; | 427 | ++dy; |
424 | } | 428 | } |
425 | p->drawPixmap( x + dx, y + dy, *pixmap ); | 429 | p->drawPixmap( x + dx, y + dy, *pixmap ); |
426 | } | 430 | } |
427 | } | 431 | } |
428 | else if ( type == IconTextRight ) { // icon and text (if any) | 432 | else if ( type == IconTextRight ) { // icon and text (if any) |
429 | if ( pixmap ) { | 433 | if ( pixmap ) { |
430 | dx = 4; | 434 | dx = 4; |
431 | dy = ( h - pixmap->height() ) / 2; | 435 | dy = ( h - pixmap->height() ) / 2; |
432 | if ( sunken ) { | 436 | if ( sunken ) { |
433 | ++dx; | 437 | ++dx; |
434 | ++dy; | 438 | ++dy; |
435 | } | 439 | } |
436 | p->drawPixmap( x + dx, y + dy, *pixmap ); | 440 | p->drawPixmap( x + dx, y + dy, *pixmap ); |
437 | } | 441 | } |
438 | if ( !btext.isNull() ) { | 442 | if ( !btext.isNull() ) { |
439 | int tf = AlignVCenter | AlignLeft; | 443 | int tf = AlignVCenter | AlignLeft; |
440 | if ( pixmap ) | 444 | if ( pixmap ) |
441 | dx = 4 + pixmap->width() + 2; | 445 | dx = 4 + pixmap->width() + 2; |
442 | else | 446 | else |
443 | dx = 4; | 447 | dx = 4; |
444 | dy = 0; | 448 | dy = 0; |
445 | if ( sunken ) { | 449 | if ( sunken ) { |
446 | ++dx; | 450 | ++dx; |
447 | ++dy; | 451 | ++dy; |
448 | } | 452 | } |
449 | if ( font ) | 453 | if ( font ) |
450 | p->setFont( *font ); | 454 | p->setFont( *font ); |
451 | if ( raised ) | 455 | if ( raised ) |
452 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); | 456 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); |
453 | p->drawText( x + dx, y + dy, w - dx, h, tf, btext ); | 457 | p->drawText( x + dx, y + dy, w - dx, h, tf, btext ); |
454 | } | 458 | } |
455 | } | 459 | } |
456 | else if ( type == Text ) { // only text, even if there is a icon | 460 | else if ( type == Text ) { // only text, even if there is a icon |
457 | if ( !btext.isNull() ) { | 461 | if ( !btext.isNull() ) { |
458 | int tf = AlignTop | AlignLeft; | 462 | int tf = AlignTop | AlignLeft; |
459 | if ( !enabled ) | 463 | if ( !enabled ) |
460 | p->setPen( g.dark() ); | 464 | p->setPen( g.dark() ); |
461 | dx = ( w - fm.width( btext ) ) / 2; | 465 | dx = ( w - fm.width( btext ) ) / 2; |
462 | dy = ( h - fm.lineSpacing() ) / 2; | 466 | dy = ( h - fm.lineSpacing() ) / 2; |
463 | if ( sunken ) { | 467 | if ( sunken ) { |
464 | ++dx; | 468 | ++dx; |
465 | ++dy; | 469 | ++dy; |
466 | } | 470 | } |
467 | if ( font ) | 471 | if ( font ) |
468 | p->setFont( *font ); | 472 | p->setFont( *font ); |
469 | if ( raised ) | 473 | if ( raised ) |
470 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); | 474 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); |
471 | p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); | 475 | p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); |
472 | } | 476 | } |
473 | } | 477 | } |
474 | else if ( type == IconTextBottom ) { | 478 | else if ( type == IconTextBottom ) { |
475 | if ( pixmap ) { | 479 | if ( pixmap ) { |
476 | dx = ( w - pixmap->width() ) / 2; | 480 | dx = ( w - pixmap->width() ) / 2; |
477 | dy = ( h - fm.lineSpacing() - pixmap->height() ) / 2; | 481 | dy = ( h - fm.lineSpacing() - pixmap->height() ) / 2; |
478 | if ( sunken ) { | 482 | if ( sunken ) { |
479 | ++dx; | 483 | ++dx; |
480 | ++dy; | 484 | ++dy; |
481 | } | 485 | } |
482 | p->drawPixmap( x + dx, y + dy, *pixmap ); | 486 | p->drawPixmap( x + dx, y + dy, *pixmap ); |
483 | } | 487 | } |
484 | if ( !btext.isNull() ) { | 488 | if ( !btext.isNull() ) { |