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