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,179 +1,362 @@ | |||
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]); |
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 | |||
@@ -1117,201 +1117,202 @@ void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) | |||
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, |