author | sandman <sandman> | 2002-11-01 16:07:10 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-01 16:07:10 (UTC) |
commit | 9e4d914ade0af86707531a80e93a870e52738ce6 (patch) (unidiff) | |
tree | 13bcdec43e9d1afc7392ce44cd72ff1289f0c8eb | |
parent | 28b70b2b7f8fa03ba0991fb73dccf7b46e5c3d1f (diff) | |
download | opie-9e4d914ade0af86707531a80e93a870e52738ce6.zip opie-9e4d914ade0af86707531a80e93a870e52738ce6.tar.gz opie-9e4d914ade0af86707531a80e93a870e52738ce6.tar.bz2 |
Some fixes and enhancements:
- don't rely on clipping information from Qt/E -- this doesn't work
- theme style has support for all KDE gradient types now
-rw-r--r-- | noncore/styles/theme/ogfxeffect.cpp | 249 | ||||
-rw-r--r-- | noncore/styles/theme/ogfxeffect.h | 3 | ||||
-rw-r--r-- | noncore/styles/theme/othemestyle.cpp | 7 |
3 files changed, 223 insertions, 36 deletions
diff --git a/noncore/styles/theme/ogfxeffect.cpp b/noncore/styles/theme/ogfxeffect.cpp index 55f3c1f..cc5bbcd 100644 --- a/noncore/styles/theme/ogfxeffect.cpp +++ b/noncore/styles/theme/ogfxeffect.cpp | |||
@@ -1,324 +1,507 @@ | |||
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 | 17 | ||
18 | //====================================================================== | 18 | //====================================================================== |
19 | // | 19 | // |
20 | // Gradient effects | 20 | // Gradient effects |
21 | // | 21 | // |
22 | //====================================================================== | 22 | //====================================================================== |
23 | 23 | ||
24 | 24 | ||
25 | QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca, | 25 | QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca, |
26 | const QColor &cb, GradientType eff, int /*ncols*/) | 26 | const QColor &cb, GradientType eff, int ncols) |
27 | { | 27 | { |
28 | if(pixmap.depth() > 8 && | 28 | QImage image = gradient(pixmap.size(), ca, cb, eff, ncols); |
29 | (eff == VerticalGradient || eff == HorizontalGradient)) { | 29 | pixmap.convertFromImage(image); |
30 | 30 | ||
31 | int rDiff, gDiff, bDiff; | 31 | return pixmap; |
32 | int rca, gca, bca /*, rcb, gcb, bcb*/; | 32 | } |
33 | |||
34 | QImage OGfxEffect::gradient(const QSize &size, const QColor &ca, | ||
35 | const QColor &cb, GradientType eff, int /*ncols*/) | ||
36 | { | ||
37 | int rDiff, gDiff, bDiff; | ||
38 | int rca, gca, bca, rcb, gcb, bcb; | ||
39 | |||
40 | QImage image(size, 32); | ||
41 | |||
42 | if (size.width() == 0 || size.height() == 0) { | ||
43 | qDebug ( "WARNING: OGfxEffect::gradient: invalid image" ); | ||
44 | return image; | ||
45 | } | ||
46 | |||
47 | register int x, y; | ||
33 | 48 | ||
34 | register int x, y; | 49 | rDiff = (rcb = cb.red()) - (rca = ca.red()); |
50 | gDiff = (gcb = cb.green()) - (gca = ca.green()); | ||
51 | bDiff = (bcb = cb.blue()) - (bca = ca.blue()); | ||
35 | 52 | ||
36 | rDiff = (/*rcb = */ cb.red()) - (rca = ca.red()); | 53 | if( eff == VerticalGradient || eff == HorizontalGradient ){ |
37 | gDiff = (/*gcb = */ cb.green()) - (gca = ca.green()); | 54 | |
38 | bDiff = (/*bcb = */ cb.blue()) - (bca = ca.blue()); | 55 | uint *p; |
56 | uint rgb; | ||
39 | 57 | ||
40 | register int rl = rca << 16; | 58 | register int rl = rca << 16; |
41 | register int gl = gca << 16; | 59 | register int gl = gca << 16; |
42 | register int bl = bca << 16; | 60 | register int bl = bca << 16; |
43 | 61 | ||
44 | int rcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * rDiff; | 62 | if( eff == VerticalGradient ) { |
45 | int gcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * gDiff; | 63 | |
46 | int bcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * bDiff; | 64 | int rcdelta = ((1<<16) / size.height()) * rDiff; |
65 | int gcdelta = ((1<<16) / size.height()) * gDiff; | ||
66 | int bcdelta = ((1<<16) / size.height()) * bDiff; | ||
47 | 67 | ||
48 | QPainter p(&pixmap); | 68 | for ( y = 0; y < size.height(); y++ ) { |
69 | p = (uint *) image.scanLine(y); | ||
49 | 70 | ||
50 | // these for-loops could be merged, but the if's in the inner loop | ||
51 | // would make it slow | ||
52 | switch(eff) { | ||
53 | case VerticalGradient: | ||
54 | for ( y = 0; y < pixmap.height(); y++ ) { | ||
55 | rl += rcdelta; | 71 | rl += rcdelta; |
56 | gl += gcdelta; | 72 | gl += gcdelta; |
57 | bl += bcdelta; | 73 | bl += bcdelta; |
58 | 74 | ||
59 | p.setPen(QColor(rl>>16, gl>>16, bl>>16)); | 75 | rgb = qRgb( (rl>>16), (gl>>16), (bl>>16) ); |
60 | p.drawLine(0, y, pixmap.width()-1, y); | 76 | |
77 | for( x = 0; x < size.width(); x++ ) { | ||
78 | *p = rgb; | ||
79 | p++; | ||
80 | } | ||
61 | } | 81 | } |
62 | break; | 82 | |
63 | case HorizontalGradient: | 83 | } |
64 | for( x = 0; x < pixmap.width(); x++) { | 84 | else { // must be HorizontalGradient |
85 | |||
86 | unsigned int *o_src = (unsigned int *)image.scanLine(0); | ||
87 | unsigned int *src = o_src; | ||
88 | |||
89 | int rcdelta = ((1<<16) / size.width()) * rDiff; | ||
90 | int gcdelta = ((1<<16) / size.width()) * gDiff; | ||
91 | int bcdelta = ((1<<16) / size.width()) * bDiff; | ||
92 | |||
93 | for( x = 0; x < size.width(); x++) { | ||
94 | |||
65 | rl += rcdelta; | 95 | rl += rcdelta; |
66 | gl += gcdelta; | 96 | gl += gcdelta; |
67 | bl += bcdelta; | 97 | bl += bcdelta; |
68 | 98 | ||
69 | p.setPen(QColor(rl>>16, gl>>16, bl>>16)); | 99 | *src++ = qRgb( (rl>>16), (gl>>16), (bl>>16)); |
70 | p.drawLine(x, 0, x, pixmap.height()-1); | 100 | } |
101 | |||
102 | src = o_src; | ||
103 | |||
104 | // Believe it or not, manually copying in a for loop is faster | ||
105 | // than calling memcpy for each scanline (on the order of ms...). | ||
106 | // I think this is due to the function call overhead (mosfet). | ||
107 | |||
108 | for (y = 1; y < size.height(); ++y) { | ||
109 | |||
110 | p = (unsigned int *)image.scanLine(y); | ||
111 | src = o_src; | ||
112 | for(x=0; x < size.width(); ++x) | ||
113 | *p++ = *src++; | ||
71 | } | 114 | } |
72 | break; | ||
73 | default: | ||
74 | ; | ||
75 | } | 115 | } |
76 | } | 116 | } |
117 | |||
77 | else { | 118 | else { |
78 | // QImage image = OGfxEffect::gradient(pixmap.size(), ca, cb, | ||
79 | // (OGfxEffect::GradientType) eff, ncols); | ||
80 | // pixmap.convertFromImage(image); | ||
81 | } | ||
82 | 119 | ||
83 | return pixmap; | 120 | float rfd, gfd, bfd; |
121 | float rd = rca, gd = gca, bd = bca; | ||
122 | |||
123 | unsigned char *xtable[3]; | ||
124 | unsigned char *ytable[3]; | ||
125 | |||
126 | unsigned int w = size.width(), h = size.height(); | ||
127 | xtable[0] = new unsigned char[w]; | ||
128 | xtable[1] = new unsigned char[w]; | ||
129 | xtable[2] = new unsigned char[w]; | ||
130 | ytable[0] = new unsigned char[h]; | ||
131 | ytable[1] = new unsigned char[h]; | ||
132 | ytable[2] = new unsigned char[h]; | ||
133 | w*=2, h*=2; | ||
134 | |||
135 | if ( eff == DiagonalGradient || eff == CrossDiagonalGradient) { | ||
136 | // Diagonal dgradient code inspired by BlackBox (mosfet) | ||
137 | // BlackBox dgradient is (C) Brad Hughes, <bhughes@tcac.net> and | ||
138 | // Mike Cole <mike@mydot.com>. | ||
139 | |||
140 | rfd = (float)rDiff/w; | ||
141 | gfd = (float)gDiff/w; | ||
142 | bfd = (float)bDiff/w; | ||
143 | |||
144 | int dir; | ||
145 | for (x = 0; x < size.width(); x++, rd+=rfd, gd+=gfd, bd+=bfd) { | ||
146 | dir = eff == DiagonalGradient? x : size.width() - x - 1; | ||
147 | xtable[0][dir] = (unsigned char) rd; | ||
148 | xtable[1][dir] = (unsigned char) gd; | ||
149 | xtable[2][dir] = (unsigned char) bd; | ||
150 | } | ||
151 | rfd = (float)rDiff/h; | ||
152 | gfd = (float)gDiff/h; | ||
153 | bfd = (float)bDiff/h; | ||
154 | rd = gd = bd = 0; | ||
155 | for (y = 0; y < size.height(); y++, rd+=rfd, gd+=gfd, bd+=bfd) { | ||
156 | ytable[0][y] = (unsigned char) rd; | ||
157 | ytable[1][y] = (unsigned char) gd; | ||
158 | ytable[2][y] = (unsigned char) bd; | ||
159 | } | ||
160 | |||
161 | for (y = 0; y < size.height(); y++) { | ||
162 | unsigned int *scanline = (unsigned int *)image.scanLine(y); | ||
163 | for (x = 0; x < size.width(); x++) { | ||
164 | scanline[x] = qRgb(xtable[0][x] + ytable[0][y], | ||
165 | xtable[1][x] + ytable[1][y], | ||
166 | xtable[2][x] + ytable[2][y]); | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | |||
171 | else if (eff == RectangleGradient || | ||
172 | eff == PyramidGradient || | ||
173 | eff == PipeCrossGradient || | ||
174 | eff == EllipticGradient) | ||
175 | { | ||
176 | int rSign = rDiff>0? 1: -1; | ||
177 | int gSign = gDiff>0? 1: -1; | ||
178 | int bSign = bDiff>0? 1: -1; | ||
179 | |||
180 | rfd = (float)rDiff / size.width(); | ||
181 | gfd = (float)gDiff / size.width(); | ||
182 | bfd = (float)bDiff / size.width(); | ||
183 | |||
184 | rd = (float)rDiff/2; | ||
185 | gd = (float)gDiff/2; | ||
186 | bd = (float)bDiff/2; | ||
187 | |||
188 | for (x = 0; x < size.width(); x++, rd-=rfd, gd-=gfd, bd-=bfd) | ||
189 | { | ||
190 | xtable[0][x] = (unsigned char) abs((int)rd); | ||
191 | xtable[1][x] = (unsigned char) abs((int)gd); | ||
192 | xtable[2][x] = (unsigned char) abs((int)bd); | ||
193 | } | ||
194 | |||
195 | rfd = (float)rDiff/size.height(); | ||
196 | gfd = (float)gDiff/size.height(); | ||
197 | bfd = (float)bDiff/size.height(); | ||
198 | |||
199 | rd = (float)rDiff/2; | ||
200 | gd = (float)gDiff/2; | ||
201 | bd = (float)bDiff/2; | ||
202 | |||
203 | for (y = 0; y < size.height(); y++, rd-=rfd, gd-=gfd, bd-=bfd) | ||
204 | { | ||
205 | ytable[0][y] = (unsigned char) abs((int)rd); | ||
206 | ytable[1][y] = (unsigned char) abs((int)gd); | ||
207 | ytable[2][y] = (unsigned char) abs((int)bd); | ||
208 | } | ||
209 | unsigned int rgb; | ||
210 | int h = (size.height()+1)>>1; | ||
211 | for (y = 0; y < h; y++) { | ||
212 | unsigned int *sl1 = (unsigned int *)image.scanLine(y); | ||
213 | unsigned int *sl2 = (unsigned int *)image.scanLine(QMAX(size.height()-y-1, y)); | ||
214 | |||
215 | int w = (size.width()+1)>>1; | ||
216 | int x2 = size.width()-1; | ||
217 | |||
218 | for (x = 0; x < w; x++, x2--) { | ||
219 | rgb = 0; | ||
220 | if (eff == PyramidGradient) { | ||
221 | rgb = qRgb(rcb-rSign*(xtable[0][x]+ytable[0][y]), | ||
222 | gcb-gSign*(xtable[1][x]+ytable[1][y]), | ||
223 | bcb-bSign*(xtable[2][x]+ytable[2][y])); | ||
224 | } | ||
225 | if (eff == RectangleGradient) { | ||
226 | rgb = qRgb(rcb - rSign * | ||
227 | QMAX(xtable[0][x], ytable[0][y]) * 2, | ||
228 | gcb - gSign * | ||
229 | QMAX(xtable[1][x], ytable[1][y]) * 2, | ||
230 | bcb - bSign * | ||
231 | QMAX(xtable[2][x], ytable[2][y]) * 2); | ||
232 | } | ||
233 | if (eff == PipeCrossGradient) { | ||
234 | rgb = qRgb(rcb - rSign * | ||
235 | QMIN(xtable[0][x], ytable[0][y]) * 2, | ||
236 | gcb - gSign * | ||
237 | QMIN(xtable[1][x], ytable[1][y]) * 2, | ||
238 | bcb - bSign * | ||
239 | QMIN(xtable[2][x], ytable[2][y]) * 2); | ||
240 | } | ||
241 | if (eff == EllipticGradient) { | ||
242 | rgb = qRgb(rcb - rSign * | ||
243 | (int)sqrt((xtable[0][x]*xtable[0][x] + | ||
244 | ytable[0][y]*ytable[0][y])*2.0), | ||
245 | gcb - gSign * | ||
246 | (int)sqrt((xtable[1][x]*xtable[1][x] + | ||
247 | ytable[1][y]*ytable[1][y])*2.0), | ||
248 | bcb - bSign * | ||
249 | (int)sqrt((xtable[2][x]*xtable[2][x] + | ||
250 | ytable[2][y]*ytable[2][y])*2.0)); | ||
251 | } | ||
252 | |||
253 | sl1[x] = sl2[x] = rgb; | ||
254 | sl1[x2] = sl2[x2] = rgb; | ||
255 | } | ||
256 | } | ||
257 | } | ||
258 | |||
259 | delete [] xtable[0]; | ||
260 | delete [] xtable[1]; | ||
261 | delete [] xtable[2]; | ||
262 | delete [] ytable[0]; | ||
263 | delete [] ytable[1]; | ||
264 | delete [] ytable[2]; | ||
265 | } | ||
266 | return image; | ||
84 | } | 267 | } |
85 | 268 | ||
86 | 269 | ||
87 | //====================================================================== | 270 | //====================================================================== |
88 | // | 271 | // |
89 | // Blend effects | 272 | // Blend effects |
90 | // | 273 | // |
91 | //====================================================================== | 274 | //====================================================================== |
92 | 275 | ||
93 | 276 | ||
94 | QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity, | 277 | QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity, |
95 | const QColor &bgnd, GradientType eff, | 278 | const QColor &bgnd, GradientType eff, |
96 | bool anti_dir, int /*ncols*/) | 279 | bool anti_dir, int /*ncols*/) |
97 | { | 280 | { |
98 | QImage image = pixmap.convertToImage(); | 281 | QImage image = pixmap.convertToImage(); |
99 | OGfxEffect::blend(image, initial_intensity, bgnd, eff, anti_dir); | 282 | OGfxEffect::blend(image, initial_intensity, bgnd, eff, anti_dir); |
100 | 283 | ||
101 | if ( pixmap. depth ( ) <= 8 ) | 284 | if ( pixmap. depth ( ) <= 8 ) |
102 | image. convertDepth ( pixmap. depth ( )); | 285 | image. convertDepth ( pixmap. depth ( )); |
103 | 286 | ||
104 | pixmap.convertFromImage(image); | 287 | pixmap.convertFromImage(image); |
105 | 288 | ||
106 | return pixmap; | 289 | return pixmap; |
107 | } | 290 | } |
108 | 291 | ||
109 | 292 | ||
110 | QImage& OGfxEffect::blend(QImage &image, float initial_intensity, | 293 | QImage& OGfxEffect::blend(QImage &image, float initial_intensity, |
111 | const QColor &bgnd, GradientType eff, | 294 | const QColor &bgnd, GradientType eff, |
112 | bool anti_dir) | 295 | bool anti_dir) |
113 | { | 296 | { |
114 | if (image.width() == 0 || image.height() == 0) { | 297 | if (image.width() == 0 || image.height() == 0) { |
115 | qDebug ( "Invalid image\n" ); | 298 | qDebug ( "Invalid image\n" ); |
116 | return image; | 299 | return image; |
117 | } | 300 | } |
118 | 301 | ||
119 | int r_bgnd = bgnd.red(), g_bgnd = bgnd.green(), b_bgnd = bgnd.blue(); | 302 | int r_bgnd = bgnd.red(), g_bgnd = bgnd.green(), b_bgnd = bgnd.blue(); |
120 | int r, g, b; | 303 | int r, g, b; |
121 | int ind; | 304 | int ind; |
122 | 305 | ||
123 | unsigned int xi, xf, yi, yf; | 306 | unsigned int xi, xf, yi, yf; |
124 | unsigned int a; | 307 | unsigned int a; |
125 | 308 | ||
126 | // check the boundaries of the initial intesity param | 309 | // check the boundaries of the initial intesity param |
127 | float unaffected = 1; | 310 | float unaffected = 1; |
128 | if (initial_intensity > 1) initial_intensity = 1; | 311 | if (initial_intensity > 1) initial_intensity = 1; |
129 | if (initial_intensity < -1) initial_intensity = -1; | 312 | if (initial_intensity < -1) initial_intensity = -1; |
130 | if (initial_intensity < 0) { | 313 | if (initial_intensity < 0) { |
131 | unaffected = 1. + initial_intensity; | 314 | unaffected = 1. + initial_intensity; |
132 | initial_intensity = 0; | 315 | initial_intensity = 0; |
133 | } | 316 | } |
134 | 317 | ||
135 | 318 | ||
136 | float intensity = initial_intensity; | 319 | float intensity = initial_intensity; |
137 | float var = 1. - initial_intensity; | 320 | float var = 1. - initial_intensity; |
138 | 321 | ||
139 | if (anti_dir) { | 322 | if (anti_dir) { |
140 | initial_intensity = intensity = 1.; | 323 | initial_intensity = intensity = 1.; |
141 | var = -var; | 324 | var = -var; |
142 | } | 325 | } |
143 | 326 | ||
144 | register int x, y; | 327 | register int x, y; |
145 | 328 | ||
146 | unsigned int *data = (unsigned int *)image.bits(); | 329 | unsigned int *data = (unsigned int *)image.bits(); |
147 | 330 | ||
148 | if( eff == VerticalGradient || eff == HorizontalGradient ) { | 331 | if( eff == VerticalGradient || eff == HorizontalGradient ) { |
149 | 332 | ||
150 | // set the image domain to apply the effect to | 333 | // set the image domain to apply the effect to |
151 | xi = 0, xf = image.width(); | 334 | xi = 0, xf = image.width(); |
152 | yi = 0, yf = image.height(); | 335 | yi = 0, yf = image.height(); |
153 | if (eff == VerticalGradient) { | 336 | if (eff == VerticalGradient) { |
154 | if (anti_dir) yf = (int)(image.height() * unaffected); | 337 | if (anti_dir) yf = (int)(image.height() * unaffected); |
155 | else yi = (int)(image.height() * (1 - unaffected)); | 338 | else yi = (int)(image.height() * (1 - unaffected)); |
156 | } | 339 | } |
157 | else { | 340 | else { |
158 | if (anti_dir) xf = (int)(image.width() * unaffected); | 341 | if (anti_dir) xf = (int)(image.width() * unaffected); |
159 | else xi = (int)(image.height() * (1 - unaffected)); | 342 | else xi = (int)(image.height() * (1 - unaffected)); |
160 | } | 343 | } |
161 | 344 | ||
162 | var /= (eff == VerticalGradient?yf-yi:xf-xi); | 345 | var /= (eff == VerticalGradient?yf-yi:xf-xi); |
163 | 346 | ||
164 | for (y = yi; y < (int)yf; y++) { | 347 | for (y = yi; y < (int)yf; y++) { |
165 | intensity = eff == VerticalGradient? intensity + var : | 348 | intensity = eff == VerticalGradient? intensity + var : |
166 | initial_intensity; | 349 | initial_intensity; |
167 | for (x = xi; x < (int)xf ; x++) { | 350 | for (x = xi; x < (int)xf ; x++) { |
168 | if (eff == HorizontalGradient) intensity += var; | 351 | if (eff == HorizontalGradient) intensity += var; |
169 | ind = x + image.width() * y ; | 352 | ind = x + image.width() * y ; |
170 | r = qRed (data[ind]) + (int)(intensity * | 353 | r = qRed (data[ind]) + (int)(intensity * |
171 | (r_bgnd - qRed (data[ind]))); | 354 | (r_bgnd - qRed (data[ind]))); |
172 | g = qGreen(data[ind]) + (int)(intensity * | 355 | g = qGreen(data[ind]) + (int)(intensity * |
173 | (g_bgnd - qGreen(data[ind]))); | 356 | (g_bgnd - qGreen(data[ind]))); |
174 | b = qBlue (data[ind]) + (int)(intensity * | 357 | b = qBlue (data[ind]) + (int)(intensity * |
175 | (b_bgnd - qBlue (data[ind]))); | 358 | (b_bgnd - qBlue (data[ind]))); |
176 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 359 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
177 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 360 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
178 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 361 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
179 | a = qAlpha(data[ind]); | 362 | a = qAlpha(data[ind]); |
180 | data[ind] = qRgba(r, g, b, a); | 363 | data[ind] = qRgba(r, g, b, a); |
181 | } | 364 | } |
182 | } | 365 | } |
183 | } | 366 | } |
184 | else if (eff == DiagonalGradient || eff == CrossDiagonalGradient) { | 367 | else if (eff == DiagonalGradient || eff == CrossDiagonalGradient) { |
185 | float xvar = var / 2 / image.width(); // / unaffected; | 368 | float xvar = var / 2 / image.width(); // / unaffected; |
186 | float yvar = var / 2 / image.height(); // / unaffected; | 369 | float yvar = var / 2 / image.height(); // / unaffected; |
187 | float tmp; | 370 | float tmp; |
188 | 371 | ||
189 | for (x = 0; x < image.width() ; x++) { | 372 | for (x = 0; x < image.width() ; x++) { |
190 | tmp = xvar * (eff == DiagonalGradient? x : image.width()-x-1); | 373 | tmp = xvar * (eff == DiagonalGradient? x : image.width()-x-1); |
191 | for (y = 0; y < image.height() ; y++) { | 374 | for (y = 0; y < image.height() ; y++) { |
192 | intensity = initial_intensity + tmp + yvar * y; | 375 | intensity = initial_intensity + tmp + yvar * y; |
193 | ind = x + image.width() * y ; | 376 | ind = x + image.width() * y ; |
194 | r = qRed (data[ind]) + (int)(intensity * | 377 | r = qRed (data[ind]) + (int)(intensity * |
195 | (r_bgnd - qRed (data[ind]))); | 378 | (r_bgnd - qRed (data[ind]))); |
196 | g = qGreen(data[ind]) + (int)(intensity * | 379 | g = qGreen(data[ind]) + (int)(intensity * |
197 | (g_bgnd - qGreen(data[ind]))); | 380 | (g_bgnd - qGreen(data[ind]))); |
198 | b = qBlue (data[ind]) + (int)(intensity * | 381 | b = qBlue (data[ind]) + (int)(intensity * |
199 | (b_bgnd - qBlue (data[ind]))); | 382 | (b_bgnd - qBlue (data[ind]))); |
200 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 383 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
201 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 384 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
202 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 385 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
203 | a = qAlpha(data[ind]); | 386 | a = qAlpha(data[ind]); |
204 | data[ind] = qRgba(r, g, b, a); | 387 | data[ind] = qRgba(r, g, b, a); |
205 | } | 388 | } |
206 | } | 389 | } |
207 | } | 390 | } |
208 | 391 | ||
209 | else if (eff == RectangleGradient || eff == EllipticGradient) { | 392 | else if (eff == RectangleGradient || eff == EllipticGradient) { |
210 | float xvar; | 393 | float xvar; |
211 | float yvar; | 394 | float yvar; |
212 | 395 | ||
213 | for (x = 0; x < image.width() / 2 + image.width() % 2; x++) { | 396 | for (x = 0; x < image.width() / 2 + image.width() % 2; x++) { |
214 | xvar = var / image.width() * (image.width() - x*2/unaffected-1); | 397 | xvar = var / image.width() * (image.width() - x*2/unaffected-1); |
215 | for (y = 0; y < image.height() / 2 + image.height() % 2; y++) { | 398 | for (y = 0; y < image.height() / 2 + image.height() % 2; y++) { |
216 | yvar = var / image.height() * (image.height() - y*2/unaffected -1); | 399 | yvar = var / image.height() * (image.height() - y*2/unaffected -1); |
217 | 400 | ||
218 | if (eff == RectangleGradient) | 401 | if (eff == RectangleGradient) |
219 | intensity = initial_intensity + QMAX(xvar, yvar); | 402 | intensity = initial_intensity + QMAX(xvar, yvar); |
220 | else | 403 | else |
221 | intensity = initial_intensity + qSqrt(xvar * xvar + yvar * yvar); | 404 | intensity = initial_intensity + qSqrt(xvar * xvar + yvar * yvar); |
222 | if (intensity > 1) intensity = 1; | 405 | if (intensity > 1) intensity = 1; |
223 | if (intensity < 0) intensity = 0; | 406 | if (intensity < 0) intensity = 0; |
224 | 407 | ||
225 | //NW | 408 | //NW |
226 | ind = x + image.width() * y ; | 409 | ind = x + image.width() * y ; |
227 | r = qRed (data[ind]) + (int)(intensity * | 410 | r = qRed (data[ind]) + (int)(intensity * |
228 | (r_bgnd - qRed (data[ind]))); | 411 | (r_bgnd - qRed (data[ind]))); |
229 | g = qGreen(data[ind]) + (int)(intensity * | 412 | g = qGreen(data[ind]) + (int)(intensity * |
230 | (g_bgnd - qGreen(data[ind]))); | 413 | (g_bgnd - qGreen(data[ind]))); |
231 | b = qBlue (data[ind]) + (int)(intensity * | 414 | b = qBlue (data[ind]) + (int)(intensity * |
232 | (b_bgnd - qBlue (data[ind]))); | 415 | (b_bgnd - qBlue (data[ind]))); |
233 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 416 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
234 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 417 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
235 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 418 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
236 | a = qAlpha(data[ind]); | 419 | a = qAlpha(data[ind]); |
237 | data[ind] = qRgba(r, g, b, a); | 420 | data[ind] = qRgba(r, g, b, a); |
238 | 421 | ||
239 | //NE | 422 | //NE |
240 | ind = image.width() - x - 1 + image.width() * y ; | 423 | ind = image.width() - x - 1 + image.width() * y ; |
241 | r = qRed (data[ind]) + (int)(intensity * | 424 | r = qRed (data[ind]) + (int)(intensity * |
242 | (r_bgnd - qRed (data[ind]))); | 425 | (r_bgnd - qRed (data[ind]))); |
243 | g = qGreen(data[ind]) + (int)(intensity * | 426 | g = qGreen(data[ind]) + (int)(intensity * |
244 | (g_bgnd - qGreen(data[ind]))); | 427 | (g_bgnd - qGreen(data[ind]))); |
245 | b = qBlue (data[ind]) + (int)(intensity * | 428 | b = qBlue (data[ind]) + (int)(intensity * |
246 | (b_bgnd - qBlue (data[ind]))); | 429 | (b_bgnd - qBlue (data[ind]))); |
247 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 430 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
248 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 431 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
249 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 432 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
250 | a = qAlpha(data[ind]); | 433 | a = qAlpha(data[ind]); |
251 | data[ind] = qRgba(r, g, b, a); | 434 | data[ind] = qRgba(r, g, b, a); |
252 | } | 435 | } |
253 | } | 436 | } |
254 | 437 | ||
255 | //CT loop is doubled because of stupid central row/column issue. | 438 | //CT loop is doubled because of stupid central row/column issue. |
256 | // other solution? | 439 | // other solution? |
257 | for (x = 0; x < image.width() / 2; x++) { | 440 | for (x = 0; x < image.width() / 2; x++) { |
258 | xvar = var / image.width() * (image.width() - x*2/unaffected-1); | 441 | xvar = var / image.width() * (image.width() - x*2/unaffected-1); |
259 | for (y = 0; y < image.height() / 2; y++) { | 442 | for (y = 0; y < image.height() / 2; y++) { |
260 | yvar = var / image.height() * (image.height() - y*2/unaffected -1); | 443 | yvar = var / image.height() * (image.height() - y*2/unaffected -1); |
261 | 444 | ||
262 | if (eff == RectangleGradient) | 445 | if (eff == RectangleGradient) |
263 | intensity = initial_intensity + QMAX(xvar, yvar); | 446 | intensity = initial_intensity + QMAX(xvar, yvar); |
264 | else | 447 | else |
265 | intensity = initial_intensity + qSqrt(xvar * xvar + yvar * yvar); | 448 | intensity = initial_intensity + qSqrt(xvar * xvar + yvar * yvar); |
266 | if (intensity > 1) intensity = 1; | 449 | if (intensity > 1) intensity = 1; |
267 | if (intensity < 0) intensity = 0; | 450 | if (intensity < 0) intensity = 0; |
268 | 451 | ||
269 | //SW | 452 | //SW |
270 | ind = x + image.width() * (image.height() - y -1) ; | 453 | ind = x + image.width() * (image.height() - y -1) ; |
271 | r = qRed (data[ind]) + (int)(intensity * | 454 | r = qRed (data[ind]) + (int)(intensity * |
272 | (r_bgnd - qRed (data[ind]))); | 455 | (r_bgnd - qRed (data[ind]))); |
273 | g = qGreen(data[ind]) + (int)(intensity * | 456 | g = qGreen(data[ind]) + (int)(intensity * |
274 | (g_bgnd - qGreen(data[ind]))); | 457 | (g_bgnd - qGreen(data[ind]))); |
275 | b = qBlue (data[ind]) + (int)(intensity * | 458 | b = qBlue (data[ind]) + (int)(intensity * |
276 | (b_bgnd - qBlue (data[ind]))); | 459 | (b_bgnd - qBlue (data[ind]))); |
277 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 460 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
278 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 461 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
279 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 462 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
280 | a = qAlpha(data[ind]); | 463 | a = qAlpha(data[ind]); |
281 | data[ind] = qRgba(r, g, b, a); | 464 | data[ind] = qRgba(r, g, b, a); |
282 | 465 | ||
283 | //SE | 466 | //SE |
284 | ind = image.width()-x-1 + image.width() * (image.height() - y - 1) ; | 467 | ind = image.width()-x-1 + image.width() * (image.height() - y - 1) ; |
285 | r = qRed (data[ind]) + (int)(intensity * | 468 | r = qRed (data[ind]) + (int)(intensity * |
286 | (r_bgnd - qRed (data[ind]))); | 469 | (r_bgnd - qRed (data[ind]))); |
287 | g = qGreen(data[ind]) + (int)(intensity * | 470 | g = qGreen(data[ind]) + (int)(intensity * |
288 | (g_bgnd - qGreen(data[ind]))); | 471 | (g_bgnd - qGreen(data[ind]))); |
289 | b = qBlue (data[ind]) + (int)(intensity * | 472 | b = qBlue (data[ind]) + (int)(intensity * |
290 | (b_bgnd - qBlue (data[ind]))); | 473 | (b_bgnd - qBlue (data[ind]))); |
291 | if (r > 255) r = 255; if (r < 0 ) r = 0; | 474 | if (r > 255) r = 255; if (r < 0 ) r = 0; |
292 | if (g > 255) g = 255; if (g < 0 ) g = 0; | 475 | if (g > 255) g = 255; if (g < 0 ) g = 0; |
293 | if (b > 255) b = 255; if (b < 0 ) b = 0; | 476 | if (b > 255) b = 255; if (b < 0 ) b = 0; |
294 | a = qAlpha(data[ind]); | 477 | a = qAlpha(data[ind]); |
295 | data[ind] = qRgba(r, g, b, a); | 478 | data[ind] = qRgba(r, g, b, a); |
296 | } | 479 | } |
297 | } | 480 | } |
298 | } | 481 | } |
299 | 482 | ||
300 | else | 483 | else |
301 | qDebug ( "not implemented\n" ); | 484 | qDebug ( "not implemented\n" ); |
302 | 485 | ||
303 | return image; | 486 | return image; |
304 | } | 487 | } |
305 | 488 | ||
306 | #if 0 | 489 | #if 0 |
307 | // Not very efficient as we create a third big image... | 490 | // Not very efficient as we create a third big image... |
308 | // | 491 | // |
309 | QImage& KQGfxEffect::blend(QImage &image1, QImage &image2, | 492 | QImage& KQGfxEffect::blend(QImage &image1, QImage &image2, |
310 | GradientType gt, int xf, int yf) | 493 | GradientType gt, int xf, int yf) |
311 | { | 494 | { |
312 | if (image1.width() == 0 || image1.height() == 0 || | 495 | if (image1.width() == 0 || image1.height() == 0 || |
313 | image2.width() == 0 || image2.height() == 0) | 496 | image2.width() == 0 || image2.height() == 0) |
314 | return image1; | 497 | return image1; |
315 | 498 | ||
316 | QImage image3; | 499 | QImage image3; |
317 | 500 | ||
318 | image3 = KQGfxEffect::unbalancedGradient(image1.size(), | 501 | image3 = KQGfxEffect::unbalancedGradient(image1.size(), |
319 | QColor(0,0,0), QColor(255,255,255), | 502 | QColor(0,0,0), QColor(255,255,255), |
320 | gt, xf, yf, 0); | 503 | gt, xf, yf, 0); |
321 | 504 | ||
322 | return blend(image1,image2,image3, Red); // Channel to use is arbitrary | 505 | return blend(image1,image2,image3, Red); // Channel to use is arbitrary |
323 | } | 506 | } |
324 | #endif | 507 | #endif |
diff --git a/noncore/styles/theme/ogfxeffect.h b/noncore/styles/theme/ogfxeffect.h index 45a8482..755537f 100644 --- a/noncore/styles/theme/ogfxeffect.h +++ b/noncore/styles/theme/ogfxeffect.h | |||
@@ -1,78 +1,81 @@ | |||
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 | #ifndef __OGFX_EFFECT_H | 10 | #ifndef __OGFX_EFFECT_H |
11 | #define __OGFX_EFFECT_H | 11 | #define __OGFX_EFFECT_H |
12 | 12 | ||
13 | #include <qpixmap.h> | 13 | #include <qpixmap.h> |
14 | #include <qimage.h> | 14 | #include <qimage.h> |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * This class includes various pixmap-based graphical effects. | 17 | * This class includes various pixmap-based graphical effects. |
18 | * | 18 | * |
19 | * Everything is | 19 | * Everything is |
20 | * static, so there is no need to create an instance of this class. You can | 20 | * static, so there is no need to create an instance of this class. You can |
21 | * just call the static methods. They are encapsulated here merely to provide | 21 | * just call the static methods. They are encapsulated here merely to provide |
22 | * a common namespace. | 22 | * a common namespace. |
23 | */ | 23 | */ |
24 | class OGfxEffect | 24 | class OGfxEffect |
25 | { | 25 | { |
26 | public: | 26 | public: |
27 | enum GradientType { VerticalGradient, HorizontalGradient, | 27 | enum GradientType { VerticalGradient, HorizontalGradient, |
28 | DiagonalGradient, CrossDiagonalGradient, | 28 | DiagonalGradient, CrossDiagonalGradient, |
29 | PyramidGradient, RectangleGradient, | 29 | PyramidGradient, RectangleGradient, |
30 | PipeCrossGradient, EllipticGradient }; | 30 | PipeCrossGradient, EllipticGradient }; |
31 | enum RGBComponent { Red, Green, Blue }; | 31 | enum RGBComponent { Red, Green, Blue }; |
32 | 32 | ||
33 | enum Lighting {NorthLite, NWLite, WestLite, SWLite, | 33 | enum Lighting {NorthLite, NWLite, WestLite, SWLite, |
34 | SouthLite, SELite, EastLite, NELite}; | 34 | SouthLite, SELite, EastLite, NELite}; |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Create a gradient from color a to color b of the specified type. | 37 | * Create a gradient from color a to color b of the specified type. |
38 | * | 38 | * |
39 | * @param pixmap The pixmap to process. | 39 | * @param pixmap The pixmap to process. |
40 | * @param ca Color a. | 40 | * @param ca Color a. |
41 | * @param cb Color b. | 41 | * @param cb Color b. |
42 | * @param type The type of gradient. | 42 | * @param type The type of gradient. |
43 | * @param ncols The number of colors to use when not running on a | 43 | * @param ncols The number of colors to use when not running on a |
44 | * truecolor display. The gradient will be dithered to this number of | 44 | * truecolor display. The gradient will be dithered to this number of |
45 | * colors. Pass 0 to prevent dithering. | 45 | * colors. Pass 0 to prevent dithering. |
46 | * @return Returns the generated pixmap, for convenience. | 46 | * @return Returns the generated pixmap, for convenience. |
47 | */ | 47 | */ |
48 | static QPixmap& gradient(QPixmap& pixmap, const QColor &ca, const QColor &cb, | 48 | static QPixmap& gradient(QPixmap& pixmap, const QColor &ca, const QColor &cb, |
49 | GradientType type, int ncols=3); | 49 | GradientType type, int ncols=3); |
50 | 50 | ||
51 | static QImage gradient (const QSize &size, const QColor &ca, const QColor &cb, | ||
52 | GradientType type, int ncols=3); | ||
53 | |||
51 | 54 | ||
52 | /** | 55 | /** |
53 | * Blend the provided pixmap into a background of the indicated color | 56 | * Blend the provided pixmap into a background of the indicated color |
54 | * | 57 | * |
55 | * @param pixmap The pixmap to process. | 58 | * @param pixmap The pixmap to process. |
56 | * @param initial_intensity this parameter takes values from -1 to 1: | 59 | * @param initial_intensity this parameter takes values from -1 to 1: |
57 | * @li If positive, it tells how much to fade the image in its | 60 | * @li If positive, it tells how much to fade the image in its |
58 | * less affected spot. | 61 | * less affected spot. |
59 | * @li If negative, it tells roughly indicates how much of the image | 62 | * @li If negative, it tells roughly indicates how much of the image |
60 | * remains unaffected | 63 | * remains unaffected |
61 | * @param bgnd Indicates the color of the background to blend in. | 64 | * @param bgnd Indicates the color of the background to blend in. |
62 | * @param eff Lets you choose what kind of blending you like. | 65 | * @param eff Lets you choose what kind of blending you like. |
63 | * @param anti_dir Blend in the opposite direction (makes no much sense | 66 | * @param anti_dir Blend in the opposite direction (makes no much sense |
64 | * with concentric blending effects). | 67 | * with concentric blending effects). |
65 | * @return Returns the @ref pixmap(), provided for convenience. | 68 | * @return Returns the @ref pixmap(), provided for convenience. |
66 | */ | 69 | */ |
67 | static QPixmap& blend(QPixmap& pixmap, float initial_intensity, | 70 | static QPixmap& blend(QPixmap& pixmap, float initial_intensity, |
68 | const QColor &bgnd, GradientType eff, | 71 | const QColor &bgnd, GradientType eff, |
69 | bool anti_dir=false, int ncols=3); | 72 | bool anti_dir=false, int ncols=3); |
70 | 73 | ||
71 | 74 | ||
72 | static QImage& blend(QImage &image, float initial_intensity, | 75 | static QImage& blend(QImage &image, float initial_intensity, |
73 | const QColor &bgnd, GradientType eff, | 76 | const QColor &bgnd, GradientType eff, |
74 | bool anti_dir); | 77 | bool anti_dir); |
75 | }; | 78 | }; |
76 | 79 | ||
77 | 80 | ||
78 | #endif | 81 | #endif |
diff --git a/noncore/styles/theme/othemestyle.cpp b/noncore/styles/theme/othemestyle.cpp index d97b026..8c7a71b 100644 --- a/noncore/styles/theme/othemestyle.cpp +++ b/noncore/styles/theme/othemestyle.cpp | |||
@@ -1,1540 +1,1541 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org> | 2 | Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org> |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License version 2 as published by the Free Software Foundation. | 6 | License version 2 as published by the Free Software Foundation. |
7 | 7 | ||
8 | This library is distributed in the hope that it will be useful, | 8 | This library is distributed in the hope that it will be useful, |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | Library General Public License for more details. | 11 | Library General Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU Library General Public License | 13 | You should have received a copy of the GNU Library General Public License |
14 | along with this library; see the file COPYING.LIB. If not, write to | 14 | along with this library; see the file COPYING.LIB. If not, write to |
15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
16 | Boston, MA 02111-1307, USA. | 16 | Boston, MA 02111-1307, USA. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include "othemestyle.h" | 19 | #include "othemestyle.h" |
20 | #include "othemebase.h" | 20 | #include "othemebase.h" |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qbitmap.h> | 22 | #include <qbitmap.h> |
23 | #define INCLUDE_MENUITEM_DEF | 23 | #define INCLUDE_MENUITEM_DEF |
24 | #include <qmenudata.h> | 24 | #include <qmenudata.h> |
25 | #include <qpopupmenu.h> | 25 | #include <qpopupmenu.h> |
26 | #include <qtabbar.h> | 26 | #include <qtabbar.h> |
27 | #include <qglobal.h> | 27 | #include <qglobal.h> |
28 | 28 | ||
29 | #include <limits.h> | 29 | #include <limits.h> |
30 | #include <stdio.h> | 30 | #include <stdio.h> |
31 | 31 | ||
32 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) | 32 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) |
33 | 33 | ||
34 | OThemeStyle::OThemeStyle( const QString &configFile ) | 34 | OThemeStyle::OThemeStyle( const QString &configFile ) |
35 | : OThemeBase( configFile ) | 35 | : OThemeBase( configFile ) |
36 | { | 36 | { |
37 | setScrollBarExtent( getSBExtent(), getSBExtent() ); | 37 | setScrollBarExtent( getSBExtent(), getSBExtent() ); |
38 | setButtonDefaultIndicatorWidth( 0 ); // We REALLY should support one, see drawPushButton() below! | 38 | setButtonDefaultIndicatorWidth( 0 ); // We REALLY should support one, see drawPushButton() below! |
39 | } | 39 | } |
40 | 40 | ||
41 | OThemeStyle::~OThemeStyle() | 41 | OThemeStyle::~OThemeStyle() |
42 | {} | 42 | {} |
43 | 43 | ||
44 | void OThemeStyle::polish( QApplication * /*app*/ ) | 44 | void OThemeStyle::polish( QApplication * /*app*/ ) |
45 | {} | 45 | {} |
46 | 46 | ||
47 | void OThemeStyle::polish( QPalette &p ) | 47 | void OThemeStyle::polish( QPalette &p ) |
48 | { | 48 | { |
49 | oldPalette = p; | 49 | oldPalette = p; |
50 | 50 | ||
51 | QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background ); | 51 | QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background ); |
52 | 52 | ||
53 | if ( bgcolor. isValid ( )) | 53 | if ( bgcolor. isValid ( )) |
54 | bg = bgcolor; | 54 | bg = bgcolor; |
55 | 55 | ||
56 | if ( isColor ( Background )) | 56 | if ( isColor ( Background )) |
57 | bg = colorGroup ( oldPalette. active ( ), Background )-> background ( ); | 57 | bg = colorGroup ( oldPalette. active ( ), Background )-> background ( ); |
58 | 58 | ||
59 | p = QPalette ( bg, bg ); | 59 | p = QPalette ( bg, bg ); |
60 | 60 | ||
61 | if ( isPixmap( Background ) ) | 61 | if ( isPixmap( Background ) ) |
62 | p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background ))); | 62 | p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background ))); |
63 | 63 | ||
64 | if ( fgcolor. isValid ( )) { | 64 | if ( fgcolor. isValid ( )) { |
65 | p. setColor ( QColorGroup::Foreground, fgcolor ); | 65 | p. setColor ( QColorGroup::Foreground, fgcolor ); |
66 | p. setColor ( QColorGroup::ButtonText, fgcolor ); | 66 | p. setColor ( QColorGroup::ButtonText, fgcolor ); |
67 | } | 67 | } |
68 | if ( selfgcolor. isValid ( )) | 68 | if ( selfgcolor. isValid ( )) |
69 | p. setColor ( QColorGroup::HighlightedText, selfgcolor ); | 69 | p. setColor ( QColorGroup::HighlightedText, selfgcolor ); |
70 | if ( selbgcolor. isValid ( )) | 70 | if ( selbgcolor. isValid ( )) |
71 | p. setColor ( QColorGroup::Highlight, selbgcolor ); | 71 | p. setColor ( QColorGroup::Highlight, selbgcolor ); |
72 | if ( winfgcolor. isValid ( )) | 72 | if ( winfgcolor. isValid ( )) |
73 | p. setColor ( QColorGroup::Text, winfgcolor ); | 73 | p. setColor ( QColorGroup::Text, winfgcolor ); |
74 | if ( winbgcolor. isValid ( )) | 74 | if ( winbgcolor. isValid ( )) |
75 | p. setColor ( QColorGroup::Base, winbgcolor ); | 75 | p. setColor ( QColorGroup::Base, winbgcolor ); |
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | void OThemeStyle::unPolish( QApplication *app ) | 80 | void OThemeStyle::unPolish( QApplication *app ) |
81 | { | 81 | { |
82 | app->setPalette( oldPalette, true ); | 82 | app->setPalette( oldPalette, true ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void OThemeStyle::polish( QWidget *w ) | 85 | void OThemeStyle::polish( QWidget *w ) |
86 | { | 86 | { |
87 | if ( !w->isTopLevel() ) { | 87 | if ( !w->isTopLevel() ) { |
88 | if ( w->inherits( "QGroupBox" ) | 88 | if ( w->inherits( "QGroupBox" ) |
89 | || w->inherits( "QTabWidget" ) ) { | 89 | || w->inherits( "QTabWidget" ) ) { |
90 | w->setAutoMask( TRUE ); | 90 | w->setAutoMask( TRUE ); |
91 | return ; | 91 | return ; |
92 | } | 92 | } |
93 | if ( w->inherits( "QLabel" ) | 93 | if ( w->inherits( "QLabel" ) |
94 | || w->inherits( "QSlider" ) | 94 | || w->inherits( "QSlider" ) |
95 | || w->inherits( "QButton" ) | 95 | || w->inherits( "QButton" ) |
96 | || w->inherits( "QProgressBar" ) | 96 | || w->inherits( "QProgressBar" ) |
97 | ) { | 97 | ) { |
98 | w->setBackgroundOrigin( QWidget::ParentOrigin ); | 98 | w->setBackgroundOrigin( QWidget::ParentOrigin ); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | if ( w->inherits( "QPopupMenu" ) ) { | 101 | if ( w->inherits( "QPopupMenu" ) ) { |
102 | popupPalette = w->palette(); | 102 | popupPalette = w->palette(); |
103 | if ( isColor( MenuItem ) || isColor( MenuItemDown ) ) { | 103 | if ( isColor( MenuItem ) || isColor( MenuItemDown ) ) { |
104 | QPalette newPal( w->palette() ); | 104 | QPalette newPal( w->palette() ); |
105 | w->setPalettePropagation( QWidget::SamePalette ); | 105 | w->setPalettePropagation( QWidget::SamePalette ); |
106 | if ( isColor( MenuItem ) ) { | 106 | if ( isColor( MenuItem ) ) { |
107 | newPal.setNormal( *colorGroup( newPal.normal(), MenuItem ) ); | 107 | newPal.setNormal( *colorGroup( newPal.normal(), MenuItem ) ); |
108 | newPal.setDisabled( *colorGroup( newPal.normal(), MenuItem ) ); | 108 | newPal.setDisabled( *colorGroup( newPal.normal(), MenuItem ) ); |
109 | } | 109 | } |
110 | if ( isColor( MenuItemDown ) ) | 110 | if ( isColor( MenuItemDown ) ) |
111 | newPal.setActive( *colorGroup( newPal.active(), MenuItemDown ) ); | 111 | newPal.setActive( *colorGroup( newPal.active(), MenuItemDown ) ); |
112 | w->setPalette( newPal ); | 112 | w->setPalette( newPal ); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | if ( w->inherits( "QCheckBox" ) ) { | 115 | if ( w->inherits( "QCheckBox" ) ) { |
116 | if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) ) { | 116 | if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) ) { |
117 | QPalette newPal( w->palette() ); | 117 | QPalette newPal( w->palette() ); |
118 | w->setPalettePropagation( QWidget::SamePalette ); | 118 | w->setPalettePropagation( QWidget::SamePalette ); |
119 | if ( isColor( IndicatorOff ) ) { | 119 | if ( isColor( IndicatorOff ) ) { |
120 | newPal.setNormal( *colorGroup( newPal.normal(), IndicatorOff ) ); | 120 | newPal.setNormal( *colorGroup( newPal.normal(), IndicatorOff ) ); |
121 | newPal.setDisabled( *colorGroup( newPal.normal(), IndicatorOff ) ); | 121 | newPal.setDisabled( *colorGroup( newPal.normal(), IndicatorOff ) ); |
122 | } | 122 | } |
123 | if ( isColor( IndicatorOn ) ) | 123 | if ( isColor( IndicatorOn ) ) |
124 | newPal.setActive( *colorGroup( newPal.active(), IndicatorOn ) ); | 124 | newPal.setActive( *colorGroup( newPal.active(), IndicatorOn ) ); |
125 | w->setPalette( newPal ); | 125 | w->setPalette( newPal ); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | if ( w->inherits( "QRadioButton" ) ) { | 128 | if ( w->inherits( "QRadioButton" ) ) { |
129 | if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) ) { | 129 | if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) ) { |
130 | QPalette newPal( w->palette() ); | 130 | QPalette newPal( w->palette() ); |
131 | w->setPalettePropagation( QWidget::SamePalette ); | 131 | w->setPalettePropagation( QWidget::SamePalette ); |
132 | if ( isColor( ExIndicatorOff ) ) { | 132 | if ( isColor( ExIndicatorOff ) ) { |
133 | newPal.setNormal( *colorGroup( newPal.normal(), ExIndicatorOff ) ); | 133 | newPal.setNormal( *colorGroup( newPal.normal(), ExIndicatorOff ) ); |
134 | newPal.setDisabled( *colorGroup( newPal.normal(), | 134 | newPal.setDisabled( *colorGroup( newPal.normal(), |
135 | ExIndicatorOff ) ); | 135 | ExIndicatorOff ) ); |
136 | } | 136 | } |
137 | if ( isColor( ExIndicatorOn ) ) | 137 | if ( isColor( ExIndicatorOn ) ) |
138 | newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOn ) ); | 138 | newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOn ) ); |
139 | w->setPalette( newPal ); | 139 | w->setPalette( newPal ); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | void OThemeStyle::unPolish( QWidget* w ) | 144 | void OThemeStyle::unPolish( QWidget* w ) |
145 | { | 145 | { |
146 | if ( !w->isTopLevel() ) { | 146 | if ( !w->isTopLevel() ) { |
147 | if ( w->inherits( "QGroupBox" ) | 147 | if ( w->inherits( "QGroupBox" ) |
148 | || w->inherits( "QTabWidget" ) ) { | 148 | || w->inherits( "QTabWidget" ) ) { |
149 | w->setAutoMask( FALSE ); | 149 | w->setAutoMask( FALSE ); |
150 | return ; | 150 | return ; |
151 | } | 151 | } |
152 | if ( w->inherits( "QLabel" ) | 152 | if ( w->inherits( "QLabel" ) |
153 | || w->inherits( "QSlider" ) | 153 | || w->inherits( "QSlider" ) |
154 | || w->inherits( "QButton" ) | 154 | || w->inherits( "QButton" ) |
155 | || w->inherits( "QProgressBar" ) | 155 | || w->inherits( "QProgressBar" ) |
156 | ) { | 156 | ) { |
157 | w->setBackgroundOrigin( QWidget::WidgetOrigin ); | 157 | w->setBackgroundOrigin( QWidget::WidgetOrigin ); |
158 | } | 158 | } |
159 | } | 159 | } |
160 | if ( w->inherits( "QPopupMenu" ) ) | 160 | if ( w->inherits( "QPopupMenu" ) ) |
161 | w->unsetPalette(); | 161 | w->unsetPalette(); |
162 | if ( w->inherits( "QCheckBox" ) ) | 162 | if ( w->inherits( "QCheckBox" ) ) |
163 | w->unsetPalette(); | 163 | w->unsetPalette(); |
164 | if ( w->inherits( "QRadioButton" ) ) | 164 | if ( w->inherits( "QRadioButton" ) ) |
165 | w->unsetPalette(); | 165 | w->unsetPalette(); |
166 | } | 166 | } |
167 | 167 | ||
168 | void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h, | 168 | void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h, |
169 | const QColorGroup &g, bool sunken, bool | 169 | const QColorGroup &g, bool sunken, bool |
170 | rounded, WidgetType type, const QBrush * ) | 170 | rounded, WidgetType type, const QBrush * ) |
171 | { | 171 | { |
172 | int offset = borderPixmap( type ) ? 0 : decoWidth( type ); | 172 | int offset = borderPixmap( type ) ? 0 : decoWidth( type ); |
173 | QPen oldPen = p->pen(); | 173 | QPen oldPen = p->pen(); |
174 | 174 | ||
175 | // handle reverse bevel here since it uses decowidth differently | 175 | // handle reverse bevel here since it uses decowidth differently |
176 | if ( gradientHint( type ) == GrReverseBevel ) { | 176 | if ( gradientHint( type ) == GrReverseBevel ) { |
177 | int i; | 177 | int i; |
178 | bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h, | 178 | bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h, |
179 | Qt::CopyROP, true ); | 179 | Qt::CopyROP, true ); |
180 | p->setPen( g.text() ); | 180 | p->setPen( g.text() ); |
181 | for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 ) | 181 | for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 ) |
182 | p->drawRect( x, y, w, h ); | 182 | p->drawRect( x, y, w, h ); |
183 | } | 183 | } |
184 | // same with KDE style borders | 184 | // same with KDE style borders |
185 | else if ( !borderPixmap( type ) && shade() == KDE ) { | 185 | else if ( !borderPixmap( type ) && shade() == KDE ) { |
186 | qDrawWinButton( p, x, y, w, h, g, sunken ); | 186 | qDrawWinButton( p, x, y, w, h, g, sunken ); |
187 | if ( isPixmap( type ) ) | 187 | if ( isPixmap( type ) ) |
188 | p->drawTiledPixmap( x + 4, y + 4, w - 6, h - 6, | 188 | p->drawTiledPixmap( x + 4, y + 4, w - 6, h - 6, |
189 | *scalePixmap( w - 6, h - 6, | 189 | *scalePixmap( w - 6, h - 6, |
190 | type ) ); | 190 | type ) ); |
191 | else | 191 | else |
192 | p->fillRect( x + 4, y + 4, w - 6, h - offset * 6, | 192 | p->fillRect( x + 4, y + 4, w - 6, h - offset * 6, |
193 | g.brush( QColorGroup::Button ) ); | 193 | g.brush( QColorGroup::Button ) ); |
194 | 194 | ||
195 | } | 195 | } |
196 | else { | 196 | else { |
197 | if ( ( w - offset * 2 ) > 0 && ( h - offset * 2 ) > 0 ) { | 197 | if ( ( w - offset * 2 ) > 0 && ( h - offset * 2 ) > 0 ) { |
198 | if ( isPixmap( type ) ) | 198 | if ( isPixmap( type ) ) |
199 | if ( rounded ) | 199 | if ( rounded ) |
200 | p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) ); | 200 | p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) ); |
201 | else | 201 | else |
202 | p->drawTiledPixmap( x + offset, y + offset, w - offset * 2, | 202 | p->drawTiledPixmap( x + offset, y + offset, w - offset * 2, |
203 | h - offset * 2, | 203 | h - offset * 2, |
204 | *scalePixmap( w - offset * 2, h - offset * 2, | 204 | *scalePixmap( w - offset * 2, h - offset * 2, |
205 | type ) ); | 205 | type ) ); |
206 | else | 206 | else |
207 | p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2, | 207 | p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2, |
208 | g.brush( QColorGroup::Button ) ); | 208 | g.brush( QColorGroup::Button ) ); |
209 | } | 209 | } |
210 | if ( borderPixmap( type ) ) | 210 | if ( borderPixmap( type ) ) |
211 | bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h, | 211 | bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h, |
212 | Qt::CopyROP, false ); | 212 | Qt::CopyROP, false ); |
213 | else | 213 | else |
214 | drawShade( p, x, y, w, h, g, sunken, rounded, | 214 | drawShade( p, x, y, w, h, g, sunken, rounded, |
215 | highlightWidth( type ), borderWidth( type ), shade() ); | 215 | highlightWidth( type ), borderWidth( type ), shade() ); |
216 | } | 216 | } |
217 | p->setPen( oldPen ); | 217 | p->setPen( oldPen ); |
218 | } | 218 | } |
219 | 219 | ||
220 | void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h, | 220 | void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h, |
221 | const QColorGroup &g, bool sunken, | 221 | const QColorGroup &g, bool sunken, |
222 | const QBrush *fill ) | 222 | const QBrush *fill ) |
223 | { | 223 | { |
224 | drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ? | 224 | drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ? |
225 | PushButtonDown : PushButton, fill ); | 225 | PushButtonDown : PushButton, fill ); |
226 | } | 226 | } |
227 | 227 | ||
228 | void OThemeStyle::drawPushButton( QPushButton* btn, QPainter *p ) | 228 | void OThemeStyle::drawPushButton( QPushButton* btn, QPainter *p ) |
229 | { | 229 | { |
230 | bool sunken = btn->isOn() || btn->isDown(); | 230 | bool sunken = btn->isOn() || btn->isDown(); |
231 | int diw = buttonDefaultIndicatorWidth(); | 231 | int diw = buttonDefaultIndicatorWidth(); |
232 | drawBaseButton( p, diw, diw, btn->width() - 2 * diw, btn->height() - 2 * diw, | 232 | drawBaseButton( p, diw, diw, btn->width() - 2 * diw, btn->height() - 2 * diw, |
233 | *colorGroup( btn->colorGroup(), sunken ? PushButtonDown : | 233 | *colorGroup( btn->colorGroup(), sunken ? PushButtonDown : |
234 | PushButton ), sunken, roundButton(), | 234 | PushButton ), sunken, roundButton(), |
235 | sunken ? PushButtonDown : PushButton, NULL ); | 235 | sunken ? PushButtonDown : PushButton, NULL ); |
236 | // TODO if diw, draw fancy default button indicator | 236 | // TODO if diw, draw fancy default button indicator |
237 | } | 237 | } |
238 | 238 | ||
239 | void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h, | 239 | void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h, |
240 | bool round ) | 240 | bool round ) |
241 | { | 241 | { |
242 | // round edge fills | 242 | // round edge fills |
243 | static const QCOORD btm_left_fill[] = { | 243 | static const QCOORD btm_left_fill[] = { |
244 | 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, | 244 | 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, |
245 | 1, 2, 2, 2, 3, 2, 4, 2, 2, 3, 3, 3, 4, 3, 3, 4, 4, 4 | 245 | 1, 2, 2, 2, 3, 2, 4, 2, 2, 3, 3, 3, 4, 3, 3, 4, 4, 4 |
246 | }; | 246 | }; |
247 | 247 | ||
248 | static const QCOORD btm_right_fill[] = { | 248 | static const QCOORD btm_right_fill[] = { |
249 | 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, | 249 | 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, |
250 | 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4 | 250 | 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4 |
251 | }; | 251 | }; |
252 | 252 | ||
253 | static const QCOORD top_left_fill[] = { | 253 | static const QCOORD top_left_fill[] = { |
254 | 3, 0, 4, 0, 2, 1, 3, 1, 4, 1, 1, 2, 2, 2, 3, 2, 4, 2, 0, 3, | 254 | 3, 0, 4, 0, 2, 1, 3, 1, 4, 1, 1, 2, 2, 2, 3, 2, 4, 2, 0, 3, |
255 | 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 | 255 | 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 |
256 | }; | 256 | }; |
257 | 257 | ||
258 | static const QCOORD top_right_fill[] = { | 258 | static const QCOORD top_right_fill[] = { |
259 | 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, | 259 | 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, |
260 | 3, 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 | 260 | 3, 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 |
261 | }; | 261 | }; |
262 | 262 | ||
263 | QBrush fillBrush( color1, SolidPattern ); | 263 | QBrush fillBrush( color1, SolidPattern ); |
264 | p->setPen( color1 ); | 264 | p->setPen( color1 ); |
265 | if ( round && w > 19 && h > 19 ) { | 265 | if ( round && w > 19 && h > 19 ) { |
266 | int x2 = x + w - 1; | 266 | int x2 = x + w - 1; |
267 | int y2 = y + h - 1; | 267 | int y2 = y + h - 1; |
268 | QPointArray a( QCOORDARRLEN( top_left_fill ), top_left_fill ); | 268 | QPointArray a( QCOORDARRLEN( top_left_fill ), top_left_fill ); |
269 | a.translate( 1, 1 ); | 269 | a.translate( 1, 1 ); |
270 | p->drawPoints( a ); | 270 | p->drawPoints( a ); |
271 | a.setPoints( QCOORDARRLEN( btm_left_fill ), btm_left_fill ); | 271 | a.setPoints( QCOORDARRLEN( btm_left_fill ), btm_left_fill ); |
272 | a.translate( 1, h - 6 ); | 272 | a.translate( 1, h - 6 ); |
273 | p->drawPoints( a ); | 273 | p->drawPoints( a ); |
274 | a.setPoints( QCOORDARRLEN( top_right_fill ), top_right_fill ); | 274 | a.setPoints( QCOORDARRLEN( top_right_fill ), top_right_fill ); |
275 | a.translate( w - 6, 1 ); | 275 | a.translate( w - 6, 1 ); |
276 | p->drawPoints( a ); | 276 | p->drawPoints( a ); |
277 | a.setPoints( QCOORDARRLEN( btm_right_fill ), btm_right_fill ); | 277 | a.setPoints( QCOORDARRLEN( btm_right_fill ), btm_right_fill ); |
278 | a.translate( w - 6, h - 6 ); | 278 | a.translate( w - 6, h - 6 ); |
279 | p->drawPoints( a ); | 279 | p->drawPoints( a ); |
280 | 280 | ||
281 | p->fillRect( x + 6, y, w - 12, h, fillBrush ); | 281 | p->fillRect( x + 6, y, w - 12, h, fillBrush ); |
282 | p->fillRect( x, y + 6, x + 6, h - 12, fillBrush ); | 282 | p->fillRect( x, y + 6, x + 6, h - 12, fillBrush ); |
283 | p->fillRect( x2 - 6, y + 6, x2, h - 12, fillBrush ); | 283 | p->fillRect( x2 - 6, y + 6, x2, h - 12, fillBrush ); |
284 | p->drawLine( x + 6, y, x2 - 6, y ); | 284 | p->drawLine( x + 6, y, x2 - 6, y ); |
285 | p->drawLine( x + 6, y2, x2 - 6, y2 ); | 285 | p->drawLine( x + 6, y2, x2 - 6, y2 ); |
286 | p->drawLine( x, y + 6, x, y2 - 6 ); | 286 | p->drawLine( x, y + 6, x, y2 - 6 ); |
287 | p->drawLine( x2, y + 6, x2, y2 - 6 ); | 287 | p->drawLine( x2, y + 6, x2, y2 - 6 ); |
288 | 288 | ||
289 | } | 289 | } |
290 | else | 290 | else |
291 | p->fillRect( x, y, w, h, fillBrush ); | 291 | p->fillRect( x, y, w, h, fillBrush ); |
292 | } | 292 | } |
293 | 293 | ||
294 | void OThemeStyle::drawButtonMask( QPainter *p, int x, int y, int w, int h ) | 294 | void OThemeStyle::drawButtonMask( QPainter *p, int x, int y, int w, int h ) |
295 | { | 295 | { |
296 | drawBaseMask( p, x, y, w, h, roundButton() ); | 296 | drawBaseMask( p, x, y, w, h, roundButton() ); |
297 | } | 297 | } |
298 | 298 | ||
299 | void OThemeStyle::drawComboButtonMask( QPainter *p, int x, int y, int w, int h ) | 299 | void OThemeStyle::drawComboButtonMask( QPainter *p, int x, int y, int w, int h ) |
300 | { | 300 | { |
301 | drawBaseMask( p, x, y, w, h, roundComboBox() ); | 301 | drawBaseMask( p, x, y, w, h, roundComboBox() ); |
302 | } | 302 | } |
303 | 303 | ||
304 | void OThemeStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, | 304 | void OThemeStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, |
305 | const QColorGroup &g, bool sunken, | 305 | const QColorGroup &g, bool sunken, |
306 | const QBrush * ) | 306 | const QBrush * ) |
307 | { | 307 | { |
308 | WidgetType type = sunken ? BevelDown : Bevel; | 308 | WidgetType type = sunken ? BevelDown : Bevel; |
309 | drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); | 309 | drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); |
310 | } | 310 | } |
311 | 311 | ||
312 | void OThemeStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, | 312 | void OThemeStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, |
313 | const QColorGroup &g, bool sunken, | 313 | const QColorGroup &g, bool sunken, |
314 | const QBrush * ) | 314 | const QBrush * ) |
315 | { | 315 | { |
316 | WidgetType type = sunken ? ToolButtonDown : ToolButton; | 316 | WidgetType type = sunken ? ToolButtonDown : ToolButton; |
317 | drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); | 317 | drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); |
318 | } | 318 | } |
319 | 319 | ||
320 | #if 0 | 320 | #if 0 |
321 | void OThemeStyle::drawKToolBarButton( QPainter *p, int x, int y, int w, int h, | 321 | void OThemeStyle::drawKToolBarButton( QPainter *p, int x, int y, int w, int h, |
322 | const QColorGroup &g, bool sunken, | 322 | const QColorGroup &g, bool sunken, |
323 | bool raised, bool enabled, bool popup, | 323 | bool raised, bool enabled, bool popup, |
324 | KToolButtonType type, const QString &btext, | 324 | KToolButtonType type, const QString &btext, |
325 | const QPixmap *pixmap, QFont *font, | 325 | const QPixmap *pixmap, QFont *font, |
326 | QWidget * ) | 326 | QWidget * ) |
327 | { | 327 | { |
328 | QFont tmp_font( QString::fromLatin1( "Helvetica" ), 10 ); | 328 | QFont tmp_font( QString::fromLatin1( "Helvetica" ), 10 ); |
329 | if ( font ) | 329 | if ( font ) |
330 | tmp_font = *font; | 330 | tmp_font = *font; |
331 | QFontMetrics fm( tmp_font ); | 331 | QFontMetrics fm( tmp_font ); |
332 | WidgetType widget = sunken ? ToolButtonDown : ToolButton; | 332 | WidgetType widget = sunken ? ToolButtonDown : ToolButton; |
333 | 333 | ||
334 | drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, false, | 334 | drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, false, |
335 | widget ); | 335 | widget ); |
336 | int dx, dy; | 336 | int dx, dy; |
337 | if ( type == Icon ) { // icon only | 337 | if ( type == Icon ) { // icon only |
338 | if ( pixmap ) { | 338 | if ( pixmap ) { |
339 | dx = ( w - pixmap->width() ) / 2; | 339 | dx = ( w - pixmap->width() ) / 2; |
340 | dy = ( h - pixmap->height() ) / 2; | 340 | dy = ( h - pixmap->height() ) / 2; |
341 | if ( sunken ) { | 341 | if ( sunken ) { |
342 | ++dx; | 342 | ++dx; |
343 | ++dy; | 343 | ++dy; |
344 | } | 344 | } |
345 | p->drawPixmap( x + dx, y + dy, *pixmap ); | 345 | p->drawPixmap( x + dx, y + dy, *pixmap ); |
346 | } | 346 | } |
347 | } | 347 | } |
348 | else if ( type == IconTextRight ) { // icon and text (if any) | 348 | else if ( type == IconTextRight ) { // icon and text (if any) |
349 | if ( pixmap ) { | 349 | if ( pixmap ) { |
350 | dx = 4; | 350 | dx = 4; |
351 | dy = ( h - pixmap->height() ) / 2; | 351 | dy = ( h - pixmap->height() ) / 2; |
352 | if ( sunken ) { | 352 | if ( sunken ) { |
353 | ++dx; | 353 | ++dx; |
354 | ++dy; | 354 | ++dy; |
355 | } | 355 | } |
356 | p->drawPixmap( x + dx, y + dy, *pixmap ); | 356 | p->drawPixmap( x + dx, y + dy, *pixmap ); |
357 | } | 357 | } |
358 | if ( !btext.isNull() ) { | 358 | if ( !btext.isNull() ) { |
359 | int tf = AlignVCenter | AlignLeft; | 359 | int tf = AlignVCenter | AlignLeft; |
360 | if ( pixmap ) | 360 | if ( pixmap ) |
361 | dx = 4 + pixmap->width() + 2; | 361 | dx = 4 + pixmap->width() + 2; |
362 | else | 362 | else |
363 | dx = 4; | 363 | dx = 4; |
364 | dy = 0; | 364 | dy = 0; |
365 | if ( sunken ) { | 365 | if ( sunken ) { |
366 | ++dx; | 366 | ++dx; |
367 | ++dy; | 367 | ++dy; |
368 | } | 368 | } |
369 | if ( font ) | 369 | if ( font ) |
370 | p->setFont( *font ); | 370 | p->setFont( *font ); |
371 | if ( raised ) | 371 | if ( raised ) |
372 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); | 372 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); |
373 | p->drawText( x + dx, y + dy, w - dx, h, tf, btext ); | 373 | p->drawText( x + dx, y + dy, w - dx, h, tf, btext ); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | else if ( type == Text ) { // only text, even if there is a icon | 376 | else if ( type == Text ) { // only text, even if there is a icon |
377 | if ( !btext.isNull() ) { | 377 | if ( !btext.isNull() ) { |
378 | int tf = AlignTop | AlignLeft; | 378 | int tf = AlignTop | AlignLeft; |
379 | if ( !enabled ) | 379 | if ( !enabled ) |
380 | p->setPen( g.dark() ); | 380 | p->setPen( g.dark() ); |
381 | dx = ( w - fm.width( btext ) ) / 2; | 381 | dx = ( w - fm.width( btext ) ) / 2; |
382 | dy = ( h - fm.lineSpacing() ) / 2; | 382 | dy = ( h - fm.lineSpacing() ) / 2; |
383 | if ( sunken ) { | 383 | if ( sunken ) { |
384 | ++dx; | 384 | ++dx; |
385 | ++dy; | 385 | ++dy; |
386 | } | 386 | } |
387 | if ( font ) | 387 | if ( font ) |
388 | p->setFont( *font ); | 388 | p->setFont( *font ); |
389 | if ( raised ) | 389 | if ( raised ) |
390 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); | 390 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); |
391 | p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); | 391 | p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | else if ( type == IconTextBottom ) { | 394 | else if ( type == IconTextBottom ) { |
395 | if ( pixmap ) { | 395 | if ( pixmap ) { |
396 | dx = ( w - pixmap->width() ) / 2; | 396 | dx = ( w - pixmap->width() ) / 2; |
397 | dy = ( h - fm.lineSpacing() - pixmap->height() ) / 2; | 397 | dy = ( h - fm.lineSpacing() - pixmap->height() ) / 2; |
398 | if ( sunken ) { | 398 | if ( sunken ) { |
399 | ++dx; | 399 | ++dx; |
400 | ++dy; | 400 | ++dy; |
401 | } | 401 | } |
402 | p->drawPixmap( x + dx, y + dy, *pixmap ); | 402 | p->drawPixmap( x + dx, y + dy, *pixmap ); |
403 | } | 403 | } |
404 | if ( !btext.isNull() ) { | 404 | if ( !btext.isNull() ) { |
405 | int tf = AlignBottom | AlignHCenter; | 405 | int tf = AlignBottom | AlignHCenter; |
406 | dx = ( w - fm.width( btext ) ) / 2; | 406 | dx = ( w - fm.width( btext ) ) / 2; |
407 | dy = h - fm.lineSpacing() - 4; | 407 | dy = h - fm.lineSpacing() - 4; |
408 | if ( sunken ) { | 408 | if ( sunken ) { |
409 | ++dx; | 409 | ++dx; |
410 | ++dy; | 410 | ++dy; |
411 | } | 411 | } |
412 | if ( font ) | 412 | if ( font ) |
413 | p->setFont( *font ); | 413 | p->setFont( *font ); |
414 | if ( raised ) | 414 | if ( raised ) |
415 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); | 415 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); |
416 | p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); | 416 | p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); |
417 | } | 417 | } |
418 | } | 418 | } |
419 | if ( popup ) { | 419 | if ( popup ) { |
420 | if ( enabled ) | 420 | if ( enabled ) |
421 | qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, 0, 0, | 421 | qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, 0, 0, |
422 | g, true ); | 422 | g, true ); |
423 | else | 423 | else |
424 | qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, | 424 | qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, |
425 | 0, 0, g, false ); | 425 | 0, 0, g, false ); |
426 | } | 426 | } |
427 | } | 427 | } |
428 | 428 | ||
429 | void OThemeStyle::drawKBarHandle( QPainter *p, int x, int y, int w, int h, | 429 | void OThemeStyle::drawKBarHandle( QPainter *p, int x, int y, int w, int h, |
430 | const QColorGroup &g, KToolBarPos, QBrush * ) | 430 | const QColorGroup &g, KToolBarPos, QBrush * ) |
431 | { | 431 | { |
432 | if ( w > h ) | 432 | if ( w > h ) |
433 | drawBaseButton( p, x, y, w, h, *colorGroup( g, HBarHandle ), false, false, | 433 | drawBaseButton( p, x, y, w, h, *colorGroup( g, HBarHandle ), false, false, |
434 | HBarHandle ); | 434 | HBarHandle ); |
435 | else | 435 | else |
436 | drawBaseButton( p, x, y, w, h, *colorGroup( g, VBarHandle ), false, false, | 436 | drawBaseButton( p, x, y, w, h, *colorGroup( g, VBarHandle ), false, false, |
437 | VBarHandle ); | 437 | VBarHandle ); |
438 | } | 438 | } |
439 | 439 | ||
440 | void OThemeStyle::drawKToolBar( QPainter *p, int x, int y, int w, int h, | 440 | void OThemeStyle::drawKToolBar( QPainter *p, int x, int y, int w, int h, |
441 | const QColorGroup &g, KToolBarPos, QBrush * ) | 441 | const QColorGroup &g, KToolBarPos, QBrush * ) |
442 | { | 442 | { |
443 | drawBaseButton( p, x, y, w, h, *colorGroup( g, ToolBar ), false, false, | 443 | drawBaseButton( p, x, y, w, h, *colorGroup( g, ToolBar ), false, false, |
444 | ToolBar ); | 444 | ToolBar ); |
445 | } | 445 | } |
446 | #endif | 446 | #endif |
447 | 447 | ||
448 | QRect OThemeStyle::buttonRect( int x, int y, int w, int h ) | 448 | QRect OThemeStyle::buttonRect( int x, int y, int w, int h ) |
449 | { | 449 | { |
450 | int spacing = decoWidth( PushButton ) > decoWidth( PushButtonDown ) ? | 450 | int spacing = decoWidth( PushButton ) > decoWidth( PushButtonDown ) ? |
451 | decoWidth( PushButton ) : decoWidth( PushButtonDown ); | 451 | decoWidth( PushButton ) : decoWidth( PushButtonDown ); |
452 | return ( QRect( x + spacing, y + spacing, w - ( spacing * 2 ), h - ( spacing * 2 ) ) ); | 452 | return ( QRect( x + spacing, y + spacing, w - ( spacing * 2 ), h - ( spacing * 2 ) ) ); |
453 | } | 453 | } |
454 | 454 | ||
455 | void OThemeStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, | 455 | void OThemeStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, |
456 | const QColorGroup &g, bool sunken, bool, | 456 | const QColorGroup &g, bool sunken, bool, |
457 | bool, const QBrush * ) | 457 | bool, const QBrush * ) |
458 | { | 458 | { |
459 | WidgetType widget = sunken ? ComboBoxDown : ComboBox; | 459 | WidgetType widget = sunken ? ComboBoxDown : ComboBox; |
460 | drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, | 460 | drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, |
461 | roundComboBox(), widget ); | 461 | roundComboBox(), widget ); |
462 | if ( !sunken && isPixmap( ComboDeco ) ) | 462 | if ( !sunken && isPixmap( ComboDeco ) ) |
463 | p->drawPixmap( w - uncached( ComboDeco ) ->width() - | 463 | p->drawPixmap( w - uncached( ComboDeco ) ->width() - |
464 | decoWidth( ComboBox ) - 2, | 464 | decoWidth( ComboBox ) - 2, |
465 | y + ( h - uncached( ComboDeco ) -> | 465 | y + ( h - uncached( ComboDeco ) -> |
466 | height() ) / 2, *uncached( ComboDeco ) ); | 466 | height() ) / 2, *uncached( ComboDeco ) ); |
467 | else if ( sunken && isPixmap( ComboDecoDown ) ) | 467 | else if ( sunken && isPixmap( ComboDecoDown ) ) |
468 | p->drawPixmap( w - uncached( ComboDecoDown ) ->width() - | 468 | p->drawPixmap( w - uncached( ComboDecoDown ) ->width() - |
469 | decoWidth( ComboBoxDown ) - 2, | 469 | decoWidth( ComboBoxDown ) - 2, |
470 | y + ( h - uncached( ComboDecoDown ) -> | 470 | y + ( h - uncached( ComboDecoDown ) -> |
471 | height() ) / 2, *uncached( ComboDecoDown ) ); | 471 | height() ) / 2, *uncached( ComboDecoDown ) ); |
472 | else { | 472 | else { |
473 | qDrawArrow( p, Qt::DownArrow, Qt::MotifStyle, false, w - 15, y + 6, 10, | 473 | qDrawArrow( p, Qt::DownArrow, Qt::MotifStyle, false, w - 15, y + 6, 10, |
474 | h - 15, *colorGroup( g, widget ), true ); | 474 | h - 15, *colorGroup( g, widget ), true ); |
475 | qDrawShadeRect( p, w - 14, y + 7 + ( h - 15 ), 10, 3, *colorGroup( g, widget ) ); | 475 | qDrawShadeRect( p, w - 14, y + 7 + ( h - 15 ), 10, 3, *colorGroup( g, widget ) ); |
476 | } | 476 | } |
477 | } | 477 | } |
478 | 478 | ||
479 | void OThemeStyle::drawScrollBarControls( QPainter *p, const QScrollBar *sb, | 479 | void OThemeStyle::drawScrollBarControls( QPainter *p, const QScrollBar *sb, |
480 | int sliderStart, uint controls, | 480 | int sliderStart, uint controls, |
481 | uint activeControl ) | 481 | uint activeControl ) |
482 | { | 482 | { |
483 | int sliderMin, sliderMax, sliderLength, buttonDim; | 483 | int sliderMin, sliderMax, sliderLength, buttonDim; |
484 | QRect add | 484 | QRect add |
485 | , sub, addPage, subPage, slider; | 485 | , sub, addPage, subPage, slider; |
486 | int addX, addY, subX, subY; | 486 | int addX, addY, subX, subY; |
487 | bool horizontal = sb->orientation() == QScrollBar::Horizontal; | 487 | bool horizontal = sb->orientation() == QScrollBar::Horizontal; |
488 | int len = ( horizontal ) ? sb->width() : sb->height(); | 488 | int len = ( horizontal ) ? sb->width() : sb->height(); |
489 | int extent = ( horizontal ) ? sb->height() : sb->width(); | 489 | int extent = ( horizontal ) ? sb->height() : sb->width(); |
490 | int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove ); | 490 | int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove ); |
491 | QColorGroup g = sb->colorGroup(); | 491 | QColorGroup g = sb->colorGroup(); |
492 | 492 | ||
493 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); | 493 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); |
494 | if ( sliderStart > sliderMax ) | 494 | if ( sliderStart > sliderMax ) |
495 | sliderStart = sliderMax; | 495 | sliderStart = sliderMax; |
496 | 496 | ||
497 | int sliderEnd = sliderStart + sliderLength; | 497 | int sliderEnd = sliderStart + sliderLength; |
498 | int sliderWidth = extent - offset * 2; | 498 | int sliderWidth = extent - offset * 2; |
499 | 499 | ||
500 | // Scary button placement code >:-P Feel free to improve this if you | 500 | // Scary button placement code >:-P Feel free to improve this if you |
501 | // want. I get a headache just looking at it... (mosfet) | 501 | // want. I get a headache just looking at it... (mosfet) |
502 | if ( scrollBarLayout() == SBOpposite ) { | 502 | if ( scrollBarLayout() == SBOpposite ) { |
503 | if ( horizontal ) { | 503 | if ( horizontal ) { |
504 | subY = addY = ( extent - buttonDim ) / 2; | 504 | subY = addY = ( extent - buttonDim ) / 2; |
505 | subX = offset; | 505 | subX = offset; |
506 | addX = len - buttonDim - offset; | 506 | addX = len - buttonDim - offset; |
507 | } | 507 | } |
508 | else { | 508 | else { |
509 | subX = addX = ( extent - buttonDim ) / 2; | 509 | subX = addX = ( extent - buttonDim ) / 2; |
510 | subY = offset; | 510 | subY = offset; |
511 | addY = len - buttonDim - offset; | 511 | addY = len - buttonDim - offset; |
512 | } | 512 | } |
513 | sub.setRect( subX, subY, buttonDim, buttonDim ); | 513 | sub.setRect( subX, subY, buttonDim, buttonDim ); |
514 | add.setRect( addX, addY, buttonDim, buttonDim ); | 514 | add.setRect( addX, addY, buttonDim, buttonDim ); |
515 | if ( horizontal ) { | 515 | if ( horizontal ) { |
516 | subPage.setRect( sub.right() + 1, offset, | 516 | subPage.setRect( sub.right() + 1, offset, |
517 | sliderStart - sub.right() - 1 , sliderWidth ); | 517 | sliderStart - sub.right() - 1 , sliderWidth ); |
518 | addPage.setRect( sliderEnd, offset, addX - sliderEnd, sliderWidth ); | 518 | addPage.setRect( sliderEnd, offset, addX - sliderEnd, sliderWidth ); |
519 | slider.setRect( sliderStart, offset, sliderLength, sliderWidth ); | 519 | slider.setRect( sliderStart, offset, sliderLength, sliderWidth ); |
520 | } | 520 | } |
521 | else { | 521 | else { |
522 | subPage.setRect( offset, sub.bottom() + 1, sliderWidth, | 522 | subPage.setRect( offset, sub.bottom() + 1, sliderWidth, |
523 | sliderStart - sub.bottom() - 1 ); | 523 | sliderStart - sub.bottom() - 1 ); |
524 | addPage.setRect( offset, sliderEnd, sliderWidth, addY - sliderEnd ); | 524 | addPage.setRect( offset, sliderEnd, sliderWidth, addY - sliderEnd ); |
525 | slider.setRect( offset, sliderStart, sliderWidth, sliderLength ); | 525 | slider.setRect( offset, sliderStart, sliderWidth, sliderLength ); |
526 | } | 526 | } |
527 | } | 527 | } |
528 | else if ( horizontal ) { | 528 | else if ( horizontal ) { |
529 | subY = addY = ( extent - buttonDim ) / 2; | 529 | subY = addY = ( extent - buttonDim ) / 2; |
530 | if ( scrollBarLayout() == SBBottomLeft ) { | 530 | if ( scrollBarLayout() == SBBottomLeft ) { |
531 | subX = offset; | 531 | subX = offset; |
532 | addX = buttonDim + offset; | 532 | addX = buttonDim + offset; |
533 | subPage.setRect( buttonDim * 2, 0, sliderStart - 1, extent ); | 533 | subPage.setRect( buttonDim * 2, 0, sliderStart - 1, extent ); |
534 | addPage.setRect( sliderEnd, 0, len - sliderEnd, extent ); | 534 | addPage.setRect( sliderEnd, 0, len - sliderEnd, extent ); |
535 | slider.setRect( sliderStart, 0, sliderLength, extent ); | 535 | slider.setRect( sliderStart, 0, sliderLength, extent ); |
536 | } | 536 | } |
537 | else { | 537 | else { |
538 | subX = len - buttonDim - buttonDim - offset; | 538 | subX = len - buttonDim - buttonDim - offset; |
539 | addX = len - buttonDim - offset; | 539 | addX = len - buttonDim - offset; |
540 | subPage.setRect( offset + 1, offset, sliderStart - 1 , sliderWidth ); | 540 | subPage.setRect( offset + 1, offset, sliderStart - 1 , sliderWidth ); |
541 | addPage.setRect( sliderEnd, offset, subX - sliderEnd, sliderWidth ); | 541 | addPage.setRect( sliderEnd, offset, subX - sliderEnd, sliderWidth ); |
542 | slider.setRect( sliderStart, offset, sliderLength, sliderWidth ); | 542 | slider.setRect( sliderStart, offset, sliderLength, sliderWidth ); |
543 | } | 543 | } |
544 | sub.setRect( subX, subY, buttonDim, buttonDim ); | 544 | sub.setRect( subX, subY, buttonDim, buttonDim ); |
545 | add.setRect( addX, addY, buttonDim, buttonDim ); | 545 | add.setRect( addX, addY, buttonDim, buttonDim ); |
546 | } | 546 | } |
547 | else { // BottomLeft and BottomRight vertical bars are the same. | 547 | else { // BottomLeft and BottomRight vertical bars are the same. |
548 | subX = addX = ( extent - buttonDim ) / 2; | 548 | subX = addX = ( extent - buttonDim ) / 2; |
549 | subY = len - buttonDim - buttonDim - offset; | 549 | subY = len - buttonDim - buttonDim - offset; |
550 | addY = len - buttonDim - offset; | 550 | addY = len - buttonDim - offset; |
551 | subPage.setRect( offset, offset + 1, sliderWidth, | 551 | subPage.setRect( offset, offset + 1, sliderWidth, |
552 | sliderStart - offset - 1 ); | 552 | sliderStart - offset - 1 ); |
553 | addPage.setRect( offset, sliderEnd, sliderWidth, subY - sliderEnd ); | 553 | addPage.setRect( offset, sliderEnd, sliderWidth, subY - sliderEnd ); |
554 | slider.setRect( offset, sliderStart, sliderWidth, sliderLength ); | 554 | slider.setRect( offset, sliderStart, sliderWidth, sliderLength ); |
555 | sub.setRect( subX, subY, buttonDim, buttonDim ); | 555 | sub.setRect( subX, subY, buttonDim, buttonDim ); |
556 | add.setRect( addX, addY, buttonDim, buttonDim ); | 556 | add.setRect( addX, addY, buttonDim, buttonDim ); |
557 | } | 557 | } |
558 | // End of the button placement code | 558 | // End of the button placement code |
559 | 559 | ||
560 | bool active; | 560 | bool active; |
561 | if ( ( controls & QStyle::SubPage ) ) { | 561 | if ( ( controls & QStyle::SubPage ) ) { |
562 | drawScrollBarGroove( p, sb, horizontal, subPage, g ); | 562 | drawScrollBarGroove( p, sb, horizontal, subPage, g ); |
563 | } | 563 | } |
564 | if ( ( controls & QStyle::AddPage ) ) { | 564 | if ( ( controls & QStyle::AddPage ) ) { |
565 | drawScrollBarGroove( p, sb, horizontal, addPage, g ); | 565 | drawScrollBarGroove( p, sb, horizontal, addPage, g ); |
566 | } | 566 | } |
567 | if ( controls & QStyle::AddLine ) { | 567 | if ( controls & QStyle::AddLine ) { |
568 | active = activeControl == QStyle::AddLine; | 568 | active = activeControl == QStyle::AddLine; |
569 | drawBaseButton( p, add.x(), add.y(), add.width(), add.height(), | 569 | drawBaseButton( p, add.x(), add.y(), add.width(), add.height(), |
570 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ), | 570 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ), |
571 | active, false, active ? ScrollButtonDown : ScrollButton ); | 571 | active, false, active ? ScrollButtonDown : ScrollButton ); |
572 | drawArrow( p, ( horizontal ) ? RightArrow : DownArrow, active, add.x() + 3, | 572 | drawArrow( p, ( horizontal ) ? RightArrow : DownArrow, active, add.x() + 3, |
573 | add.y() + 3, add.width() - 6, add.height() - 6, | 573 | add.y() + 3, add.width() - 6, add.height() - 6, |
574 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) ); | 574 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) ); |
575 | } | 575 | } |
576 | if ( controls & QStyle::SubLine ) { | 576 | if ( controls & QStyle::SubLine ) { |
577 | active = activeControl == QStyle::SubLine; | 577 | active = activeControl == QStyle::SubLine; |
578 | p->setPen( g.dark() ); | 578 | p->setPen( g.dark() ); |
579 | p->drawRect( sub ); | 579 | p->drawRect( sub ); |
580 | drawBaseButton( p, sub.x(), sub.y(), sub.width(), sub.height(), | 580 | drawBaseButton( p, sub.x(), sub.y(), sub.width(), sub.height(), |
581 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ), | 581 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ), |
582 | active, false, active ? ScrollButtonDown : ScrollButton ); | 582 | active, false, active ? ScrollButtonDown : ScrollButton ); |
583 | drawArrow( p, ( horizontal ) ? LeftArrow : UpArrow, active, sub.x() + 3, | 583 | drawArrow( p, ( horizontal ) ? LeftArrow : UpArrow, active, sub.x() + 3, |
584 | sub.y() + 3, sub.width() - 6, sub.height() - 6, | 584 | sub.y() + 3, sub.width() - 6, sub.height() - 6, |
585 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) ); | 585 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) ); |
586 | } | 586 | } |
587 | if ( controls & QStyle::Slider ) { | 587 | if ( controls & QStyle::Slider ) { |
588 | active = activeControl == QStyle::Slider; | 588 | active = activeControl == QStyle::Slider; |
589 | WidgetType widget = horizontal ? | 589 | WidgetType widget = horizontal ? |
590 | active ? HScrollBarSliderDown : HScrollBarSlider : | 590 | active ? HScrollBarSliderDown : HScrollBarSlider : |
591 | active ? VScrollBarSliderDown : VScrollBarSlider; | 591 | active ? VScrollBarSliderDown : VScrollBarSlider; |
592 | 592 | ||
593 | drawBaseButton( p, slider.x(), slider.y(), slider.width(), | 593 | drawBaseButton( p, slider.x(), slider.y(), slider.width(), |
594 | slider.height(), *colorGroup( g, widget ), active, false, | 594 | slider.height(), *colorGroup( g, widget ), active, false, |
595 | widget ); | 595 | widget ); |
596 | int spaceW = horizontal ? slider.width() - decoWidth( widget ) - 4 : | 596 | int spaceW = horizontal ? slider.width() - decoWidth( widget ) - 4 : |
597 | slider.width(); | 597 | slider.width(); |
598 | int spaceH = horizontal ? slider.height() : | 598 | int spaceH = horizontal ? slider.height() : |
599 | slider.height() - decoWidth( widget ) - 4; | 599 | slider.height() - decoWidth( widget ) - 4; |
600 | widget = active ? horizontal ? HScrollDecoDown : VScrollDecoDown : | 600 | widget = active ? horizontal ? HScrollDecoDown : VScrollDecoDown : |
601 | horizontal ? HScrollDeco : VScrollDeco; | 601 | horizontal ? HScrollDeco : VScrollDeco; |
602 | if ( isPixmap( widget ) ) { | 602 | if ( isPixmap( widget ) ) { |
603 | if ( spaceW >= uncached( widget ) ->width() && | 603 | if ( spaceW >= uncached( widget ) ->width() && |
604 | spaceH >= uncached( widget ) ->height() ) { | 604 | spaceH >= uncached( widget ) ->height() ) { |
605 | p->drawPixmap( slider.x() + ( slider.width() - | 605 | p->drawPixmap( slider.x() + ( slider.width() - |
606 | uncached( widget ) ->width() ) / 2, | 606 | uncached( widget ) ->width() ) / 2, |
607 | slider.y() + ( slider.height() - | 607 | slider.y() + ( slider.height() - |
608 | uncached( widget ) ->height() ) / 2, | 608 | uncached( widget ) ->height() ) / 2, |
609 | *uncached( widget ) ); | 609 | *uncached( widget ) ); |
610 | } | 610 | } |
611 | } | 611 | } |
612 | } | 612 | } |
613 | } | 613 | } |
614 | 614 | ||
615 | void OThemeStyle::drawScrollBarGroove( QPainter *p, const QScrollBar *sb, | 615 | void OThemeStyle::drawScrollBarGroove( QPainter *p, const QScrollBar *sb, |
616 | bool horizontal, QRect r, QColorGroup g ) | 616 | bool horizontal, QRect r, QColorGroup g ) |
617 | 617 | ||
618 | { | 618 | { |
619 | WidgetType widget = ( horizontal ) ? HScrollGroove : VScrollGroove; | 619 | WidgetType widget = ( horizontal ) ? HScrollGroove : VScrollGroove; |
620 | if ( !isPixmap( widget ) ) { | 620 | if ( !isPixmap( widget ) ) { |
621 | p->fillRect( r, colorGroup( g, widget ) ->brush( QColorGroup::Background ) ); | 621 | p->fillRect( r, colorGroup( g, widget ) ->brush( QColorGroup::Background ) ); |
622 | } | 622 | } |
623 | else { | 623 | else { |
624 | // If the groove is pixmapped we make a full-sized image (it gets | 624 | // If the groove is pixmapped we make a full-sized image (it gets |
625 | // cached) then bitBlt it to the appropriate rect. | 625 | // cached) then bitBlt it to the appropriate rect. |
626 | QPixmap buffer( sb->size() ); | 626 | QPixmap buffer( sb->size() ); |
627 | QPainter bPainter( &buffer ); | 627 | QPainter bPainter( &buffer ); |
628 | bPainter.drawTiledPixmap( 0, 0, buffer.width(), buffer.height(), | 628 | bPainter.drawTiledPixmap( 0, 0, buffer.width(), buffer.height(), |
629 | *scalePixmap( buffer.width(), buffer.height(), | 629 | *scalePixmap( buffer.width(), buffer.height(), |
630 | widget ) ); | 630 | widget ) ); |
631 | bitBlt( p->device(), r.x(), r.y(), &buffer, r.x(), r.y(), r.width(), | 631 | bitBlt( p->device(), r.x(), r.y(), &buffer, r.x(), r.y(), r.width(), |
632 | r.height(), Qt::CopyROP ); | 632 | r.height(), Qt::CopyROP ); |
633 | } | 633 | } |
634 | // Do the borders and frame | 634 | // Do the borders and frame |
635 | drawShade( p, sb->rect().x(), sb->rect().y(), sb->rect().width(), | 635 | drawShade( p, sb->rect().x(), sb->rect().y(), sb->rect().width(), |
636 | sb->rect().height(), *colorGroup( g, widget ), true, false, | 636 | sb->rect().height(), *colorGroup( g, widget ), true, false, |
637 | highlightWidth( widget ), borderWidth( widget ), shade() ); | 637 | highlightWidth( widget ), borderWidth( widget ), shade() ); |
638 | } | 638 | } |
639 | 639 | ||
640 | void OThemeStyle::scrollBarMetrics( const QScrollBar *sb, int &sliderMin, | 640 | void OThemeStyle::scrollBarMetrics( const QScrollBar *sb, int &sliderMin, |
641 | int &sliderMax, int &sliderLength, | 641 | int &sliderMax, int &sliderLength, |
642 | int &buttonDim ) | 642 | int &buttonDim ) |
643 | { | 643 | { |
644 | bool horizontal = sb->orientation() == QScrollBar::Horizontal; | 644 | bool horizontal = sb->orientation() == QScrollBar::Horizontal; |
645 | int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove ); | 645 | int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove ); |
646 | int maxlen; | 646 | int maxlen; |
647 | int len = horizontal ? sb->width() : sb->height(); | 647 | int len = horizontal ? sb->width() : sb->height(); |
648 | int extent = horizontal ? sb->height() : sb->width(); | 648 | int extent = horizontal ? sb->height() : sb->width(); |
649 | 649 | ||
650 | if ( len > ( extent - offset * 2 - 1 ) * 2 + offset * 2 ) | 650 | if ( len > ( extent - offset * 2 - 1 ) * 2 + offset * 2 ) |
651 | buttonDim = extent - offset * 2; | 651 | buttonDim = extent - offset * 2; |
652 | else | 652 | else |
653 | buttonDim = ( len - offset * 2 ) / 2 - 1; | 653 | buttonDim = ( len - offset * 2 ) / 2 - 1; |
654 | maxlen = len - offset * 2 - buttonDim * 2 - 1; | 654 | maxlen = len - offset * 2 - buttonDim * 2 - 1; |
655 | 655 | ||
656 | switch ( scrollBarLayout() ) { | 656 | switch ( scrollBarLayout() ) { |
657 | case SBBottomLeft: | 657 | case SBBottomLeft: |
658 | sliderMin = ( horizontal ) ? buttonDim * 2 + offset + 1 : offset + 1; | 658 | sliderMin = ( horizontal ) ? buttonDim * 2 + offset + 1 : offset + 1; |
659 | break; | 659 | break; |
660 | case SBBottomRight: | 660 | case SBBottomRight: |
661 | sliderMin = offset + 1; | 661 | sliderMin = offset + 1; |
662 | break; | 662 | break; |
663 | case SBOpposite: | 663 | case SBOpposite: |
664 | default: | 664 | default: |
665 | sliderMin = offset + buttonDim; | 665 | sliderMin = offset + buttonDim; |
666 | break; | 666 | break; |
667 | } | 667 | } |
668 | if ( sb->maxValue() == sb->minValue() ) | 668 | if ( sb->maxValue() == sb->minValue() ) |
669 | sliderLength = maxlen; | 669 | sliderLength = maxlen; |
670 | else | 670 | else |
671 | sliderLength = ( sb->pageStep() * maxlen ) / ( sb->maxValue() - | 671 | sliderLength = ( sb->pageStep() * maxlen ) / ( sb->maxValue() - |
672 | sb->minValue() + sb->pageStep() ); | 672 | sb->minValue() + sb->pageStep() ); |
673 | if ( sliderLength < 12 || ( sb->maxValue() - sb->minValue() ) > INT_MAX / 2 ) | 673 | if ( sliderLength < 12 || ( sb->maxValue() - sb->minValue() ) > INT_MAX / 2 ) |
674 | sliderLength = 12; | 674 | sliderLength = 12; |
675 | if ( sliderLength > maxlen ) | 675 | if ( sliderLength > maxlen ) |
676 | sliderLength = maxlen; | 676 | sliderLength = maxlen; |
677 | sliderMax = sliderMin + maxlen - sliderLength; | 677 | sliderMax = sliderMin + maxlen - sliderLength; |
678 | } | 678 | } |
679 | 679 | ||
680 | QStyle::ScrollControl OThemeStyle::scrollBarPointOver( const QScrollBar *sb, | 680 | QStyle::ScrollControl OThemeStyle::scrollBarPointOver( const QScrollBar *sb, |
681 | int sliderStart, | 681 | int sliderStart, |
682 | const QPoint &p ) | 682 | const QPoint &p ) |
683 | { | 683 | { |
684 | if ( !sb->rect().contains( p ) ) | 684 | if ( !sb->rect().contains( p ) ) |
685 | return ( QStyle::NoScroll ); | 685 | return ( QStyle::NoScroll ); |
686 | int sliderMin, sliderMax, sliderLength, buttonDim; | 686 | int sliderMin, sliderMax, sliderLength, buttonDim; |
687 | int pos = ( sb->orientation() == QScrollBar::Horizontal ) ? p.x() : p.y(); | 687 | int pos = ( sb->orientation() == QScrollBar::Horizontal ) ? p.x() : p.y(); |
688 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); | 688 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); |
689 | 689 | ||
690 | if ( scrollBarLayout() == SBOpposite ) { | 690 | if ( scrollBarLayout() == SBOpposite ) { |
691 | if ( pos < sliderMin ) | 691 | if ( pos < sliderMin ) |
692 | return QStyle::SubLine; | 692 | return QStyle::SubLine; |
693 | if ( pos < sliderStart ) | 693 | if ( pos < sliderStart ) |
694 | return SubPage; | 694 | return SubPage; |
695 | if ( pos < sliderStart + sliderLength ) | 695 | if ( pos < sliderStart + sliderLength ) |
696 | return QStyle::Slider; | 696 | return QStyle::Slider; |
697 | if ( pos < sliderMax + sliderLength ) | 697 | if ( pos < sliderMax + sliderLength ) |
698 | return QStyle::AddPage; | 698 | return QStyle::AddPage; |
699 | return QStyle::AddLine; | 699 | return QStyle::AddLine; |
700 | } | 700 | } |
701 | if ( scrollBarLayout() == SBBottomLeft && sb->orientation() == | 701 | if ( scrollBarLayout() == SBBottomLeft && sb->orientation() == |
702 | QScrollBar::Horizontal ) { | 702 | QScrollBar::Horizontal ) { |
703 | if ( pos <= buttonDim ) | 703 | if ( pos <= buttonDim ) |
704 | return ( QStyle::SubLine ); | 704 | return ( QStyle::SubLine ); |
705 | else if ( pos <= buttonDim * 2 ) | 705 | else if ( pos <= buttonDim * 2 ) |
706 | return ( QStyle::AddLine ); | 706 | return ( QStyle::AddLine ); |
707 | else if ( pos < sliderStart ) | 707 | else if ( pos < sliderStart ) |
708 | return ( QStyle::SubPage ); | 708 | return ( QStyle::SubPage ); |
709 | else if ( pos < sliderStart + sliderLength ) | 709 | else if ( pos < sliderStart + sliderLength ) |
710 | return ( QStyle::Slider ); | 710 | return ( QStyle::Slider ); |
711 | return ( AddPage ); | 711 | return ( AddPage ); |
712 | } | 712 | } |
713 | else { | 713 | else { |
714 | if ( pos < sliderStart ) | 714 | if ( pos < sliderStart ) |
715 | return QStyle::SubPage; | 715 | return QStyle::SubPage; |
716 | if ( pos < sliderStart + sliderLength ) | 716 | if ( pos < sliderStart + sliderLength ) |
717 | return QStyle::Slider; | 717 | return QStyle::Slider; |
718 | if ( pos < sliderMax + sliderLength ) | 718 | if ( pos < sliderMax + sliderLength ) |
719 | return QStyle::AddPage; | 719 | return QStyle::AddPage; |
720 | if ( pos < sliderMax + sliderLength + buttonDim ) | 720 | if ( pos < sliderMax + sliderLength + buttonDim ) |
721 | return QStyle::SubLine; | 721 | return QStyle::SubLine; |
722 | return QStyle::AddLine; | 722 | return QStyle::AddLine; |
723 | } | 723 | } |
724 | } | 724 | } |
725 | 725 | ||
726 | QSize OThemeStyle::exclusiveIndicatorSize() const | 726 | QSize OThemeStyle::exclusiveIndicatorSize() const |
727 | { | 727 | { |
728 | if ( isPixmap( ExIndicatorOn ) ) | 728 | if ( isPixmap( ExIndicatorOn ) ) |
729 | return ( uncached( ExIndicatorOn ) ->size() ); | 729 | return ( uncached( ExIndicatorOn ) ->size() ); |
730 | else | 730 | else |
731 | return ( QWindowsStyle::exclusiveIndicatorSize() ); | 731 | return ( QWindowsStyle::exclusiveIndicatorSize() ); |
732 | } | 732 | } |
733 | 733 | ||
734 | QSize OThemeStyle::indicatorSize() const | 734 | QSize OThemeStyle::indicatorSize() const |
735 | { | 735 | { |
736 | if ( isPixmap( IndicatorOn ) ) | 736 | if ( isPixmap( IndicatorOn ) ) |
737 | return ( uncached( IndicatorOn ) ->size() ); | 737 | return ( uncached( IndicatorOn ) ->size() ); |
738 | else | 738 | else |
739 | return ( QWindowsStyle::indicatorSize() ); | 739 | return ( QWindowsStyle::indicatorSize() ); |
740 | } | 740 | } |
741 | 741 | ||
742 | void OThemeStyle::drawExclusiveIndicator( QPainter* p, int x, int y, int w, | 742 | void OThemeStyle::drawExclusiveIndicator( QPainter* p, int x, int y, int w, |
743 | int h, const QColorGroup &g, bool on, | 743 | int h, const QColorGroup &g, bool on, |
744 | bool down, bool enabled ) | 744 | bool down, bool enabled ) |
745 | { | 745 | { |
746 | if ( isPixmap( ( on || down ) ? ExIndicatorOn : ExIndicatorOff ) ) { | 746 | if ( isPixmap( ( on || down ) ? ExIndicatorOn : ExIndicatorOff ) ) { |
747 | p->drawPixmap( x, y, *uncached( ( on || down ) ? ExIndicatorOn : | 747 | p->drawPixmap( x, y, *uncached( ( on || down ) ? ExIndicatorOn : |
748 | ExIndicatorOff ) ); | 748 | ExIndicatorOff ) ); |
749 | } | 749 | } |
750 | else { | 750 | else { |
751 | QWindowsStyle::drawExclusiveIndicator( p, x, y, w, h, | 751 | QWindowsStyle::drawExclusiveIndicator( p, x, y, w, h, |
752 | *colorGroup( g, ExIndicatorOn ), | 752 | *colorGroup( g, ExIndicatorOn ), |
753 | on, down, enabled ); | 753 | on, down, enabled ); |
754 | } | 754 | } |
755 | 755 | ||
756 | } | 756 | } |
757 | 757 | ||
758 | void OThemeStyle::drawIndicator( QPainter* p, int x, int y, int w, int h, | 758 | void OThemeStyle::drawIndicator( QPainter* p, int x, int y, int w, int h, |
759 | const QColorGroup &g, int state, bool down, | 759 | const QColorGroup &g, int state, bool down, |
760 | bool enabled ) | 760 | bool enabled ) |
761 | { | 761 | { |
762 | if ( isPixmap( ( down || state != QButton::Off ) ? | 762 | if ( isPixmap( ( down || state != QButton::Off ) ? |
763 | IndicatorOn : IndicatorOff ) ) { | 763 | IndicatorOn : IndicatorOff ) ) { |
764 | p->drawPixmap( x, y, *uncached( ( down || state != QButton::Off ) ? | 764 | p->drawPixmap( x, y, *uncached( ( down || state != QButton::Off ) ? |
765 | IndicatorOn : IndicatorOff ) ); | 765 | IndicatorOn : IndicatorOff ) ); |
766 | } | 766 | } |
767 | else { | 767 | else { |
768 | QWindowsStyle::drawIndicator( p, x, y, w, h, | 768 | QWindowsStyle::drawIndicator( p, x, y, w, h, |
769 | *colorGroup( g, IndicatorOn ), state, | 769 | *colorGroup( g, IndicatorOn ), state, |
770 | down, enabled ); | 770 | down, enabled ); |
771 | } | 771 | } |
772 | } | 772 | } |
773 | 773 | ||
774 | void OThemeStyle::drawExclusiveIndicatorMask( QPainter *p, int x, int y, int w, | 774 | void OThemeStyle::drawExclusiveIndicatorMask( QPainter *p, int x, int y, int w, |
775 | int h, bool on ) | 775 | int h, bool on ) |
776 | { | 776 | { |
777 | if ( isPixmap( ( on ) ? ExIndicatorOn : ExIndicatorOff ) ) { | 777 | if ( isPixmap( ( on ) ? ExIndicatorOn : ExIndicatorOff ) ) { |
778 | const QBitmap * mask = uncached( ( on ) ? ExIndicatorOn : ExIndicatorOff ) -> | 778 | const QBitmap * mask = uncached( ( on ) ? ExIndicatorOn : ExIndicatorOff ) -> |
779 | mask(); | 779 | mask(); |
780 | if ( mask ) { | 780 | if ( mask ) { |
781 | p->drawPixmap( x, y, *mask ); | 781 | p->drawPixmap( x, y, *mask ); |
782 | } | 782 | } |
783 | else | 783 | else |
784 | p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); | 784 | p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); |
785 | } | 785 | } |
786 | else | 786 | else |
787 | QWindowsStyle::drawExclusiveIndicatorMask( p, x, y, w, h, on ); | 787 | QWindowsStyle::drawExclusiveIndicatorMask( p, x, y, w, h, on ); |
788 | } | 788 | } |
789 | 789 | ||
790 | void OThemeStyle::drawIndicatorMask( QPainter *p, int x, int y, int w, int h, | 790 | void OThemeStyle::drawIndicatorMask( QPainter *p, int x, int y, int w, int h, |
791 | int state ) | 791 | int state ) |
792 | { | 792 | { |
793 | if ( isPixmap( ( state != QButton::Off ) ? IndicatorOn : IndicatorOff ) ) { | 793 | if ( isPixmap( ( state != QButton::Off ) ? IndicatorOn : IndicatorOff ) ) { |
794 | const QBitmap * mask = uncached( ( state != QButton::Off ) ? IndicatorOn : | 794 | const QBitmap * mask = uncached( ( state != QButton::Off ) ? IndicatorOn : |
795 | IndicatorOff ) ->mask(); | 795 | IndicatorOff ) ->mask(); |
796 | if ( mask ) | 796 | if ( mask ) |
797 | p->drawPixmap( x, y, *mask ); | 797 | p->drawPixmap( x, y, *mask ); |
798 | else | 798 | else |
799 | p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); | 799 | p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); |
800 | } | 800 | } |
801 | else | 801 | else |
802 | QWindowsStyle::drawIndicatorMask( p, x, y, w, h, state ); | 802 | QWindowsStyle::drawIndicatorMask( p, x, y, w, h, state ); |
803 | } | 803 | } |
804 | 804 | ||
805 | void OThemeStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, | 805 | void OThemeStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, |
806 | const QColorGroup& g, QCOORD c, | 806 | const QColorGroup& g, QCOORD c, |
807 | Orientation orient ) | 807 | Orientation orient ) |
808 | { | 808 | { |
809 | if ( roundSlider() ) | 809 | if ( roundSlider() ) |
810 | QWindowsStyle::drawSliderGroove( p, x, y, w, h, | 810 | QWindowsStyle::drawSliderGroove( p, x, y, w, h, |
811 | *colorGroup( g, SliderGroove ), | 811 | *colorGroup( g, SliderGroove ), |
812 | c, orient ); | 812 | c, orient ); |
813 | else | 813 | else |
814 | drawBaseButton( p, x, y, w, h, *colorGroup( g, SliderGroove ), true, | 814 | drawBaseButton( p, x, y, w, h, *colorGroup( g, SliderGroove ), true, |
815 | false, SliderGroove ); | 815 | false, SliderGroove ); |
816 | } | 816 | } |
817 | 817 | ||
818 | void OThemeStyle::drawSlider( QPainter *p, int x, int y, int w, int h, | 818 | void OThemeStyle::drawSlider( QPainter *p, int x, int y, int w, int h, |
819 | const QColorGroup &g, Orientation orient, | 819 | const QColorGroup &g, Orientation orient, |
820 | bool tickAbove, bool tickBelow ) | 820 | bool tickAbove, bool tickBelow ) |
821 | { | 821 | { |
822 | if ( isPixmap( Slider ) ) { | 822 | if ( isPixmap( Slider ) ) { |
823 | if ( orient == Qt::Horizontal ) | 823 | if ( orient == Qt::Horizontal ) |
824 | p->drawPixmap( x, y + ( h - uncached( Slider ) ->height() ) / 2, | 824 | p->drawPixmap( x, y + ( h - uncached( Slider ) ->height() ) / 2, |
825 | *uncached( Slider ) ); | 825 | *uncached( Slider ) ); |
826 | else | 826 | else |
827 | p->drawPixmap( x + ( w - uncached( Slider ) ->width() ) / 2, | 827 | p->drawPixmap( x + ( w - uncached( Slider ) ->width() ) / 2, |
828 | y, *uncached( Slider ) ); | 828 | y, *uncached( Slider ) ); |
829 | } | 829 | } |
830 | else { | 830 | else { |
831 | QWindowsStyle::drawSlider( p, x, y, w, h, *colorGroup( g, Slider ), | 831 | QWindowsStyle::drawSlider( p, x, y, w, h, *colorGroup( g, Slider ), |
832 | orient, tickAbove, tickBelow ); | 832 | orient, tickAbove, tickBelow ); |
833 | } | 833 | } |
834 | } | 834 | } |
835 | 835 | ||
836 | void OThemeStyle::drawSliderMask( QPainter *p, int x, int y, int w, int h, | 836 | void OThemeStyle::drawSliderMask( QPainter *p, int x, int y, int w, int h, |
837 | Orientation orient, bool tickAbove, | 837 | Orientation orient, bool tickAbove, |
838 | bool tickBelow ) | 838 | bool tickBelow ) |
839 | { | 839 | { |
840 | // This is odd. If we fill in the entire region it still masks the slider | 840 | // This is odd. If we fill in the entire region it still masks the slider |
841 | // properly. I have no idea, this used to be different in Qt betas... | 841 | // properly. I have no idea, this used to be different in Qt betas... |
842 | if ( isPixmap( Slider ) ) | 842 | if ( isPixmap( Slider ) ) |
843 | p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); | 843 | p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); |
844 | else | 844 | else |
845 | QWindowsStyle::drawSliderMask( p, x, y, w, h, orient, tickAbove, | 845 | QWindowsStyle::drawSliderMask( p, x, y, w, h, orient, tickAbove, |
846 | tickBelow ); | 846 | tickBelow ); |
847 | } | 847 | } |
848 | 848 | ||
849 | int OThemeStyle::defaultFrameWidth() const | 849 | int OThemeStyle::defaultFrameWidth() const |
850 | { | 850 | { |
851 | return ( frameWidth() ); | 851 | return ( frameWidth() ); |
852 | } | 852 | } |
853 | 853 | ||
854 | void OThemeStyle::getButtonShift( int &x, int &y ) | 854 | void OThemeStyle::getButtonShift( int &x, int &y ) |
855 | { | 855 | { |
856 | x = buttonXShift(); | 856 | x = buttonXShift(); |
857 | y = buttonYShift(); | 857 | y = buttonYShift(); |
858 | } | 858 | } |
859 | 859 | ||
860 | int OThemeStyle::sliderLength() const | 860 | int OThemeStyle::sliderLength() const |
861 | { | 861 | { |
862 | return ( sliderButtonLength() ); | 862 | return ( sliderButtonLength() ); |
863 | } | 863 | } |
864 | 864 | ||
865 | void OThemeStyle::drawArrow( QPainter *p, Qt::ArrowType type, bool down, int x, | 865 | void OThemeStyle::drawArrow( QPainter *p, Qt::ArrowType type, bool down, int x, |
866 | int y, int w, int h, const QColorGroup &g, | 866 | int y, int w, int h, const QColorGroup &g, |
867 | bool enabled, const QBrush * ) | 867 | bool enabled, const QBrush * ) |
868 | { | 868 | { |
869 | // Handles pixmapped arrows. A little inefficent because you can specify | 869 | // Handles pixmapped arrows. A little inefficent because you can specify |
870 | // some as pixmaps and some as default types. | 870 | // some as pixmaps and some as default types. |
871 | WidgetType widget; | 871 | WidgetType widget; |
872 | switch ( type ) { | 872 | switch ( type ) { |
873 | case UpArrow: | 873 | case UpArrow: |
874 | widget = enabled ? down ? SunkenArrowUp : ArrowUp : DisArrowUp; | 874 | widget = enabled ? down ? SunkenArrowUp : ArrowUp : DisArrowUp; |
875 | break; | 875 | break; |
876 | case DownArrow: | 876 | case DownArrow: |
877 | widget = enabled ? down ? SunkenArrowDown : ArrowDown : DisArrowDown; | 877 | widget = enabled ? down ? SunkenArrowDown : ArrowDown : DisArrowDown; |
878 | break; | 878 | break; |
879 | case LeftArrow: | 879 | case LeftArrow: |
880 | widget = enabled ? down ? SunkenArrowLeft : ArrowLeft : DisArrowLeft; | 880 | widget = enabled ? down ? SunkenArrowLeft : ArrowLeft : DisArrowLeft; |
881 | break; | 881 | break; |
882 | case RightArrow: | 882 | case RightArrow: |
883 | default: | 883 | default: |
884 | widget = enabled ? down ? SunkenArrowRight : ArrowRight : DisArrowRight; | 884 | widget = enabled ? down ? SunkenArrowRight : ArrowRight : DisArrowRight; |
885 | break; | 885 | break; |
886 | } | 886 | } |
887 | if ( isPixmap( widget ) ) { | 887 | if ( isPixmap( widget ) ) { |
888 | p->drawPixmap( x + ( w - uncached( widget ) ->width() ) / 2, | 888 | p->drawPixmap( x + ( w - uncached( widget ) ->width() ) / 2, |
889 | y + ( h - uncached( widget ) ->height() ) / 2, | 889 | y + ( h - uncached( widget ) ->height() ) / 2, |
890 | *uncached( widget ) ); | 890 | *uncached( widget ) ); |
891 | return ; | 891 | return ; |
892 | } | 892 | } |
893 | const QColorGroup *cg = colorGroup( g, widget ); | 893 | const QColorGroup *cg = colorGroup( g, widget ); |
894 | // Standard arrow types | 894 | // Standard arrow types |
895 | if ( arrowType() == MotifArrow ) | 895 | if ( arrowType() == MotifArrow ) |
896 | qDrawArrow( p, type, Qt::MotifStyle, down, x, y, w, h, *cg, enabled ); | 896 | qDrawArrow( p, type, Qt::MotifStyle, down, x, y, w, h, *cg, enabled ); |
897 | else if ( arrowType() == SmallArrow ) { | 897 | else if ( arrowType() == SmallArrow ) { |
898 | QColorGroup tmp( *cg ); | 898 | QColorGroup tmp( *cg ); |
899 | tmp.setBrush( QColorGroup::Button, QBrush( NoBrush ) ); | 899 | tmp.setBrush( QColorGroup::Button, QBrush( NoBrush ) ); |
900 | QWindowsStyle::drawArrow( p, type, false, x, y, w, h, | 900 | QWindowsStyle::drawArrow( p, type, false, x, y, w, h, |
901 | tmp, true ); | 901 | tmp, true ); |
902 | } | 902 | } |
903 | else { | 903 | else { |
904 | QPointArray a; | 904 | QPointArray a; |
905 | int x2 = x + w - 1, y2 = y + h - 1; | 905 | int x2 = x + w - 1, y2 = y + h - 1; |
906 | switch ( type ) { | 906 | switch ( type ) { |
907 | case Qt::UpArrow: | 907 | case Qt::UpArrow: |
908 | a.setPoints( 4, x, y2, x2, y2, x + w / 2, y, x, y2 ); | 908 | a.setPoints( 4, x, y2, x2, y2, x + w / 2, y, x, y2 ); |
909 | break; | 909 | break; |
910 | case Qt::DownArrow: | 910 | case Qt::DownArrow: |
911 | a.setPoints( 4, x, y, x2, y, x + w / 2, y2, x, y ); | 911 | a.setPoints( 4, x, y, x2, y, x + w / 2, y2, x, y ); |
912 | break; | 912 | break; |
913 | case Qt::LeftArrow: | 913 | case Qt::LeftArrow: |
914 | a.setPoints( 4, x2, y, x2, y2, x, y + h / 2, x2, y ); | 914 | a.setPoints( 4, x2, y, x2, y2, x, y + h / 2, x2, y ); |
915 | break; | 915 | break; |
916 | default: | 916 | default: |
917 | a.setPoints( 4, x, y, x, y2, x2, y + h / 2, x, y ); | 917 | a.setPoints( 4, x, y, x, y2, x2, y + h / 2, x, y ); |
918 | break; | 918 | break; |
919 | } | 919 | } |
920 | QBrush oldBrush = p->brush(); | 920 | QBrush oldBrush = p->brush(); |
921 | QPen oldPen = p->pen(); | 921 | QPen oldPen = p->pen(); |
922 | p->setBrush( cg->brush( QColorGroup::Shadow ) ); | 922 | p->setBrush( cg->brush( QColorGroup::Shadow ) ); |
923 | p->setPen( cg->shadow() ); | 923 | p->setPen( cg->shadow() ); |
924 | p->drawPolygon( a ); | 924 | p->drawPolygon( a ); |
925 | p->setBrush( oldBrush ); | 925 | p->setBrush( oldBrush ); |
926 | p->setPen( oldPen ); | 926 | p->setPen( oldPen ); |
927 | } | 927 | } |
928 | } | 928 | } |
929 | 929 | ||
930 | /* This is where we draw the borders and highlights. The new round button | 930 | /* This is where we draw the borders and highlights. The new round button |
931 | * code is a pain in the arse. We don't want to be calculating arcs so | 931 | * code is a pain in the arse. We don't want to be calculating arcs so |
932 | * use a whole lotta QPointArray's ;-) The code is made a lot more complex | 932 | * use a whole lotta QPointArray's ;-) The code is made a lot more complex |
933 | * because you can have variable width border and highlights... | 933 | * because you can have variable width border and highlights... |
934 | * I may want to cache this if round buttons are used, but am concerned | 934 | * I may want to cache this if round buttons are used, but am concerned |
935 | * about excessive cache misses. This is a memory/speed tradeoff that I | 935 | * about excessive cache misses. This is a memory/speed tradeoff that I |
936 | * have to test. | 936 | * have to test. |
937 | */ | 937 | */ |
938 | void OThemeStyle::drawShade( QPainter *p, int x, int y, int w, int h, | 938 | void OThemeStyle::drawShade( QPainter *p, int x, int y, int w, int h, |
939 | const QColorGroup &g, bool sunken, bool rounded, | 939 | const QColorGroup &g, bool sunken, bool rounded, |
940 | int hWidth, int bWidth, ShadeStyle style ) | 940 | int hWidth, int bWidth, ShadeStyle style ) |
941 | { | 941 | { |
942 | int i, sc, bc, x2, y2; | 942 | int i, sc, bc, x2, y2; |
943 | QPen highPen, lowPen; | 943 | QPen highPen, lowPen; |
944 | 944 | ||
945 | if ( style == Motif ) { | 945 | if ( style == Motif ) { |
946 | highPen.setColor( sunken ? g.dark() : g.light() ); | 946 | highPen.setColor( sunken ? g.dark() : g.light() ); |
947 | lowPen.setColor( sunken ? g.light() : g.dark() ); | 947 | lowPen.setColor( sunken ? g.light() : g.dark() ); |
948 | } | 948 | } |
949 | else { | 949 | else { |
950 | highPen.setColor( sunken ? g.shadow() : g.light() ); | 950 | highPen.setColor( sunken ? g.shadow() : g.light() ); |
951 | lowPen.setColor( sunken ? g.light() : g.shadow() ); | 951 | lowPen.setColor( sunken ? g.light() : g.shadow() ); |
952 | } | 952 | } |
953 | 953 | ||
954 | // Advanced round buttons | 954 | // Advanced round buttons |
955 | if ( rounded && w > 19 && h > 19 ) { | 955 | if ( rounded && w > 19 && h > 19 ) { |
956 | x2 = x + w - 1, y2 = y + h - 1; | 956 | x2 = x + w - 1, y2 = y + h - 1; |
957 | QPointArray bPntArray, hPntArray, lPntArray; | 957 | QPointArray bPntArray, hPntArray, lPntArray; |
958 | QPointArray bLineArray, hLineArray, lLineArray; | 958 | QPointArray bLineArray, hLineArray, lLineArray; |
959 | // borders | 959 | // borders |
960 | for ( i = 0, bc = 0; i < bWidth; ++i ) { | 960 | for ( i = 0, bc = 0; i < bWidth; ++i ) { |
961 | bPntArray.putPoints( bc, 24, x + 4, y + 1, x + 5, y + 1, x + 3, y + 2, x + 2, y + 3, | 961 | bPntArray.putPoints( bc, 24, x + 4, y + 1, x + 5, y + 1, x + 3, y + 2, x + 2, y + 3, |
962 | x + 1, y + 4, x + 1, y + 5, x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, | 962 | x + 1, y + 4, x + 1, y + 5, x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, |
963 | x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2, x2 - 5, y2 - 1, | 963 | x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2, x2 - 5, y2 - 1, |
964 | x2 - 4, y2 - 1, x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, | 964 | x2 - 4, y2 - 1, x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, |
965 | x2 - 1, y2 - 4, x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, | 965 | x2 - 1, y2 - 4, x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, |
966 | x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 ); | 966 | x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 ); |
967 | bc += 24; | 967 | bc += 24; |
968 | // ellispe edges don't match exactly, so fill in blanks | 968 | // ellispe edges don't match exactly, so fill in blanks |
969 | if ( i < bWidth - 1 || hWidth != 0 ) { | 969 | if ( i < bWidth - 1 || hWidth != 0 ) { |
970 | bPntArray.putPoints( bc, 20, x + 6, y + 1, x + 4, y + 2, x + 3, y + 3, | 970 | bPntArray.putPoints( bc, 20, x + 6, y + 1, x + 4, y + 2, x + 3, y + 3, |
971 | x + 2, y + 4, x + 1, y + 6, x2 - 6, y + 1, x2 - 4, y + 2, | 971 | x + 2, y + 4, x + 1, y + 6, x2 - 6, y + 1, x2 - 4, y + 2, |
972 | x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6, x2 - 6, y2 - 1, | 972 | x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6, x2 - 6, y2 - 1, |
973 | x2 - 4, y2 - 2, x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6, | 973 | x2 - 4, y2 - 2, x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6, |
974 | x + 6, y2 - 1, x + 4, y2 - 2, x + 3, y2 - 3, x2 - 1, y + 6, | 974 | x + 6, y2 - 1, x + 4, y2 - 2, x + 3, y2 - 3, x2 - 1, y + 6, |
975 | x2 - 2, y + 4 ); | 975 | x2 - 2, y + 4 ); |
976 | bc += 20; | 976 | bc += 20; |
977 | } | 977 | } |
978 | bLineArray.putPoints( i * 8, 8, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6, | 978 | bLineArray.putPoints( i * 8, 8, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6, |
979 | x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 ); | 979 | x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 ); |
980 | ++x, ++y; | 980 | ++x, ++y; |
981 | --x2, --y2; | 981 | --x2, --y2; |
982 | } | 982 | } |
983 | // highlights | 983 | // highlights |
984 | for ( i = 0, sc = 0; i < hWidth; ++i ) { | 984 | for ( i = 0, sc = 0; i < hWidth; ++i ) { |
985 | hPntArray.putPoints( sc, 12, x + 4, y + 1, x + 5, y + 1, // top left | 985 | hPntArray.putPoints( sc, 12, x + 4, y + 1, x + 5, y + 1, // top left |
986 | x + 3, y + 2, x + 2, y + 3, x + 1, y + 4, x + 1, y + 5, | 986 | x + 3, y + 2, x + 2, y + 3, x + 1, y + 4, x + 1, y + 5, |
987 | x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, // half corners | 987 | x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, // half corners |
988 | x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2 ); | 988 | x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2 ); |
989 | lPntArray.putPoints( sc, 12, x2 - 5, y2 - 1, x2 - 4, y2 - 1, // btm right | 989 | lPntArray.putPoints( sc, 12, x2 - 5, y2 - 1, x2 - 4, y2 - 1, // btm right |
990 | x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, x2 - 1, y2 - 4, | 990 | x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, x2 - 1, y2 - 4, |
991 | x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, //half corners | 991 | x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, //half corners |
992 | x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 ); | 992 | x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 ); |
993 | sc += 12; | 993 | sc += 12; |
994 | if ( i < hWidth - 1 ) { | 994 | if ( i < hWidth - 1 ) { |
995 | hPntArray.putPoints( sc, 10, x + 6, y + 1, x + 4, y + 2, // top left | 995 | hPntArray.putPoints( sc, 10, x + 6, y + 1, x + 4, y + 2, // top left |
996 | x + 3, y + 3, x + 2, y + 4, x + 1, y + 6, | 996 | x + 3, y + 3, x + 2, y + 4, x + 1, y + 6, |
997 | x2 - 6, y + 1, x2 - 4, y + 2, // half corners | 997 | x2 - 6, y + 1, x2 - 4, y + 2, // half corners |
998 | x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6 ); | 998 | x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6 ); |
999 | lPntArray.putPoints( sc, 10, x2 - 6, y2 - 1, x2 - 4, y2 - 2, // btm right | 999 | lPntArray.putPoints( sc, 10, x2 - 6, y2 - 1, x2 - 4, y2 - 2, // btm right |
1000 | x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6, | 1000 | x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6, |
1001 | x + 6, y2 - 1, x + 4, y2 - 2, // half corners | 1001 | x + 6, y2 - 1, x + 4, y2 - 2, // half corners |
1002 | x + 3, y2 - 3, x2 - 1, y + 6, x2 - 2, y + 4 ); | 1002 | x + 3, y2 - 3, x2 - 1, y + 6, x2 - 2, y + 4 ); |
1003 | sc += 10; | 1003 | sc += 10; |
1004 | } | 1004 | } |
1005 | hLineArray.putPoints( i * 4, 4, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6 ); | 1005 | hLineArray.putPoints( i * 4, 4, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6 ); |
1006 | lLineArray.putPoints( i * 4, 4, x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 ); | 1006 | lLineArray.putPoints( i * 4, 4, x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 ); |
1007 | ++x, ++y; | 1007 | ++x, ++y; |
1008 | --x2, --y2; | 1008 | --x2, --y2; |
1009 | } | 1009 | } |
1010 | p->setPen( Qt::black ); | 1010 | p->setPen( Qt::black ); |
1011 | p->drawPoints( bPntArray ); | 1011 | p->drawPoints( bPntArray ); |
1012 | p->drawLineSegments( bLineArray ); | 1012 | p->drawLineSegments( bLineArray ); |
1013 | p->setPen( highPen ); | 1013 | p->setPen( highPen ); |
1014 | p->drawPoints( hPntArray ); | 1014 | p->drawPoints( hPntArray ); |
1015 | p->drawLineSegments( hLineArray ); | 1015 | p->drawLineSegments( hLineArray ); |
1016 | p->setPen( lowPen ); | 1016 | p->setPen( lowPen ); |
1017 | p->drawPoints( lPntArray ); | 1017 | p->drawPoints( lPntArray ); |
1018 | p->drawLineSegments( lLineArray ); | 1018 | p->drawLineSegments( lLineArray ); |
1019 | } | 1019 | } |
1020 | // Rectangular buttons | 1020 | // Rectangular buttons |
1021 | else { | 1021 | else { |
1022 | QPointArray highShade( hWidth * 4 ); | 1022 | QPointArray highShade( hWidth * 4 ); |
1023 | QPointArray lowShade( hWidth * 4 ); | 1023 | QPointArray lowShade( hWidth * 4 ); |
1024 | 1024 | ||
1025 | p->setPen( g.shadow() ); | 1025 | p->setPen( g.shadow() ); |
1026 | for ( i = 0; i < bWidth && w > 2 && h > 2; ++i, ++x, ++y, w -= 2, h -= 2 ) | 1026 | for ( i = 0; i < bWidth && w > 2 && h > 2; ++i, ++x, ++y, w -= 2, h -= 2 ) |
1027 | p->drawRect( x, y , w, h ); | 1027 | p->drawRect( x, y , w, h ); |
1028 | 1028 | ||
1029 | if ( !hWidth ) | 1029 | if ( !hWidth ) |
1030 | return ; | 1030 | return ; |
1031 | 1031 | ||
1032 | x2 = x + w - 1, y2 = y + h - 1; | 1032 | x2 = x + w - 1, y2 = y + h - 1; |
1033 | for ( i = 0; i < hWidth; ++i, ++x, ++y, --x2, --y2 ) { | 1033 | for ( i = 0; i < hWidth; ++i, ++x, ++y, --x2, --y2 ) { |
1034 | highShade.putPoints( i * 4, 4, x, y, x2, y, x, y, x, y2 ); | 1034 | highShade.putPoints( i * 4, 4, x, y, x2, y, x, y, x, y2 ); |
1035 | lowShade.putPoints( i * 4, 4, x, y2, x2, y2, x2, y, x2, y2 ); | 1035 | lowShade.putPoints( i * 4, 4, x, y2, x2, y2, x2, y, x2, y2 ); |
1036 | } | 1036 | } |
1037 | if ( style == Windows && hWidth > 1 ) { | 1037 | if ( style == Windows && hWidth > 1 ) { |
1038 | p->setPen( highPen ); | 1038 | p->setPen( highPen ); |
1039 | p->drawLineSegments( highShade, 0, 2 ); | 1039 | p->drawLineSegments( highShade, 0, 2 ); |
1040 | p->setPen( lowPen ); | 1040 | p->setPen( lowPen ); |
1041 | p->drawLineSegments( lowShade, 0, 2 ); | 1041 | p->drawLineSegments( lowShade, 0, 2 ); |
1042 | 1042 | ||
1043 | p->setPen( ( sunken ) ? g.dark() : g.mid() ); | 1043 | p->setPen( ( sunken ) ? g.dark() : g.mid() ); |
1044 | p->drawLineSegments( highShade, 4 ); | 1044 | p->drawLineSegments( highShade, 4 ); |
1045 | p->setPen( ( sunken ) ? g.mid() : g.dark() ); | 1045 | p->setPen( ( sunken ) ? g.mid() : g.dark() ); |
1046 | p->drawLineSegments( lowShade, 4 ); | 1046 | p->drawLineSegments( lowShade, 4 ); |
1047 | } | 1047 | } |
1048 | else { | 1048 | else { |
1049 | p->setPen( ( sunken ) ? g.dark() : g.light() ); | 1049 | p->setPen( ( sunken ) ? g.dark() : g.light() ); |
1050 | p->drawLineSegments( highShade ); | 1050 | p->drawLineSegments( highShade ); |
1051 | p->setPen( ( sunken ) ? g.light() : g.dark() ); | 1051 | p->setPen( ( sunken ) ? g.light() : g.dark() ); |
1052 | p->drawLineSegments( lowShade ); | 1052 | p->drawLineSegments( lowShade ); |
1053 | } | 1053 | } |
1054 | } | 1054 | } |
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) | 1057 | void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) |
1058 | { | 1058 | { |
1059 | WidgetType widget = btn->isDown() || btn->isOn() ? PushButtonDown : | 1059 | WidgetType widget = btn->isDown() || btn->isOn() ? PushButtonDown : |
1060 | PushButton; | 1060 | PushButton; |
1061 | const QColorGroup *cg = colorGroup( btn->colorGroup(), widget ); | 1061 | const QColorGroup *cg = colorGroup( btn->colorGroup(), widget ); |
1062 | int x, y, w, h; | 1062 | int x, y, w, h; |
1063 | 1063 | ||
1064 | QRect r = btn->rect(); | 1064 | QRect r = btn->rect(); |
1065 | r.rect( &x, &y, &w, &h ); | 1065 | r.rect( &x, &y, &w, &h ); |
1066 | x += decoWidth( widget ); | 1066 | x += decoWidth( widget ); |
1067 | y += decoWidth( widget ); | 1067 | y += decoWidth( widget ); |
1068 | w -= decoWidth( widget ) * 2; | 1068 | w -= decoWidth( widget ) * 2; |
1069 | h -= decoWidth( widget ) * 2; | 1069 | h -= decoWidth( widget ) * 2; |
1070 | bool act = btn->isOn() || btn->isDown(); | 1070 | bool act = btn->isOn() || btn->isDown(); |
1071 | 1071 | ||
1072 | // If this is a button with an associated popup menu, draw an arrow first | 1072 | // If this is a button with an associated popup menu, draw an arrow first |
1073 | if ( btn->popup() ) { | 1073 | if ( btn->popup() ) { |
1074 | int dx = menuButtonIndicatorWidth( btn->height() ); | 1074 | int dx = menuButtonIndicatorWidth( btn->height() ); |
1075 | 1075 | ||
1076 | QColorGroup g( btn->colorGroup() ); | 1076 | QColorGroup g( btn->colorGroup() ); |
1077 | int xx = x + w - dx - 4; | 1077 | int xx = x + w - dx - 4; |
1078 | int yy = y - 3; | 1078 | int yy = y - 3; |
1079 | int hh = h + 6; | 1079 | int hh = h + 6; |
1080 | 1080 | ||
1081 | if ( !act ) { | 1081 | if ( !act ) { |
1082 | p->setPen( g.light() ); | 1082 | p->setPen( g.light() ); |
1083 | p->drawLine( xx, yy + 3, xx, yy + hh - 4 ); | 1083 | p->drawLine( xx, yy + 3, xx, yy + hh - 4 ); |
1084 | } | 1084 | } |
1085 | else { | 1085 | else { |
1086 | p->setPen( g.button() ); | 1086 | p->setPen( g.button() ); |
1087 | p->drawLine( xx, yy + 4, xx, yy + hh - 4 ); | 1087 | p->drawLine( xx, yy + 4, xx, yy + hh - 4 ); |
1088 | } | 1088 | } |
1089 | drawArrow( p, DownArrow, FALSE, | 1089 | drawArrow( p, DownArrow, FALSE, |
1090 | x + w - dx - 2, y + 2, dx, h - 4, | 1090 | x + w - dx - 2, y + 2, dx, h - 4, |
1091 | btn->colorGroup(), | 1091 | btn->colorGroup(), |
1092 | btn->isEnabled() ); | 1092 | btn->isEnabled() ); |
1093 | w -= dx; | 1093 | w -= dx; |
1094 | } | 1094 | } |
1095 | 1095 | ||
1096 | // Next, draw iconset, if any | 1096 | // Next, draw iconset, if any |
1097 | if ( btn->iconSet() && !btn->iconSet() ->isNull() ) { | 1097 | if ( btn->iconSet() && !btn->iconSet() ->isNull() ) { |
1098 | QIconSet::Mode mode = btn->isEnabled() | 1098 | QIconSet::Mode mode = btn->isEnabled() |
1099 | ? QIconSet::Normal : QIconSet::Disabled; | 1099 | ? QIconSet::Normal : QIconSet::Disabled; |
1100 | if ( mode == QIconSet::Normal && btn->hasFocus() ) | 1100 | if ( mode == QIconSet::Normal && btn->hasFocus() ) |
1101 | mode = QIconSet::Active; | 1101 | mode = QIconSet::Active; |
1102 | QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Small, mode ); | 1102 | QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Small, mode ); |
1103 | int pixw = pixmap.width(); | 1103 | int pixw = pixmap.width(); |
1104 | int pixh = pixmap.height(); | 1104 | int pixh = pixmap.height(); |
1105 | 1105 | ||
1106 | p->drawPixmap( x + 6, y + h / 2 - pixh / 2, pixmap ); | 1106 | p->drawPixmap( x + 6, y + h / 2 - pixh / 2, pixmap ); |
1107 | x += pixw + 8; | 1107 | x += pixw + 8; |
1108 | w -= pixw + 8; | 1108 | w -= pixw + 8; |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | if ( widget == PushButtonDown ) { | 1111 | if ( widget == PushButtonDown ) { |
1112 | drawItem( p, x + buttonXShift(), y + buttonYShift(), | 1112 | drawItem( p, x + buttonXShift(), y + buttonYShift(), |
1113 | w, h, AlignCenter | ShowPrefix, *cg, btn->isEnabled(), | 1113 | w, h, AlignCenter | ShowPrefix, *cg, btn->isEnabled(), |
1114 | btn->pixmap(), btn->text(), -1, &cg->buttonText() ); | 1114 | btn->pixmap(), btn->text(), -1, &cg->buttonText() ); |
1115 | } | 1115 | } |
1116 | else { | 1116 | else { |
1117 | drawItem( p, x, y, w, h, AlignCenter | ShowPrefix, *cg, | 1117 | drawItem( p, x, y, w, h, AlignCenter | ShowPrefix, *cg, |
1118 | btn->isEnabled(), btn->pixmap(), btn->text(), -1, | 1118 | btn->isEnabled(), btn->pixmap(), btn->text(), -1, |
1119 | &cg->buttonText() ); | 1119 | &cg->buttonText() ); |
1120 | } | 1120 | } |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | int OThemeStyle::splitterWidth() const | 1123 | int OThemeStyle::splitterWidth() const |
1124 | { | 1124 | { |
1125 | return ( splitWidth() ); | 1125 | return ( splitWidth() ); |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | void OThemeStyle::drawSplitter( QPainter *p, int x, int y, int w, int h, | 1128 | void OThemeStyle::drawSplitter( QPainter *p, int x, int y, int w, int h, |
1129 | const QColorGroup &g, Orientation ) | 1129 | const QColorGroup &g, Orientation ) |
1130 | { | 1130 | { |
1131 | drawBaseButton( p, x, y, w, h, *colorGroup( g, Splitter ), false, false, | 1131 | drawBaseButton( p, x, y, w, h, *colorGroup( g, Splitter ), false, false, |
1132 | Splitter ); | 1132 | Splitter ); |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | void OThemeStyle::drawCheckMark( QPainter *p, int x, int y, int w, int h, | 1135 | void OThemeStyle::drawCheckMark( QPainter *p, int x, int y, int w, int h, |
1136 | const QColorGroup &g, bool act, bool dis ) | 1136 | const QColorGroup &g, bool act, bool dis ) |
1137 | { | 1137 | { |
1138 | if ( isPixmap( CheckMark ) ) { | 1138 | if ( isPixmap( CheckMark ) ) { |
1139 | if ( !dis ) | 1139 | if ( !dis ) |
1140 | p->drawPixmap( x + ( w - uncached( CheckMark ) ->width() ) / 2, | 1140 | p->drawPixmap( x + ( w - uncached( CheckMark ) ->width() ) / 2, |
1141 | y + ( h - uncached( CheckMark ) ->height() ) / 2, | 1141 | y + ( h - uncached( CheckMark ) ->height() ) / 2, |
1142 | *uncached( CheckMark ) ); | 1142 | *uncached( CheckMark ) ); |
1143 | } | 1143 | } |
1144 | else | 1144 | else |
1145 | QWindowsStyle::drawCheckMark( p, x, y, w, h, *colorGroup( g, CheckMark ), | 1145 | QWindowsStyle::drawCheckMark( p, x, y, w, h, *colorGroup( g, CheckMark ), |
1146 | act, dis ); | 1146 | act, dis ); |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi, | 1149 | int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi, |
1150 | const QFontMetrics &fm ) | 1150 | const QFontMetrics &fm ) |
1151 | { | 1151 | { |
1152 | int h2, h = 0; | 1152 | int h2, h = 0; |
1153 | int offset = QMAX( decoWidth( MenuItemDown ), decoWidth( MenuItem ) ) + 4; | 1153 | int offset = QMAX( decoWidth( MenuItemDown ), decoWidth( MenuItem ) ) + 4; |
1154 | 1154 | ||
1155 | if ( mi->isSeparator() ) | 1155 | if ( mi->isSeparator() ) |
1156 | return ( 2 ); | 1156 | return ( 2 ); |
1157 | if ( mi->isChecked() ) | 1157 | if ( mi->isChecked() ) |
1158 | h = isPixmap( CheckMark ) ? uncached( CheckMark ) ->height() + offset : | 1158 | h = isPixmap( CheckMark ) ? uncached( CheckMark ) ->height() + offset : |
1159 | offset + 16; | 1159 | offset + 16; |
1160 | if ( mi->pixmap() ) { | 1160 | if ( mi->pixmap() ) { |
1161 | h2 = mi->pixmap() ->height() + offset; | 1161 | h2 = mi->pixmap() ->height() + offset; |
1162 | h = h2 > h ? h2 : h; | 1162 | h = h2 > h ? h2 : h; |
1163 | } | 1163 | } |
1164 | if ( mi->iconSet() ) { | 1164 | if ( mi->iconSet() ) { |
1165 | h2 = mi->iconSet() -> | 1165 | h2 = mi->iconSet() -> |
1166 | pixmap( QIconSet::Small, QIconSet::Normal ).height() + offset; | 1166 | pixmap( QIconSet::Small, QIconSet::Normal ).height() + offset; |
1167 | h = h2 > h ? h2 : h; | 1167 | h = h2 > h ? h2 : h; |
1168 | } | 1168 | } |
1169 | h2 = fm.height() + offset; | 1169 | h2 = fm.height() + offset; |
1170 | h = h2 > h ? h2 : h; | 1170 | h = h2 > h ? h2 : h; |
1171 | return ( h ); | 1171 | return ( h ); |
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, | 1174 | void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, |
1175 | int tab, QMenuItem* mi, | 1175 | int tab, QMenuItem* mi, |
1176 | const QPalette& pal, bool act, | 1176 | const QPalette& pal, bool act, |
1177 | bool enabled, int x, int y, int w, int h ) | 1177 | bool enabled, int x, int y, int w, int h ) |
1178 | { | 1178 | { |
1179 | // I changed the following method to be based from Qt's instead of my own | 1179 | // I changed the following method to be based from Qt's instead of my own |
1180 | // wacky code. Works much better now :P (mosfet) | 1180 | // wacky code. Works much better now :P (mosfet) |
1181 | static const int motifItemFrame = 2; // menu item frame width | 1181 | static const int motifItemFrame = 2; // menu item frame width |
1182 | static const int motifItemHMargin = 5; // menu item hor text margin | 1182 | static const int motifItemHMargin = 5; // menu item hor text margin |
1183 | static const int motifItemVMargin = 4; // menu item ver text margin | 1183 | static const int motifItemVMargin = 4; // menu item ver text margin |
1184 | 1184 | ||
1185 | static const int motifArrowHMargin = 6; // arrow horizontal margin | 1185 | static const int motifArrowHMargin = 6; // arrow horizontal margin |
1186 | static const int windowsRightBorder = 12; // right border on windowsstatic const int windowsCheckMarkWidth = 12; // checkmarks width on windows | 1186 | static const int windowsRightBorder = 12; // right border on windowsstatic const int windowsCheckMarkWidth = 12; // checkmarks width on windows |
1187 | bool dis = !enabled; | 1187 | bool dis = !enabled; |
1188 | const QColorGroup &g = dis ? *colorGroup( pal.normal(), MenuItem ) : | 1188 | const QColorGroup &g = dis ? *colorGroup( pal.normal(), MenuItem ) : |
1189 | *colorGroup( pal.normal(), MenuItemDown ); | 1189 | *colorGroup( pal.normal(), MenuItemDown ); |
1190 | 1190 | ||
1191 | QColorGroup itemg = dis ? *colorGroup( pal.disabled(), MenuItem ) | 1191 | QColorGroup itemg = dis ? *colorGroup( pal.disabled(), MenuItem ) |
1192 | : act ? *colorGroup( pal.active(), MenuItemDown ) | 1192 | : act ? *colorGroup( pal.active(), MenuItemDown ) |
1193 | : *colorGroup( pal.normal(), MenuItem ); | 1193 | : *colorGroup( pal.normal(), MenuItem ); |
1194 | 1194 | ||
1195 | maxpmw = QMAX( maxpmw, 20 ); | 1195 | maxpmw = QMAX( maxpmw, 20 ); |
1196 | int checkcol = maxpmw; | 1196 | int checkcol = maxpmw; |
1197 | 1197 | ||
1198 | if ( mi && mi->isSeparator() ) { | 1198 | if ( mi && mi->isSeparator() ) { |
1199 | p->setPen( g.dark() ); | 1199 | p->setPen( g.dark() ); |
1200 | p->drawLine( x, y, x + w, y ); | 1200 | p->drawLine( x, y, x + w, y ); |
1201 | p->setPen( g.light() ); | 1201 | p->setPen( g.light() ); |
1202 | p->drawLine( x, y + 1, x + w, y + 1 ); | 1202 | p->drawLine( x, y + 1, x + w, y + 1 ); |
1203 | return ; | 1203 | return ; |
1204 | } | 1204 | } |
1205 | if ( act ) { | 1205 | if ( act ) { |
1206 | drawBaseButton( p, x, y, w, h, g, true, false, MenuItemDown ); | 1206 | drawBaseButton( p, x, y, w, h, g, true, false, MenuItemDown ); |
1207 | } | 1207 | } |
1208 | else { | 1208 | else { |
1209 | drawShade( p, x, y, w, h, *colorGroup( g, MenuItem ), false, false, | 1209 | drawShade( p, x, y, w, h, *colorGroup( g, MenuItem ), false, false, |
1210 | highlightWidth( MenuItem ), borderWidth( MenuItem ), | 1210 | highlightWidth( MenuItem ), borderWidth( MenuItem ), |
1211 | shade() ); | 1211 | shade() ); |
1212 | int dw = decoWidth( MenuItem ); | 1212 | int dw = decoWidth( MenuItem ); |
1213 | if ( !isPixmap( MenuItem ) ) | 1213 | if ( !isPixmap( MenuItem ) ) { |
1214 | p->fillRect( x + dw, y + dw, w - dw * 2, h - dw * 2, | 1214 | p->fillRect( x + dw, y + dw, w - dw * 2, h - dw * 2, |
1215 | colorGroup( g, MenuItem ) -> | 1215 | colorGroup( g, MenuItem ) -> |
1216 | brush( QColorGroup::Background ) ); | 1216 | brush( QColorGroup::Background ) ); |
1217 | } | ||
1217 | else { | 1218 | else { |
1218 | // process inactive item pixmaps as one large item | 1219 | // process inactive item pixmaps as one large item |
1219 | p->drawTiledPixmap( x + dw, y + dw, w - dw * 2, h - dw * 2, *scalePixmap | 1220 | p->drawTiledPixmap( x + dw, y + dw, w - dw * 2, h - dw * 2, *scalePixmap |
1220 | // (w, p->window().height(), MenuItem), | 1221 | (w, ((QWidget *)p->device())->height(), MenuItem), |
1221 | ( w, p->clipRegion().boundingRect().height(), MenuItem ), | 1222 | //( w, p->clipRegion().boundingRect().height(), MenuItem ), // cliping does not work in Qt/E |
1222 | x, y ); | 1223 | x, y ); |
1223 | } | 1224 | } |
1224 | 1225 | ||
1225 | if ( checkable && mi && mi->isChecked() ) { | 1226 | if ( checkable && mi && mi->isChecked() ) { |
1226 | // draw 'pressed' border around checkable items | 1227 | // draw 'pressed' border around checkable items |
1227 | // This is extremely important for items that have an iconset | 1228 | // This is extremely important for items that have an iconset |
1228 | // because the checkmark isn't drawn in that case | 1229 | // because the checkmark isn't drawn in that case |
1229 | // An alternative would be superimposing the checkmark over | 1230 | // An alternative would be superimposing the checkmark over |
1230 | // the iconset instead or not drawing the iconset at all. | 1231 | // the iconset instead or not drawing the iconset at all. |
1231 | int mw = checkcol + motifItemFrame; | 1232 | int mw = checkcol + motifItemFrame; |
1232 | drawShade( p, x, y, mw, h, g, true, false, | 1233 | drawShade( p, x, y, mw, h, g, true, false, |
1233 | highlightWidth( MenuItemDown ), | 1234 | highlightWidth( MenuItemDown ), |
1234 | borderWidth( MenuItemDown ), shade() ); | 1235 | borderWidth( MenuItemDown ), shade() ); |
1235 | } | 1236 | } |
1236 | } | 1237 | } |
1237 | if ( !mi ) | 1238 | if ( !mi ) |
1238 | return ; | 1239 | return ; |
1239 | if ( mi->iconSet() ) { | 1240 | if ( mi->iconSet() ) { |
1240 | QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; | 1241 | QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; |
1241 | if ( act && !dis ) | 1242 | if ( act && !dis ) |
1242 | mode = QIconSet::Active; | 1243 | mode = QIconSet::Active; |
1243 | QPixmap pixmap = mi->iconSet() ->pixmap( QIconSet::Small, mode ); | 1244 | QPixmap pixmap = mi->iconSet() ->pixmap( QIconSet::Small, mode ); |
1244 | int pixw = pixmap.width(); | 1245 | int pixw = pixmap.width(); |
1245 | int pixh = pixmap.height(); | 1246 | int pixh = pixmap.height(); |
1246 | QRect cr( x, y, checkcol, h ); | 1247 | QRect cr( x, y, checkcol, h ); |
1247 | QRect pmr( 0, 0, pixw, pixh ); | 1248 | QRect pmr( 0, 0, pixw, pixh ); |
1248 | pmr.moveCenter( cr.center() ); | 1249 | pmr.moveCenter( cr.center() ); |
1249 | p->setPen( itemg.text() ); | 1250 | p->setPen( itemg.text() ); |
1250 | p->drawPixmap( pmr.topLeft(), pixmap ); | 1251 | p->drawPixmap( pmr.topLeft(), pixmap ); |
1251 | 1252 | ||
1252 | } | 1253 | } |
1253 | else if ( checkable ) { | 1254 | else if ( checkable ) { |
1254 | int mw = checkcol + motifItemFrame; | 1255 | int mw = checkcol + motifItemFrame; |
1255 | int mh = h - 2 * motifItemFrame; | 1256 | int mh = h - 2 * motifItemFrame; |
1256 | if ( mi->isChecked() ) { | 1257 | if ( mi->isChecked() ) { |
1257 | drawCheckMark( p, x + motifItemFrame, | 1258 | drawCheckMark( p, x + motifItemFrame, |
1258 | y + motifItemFrame, mw, mh, itemg, act, dis ); | 1259 | y + motifItemFrame, mw, mh, itemg, act, dis ); |
1259 | } | 1260 | } |
1260 | } | 1261 | } |
1261 | 1262 | ||
1262 | p->setPen( colorGroup( g, act ? MenuItemDown : MenuItem ) ->text() ); | 1263 | p->setPen( colorGroup( g, act ? MenuItemDown : MenuItem ) ->text() ); |
1263 | 1264 | ||
1264 | QColor discol; | 1265 | QColor discol; |
1265 | if ( dis ) { | 1266 | if ( dis ) { |
1266 | discol = itemg.text(); | 1267 | discol = itemg.text(); |
1267 | p->setPen( discol ); | 1268 | p->setPen( discol ); |
1268 | } | 1269 | } |
1269 | 1270 | ||
1270 | int xm = motifItemFrame + checkcol + motifItemHMargin; | 1271 | int xm = motifItemFrame + checkcol + motifItemHMargin; |
1271 | 1272 | ||
1272 | QString s = mi->text(); | 1273 | QString s = mi->text(); |
1273 | if ( !s.isNull() ) { | 1274 | if ( !s.isNull() ) { |
1274 | int t = s.find( '\t' ); | 1275 | int t = s.find( '\t' ); |
1275 | int m = motifItemVMargin; | 1276 | int m = motifItemVMargin; |
1276 | const int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine; | 1277 | const int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine; |
1277 | if ( t >= 0 ) { | 1278 | if ( t >= 0 ) { |
1278 | if ( dis && !act ) { | 1279 | if ( dis && !act ) { |
1279 | p->setPen( g.light() ); | 1280 | p->setPen( g.light() ); |
1280 | p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame + 1, | 1281 | p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame + 1, |
1281 | y + m + 1, tab, h - 2 * m, text_flags, s.mid( t + 1 ) ); | 1282 | y + m + 1, tab, h - 2 * m, text_flags, s.mid( t + 1 ) ); |
1282 | p->setPen( discol ); | 1283 | p->setPen( discol ); |
1283 | } | 1284 | } |
1284 | p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame, | 1285 | p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame, |
1285 | y + m, tab, h - 2 * m, text_flags, s.mid( t + 1 ) ); | 1286 | y + m, tab, h - 2 * m, text_flags, s.mid( t + 1 ) ); |
1286 | } | 1287 | } |
1287 | if ( dis && !act ) { | 1288 | if ( dis && !act ) { |
1288 | p->setPen( g.light() ); | 1289 | p->setPen( g.light() ); |
1289 | p->drawText( x + xm + 1, y + m + 1, w - xm + 1, h - 2 * m, text_flags, s, t ); | 1290 | p->drawText( x + xm + 1, y + m + 1, w - xm + 1, h - 2 * m, text_flags, s, t ); |
1290 | p->setPen( discol ); | 1291 | p->setPen( discol ); |
1291 | } | 1292 | } |
1292 | p->drawText( x + xm, y + m, w - xm - tab + 1, h - 2 * m, text_flags, s, t ); | 1293 | p->drawText( x + xm, y + m, w - xm - tab + 1, h - 2 * m, text_flags, s, t ); |
1293 | } | 1294 | } |
1294 | else if ( mi->pixmap() ) { | 1295 | else if ( mi->pixmap() ) { |
1295 | QPixmap * pixmap = mi->pixmap(); | 1296 | QPixmap * pixmap = mi->pixmap(); |
1296 | if ( pixmap->depth() == 1 ) | 1297 | if ( pixmap->depth() == 1 ) |
1297 | p->setBackgroundMode( OpaqueMode ); | 1298 | p->setBackgroundMode( OpaqueMode ); |
1298 | p->drawPixmap( x + xm, y + motifItemFrame, *pixmap ); | 1299 | p->drawPixmap( x + xm, y + motifItemFrame, *pixmap ); |
1299 | if ( pixmap->depth() == 1 ) | 1300 | if ( pixmap->depth() == 1 ) |
1300 | p->setBackgroundMode( TransparentMode ); | 1301 | p->setBackgroundMode( TransparentMode ); |
1301 | } | 1302 | } |
1302 | if ( mi->popup() ) { | 1303 | if ( mi->popup() ) { |
1303 | int dim = ( h - 2 * motifItemFrame ) / 2; | 1304 | int dim = ( h - 2 * motifItemFrame ) / 2; |
1304 | if ( act ) { | 1305 | if ( act ) { |
1305 | if ( !dis ) | 1306 | if ( !dis ) |
1306 | discol = colorGroup( g, MenuItemDown ) ->text(); | 1307 | discol = colorGroup( g, MenuItemDown ) ->text(); |
1307 | //discol = white; | 1308 | //discol = white; |
1308 | QColorGroup g2( discol, g.highlight(), | 1309 | QColorGroup g2( discol, g.highlight(), |
1309 | white, white, | 1310 | white, white, |
1310 | dis ? discol : white, | 1311 | dis ? discol : white, |
1311 | discol, white ); | 1312 | discol, white ); |
1312 | drawArrow( p, RightArrow, true, | 1313 | drawArrow( p, RightArrow, true, |
1313 | x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, | 1314 | x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, |
1314 | dim, dim, g2, TRUE ); | 1315 | dim, dim, g2, TRUE ); |
1315 | } | 1316 | } |
1316 | else { | 1317 | else { |
1317 | drawArrow( p, RightArrow, | 1318 | drawArrow( p, RightArrow, |
1318 | false, | 1319 | false, |
1319 | x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, | 1320 | x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, |
1320 | dim, dim, g, mi->isEnabled() ); | 1321 | dim, dim, g, mi->isEnabled() ); |
1321 | } | 1322 | } |
1322 | } | 1323 | } |
1323 | } | 1324 | } |
1324 | 1325 | ||
1325 | void OThemeStyle::drawFocusRect( QPainter *p, const QRect &r, | 1326 | void OThemeStyle::drawFocusRect( QPainter *p, const QRect &r, |
1326 | const QColorGroup &g, const QColor *c, | 1327 | const QColorGroup &g, const QColor *c, |
1327 | bool atBorder ) | 1328 | bool atBorder ) |
1328 | { | 1329 | { |
1329 | p->setPen( g.dark() ); | 1330 | p->setPen( g.dark() ); |
1330 | if ( !is3DFocus() ) | 1331 | if ( !is3DFocus() ) |
1331 | QWindowsStyle::drawFocusRect( p, r, g, c, atBorder ); | 1332 | QWindowsStyle::drawFocusRect( p, r, g, c, atBorder ); |
1332 | else { | 1333 | else { |
1333 | int i = focusOffset(); | 1334 | int i = focusOffset(); |
1334 | p->drawLine( r.x() + i, r.y() + 1 + i, r.x() + i, r.bottom() - 1 - i ); | 1335 | p->drawLine( r.x() + i, r.y() + 1 + i, r.x() + i, r.bottom() - 1 - i ); |
1335 | p->drawLine( r.x() + 1 + i, r.y() + i, r.right() - 1 - i, r.y() + i ); | 1336 | p->drawLine( r.x() + 1 + i, r.y() + i, r.right() - 1 - i, r.y() + i ); |
1336 | p->setPen( g.light() ); | 1337 | p->setPen( g.light() ); |
1337 | p->drawLine( r.right() - i, r.y() + 1 + i, r.right() - i, r.bottom() - 1 - i ); | 1338 | p->drawLine( r.right() - i, r.y() + 1 + i, r.right() - i, r.bottom() - 1 - i ); |
1338 | p->drawLine( r.x() + 1 + i, r.bottom() - i, r.right() - 1 - i, r.bottom() - i ); | 1339 | p->drawLine( r.x() + 1 + i, r.bottom() - i, r.right() - 1 - i, r.bottom() - i ); |
1339 | } | 1340 | } |
1340 | } | 1341 | } |
1341 | 1342 | ||
1342 | #if 0 | 1343 | #if 0 |
1343 | void OThemeStyle::drawKMenuBar( QPainter *p, int x, int y, int w, int h, | 1344 | void OThemeStyle::drawKMenuBar( QPainter *p, int x, int y, int w, int h, |
1344 | const QColorGroup &g, bool, QBrush * ) | 1345 | const QColorGroup &g, bool, QBrush * ) |
1345 | { | 1346 | { |
1346 | drawBaseButton( p, x, y, w, h, *colorGroup( g, MenuBar ), false, false, | 1347 | drawBaseButton( p, x, y, w, h, *colorGroup( g, MenuBar ), false, false, |
1347 | MenuBar ); | 1348 | MenuBar ); |
1348 | } | 1349 | } |
1349 | 1350 | ||
1350 | void OThemeStyle::drawKMenuItem( QPainter *p, int x, int y, int w, int h, | 1351 | void OThemeStyle::drawKMenuItem( QPainter *p, int x, int y, int w, int h, |
1351 | const QColorGroup &g, bool active, | 1352 | const QColorGroup &g, bool active, |
1352 | QMenuItem *mi, QBrush * ) | 1353 | QMenuItem *mi, QBrush * ) |
1353 | { | 1354 | { |
1354 | const QColorGroup * cg = colorGroup( g, active ? MenuBarItem : MenuBar ); | 1355 | const QColorGroup * cg = colorGroup( g, active ? MenuBarItem : MenuBar ); |
1355 | QColor btext = cg->buttonText(); | 1356 | QColor btext = cg->buttonText(); |
1356 | if ( active ) | 1357 | if ( active ) |
1357 | drawBaseButton( p, x, y, w, h, *cg, false, false, MenuBarItem ); | 1358 | drawBaseButton( p, x, y, w, h, *cg, false, false, MenuBarItem ); |
1358 | //qDrawShadePanel(p, x, y, w, h, *cg, false, 1); | 1359 | //qDrawShadePanel(p, x, y, w, h, *cg, false, 1); |
1359 | 1360 | ||
1360 | drawItem( p, x, y, w, h, AlignCenter | ShowPrefix | DontClip | SingleLine, | 1361 | drawItem( p, x, y, w, h, AlignCenter | ShowPrefix | DontClip | SingleLine, |
1361 | *cg, mi->isEnabled(), mi->pixmap(), mi->text(), | 1362 | *cg, mi->isEnabled(), mi->pixmap(), mi->text(), |
1362 | -1, &btext ); | 1363 | -1, &btext ); |
1363 | ; | 1364 | ; |
1364 | } | 1365 | } |
1365 | 1366 | ||
1366 | void OThemeStyle::drawKProgressBlock( QPainter *p, int x, int y, int w, int h, | 1367 | void OThemeStyle::drawKProgressBlock( QPainter *p, int x, int y, int w, int h, |
1367 | const QColorGroup &g, QBrush * ) | 1368 | const QColorGroup &g, QBrush * ) |
1368 | { | 1369 | { |
1369 | drawBaseButton( p, x, y, w, h, *colorGroup( g, ProgressBar ), false, false, | 1370 | drawBaseButton( p, x, y, w, h, *colorGroup( g, ProgressBar ), false, false, |
1370 | ProgressBar ); | 1371 | ProgressBar ); |
1371 | } | 1372 | } |
1372 | 1373 | ||
1373 | void OThemeStyle::getKProgressBackground( const QColorGroup &g, QBrush &bg ) | 1374 | void OThemeStyle::getKProgressBackground( const QColorGroup &g, QBrush &bg ) |
1374 | { | 1375 | { |
1375 | const QColorGroup * cg = colorGroup( g, ProgressBg ); | 1376 | const QColorGroup * cg = colorGroup( g, ProgressBg ); |
1376 | bg.setColor( cg->color( QColorGroup::Background ) ); | 1377 | bg.setColor( cg->color( QColorGroup::Background ) ); |
1377 | if ( isPixmap( ProgressBg ) ) | 1378 | if ( isPixmap( ProgressBg ) ) |
1378 | bg.setPixmap( *uncached( ProgressBg ) ); | 1379 | bg.setPixmap( *uncached( ProgressBg ) ); |
1379 | } | 1380 | } |
1380 | #endif | 1381 | #endif |
1381 | 1382 | ||
1382 | void OThemeStyle::tabbarMetrics( const QTabBar* t, int& hframe, int& vframe, int& overlap ) | 1383 | void OThemeStyle::tabbarMetrics( const QTabBar* t, int& hframe, int& vframe, int& overlap ) |
1383 | { | 1384 | { |
1384 | QCommonStyle::tabbarMetrics( t, hframe, vframe, overlap ); | 1385 | QCommonStyle::tabbarMetrics( t, hframe, vframe, overlap ); |
1385 | } | 1386 | } |
1386 | 1387 | ||
1387 | void OThemeStyle::drawTab( QPainter* p, const QTabBar* tb, QTab* t , | 1388 | void OThemeStyle::drawTab( QPainter* p, const QTabBar* tb, QTab* t , |
1388 | bool selected ) | 1389 | bool selected ) |
1389 | { | 1390 | { |
1390 | WidgetType widget = selected ? ActiveTab : InactiveTab; | 1391 | WidgetType widget = selected ? ActiveTab : InactiveTab; |
1391 | const QColorGroup *cg = colorGroup( tb->colorGroup(), widget ); | 1392 | const QColorGroup *cg = colorGroup( tb->colorGroup(), widget ); |
1392 | int i; | 1393 | int i; |
1393 | int x = t->r.x(), y = t->r.y(); | 1394 | int x = t->r.x(), y = t->r.y(); |
1394 | int x2 = t->r.right(), y2 = t->r.bottom(); | 1395 | int x2 = t->r.right(), y2 = t->r.bottom(); |
1395 | int bWidth = borderWidth( widget ); | 1396 | int bWidth = borderWidth( widget ); |
1396 | int hWidth = highlightWidth( widget ); | 1397 | int hWidth = highlightWidth( widget ); |
1397 | if ( tb->shape() == QTabBar::RoundedAbove ) { | 1398 | if ( tb->shape() == QTabBar::RoundedAbove ) { |
1398 | if ( !selected ) { | 1399 | if ( !selected ) { |
1399 | p->fillRect( x, y, x2 - x + 1, 2, | 1400 | p->fillRect( x, y, x2 - x + 1, 2, |
1400 | tb->palette().normal().brush( QColorGroup::Background ) ); | 1401 | tb->palette().normal().brush( QColorGroup::Background ) ); |
1401 | y += 2; | 1402 | y += 2; |
1402 | } | 1403 | } |
1403 | p->setPen( cg->text() ); | 1404 | p->setPen( cg->text() ); |
1404 | i = 0; | 1405 | i = 0; |
1405 | if ( i < bWidth ) { | 1406 | if ( i < bWidth ) { |
1406 | p->drawLine( x, y + 1, x, y2 ); | 1407 | p->drawLine( x, y + 1, x, y2 ); |
1407 | p->drawLine( x2, y + 1, x2, y2 ); | 1408 | p->drawLine( x2, y + 1, x2, y2 ); |
1408 | p->drawLine( x + 1, y, x2 - 1, y ); | 1409 | p->drawLine( x + 1, y, x2 - 1, y ); |
1409 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1410 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1410 | p->drawLine( x, y2, x2, y2 ); | 1411 | p->drawLine( x, y2, x2, y2 ); |
1411 | --y2; | 1412 | --y2; |
1412 | } | 1413 | } |
1413 | ++i, ++x, ++y, --x2; | 1414 | ++i, ++x, ++y, --x2; |
1414 | } | 1415 | } |
1415 | for ( ; i < bWidth; ++i, ++x, ++y, --x2 ) { | 1416 | for ( ; i < bWidth; ++i, ++x, ++y, --x2 ) { |
1416 | p->drawLine( x, y, x, y2 ); | 1417 | p->drawLine( x, y, x, y2 ); |
1417 | p->drawLine( x2, y, x2, y2 ); | 1418 | p->drawLine( x2, y, x2, y2 ); |
1418 | p->drawLine( x, y, x2, y ); | 1419 | p->drawLine( x, y, x2, y ); |
1419 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1420 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1420 | p->drawLine( x, y2, x2, y2 ); | 1421 | p->drawLine( x, y2, x2, y2 ); |
1421 | --y2; | 1422 | --y2; |
1422 | } | 1423 | } |
1423 | } | 1424 | } |
1424 | i = 0; | 1425 | i = 0; |
1425 | if ( i < hWidth && bWidth == 0 ) { | 1426 | if ( i < hWidth && bWidth == 0 ) { |
1426 | p->setPen( cg->light() ); | 1427 | p->setPen( cg->light() ); |
1427 | p->drawLine( x, y + 1, x, y2 ); | 1428 | p->drawLine( x, y + 1, x, y2 ); |
1428 | p->drawLine( x + 1, y, x2 - 1, y ); | 1429 | p->drawLine( x + 1, y, x2 - 1, y ); |
1429 | p->setPen( cg->dark() ); | 1430 | p->setPen( cg->dark() ); |
1430 | p->drawLine( x2, y + 1, x2, y2 ); | 1431 | p->drawLine( x2, y + 1, x2, y2 ); |
1431 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1432 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1432 | p->drawLine( x, y2, x2, y2 ); | 1433 | p->drawLine( x, y2, x2, y2 ); |
1433 | --y2; | 1434 | --y2; |
1434 | } | 1435 | } |
1435 | ++i, ++x, ++y, --x2; | 1436 | ++i, ++x, ++y, --x2; |
1436 | } | 1437 | } |
1437 | for ( ; i < hWidth; ++i, ++x, ++y, --x2 ) { | 1438 | for ( ; i < hWidth; ++i, ++x, ++y, --x2 ) { |
1438 | p->setPen( cg->light() ); | 1439 | p->setPen( cg->light() ); |
1439 | p->drawLine( x, y, x, y2 ); | 1440 | p->drawLine( x, y, x, y2 ); |
1440 | p->drawLine( x, y, x2, y ); | 1441 | p->drawLine( x, y, x2, y ); |
1441 | p->setPen( cg->dark() ); | 1442 | p->setPen( cg->dark() ); |
1442 | p->drawLine( x2, y + 1, x2, y2 ); | 1443 | p->drawLine( x2, y + 1, x2, y2 ); |
1443 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1444 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1444 | p->drawLine( x, y2, x2, y2 ); | 1445 | p->drawLine( x, y2, x2, y2 ); |
1445 | --y2; | 1446 | --y2; |
1446 | } | 1447 | } |
1447 | } | 1448 | } |
1448 | if ( isPixmap( widget ) ) | 1449 | if ( isPixmap( widget ) ) |
1449 | p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1, | 1450 | p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1, |
1450 | *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) ); | 1451 | *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) ); |
1451 | else | 1452 | else |
1452 | p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() ); | 1453 | p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() ); |
1453 | } | 1454 | } |
1454 | else if ( tb->shape() == QTabBar::RoundedBelow ) { | 1455 | else if ( tb->shape() == QTabBar::RoundedBelow ) { |
1455 | if ( !selected ) { | 1456 | if ( !selected ) { |
1456 | p->fillRect( x, y2 - 2, x2 - x + 1, 2, | 1457 | p->fillRect( x, y2 - 2, x2 - x + 1, 2, |
1457 | tb->palette().normal().brush( QColorGroup::Background ) ); | 1458 | tb->palette().normal().brush( QColorGroup::Background ) ); |
1458 | y2 -= 2; | 1459 | y2 -= 2; |
1459 | } | 1460 | } |
1460 | p->setPen( cg->text() ); | 1461 | p->setPen( cg->text() ); |
1461 | i = 0; | 1462 | i = 0; |
1462 | if ( i < bWidth ) { | 1463 | if ( i < bWidth ) { |
1463 | p->drawLine( x, y, x, y2 - 1 ); | 1464 | p->drawLine( x, y, x, y2 - 1 ); |
1464 | p->drawLine( x2, y, x2, y2 - 1 ); | 1465 | p->drawLine( x2, y, x2, y2 - 1 ); |
1465 | p->drawLine( x + 1, y2, x2 - 1, y2 ); | 1466 | p->drawLine( x + 1, y2, x2 - 1, y2 ); |
1466 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1467 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1467 | p->drawLine( x, y, x2, y ); | 1468 | p->drawLine( x, y, x2, y ); |
1468 | ++y; | 1469 | ++y; |
1469 | } | 1470 | } |
1470 | } | 1471 | } |
1471 | for ( ; i < bWidth; ++i, ++x, --x2, --y2 ) { | 1472 | for ( ; i < bWidth; ++i, ++x, --x2, --y2 ) { |
1472 | p->drawLine( x, y, x, y2 ); | 1473 | p->drawLine( x, y, x, y2 ); |
1473 | p->drawLine( x2, y, x2, y2 ); | 1474 | p->drawLine( x2, y, x2, y2 ); |
1474 | p->drawLine( x, y2, x2, y2 ); | 1475 | p->drawLine( x, y2, x2, y2 ); |
1475 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1476 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1476 | p->drawLine( x, y, x2, y ); | 1477 | p->drawLine( x, y, x2, y ); |
1477 | ++y; | 1478 | ++y; |
1478 | } | 1479 | } |
1479 | } | 1480 | } |
1480 | i = 0; | 1481 | i = 0; |
1481 | if ( i < hWidth && bWidth == 0 ) { | 1482 | if ( i < hWidth && bWidth == 0 ) { |
1482 | p->setPen( cg->dark() ); | 1483 | p->setPen( cg->dark() ); |
1483 | p->drawLine( x + 1, y2, x2 - 1, y2 ); | 1484 | p->drawLine( x + 1, y2, x2 - 1, y2 ); |
1484 | p->drawLine( x2, y, x2, y2 - 1 ); | 1485 | p->drawLine( x2, y, x2, y2 - 1 ); |
1485 | p->setPen( cg->light() ); | 1486 | p->setPen( cg->light() ); |
1486 | p->drawLine( x, y, x, y2 - 1 ); | 1487 | p->drawLine( x, y, x, y2 - 1 ); |
1487 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1488 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1488 | p->drawLine( x, y, x2, y ); | 1489 | p->drawLine( x, y, x2, y ); |
1489 | ++y; | 1490 | ++y; |
1490 | } | 1491 | } |
1491 | ++i, ++x, --x2, --y2; | 1492 | ++i, ++x, --x2, --y2; |
1492 | } | 1493 | } |
1493 | for ( ; i < hWidth; ++i, ++x, --x2, --y2 ) { | 1494 | for ( ; i < hWidth; ++i, ++x, --x2, --y2 ) { |
1494 | p->setPen( cg->dark() ); | 1495 | p->setPen( cg->dark() ); |
1495 | p->drawLine( x, y2, x2, y2 ); | 1496 | p->drawLine( x, y2, x2, y2 ); |
1496 | p->drawLine( x2, y, x2, y2 ); | 1497 | p->drawLine( x2, y, x2, y2 ); |
1497 | p->setPen( cg->light() ); | 1498 | p->setPen( cg->light() ); |
1498 | p->drawLine( x, y, x, y2 ); | 1499 | p->drawLine( x, y, x, y2 ); |
1499 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1500 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1500 | p->drawLine( x, y, x2, y ); | 1501 | p->drawLine( x, y, x2, y ); |
1501 | ++y; | 1502 | ++y; |
1502 | } | 1503 | } |
1503 | } | 1504 | } |
1504 | if ( isPixmap( widget ) ) | 1505 | if ( isPixmap( widget ) ) |
1505 | p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1, | 1506 | p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1, |
1506 | *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) ); | 1507 | *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) ); |
1507 | else | 1508 | else |
1508 | p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() ); | 1509 | p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() ); |
1509 | } | 1510 | } |
1510 | else | 1511 | else |
1511 | QCommonStyle::drawTab( p, tb, t, selected ); | 1512 | QCommonStyle::drawTab( p, tb, t, selected ); |
1512 | } | 1513 | } |
1513 | 1514 | ||
1514 | void OThemeStyle::drawTabMask( QPainter* p, const QTabBar* tb, QTab* t, | 1515 | void OThemeStyle::drawTabMask( QPainter* p, const QTabBar* tb, QTab* t, |
1515 | bool selected ) | 1516 | bool selected ) |
1516 | { | 1517 | { |
1517 | QRect r( t->r ); | 1518 | QRect r( t->r ); |
1518 | 1519 | ||
1519 | if ( tb->shape() == QTabBar::RoundedAbove ) { | 1520 | if ( tb->shape() == QTabBar::RoundedAbove ) { |
1520 | if ( !selected ) | 1521 | if ( !selected ) |
1521 | r.setTop( r.top() + 2 ); | 1522 | r.setTop( r.top() + 2 ); |
1522 | p->drawLine( r.left() + 1, r.top(), r.right() - 1, r.top() ); | 1523 | p->drawLine( r.left() + 1, r.top(), r.right() - 1, r.top() ); |
1523 | QBrush b( color1, SolidPattern ); | 1524 | QBrush b( color1, SolidPattern ); |
1524 | p->fillRect( r.left(), r.top() + 1, r.width(), r.height() - 1, b ); | 1525 | p->fillRect( r.left(), r.top() + 1, r.width(), r.height() - 1, b ); |
1525 | } | 1526 | } |
1526 | else if ( tb->shape() == QTabBar::RoundedBelow ) { | 1527 | else if ( tb->shape() == QTabBar::RoundedBelow ) { |
1527 | if ( !selected ) | 1528 | if ( !selected ) |
1528 | r.setBottom( r.bottom() - 2 ); | 1529 | r.setBottom( r.bottom() - 2 ); |
1529 | p->drawLine( r.left() + 1, r.bottom(), r.right() - 1, r.bottom() ); | 1530 | p->drawLine( r.left() + 1, r.bottom(), r.right() - 1, r.bottom() ); |
1530 | QBrush b( color1, SolidPattern ); | 1531 | QBrush b( color1, SolidPattern ); |
1531 | p->fillRect( r.left(), r.top(), r.width(), r.height() - 1, b ); | 1532 | p->fillRect( r.left(), r.top(), r.width(), r.height() - 1, b ); |
1532 | } | 1533 | } |
1533 | else | 1534 | else |
1534 | QCommonStyle::drawTabMask( p, tb, t, selected ); | 1535 | QCommonStyle::drawTabMask( p, tb, t, selected ); |
1535 | 1536 | ||
1536 | } | 1537 | } |
1537 | 1538 | ||
1538 | 1539 | ||
1539 | //#include "kthemestyle.moc" | 1540 | //#include "kthemestyle.moc" |
1540 | 1541 | ||