summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/theme/ogfxeffect.cpp249
-rw-r--r--noncore/styles/theme/ogfxeffect.h3
-rw-r--r--noncore/styles/theme/othemestyle.cpp7
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
25QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca, 25QPixmap& 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
34QImage 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
94QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity, 277QPixmap& 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
110QImage& OGfxEffect::blend(QImage &image, float initial_intensity, 293QImage& 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//
309QImage& KQGfxEffect::blend(QImage &image1, QImage &image2, 492QImage& 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 */
24class OGfxEffect 24class OGfxEffect
25{ 25{
26public: 26public:
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
@@ -701,840 +701,841 @@ QStyle::ScrollControl OThemeStyle::scrollBarPointOver( const QScrollBar *sb,
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
726QSize OThemeStyle::exclusiveIndicatorSize() const 726QSize 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
734QSize OThemeStyle::indicatorSize() const 734QSize 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
742void OThemeStyle::drawExclusiveIndicator( QPainter* p, int x, int y, int w, 742void 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
758void OThemeStyle::drawIndicator( QPainter* p, int x, int y, int w, int h, 758void 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
774void OThemeStyle::drawExclusiveIndicatorMask( QPainter *p, int x, int y, int w, 774void 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
790void OThemeStyle::drawIndicatorMask( QPainter *p, int x, int y, int w, int h, 790void 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
805void OThemeStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, 805void 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
818void OThemeStyle::drawSlider( QPainter *p, int x, int y, int w, int h, 818void 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
836void OThemeStyle::drawSliderMask( QPainter *p, int x, int y, int w, int h, 836void 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
849int OThemeStyle::defaultFrameWidth() const 849int OThemeStyle::defaultFrameWidth() const
850{ 850{
851 return ( frameWidth() ); 851 return ( frameWidth() );
852} 852}
853 853
854void OThemeStyle::getButtonShift( int &x, int &y ) 854void OThemeStyle::getButtonShift( int &x, int &y )
855{ 855{
856 x = buttonXShift(); 856 x = buttonXShift();
857 y = buttonYShift(); 857 y = buttonYShift();
858} 858}
859 859
860int OThemeStyle::sliderLength() const 860int OThemeStyle::sliderLength() const
861{ 861{
862 return ( sliderButtonLength() ); 862 return ( sliderButtonLength() );
863} 863}
864 864
865void OThemeStyle::drawArrow( QPainter *p, Qt::ArrowType type, bool down, int x, 865void 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:
874widget = enabled ? down ? SunkenArrowUp : ArrowUp : DisArrowUp; 874widget = enabled ? down ? SunkenArrowUp : ArrowUp : DisArrowUp;
875 break; 875 break;
876 case DownArrow: 876 case DownArrow:
877widget = enabled ? down ? SunkenArrowDown : ArrowDown : DisArrowDown; 877widget = enabled ? down ? SunkenArrowDown : ArrowDown : DisArrowDown;
878 break; 878 break;
879 case LeftArrow: 879 case LeftArrow:
880widget = enabled ? down ? SunkenArrowLeft : ArrowLeft : DisArrowLeft; 880widget = enabled ? down ? SunkenArrowLeft : ArrowLeft : DisArrowLeft;
881 break; 881 break;
882 case RightArrow: 882 case RightArrow:
883 default: 883 default:
884widget = enabled ? down ? SunkenArrowRight : ArrowRight : DisArrowRight; 884widget = 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 */
938void OThemeStyle::drawShade( QPainter *p, int x, int y, int w, int h, 938void 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
1057void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) 1057void 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
1123int OThemeStyle::splitterWidth() const 1123int OThemeStyle::splitterWidth() const
1124{ 1124{
1125 return ( splitWidth() ); 1125 return ( splitWidth() );
1126} 1126}
1127 1127
1128void OThemeStyle::drawSplitter( QPainter *p, int x, int y, int w, int h, 1128void 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
1135void OThemeStyle::drawCheckMark( QPainter *p, int x, int y, int w, int h, 1135void 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
1149int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi, 1149int 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
1174void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, 1174void 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
1325void OThemeStyle::drawFocusRect( QPainter *p, const QRect &r, 1326void 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
1343void OThemeStyle::drawKMenuBar( QPainter *p, int x, int y, int w, int h, 1344void 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
1350void OThemeStyle::drawKMenuItem( QPainter *p, int x, int y, int w, int h, 1351void 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
1366void OThemeStyle::drawKProgressBlock( QPainter *p, int x, int y, int w, int h, 1367void 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
1373void OThemeStyle::getKProgressBackground( const QColorGroup &g, QBrush &bg ) 1374void 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
1382void OThemeStyle::tabbarMetrics( const QTabBar* t, int& hframe, int& vframe, int& overlap ) 1383void 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
1387void OThemeStyle::drawTab( QPainter* p, const QTabBar* tb, QTab* t , 1388void 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
1514void OThemeStyle::drawTabMask( QPainter* p, const QTabBar* tb, QTab* t, 1515void 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