author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 11:15:19 +0300 | |
branch | RCL_3 |
changeset 11 | 25a739ee40f4 |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qplastiquestyle.h" |
|
43 |
||
44 |
#if !defined(QT_NO_STYLE_PLASTIQUE) || defined(QT_PLUGIN) |
|
45 |
||
46 |
static const bool AnimateBusyProgressBar = true; |
|
47 |
static const bool AnimateProgressBar = false; |
|
48 |
// #define QPlastique_MaskButtons |
|
49 |
static const int ProgressBarFps = 25; |
|
50 |
static const int blueFrameWidth = 2; // with of line edit focus frame |
|
51 |
||
52 |
#include "qwindowsstyle_p.h" |
|
53 |
#include <private/qstylehelper_p.h> |
|
54 |
#include <qapplication.h> |
|
55 |
#include <qbitmap.h> |
|
56 |
#include <qabstractitemview.h> |
|
57 |
#include <qcheckbox.h> |
|
58 |
#include <qcombobox.h> |
|
59 |
#include <qdatetime.h> |
|
60 |
#include <qdebug.h> |
|
61 |
#include <qdialogbuttonbox.h> |
|
62 |
#include <qformlayout.h> |
|
63 |
#include <qgroupbox.h> |
|
64 |
#include <qimage.h> |
|
65 |
#include <qlineedit.h> |
|
66 |
#include <qmainwindow.h> |
|
67 |
#include <qmenu.h> |
|
68 |
#include <qmenubar.h> |
|
69 |
#include <qpainter.h> |
|
70 |
#include <qpaintengine.h> |
|
71 |
#include <qpainterpath.h> |
|
72 |
#include <qpalette.h> |
|
73 |
#include <qpen.h> |
|
74 |
#include <qpixmap.h> |
|
75 |
#include <qpixmapcache.h> |
|
76 |
#include <qprogressbar.h> |
|
77 |
#include <qpushbutton.h> |
|
78 |
#include <qradiobutton.h> |
|
79 |
#include <qscrollbar.h> |
|
80 |
#include <qspinbox.h> |
|
81 |
#include <qsplitter.h> |
|
82 |
#include <qstyleoption.h> |
|
83 |
#include <qtextedit.h> |
|
84 |
#include <qtoolbar.h> |
|
85 |
#include <qtoolbox.h> |
|
86 |
#include <qtoolbutton.h> |
|
87 |
#include <qworkspace.h> |
|
88 |
#include <qprocess.h> |
|
89 |
#include <qvarlengtharray.h> |
|
90 |
#include <limits.h> |
|
91 |
||
92 |
QT_BEGIN_NAMESPACE |
|
93 |
||
94 |
// from windows style |
|
95 |
static const int windowsItemFrame = 2; // menu item frame width |
|
96 |
static const int windowsSepHeight = 2; // separator item height |
|
97 |
static const int windowsItemHMargin = 3; // menu item hor text margin |
|
98 |
static const int windowsItemVMargin = 2; // menu item ver text margin |
|
99 |
static const int windowsArrowHMargin = 6; // arrow horizontal margin |
|
100 |
static const int windowsTabSpacing = 12; // space between text and tab |
|
101 |
static const int windowsRightBorder = 15; // right border on windows |
|
102 |
static const int windowsCheckMarkWidth = 12; // checkmarks width on windows |
|
103 |
||
104 |
static const char * const qt_plastique_slider_verticalhandle[] = { |
|
105 |
"15 11 6 1", |
|
106 |
" c None", |
|
107 |
"+ c #979797", |
|
108 |
"@ c #C9C9C9", |
|
109 |
"$ c #C1C1C1", |
|
110 |
"b c None", |
|
111 |
"d c None", |
|
112 |
" $++++++++$ ", |
|
113 |
"$+bbbbbbbb+$ ", |
|
114 |
"+b $$ +$ ", |
|
115 |
"+b $@ +$ ", |
|
116 |
"+b +$", |
|
117 |
"+b d+", |
|
118 |
"+b d+$", |
|
119 |
"+b $$ d+$ ", |
|
120 |
"+b $@ d+$ ", |
|
121 |
"$+dddddddd+$ ", |
|
122 |
" $++++++++$ "}; |
|
123 |
||
124 |
static const char * const qt_plastique_slider_verticalhandle_left[] = { |
|
125 |
"15 11 6 1", |
|
126 |
" c None", |
|
127 |
"+ c #979797", |
|
128 |
"@ c #C9C9C9", |
|
129 |
"$ c #C1C1C1", |
|
130 |
"b c None", |
|
131 |
"d c None", |
|
132 |
" $++++++++$ ", |
|
133 |
" $+bbbbbbbb+$", |
|
134 |
" $+b $$ d+", |
|
135 |
" $+b $@ d+", |
|
136 |
"$+b d+", |
|
137 |
"+b d+", |
|
138 |
"$+ d+", |
|
139 |
" $+ $$ d+", |
|
140 |
" $+ $@ d+", |
|
141 |
" $+dddddddd+$", |
|
142 |
" $++++++++$ "}; |
|
143 |
||
144 |
static const char * const qt_plastique_slider_horizontalhandle[] = { |
|
145 |
"11 15 6 1", |
|
146 |
" c None", |
|
147 |
"+ c #979797", |
|
148 |
"@ c #C9C9C9", |
|
149 |
"$ c #C1C1C1", |
|
150 |
"b c None", |
|
151 |
"d c None", |
|
152 |
" $+++++++$ ", |
|
153 |
"$+bbbbbbb+$", |
|
154 |
"+b d+", |
|
155 |
"+b$$ $$d+", |
|
156 |
"+b$@ $@d+", |
|
157 |
"+b d+", |
|
158 |
"+b d+", |
|
159 |
"+b d+", |
|
160 |
"+b d+", |
|
161 |
"+b d+", |
|
162 |
"$+ d+$", |
|
163 |
" $+ d+$ ", |
|
164 |
" $+ d+$ ", |
|
165 |
" $+d+$ ", |
|
166 |
" $+$ "}; |
|
167 |
||
168 |
static const char * const qt_plastique_slider_horizontalhandle_up[] = { |
|
169 |
"11 15 6 1", |
|
170 |
" c None", |
|
171 |
"+ c #979797", |
|
172 |
"@ c #C9C9C9", |
|
173 |
"$ c #C1C1C1", |
|
174 |
"b c None", |
|
175 |
"d c None", |
|
176 |
" $+$ ", |
|
177 |
" $+b+$ ", |
|
178 |
" $+b +$ ", |
|
179 |
" $+b +$ ", |
|
180 |
"$+b +$", |
|
181 |
"+b d+", |
|
182 |
"+b d+", |
|
183 |
"+b d+", |
|
184 |
"+b d+", |
|
185 |
"+b d+", |
|
186 |
"+b$$ $$d+", |
|
187 |
"+b$@ $@d+", |
|
188 |
"+b d+", |
|
189 |
"$+ddddddd+$", |
|
190 |
" $+++++++$ "}; |
|
191 |
||
192 |
static const char * const qt_scrollbar_button_arrow_left[] = { |
|
193 |
"4 7 2 1", |
|
194 |
" c None", |
|
195 |
"* c #BFBFBF", |
|
196 |
" *", |
|
197 |
" **", |
|
198 |
" ***", |
|
199 |
"****", |
|
200 |
" ***", |
|
201 |
" **", |
|
202 |
" *"}; |
|
203 |
||
204 |
static const char * const qt_scrollbar_button_arrow_right[] = { |
|
205 |
"4 7 2 1", |
|
206 |
" c None", |
|
207 |
"* c #BFBFBF", |
|
208 |
"* ", |
|
209 |
"** ", |
|
210 |
"*** ", |
|
211 |
"****", |
|
212 |
"*** ", |
|
213 |
"** ", |
|
214 |
"* "}; |
|
215 |
||
216 |
static const char * const qt_scrollbar_button_arrow_up[] = { |
|
217 |
"7 4 2 1", |
|
218 |
" c None", |
|
219 |
"* c #BFBFBF", |
|
220 |
" * ", |
|
221 |
" *** ", |
|
222 |
" ***** ", |
|
223 |
"*******"}; |
|
224 |
||
225 |
static const char * const qt_scrollbar_button_arrow_down[] = { |
|
226 |
"7 4 2 1", |
|
227 |
" c None", |
|
228 |
"* c #BFBFBF", |
|
229 |
"*******", |
|
230 |
" ***** ", |
|
231 |
" *** ", |
|
232 |
" * "}; |
|
233 |
||
234 |
static const char * const qt_scrollbar_button_left[] = { |
|
235 |
"16 16 6 1", |
|
236 |
" c None", |
|
237 |
". c #BFBFBF", |
|
238 |
"+ c #979797", |
|
239 |
"# c #FAFAFA", |
|
240 |
"< c #FAFAFA", |
|
241 |
"* c #FAFAFA", |
|
242 |
" .+++++++++++++.", |
|
243 |
".+#############+", |
|
244 |
"+# <+", |
|
245 |
"+# <+", |
|
246 |
"+# <+", |
|
247 |
"+# <+", |
|
248 |
"+# <+", |
|
249 |
"+# <+", |
|
250 |
"+# <+", |
|
251 |
"+# <+", |
|
252 |
"+# <+", |
|
253 |
"+# <+", |
|
254 |
"+# <+", |
|
255 |
"+# <+", |
|
256 |
".+<<<<<<<<<<<<<+", |
|
257 |
" .+++++++++++++."}; |
|
258 |
||
259 |
static const char * const qt_scrollbar_button_right[] = { |
|
260 |
"16 16 6 1", |
|
261 |
" c None", |
|
262 |
". c #BFBFBF", |
|
263 |
"+ c #979797", |
|
264 |
"# c #FAFAFA", |
|
265 |
"< c #FAFAFA", |
|
266 |
"* c #FAFAFA", |
|
267 |
".+++++++++++++. ", |
|
268 |
"+#############+.", |
|
269 |
"+# <+", |
|
270 |
"+# <+", |
|
271 |
"+# <+", |
|
272 |
"+# <+", |
|
273 |
"+# <+", |
|
274 |
"+# <+", |
|
275 |
"+# <+", |
|
276 |
"+# <+", |
|
277 |
"+# <+", |
|
278 |
"+# <+", |
|
279 |
"+# <+", |
|
280 |
"+# <+", |
|
281 |
"+<<<<<<<<<<<<<+.", |
|
282 |
".+++++++++++++. "}; |
|
283 |
||
284 |
static const char * const qt_scrollbar_button_up[] = { |
|
285 |
"16 16 6 1", |
|
286 |
" c None", |
|
287 |
". c #BFBFBF", |
|
288 |
"+ c #979797", |
|
289 |
"# c #FAFAFA", |
|
290 |
"< c #FAFAFA", |
|
291 |
"* c #FAFAFA", |
|
292 |
" .++++++++++++. ", |
|
293 |
".+############+.", |
|
294 |
"+# <+", |
|
295 |
"+# <+", |
|
296 |
"+# <+", |
|
297 |
"+# <+", |
|
298 |
"+# <+", |
|
299 |
"+# <+", |
|
300 |
"+# <+", |
|
301 |
"+# <+", |
|
302 |
"+# <+", |
|
303 |
"+# <+", |
|
304 |
"+# <+", |
|
305 |
"+# <+", |
|
306 |
"+<<<<<<<<<<<<<<+", |
|
307 |
".++++++++++++++."}; |
|
308 |
||
309 |
static const char * const qt_scrollbar_button_down[] = { |
|
310 |
"16 16 6 1", |
|
311 |
" c None", |
|
312 |
". c #BFBFBF", |
|
313 |
"+ c #979797", |
|
314 |
"# c #FAFAFA", |
|
315 |
"< c #FAFAFA", |
|
316 |
"* c #FAFAFA", |
|
317 |
"++++++++++++++++", |
|
318 |
"+##############+", |
|
319 |
"+# <+", |
|
320 |
"+# <+", |
|
321 |
"+# <+", |
|
322 |
"+# <+", |
|
323 |
"+# <+", |
|
324 |
"+# <+", |
|
325 |
"+# <+", |
|
326 |
"+# <+", |
|
327 |
"+# <+", |
|
328 |
"+# <+", |
|
329 |
"+# <+", |
|
330 |
"+# <+", |
|
331 |
".+<<<<<<<<<<<<+.", |
|
332 |
" .++++++++++++. "}; |
|
333 |
||
334 |
static const char * const qt_scrollbar_slider_pattern_vertical[] = { |
|
335 |
"10 18 3 1", |
|
336 |
" c None", |
|
337 |
". c #BFBFBF", |
|
338 |
"+ c #979797", |
|
339 |
".. .. ..", |
|
340 |
".+ .+ .+", |
|
341 |
" ", |
|
342 |
" ", |
|
343 |
".. .. ..", |
|
344 |
".+ .+ .+", |
|
345 |
" ", |
|
346 |
" ", |
|
347 |
".. .. ..", |
|
348 |
".+ .+ .+", |
|
349 |
" ", |
|
350 |
" ", |
|
351 |
".. .. ..", |
|
352 |
".+ .+ .+", |
|
353 |
" ", |
|
354 |
" ", |
|
355 |
".. .. ..", |
|
356 |
".+ .+ .+"}; |
|
357 |
||
358 |
static const char * const qt_scrollbar_slider_pattern_horizontal[] = { |
|
359 |
"18 10 3 1", |
|
360 |
" c None", |
|
361 |
". c #BFBFBF", |
|
362 |
"+ c #979797", |
|
363 |
".. .. .. .. ..", |
|
364 |
".+ .+ .+ .+ .+", |
|
365 |
" ", |
|
366 |
" ", |
|
367 |
".. .. .. .. ..", |
|
368 |
".+ .+ .+ .+ .+", |
|
369 |
" ", |
|
370 |
" ", |
|
371 |
".. .. .. .. ..", |
|
372 |
".+ .+ .+ .+ .+"}; |
|
373 |
||
374 |
static const char * const qt_toolbarhandle[] = { |
|
375 |
"6 6 4 1", |
|
376 |
" c None", |
|
377 |
". c #C5C5C5", |
|
378 |
"+ c #EEEEEE", |
|
379 |
"@ c #FAFAFA", |
|
380 |
".. ", |
|
381 |
".+@ ", |
|
382 |
" @@ ", |
|
383 |
" .. ", |
|
384 |
" .+@", |
|
385 |
" @@"}; |
|
386 |
||
387 |
static const char * const qt_simple_toolbarhandle[] = { |
|
388 |
"3 3 4 1", |
|
389 |
" c None", |
|
390 |
". c #C5C5C5", |
|
391 |
"+ c #EEEEEE", |
|
392 |
"@ c #FAFAFA", |
|
393 |
".. ", |
|
394 |
".+@", |
|
395 |
" @@"}; |
|
396 |
||
397 |
static const char * const qt_titlebar_context_help[] = { |
|
398 |
"27 27 5 1", |
|
399 |
" c None", |
|
400 |
". c #0A0C12", |
|
401 |
"+ c #1B202D", |
|
402 |
"@ c #293144", |
|
403 |
"# c #3C435D", |
|
404 |
" ", |
|
405 |
" ", |
|
406 |
" ", |
|
407 |
" ", |
|
408 |
" ", |
|
409 |
" ", |
|
410 |
" ", |
|
411 |
" ", |
|
412 |
" +@##@+ ", |
|
413 |
" .@@@.+@@.. ", |
|
414 |
" .##+ +@@+. ", |
|
415 |
" .##@ @#@+. ", |
|
416 |
" .... +@+.. ", |
|
417 |
" .@+@@.. ", |
|
418 |
" +#@@+ ", |
|
419 |
" .##. ", |
|
420 |
" .++. ", |
|
421 |
" .++. ", |
|
422 |
" +##+ ", |
|
423 |
" .@@. ", |
|
424 |
" ", |
|
425 |
" ", |
|
426 |
" ", |
|
427 |
" ", |
|
428 |
" ", |
|
429 |
" ", |
|
430 |
" "}; |
|
431 |
||
432 |
static QLinearGradient qMapGradientToRect(const QLinearGradient &gradient, const QRectF &rect) |
|
433 |
{ |
|
434 |
QLinearGradient tmpGrad(rect.center().x(), rect.top(), |
|
435 |
rect.center().x(), rect.bottom()); |
|
436 |
tmpGrad.setStops(gradient.stops()); |
|
437 |
return tmpGrad; |
|
438 |
} |
|
439 |
||
440 |
static QBrush qMapBrushToRect(const QBrush &brush, const QRectF &rect) |
|
441 |
{ |
|
442 |
if (!brush.gradient()) |
|
443 |
return brush; |
|
444 |
||
445 |
// ### Ugly assumption that it's a linear gradient |
|
446 |
QBrush tmp(qMapGradientToRect(*static_cast<const QLinearGradient *>(brush.gradient()), rect)); |
|
447 |
return tmp; |
|
448 |
} |
|
449 |
||
450 |
static void qBrushSetAlphaF(QBrush *brush, qreal alpha) |
|
451 |
{ |
|
452 |
if (const QGradient *gradient = brush->gradient()) { |
|
453 |
// Use the gradient. Call QColor::setAlphaF() on all color stops. |
|
454 |
QGradientStops stops = gradient->stops(); |
|
455 |
QMutableVectorIterator<QGradientStop> it(stops); |
|
456 |
QColor tmpColor; |
|
457 |
while (it.hasNext()) { |
|
458 |
it.next(); |
|
459 |
tmpColor = it.value().second; |
|
460 |
tmpColor.setAlphaF(alpha * tmpColor.alphaF()); |
|
461 |
it.setValue(QPair<qreal, QColor>(it.value().first, tmpColor)); |
|
462 |
} |
|
463 |
||
464 |
switch (gradient->type()) { |
|
465 |
case QGradient::RadialGradient: { |
|
466 |
QRadialGradient grad = *static_cast<const QRadialGradient *>(gradient); |
|
467 |
grad.setStops(stops); |
|
468 |
*brush = QBrush(grad); |
|
469 |
break; |
|
470 |
} |
|
471 |
case QGradient::ConicalGradient: { |
|
472 |
QConicalGradient grad = *static_cast<const QConicalGradient *>(gradient); |
|
473 |
grad.setStops(stops); |
|
474 |
*brush = QBrush(grad); |
|
475 |
break; |
|
476 |
} |
|
477 |
default: |
|
478 |
qWarning("QPlastiqueStyle::qBrushLight() - unknown gradient type" |
|
479 |
" - falling back to QLinearGradient"); |
|
480 |
case QGradient::LinearGradient: { |
|
481 |
QLinearGradient grad = *static_cast<const QLinearGradient *>(gradient); |
|
482 |
grad.setStops(stops); |
|
483 |
*brush = QBrush(grad); |
|
484 |
break; |
|
485 |
} |
|
486 |
} |
|
487 |
} else if (!brush->texture().isNull()) { |
|
488 |
// Modify the texture - ridiculously expensive. |
|
489 |
QPixmap texture = brush->texture(); |
|
490 |
QPixmap pixmap; |
|
491 |
QString name = QString::fromLatin1("qbrushtexture-alpha-%1-%2").arg(alpha).arg(texture.cacheKey()); |
|
492 |
if (!QPixmapCache::find(name, pixmap)) { |
|
493 |
QImage image = texture.toImage(); |
|
494 |
QRgb *rgb = reinterpret_cast<QRgb *>(image.bits()); |
|
495 |
int pixels = image.width() * image.height(); |
|
496 |
QColor tmpColor; |
|
497 |
while (pixels--) { |
|
498 |
tmpColor.setRgb(*rgb); |
|
499 |
tmpColor.setAlphaF(alpha * tmpColor.alphaF()); |
|
500 |
*rgb++ = tmpColor.rgba(); |
|
501 |
} |
|
502 |
pixmap = QPixmap::fromImage(image); |
|
503 |
QPixmapCache::insert(name, pixmap); |
|
504 |
} |
|
505 |
brush->setTexture(pixmap); |
|
506 |
} else { |
|
507 |
// Use the color |
|
508 |
QColor tmpColor = brush->color(); |
|
509 |
tmpColor.setAlphaF(alpha * tmpColor.alphaF()); |
|
510 |
brush->setColor(tmpColor); |
|
511 |
} |
|
512 |
} |
|
513 |
||
514 |
static QBrush qBrushLight(QBrush brush, int light) |
|
515 |
{ |
|
516 |
if (const QGradient *gradient = brush.gradient()) { |
|
517 |
// Use the gradient. Call QColor::lighter() on all color stops. |
|
518 |
QGradientStops stops = gradient->stops(); |
|
519 |
QMutableVectorIterator<QGradientStop> it(stops); |
|
520 |
while (it.hasNext()) { |
|
521 |
it.next(); |
|
522 |
it.setValue(QPair<qreal, QColor>(it.value().first, it.value().second.lighter(light))); |
|
523 |
} |
|
524 |
||
525 |
switch (gradient->type()) { |
|
526 |
case QGradient::RadialGradient: { |
|
527 |
QRadialGradient grad = *static_cast<const QRadialGradient *>(gradient); |
|
528 |
grad.setStops(stops); |
|
529 |
brush = QBrush(grad); |
|
530 |
break; |
|
531 |
} |
|
532 |
case QGradient::ConicalGradient: { |
|
533 |
QConicalGradient grad = *static_cast<const QConicalGradient *>(gradient); |
|
534 |
grad.setStops(stops); |
|
535 |
brush = QBrush(grad); |
|
536 |
break; |
|
537 |
} |
|
538 |
default: |
|
539 |
qWarning("QPlastiqueStyle::qBrushLight() - unknown gradient type" |
|
540 |
" - falling back to QLinearGradient"); |
|
541 |
case QGradient::LinearGradient: { |
|
542 |
QLinearGradient grad = *static_cast<const QLinearGradient *>(gradient); |
|
543 |
grad.setStops(stops); |
|
544 |
brush = QBrush(grad); |
|
545 |
break; |
|
546 |
} |
|
547 |
} |
|
548 |
} else if (!brush.texture().isNull()) { |
|
549 |
// Modify the texture - ridiculously expensive. |
|
550 |
QPixmap texture = brush.texture(); |
|
551 |
QPixmap pixmap; |
|
552 |
QString name = QString::fromLatin1("qbrushtexture-light-%1-%2").arg(light).arg(texture.cacheKey()); |
|
553 |
if (!QPixmapCache::find(name, pixmap)) { |
|
554 |
QImage image = texture.toImage(); |
|
555 |
QRgb *rgb = reinterpret_cast<QRgb *>(image.bits()); |
|
556 |
int pixels = image.width() * image.height(); |
|
557 |
QColor tmpColor; |
|
558 |
while (pixels--) { |
|
559 |
tmpColor.setRgb(*rgb); |
|
560 |
*rgb++ = tmpColor.lighter(light).rgba(); |
|
561 |
} |
|
562 |
pixmap = QPixmap::fromImage(image); |
|
563 |
QPixmapCache::insert(name, pixmap); |
|
564 |
} |
|
565 |
brush.setTexture(pixmap); |
|
566 |
} else { |
|
567 |
// Use the color |
|
568 |
brush.setColor(brush.color().lighter(light)); |
|
569 |
} |
|
570 |
return brush; |
|
571 |
} |
|
572 |
||
573 |
static QBrush qBrushDark(QBrush brush, int dark) |
|
574 |
{ |
|
575 |
if (const QGradient *gradient = brush.gradient()) { |
|
576 |
// Use the gradient. Call QColor::darker() on all color stops. |
|
577 |
QGradientStops stops = gradient->stops(); |
|
578 |
QMutableVectorIterator<QGradientStop> it(stops); |
|
579 |
while (it.hasNext()) { |
|
580 |
it.next(); |
|
581 |
it.setValue(QPair<qreal, QColor>(it.value().first, it.value().second.darker(dark))); |
|
582 |
} |
|
583 |
||
584 |
switch (gradient->type()) { |
|
585 |
case QGradient::RadialGradient: { |
|
586 |
QRadialGradient grad = *static_cast<const QRadialGradient *>(gradient); |
|
587 |
grad.setStops(stops); |
|
588 |
brush = QBrush(grad); |
|
589 |
break; |
|
590 |
} |
|
591 |
case QGradient::ConicalGradient: { |
|
592 |
QConicalGradient grad = *static_cast<const QConicalGradient *>(gradient); |
|
593 |
grad.setStops(stops); |
|
594 |
brush = QBrush(grad); |
|
595 |
break; |
|
596 |
} |
|
597 |
default: |
|
598 |
qWarning("QPlastiqueStyle::qBrushDark() - unknown gradient type" |
|
599 |
" - falling back to QLinearGradient"); |
|
600 |
case QGradient::LinearGradient: { |
|
601 |
QLinearGradient grad = *static_cast<const QLinearGradient *>(gradient); |
|
602 |
grad.setStops(stops); |
|
603 |
brush = QBrush(grad); |
|
604 |
break; |
|
605 |
} |
|
606 |
} |
|
607 |
} else if (!brush.texture().isNull()) { |
|
608 |
// Modify the texture - ridiculously expensive. |
|
609 |
QPixmap texture = brush.texture(); |
|
610 |
QPixmap pixmap; |
|
611 |
QString name = QString::fromLatin1("qbrushtexture-dark-%1-%2").arg(dark).arg(brush.texture().cacheKey()); |
|
612 |
if (!QPixmapCache::find(name, pixmap)) { |
|
613 |
QImage image = texture.toImage(); |
|
614 |
QRgb *rgb = reinterpret_cast<QRgb *>(image.bits()); |
|
615 |
int pixels = image.width() * image.height(); |
|
616 |
QColor tmpColor; |
|
617 |
while (pixels--) { |
|
618 |
tmpColor.setRgb(*rgb); |
|
619 |
*rgb++ = tmpColor.darker(dark).rgba(); |
|
620 |
} |
|
621 |
pixmap = QPixmap::fromImage(image); |
|
622 |
QPixmapCache::insert(name, pixmap); |
|
623 |
} |
|
624 |
brush.setTexture(pixmap); |
|
625 |
} else { |
|
626 |
// Use the color |
|
627 |
brush.setColor(brush.color().darker(dark)); |
|
628 |
} |
|
629 |
return brush; |
|
630 |
} |
|
631 |
||
632 |
/* |
|
633 |
Draws a rounded frame using the provided brush for 1, and adds 0.5 alpha |
|
634 |
for 0. |
|
635 |
||
636 |
0111111110 |
|
637 |
01 10 |
|
638 |
1 1 |
|
639 |
1 1 |
|
640 |
1 1 |
|
641 |
01 10 |
|
642 |
0111111110 |
|
643 |
*/ |
|
644 |
static void qt_plastique_draw_frame(QPainter *painter, const QRect &rect, const QStyleOption *option, |
|
645 |
QFrame::Shadow shadow = QFrame::Plain) |
|
646 |
{ |
|
647 |
QPen oldPen = painter->pen(); |
|
648 |
QBrush border; |
|
649 |
QBrush corner; |
|
650 |
QBrush innerTopLeft; |
|
651 |
QBrush innerBottomRight; |
|
652 |
||
653 |
if (shadow != QFrame::Plain && (option->state & QStyle::State_HasFocus)) { |
|
654 |
border = option->palette.highlight(); |
|
655 |
qBrushSetAlphaF(&border, qreal(0.8)); |
|
656 |
corner = option->palette.highlight(); |
|
657 |
qBrushSetAlphaF(&corner, 0.5); |
|
658 |
innerTopLeft = qBrushDark(option->palette.highlight(), 125); |
|
659 |
innerBottomRight = option->palette.highlight(); |
|
660 |
qBrushSetAlphaF(&innerBottomRight, qreal(0.65)); |
|
661 |
} else { |
|
662 |
border = option->palette.shadow(); |
|
663 |
qBrushSetAlphaF(&border, qreal(0.4)); |
|
664 |
corner = option->palette.shadow(); |
|
665 |
qBrushSetAlphaF(&corner, 0.25); |
|
666 |
innerTopLeft = option->palette.shadow(); |
|
667 |
innerBottomRight = option->palette.shadow(); |
|
668 |
if (shadow == QFrame::Sunken) { |
|
669 |
qBrushSetAlphaF(&innerTopLeft, qreal(0.23)); |
|
670 |
qBrushSetAlphaF(&innerBottomRight, qreal(0.075)); |
|
671 |
} else { |
|
672 |
qBrushSetAlphaF(&innerTopLeft, qreal(0.075)); |
|
673 |
qBrushSetAlphaF(&innerBottomRight, qreal(0.23)); |
|
674 |
} |
|
675 |
} |
|
676 |
||
677 |
QLine lines[4]; |
|
678 |
QPoint points[8]; |
|
679 |
||
680 |
// Opaque corner lines |
|
681 |
painter->setPen(QPen(border, 0)); |
|
682 |
lines[0] = QLine(rect.left() + 2, rect.top(), rect.right() - 2, rect.top()); |
|
683 |
lines[1] = QLine(rect.left() + 2, rect.bottom(), rect.right() - 2, rect.bottom()); |
|
684 |
lines[2] = QLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2); |
|
685 |
lines[3] = QLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2); |
|
686 |
painter->drawLines(lines, 4); |
|
687 |
||
688 |
// Opaque corner dots |
|
689 |
points[0] = QPoint(rect.left() + 1, rect.top() + 1); |
|
690 |
points[1] = QPoint(rect.left() + 1, rect.bottom() - 1); |
|
691 |
points[2] = QPoint(rect.right() - 1, rect.top() + 1); |
|
692 |
points[3] = QPoint(rect.right() - 1, rect.bottom() - 1); |
|
693 |
painter->drawPoints(points, 4); |
|
694 |
||
695 |
// Shaded corner dots |
|
696 |
painter->setPen(QPen(corner, 0)); |
|
697 |
points[0] = QPoint(rect.left(), rect.top() + 1); |
|
698 |
points[1] = QPoint(rect.left(), rect.bottom() - 1); |
|
699 |
points[2] = QPoint(rect.left() + 1, rect.top()); |
|
700 |
points[3] = QPoint(rect.left() + 1, rect.bottom()); |
|
701 |
points[4] = QPoint(rect.right(), rect.top() + 1); |
|
702 |
points[5] = QPoint(rect.right(), rect.bottom() - 1); |
|
703 |
points[6] = QPoint(rect.right() - 1, rect.top()); |
|
704 |
points[7] = QPoint(rect.right() - 1, rect.bottom()); |
|
705 |
painter->drawPoints(points, 8); |
|
706 |
||
707 |
// Shadows |
|
708 |
if (shadow != QFrame::Plain) { |
|
709 |
painter->setPen(QPen(innerTopLeft, 0)); |
|
710 |
lines[0] = QLine(rect.left() + 2, rect.top() + 1, rect.right() - 2, rect.top() + 1); |
|
711 |
lines[1] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2); |
|
712 |
painter->drawLines(lines, 2); |
|
713 |
painter->setPen(QPen(innerBottomRight, 0)); |
|
714 |
lines[0] = QLine(rect.left() + 2, rect.bottom() - 1, rect.right() - 2, rect.bottom() - 1); |
|
715 |
lines[1] = QLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2); |
|
716 |
painter->drawLines(lines, 2); |
|
717 |
} |
|
718 |
||
719 |
painter->setPen(oldPen); |
|
720 |
} |
|
721 |
||
722 |
static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50) |
|
723 |
{ |
|
724 |
const int maxFactor = 100; |
|
725 |
QColor tmp = colorA; |
|
726 |
tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor); |
|
727 |
tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor); |
|
728 |
tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor); |
|
729 |
return tmp; |
|
730 |
} |
|
731 |
||
732 |
static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart, |
|
733 |
const QColor &gradientStop) |
|
734 |
{ |
|
735 |
QString gradientName; |
|
736 |
gradientName.sprintf("%dx%d-%x-%x", rect.width(), rect.height(), gradientStart.rgba(), gradientStop.rgba()); |
|
737 |
QPixmap cache; |
|
738 |
QPainter *p = painter; |
|
739 |
QRect r = rect; |
|
740 |
||
741 |
bool doPixmapCache = painter->deviceTransform().isIdentity() |
|
742 |
&& painter->worldMatrix().isIdentity(); |
|
743 |
if (doPixmapCache && QPixmapCache::find(gradientName, cache)) { |
|
744 |
painter->drawPixmap(rect, cache); |
|
745 |
} else { |
|
746 |
if (doPixmapCache) { |
|
747 |
cache = QPixmap(rect.size()); |
|
748 |
cache.fill(Qt::transparent); |
|
749 |
p = new QPainter(&cache); |
|
750 |
r = QRect(0, 0, rect.width(), rect.height()); |
|
751 |
} |
|
752 |
||
753 |
int x = r.center().x(); |
|
754 |
QLinearGradient gradient(x, r.top(), x, r.bottom()); |
|
755 |
gradient.setColorAt(0, gradientStart); |
|
756 |
gradient.setColorAt(1, gradientStop); |
|
757 |
p->fillRect(r, gradient); |
|
758 |
||
759 |
if (doPixmapCache) { |
|
760 |
p->end(); |
|
761 |
delete p; |
|
762 |
painter->drawPixmap(rect, cache); |
|
763 |
QPixmapCache::insert(gradientName, cache); |
|
764 |
} |
|
765 |
} |
|
766 |
} |
|
767 |
||
768 |
static void qt_plastique_drawFrame(QPainter *painter, const QStyleOption *option, const QWidget *widget) |
|
769 |
{ |
|
770 |
QRect rect = option->rect; |
|
771 |
QPen oldPen = painter->pen(); |
|
772 |
||
773 |
QColor borderColor = option->palette.background().color().darker(178); |
|
774 |
QColor gradientStartColor = option->palette.button().color().lighter(104); |
|
775 |
QColor gradientStopColor = option->palette.button().color().darker(105); |
|
776 |
QColor alphaCornerColor; |
|
777 |
if (widget) { |
|
778 |
// ### backgroundrole/foregroundrole should be part of the style option |
|
779 |
alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor); |
|
780 |
} else { |
|
781 |
alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); |
|
782 |
} |
|
783 |
||
784 |
QLine lines[4]; |
|
785 |
QPoint points[8]; |
|
786 |
||
787 |
// outline / border |
|
788 |
painter->setPen(borderColor); |
|
789 |
lines[0] = QLine(rect.left() + 2, rect.top(), rect.right() - 2, rect.top()); |
|
790 |
lines[1] = QLine(rect.left() + 2, rect.bottom(), rect.right() - 2, rect.bottom()); |
|
791 |
lines[2] = QLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2); |
|
792 |
lines[3] = QLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2); |
|
793 |
painter->drawLines(lines, 4); |
|
794 |
||
795 |
points[0] = QPoint(rect.left() + 1, rect.top() + 1); |
|
796 |
points[1] = QPoint(rect.right() - 1, rect.top() + 1); |
|
797 |
points[2] = QPoint(rect.left() + 1, rect.bottom() - 1); |
|
798 |
points[3] = QPoint(rect.right() - 1, rect.bottom() - 1); |
|
799 |
painter->drawPoints(points, 4); |
|
800 |
||
801 |
painter->setPen(alphaCornerColor); |
|
802 |
||
803 |
points[0] = QPoint(rect.left() + 1, rect.top()); |
|
804 |
points[1] = QPoint(rect.right() - 1, rect.top()); |
|
805 |
points[2] = QPoint(rect.left() + 1, rect.bottom()); |
|
806 |
points[3] = QPoint(rect.right() - 1, rect.bottom()); |
|
807 |
points[4] = QPoint(rect.left(), rect.top() + 1); |
|
808 |
points[5] = QPoint(rect.right(), rect.top() + 1); |
|
809 |
points[6] = QPoint(rect.left(), rect.bottom() - 1); |
|
810 |
points[7] = QPoint(rect.right(), rect.bottom() - 1); |
|
811 |
painter->drawPoints(points, 8); |
|
812 |
||
813 |
// inner border |
|
814 |
if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) |
|
815 |
painter->setPen(option->palette.button().color().darker(118)); |
|
816 |
else |
|
817 |
painter->setPen(gradientStartColor); |
|
818 |
||
819 |
lines[0] = QLine(rect.left() + 2, rect.top() + 1, rect.right() - 2, option->rect.top() + 1); |
|
820 |
lines[1] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, option->rect.bottom() - 2); |
|
821 |
painter->drawLines(lines, 2); |
|
822 |
||
823 |
if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) |
|
824 |
painter->setPen(option->palette.button().color().darker(110)); |
|
825 |
else |
|
826 |
painter->setPen(gradientStopColor.darker(102)); |
|
827 |
||
828 |
lines[0] = QLine(rect.left() + 2, rect.bottom() - 1, rect.right() - 2, rect.bottom() - 1); |
|
829 |
lines[1] = QLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2); |
|
830 |
painter->drawLines(lines, 2); |
|
831 |
||
832 |
painter->setPen(oldPen); |
|
833 |
} |
|
834 |
||
835 |
static void qt_plastique_drawShadedPanel(QPainter *painter, const QStyleOption *option, bool base, |
|
836 |
const QWidget *widget) |
|
837 |
{ |
|
838 |
QRect rect = option->rect; |
|
839 |
QPen oldPen = painter->pen(); |
|
840 |
||
841 |
QColor gradientStartColor = option->palette.button().color().lighter(104); |
|
842 |
QColor gradientStopColor = option->palette.button().color().darker(105); |
|
843 |
||
844 |
// gradient fill |
|
845 |
if ((option->state & QStyle::State_Enabled) || !(option->state & QStyle::State_AutoRaise)) { |
|
846 |
if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) { |
|
847 |
qt_plastique_draw_gradient(painter, rect.adjusted(1, 1, -1, -1), |
|
848 |
option->palette.button().color().darker(114), |
|
849 |
option->palette.button().color().darker(106)); |
|
850 |
} else { |
|
851 |
qt_plastique_draw_gradient(painter, rect.adjusted(1, 1, -1, -1), |
|
852 |
base ? option->palette.background().color().lighter(105) : gradientStartColor, |
|
853 |
base ? option->palette.background().color().darker(102) : gradientStopColor); |
|
854 |
} |
|
855 |
} |
|
856 |
||
857 |
qt_plastique_drawFrame(painter, option, widget); |
|
858 |
||
859 |
painter->setPen(oldPen); |
|
860 |
} |
|
861 |
||
862 |
static void qt_plastique_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken) |
|
863 |
{ |
|
864 |
if (tmp.isNull()) |
|
865 |
return; |
|
866 |
bool active = (option->titleBarState & QStyle::State_Active); |
|
867 |
||
868 |
// ### use palette colors instead |
|
869 |
QColor mdiButtonGradientStartColor; |
|
870 |
QColor mdiButtonGradientStopColor; |
|
871 |
if (active) { |
|
872 |
mdiButtonGradientStartColor = QColor((hover || sunken) ? 0x7d8bb1 : 0x55689a); |
|
873 |
mdiButtonGradientStopColor = QColor((hover || sunken) ? 0x939ebe : 0x7381ab); |
|
874 |
} else { |
|
875 |
mdiButtonGradientStartColor = QColor((hover || sunken) ? 0x9e9e9e : 0x818181); |
|
876 |
mdiButtonGradientStopColor = QColor((hover || sunken) ? 0xababab : 0x929292); |
|
877 |
} |
|
878 |
||
879 |
qt_plastique_draw_gradient(painter, tmp.adjusted(1, 1, -1, -1), |
|
880 |
mdiButtonGradientStartColor, mdiButtonGradientStopColor); |
|
881 |
||
882 |
QColor mdiButtonBorderColor; |
|
883 |
if (active) { |
|
884 |
mdiButtonBorderColor = (hover || sunken) ? QColor(0x627097) : QColor(0x324577); |
|
885 |
} else { |
|
886 |
mdiButtonBorderColor = (hover || sunken) ? QColor(0x838383) : QColor(0x5e5e5e); |
|
887 |
} |
|
888 |
painter->setPen(QPen(mdiButtonBorderColor, 1)); |
|
889 |
||
890 |
const QLine lines[4] = { |
|
891 |
QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()), |
|
892 |
QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()), |
|
893 |
QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2), |
|
894 |
QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2) }; |
|
895 |
painter->drawLines(lines, 4); |
|
896 |
||
897 |
const QPoint points[4] = { |
|
898 |
QPoint(tmp.left() + 1, tmp.top() + 1), |
|
899 |
QPoint(tmp.right() - 1, tmp.top() + 1), |
|
900 |
QPoint(tmp.left() + 1, tmp.bottom() - 1), |
|
901 |
QPoint(tmp.right() - 1, tmp.bottom() - 1) }; |
|
902 |
painter->drawPoints(points, 4); |
|
903 |
} |
|
904 |
||
905 |
#ifndef QT_NO_DOCKWIDGET |
|
906 |
static QString elliditide(const QString &text, const QFontMetrics &fontMetrics, const QRect &rect, int *textWidth = 0) |
|
907 |
{ |
|
908 |
// Chop and insert ellide into title if text is too wide |
|
909 |
QString title = text; |
|
910 |
int width = textWidth ? *textWidth : fontMetrics.width(text); |
|
911 |
QString ellipsis = QLatin1String("..."); |
|
912 |
if (width > rect.width()) { |
|
913 |
QString leftHalf = title.left(title.size() / 2); |
|
914 |
QString rightHalf = title.mid(leftHalf.size() + 1); |
|
915 |
while (!leftHalf.isEmpty() && !rightHalf.isEmpty()) { |
|
916 |
leftHalf.chop(1); |
|
917 |
int width = fontMetrics.width(leftHalf + ellipsis + rightHalf); |
|
918 |
if (width < rect.width()) { |
|
919 |
title = leftHalf + ellipsis + rightHalf; |
|
920 |
width = width; |
|
921 |
break; |
|
922 |
} |
|
923 |
rightHalf.remove(0, 1); |
|
924 |
width = fontMetrics.width(leftHalf + ellipsis + rightHalf); |
|
925 |
if (width < rect.width()) { |
|
926 |
title = leftHalf + ellipsis + rightHalf; |
|
927 |
width = width; |
|
928 |
break; |
|
929 |
} |
|
930 |
} |
|
931 |
} |
|
932 |
if (textWidth) |
|
933 |
*textWidth = width; |
|
934 |
return title; |
|
935 |
} |
|
936 |
#endif |
|
937 |
||
938 |
#if !defined(QT_NO_DOCKWIDGET) || !defined(QT_NO_SPLITTER) |
|
939 |
static void qt_plastique_draw_handle(QPainter *painter, const QStyleOption *option, |
|
940 |
const QRect &rect, Qt::Orientation orientation, |
|
941 |
const QWidget *widget) |
|
942 |
{ |
|
943 |
QColor borderColor = option->palette.background().color().darker(178); |
|
944 |
QColor alphaCornerColor; |
|
945 |
if (widget) { |
|
946 |
// ### backgroundrole/foregroundrole should be part of the style option |
|
947 |
alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor); |
|
948 |
} else { |
|
949 |
alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); |
|
950 |
} |
|
951 |
QImage handle(qt_simple_toolbarhandle); |
|
952 |
alphaCornerColor.setAlpha(170); |
|
953 |
handle.setColor(1, alphaCornerColor.rgba()); |
|
954 |
handle.setColor(2, mergedColors(alphaCornerColor, option->palette.light().color()).rgba()); |
|
955 |
handle.setColor(3, option->palette.light().color().rgba()); |
|
956 |
||
957 |
const int spacing = 2; |
|
958 |
||
959 |
if (orientation == Qt::Vertical) { |
|
960 |
int nchunks = rect.width() / (handle.width() + spacing); |
|
961 |
for (int i = 0; i < nchunks; ++i) |
|
962 |
painter->drawImage(QPoint(rect.left() + i * (handle.width() + spacing), rect.top()), handle); |
|
963 |
} else { |
|
964 |
int nchunks = rect.height() / (handle.height() + spacing); |
|
965 |
for (int i = 0; i < nchunks; ++i) |
|
966 |
painter->drawImage(QPoint(rect.left(), rect.top() + i * (handle.height() + spacing)), handle); |
|
967 |
} |
|
968 |
} |
|
969 |
#endif |
|
970 |
||
971 |
class QPlastiqueStylePrivate : public QWindowsStylePrivate |
|
972 |
{ |
|
973 |
Q_DECLARE_PUBLIC(QPlastiqueStyle) |
|
974 |
public: |
|
975 |
QPlastiqueStylePrivate(); |
|
976 |
virtual ~QPlastiqueStylePrivate(); |
|
977 |
void drawPartialFrame(QPainter *painter, const QStyleOptionComplex *option, |
|
978 |
const QRect &rect, const QWidget *widget) const; |
|
979 |
||
980 |
#ifndef QT_NO_PROGRESSBAR |
|
981 |
QList<QProgressBar *> bars; |
|
982 |
int progressBarAnimateTimer; |
|
983 |
QTime timer; |
|
984 |
#endif |
|
985 |
}; |
|
986 |
||
987 |
/*! |
|
988 |
\internal |
|
989 |
*/ |
|
990 |
QPlastiqueStylePrivate::QPlastiqueStylePrivate() : |
|
991 |
QWindowsStylePrivate() |
|
992 |
#ifndef QT_NO_PROGRESSBAR |
|
993 |
, progressBarAnimateTimer(0) |
|
994 |
#endif |
|
995 |
{ |
|
996 |
} |
|
997 |
||
998 |
/*! |
|
999 |
\internal |
|
1000 |
*/ |
|
1001 |
QPlastiqueStylePrivate::~QPlastiqueStylePrivate() |
|
1002 |
{ |
|
1003 |
} |
|
1004 |
||
1005 |
/*! |
|
1006 |
\class QPlastiqueStyle |
|
1007 |
\brief The QPlastiqueStyle class provides a widget style similar to the |
|
1008 |
Plastik style available in KDE. |
|
1009 |
||
1010 |
The Plastique style provides a default look and feel for widgets on X11 |
|
1011 |
that closely resembles the Plastik style, introduced by Sandro Giessl in |
|
1012 |
KDE 3.2. |
|
1013 |
||
1014 |
\img qplastiquestyle.png |
|
1015 |
\sa QWindowsXPStyle, QMacStyle, QWindowsStyle, QCDEStyle, QMotifStyle |
|
1016 |
*/ |
|
1017 |
||
1018 |
/*! |
|
1019 |
Constructs a QPlastiqueStyle object. |
|
1020 |
*/ |
|
1021 |
QPlastiqueStyle::QPlastiqueStyle() |
|
1022 |
: QWindowsStyle(*new QPlastiqueStylePrivate) |
|
1023 |
{ |
|
1024 |
setObjectName(QLatin1String("Plastique")); |
|
1025 |
} |
|
1026 |
||
1027 |
/*! |
|
1028 |
Destructs the QPlastiqueStyle object. |
|
1029 |
*/ |
|
1030 |
QPlastiqueStyle::~QPlastiqueStyle() |
|
1031 |
{ |
|
1032 |
} |
|
1033 |
||
1034 |
/* |
|
1035 |
Used by spin- and combo box. |
|
1036 |
Draws a rounded frame around rect but omits the right hand edge |
|
1037 |
*/ |
|
1038 |
void QPlastiqueStylePrivate::drawPartialFrame(QPainter *painter, const QStyleOptionComplex *option, |
|
1039 |
const QRect &rect, const QWidget *widget) const |
|
1040 |
{ |
|
1041 |
Q_Q(const QPlastiqueStyle); |
|
1042 |
bool reverse = option->direction == Qt::RightToLeft; |
|
1043 |
QStyleOptionFrame frameOpt; |
|
1044 |
#ifndef QT_NO_LINEEDIT |
|
1045 |
if (QLineEdit *lineedit = qFindChild<QLineEdit *>(widget)) |
|
1046 |
frameOpt.initFrom(lineedit); |
|
1047 |
#else |
|
1048 |
Q_UNUSED(widget) |
|
1049 |
#endif // QT_NO_LINEEDIT |
|
1050 |
||
1051 |
frameOpt.rect = rect; |
|
1052 |
painter->save(); |
|
1053 |
frameOpt.rect.adjust(-blueFrameWidth + (reverse ? 1 : 0), -blueFrameWidth, |
|
1054 |
blueFrameWidth + (reverse ? 0 : -1), blueFrameWidth); |
|
1055 |
painter->setClipRect(frameOpt.rect); |
|
1056 |
frameOpt.rect.adjust(reverse ? -2 : 0, 0, reverse ? 0 : 2, 0); |
|
1057 |
frameOpt.lineWidth = q->pixelMetric(QStyle::PM_DefaultFrameWidth); |
|
1058 |
frameOpt.midLineWidth = 0; |
|
1059 |
frameOpt.state = option->state | QStyle::State_Sunken; |
|
1060 |
frameOpt.palette = option->palette; |
|
1061 |
q->drawPrimitive(QStyle::PE_PanelLineEdit, &frameOpt, painter, widget); |
|
1062 |
painter->restore(); |
|
1063 |
||
1064 |
// Draw a two pixel highlight on the flat edge |
|
1065 |
if (option->state & QStyle::State_HasFocus) { |
|
1066 |
painter->setPen(QPen(option->palette.highlight(), 0)); |
|
1067 |
QBrush focusBorder = option->palette.highlight(); |
|
1068 |
qBrushSetAlphaF(&focusBorder, qreal(0.65)); |
|
1069 |
if (!reverse) { |
|
1070 |
painter->drawLine(rect.topRight() + QPoint(1, -1), |
|
1071 |
rect.bottomRight() + QPoint(1, 1)); |
|
1072 |
painter->setPen(QPen(focusBorder, 0)); |
|
1073 |
painter->drawLine(rect.topRight(), |
|
1074 |
rect.bottomRight()); |
|
1075 |
} |
|
1076 |
else { |
|
1077 |
painter->drawLine(rect.topLeft() + QPoint(-1, -1), |
|
1078 |
rect.bottomLeft() + QPoint(-1, 1)); |
|
1079 |
painter->setPen(QPen(focusBorder, 0)); |
|
1080 |
painter->drawLine(rect.topLeft(), |
|
1081 |
rect.bottomLeft()); |
|
1082 |
} |
|
1083 |
} |
|
1084 |
} |
|
1085 |
||
1086 |
/*! |
|
1087 |
\reimp |
|
1088 |
*/ |
|
1089 |
void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, |
|
1090 |
QPainter *painter, const QWidget *widget) const |
|
1091 |
{ |
|
1092 |
Q_ASSERT(option); |
|
1093 |
||
1094 |
QColor borderColor = option->palette.background().color().darker(178); |
|
1095 |
QColor gradientStartColor = option->palette.button().color().lighter(104); |
|
1096 |
QColor gradientStopColor = option->palette.button().color().darker(105); |
|
1097 |
QColor highlightedGradientStartColor = option->palette.button().color().lighter(101); |
|
1098 |
QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85); |
|
1099 |
QColor highlightedBaseGradientStartColor = option->palette.base().color(); |
|
1100 |
QColor highlightedBaseGradientStopColor = mergedColors(option->palette.base().color().darker(105), option->palette.highlight().color(), 70); |
|
1101 |
QColor highlightedDarkInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 35); |
|
1102 |
QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58); |
|
1103 |
QColor alphaCornerColor; |
|
1104 |
if (widget) { |
|
1105 |
// ### backgroundrole/foregroundrole should be part of the style option |
|
1106 |
alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor); |
|
1107 |
} else { |
|
1108 |
alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); |
|
1109 |
} |
|
1110 |
QColor alphaInnerColor = mergedColors(highlightedLightInnerBorderColor, gradientStartColor); |
|
1111 |
QColor alphaInnerColorNoHover = mergedColors(borderColor, gradientStartColor); |
|
1112 |
QColor alphaTextColor = mergedColors(option->palette.background().color(), option->palette.text().color()); |
|
1113 |
QColor alphaLightTextColor = mergedColors(option->palette.background().color().lighter(250), option->palette.text().color().lighter(250)); |
|
1114 |
QColor lightShadow = option->palette.button().color().lighter(105); |
|
1115 |
QColor shadowGradientStartColor = option->palette.button().color().darker(115); |
|
1116 |
QColor shadow = shadowGradientStartColor; |
|
1117 |
||
1118 |
switch (element) { |
|
1119 |
case PE_IndicatorButtonDropDown: |
|
1120 |
proxy()->drawPrimitive(PE_PanelButtonTool, option, painter, widget); |
|
1121 |
break; |
|
1122 |
case PE_FrameDefaultButton: { |
|
1123 |
if (!(option->state & QStyle::State_Enabled)) |
|
1124 |
break; |
|
1125 |
painter->setPen(QPen(QColor(0, 0, 0, 127), 0)); |
|
1126 |
const QLine lines[4] = { |
|
1127 |
QLine(option->rect.left() + 2, option->rect.top(), |
|
1128 |
option->rect.right() - 2, option->rect.top()), |
|
1129 |
QLine(option->rect.left() + 2, option->rect.bottom(), |
|
1130 |
option->rect.right() - 2, option->rect.bottom()), |
|
1131 |
QLine(option->rect.left(), option->rect.top() + 2, |
|
1132 |
option->rect.left(), option->rect.bottom() - 2), |
|
1133 |
QLine(option->rect.right(), option->rect.top() + 2, |
|
1134 |
option->rect.right(), option->rect.bottom() - 2) }; |
|
1135 |
painter->drawLines(lines, 4); |
|
1136 |
||
1137 |
QPoint points[8]; |
|
1138 |
points[0] = QPoint(option->rect.left() + 1, option->rect.top() + 1); |
|
1139 |
points[1] = QPoint(option->rect.right() - 1, option->rect.top() + 1); |
|
1140 |
points[2] = QPoint(option->rect.left() + 1, option->rect.bottom() - 1); |
|
1141 |
points[3] = QPoint(option->rect.right() - 1, option->rect.bottom() - 1); |
|
1142 |
painter->drawPoints(points, 4); |
|
1143 |
||
1144 |
painter->setPen(QPen(QColor(0, 0, 0, 63), 0)); |
|
1145 |
points[0] = QPoint(option->rect.left() + 1, option->rect.top()); |
|
1146 |
points[1] = QPoint(option->rect.right() - 1, option->rect.top()); |
|
1147 |
points[2] = QPoint(option->rect.left(), option->rect.top() + 1); |
|
1148 |
points[3] = QPoint(option->rect.right(), option->rect.top() + 1); |
|
1149 |
points[4] = QPoint(option->rect.left() + 1, option->rect.bottom()); |
|
1150 |
points[5] = QPoint(option->rect.right() - 1, option->rect.bottom()); |
|
1151 |
points[6] = QPoint(option->rect.left(), option->rect.bottom() - 1); |
|
1152 |
points[7] = QPoint(option->rect.right(), option->rect.bottom() - 1); |
|
1153 |
painter->drawPoints(points, 8); |
|
1154 |
||
1155 |
break; |
|
1156 |
} |
|
1157 |
#ifndef QT_NO_TABWIDGET |
|
1158 |
case PE_FrameTabWidget: |
|
1159 |
if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) { |
|
1160 |
if (twf->shape != QTabBar::RoundedNorth && twf->shape != QTabBar::RoundedWest && |
|
1161 |
twf->shape != QTabBar::RoundedSouth && twf->shape != QTabBar::RoundedEast) { |
|
1162 |
QWindowsStyle::drawPrimitive(element, option, painter, widget); |
|
1163 |
break; |
|
1164 |
} |
|
1165 |
||
1166 |
int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, twf, widget); |
|
1167 |
bool reverse = (twf->direction == Qt::RightToLeft); |
|
1168 |
||
1169 |
painter->save(); |
|
1170 |
||
1171 |
// Start by filling the contents of the tab widget frame (which is |
|
1172 |
// actually a panel). |
|
1173 |
painter->fillRect(option->rect.adjusted(1, 1, -1, -1), option->palette.window()); |
|
1174 |
||
1175 |
QRect tabBarRect; |
|
1176 |
switch (twf->shape) { |
|
1177 |
case QTabBar::RoundedNorth: |
|
1178 |
if (reverse) |
|
1179 |
tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width() - twf->tabBarSize.width() + 1, twf->rect.top(), twf->tabBarSize.width(), borderThickness); |
|
1180 |
else |
|
1181 |
tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(), twf->rect.top(), twf->tabBarSize.width(), borderThickness); |
|
1182 |
break ; |
|
1183 |
case QTabBar::RoundedWest: |
|
1184 |
tabBarRect = QRect(twf->rect.left(), twf->rect.top() + twf->leftCornerWidgetSize.height(), borderThickness, twf->tabBarSize.height()); |
|
1185 |
break ; |
|
1186 |
case QTabBar::RoundedEast: |
|
1187 |
tabBarRect = QRect(twf->rect.right() - borderThickness + 1, twf->rect.top() + twf->leftCornerWidgetSize.height(), |
|
1188 |
borderThickness, twf->tabBarSize.height()); |
|
1189 |
break ; |
|
1190 |
case QTabBar::RoundedSouth: |
|
1191 |
if (reverse) |
|
1192 |
tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width() - twf->tabBarSize.width() + 1, |
|
1193 |
twf->rect.bottom() - borderThickness + 1, twf->tabBarSize.width(), borderThickness); |
|
1194 |
else |
|
1195 |
tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(), |
|
1196 |
twf->rect.bottom() - borderThickness + 1, twf->tabBarSize.width(), borderThickness); |
|
1197 |
break ; |
|
1198 |
default: |
|
1199 |
break; |
|
1200 |
} |
|
1201 |
||
1202 |
QRegion region(twf->rect); |
|
1203 |
region -= tabBarRect; |
|
1204 |
painter->setClipRegion(region); |
|
1205 |
||
1206 |
// Outer border |
|
1207 |
QLine leftLine = QLine(twf->rect.topLeft() + QPoint(0, 2), twf->rect.bottomLeft() - QPoint(0, 2)); |
|
1208 |
QLine rightLine = QLine(twf->rect.topRight() + QPoint(0, 2), twf->rect.bottomRight() - QPoint(0, 2)); |
|
1209 |
QLine bottomLine = QLine(twf->rect.bottomLeft() + QPoint(2, 0), twf->rect.bottomRight() - QPoint(2, 0)); |
|
1210 |
QLine topLine = QLine(twf->rect.topLeft() + QPoint(2, 0), twf->rect.topRight() - QPoint(2, 0)); |
|
1211 |
||
1212 |
QBrush border = option->palette.shadow(); |
|
1213 |
qBrushSetAlphaF(&border, qreal(0.4)); |
|
1214 |
painter->setPen(QPen(border, 0)); |
|
1215 |
||
1216 |
QVarLengthArray<QLine, 4> lines; |
|
1217 |
QVarLengthArray<QPoint, 8> points; |
|
1218 |
||
1219 |
lines.append(topLine); |
|
1220 |
||
1221 |
// Inner border |
|
1222 |
QLine innerLeftLine = QLine(leftLine.p1() + QPoint(1, 0), leftLine.p2() + QPoint(1, 0)); |
|
1223 |
QLine innerRightLine = QLine(rightLine.p1() - QPoint(1, 0), rightLine.p2() - QPoint(1, 0)); |
|
1224 |
QLine innerBottomLine = QLine(bottomLine.p1() - QPoint(0, 1), bottomLine.p2() - QPoint(0, 1)); |
|
1225 |
QLine innerTopLine = QLine(topLine.p1() + QPoint(0, 1), topLine.p2() + QPoint(0, 1)); |
|
1226 |
||
1227 |
// Rounded Corner |
|
1228 |
QPoint leftBottomOuterCorner = QPoint(innerLeftLine.p2() + QPoint(0, 1)); |
|
1229 |
QPoint leftBottomInnerCorner1 = QPoint(leftLine.p2() + QPoint(0, 1)); |
|
1230 |
QPoint leftBottomInnerCorner2 = QPoint(bottomLine.p1() - QPoint(1, 0)); |
|
1231 |
QPoint rightBottomOuterCorner = QPoint(innerRightLine.p2() + QPoint(0, 1)); |
|
1232 |
QPoint rightBottomInnerCorner1 = QPoint(rightLine.p2() + QPoint(0, 1)); |
|
1233 |
QPoint rightBottomInnerCorner2 = QPoint(bottomLine.p2() + QPoint(1, 0)); |
|
1234 |
QPoint rightTopOuterCorner = QPoint(innerRightLine.p1() - QPoint(0, 1)); |
|
1235 |
QPoint rightTopInnerCorner1 = QPoint(rightLine.p1() - QPoint(0, 1)); |
|
1236 |
QPoint rightTopInnerCorner2 = QPoint(topLine.p2() + QPoint(1, 0)); |
|
1237 |
QPoint leftTopOuterCorner = QPoint(innerLeftLine.p1() - QPoint(0, 1)); |
|
1238 |
QPoint leftTopInnerCorner1 = QPoint(leftLine.p1() - QPoint(0, 1)); |
|
1239 |
QPoint leftTopInnerCorner2 = QPoint(topLine.p1() - QPoint(1, 0)); |
|
1240 |
||
1241 |
lines.append(leftLine); |
|
1242 |
lines.append(rightLine); |
|
1243 |
lines.append(bottomLine); |
|
1244 |
||
1245 |
painter->drawLines(lines.constData(), lines.size()); |
|
1246 |
lines.clear(); |
|
1247 |
||
1248 |
points.append(leftBottomOuterCorner); |
|
1249 |
points.append(rightBottomOuterCorner); |
|
1250 |
points.append(rightTopOuterCorner); |
|
1251 |
points.append(leftTopOuterCorner); |
|
1252 |
||
1253 |
painter->drawPoints(points.constData(), points.size()); |
|
1254 |
points.clear(); |
|
1255 |
||
1256 |
QBrush innerTopLeft = option->palette.shadow(); |
|
1257 |
qBrushSetAlphaF(&innerTopLeft, qreal(0.075)); |
|
1258 |
painter->setPen(QPen(innerTopLeft, 0)); |
|
1259 |
||
1260 |
lines.append(innerLeftLine); |
|
1261 |
lines.append(innerTopLine); |
|
1262 |
painter->drawLines(lines.constData(), lines.size()); |
|
1263 |
lines.clear(); |
|
1264 |
||
1265 |
QBrush innerBottomRight = option->palette.shadow(); |
|
1266 |
qBrushSetAlphaF(&innerBottomRight, qreal(0.23)); |
|
1267 |
painter->setPen(QPen(innerBottomRight, 0)); |
|
1268 |
lines.append(innerRightLine); |
|
1269 |
lines.append(innerBottomLine); |
|
1270 |
painter->drawLines(lines.constData(), lines.size()); |
|
1271 |
lines.clear(); |
|
1272 |
||
1273 |
QBrush corner = option->palette.shadow(); |
|
1274 |
qBrushSetAlphaF(&corner, 0.25); |
|
1275 |
painter->setPen(QPen(corner, 0)); |
|
1276 |
points.append(leftBottomInnerCorner1); |
|
1277 |
points.append(leftBottomInnerCorner2); |
|
1278 |
points.append(rightBottomInnerCorner1); |
|
1279 |
points.append(rightBottomInnerCorner2); |
|
1280 |
points.append(rightTopInnerCorner1); |
|
1281 |
points.append(rightTopInnerCorner2); |
|
1282 |
points.append(leftTopInnerCorner1); |
|
1283 |
points.append(leftTopInnerCorner2); |
|
1284 |
painter->drawPoints(points.constData(), points.size()); |
|
1285 |
points.clear(); |
|
1286 |
||
1287 |
painter->restore(); |
|
1288 |
} |
|
1289 |
break ; |
|
1290 |
#endif // QT_NO_TABWIDGET |
|
1291 |
#ifndef QT_NO_TABBAR |
|
1292 |
case PE_FrameTabBarBase: |
|
1293 |
if (const QStyleOptionTabBarBase *tbb = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) { |
|
1294 |
if (tbb->shape != QTabBar::RoundedNorth && tbb->shape != QTabBar::RoundedWest && |
|
1295 |
tbb->shape != QTabBar::RoundedSouth && tbb->shape != QTabBar::RoundedEast) { |
|
1296 |
QWindowsStyle::drawPrimitive(element, option, painter, widget); |
|
1297 |
break; |
|
1298 |
} |
|
1299 |
||
1300 |
painter->save(); |
|
1301 |
||
1302 |
QRegion region(tbb->rect); |
|
1303 |
region -= tbb->tabBarRect; |
|
1304 |
painter->setClipRegion(region); |
|
1305 |
||
1306 |
QLine topLine = QLine(tbb->rect.bottomLeft() - QPoint(0, 1), tbb->rect.bottomRight() - QPoint(0, 1)); |
|
1307 |
QLine bottomLine = QLine(tbb->rect.bottomLeft(), tbb->rect.bottomRight()); |
|
1308 |
||
1309 |
QBrush border = option->palette.shadow(); |
|
1310 |
qBrushSetAlphaF(&border, qreal(0.4)); |
|
1311 |
QBrush innerTopLeft = option->palette.shadow(); |
|
1312 |
qBrushSetAlphaF(&innerTopLeft, qreal(0.075)); |
|
1313 |
QBrush innerBottomRight = option->palette.shadow(); |
|
1314 |
qBrushSetAlphaF(&innerBottomRight, qreal(0.23)); |
|
1315 |
QBrush corner = option->palette.shadow(); |
|
1316 |
qBrushSetAlphaF(&corner, 0.25); |
|
1317 |
||
1318 |
if (tbb->shape == QTabBar::RoundedSouth) |
|
1319 |
painter->setPen(QPen(corner, 0)); |
|
1320 |
else |
|
1321 |
painter->setPen(QPen(border, 0)); |
|
1322 |
painter->drawLine(topLine); |
|
1323 |
||
1324 |
if (tbb->shape != QTabBar::RoundedSouth) |
|
1325 |
painter->setPen(QPen(innerTopLeft, 0)); |
|
1326 |
else |
|
1327 |
painter->setPen(QPen(border, 0)); |
|
1328 |
painter->drawLine(bottomLine); |
|
1329 |
||
1330 |
painter->restore(); |
|
1331 |
} |
|
1332 |
break ; |
|
1333 |
#endif // QT_NO_TABBAR |
|
1334 |
#ifndef QT_NO_GROUPBOX |
|
1335 |
case PE_FrameGroupBox: |
|
1336 |
if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
|
1337 |
QStyleOptionFrameV2 frameV2(*frame); |
|
1338 |
if (frameV2.features & QStyleOptionFrameV2::Flat) { |
|
1339 |
QPen oldPen = painter->pen(); |
|
1340 |
painter->setPen(borderColor); |
|
1341 |
painter->drawLine(frameV2.rect.topLeft(), frameV2.rect.topRight()); |
|
1342 |
painter->setPen(oldPen); |
|
1343 |
} else { |
|
1344 |
frameV2.state &= ~(State_Sunken | State_HasFocus); |
|
1345 |
proxy()->drawPrimitive(PE_Frame, &frameV2, painter, widget); |
|
1346 |
} |
|
1347 |
} |
|
1348 |
break; |
|
1349 |
#endif // QT_NO_GROUPBOX |
|
1350 |
case PE_Frame: { |
|
1351 |
QFrame::Shadow shadow = QFrame::Plain; |
|
1352 |
if (option->state & State_Sunken) |
|
1353 |
shadow = QFrame::Sunken; |
|
1354 |
else if (option->state & State_Raised) |
|
1355 |
shadow = QFrame::Raised; |
|
1356 |
qt_plastique_draw_frame(painter, option->rect, option, shadow); |
|
1357 |
break; |
|
1358 |
} |
|
1359 |
#ifndef QT_NO_LINEEDIT |
|
1360 |
case PE_FrameLineEdit: |
|
1361 |
qt_plastique_draw_frame(painter, option->rect, option, QFrame::Sunken); |
|
1362 |
break; |
|
1363 |
case PE_PanelLineEdit: |
|
1364 |
if (const QStyleOptionFrame *lineEdit = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
|
1365 |
// Panel of a line edit inside combo box or spin box is drawn in CC_ComboBox and CC_SpinBox |
|
1366 |
if (widget) { |
|
1367 |
#ifndef QT_NO_COMBOBOX |
|
1368 |
if (qobject_cast<const QComboBox *>(widget->parentWidget())) |
|
1369 |
break; |
|
1370 |
#endif |
|
1371 |
#ifndef QT_NO_SPINBOX |
|
1372 |
if (qobject_cast<const QAbstractSpinBox *>(widget->parentWidget())) |
|
1373 |
break; |
|
1374 |
#endif |
|
1375 |
} |
|
1376 |
||
1377 |
painter->save(); |
|
1378 |
||
1379 |
// Fill the line edit insides |
|
1380 |
QRect filledRect = lineEdit->rect.adjusted(1, 1, -1, -1); |
|
1381 |
QBrush baseBrush = qMapBrushToRect(lineEdit->palette.base(), filledRect); |
|
1382 |
painter->setBrushOrigin(filledRect.topLeft()); |
|
1383 |
painter->fillRect(filledRect.adjusted(1, 1, -1, -1), baseBrush); |
|
1384 |
||
1385 |
painter->setPen(QPen(baseBrush, 0)); |
|
1386 |
const QLine lines[4] = { |
|
1387 |
QLine(filledRect.left(), filledRect.top() + 1, |
|
1388 |
filledRect.left(), filledRect.bottom() - 1), |
|
1389 |
QLine(filledRect.right(), filledRect.top() + 1, |
|
1390 |
filledRect.right(), filledRect.bottom() - 1), |
|
1391 |
QLine(filledRect.left() + 1, filledRect.top(), |
|
1392 |
filledRect.right() - 1, filledRect.top()), |
|
1393 |
QLine(filledRect.left() + 1, filledRect.bottom(), |
|
1394 |
filledRect.right() - 1, filledRect.bottom()) }; |
|
1395 |
painter->drawLines(lines, 4); |
|
1396 |
||
1397 |
if (lineEdit->lineWidth != 0) |
|
1398 |
qt_plastique_draw_frame(painter, option->rect, option, QFrame::Sunken); |
|
1399 |
||
1400 |
painter->restore(); |
|
1401 |
break; |
|
1402 |
} |
|
1403 |
#endif // QT_NO_LINEEDIT |
|
1404 |
case PE_FrameDockWidget: |
|
1405 |
case PE_FrameMenu: |
|
1406 |
case PE_FrameStatusBarItem: { |
|
1407 |
// Draws the frame around a popup menu. |
|
1408 |
QPen oldPen = painter->pen(); |
|
1409 |
painter->setPen(borderColor); |
|
1410 |
painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); |
|
1411 |
painter->setPen(alphaCornerColor); |
|
1412 |
const QPoint points[4] = { |
|
1413 |
QPoint(option->rect.topLeft()), |
|
1414 |
QPoint(option->rect.topRight()), |
|
1415 |
QPoint(option->rect.bottomLeft()), |
|
1416 |
QPoint(option->rect.bottomRight()) }; |
|
1417 |
painter->drawPoints(points, 4); |
|
1418 |
painter->setPen(oldPen); |
|
1419 |
break; |
|
1420 |
} |
|
1421 |
#ifdef QT3_SUPPORT |
|
1422 |
case PE_Q3DockWindowSeparator: { |
|
1423 |
QPen oldPen = painter->pen(); |
|
1424 |
painter->setPen(alphaCornerColor); |
|
1425 |
QRect rect = option->rect; |
|
1426 |
if (option->state & State_Horizontal) { |
|
1427 |
painter->drawLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 1); |
|
1428 |
} else { |
|
1429 |
painter->drawLine(rect.left() + 2, rect.bottom(), rect.right() - 1, rect.bottom()); |
|
1430 |
} |
|
1431 |
painter->setPen(oldPen); |
|
1432 |
break; |
|
1433 |
} |
|
1434 |
case PE_Q3Separator: { |
|
1435 |
QPen oldPen = painter->pen(); |
|
1436 |
painter->setPen(alphaCornerColor); |
|
1437 |
if ((option->state & State_Horizontal) == 0) |
|
1438 |
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); |
|
1439 |
else |
|
1440 |
painter->drawLine(option->rect.topRight(), option->rect.bottomRight()); |
|
1441 |
painter->setPen(option->palette.background().color().lighter(104)); |
|
1442 |
if ((option->state & State_Horizontal) == 0) |
|
1443 |
painter->drawLine(option->rect.topLeft(), option->rect.topRight()); |
|
1444 |
else |
|
1445 |
painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft()); |
|
1446 |
painter->setPen(oldPen); |
|
1447 |
break; |
|
1448 |
} |
|
1449 |
#endif // QT3_SUPPORT |
|
1450 |
#ifndef QT_NO_MAINWINDOW |
|
1451 |
case PE_PanelMenuBar: |
|
1452 |
if ((widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) |
|
1453 |
#ifdef QT3_SUPPORT |
|
1454 |
|| (widget && widget->parentWidget() && widget->parentWidget()->inherits("Q3MainWindow")) |
|
1455 |
#endif |
|
1456 |
) { |
|
1457 |
// Draws the light line above and the dark line below menu bars and |
|
1458 |
// tool bars. |
|
1459 |
QPen oldPen = painter->pen(); |
|
1460 |
if (element == PE_PanelMenuBar || (option->state & State_Horizontal)) { |
|
1461 |
painter->setPen(alphaCornerColor); |
|
1462 |
painter->drawLine(option->rect.left(), option->rect.bottom(), |
|
1463 |
option->rect.right(), option->rect.bottom()); |
|
1464 |
painter->setPen(option->palette.background().color().lighter(104)); |
|
1465 |
painter->drawLine(option->rect.left(), option->rect.top(), |
|
1466 |
option->rect.right(), option->rect.top()); |
|
1467 |
} else { |
|
1468 |
painter->setPen(option->palette.background().color().lighter(104)); |
|
1469 |
painter->drawLine(option->rect.left(), option->rect.top(), |
|
1470 |
option->rect.left(), option->rect.bottom()); |
|
1471 |
painter->setPen(alphaCornerColor); |
|
1472 |
painter->drawLine(option->rect.right(), option->rect.top(), |
|
1473 |
option->rect.right(), option->rect.bottom()); |
|
1474 |
} |
|
1475 |
painter->setPen(oldPen); |
|
1476 |
} |
|
1477 |
break; |
|
1478 |
#endif // QT_NO_MAINWINDOW |
|
1479 |
case PE_IndicatorHeaderArrow: { |
|
1480 |
bool usedAntialiasing = painter->renderHints() & QPainter::Antialiasing; |
|
1481 |
if (!usedAntialiasing) |
|
1482 |
painter->setRenderHint(QPainter::Antialiasing); |
|
1483 |
QWindowsStyle::drawPrimitive(element, option, painter, widget); |
|
1484 |
if (!usedAntialiasing) |
|
1485 |
painter->setRenderHint(QPainter::Antialiasing, false); |
|
1486 |
break; |
|
1487 |
} |
|
1488 |
case PE_PanelButtonTool: |
|
1489 |
// Draws a tool button (f.ex., in QToolBar and QTabBar) |
|
1490 |
if ((option->state & State_Enabled || option->state & State_On) || !(option->state & State_AutoRaise)) |
|
1491 |
qt_plastique_drawShadedPanel(painter, option, true, widget); |
|
1492 |
break; |
|
1493 |
#ifndef QT_NO_TOOLBAR |
|
1494 |
case PE_IndicatorToolBarHandle: { |
|
1495 |
QPixmap cache; |
|
1496 |
QRect rect = option->rect; |
|
1497 |
#ifdef QT3_SUPPORT |
|
1498 |
if (widget && widget->inherits("Q3DockWindowHandle") && widget->parentWidget()->inherits("Q3DockWindow")) { |
|
1499 |
if (!(option->state & State_Horizontal)) |
|
1500 |
rect.adjust(2, 0, -2, 0); |
|
1501 |
} |
|
1502 |
#endif |
|
1503 |
QString pixmapName = QStyleHelper::uniqueName(QLatin1String("toolbarhandle"), option, rect.size()); |
|
1504 |
if (!QPixmapCache::find(pixmapName, cache)) { |
|
1505 |
cache = QPixmap(rect.size()); |
|
1506 |
cache.fill(Qt::transparent); |
|
1507 |
QPainter cachePainter(&cache); |
|
1508 |
QRect cacheRect(QPoint(0, 0), rect.size()); |
|
1509 |
if (widget) |
|
1510 |
cachePainter.fillRect(cacheRect, option->palette.brush(widget->backgroundRole())); |
|
1511 |
else |
|
1512 |
cachePainter.fillRect(cacheRect, option->palette.background()); |
|
1513 |
||
1514 |
QImage handle(qt_toolbarhandle); |
|
1515 |
alphaCornerColor.setAlpha(170); |
|
1516 |
handle.setColor(1, alphaCornerColor.rgba()); |
|
1517 |
handle.setColor(2, mergedColors(alphaCornerColor, option->palette.light().color()).rgba()); |
|
1518 |
handle.setColor(3, option->palette.light().color().rgba()); |
|
1519 |
||
1520 |
if (option->state & State_Horizontal) { |
|
1521 |
int nchunks = cacheRect.height() / handle.height(); |
|
1522 |
int indent = (cacheRect.height() - (nchunks * handle.height())) / 2; |
|
1523 |
for (int i = 0; i < nchunks; ++i) |
|
1524 |
cachePainter.drawImage(QPoint(cacheRect.left() + 3, cacheRect.top() + indent + i * handle.height()), |
|
1525 |
handle); |
|
1526 |
} else { |
|
1527 |
int nchunks = cacheRect.width() / handle.width(); |
|
1528 |
int indent = (cacheRect.width() - (nchunks * handle.width())) / 2; |
|
1529 |
for (int i = 0; i < nchunks; ++i) |
|
1530 |
cachePainter.drawImage(QPoint(cacheRect.left() + indent + i * handle.width(), cacheRect.top() + 3), |
|
1531 |
handle); |
|
1532 |
} |
|
1533 |
cachePainter.end(); |
|
1534 |
QPixmapCache::insert(pixmapName, cache); |
|
1535 |
} |
|
1536 |
painter->drawPixmap(rect.topLeft(), cache); |
|
1537 |
break; |
|
1538 |
} |
|
1539 |
case PE_IndicatorToolBarSeparator: { |
|
1540 |
QPen oldPen = painter->pen(); |
|
1541 |
painter->setPen(alphaCornerColor); |
|
1542 |
if (option->state & State_Horizontal) { |
|
1543 |
painter->drawLine(option->rect.left(), option->rect.top() + 1, option->rect.left(), option->rect.bottom() - 2); |
|
1544 |
painter->setPen(option->palette.base().color()); |
|
1545 |
painter->drawLine(option->rect.right(), option->rect.top() + 1, option->rect.right(), option->rect.bottom() - 2); |
|
1546 |
} else { |
|
1547 |
painter->drawLine(option->rect.left() + 1, option->rect.top(), option->rect.right() - 2, option->rect.top()); |
|
1548 |
painter->setPen(option->palette.base().color()); |
|
1549 |
painter->drawLine(option->rect.left() + 1, option->rect.bottom(), option->rect.right() - 2, option->rect.bottom()); |
|
1550 |
} |
|
1551 |
painter->setPen(oldPen); |
|
1552 |
break; |
|
1553 |
} |
|
1554 |
#endif // QT_NO_TOOLBAR |
|
1555 |
case PE_PanelButtonCommand: |
|
1556 |
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
1557 |
bool sunken = (button->state & State_Sunken) || (button->state & State_On); |
|
1558 |
if ((button->features & QStyleOptionButton::Flat) && !sunken) |
|
1559 |
break; |
|
1560 |
||
1561 |
bool defaultButton = (button->features & (QStyleOptionButton::DefaultButton |
|
1562 |
| QStyleOptionButton::AutoDefaultButton)); |
|
1563 |
||
1564 |
BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("pushbutton-%1").arg(defaultButton)) |
|
1565 |
||
1566 |
QPen oldPen = p->pen(); |
|
1567 |
bool hover = (button->state & State_Enabled) && (button->state & State_MouseOver); |
|
1568 |
||
1569 |
// Give the painter a different brush origin for sunken buttons |
|
1570 |
if (sunken) { |
|
1571 |
// ### No such function |
|
1572 |
// p->setPenOrigin(rect.left() + 1, rect.top() + 1); |
|
1573 |
p->setBrushOrigin(rect.left() + 1, rect.top() + 1); |
|
1574 |
} |
|
1575 |
||
1576 |
// Draw border |
|
1577 |
qt_plastique_draw_frame(p, rect, option); |
|
1578 |
||
1579 |
// Fill the panel |
|
1580 |
QRectF fillRect = rect.adjusted(2, 2, -2, -2); |
|
1581 |
||
1582 |
// Button colors |
|
1583 |
QBrush alphaCornerBrush = qMapBrushToRect(qBrushDark(option->palette.button(), 165), rect); |
|
1584 |
qBrushSetAlphaF(&alphaCornerBrush, 0.5); |
|
1585 |
QBrush buttonGradientBrush; |
|
1586 |
QBrush leftLineGradientBrush; |
|
1587 |
QBrush rightLineGradientBrush; |
|
1588 |
QBrush sunkenButtonGradientBrush; |
|
1589 |
QBrush sunkenLeftLineGradientBrush; |
|
1590 |
QBrush sunkenRightLineGradientBrush; |
|
1591 |
QBrush buttonBrush = qMapBrushToRect(option->palette.button(), rect); |
|
1592 |
if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) { |
|
1593 |
buttonGradientBrush = buttonBrush; |
|
1594 |
sunkenButtonGradientBrush = qBrushDark(buttonBrush, 108); |
|
1595 |
leftLineGradientBrush = qBrushLight(buttonBrush, 105); |
|
1596 |
rightLineGradientBrush = qBrushDark(buttonBrush, 105); |
|
1597 |
sunkenLeftLineGradientBrush = qBrushDark(buttonBrush, 110); |
|
1598 |
sunkenRightLineGradientBrush = qBrushDark(buttonBrush, 106); |
|
1599 |
} else { |
|
1600 |
// Generate gradients |
|
1601 |
QLinearGradient buttonGradient(rect.topLeft(), rect.bottomLeft()); |
|
1602 |
if (hover) { |
|
1603 |
buttonGradient.setColorAt(0.0, mergedColors(option->palette.highlight().color(), |
|
1604 |
buttonBrush.color().lighter(104), 6)); |
|
1605 |
buttonGradient.setColorAt(1.0, mergedColors(option->palette.highlight().color(), |
|
1606 |
buttonBrush.color().darker(110), 6)); |
|
1607 |
} else { |
|
1608 |
buttonGradient.setColorAt(0.0, buttonBrush.color().lighter(104)); |
|
1609 |
buttonGradient.setColorAt(1.0, buttonBrush.color().darker(110)); |
|
1610 |
} |
|
1611 |
buttonGradientBrush = QBrush(buttonGradient); |
|
1612 |
||
1613 |
QLinearGradient buttonGradient2(rect.topLeft(), rect.bottomLeft()); |
|
1614 |
buttonGradient2.setColorAt(0.0, buttonBrush.color().darker(113)); |
|
1615 |
buttonGradient2.setColorAt(1.0, buttonBrush.color().darker(103)); |
|
1616 |
sunkenButtonGradientBrush = QBrush(buttonGradient2); |
|
1617 |
||
1618 |
QLinearGradient buttonGradient3(rect.topLeft(), rect.bottomLeft()); |
|
1619 |
buttonGradient3.setColorAt(0.0, buttonBrush.color().lighter(105)); |
|
1620 |
buttonGradient3.setColorAt(1.0, buttonBrush.color()); |
|
1621 |
leftLineGradientBrush = QBrush(buttonGradient3); |
|
1622 |
||
1623 |
QLinearGradient buttonGradient4(rect.topLeft(), rect.bottomLeft()); |
|
1624 |
buttonGradient4.setColorAt(0.0, buttonBrush.color()); |
|
1625 |
buttonGradient4.setColorAt(1.0, buttonBrush.color().darker(110)); |
|
1626 |
rightLineGradientBrush = QBrush(buttonGradient4); |
|
1627 |
||
1628 |
QLinearGradient buttonGradient5(rect.topLeft(), rect.bottomLeft()); |
|
1629 |
buttonGradient5.setColorAt(0.0, buttonBrush.color().darker(113)); |
|
1630 |
buttonGradient5.setColorAt(1.0, buttonBrush.color().darker(107)); |
|
1631 |
sunkenLeftLineGradientBrush = QBrush(buttonGradient5); |
|
1632 |
||
1633 |
QLinearGradient buttonGradient6(rect.topLeft(), rect.bottomLeft()); |
|
1634 |
buttonGradient6.setColorAt(0.0, buttonBrush.color().darker(108)); |
|
1635 |
buttonGradient6.setColorAt(1.0, buttonBrush.color().darker(103)); |
|
1636 |
sunkenRightLineGradientBrush = QBrush(buttonGradient6); |
|
1637 |
} |
|
1638 |
||
1639 |
// Main fill |
|
1640 |
p->fillRect(fillRect, |
|
1641 |
qMapBrushToRect(sunken ? sunkenButtonGradientBrush |
|
1642 |
: buttonGradientBrush, rect)); |
|
1643 |
||
1644 |
// Top line |
|
1645 |
p->setPen(QPen(qBrushLight(qMapBrushToRect(sunken ? sunkenButtonGradientBrush |
|
1646 |
: buttonGradientBrush, rect), 105), 0)); |
|
1647 |
p->drawLine(QPointF(rect.left() + 2, rect.top() + 1), |
|
1648 |
QPointF(rect.right() - 2, rect.top() + 1)); |
|
1649 |
||
1650 |
// Bottom line |
|
1651 |
p->setPen(QPen(qBrushDark(qMapBrushToRect(sunken ? sunkenButtonGradientBrush |
|
1652 |
: buttonGradientBrush, rect), 105), 0)); |
|
1653 |
p->drawLine(QPointF(rect.left() + 2, rect.bottom() - 1), |
|
1654 |
QPointF(rect.right() - 2, rect.bottom() - 1)); |
|
1655 |
||
1656 |
// Left line |
|
1657 |
p->setPen(QPen(qMapBrushToRect(sunken ? sunkenLeftLineGradientBrush |
|
1658 |
: leftLineGradientBrush, rect), 1)); |
|
1659 |
p->drawLine(QPointF(rect.left() + 1, rect.top() + 2), |
|
1660 |
QPointF(rect.left() + 1, rect.bottom() - 2)); |
|
1661 |
||
1662 |
// Right line |
|
1663 |
p->setPen(QPen(qMapBrushToRect(sunken ? sunkenRightLineGradientBrush |
|
1664 |
: rightLineGradientBrush, rect), 1)); |
|
1665 |
p->drawLine(QPointF(rect.right() - 1, rect.top() + 2), |
|
1666 |
QPointF(rect.right() - 1, rect.bottom() - 2)); |
|
1667 |
||
1668 |
// Hovering |
|
1669 |
if (hover && !sunken) { |
|
1670 |
QBrush hover = qMapBrushToRect(option->palette.highlight(), rect); |
|
1671 |
QBrush hoverOuter = hover; |
|
1672 |
qBrushSetAlphaF(&hoverOuter, qreal(0.7)); |
|
1673 |
||
1674 |
QLine lines[2]; |
|
1675 |
||
1676 |
p->setPen(QPen(hoverOuter, 0)); |
|
1677 |
lines[0] = QLine(rect.left() + 1, rect.top() + 1, rect.right() - 1, rect.top() + 1); |
|
1678 |
lines[1] = QLine(rect.left() + 1, rect.bottom() - 1, rect.right() - 1, rect.bottom() - 1); |
|
1679 |
p->drawLines(lines, 2); |
|
1680 |
||
1681 |
QBrush hoverInner = hover; |
|
1682 |
qBrushSetAlphaF(&hoverInner, qreal(0.45)); |
|
1683 |
p->setPen(QPen(hoverInner, 0)); |
|
1684 |
lines[0] = QLine(rect.left() + 1, rect.top() + 2, rect.right() - 1, rect.top() + 2); |
|
1685 |
lines[1] = QLine(rect.left() + 1, rect.bottom() - 2, rect.right() - 1, rect.bottom() - 2); |
|
1686 |
p->drawLines(lines, 2); |
|
1687 |
||
1688 |
QBrush hoverSide = hover; |
|
1689 |
qBrushSetAlphaF(&hoverSide, qreal(0.075)); |
|
1690 |
p->setPen(QPen(hoverSide, 0)); |
|
1691 |
lines[0] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2); |
|
1692 |
lines[1] = QLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2); |
|
1693 |
p->drawLines(lines, 2); |
|
1694 |
} |
|
1695 |
||
1696 |
p->setPen(oldPen); |
|
1697 |
||
1698 |
END_STYLE_PIXMAPCACHE |
|
1699 |
} |
|
1700 |
break; |
|
1701 |
case PE_IndicatorCheckBox: |
|
1702 |
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
1703 |
BEGIN_STYLE_PIXMAPCACHE(QLatin1String("checkbox")) |
|
1704 |
||
1705 |
p->save(); |
|
1706 |
||
1707 |
// Outline |
|
1708 |
QBrush border = option->palette.shadow(); |
|
1709 |
qBrushSetAlphaF(&border, qreal(0.4)); |
|
1710 |
p->setPen(QPen(border, 0)); |
|
1711 |
const QLine lines[4] = { |
|
1712 |
QLine(rect.left() + 1, rect.top(), rect.right() - 1, rect.top()), |
|
1713 |
QLine(rect.left() + 1, rect.bottom(), rect.right() - 1, rect.bottom()), |
|
1714 |
QLine(rect.left(), rect.top() + 1, rect.left(), rect.bottom() - 1), |
|
1715 |
QLine(rect.right(), rect.top() + 1, rect.right(), rect.bottom() - 1) }; |
|
1716 |
p->drawLines(lines, 4); |
|
1717 |
||
1718 |
QBrush corner = option->palette.shadow(); |
|
1719 |
qBrushSetAlphaF(&corner, qreal(0.2)); |
|
1720 |
p->setPen(QPen(corner, 0)); |
|
1721 |
const QPoint points[4] = { |
|
1722 |
rect.topLeft(), rect.topRight(), |
|
1723 |
rect.bottomLeft(), rect.bottomRight() }; |
|
1724 |
p->drawPoints(points, 4); |
|
1725 |
||
1726 |
// Fill |
|
1727 |
QBrush baseBrush = qMapBrushToRect(button->palette.base(), rect); |
|
1728 |
if (!baseBrush.gradient() && baseBrush.texture().isNull()) { |
|
1729 |
QLinearGradient gradient(rect.center().x(), rect.top(), rect.center().x(), rect.bottom()); |
|
1730 |
gradient.setColorAt(0, baseBrush.color()); |
|
1731 |
gradient.setColorAt(1, baseBrush.color().darker(105)); |
|
1732 |
baseBrush = gradient; |
|
1733 |
} |
|
1734 |
p->fillRect(rect.adjusted(1, 1, -1, -1), baseBrush); |
|
1735 |
||
1736 |
// Hover |
|
1737 |
if ((button->state & State_Enabled) && (button->state & State_MouseOver)) { |
|
1738 |
QBrush pen = qMapBrushToRect(button->palette.highlight(), rect); |
|
1739 |
qBrushSetAlphaF(&pen, qreal(0.8)); |
|
1740 |
p->setPen(QPen(pen, 0)); |
|
1741 |
p->drawRect(rect.adjusted(1, 1, -2, -2)); |
|
1742 |
qBrushSetAlphaF(&pen, 0.5); |
|
1743 |
p->setPen(QPen(pen, 0)); |
|
1744 |
p->drawRect(rect.adjusted(2, 2, -3, -3)); |
|
1745 |
||
1746 |
qBrushSetAlphaF(&pen, qreal(0.2)); |
|
1747 |
p->setBrush(pen); |
|
1748 |
p->drawRect(rect.adjusted(2, 2, -3, -3)); |
|
1749 |
} |
|
1750 |
||
1751 |
// Indicator |
|
1752 |
bool on = button->state & State_On; |
|
1753 |
bool sunken = button->state & State_Sunken; |
|
1754 |
bool unchanged = button->state & State_NoChange; |
|
1755 |
bool enabled = button->state & State_Enabled; |
|
1756 |
if (on || (enabled && sunken) || unchanged) { |
|
1757 |
p->setRenderHint(QPainter::Antialiasing); |
|
1758 |
QBrush pointBrush = qMapBrushToRect(button->palette.text(), rect); |
|
1759 |
if (sunken) |
|
1760 |
qBrushSetAlphaF(&pointBrush, qreal(0.5)); |
|
1761 |
else if (unchanged) |
|
1762 |
qBrushSetAlphaF(&pointBrush, qreal(0.3)); |
|
1763 |
p->setPen(QPen(pointBrush, 3)); |
|
1764 |
const QLine lines[2] = { |
|
1765 |
QLine(rect.left() + 4, rect.top() + 4, rect.right() - 3, rect.bottom() - 3), |
|
1766 |
QLine(rect.right() - 3, rect.top() + 4, rect.left() + 4, rect.bottom() - 3) }; |
|
1767 |
p->drawLines(lines, 2); |
|
1768 |
} |
|
1769 |
||
1770 |
p->restore(); |
|
1771 |
END_STYLE_PIXMAPCACHE |
|
1772 |
} |
|
1773 |
break; |
|
1774 |
case PE_IndicatorRadioButton: |
|
1775 |
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
1776 |
BEGIN_STYLE_PIXMAPCACHE(QLatin1String("radiobutton")) |
|
1777 |
||
1778 |
p->save(); |
|
1779 |
p->setRenderHint(QPainter::Antialiasing); |
|
1780 |
||
1781 |
// The the filled ellipse |
|
1782 |
QBrush border = qMapBrushToRect(option->palette.shadow(), rect); |
|
1783 |
qBrushSetAlphaF(&border, qreal(0.51)); |
|
1784 |
p->setPen(QPen(border, 0)); |
|
1785 |
||
1786 |
QBrush baseBrush = qMapBrushToRect(button->palette.base(), rect); |
|
1787 |
if (!baseBrush.gradient() && baseBrush.texture().isNull()) { |
|
1788 |
QLinearGradient gradient(rect.center().x(), rect.top(), rect.center().x(), rect.bottom()); |
|
1789 |
gradient.setColorAt(0, baseBrush.color()); |
|
1790 |
gradient.setColorAt(1, baseBrush.color().darker(105)); |
|
1791 |
baseBrush = gradient; |
|
1792 |
} |
|
1793 |
p->setBrush(baseBrush); |
|
1794 |
p->drawEllipse(QRectF(rect).adjusted(1, 1, -1, -1)); |
|
1795 |
||
1796 |
// Hover |
|
1797 |
if ((button->state & State_Enabled) && (button->state & State_MouseOver)) { |
|
1798 |
QBrush pen = qMapBrushToRect(button->palette.highlight(), rect); |
|
1799 |
qBrushSetAlphaF(&pen, qreal(0.8)); |
|
1800 |
p->setPen(QPen(pen, 0)); |
|
1801 |
qBrushSetAlphaF(&pen, qreal(0.2)); |
|
1802 |
p->setBrush(pen); |
|
1803 |
p->drawEllipse(QRectF(rect).adjusted(2, 2, -2, -2)); |
|
1804 |
} |
|
1805 |
||
1806 |
// Indicator |
|
1807 |
bool on = button->state & State_On; |
|
1808 |
bool sunken = button->state & State_Sunken; |
|
1809 |
bool enabled = button->state & State_Enabled; |
|
1810 |
if (on || (enabled && sunken)) { |
|
1811 |
p->setPen(Qt::NoPen); |
|
1812 |
QBrush pointBrush = qMapBrushToRect(button->palette.text(), rect); |
|
1813 |
if (sunken) |
|
1814 |
qBrushSetAlphaF(&pointBrush, 0.5); |
|
1815 |
p->setBrush(pointBrush); |
|
1816 |
p->drawEllipse(QRectF(rect).adjusted(3, 3, -3, -3)); |
|
1817 |
} |
|
1818 |
||
1819 |
p->restore(); |
|
1820 |
END_STYLE_PIXMAPCACHE |
|
1821 |
} |
|
1822 |
break; |
|
1823 |
#ifndef QT_NO_DOCKWIDGET |
|
1824 |
case PE_IndicatorDockWidgetResizeHandle: |
|
1825 |
if ((option->state & State_Enabled) && (option->state & State_MouseOver)) |
|
1826 |
painter->fillRect(option->rect, QColor(255, 255, 255, 128)); |
|
1827 |
if (option->state & State_Horizontal) { |
|
1828 |
int width = option->rect.width() / 3; |
|
1829 |
QRect rect(option->rect.center().x() - width / 2, |
|
1830 |
option->rect.top() + (option->rect.height() / 2) - 1, width, 3); |
|
1831 |
qt_plastique_draw_handle(painter, option, rect, Qt::Vertical, widget); |
|
1832 |
} else { |
|
1833 |
int height = option->rect.height() / 3; |
|
1834 |
QRect rect(option->rect.left() + (option->rect.width() / 2 - 1), |
|
1835 |
option->rect.center().y() - height / 2, 3, height); |
|
1836 |
qt_plastique_draw_handle(painter, option, rect, Qt::Horizontal, widget); |
|
1837 |
} |
|
1838 |
break; |
|
1839 |
#endif // QT_NO_DOCKWIDGET |
|
1840 |
case PE_IndicatorViewItemCheck: { |
|
1841 |
QStyleOptionButton button; |
|
1842 |
button.QStyleOption::operator=(*option); |
|
1843 |
button.state &= ~State_MouseOver; |
|
1844 |
proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); |
|
1845 |
break; |
|
1846 |
} |
|
1847 |
case PE_FrameWindow: { |
|
1848 |
painter->save(); |
|
1849 |
bool active = (option->state & State_Active); |
|
1850 |
int titleBarStop = option->rect.top() + proxy()->pixelMetric(PM_TitleBarHeight, option, widget); |
|
1851 |
||
1852 |
QPalette palette = option->palette; |
|
1853 |
if (!active) |
|
1854 |
palette.setCurrentColorGroup(QPalette::Disabled); |
|
1855 |
||
1856 |
// Frame and rounded corners |
|
1857 |
painter->setPen(mergedColors(palette.highlight().color(), Qt::black, 50)); |
|
1858 |
||
1859 |
QLine lines[3]; |
|
1860 |
QPoint points[4]; |
|
1861 |
||
1862 |
// bottom border line |
|
1863 |
lines[0] = QLine(option->rect.left() + 1, option->rect.bottom(), option->rect.right() - 1, option->rect.bottom()); |
|
1864 |
||
1865 |
// bottom left and right side border lines |
|
1866 |
lines[1] = QLine(option->rect.left(), titleBarStop, option->rect.left(), option->rect.bottom() - 1); |
|
1867 |
lines[2] = QLine(option->rect.right(), titleBarStop, option->rect.right(), option->rect.bottom() - 1); |
|
1868 |
painter->drawLines(lines, 3); |
|
1869 |
points[0] = QPoint(option->rect.left() + 1, option->rect.bottom() - 1); |
|
1870 |
points[1] = QPoint(option->rect.right() - 1, option->rect.bottom() - 1); |
|
1871 |
painter->drawPoints(points, 2); |
|
1872 |
||
1873 |
#ifdef QT3_SUPPORT |
|
1874 |
if (widget && widget->inherits("Q3DockWindow")) { |
|
1875 |
// also draw the frame on the title bar |
|
1876 |
lines[0] = QLine(option->rect.left() + 1, option->rect.top(), |
|
1877 |
option->rect.right() - 1, option->rect.top()); |
|
1878 |
lines[1] = QLine(option->rect.left(), option->rect.top() + 1, |
|
1879 |
option->rect.left(), titleBarStop); |
|
1880 |
lines[2] = QLine(option->rect.right(), option->rect.top() + 1, |
|
1881 |
option->rect.right(), titleBarStop); |
|
1882 |
painter->drawLines(lines, 3); |
|
1883 |
} |
|
1884 |
#endif |
|
1885 |
||
1886 |
// alpha corners |
|
1887 |
painter->setPen(mergedColors(palette.highlight().color(), palette.background().color(), 55)); |
|
1888 |
points[0] = QPoint(option->rect.left() + 2, option->rect.bottom() - 1); |
|
1889 |
points[1] = QPoint(option->rect.left() + 1, option->rect.bottom() - 2); |
|
1890 |
points[2] = QPoint(option->rect.right() - 2, option->rect.bottom() - 1); |
|
1891 |
points[3] = QPoint(option->rect.right() - 1, option->rect.bottom() - 2); |
|
1892 |
painter->drawPoints(points, 4); |
|
1893 |
||
1894 |
#ifdef QT3_SUPPORT |
|
1895 |
if (widget && widget->inherits("Q3DockWindow")) { |
|
1896 |
// also draw the frame on the title bar |
|
1897 |
points[0] = option->rect.topLeft(); |
|
1898 |
points[1] = option->rect.topRight(); |
|
1899 |
painter->drawPoints(points, 2); |
|
1900 |
} |
|
1901 |
#endif |
|
1902 |
||
1903 |
// upper and lower left inner |
|
1904 |
painter->setPen(active ? mergedColors(palette.highlight().color(), palette.background().color()) : palette.background().color().darker(120)); |
|
1905 |
painter->drawLine(option->rect.left() + 1, titleBarStop, option->rect.left() + 1, option->rect.bottom() - 2); |
|
1906 |
||
1907 |
#ifdef QT3_SUPPORT |
|
1908 |
if (widget && widget->inherits("Q3DockWindow")) { |
|
1909 |
// also draw the frame on the title bar |
|
1910 |
lines[0] = QLine(option->rect.left() + 1, option->rect.top() + 1, |
|
1911 |
option->rect.left() + 1, titleBarStop); |
|
1912 |
lines[1] = QLine(option->rect.right() - 1, option->rect.top() + 1, |
|
1913 |
option->rect.right() - 1, titleBarStop); |
|
1914 |
lines[2] = QLine(option->rect.left() + 1, option->rect.top() + 1, |
|
1915 |
option->rect.right() - 1, option->rect.top() + 1); |
|
1916 |
painter->drawLines(lines, 3); |
|
1917 |
} |
|
1918 |
#endif |
|
1919 |
||
1920 |
painter->setPen(active ? mergedColors(palette.highlight().color(), palette.background().color(), 57) : palette.background().color().darker(130)); |
|
1921 |
lines[0] = QLine(option->rect.right() - 1, titleBarStop, option->rect.right() - 1, option->rect.bottom() - 2); |
|
1922 |
lines[1] = QLine(option->rect.left() + 1, option->rect.bottom() - 1, option->rect.right() - 1, option->rect.bottom() - 1); |
|
1923 |
painter->drawLines(lines, 2); |
|
1924 |
||
1925 |
painter->restore(); |
|
1926 |
} |
|
1927 |
break; |
|
1928 |
case PE_IndicatorBranch: { |
|
1929 |
int mid_h = option->rect.x() + option->rect.width() / 2; |
|
1930 |
int mid_v = option->rect.y() + option->rect.height() / 2; |
|
1931 |
int bef_h = mid_h; |
|
1932 |
int bef_v = mid_v; |
|
1933 |
int aft_h = mid_h; |
|
1934 |
int aft_v = mid_v; |
|
1935 |
QBrush brush(option->palette.dark().color(), Qt::Dense4Pattern); |
|
1936 |
if (option->state & State_Item) { |
|
1937 |
if (option->direction == Qt::RightToLeft) |
|
1938 |
painter->fillRect(option->rect.left(), mid_v, bef_h - option->rect.left(), 1, brush); |
|
1939 |
else |
|
1940 |
painter->fillRect(aft_h, mid_v, option->rect.right() - aft_h + 1, 1, brush); |
|
1941 |
} |
|
1942 |
if (option->state & State_Sibling) |
|
1943 |
painter->fillRect(mid_h, aft_v, 1, option->rect.bottom() - aft_v + 1, brush); |
|
1944 |
if (option->state & (State_Open | State_Children | State_Item | State_Sibling)) |
|
1945 |
painter->fillRect(mid_h, option->rect.y(), 1, bef_v - option->rect.y(), brush); |
|
1946 |
||
1947 |
if (option->state & State_Children) { |
|
1948 |
painter->save(); |
|
1949 |
QPoint center = option->rect.center(); |
|
1950 |
// border |
|
1951 |
QRect fullRect(center.x() - 4, center.y() - 4, 9, 9); |
|
1952 |
painter->setPen(borderColor); |
|
1953 |
||
1954 |
const QLine lines[4] = { |
|
1955 |
QLine(fullRect.left() + 1, fullRect.top(), |
|
1956 |
fullRect.right() - 1, fullRect.top()), |
|
1957 |
QLine(fullRect.left() + 1, fullRect.bottom(), |
|
1958 |
fullRect.right() - 1, fullRect.bottom()), |
|
1959 |
QLine(fullRect.left(), fullRect.top() + 1, |
|
1960 |
fullRect.left(), fullRect.bottom() - 1), |
|
1961 |
QLine(fullRect.right(), fullRect.top() + 1, |
|
1962 |
fullRect.right(), fullRect.bottom() - 1) }; |
|
1963 |
painter->drawLines(lines, 4); |
|
1964 |
||
1965 |
// "antialiased" corners |
|
1966 |
painter->setPen(alphaCornerColor); |
|
1967 |
const QPoint points[4] = { |
|
1968 |
fullRect.topLeft(), |
|
1969 |
fullRect.topRight(), |
|
1970 |
fullRect.bottomLeft(), |
|
1971 |
fullRect.bottomRight() }; |
|
1972 |
painter->drawPoints(points, 4); |
|
1973 |
||
1974 |
// fill |
|
1975 |
QRect adjustedRect = fullRect; |
|
1976 |
QRect gradientRect(adjustedRect.left() + 1, adjustedRect.top() + 1, |
|
1977 |
adjustedRect.right() - adjustedRect.left() - 1, |
|
1978 |
adjustedRect.bottom() - adjustedRect.top() - 1); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1979 |
if (option->palette.base().style() == Qt::SolidPattern) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1980 |
QColor baseGradientStartColor = option->palette.base().color().darker(101); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1981 |
QColor baseGradientStopColor = option->palette.base().color().darker(106); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1982 |
qt_plastique_draw_gradient(painter, gradientRect, baseGradientStartColor, baseGradientStopColor); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1983 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1984 |
painter->fillRect(gradientRect, option->palette.base()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1985 |
} |
0 | 1986 |
// draw "+" or "-" |
1987 |
painter->setPen(alphaTextColor); |
|
1988 |
painter->drawLine(center.x() - 2, center.y(), center.x() + 2, center.y()); |
|
1989 |
if (!(option->state & State_Open)) |
|
1990 |
painter->drawLine(center.x(), center.y() - 2, center.x(), center.y() + 2); |
|
1991 |
painter->restore(); |
|
1992 |
} |
|
1993 |
} |
|
1994 |
break; |
|
1995 |
default: |
|
1996 |
QWindowsStyle::drawPrimitive(element, option, painter, widget); |
|
1997 |
break; |
|
1998 |
} |
|
1999 |
} |
|
2000 |
||
2001 |
/*! |
|
2002 |
\reimp |
|
2003 |
*/ |
|
2004 |
void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *option, |
|
2005 |
QPainter *painter, const QWidget *widget) const |
|
2006 |
{ |
|
2007 |
QColor borderColor = option->palette.background().color().darker(178); |
|
2008 |
QColor alphaCornerColor; |
|
2009 |
if (widget) { |
|
2010 |
// ### backgroundrole/foregroundrole should be part of the style option |
|
2011 |
alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor); |
|
2012 |
} else { |
|
2013 |
alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); |
|
2014 |
} |
|
2015 |
QColor alphaTextColor = mergedColors(option->palette.background().color(), option->palette.text().color()); |
|
2016 |
||
2017 |
QColor gradientStartColor = option->palette.button().color().lighter(104); |
|
2018 |
QColor gradientStopColor = option->palette.button().color().darker(105); |
|
2019 |
||
2020 |
QColor shadowGradientStartColor = option->palette.button().color().darker(115); |
|
2021 |
QColor shadowGradientStopColor = option->palette.button().color().darker(120); |
|
2022 |
||
2023 |
QColor highlightedGradientStartColor = option->palette.button().color().lighter(101); |
|
2024 |
QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85); |
|
2025 |
||
2026 |
QColor lightShadowGradientStartColor = highlightedGradientStartColor.lighter(105); |
|
2027 |
QColor lightShadowGradientStopColor = highlightedGradientStopColor.lighter(105); |
|
2028 |
||
2029 |
QColor highlightedDarkInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 35); |
|
2030 |
QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58); |
|
2031 |
||
2032 |
QColor alphaInnerColor = mergedColors(highlightedDarkInnerBorderColor, option->palette.base().color()); |
|
2033 |
QColor lightShadow = lightShadowGradientStartColor; |
|
2034 |
QColor shadow = shadowGradientStartColor; |
|
2035 |
||
2036 |
switch (element) { |
|
2037 |
#ifndef QT_NO_TABBAR |
|
2038 |
case CE_TabBarTabShape: |
|
2039 |
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) { |
|
2040 |
||
2041 |
if (tab->shape != QTabBar::RoundedNorth && tab->shape != QTabBar::RoundedWest && |
|
2042 |
tab->shape != QTabBar::RoundedSouth && tab->shape != QTabBar::RoundedEast) { |
|
2043 |
QWindowsStyle::drawControl(element, option, painter, widget); |
|
2044 |
break; |
|
2045 |
} |
|
2046 |
||
2047 |
painter->save(); |
|
2048 |
||
2049 |
// Set up some convenience variables |
|
2050 |
bool disabled = !(tab->state & State_Enabled); |
|
2051 |
bool onlyTab = tab->position == QStyleOptionTab::OnlyOneTab; |
|
2052 |
bool selected = tab->state & State_Selected; |
|
2053 |
bool mouseOver = (tab->state & State_MouseOver) && !selected && !disabled; |
|
2054 |
bool previousSelected = tab->selectedPosition == QStyleOptionTab::PreviousIsSelected; |
|
2055 |
bool nextSelected = tab->selectedPosition == QStyleOptionTab::NextIsSelected; |
|
2056 |
bool leftCornerWidget = (tab->cornerWidgets & QStyleOptionTab::LeftCornerWidget); |
|
2057 |
bool reverse = (tab->direction == Qt::RightToLeft); |
|
2058 |
||
2059 |
int lowerTop = selected ? 0 : 3; // to make the selected tab bigger than the rest |
|
2060 |
QRect adjustedRect; |
|
2061 |
bool atEnd = (tab->position == QStyleOptionTab::End) || onlyTab; |
|
2062 |
bool atBeginning = ((tab->position == QStyleOptionTab::Beginning) || onlyTab) |
|
2063 |
&& !leftCornerWidget; |
|
2064 |
bool reverseShadow = false; |
|
2065 |
||
2066 |
int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget); |
|
2067 |
int marginLeft = 0; |
|
2068 |
if ((atBeginning && !selected) || (selected && leftCornerWidget && ((tab->position == QStyleOptionTab::Beginning) || onlyTab))) { |
|
2069 |
marginLeft = 1; |
|
2070 |
} |
|
2071 |
||
2072 |
// I've set the names based on the natural coordinate system. Vectors are used to rotate everything |
|
2073 |
// if the orientation of the tab bare is different than north. |
|
2074 |
{ |
|
2075 |
// Coordinates of corners of rectangle for transformation |
|
2076 |
QPoint topLeft; |
|
2077 |
QPoint topRight; |
|
2078 |
QPoint bottomLeft; |
|
2079 |
QPoint bottomRight; |
|
2080 |
||
2081 |
// Fill with normalized vectors in the direction of the coordinate system |
|
2082 |
// (down and right should be complement of up and left, or it will look odd) |
|
2083 |
QPoint vectorUp; |
|
2084 |
QPoint vectorDown; |
|
2085 |
QPoint vectorLeft; |
|
2086 |
QPoint vectorRight; |
|
2087 |
||
2088 |
QBrush border = option->palette.shadow(); |
|
2089 |
qBrushSetAlphaF(&border, qreal(0.4)); |
|
2090 |
QBrush innerTopLeft = option->palette.shadow(); |
|
2091 |
qBrushSetAlphaF(&innerTopLeft, qreal(0.075)); |
|
2092 |
QBrush innerBottomRight = option->palette.shadow(); |
|
2093 |
qBrushSetAlphaF(&innerBottomRight, qreal(0.23)); |
|
2094 |
QBrush corner = option->palette.shadow(); |
|
2095 |
qBrushSetAlphaF(&corner, qreal(0.25)); |
|
2096 |
||
2097 |
QBrush baseColor1; |
|
2098 |
QBrush baseColor2; |
|
2099 |
||
2100 |
switch (tab->shape) { |
|
2101 |
case QTabBar::RoundedNorth: |
|
2102 |
vectorUp = QPoint(0, -1); |
|
2103 |
vectorDown = QPoint(0, 1); |
|
2104 |
||
2105 |
if (reverse) { |
|
2106 |
vectorLeft = QPoint(1, 0); |
|
2107 |
vectorRight = QPoint(-1, 0); |
|
2108 |
reverseShadow = true; |
|
2109 |
} else { |
|
2110 |
vectorLeft = QPoint(-1, 0); |
|
2111 |
vectorRight = QPoint(1, 0); |
|
2112 |
} |
|
2113 |
||
2114 |
if (reverse) { |
|
2115 |
topLeft = tab->rect.topRight(); |
|
2116 |
topRight = tab->rect.topLeft(); |
|
2117 |
bottomLeft = tab->rect.bottomRight(); |
|
2118 |
bottomRight = tab->rect.bottomLeft(); |
|
2119 |
} else { |
|
2120 |
topLeft = tab->rect.topLeft(); |
|
2121 |
topRight = tab->rect.topRight(); |
|
2122 |
bottomLeft = tab->rect.bottomLeft(); |
|
2123 |
bottomRight = tab->rect.bottomRight(); |
|
2124 |
} |
|
2125 |
||
2126 |
||
2127 |
baseColor1 = border; |
|
2128 |
baseColor2 = innerTopLeft; |
|
2129 |
break ; |
|
2130 |
case QTabBar::RoundedWest: |
|
2131 |
vectorUp = QPoint(-1, 0); |
|
2132 |
vectorDown = QPoint(1, 0); |
|
2133 |
vectorLeft = QPoint(0, -1); |
|
2134 |
vectorRight = QPoint(0, 1); |
|
2135 |
||
2136 |
topLeft = tab->rect.topLeft(); |
|
2137 |
topRight = tab->rect.bottomLeft(); |
|
2138 |
bottomLeft = tab->rect.topRight(); |
|
2139 |
bottomRight = tab->rect.bottomRight(); |
|
2140 |
||
2141 |
baseColor1 = border; |
|
2142 |
baseColor2 = innerTopLeft; |
|
2143 |
break ; |
|
2144 |
case QTabBar::RoundedEast: |
|
2145 |
vectorUp = QPoint(1, 0); |
|
2146 |
vectorDown = QPoint(-1, 0); |
|
2147 |
vectorLeft = QPoint(0, -1); |
|
2148 |
vectorRight = QPoint(0, 1); |
|
2149 |
||
2150 |
topLeft = tab->rect.topRight(); |
|
2151 |
topRight = tab->rect.bottomRight(); |
|
2152 |
bottomLeft = tab->rect.topLeft(); |
|
2153 |
bottomRight = tab->rect.bottomLeft(); |
|
2154 |
||
2155 |
baseColor1 = border; |
|
2156 |
baseColor2 = innerBottomRight; |
|
2157 |
break ; |
|
2158 |
case QTabBar::RoundedSouth: |
|
2159 |
vectorUp = QPoint(0, 1); |
|
2160 |
vectorDown = QPoint(0, -1); |
|
2161 |
||
2162 |
if (reverse) { |
|
2163 |
vectorLeft = QPoint(1, 0); |
|
2164 |
vectorRight = QPoint(-1, 0); |
|
2165 |
reverseShadow = true; |
|
2166 |
||
2167 |
topLeft = tab->rect.bottomRight(); |
|
2168 |
topRight = tab->rect.bottomLeft(); |
|
2169 |
bottomLeft = tab->rect.topRight(); |
|
2170 |
bottomRight = tab->rect.topLeft(); |
|
2171 |
} else { |
|
2172 |
vectorLeft = QPoint(-1, 0); |
|
2173 |
vectorRight = QPoint(1, 0); |
|
2174 |
||
2175 |
topLeft = tab->rect.bottomLeft(); |
|
2176 |
topRight = tab->rect.bottomRight(); |
|
2177 |
bottomLeft = tab->rect.topLeft(); |
|
2178 |
bottomRight = tab->rect.topRight(); |
|
2179 |
} |
|
2180 |
||
2181 |
baseColor1 = border; |
|
2182 |
baseColor2 = innerBottomRight; |
|
2183 |
break ; |
|
2184 |
default: |
|
2185 |
break; |
|
2186 |
} |
|
2187 |
||
2188 |
// Make the tab smaller when it's at the end, so that we are able to draw the corner |
|
2189 |
if (atEnd) { |
|
2190 |
topRight += vectorLeft; |
|
2191 |
bottomRight += vectorLeft; |
|
2192 |
} |
|
2193 |
||
2194 |
{ |
|
2195 |
// Outer border |
|
2196 |
QLine topLine; |
|
2197 |
{ |
|
2198 |
QPoint adjustTopLineLeft = (vectorRight * (marginLeft + (previousSelected ? 0 : 1))) + |
|
2199 |
(vectorDown * lowerTop); |
|
2200 |
QPoint adjustTopLineRight = (vectorDown * lowerTop); |
|
2201 |
if (atBeginning || selected) |
|
2202 |
adjustTopLineLeft += vectorRight; |
|
2203 |
if (atEnd || selected) |
|
2204 |
adjustTopLineRight += 2 * vectorLeft; |
|
2205 |
||
2206 |
topLine = QLine(topLeft + adjustTopLineLeft, topRight + adjustTopLineRight); |
|
2207 |
} |
|
2208 |
||
2209 |
QLine leftLine; |
|
2210 |
{ |
|
2211 |
QPoint adjustLeftLineTop = (vectorRight * marginLeft) + (vectorDown * (lowerTop + 1)); |
|
2212 |
QPoint adjustLeftLineBottom = (vectorRight * marginLeft) + (vectorUp * borderThickness); |
|
2213 |
if (atBeginning || selected) |
|
2214 |
adjustLeftLineTop += vectorDown; // Make place for rounded corner |
|
2215 |
if (atBeginning && selected) |
|
2216 |
adjustLeftLineBottom += borderThickness * vectorDown; |
|
2217 |
else if (selected) |
|
2218 |
adjustLeftLineBottom += vectorUp; |
|
2219 |
||
2220 |
leftLine = QLine(topLeft + adjustLeftLineTop, bottomLeft + adjustLeftLineBottom); |
|
2221 |
} |
|
2222 |
||
2223 |
QLine rightLine; |
|
2224 |
{ |
|
2225 |
QPoint adjustRightLineTop = vectorDown * (2 + lowerTop); |
|
2226 |
QPoint adjustRightLineBottom = vectorUp * borderThickness; |
|
2227 |
if (selected) |
|
2228 |
adjustRightLineBottom += vectorUp; |
|
2229 |
||
2230 |
rightLine = QLine(topRight + adjustRightLineTop, bottomRight + adjustRightLineBottom); |
|
2231 |
} |
|
2232 |
||
2233 |
// Background |
|
2234 |
QPoint startPoint = topLine.p1() + vectorDown + vectorLeft; |
|
2235 |
if (mouseOver) |
|
2236 |
startPoint += vectorDown; |
|
2237 |
QPoint endPoint = rightLine.p2(); |
|
2238 |
||
2239 |
if (tab->state & State_Enabled) { |
|
2240 |
QRect fillRect = QRect(startPoint, endPoint).normalized(); |
|
2241 |
if (fillRect.isValid()) { |
|
2242 |
if (selected) { |
|
2243 |
fillRect = QRect(startPoint, endPoint + vectorLeft + vectorDown * 3).normalized(); |
|
2244 |
painter->fillRect(fillRect, option->palette.window()); |
|
2245 |
||
2246 |
// Connect to the base |
|
2247 |
painter->setPen(QPen(option->palette.window(), 0)); |
|
2248 |
QVarLengthArray<QPoint, 6> points; |
|
2249 |
points.append(rightLine.p2() + vectorDown); |
|
2250 |
points.append(rightLine.p2() + vectorDown + vectorDown); |
|
2251 |
points.append(rightLine.p2() + vectorDown + vectorDown + vectorRight); |
|
2252 |
if (tab->position != QStyleOptionTab::Beginning) { |
|
2253 |
points.append(leftLine.p2() + vectorDown); |
|
2254 |
points.append(leftLine.p2() + vectorDown + vectorDown); |
|
2255 |
points.append(leftLine.p2() + vectorDown + vectorDown + vectorLeft); |
|
2256 |
} |
|
2257 |
painter->drawPoints(points.constData(), points.size()); |
|
2258 |
} else { |
|
2259 |
QBrush buttonGradientBrush; |
|
2260 |
QBrush buttonBrush = qMapBrushToRect(option->palette.button(), fillRect); |
|
2261 |
if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) { |
|
2262 |
buttonGradientBrush = buttonBrush; |
|
2263 |
} else { |
|
2264 |
// Generate gradients |
|
2265 |
QLinearGradient buttonGradient(fillRect.topLeft(), fillRect.bottomLeft()); |
|
2266 |
buttonGradient.setColorAt(0.0, buttonBrush.color().lighter(104)); |
|
2267 |
buttonGradient.setColorAt(1.0, buttonBrush.color().darker(110)); |
|
2268 |
buttonGradientBrush = QBrush(buttonGradient); |
|
2269 |
} |
|
2270 |
||
2271 |
painter->fillRect(fillRect, buttonGradientBrush); |
|
2272 |
} |
|
2273 |
} |
|
2274 |
} |
|
2275 |
||
2276 |
QPoint rightCornerDot = topRight + vectorLeft + (lowerTop + 1)*vectorDown; |
|
2277 |
QPoint leftCornerDot = topLeft + (marginLeft + 1)*vectorRight + (lowerTop + 1)*vectorDown; |
|
2278 |
QPoint bottomRightConnectToBase = rightLine.p2() + vectorRight + vectorDown; |
|
2279 |
QPoint bottomLeftConnectToBase = leftLine.p2() + vectorLeft + vectorDown; |
|
2280 |
||
2281 |
painter->setPen(QPen(border, 0)); |
|
2282 |
||
2283 |
QVarLengthArray<QLine, 3> lines; |
|
2284 |
QVarLengthArray<QPoint, 7> points; |
|
2285 |
||
2286 |
lines.append(topLine); |
|
2287 |
||
2288 |
if (mouseOver) { |
|
2289 |
painter->drawLines(lines.constData(), lines.count()); |
|
2290 |
lines.clear(); |
|
2291 |
||
2292 |
QLine secondHoverLine = QLine(topLine.p1() + vectorDown * 2 + vectorLeft, topLine.p2() + vectorDown * 2 + vectorRight); |
|
2293 |
painter->setPen(highlightedLightInnerBorderColor); |
|
2294 |
painter->drawLine(secondHoverLine); |
|
2295 |
} |
|
2296 |
||
2297 |
if (mouseOver) |
|
2298 |
painter->setPen(QPen(border, 0)); |
|
2299 |
||
2300 |
if (!previousSelected) |
|
2301 |
lines.append(leftLine); |
|
2302 |
if (atEnd || selected) { |
|
2303 |
lines.append(rightLine); |
|
2304 |
points.append(rightCornerDot); |
|
2305 |
} |
|
2306 |
if (atBeginning || selected) |
|
2307 |
points.append(leftCornerDot); |
|
2308 |
if (selected) { |
|
2309 |
points.append(bottomRightConnectToBase); |
|
2310 |
points.append(bottomLeftConnectToBase); |
|
2311 |
} |
|
2312 |
if (lines.size() > 0) { |
|
2313 |
painter->drawLines(lines.constData(), lines.size()); |
|
2314 |
lines.clear(); |
|
2315 |
} |
|
2316 |
if (points.size() > 0) { |
|
2317 |
painter->drawPoints(points.constData(), points.size()); |
|
2318 |
points.clear(); |
|
2319 |
} |
|
2320 |
||
2321 |
// Antialiasing |
|
2322 |
painter->setPen(QPen(corner, 0)); |
|
2323 |
if (atBeginning || selected) |
|
2324 |
points.append(topLine.p1() + vectorLeft); |
|
2325 |
if (!previousSelected) |
|
2326 |
points.append(leftLine.p1() + vectorUp); |
|
2327 |
if (atEnd || selected) { |
|
2328 |
points.append(topLine.p2() + vectorRight); |
|
2329 |
points.append(rightLine.p1() + vectorUp); |
|
2330 |
} |
|
2331 |
||
2332 |
if (selected) { |
|
2333 |
points.append(bottomRightConnectToBase + vectorLeft); |
|
2334 |
if (!atBeginning) { |
|
2335 |
points.append(bottomLeftConnectToBase + vectorRight); |
|
2336 |
||
2337 |
if (((tab->position == QStyleOptionTab::Beginning) || onlyTab) && leftCornerWidget) { |
|
2338 |
// A special case: When the first tab is selected and |
|
2339 |
// has a left corner widget, it needs to do more work |
|
2340 |
// to connect to the base |
|
2341 |
QPoint p1 = bottomLeftConnectToBase + vectorDown; |
|
2342 |
||
2343 |
points.append(p1); |
|
2344 |
} |
|
2345 |
} |
|
2346 |
} |
|
2347 |
if (points.size() > 0) { |
|
2348 |
painter->drawPoints(points.constData(), points.size()); |
|
2349 |
points.clear(); |
|
2350 |
} |
|
2351 |
||
2352 |
// Inner border |
|
2353 |
QLine innerTopLine = QLine(topLine.p1() + vectorDown, topLine.p2() + vectorDown); |
|
2354 |
if (!selected) { |
|
2355 |
QLinearGradient topLineGradient(innerTopLine.p1(),innerTopLine.p2()); |
|
2356 |
topLineGradient.setColorAt(0, lightShadowGradientStartColor); |
|
2357 |
topLineGradient.setColorAt(1, lightShadowGradientStopColor); |
|
2358 |
painter->setPen(QPen(mouseOver ? QBrush(highlightedDarkInnerBorderColor) : QBrush(topLineGradient), 1)); |
|
2359 |
} else { |
|
2360 |
painter->setPen(QPen(innerTopLeft, 0)); |
|
2361 |
} |
|
2362 |
painter->drawLine(innerTopLine); |
|
2363 |
||
2364 |
QLine innerLeftLine = QLine(leftLine.p1() + vectorRight + vectorDown, leftLine.p2() + vectorRight); |
|
2365 |
QLine innerRightLine = QLine(rightLine.p1() + vectorLeft + vectorDown, rightLine.p2() + vectorLeft); |
|
2366 |
||
2367 |
if (selected) { |
|
2368 |
innerRightLine = QLine(innerRightLine.p1() + vectorUp, innerRightLine.p2()); |
|
2369 |
innerLeftLine = QLine(innerLeftLine.p1() + vectorUp, innerLeftLine.p2()); |
|
2370 |
} |
|
2371 |
||
2372 |
if (selected || atBeginning) { |
|
2373 |
QBrush leftLineGradientBrush; |
|
2374 |
QRect rect = QRect(innerLeftLine.p1(), innerLeftLine.p2()).normalized(); |
|
2375 |
QBrush buttonBrush = qMapBrushToRect(option->palette.button(), rect); |
|
2376 |
if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) { |
|
2377 |
leftLineGradientBrush = qBrushLight(buttonBrush, 105); |
|
2378 |
} else { |
|
2379 |
QLinearGradient buttonGradient3(rect.topLeft(), rect.bottomLeft()); |
|
2380 |
buttonGradient3.setColorAt(0.0, buttonBrush.color().lighter(105)); |
|
2381 |
buttonGradient3.setColorAt(1.0, buttonBrush.color()); |
|
2382 |
leftLineGradientBrush = QBrush(buttonGradient3); |
|
2383 |
} |
|
2384 |
||
2385 |
if (!selected) |
|
2386 |
painter->setPen(QPen(leftLineGradientBrush, 0)); |
|
2387 |
||
2388 |
// Assume the sun is on the same side in Right-To-Left layouts and draw the |
|
2389 |
// light shadow on the left side always (the right line is on the left side in |
|
2390 |
// reverse layouts for north and south) |
|
2391 |
if (reverseShadow) |
|
2392 |
painter->drawLine(innerRightLine); |
|
2393 |
else |
|
2394 |
painter->drawLine(innerLeftLine); |
|
2395 |
} |
|
2396 |
||
2397 |
if (atEnd || selected) { |
|
2398 |
if (!selected) { |
|
2399 |
QBrush rightLineGradientBrush; |
|
2400 |
QRect rect = QRect(innerRightLine.p1(), innerRightLine.p2()).normalized(); |
|
2401 |
QBrush buttonBrush = qMapBrushToRect(option->palette.button(), rect); |
|
2402 |
if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) { |
|
2403 |
rightLineGradientBrush = qBrushDark(buttonBrush, 105); |
|
2404 |
} else { |
|
2405 |
QLinearGradient buttonGradient4(rect.topLeft(), rect.bottomLeft()); |
|
2406 |
buttonGradient4.setColorAt(0.0, buttonBrush.color()); |
|
2407 |
buttonGradient4.setColorAt(1.0, buttonBrush.color().darker(110)); |
|
2408 |
rightLineGradientBrush = QBrush(buttonGradient4); |
|
2409 |
} |
|
2410 |
||
2411 |
painter->setPen(QPen(rightLineGradientBrush, 0)); |
|
2412 |
} else { |
|
2413 |
painter->setPen(QPen(innerBottomRight, 0)); |
|
2414 |
} |
|
2415 |
||
2416 |
if (reverseShadow) |
|
2417 |
painter->drawLine(innerLeftLine); |
|
2418 |
else |
|
2419 |
painter->drawLine(innerRightLine); |
|
2420 |
} |
|
2421 |
||
2422 |
||
2423 |
// Base |
|
2424 |
QLine baseLine = QLine(bottomLeft + marginLeft * 2 * vectorRight, bottomRight); |
|
2425 |
{ |
|
2426 |
||
2427 |
QPoint adjustedLeft; |
|
2428 |
QPoint adjustedRight; |
|
2429 |
||
2430 |
if (atEnd && !selected) { |
|
2431 |
baseLine = QLine(baseLine.p1(), baseLine.p2() + vectorRight); |
|
2432 |
} |
|
2433 |
||
2434 |
if (nextSelected) { |
|
2435 |
adjustedRight += vectorLeft; |
|
2436 |
baseLine = QLine(baseLine.p1(), baseLine.p2() + vectorLeft); |
|
2437 |
} |
|
2438 |
if (previousSelected) { |
|
2439 |
adjustedLeft += vectorRight; |
|
2440 |
baseLine = QLine(baseLine.p1() + vectorRight, baseLine.p2()); |
|
2441 |
} |
|
2442 |
if (atBeginning) |
|
2443 |
adjustedLeft += vectorRight; |
|
2444 |
||
2445 |
painter->setPen(QPen(baseColor2, 0)); |
|
2446 |
if (!selected) |
|
2447 |
painter->drawLine(baseLine); |
|
2448 |
||
2449 |
if (atEnd && !selected) |
|
2450 |
painter->drawPoint(baseLine.p2() + vectorRight); |
|
2451 |
||
2452 |
if (atBeginning && !selected) |
|
2453 |
adjustedLeft = vectorRight; |
|
2454 |
else |
|
2455 |
adjustedLeft = QPoint(0, 0); |
|
2456 |
painter->setPen(QPen(baseColor1, 0)); |
|
2457 |
if (!selected) |
|
2458 |
painter->drawLine(bottomLeft + vectorUp + adjustedLeft, baseLine.p2() + vectorUp); |
|
2459 |
||
2460 |
QPoint endPoint = bottomRight + vectorUp; |
|
2461 |
if (atEnd && !selected) |
|
2462 |
painter->drawPoint(endPoint); |
|
2463 |
||
2464 |
// For drawing a lower left "fake" corner on the base when the first tab is unselected |
|
2465 |
if (atBeginning && !selected) { |
|
2466 |
painter->drawPoint(baseLine.p1() + vectorLeft); |
|
2467 |
} |
|
2468 |
||
2469 |
painter->setPen(QPen(corner, 0)); |
|
2470 |
if (nextSelected) |
|
2471 |
painter->drawPoint(endPoint); |
|
2472 |
else if (selected) |
|
2473 |
painter->drawPoint(endPoint + vectorRight); |
|
2474 |
||
2475 |
// For drawing a lower left "fake" corner on the base when the first tab is unselected |
|
2476 |
if (atBeginning && !selected) { |
|
2477 |
painter->drawPoint(baseLine.p1() + 2 * vectorLeft); |
|
2478 |
} |
|
2479 |
} |
|
2480 |
} |
|
2481 |
} |
|
2482 |
||
2483 |
// Yay we're done |
|
2484 |
||
2485 |
painter->restore(); |
|
2486 |
} |
|
2487 |
break; |
|
2488 |
#endif // QT_NO_TABBAR |
|
2489 |
#ifndef QT_NO_PROGRESSBAR |
|
2490 |
case CE_ProgressBarGroove: |
|
2491 |
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { |
|
2492 |
QRect rect = bar->rect; |
|
2493 |
QPen oldPen = painter->pen(); |
|
2494 |
||
2495 |
QLine lines[4]; |
|
2496 |
||
2497 |
// outline |
|
2498 |
painter->setPen(borderColor); |
|
2499 |
lines[0] = QLine(rect.left() + 2, rect.top(), rect.right() - 2, rect.top()); |
|
2500 |
lines[1] = QLine(rect.left() + 2, rect.bottom(), rect.right() - 2, rect.bottom()); |
|
2501 |
lines[2] = QLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2); |
|
2502 |
lines[3] = QLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2); |
|
2503 |
painter->drawLines(lines, 4); |
|
2504 |
||
2505 |
QPoint points[8]; |
|
2506 |
points[0] = QPoint(rect.left() + 1, rect.top() + 1); |
|
2507 |
points[1] = QPoint(rect.right() - 1, rect.top() + 1); |
|
2508 |
points[2] = QPoint(rect.left() + 1, rect.bottom() - 1); |
|
2509 |
points[3] = QPoint(rect.right() - 1, rect.bottom() - 1); |
|
2510 |
painter->drawPoints(points, 4); |
|
2511 |
||
2512 |
// alpha corners |
|
2513 |
painter->setPen(alphaCornerColor); |
|
2514 |
points[0] = QPoint(rect.left(), rect.top() + 1); |
|
2515 |
points[1] = QPoint(rect.left() + 1, rect.top()); |
|
2516 |
points[2] = QPoint(rect.right(), rect.top() + 1); |
|
2517 |
points[3] = QPoint(rect.right() - 1, rect.top()); |
|
2518 |
points[4] = QPoint(rect.left(), rect.bottom() - 1); |
|
2519 |
points[5] = QPoint(rect.left() + 1, rect.bottom()); |
|
2520 |
points[6] = QPoint(rect.right(), rect.bottom() - 1); |
|
2521 |
points[7] = QPoint(rect.right() - 1, rect.bottom()); |
|
2522 |
painter->drawPoints(points, 8); |
|
2523 |
||
2524 |
// inner outline, north-west |
|
2525 |
painter->setPen(gradientStartColor.darker(105)); |
|
2526 |
lines[0] = QLine(rect.left() + 2, rect.top() + 1, rect.right() - 2, rect.top() + 1); |
|
2527 |
lines[1] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2); |
|
2528 |
painter->drawLines(lines, 2); |
|
2529 |
||
2530 |
// base of the groove |
|
2531 |
painter->setPen(QPen()); |
|
2532 |
painter->fillRect(rect.adjusted(2, 2, -2, -1), QBrush(bar->palette.base().color())); |
|
2533 |
painter->setPen(bar->palette.base().color()); |
|
2534 |
painter->drawLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2); |
|
2535 |
||
2536 |
painter->setPen(oldPen); |
|
2537 |
} |
|
2538 |
break; |
|
2539 |
case CE_ProgressBarLabel: |
|
2540 |
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { |
|
2541 |
// The busy indicator doesn't draw a label |
|
2542 |
if (bar->minimum == 0 && bar->maximum == 0) |
|
2543 |
return; |
|
2544 |
||
2545 |
painter->save(); |
|
2546 |
||
2547 |
QRect rect = bar->rect; |
|
2548 |
QRect leftRect; |
|
2549 |
||
2550 |
QFont font; |
|
2551 |
font.setBold(true); |
|
2552 |
painter->setFont(font); |
|
2553 |
painter->setPen(bar->palette.text().color()); |
|
2554 |
||
2555 |
bool vertical = false; |
|
2556 |
bool inverted = false; |
|
2557 |
bool bottomToTop = false; |
|
2558 |
// Get extra style options if version 2 |
|
2559 |
if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
2560 |
vertical = (bar2->orientation == Qt::Vertical); |
|
2561 |
inverted = bar2->invertedAppearance; |
|
2562 |
bottomToTop = bar2->bottomToTop; |
|
2563 |
} |
|
2564 |
||
2565 |
if (vertical) { |
|
2566 |
rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height |
|
2567 |
QTransform m; |
|
2568 |
if (bottomToTop) { |
|
2569 |
m.translate(0.0, rect.width()); |
|
2570 |
m.rotate(-90); |
|
2571 |
} else { |
|
2572 |
m.translate(rect.height(), 0.0); |
|
2573 |
m.rotate(90); |
|
2574 |
} |
|
2575 |
painter->setTransform(m, true); |
|
2576 |
} |
|
2577 |
||
2578 |
int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum) * rect.width(); |
|
2579 |
||
2580 |
bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted) |
|
2581 |
|| ((bar->direction == Qt::LeftToRight) && inverted))) || (vertical && ((!inverted && !bottomToTop) || (inverted && bottomToTop))); |
|
2582 |
if (flip) { |
|
2583 |
int indicatorPos = rect.width() - progressIndicatorPos; |
|
2584 |
if (indicatorPos >= 0 && indicatorPos <= rect.width()) { |
|
2585 |
painter->setPen(bar->palette.base().color()); |
|
2586 |
leftRect = QRect(rect.left(), rect.top(), indicatorPos, rect.height()); |
|
2587 |
} else if (indicatorPos > rect.width()) { |
|
2588 |
painter->setPen(bar->palette.text().color()); |
|
2589 |
} else { |
|
2590 |
painter->setPen(bar->palette.base().color()); |
|
2591 |
} |
|
2592 |
} else { |
|
2593 |
if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width()) { |
|
2594 |
leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height()); |
|
2595 |
} else if (progressIndicatorPos > rect.width()) { |
|
2596 |
painter->setPen(bar->palette.base().color()); |
|
2597 |
} else { |
|
2598 |
painter->setPen(bar->palette.text().color()); |
|
2599 |
} |
|
2600 |
} |
|
2601 |
||
2602 |
QRegion rightRect = rect; |
|
2603 |
rightRect = rightRect.subtracted(leftRect); |
|
2604 |
painter->setClipRegion(rightRect); |
|
2605 |
painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter)); |
|
2606 |
if (!leftRect.isNull()) { |
|
2607 |
painter->setPen(flip ? bar->palette.text().color() : bar->palette.base().color()); |
|
2608 |
painter->setClipRect(leftRect); |
|
2609 |
painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter)); |
|
2610 |
} |
|
2611 |
||
2612 |
painter->restore(); |
|
2613 |
} |
|
2614 |
break; |
|
2615 |
case CE_ProgressBarContents: |
|
2616 |
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { |
|
2617 |
Q_D(const QPlastiqueStyle); |
|
2618 |
QRect rect = bar->rect; |
|
2619 |
bool vertical = false; |
|
2620 |
bool inverted = false; |
|
2621 |
bool indeterminate = (bar->minimum == 0 && bar->maximum == 0); |
|
2622 |
if (!indeterminate && bar->progress == -1) |
|
2623 |
break; |
|
2624 |
||
2625 |
painter->save(); |
|
2626 |
||
2627 |
// Get extra style options if version 2 |
|
2628 |
if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
2629 |
vertical = (bar2->orientation == Qt::Vertical); |
|
2630 |
inverted = bar2->invertedAppearance; |
|
2631 |
} |
|
2632 |
||
2633 |
// If the orientation is vertical, we use a transform to rotate |
|
2634 |
// the progress bar 90 degrees clockwise. This way we can use the |
|
2635 |
// same rendering code for both orientations. |
|
2636 |
if (vertical) { |
|
2637 |
rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height |
|
2638 |
QTransform m = QTransform::fromTranslate(rect.height()-1, 0); |
|
2639 |
m.rotate(90.0); |
|
2640 |
painter->setTransform(m, true); |
|
2641 |
} |
|
2642 |
||
2643 |
int maxWidth = rect.width() - 4; |
|
2644 |
int minWidth = 4; |
|
2645 |
qint64 progress = qMax<qint64>(bar->progress, bar->minimum); // workaround for bug in QProgressBar |
|
2646 |
double vc6_workaround = ((progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth); |
|
2647 |
int width = indeterminate ? maxWidth : qMax(int(vc6_workaround), minWidth); |
|
2648 |
bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; |
|
2649 |
if (inverted) |
|
2650 |
reverse = !reverse; |
|
2651 |
||
2652 |
QRect progressBar; |
|
2653 |
if (!indeterminate) { |
|
2654 |
if (!reverse) { |
|
2655 |
progressBar.setRect(rect.left() + 2, rect.top() + 2, width, rect.height() - 4); |
|
2656 |
} else { |
|
2657 |
progressBar.setRect(rect.right() - 1 - width, rect.top() + 2, width, rect.height() - 4); |
|
2658 |
} |
|
2659 |
} else { |
|
2660 |
int slideWidth = ((rect.width() - 4) * 2) / 3; |
|
2661 |
int step = ((d->animateStep * slideWidth) / ProgressBarFps) % slideWidth; |
|
2662 |
if ((((d->animateStep * slideWidth) / ProgressBarFps) % (2 * slideWidth)) >= slideWidth) |
|
2663 |
step = slideWidth - step; |
|
2664 |
progressBar.setRect(rect.left() + 2 + step, rect.top() + 2, |
|
2665 |
slideWidth / 2, rect.height() - 4); |
|
2666 |
} |
|
2667 |
||
2668 |
// outline |
|
2669 |
painter->setPen(highlightedDarkInnerBorderColor); |
|
2670 |
||
2671 |
QVarLengthArray<QLine, 4> lines; |
|
2672 |
QVarLengthArray<QPoint, 8> points; |
|
2673 |
if (!reverse) { |
|
2674 |
if (width == minWidth) { |
|
2675 |
points.append(QPoint(progressBar.left() + 1, progressBar.top())); |
|
2676 |
points.append(QPoint(progressBar.left() + 1, progressBar.bottom())); |
|
2677 |
} else { |
|
2678 |
if (indeterminate) { |
|
2679 |
lines.append(QLine(progressBar.left() + 2, progressBar.top(), |
|
2680 |
progressBar.right() - 2, progressBar.top())); |
|
2681 |
lines.append(QLine(progressBar.left() + 2, progressBar.bottom(), |
|
2682 |
progressBar.right() - 2, progressBar.bottom())); |
|
2683 |
} else { |
|
2684 |
lines.append(QLine(progressBar.left() + 1, progressBar.top(), |
|
2685 |
progressBar.right() - 2, progressBar.top())); |
|
2686 |
lines.append(QLine(progressBar.left() + 1, progressBar.bottom(), |
|
2687 |
progressBar.right() - 2, progressBar.bottom())); |
|
2688 |
} |
|
2689 |
} |
|
2690 |
||
2691 |
if (indeterminate) { |
|
2692 |
lines.append(QLine(progressBar.left(), progressBar.top() + 2, |
|
2693 |
progressBar.left(), progressBar.bottom() - 2)); |
|
2694 |
} else { |
|
2695 |
lines.append(QLine(progressBar.left(), progressBar.top() + 1, |
|
2696 |
progressBar.left(), progressBar.bottom() - 1)); |
|
2697 |
} |
|
2698 |
lines.append(QLine(progressBar.right(), progressBar.top() + 2, |
|
2699 |
progressBar.right(), progressBar.bottom() - 2)); |
|
2700 |
} else { |
|
2701 |
if (width == minWidth) { |
|
2702 |
points.append(QPoint(progressBar.right() - 1, progressBar.top())); |
|
2703 |
points.append(QPoint(progressBar.right() - 1, progressBar.bottom())); |
|
2704 |
} else { |
|
2705 |
if (indeterminate) { |
|
2706 |
lines.append(QLine(progressBar.right() - 2, progressBar.top(), |
|
2707 |
progressBar.left() + 2, progressBar.top())); |
|
2708 |
lines.append(QLine(progressBar.right() - 2, progressBar.bottom(), |
|
2709 |
progressBar.left() + 2, progressBar.bottom())); |
|
2710 |
} else { |
|
2711 |
lines.append(QLine(progressBar.right() - 1, progressBar.top(), |
|
2712 |
progressBar.left() + 2, progressBar.top())); |
|
2713 |
lines.append(QLine(progressBar.right() - 1, progressBar.bottom(), |
|
2714 |
progressBar.left() + 2, progressBar.bottom())); |
|
2715 |
} |
|
2716 |
} |
|
2717 |
if (indeterminate) { |
|
2718 |
lines.append(QLine(progressBar.right(), progressBar.top() + 2, |
|
2719 |
progressBar.right(), progressBar.bottom() - 2)); |
|
2720 |
} else { |
|
2721 |
lines.append(QLine(progressBar.right(), progressBar.top() + 1, |
|
2722 |
progressBar.right(), progressBar.bottom() - 1)); |
|
2723 |
} |
|
2724 |
lines.append(QLine(progressBar.left(), progressBar.top() + 2, |
|
2725 |
progressBar.left(), progressBar.bottom() - 2)); |
|
2726 |
} |
|
2727 |
||
2728 |
if (points.size() > 0) { |
|
2729 |
painter->drawPoints(points.constData(), points.size()); |
|
2730 |
points.clear(); |
|
2731 |
} |
|
2732 |
painter->drawLines(lines.constData(), lines.size()); |
|
2733 |
lines.clear(); |
|
2734 |
||
2735 |
// alpha corners |
|
2736 |
painter->setPen(alphaInnerColor); |
|
2737 |
if (!reverse) { |
|
2738 |
if (indeterminate) { |
|
2739 |
points.append(QPoint(progressBar.left() + 1, progressBar.top())); |
|
2740 |
points.append(QPoint(progressBar.left(), progressBar.top() + 1)); |
|
2741 |
points.append(QPoint(progressBar.left() + 1, progressBar.bottom())); |
|
2742 |
points.append(QPoint(progressBar.left(), progressBar.bottom() - 1)); |
|
2743 |
} else { |
|
2744 |
points.append(QPoint(progressBar.left(), progressBar.top())); |
|
2745 |
points.append(QPoint(progressBar.left(), progressBar.bottom())); |
|
2746 |
} |
|
2747 |
points.append(QPoint(progressBar.right() - 1, progressBar.top())); |
|
2748 |
points.append(QPoint(progressBar.right(), progressBar.top() + 1)); |
|
2749 |
points.append(QPoint(progressBar.right() - 1, progressBar.bottom())); |
|
2750 |
points.append(QPoint(progressBar.right(), progressBar.bottom() - 1)); |
|
2751 |
} else { |
|
2752 |
if (indeterminate) { |
|
2753 |
points.append(QPoint(progressBar.right() - 1, progressBar.top())); |
|
2754 |
points.append(QPoint(progressBar.right(), progressBar.top() + 1)); |
|
2755 |
points.append(QPoint(progressBar.right() - 1, progressBar.bottom())); |
|
2756 |
points.append(QPoint(progressBar.right(), progressBar.bottom() - 1)); |
|
2757 |
} else { |
|
2758 |
points.append(QPoint(progressBar.right(), progressBar.top())); |
|
2759 |
points.append(QPoint(progressBar.right(), progressBar.bottom())); |
|
2760 |
} |
|
2761 |
points.append(QPoint(progressBar.left() + 1, progressBar.top())); |
|
2762 |
points.append(QPoint(progressBar.left(), progressBar.top() + 1)); |
|
2763 |
points.append(QPoint(progressBar.left() + 1, progressBar.bottom())); |
|
2764 |
points.append(QPoint(progressBar.left(), progressBar.bottom() - 1)); |
|
2765 |
} |
|
2766 |
||
2767 |
painter->drawPoints(points.constData(), points.size()); |
|
2768 |
points.clear(); |
|
2769 |
||
2770 |
// contents |
|
2771 |
painter->setPen(QPen()); |
|
2772 |
||
2773 |
QString progressBarName = QStyleHelper::uniqueName(QLatin1String("progressBarContents"), |
|
2774 |
option, rect.size()); |
|
2775 |
QPixmap cache; |
|
2776 |
if (!QPixmapCache::find(progressBarName, cache) && rect.height() > 7) { |
|
2777 |
QSize size = rect.size(); |
|
2778 |
cache = QPixmap(QSize(size.width() - 6 + 30, size.height() - 6)); |
|
2779 |
cache.fill(Qt::white); |
|
2780 |
QPainter cachePainter(&cache); |
|
2781 |
QRect pixmapRect(0, 0, cache.width(), cache.height()); |
|
2782 |
||
2783 |
int leftEdge = 0; |
|
2784 |
bool flip = false; |
|
2785 |
while (leftEdge < cache.width() + 1) { |
|
2786 |
QColor rectColor = option->palette.highlight().color(); |
|
2787 |
QColor lineColor = option->palette.highlight().color(); |
|
2788 |
if (flip) { |
|
2789 |
flip = false; |
|
2790 |
rectColor = rectColor.lighter(105); |
|
2791 |
lineColor = lineColor.lighter(105); |
|
2792 |
} else { |
|
2793 |
flip = true; |
|
2794 |
} |
|
2795 |
||
2796 |
cachePainter.setPen(lineColor); |
|
2797 |
const QLine cacheLines[2] = { |
|
2798 |
QLine(pixmapRect.left() + leftEdge - 1, pixmapRect.top(), |
|
2799 |
pixmapRect.left() + leftEdge + 9, pixmapRect.top()), |
|
2800 |
QLine(pixmapRect.left() + leftEdge - 1, pixmapRect.bottom(), |
|
2801 |
pixmapRect.left() + leftEdge + 9, pixmapRect.bottom()) }; |
|
2802 |
cachePainter.drawLines(cacheLines, 2); |
|
2803 |
cachePainter.fillRect(QRect(pixmapRect.left() + leftEdge, pixmapRect.top(), |
|
2804 |
10, pixmapRect.height()), rectColor); |
|
2805 |
||
2806 |
leftEdge += 10; |
|
2807 |
} |
|
2808 |
||
2809 |
QPixmapCache::insert(progressBarName, cache); |
|
2810 |
} |
|
2811 |
painter->setClipRect(progressBar.adjusted(1, 0, -1, -1)); |
|
2812 |
||
2813 |
if (!vertical) |
|
2814 |
progressBar.adjust(0, 1, 0, 1); |
|
2815 |
if (!indeterminate) { |
|
2816 |
int step = (AnimateProgressBar || (indeterminate && AnimateBusyProgressBar)) ? (d->animateStep % 20) : 0; |
|
2817 |
if (reverse) |
|
2818 |
painter->drawPixmap(progressBar.left() - 25 + step, progressBar.top(), cache); |
|
2819 |
else |
|
2820 |
painter->drawPixmap(progressBar.left() - 25 - step + width % 20, progressBar.top(), cache); |
|
2821 |
} else { |
|
2822 |
painter->drawPixmap(progressBar.left(), progressBar.top(), cache); |
|
2823 |
} |
|
2824 |
||
2825 |
painter->restore(); |
|
2826 |
} |
|
2827 |
break; |
|
2828 |
#endif // QT_NO_PROGRESSBAR |
|
2829 |
case CE_HeaderSection: |
|
2830 |
// Draws the header in tables. |
|
2831 |
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
|
2832 |
QPixmap cache; |
|
2833 |
QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size()); |
|
2834 |
pixmapName += QString::number(- int(header->position)); |
|
2835 |
pixmapName += QString::number(- int(header->orientation)); |
|
2836 |
||
2837 |
if (!QPixmapCache::find(pixmapName, cache)) { |
|
2838 |
cache = QPixmap(option->rect.size()); |
|
2839 |
cache.fill(Qt::white); |
|
2840 |
QRect pixmapRect(0, 0, option->rect.width(), option->rect.height()); |
|
2841 |
QPainter cachePainter(&cache); |
|
2842 |
||
2843 |
bool sunken = (header->state & State_Enabled) && (header->state & State_Sunken); |
|
2844 |
||
2845 |
QColor headerGradientStart = sunken ? option->palette.background().color().darker(114) : gradientStartColor; |
|
2846 |
QColor headerGradientStop = sunken ? option->palette.background().color().darker(106) : gradientStopColor; |
|
2847 |
||
2848 |
QColor lightLine = sunken ? option->palette.background().color().darker(118) : gradientStartColor; |
|
2849 |
QColor darkLine = sunken ? option->palette.background().color().darker(110) : gradientStopColor.darker(105); |
|
2850 |
||
2851 |
qt_plastique_draw_gradient(&cachePainter, pixmapRect, |
|
2852 |
headerGradientStart, headerGradientStop); |
|
2853 |
||
2854 |
cachePainter.setPen(borderColor); |
|
2855 |
cachePainter.drawRect(pixmapRect.adjusted(0, 0, -1, -1)); |
|
2856 |
cachePainter.setPen(alphaCornerColor); |
|
2857 |
||
2858 |
const QPoint points[4] = { |
|
2859 |
pixmapRect.topLeft(), pixmapRect.topRight(), |
|
2860 |
pixmapRect.bottomLeft(), pixmapRect.bottomRight() }; |
|
2861 |
cachePainter.drawPoints(points, 4); |
|
2862 |
||
2863 |
QLine lines[2]; |
|
2864 |
||
2865 |
// inner lines |
|
2866 |
cachePainter.setPen(lightLine); |
|
2867 |
lines[0] = QLine(pixmapRect.left() + 2, pixmapRect.top() + 1, |
|
2868 |
pixmapRect.right() - 2, pixmapRect.top() + 1); |
|
2869 |
lines[1] = QLine(pixmapRect.left() + 1, pixmapRect.top() + 2, |
|
2870 |
pixmapRect.left() + 1, pixmapRect.bottom() - 2); |
|
2871 |
cachePainter.drawLines(lines, 2); |
|
2872 |
||
2873 |
cachePainter.setPen(darkLine); |
|
2874 |
lines[0] = QLine(pixmapRect.left() + 2, pixmapRect.bottom() - 1, |
|
2875 |
pixmapRect.right() - 2, pixmapRect.bottom() - 1); |
|
2876 |
lines[1] = QLine(pixmapRect.right() - 1, pixmapRect.bottom() - 2, |
|
2877 |
pixmapRect.right() - 1, pixmapRect.top() + 2); |
|
2878 |
cachePainter.drawLines(lines, 2); |
|
2879 |
||
2880 |
cachePainter.end(); |
|
2881 |
QPixmapCache::insert(pixmapName, cache); |
|
2882 |
} |
|
2883 |
painter->drawPixmap(option->rect.topLeft(), cache); |
|
2884 |
||
2885 |
} |
|
2886 |
break; |
|
2887 |
#ifndef QT_NO_MENU |
|
2888 |
case CE_MenuItem: |
|
2889 |
// Draws one item in a popup menu. |
|
2890 |
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
2891 |
painter->save(); |
|
2892 |
QBrush textBrush; |
|
2893 |
if (option->palette.resolve() & (1 << QPalette::ButtonText)) |
|
2894 |
textBrush = option->palette.buttonText(); |
|
2895 |
else |
|
2896 |
textBrush = option->palette.windowText(); // KDE uses windowText rather than buttonText for menus |
|
2897 |
||
2898 |
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { |
|
2899 |
painter->fillRect(menuItem->rect, option->palette.background().color().lighter(103)); |
|
2900 |
||
2901 |
int w = 0; |
|
2902 |
if (!menuItem->text.isEmpty()) { |
|
2903 |
painter->setFont(menuItem->font); |
|
2904 |
proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, |
|
2905 |
menuItem->palette, menuItem->state & State_Enabled, menuItem->text, |
|
2906 |
QPalette::Text); |
|
2907 |
w = menuItem->fontMetrics.width(menuItem->text) + 5; |
|
2908 |
} |
|
2909 |
||
2910 |
painter->setPen(alphaCornerColor); |
|
2911 |
bool reverse = menuItem->direction == Qt::RightToLeft; |
|
2912 |
painter->drawLine(menuItem->rect.left() + 5 + (reverse ? 0 : w), menuItem->rect.center().y(), |
|
2913 |
menuItem->rect.right() - 5 - (reverse ? w : 0), menuItem->rect.center().y()); |
|
2914 |
||
2915 |
painter->restore(); |
|
2916 |
break; |
|
2917 |
} |
|
2918 |
||
2919 |
bool selected = menuItem->state & State_Selected; |
|
2920 |
bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; |
|
2921 |
bool checked = menuItem->checked; |
|
2922 |
||
2923 |
if (selected) { |
|
2924 |
qt_plastique_draw_gradient(painter, menuItem->rect, |
|
2925 |
option->palette.highlight().color().lighter(105), |
|
2926 |
option->palette.highlight().color().darker(110)); |
|
2927 |
||
2928 |
painter->setPen(option->palette.highlight().color().lighter(110)); |
|
2929 |
painter->drawLine(option->rect.topLeft(), option->rect.topRight()); |
|
2930 |
painter->setPen(option->palette.highlight().color().darker(115)); |
|
2931 |
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); |
|
2932 |
} else { |
|
2933 |
painter->fillRect(option->rect, option->palette.background().color().lighter(103)); |
|
2934 |
} |
|
2935 |
||
2936 |
// Check |
|
2937 |
QRect checkRect(option->rect.left() + 7, option->rect.center().y() - 6, 13, 13); |
|
2938 |
checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect); |
|
2939 |
if (checkable) { |
|
2940 |
if ((menuItem->checkType & QStyleOptionMenuItem::Exclusive) && menuItem->icon.isNull()) { |
|
2941 |
QStyleOptionButton button; |
|
2942 |
button.rect = checkRect; |
|
2943 |
button.state = menuItem->state; |
|
2944 |
if (checked) |
|
2945 |
button.state |= State_On; |
|
2946 |
button.palette = menuItem->palette; |
|
2947 |
proxy()->drawPrimitive(PE_IndicatorRadioButton, &button, painter, widget); |
|
2948 |
} else { |
|
2949 |
if (menuItem->icon.isNull()) { |
|
2950 |
QStyleOptionButton button; |
|
2951 |
button.rect = checkRect; |
|
2952 |
button.state = menuItem->state; |
|
2953 |
if (checked) |
|
2954 |
button.state |= State_On; |
|
2955 |
button.palette = menuItem->palette; |
|
2956 |
proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); |
|
2957 |
} else if (checked) { |
|
2958 |
int iconSize = qMax(menuItem->maxIconWidth, 20); |
|
2959 |
QRect sunkenRect(option->rect.left() + 1, |
|
2960 |
option->rect.top() + (option->rect.height() - iconSize) / 2 + 1, |
|
2961 |
iconSize, iconSize); |
|
2962 |
sunkenRect = visualRect(menuItem->direction, menuItem->rect, sunkenRect); |
|
2963 |
||
2964 |
QStyleOption opt = *option; |
|
2965 |
opt.state |= State_Sunken; |
|
2966 |
opt.rect = sunkenRect; |
|
2967 |
qt_plastique_drawShadedPanel(painter, &opt, false, widget); |
|
2968 |
} |
|
2969 |
} |
|
2970 |
} |
|
2971 |
||
2972 |
// Text and icon, ripped from windows style |
|
2973 |
bool dis = !(menuItem->state & State_Enabled); |
|
2974 |
bool act = menuItem->state & State_Selected; |
|
2975 |
const QStyleOption *opt = option; |
|
2976 |
const QStyleOptionMenuItem *menuitem = menuItem; |
|
2977 |
int checkcol = qMax(menuitem->maxIconWidth, 20); |
|
2978 |
QPainter *p = painter; |
|
2979 |
QRect vCheckRect = visualRect(opt->direction, menuitem->rect, |
|
2980 |
QRect(menuitem->rect.x(), menuitem->rect.y(), |
|
2981 |
checkcol, menuitem->rect.height())); |
|
2982 |
if (!menuItem->icon.isNull()) { |
|
2983 |
QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal; |
|
2984 |
if (act && !dis) |
|
2985 |
mode = QIcon::Active; |
|
2986 |
QPixmap pixmap; |
|
2987 |
if (checked) |
|
2988 |
pixmap = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On); |
|
2989 |
else |
|
2990 |
pixmap = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), mode); |
|
2991 |
int pixw = pixmap.width(); |
|
2992 |
int pixh = pixmap.height(); |
|
2993 |
||
2994 |
QRect pmr(0, 0, pixw, pixh); |
|
2995 |
pmr.moveCenter(vCheckRect.center()); |
|
2996 |
painter->setPen(textBrush.color()); |
|
2997 |
if (checkable && checked) |
|
2998 |
painter->drawPixmap(QPoint(pmr.left() + 1, pmr.top() + 1), pixmap); |
|
2999 |
else |
|
3000 |
painter->drawPixmap(pmr.topLeft(), pixmap); |
|
3001 |
} |
|
3002 |
||
3003 |
if (selected) { |
|
3004 |
painter->setPen(menuItem->palette.highlightedText().color()); |
|
3005 |
} else { |
|
3006 |
painter->setPen(textBrush.color()); |
|
3007 |
} |
|
3008 |
int x, y, w, h; |
|
3009 |
menuitem->rect.getRect(&x, &y, &w, &h); |
|
3010 |
int tab = menuitem->tabWidth; |
|
3011 |
QColor discol; |
|
3012 |
if (dis) { |
|
3013 |
discol = textBrush.color(); |
|
3014 |
p->setPen(discol); |
|
3015 |
} |
|
3016 |
int xm = windowsItemFrame + checkcol + windowsItemHMargin; |
|
3017 |
int xpos = menuitem->rect.x() + xm; |
|
3018 |
QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); |
|
3019 |
QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); |
|
3020 |
QString s = menuitem->text; |
|
3021 |
if (!s.isEmpty()) { // draw text |
|
3022 |
p->save(); |
|
3023 |
int t = s.indexOf(QLatin1Char('\t')); |
|
3024 |
int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; |
|
3025 |
if (!styleHint(SH_UnderlineShortcut, menuitem, widget)) |
|
3026 |
text_flags |= Qt::TextHideMnemonic; |
|
3027 |
text_flags |= Qt::AlignLeft; |
|
3028 |
if (t >= 0) { |
|
3029 |
QRect vShortcutRect = visualRect(opt->direction, menuitem->rect, |
|
3030 |
QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom()))); |
|
3031 |
if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) { |
|
3032 |
p->setPen(menuitem->palette.light().color()); |
|
3033 |
p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1)); |
|
3034 |
p->setPen(discol); |
|
3035 |
} |
|
3036 |
p->drawText(vShortcutRect, text_flags, s.mid(t + 1)); |
|
3037 |
s = s.left(t); |
|
3038 |
} |
|
3039 |
QFont font = menuitem->font; |
|
3040 |
if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) |
|
3041 |
font.setBold(true); |
|
3042 |
p->setFont(font); |
|
3043 |
if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) { |
|
3044 |
p->setPen(menuitem->palette.light().color()); |
|
3045 |
p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t)); |
|
3046 |
p->setPen(discol); |
|
3047 |
} |
|
3048 |
p->drawText(vTextRect, text_flags, s.left(t)); |
|
3049 |
p->restore(); |
|
3050 |
} |
|
3051 |
||
3052 |
// Arrow |
|
3053 |
if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow |
|
3054 |
int dim = (menuItem->rect.height() - 4) / 2; |
|
3055 |
PrimitiveElement arrow; |
|
3056 |
arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight; |
|
3057 |
int xpos = menuItem->rect.left() + menuItem->rect.width() - 6 - 2 - dim; |
|
3058 |
QRect vSubMenuRect = visualRect(option->direction, menuItem->rect, |
|
3059 |
QRect(xpos, menuItem->rect.top() + menuItem->rect.height() / 2 - dim / 2, dim, dim)); |
|
3060 |
QStyleOptionMenuItem newMI = *menuItem; |
|
3061 |
newMI.rect = vSubMenuRect; |
|
3062 |
newMI.state = option->state & State_Enabled; |
|
3063 |
if (selected) |
|
3064 |
newMI.palette.setColor(QPalette::ButtonText, |
|
3065 |
newMI.palette.highlightedText().color()); |
|
3066 |
else |
|
3067 |
newMI.palette.setColor(QPalette::ButtonText, textBrush.color()); |
|
3068 |
proxy()->drawPrimitive(arrow, &newMI, painter, widget); |
|
3069 |
} |
|
3070 |
||
3071 |
painter->restore(); |
|
3072 |
} |
|
3073 |
break; |
|
3074 |
#endif // QT_NO_MENU |
|
3075 |
#ifndef QT_NO_MENUBAR |
|
3076 |
case CE_MenuBarItem: |
|
3077 |
// Draws a menu bar item; File, Edit, Help etc.. |
|
3078 |
if ((option->state & State_Selected)) { |
|
3079 |
QPixmap cache; |
|
3080 |
QString pixmapName = QStyleHelper::uniqueName(QLatin1String("menubaritem"), option, option->rect.size()); |
|
3081 |
if (!QPixmapCache::find(pixmapName, cache)) { |
|
3082 |
cache = QPixmap(option->rect.size()); |
|
3083 |
cache.fill(Qt::white); |
|
3084 |
QRect pixmapRect(0, 0, option->rect.width(), option->rect.height()); |
|
3085 |
QPainter cachePainter(&cache); |
|
3086 |
||
3087 |
QRect rect = pixmapRect; |
|
3088 |
||
3089 |
// gradient fill |
|
3090 |
if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) { |
|
3091 |
qt_plastique_draw_gradient(&cachePainter, rect.adjusted(1, 1, -1, -1), |
|
3092 |
option->palette.button().color().darker(114), |
|
3093 |
option->palette.button().color().darker(106)); |
|
3094 |
} else { |
|
3095 |
qt_plastique_draw_gradient(&cachePainter, rect.adjusted(1, 1, -1, -1), |
|
3096 |
option->palette.background().color().lighter(105), |
|
3097 |
option->palette.background().color().darker(102)); |
|
3098 |
} |
|
3099 |
||
3100 |
// outer border and corners |
|
3101 |
cachePainter.setPen(borderColor); |
|
3102 |
cachePainter.drawRect(rect.adjusted(0, 0, -1, -1)); |
|
3103 |
cachePainter.setPen(alphaCornerColor); |
|
3104 |
||
3105 |
const QPoint points[4] = { |
|
3106 |
rect.topLeft(), |
|
3107 |
rect.topRight(), |
|
3108 |
rect.bottomLeft(), |
|
3109 |
rect.bottomRight() }; |
|
3110 |
cachePainter.drawPoints(points, 4); |
|
3111 |
||
3112 |
// inner border |
|
3113 |
if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) |
|
3114 |
cachePainter.setPen(option->palette.button().color().darker(118)); |
|
3115 |
else |
|
3116 |
cachePainter.setPen(gradientStartColor); |
|
3117 |
||
3118 |
QLine lines[2]; |
|
3119 |
lines[0] = QLine(rect.left() + 1, rect.top() + 1, rect.right() - 1, rect.top() + 1); |
|
3120 |
lines[1] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2); |
|
3121 |
cachePainter.drawLines(lines, 2); |
|
3122 |
||
3123 |
if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) |
|
3124 |
cachePainter.setPen(option->palette.button().color().darker(114)); |
|
3125 |
else |
|
3126 |
cachePainter.setPen(gradientStopColor.darker(102)); |
|
3127 |
lines[0] = QLine(rect.left() + 1, rect.bottom() - 1, rect.right() - 1, rect.bottom() - 1); |
|
3128 |
lines[1] = QLine(rect.right() - 1, rect.top() + 1, rect.right() - 1, rect.bottom() - 2); |
|
3129 |
cachePainter.drawLines(lines, 2); |
|
3130 |
cachePainter.end(); |
|
3131 |
QPixmapCache::insert(pixmapName, cache); |
|
3132 |
} |
|
3133 |
painter->drawPixmap(option->rect.topLeft(), cache); |
|
3134 |
} else { |
|
3135 |
painter->fillRect(option->rect, option->palette.background()); |
|
3136 |
} |
|
3137 |
||
3138 |
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
3139 |
QStyleOptionMenuItem newMI = *mbi; |
|
3140 |
if (!(option->palette.resolve() & (1 << QPalette::ButtonText))) //KDE uses windowText rather than buttonText for menus |
|
3141 |
newMI.palette.setColor(QPalette::ButtonText, newMI.palette.windowText().color()); |
|
3142 |
QCommonStyle::drawControl(element, &newMI, painter, widget); |
|
3143 |
} |
|
3144 |
break; |
|
3145 |
||
3146 |
#ifndef QT_NO_MAINWINDOW |
|
3147 |
case CE_MenuBarEmptyArea: |
|
3148 |
if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) { |
|
3149 |
painter->fillRect(option->rect, option->palette.window()); |
|
3150 |
QPen oldPen = painter->pen(); |
|
3151 |
painter->setPen(QPen(option->palette.dark().color())); |
|
3152 |
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); |
|
3153 |
painter->setPen(oldPen); |
|
3154 |
} |
|
3155 |
break; |
|
3156 |
#endif // QT_NO_MAINWINDOW |
|
3157 |
||
3158 |
#endif // QT_NO_MENUBAR |
|
3159 |
||
3160 |
#ifndef QT_NO_TOOLBOX |
|
3161 |
case CE_ToolBoxTabShape: |
|
3162 |
if (const QStyleOptionToolBox *toolBox = qstyleoption_cast<const QStyleOptionToolBox *>(option)) { |
|
3163 |
painter->save(); |
|
3164 |
||
3165 |
int width = toolBox->rect.width(); |
|
3166 |
int diag = toolBox->rect.height() - 2; |
|
3167 |
||
3168 |
// The essential points |
|
3169 |
QPoint rightMost; |
|
3170 |
QPoint rightEdge; |
|
3171 |
QPoint leftEdge; |
|
3172 |
QPoint leftMost; |
|
3173 |
QPoint leftOne; |
|
3174 |
QPoint rightOne; |
|
3175 |
QPoint upOne(0, -1); |
|
3176 |
QPoint downOne(0, 1); |
|
3177 |
||
3178 |
if (toolBox->direction != Qt::RightToLeft) { |
|
3179 |
rightMost = QPoint(toolBox->rect.right(), toolBox->rect.bottom() - 2); |
|
3180 |
rightEdge = QPoint(toolBox->rect.right() - width / 10, toolBox->rect.bottom() - 2); |
|
3181 |
leftEdge = QPoint(toolBox->rect.right() - width / 10 - diag, toolBox->rect.top()); |
|
3182 |
leftMost = QPoint(toolBox->rect.left(), toolBox->rect.top()); |
|
3183 |
leftOne = QPoint(-1, 0); |
|
3184 |
rightOne = QPoint(1, 0); |
|
3185 |
} else { |
|
3186 |
rightMost = QPoint(toolBox->rect.left(), toolBox->rect.bottom() - 2); |
|
3187 |
rightEdge = QPoint(toolBox->rect.left() + width / 10, toolBox->rect.bottom() - 2); |
|
3188 |
leftEdge = QPoint(toolBox->rect.left() + width / 10 + diag, toolBox->rect.top()); |
|
3189 |
leftMost = QPoint(toolBox->rect.right(), toolBox->rect.top()); |
|
3190 |
leftOne = QPoint(1, 0); |
|
3191 |
rightOne = QPoint(-1, 0); |
|
3192 |
} |
|
3193 |
||
3194 |
QLine lines[3]; |
|
3195 |
||
3196 |
// Draw the outline |
|
3197 |
painter->setPen(borderColor); |
|
3198 |
lines[0] = QLine(rightMost, rightEdge); |
|
3199 |
lines[1] = QLine(rightEdge + leftOne, leftEdge); |
|
3200 |
lines[2] = QLine(leftEdge + leftOne, leftMost); |
|
3201 |
painter->drawLines(lines, 3); |
|
3202 |
painter->setPen(toolBox->palette.base().color()); |
|
3203 |
lines[0] = QLine(rightMost + downOne, rightEdge + downOne); |
|
3204 |
lines[1] = QLine(rightEdge + leftOne + downOne, leftEdge + downOne); |
|
3205 |
lines[2] = QLine(leftEdge + leftOne + downOne, leftMost + downOne); |
|
3206 |
painter->drawLines(lines, 3); |
|
3207 |
||
3208 |
painter->restore(); |
|
3209 |
} |
|
3210 |
break; |
|
3211 |
#endif // QT_NO_TOOLBOX |
|
3212 |
#ifndef QT_NO_SPLITTER |
|
3213 |
case CE_Splitter: |
|
3214 |
if ((option->state & State_Enabled) && (option->state & State_MouseOver)) |
|
3215 |
painter->fillRect(option->rect, QColor(255, 255, 255, 128)); |
|
3216 |
if (option->state & State_Horizontal) { |
|
3217 |
int height = option->rect.height() / 3; |
|
3218 |
QRect rect(option->rect.left() + (option->rect.width() / 2 - 1), |
|
3219 |
option->rect.center().y() - height / 2, 3, height); |
|
3220 |
qt_plastique_draw_handle(painter, option, rect, Qt::Horizontal, widget); |
|
3221 |
} else { |
|
3222 |
int width = option->rect.width() / 3; |
|
3223 |
QRect rect(option->rect.center().x() - width / 2, |
|
3224 |
option->rect.top() + (option->rect.height() / 2) - 1, width, 3); |
|
3225 |
qt_plastique_draw_handle(painter, option, rect, Qt::Vertical, widget); |
|
3226 |
} |
|
3227 |
break; |
|
3228 |
#endif // QT_NO_SPLITTER |
|
3229 |
#ifndef QT_NO_DOCKWIDGET |
|
3230 |
case CE_DockWidgetTitle: |
|
3231 |
if (const QStyleOptionDockWidget *dockWidget = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) { |
|
3232 |
painter->save(); |
|
3233 |
||
3234 |
const QStyleOptionDockWidgetV2 *v2 |
|
3235 |
= qstyleoption_cast<const QStyleOptionDockWidgetV2*>(dockWidget); |
|
3236 |
bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar; |
|
3237 |
||
3238 |
// Find text width and title rect |
|
3239 |
int textWidth = option->fontMetrics.width(dockWidget->title); |
|
3240 |
int margin = 4; |
|
3241 |
QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget); |
|
3242 |
QRect rect = dockWidget->rect; |
|
3243 |
||
3244 |
if (verticalTitleBar) { |
|
3245 |
QRect r = rect; |
|
3246 |
QSize s = r.size(); |
|
3247 |
s.transpose(); |
|
3248 |
r.setSize(s); |
|
3249 |
||
3250 |
titleRect = QRect(r.left() + rect.bottom() |
|
3251 |
- titleRect.bottom(), |
|
3252 |
r.top() + titleRect.left() - rect.left(), |
|
3253 |
titleRect.height(), titleRect.width()); |
|
3254 |
||
3255 |
painter->translate(r.left(), r.top() + r.width()); |
|
3256 |
painter->rotate(-90); |
|
3257 |
painter->translate(-r.left(), -r.top()); |
|
3258 |
||
3259 |
rect = r; |
|
3260 |
} |
|
3261 |
||
3262 |
// Chop and insert ellide into title if text is too wide |
|
3263 |
QString title = elliditide(dockWidget->title, dockWidget->fontMetrics, titleRect, &textWidth); |
|
3264 |
||
3265 |
// Draw the toolbar handle pattern to the left and right of the text |
|
3266 |
QImage handle(qt_toolbarhandle); |
|
3267 |
alphaCornerColor.setAlpha(170); |
|
3268 |
handle.setColor(1, alphaCornerColor.rgba()); |
|
3269 |
handle.setColor(2, mergedColors(alphaCornerColor, option->palette.light().color()).rgba()); |
|
3270 |
handle.setColor(3, option->palette.light().color().rgba()); |
|
3271 |
||
3272 |
if (title.isEmpty()) { |
|
3273 |
// Joint handle if there's no title |
|
3274 |
QRect r; |
|
3275 |
#ifdef QT3_SUPPORT |
|
3276 |
// Q3DockWindow doesn't need space for buttons |
|
3277 |
if (widget && widget->inherits("Q3DockWindowTitleBar")) { |
|
3278 |
r = rect; |
|
3279 |
} else |
|
3280 |
#endif |
|
3281 |
r.setRect(titleRect.left(), titleRect.top(), titleRect.width(), titleRect.bottom()); |
|
3282 |
int nchunks = (r.width() / handle.width()) - 1; |
|
3283 |
int indent = (r.width() - (nchunks * handle.width())) / 2; |
|
3284 |
for (int i = 0; i < nchunks; ++i) { |
|
3285 |
painter->drawImage(QPoint(r.left() + indent + i * handle.width(), |
|
3286 |
r.center().y() - handle.height() / 2), |
|
3287 |
handle); |
|
3288 |
} |
|
3289 |
} else { |
|
3290 |
// Handle pattern to the left of the title |
|
3291 |
QRect leftSide(titleRect.left(), titleRect.top(), |
|
3292 |
titleRect.width() / 2 - textWidth / 2 - margin, titleRect.bottom()); |
|
3293 |
int nchunks = leftSide.width() / handle.width(); |
|
3294 |
int indent = (leftSide.width() - (nchunks * handle.width())) / 2; |
|
3295 |
for (int i = 0; i < nchunks; ++i) { |
|
3296 |
painter->drawImage(QPoint(leftSide.left() + indent |
|
3297 |
+ i * handle.width(), |
|
3298 |
leftSide.center().y() |
|
3299 |
- handle.height() / 2), |
|
3300 |
handle); |
|
3301 |
} |
|
3302 |
||
3303 |
// Handle pattern to the right of the title |
|
3304 |
QRect rightSide = titleRect.adjusted(titleRect.width() / 2 + textWidth / 2 + margin, 0, 0, 0); |
|
3305 |
nchunks = rightSide.width() / handle.width(); |
|
3306 |
indent = (rightSide.width() - (nchunks * handle.width())) / 2; |
|
3307 |
for (int j = 0; j < nchunks; ++j) { |
|
3308 |
painter->drawImage(QPoint(rightSide.left() + indent + j * handle.width(), |
|
3309 |
rightSide.center().y() - handle.height() / 2), |
|
3310 |
handle); |
|
3311 |
} |
|
3312 |
} |
|
3313 |
||
3314 |
// Draw the text centered |
|
3315 |
QFont font = painter->font(); |
|
3316 |
font.setPointSize(QFontInfo(font).pointSize() - 1); |
|
3317 |
painter->setFont(font); |
|
3318 |
painter->setPen(dockWidget->palette.windowText().color()); |
|
3319 |
painter->drawText(titleRect, |
|
3320 |
int(Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextShowMnemonic), |
|
3321 |
title); |
|
3322 |
||
3323 |
painter->restore(); |
|
3324 |
} |
|
3325 |
||
3326 |
break; |
|
3327 |
#endif // QT_NO_DOCKWIDGET |
|
3328 |
#ifndef QT_NO_TOOLBAR |
|
3329 |
case CE_ToolBar: |
|
3330 |
if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) { |
|
3331 |
// Draws the light line above and the dark line below menu bars and |
|
3332 |
// tool bars. |
|
3333 |
QPen oldPen = painter->pen(); |
|
3334 |
if (toolBar->toolBarArea == Qt::TopToolBarArea) { |
|
3335 |
if (toolBar->positionOfLine == QStyleOptionToolBar::End |
|
3336 |
|| toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) { |
|
3337 |
// The end and onlyone top toolbar lines draw a double |
|
3338 |
// line at the bottom to blend with the central |
|
3339 |
// widget. |
|
3340 |
painter->setPen(option->palette.background().color().lighter(104)); |
|
3341 |
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); |
|
3342 |
painter->setPen(alphaCornerColor); |
|
3343 |
painter->drawLine(option->rect.left(), option->rect.bottom() - 1, |
|
3344 |
option->rect.right(), option->rect.bottom() - 1); |
|
3345 |
} else { |
|
3346 |
// All others draw a single dark line at the bottom. |
|
3347 |
painter->setPen(alphaCornerColor); |
|
3348 |
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); |
|
3349 |
} |
|
3350 |
// All top toolbar lines draw a light line at the top. |
|
3351 |
painter->setPen(option->palette.background().color().lighter(104)); |
|
3352 |
painter->drawLine(option->rect.topLeft(), option->rect.topRight()); |
|
3353 |
} else if (toolBar->toolBarArea == Qt::BottomToolBarArea) { |
|
3354 |
if (toolBar->positionOfLine == QStyleOptionToolBar::End |
|
3355 |
|| toolBar->positionOfLine == QStyleOptionToolBar::Middle) { |
|
3356 |
// The end and middle bottom tool bar lines draw a dark |
|
3357 |
// line at the bottom. |
|
3358 |
painter->setPen(alphaCornerColor); |
|
3359 |
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); |
|
3360 |
} |
|
3361 |
if (toolBar->positionOfLine == QStyleOptionToolBar::Beginning |
|
3362 |
|| toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) { |
|
3363 |
// The beginning and only one tool bar lines draw a |
|
3364 |
// double line at the bottom to blend with the |
|
3365 |
// status bar. |
|
3366 |
// ### The styleoption could contain whether the |
|
3367 |
// main window has a menu bar and a status bar, and |
|
3368 |
// possibly dock widgets. |
|
3369 |
painter->setPen(alphaCornerColor); |
|
3370 |
painter->drawLine(option->rect.left(), option->rect.bottom() - 1, |
|
3371 |
option->rect.right(), option->rect.bottom() - 1); |
|
3372 |
painter->setPen(option->palette.background().color().lighter(104)); |
|
3373 |
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); |
|
3374 |
} |
|
3375 |
if (toolBar->positionOfLine == QStyleOptionToolBar::End) { |
|
3376 |
painter->setPen(alphaCornerColor); |
|
3377 |
painter->drawLine(option->rect.topLeft(), option->rect.topRight()); |
|
3378 |
painter->setPen(option->palette.background().color().lighter(104)); |
|
3379 |
painter->drawLine(option->rect.left(), option->rect.top() + 1, |
|
3380 |
option->rect.right(), option->rect.top() + 1); |
|
3381 |
||
3382 |
} else { |
|
3383 |
// All other bottom toolbars draw a light line at the top. |
|
3384 |
painter->setPen(option->palette.background().color().lighter(104)); |
|
3385 |
painter->drawLine(option->rect.topLeft(), option->rect.topRight()); |
|
3386 |
} |
|
3387 |
} |
|
3388 |
if (toolBar->toolBarArea == Qt::LeftToolBarArea) { |
|
3389 |
if (toolBar->positionOfLine == QStyleOptionToolBar::Middle |
|
3390 |
|| toolBar->positionOfLine == QStyleOptionToolBar::End) { |
|
3391 |
// The middle and left end toolbar lines draw a light |
|
3392 |
// line to the left. |
|
3393 |
painter->setPen(option->palette.background().color().lighter(104)); |
|
3394 |
painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft()); |
|
3395 |
} |
|
3396 |
if (toolBar->positionOfLine == QStyleOptionToolBar::End) { |
|
3397 |
// All other left toolbar lines draw a dark line to the right |
|
3398 |
painter->setPen(alphaCornerColor); |
|
3399 |
painter->drawLine(option->rect.right() - 1, option->rect.top(), |
|
3400 |
option->rect.right() - 1, option->rect.bottom()); |
|
3401 |
painter->setPen(option->palette.background().color().lighter(104)); |
|
3402 |
painter->drawLine(option->rect.topRight(), option->rect.bottomRight()); |
|
3403 |
} else { |
|
3404 |
// All other left toolbar lines draw a dark line to the right |
|
3405 |
painter->setPen(alphaCornerColor); |
|
3406 |
painter->drawLine(option->rect.topRight(), option->rect.bottomRight()); |
|
3407 |
} |
|
3408 |
} else if (toolBar->toolBarArea == Qt::RightToolBarArea) { |
|
3409 |
if (toolBar->positionOfLine == QStyleOptionToolBar::Middle |
|
3410 |
|| toolBar->positionOfLine == QStyleOptionToolBar::End) { |
|
3411 |
// Right middle and end toolbar lines draw the dark right line |
|
3412 |
painter->setPen(alphaCornerColor); |
|
3413 |
painter->drawLine(option->rect.topRight(), option->rect.bottomRight()); |
|
3414 |
} |
|
3415 |
if (toolBar->positionOfLine == QStyleOptionToolBar::End |
|
3416 |
|| toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) { |
|
3417 |
// The right end and single toolbar draws the dark |
|
3418 |
// line on its left edge |
|
3419 |
painter->setPen(alphaCornerColor); |
|
3420 |
painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft()); |
|
3421 |
// And a light line next to it |
|
3422 |
painter->setPen(option->palette.background().color().lighter(104)); |
|
3423 |
painter->drawLine(option->rect.left() + 1, option->rect.top(), |
|
3424 |
option->rect.left() + 1, option->rect.bottom()); |
|
3425 |
} else { |
|
3426 |
// Other right toolbars draw a light line on its left edge |
|
3427 |
painter->setPen(option->palette.background().color().lighter(104)); |
|
3428 |
painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft()); |
|
3429 |
} |
|
3430 |
} |
|
3431 |
painter->setPen(oldPen); |
|
3432 |
} |
|
3433 |
break; |
|
3434 |
#endif // QT_NO_TOOLBAR |
|
3435 |
#ifndef QT_NO_SCROLLBAR |
|
3436 |
case CE_ScrollBarAddLine: |
|
3437 |
if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
3438 |
||
3439 |
bool horizontal = scrollBar->orientation == Qt::Horizontal; |
|
3440 |
bool reverse = scrollBar->direction == Qt::RightToLeft; |
|
3441 |
bool sunken = scrollBar->state & State_Sunken; |
|
3442 |
||
3443 |
QString addLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_addline"), option, option->rect.size()); |
|
3444 |
QPixmap cache; |
|
3445 |
if (!QPixmapCache::find(addLinePixmapName, cache)) { |
|
3446 |
cache = QPixmap(option->rect.size()); |
|
3447 |
cache.fill(Qt::white); |
|
3448 |
QRect pixmapRect(0, 0, cache.width(), cache.height()); |
|
3449 |
QPainter addLinePainter(&cache); |
|
3450 |
addLinePainter.fillRect(pixmapRect, option->palette.background()); |
|
3451 |
||
3452 |
if (option->state & State_Enabled) { |
|
3453 |
// Gradient |
|
3454 |
QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top() + 2, |
|
3455 |
pixmapRect.center().x(), pixmapRect.bottom() - 2); |
|
3456 |
if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) { |
|
3457 |
gradient.setColorAt(0, gradientStopColor); |
|
3458 |
gradient.setColorAt(1, gradientStopColor); |
|
3459 |
} else { |
|
3460 |
gradient.setColorAt(0, gradientStartColor.lighter(105)); |
|
3461 |
gradient.setColorAt(1, gradientStopColor); |
|
3462 |
} |
|
3463 |
addLinePainter.fillRect(pixmapRect.left() + 2, pixmapRect.top() + 2, |
|
3464 |
pixmapRect.right() - 3, pixmapRect.bottom() - 3, |
|
3465 |
gradient); |
|
3466 |
} |
|
3467 |
||
3468 |
// Details |
|
3469 |
QImage addButton; |
|
3470 |
if (horizontal) { |
|
3471 |
addButton = QImage(reverse ? qt_scrollbar_button_left : qt_scrollbar_button_right); |
|
3472 |
} else { |
|
3473 |
addButton = QImage(qt_scrollbar_button_down); |
|
3474 |
} |
|
3475 |
addButton.setColor(1, alphaCornerColor.rgba()); |
|
3476 |
addButton.setColor(2, borderColor.rgba()); |
|
3477 |
if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) { |
|
3478 |
addButton.setColor(3, gradientStopColor.rgba()); |
|
3479 |
addButton.setColor(4, gradientStopColor.rgba()); |
|
3480 |
} else { |
|
3481 |
addButton.setColor(3, gradientStartColor.lighter(105).rgba()); |
|
3482 |
addButton.setColor(4, gradientStopColor.rgba()); |
|
3483 |
} |
|
3484 |
addButton.setColor(5, scrollBar->palette.text().color().rgba()); |
|
3485 |
addLinePainter.drawImage(pixmapRect, addButton); |
|
3486 |
||
3487 |
// Arrow |
|
3488 |
if (horizontal) { |
|
3489 |
QImage arrow(reverse ? qt_scrollbar_button_arrow_left : qt_scrollbar_button_arrow_right); |
|
3490 |
arrow.setColor(1, scrollBar->palette.foreground().color().rgba()); |
|
3491 |
||
3492 |
if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) |
|
3493 |
addLinePainter.translate(1, 1); |
|
3494 |
addLinePainter.drawImage(QPoint(pixmapRect.center().x() - 2, pixmapRect.center().y() - 3), arrow); |
|
3495 |
} else { |
|
3496 |
QImage arrow(qt_scrollbar_button_arrow_down); |
|
3497 |
arrow.setColor(1, scrollBar->palette.foreground().color().rgba()); |
|
3498 |
||
3499 |
if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) |
|
3500 |
addLinePainter.translate(1, 1); |
|
3501 |
addLinePainter.drawImage(QPoint(pixmapRect.center().x() - 3, pixmapRect.center().y() - 2), arrow); |
|
3502 |
} |
|
3503 |
addLinePainter.end(); |
|
3504 |
QPixmapCache::insert(addLinePixmapName, cache); |
|
3505 |
} |
|
3506 |
painter->drawPixmap(option->rect.topLeft(), cache); |
|
3507 |
} |
|
3508 |
break; |
|
3509 |
case CE_ScrollBarSubPage: |
|
3510 |
case CE_ScrollBarAddPage: |
|
3511 |
if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
3512 |
bool sunken = scrollBar->state & State_Sunken; |
|
3513 |
bool horizontal = scrollBar->orientation == Qt::Horizontal; |
|
3514 |
||
3515 |
QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_groove"), option, option->rect.size()); |
|
3516 |
if (sunken) |
|
3517 |
groovePixmapName += QLatin1String("-sunken"); |
|
3518 |
if (element == CE_ScrollBarAddPage) |
|
3519 |
groovePixmapName += QLatin1String("-addpage"); |
|
3520 |
||
3521 |
QPixmap cache; |
|
3522 |
if (!QPixmapCache::find(groovePixmapName, cache)) { |
|
3523 |
cache = QPixmap(option->rect.size()); |
|
3524 |
cache.fill(option->palette.background().color()); |
|
3525 |
QPainter groovePainter(&cache); |
|
3526 |
QRect pixmapRect = QRect(0, 0, option->rect.width(), option->rect.height()); |
|
3527 |
QColor color = scrollBar->palette.base().color().darker(sunken ? 125 : 100); |
|
3528 |
groovePainter.setBrushOrigin((element == CE_ScrollBarAddPage) ? pixmapRect.width() : 0, |
|
3529 |
(element == CE_ScrollBarAddPage) ? pixmapRect.height() : 0); |
|
3530 |
groovePainter.fillRect(pixmapRect, QBrush(color, Qt::Dense4Pattern)); |
|
3531 |
||
3532 |
QColor edgeColor = scrollBar->palette.base().color().darker(125); |
|
3533 |
if (horizontal) { |
|
3534 |
groovePainter.setBrushOrigin((element == CE_ScrollBarAddPage) ? pixmapRect.width() : 1, 0); |
|
3535 |
groovePainter.fillRect(QRect(pixmapRect.topLeft(), QSize(pixmapRect.width(), 1)), |
|
3536 |
QBrush(edgeColor, Qt::Dense4Pattern)); |
|
3537 |
groovePainter.fillRect(QRect(pixmapRect.bottomLeft(), QSize(pixmapRect.width(), 1)), |
|
3538 |
QBrush(edgeColor, Qt::Dense4Pattern)); |
|
3539 |
} else { |
|
3540 |
groovePainter.setBrushOrigin(0, (element == CE_ScrollBarAddPage) ? pixmapRect.height() : 1); |
|
3541 |
groovePainter.fillRect(QRect(pixmapRect.topLeft(), QSize(1, pixmapRect.height())), |
|
3542 |
QBrush(edgeColor, Qt::Dense4Pattern)); |
|
3543 |
groovePainter.fillRect(QRect(pixmapRect.topRight(), QSize(1, pixmapRect.height())), |
|
3544 |
QBrush(edgeColor, Qt::Dense4Pattern)); |
|
3545 |
} |
|
3546 |
||
3547 |
groovePainter.end(); |
|
3548 |
QPixmapCache::insert(groovePixmapName, cache); |
|
3549 |
} |
|
3550 |
painter->drawPixmap(option->rect.topLeft(), cache); |
|
3551 |
} |
|
3552 |
break; |
|
3553 |
case CE_ScrollBarSubLine: |
|
3554 |
if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
3555 |
QRect scrollBarSubLine = scrollBar->rect; |
|
3556 |
||
3557 |
bool horizontal = scrollBar->orientation == Qt::Horizontal; |
|
3558 |
bool isEnabled = scrollBar->state & State_Enabled; |
|
3559 |
bool reverse = scrollBar->direction == Qt::RightToLeft; |
|
3560 |
bool sunken = scrollBar->state & State_Sunken; |
|
3561 |
||
3562 |
// The SubLine (up/left) buttons |
|
3563 |
QRect button1; |
|
3564 |
QRect button2; |
|
3565 |
int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget); |
|
3566 |
if (horizontal) { |
|
3567 |
button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(), scrollBarExtent, scrollBarSubLine.height()); |
|
3568 |
button2.setRect(scrollBarSubLine.right() - (scrollBarExtent - 1), scrollBarSubLine.top(), scrollBarExtent, scrollBarSubLine.height()); |
|
3569 |
} else { |
|
3570 |
button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(), scrollBarSubLine.width(), scrollBarExtent); |
|
3571 |
button2.setRect(scrollBarSubLine.left(), scrollBarSubLine.bottom() - (scrollBarExtent - 1), scrollBarSubLine.width(), scrollBarExtent); |
|
3572 |
} |
|
3573 |
||
3574 |
QString subLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_subline"), option, button1.size()); |
|
3575 |
QPixmap cache; |
|
3576 |
if (!QPixmapCache::find(subLinePixmapName, cache)) { |
|
3577 |
cache = QPixmap(button1.size()); |
|
3578 |
cache.fill(Qt::white); |
|
3579 |
QRect pixmapRect(0, 0, cache.width(), cache.height()); |
|
3580 |
QPainter subLinePainter(&cache); |
|
3581 |
subLinePainter.fillRect(pixmapRect, option->palette.background()); |
|
3582 |
||
3583 |
if (isEnabled) { |
|
3584 |
// Gradients |
|
3585 |
if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) { |
|
3586 |
qt_plastique_draw_gradient(&subLinePainter, |
|
3587 |
QRect(pixmapRect.left() + 2, pixmapRect.top() + 2, |
|
3588 |
pixmapRect.right() - 3, pixmapRect.bottom() - 3), |
|
3589 |
gradientStopColor, |
|
3590 |
gradientStopColor); |
|
3591 |
} else { |
|
3592 |
qt_plastique_draw_gradient(&subLinePainter, |
|
3593 |
QRect(pixmapRect.left() + 2, pixmapRect.top() + 2, |
|
3594 |
pixmapRect.right() - 3, pixmapRect.bottom() - 3), |
|
3595 |
gradientStartColor.lighter(105), |
|
3596 |
gradientStopColor); |
|
3597 |
} |
|
3598 |
} |
|
3599 |
||
3600 |
// Details |
|
3601 |
QImage subButton; |
|
3602 |
if (horizontal) { |
|
3603 |
subButton = QImage(reverse ? qt_scrollbar_button_right : qt_scrollbar_button_left); |
|
3604 |
} else { |
|
3605 |
subButton = QImage(qt_scrollbar_button_up); |
|
3606 |
} |
|
3607 |
subButton.setColor(1, alphaCornerColor.rgba()); |
|
3608 |
subButton.setColor(2, borderColor.rgba()); |
|
3609 |
if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) { |
|
3610 |
subButton.setColor(3, gradientStopColor.rgba()); |
|
3611 |
subButton.setColor(4, gradientStopColor.rgba()); |
|
3612 |
} else { |
|
3613 |
subButton.setColor(3, gradientStartColor.lighter(105).rgba()); |
|
3614 |
subButton.setColor(4, gradientStopColor.rgba()); |
|
3615 |
} |
|
3616 |
subButton.setColor(5, scrollBar->palette.text().color().rgba()); |
|
3617 |
subLinePainter.drawImage(pixmapRect, subButton); |
|
3618 |
||
3619 |
// Arrows |
|
3620 |
if (horizontal) { |
|
3621 |
QImage arrow(reverse ? qt_scrollbar_button_arrow_right : qt_scrollbar_button_arrow_left); |
|
3622 |
arrow.setColor(1, scrollBar->palette.foreground().color().rgba()); |
|
3623 |
||
3624 |
if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) |
|
3625 |
subLinePainter.translate(1, 1); |
|
3626 |
subLinePainter.drawImage(QPoint(pixmapRect.center().x() - 2, pixmapRect.center().y() - 3), arrow); |
|
3627 |
} else { |
|
3628 |
QImage arrow(qt_scrollbar_button_arrow_up); |
|
3629 |
arrow.setColor(1, scrollBar->palette.foreground().color().rgba()); |
|
3630 |
||
3631 |
if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) |
|
3632 |
subLinePainter.translate(1, 1); |
|
3633 |
subLinePainter.drawImage(QPoint(pixmapRect.center().x() - 3, pixmapRect.center().y() - 2), arrow); |
|
3634 |
} |
|
3635 |
subLinePainter.end(); |
|
3636 |
QPixmapCache::insert(subLinePixmapName, cache); |
|
3637 |
} |
|
3638 |
painter->drawPixmap(button1.topLeft(), cache); |
|
3639 |
painter->drawPixmap(button2.topLeft(), cache); |
|
3640 |
} |
|
3641 |
break; |
|
3642 |
case CE_ScrollBarSlider: |
|
3643 |
if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
3644 |
bool horizontal = scrollBar->orientation == Qt::Horizontal; |
|
3645 |
bool isEnabled = scrollBar->state & State_Enabled; |
|
3646 |
||
3647 |
// The slider |
|
3648 |
if (option->rect.isValid()) { |
|
3649 |
QString sliderPixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_slider"), option, option->rect.size()); |
|
3650 |
if (horizontal) |
|
3651 |
sliderPixmapName += QLatin1String("-horizontal"); |
|
3652 |
||
3653 |
QPixmap cache; |
|
3654 |
if (!QPixmapCache::find(sliderPixmapName, cache)) { |
|
3655 |
cache = QPixmap(option->rect.size()); |
|
3656 |
cache.fill(Qt::white); |
|
3657 |
QRect pixmapRect(0, 0, cache.width(), cache.height()); |
|
3658 |
QPainter sliderPainter(&cache); |
|
3659 |
bool sunken = (scrollBar->state & State_Sunken); |
|
3660 |
||
3661 |
if (isEnabled) { |
|
3662 |
QLinearGradient gradient(pixmapRect.left(), pixmapRect.center().y(), |
|
3663 |
pixmapRect.right(), pixmapRect.center().y()); |
|
3664 |
if (horizontal) |
|
3665 |
gradient = QLinearGradient(pixmapRect.center().x(), pixmapRect.top(), |
|
3666 |
pixmapRect.center().x(), pixmapRect.bottom()); |
|
3667 |
||
3668 |
if (sunken) { |
|
3669 |
gradient.setColorAt(0, gradientStartColor.lighter(110)); |
|
3670 |
gradient.setColorAt(1, gradientStopColor.lighter(105)); |
|
3671 |
} else { |
|
3672 |
gradient.setColorAt(0, gradientStartColor.lighter(105)); |
|
3673 |
gradient.setColorAt(1, gradientStopColor); |
|
3674 |
} |
|
3675 |
sliderPainter.fillRect(pixmapRect.adjusted(2, 2, -2, -2), gradient); |
|
3676 |
} else { |
|
3677 |
sliderPainter.fillRect(pixmapRect.adjusted(2, 2, -2, -2), option->palette.background()); |
|
3678 |
} |
|
3679 |
||
3680 |
sliderPainter.setPen(borderColor); |
|
3681 |
sliderPainter.drawRect(pixmapRect.adjusted(0, 0, -1, -1)); |
|
3682 |
sliderPainter.setPen(alphaCornerColor); |
|
3683 |
QPoint points[4] = { |
|
3684 |
QPoint(pixmapRect.left(), pixmapRect.top()), |
|
3685 |
QPoint(pixmapRect.left(), pixmapRect.bottom()), |
|
3686 |
QPoint(pixmapRect.right(), pixmapRect.top()), |
|
3687 |
QPoint(pixmapRect.right(), pixmapRect.bottom()) }; |
|
3688 |
sliderPainter.drawPoints(points, 4); |
|
3689 |
||
3690 |
QLine lines[2]; |
|
3691 |
sliderPainter.setPen(sunken ? gradientStartColor.lighter(110) : gradientStartColor.lighter(105)); |
|
3692 |
lines[0] = QLine(pixmapRect.left() + 1, pixmapRect.top() + 1, |
|
3693 |
pixmapRect.right() - 1, pixmapRect.top() + 1); |
|
3694 |
lines[1] = QLine(pixmapRect.left() + 1, pixmapRect.top() + 2, |
|
3695 |
pixmapRect.left() + 1, pixmapRect.bottom() - 2); |
|
3696 |
sliderPainter.drawLines(lines, 2); |
|
3697 |
||
3698 |
sliderPainter.setPen(sunken ? gradientStopColor.lighter(105) : gradientStopColor); |
|
3699 |
lines[0] = QLine(pixmapRect.left() + 1, pixmapRect.bottom() - 1, |
|
3700 |
pixmapRect.right() - 1, pixmapRect.bottom() - 1); |
|
3701 |
lines[1] = QLine(pixmapRect.right() - 1, pixmapRect.top() + 2, |
|
3702 |
pixmapRect.right() - 1, pixmapRect.bottom() - 1); |
|
3703 |
sliderPainter.drawLines(lines, 2); |
|
3704 |
||
3705 |
int sliderMinLength = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget); |
|
3706 |
if ((horizontal && scrollBar->rect.width() > sliderMinLength) |
|
3707 |
|| (!horizontal && scrollBar->rect.height() > sliderMinLength)) { |
|
3708 |
QImage pattern(horizontal ? qt_scrollbar_slider_pattern_horizontal |
|
3709 |
: qt_scrollbar_slider_pattern_vertical); |
|
3710 |
pattern.setColor(1, alphaCornerColor.rgba()); |
|
3711 |
pattern.setColor(2, (sunken ? gradientStartColor.lighter(110) : gradientStartColor.lighter(105)).rgba()); |
|
3712 |
||
3713 |
if (horizontal) { |
|
3714 |
sliderPainter.drawImage(pixmapRect.center().x() - pattern.width() / 2 + 1, |
|
3715 |
pixmapRect.center().y() - 4, |
|
3716 |
pattern); |
|
3717 |
} else { |
|
3718 |
sliderPainter.drawImage(pixmapRect.center().x() - 4, |
|
3719 |
pixmapRect.center().y() - pattern.height() / 2 + 1, |
|
3720 |
pattern); |
|
3721 |
} |
|
3722 |
} |
|
3723 |
sliderPainter.end(); |
|
3724 |
// insert the slider into the cache |
|
3725 |
QPixmapCache::insert(sliderPixmapName, cache); |
|
3726 |
} |
|
3727 |
painter->drawPixmap(option->rect.topLeft(), cache); |
|
3728 |
} |
|
3729 |
} |
|
3730 |
break; |
|
3731 |
#endif |
|
3732 |
#ifndef QT_NO_COMBOBOX |
|
3733 |
case CE_ComboBoxLabel: |
|
3734 |
if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
3735 |
painter->save(); |
|
3736 |
if (!comboBox->editable) { |
|
3737 |
// Plastique's non-editable combo box is drawn as a button, so |
|
3738 |
// we need the label to be drawn using ButtonText where it |
|
3739 |
// would usually use Text. |
|
3740 |
painter->setPen(QPen(comboBox->palette.buttonText(), 0)); |
|
3741 |
QWindowsStyle::drawControl(element, option, painter, widget); |
|
3742 |
} else if (!comboBox->currentIcon.isNull()) { |
|
3743 |
{ |
|
3744 |
QRect editRect = proxy()->subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget); |
|
3745 |
if (comboBox->direction == Qt::RightToLeft) |
|
3746 |
editRect.adjust(0, 2, -2, -2); |
|
3747 |
else |
|
3748 |
editRect.adjust(2, 2, 0, -2); |
|
3749 |
painter->save(); |
|
3750 |
painter->setClipRect(editRect); |
|
3751 |
if (!comboBox->currentIcon.isNull()) { |
|
3752 |
QIcon::Mode mode = comboBox->state & State_Enabled ? QIcon::Normal |
|
3753 |
: QIcon::Disabled; |
|
3754 |
QPixmap pixmap = comboBox->currentIcon.pixmap(comboBox->iconSize, mode); |
|
3755 |
QRect iconRect(editRect); |
|
3756 |
iconRect.setWidth(comboBox->iconSize.width() + 5); |
|
3757 |
iconRect = alignedRect(comboBox->direction, |
|
3758 |
Qt::AlignLeft | Qt::AlignVCenter, |
|
3759 |
iconRect.size(), editRect); |
|
3760 |
painter->fillRect(iconRect, option->palette.brush(QPalette::Base)); |
|
3761 |
proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); |
|
3762 |
} |
|
3763 |
painter->restore(); |
|
3764 |
} |
|
3765 |
} else { |
|
3766 |
QWindowsStyle::drawControl(element, option, painter, widget); |
|
3767 |
} |
|
3768 |
||
3769 |
painter->restore(); |
|
3770 |
} |
|
3771 |
break; |
|
3772 |
#endif |
|
3773 |
default: |
|
3774 |
QWindowsStyle::drawControl(element, option, painter, widget); |
|
3775 |
break; |
|
3776 |
} |
|
3777 |
} |
|
3778 |
||
3779 |
/*! |
|
3780 |
\reimp |
|
3781 |
*/ |
|
3782 |
void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, |
|
3783 |
QPainter *painter, const QWidget *widget) const |
|
3784 |
{ |
|
3785 |
QColor borderColor = option->palette.background().color().darker(178); |
|
3786 |
QColor alphaCornerColor; |
|
3787 |
if (widget) { |
|
3788 |
// ### backgroundrole/foregroundrole should be part of the style option |
|
3789 |
alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor); |
|
3790 |
} else { |
|
3791 |
alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); |
|
3792 |
} |
|
3793 |
QColor gradientStartColor = option->palette.button().color().lighter(104); |
|
3794 |
QColor gradientStopColor = option->palette.button().color().darker(105); |
|
3795 |
QColor highlightedGradientStartColor = option->palette.button().color().lighter(101); |
|
3796 |
QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85); |
|
3797 |
QColor highlightedDarkInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 35); |
|
3798 |
QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58); |
|
3799 |
||
3800 |
switch (control) { |
|
3801 |
#ifndef QT_NO_SLIDER |
|
3802 |
case CC_Slider: |
|
3803 |
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
3804 |
QRect grooveRegion = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); |
|
3805 |
QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); |
|
3806 |
QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); |
|
3807 |
bool horizontal = slider->orientation == Qt::Horizontal; |
|
3808 |
bool ticksAbove = slider->tickPosition & QSlider::TicksAbove; |
|
3809 |
bool ticksBelow = slider->tickPosition & QSlider::TicksBelow; |
|
3810 |
||
3811 |
QRect groove; |
|
3812 |
//The clickable region is 5 px wider than the visible groove for improved usability |
|
3813 |
if (grooveRegion.isValid()) |
|
3814 |
groove = horizontal ? grooveRegion.adjusted(0, 5, 0, -5) : grooveRegion.adjusted(5, 0, -5, 0); |
|
3815 |
||
3816 |
||
3817 |
QPixmap cache; |
|
3818 |
||
3819 |
if ((option->subControls & SC_SliderGroove) && groove.isValid()) { |
|
3820 |
BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("slider_groove-%0-%1").arg(ticksAbove).arg(ticksBelow)) |
|
3821 |
p->fillRect(groove, option->palette.background()); |
|
3822 |
||
3823 |
// draw groove |
|
3824 |
if (horizontal) { |
|
3825 |
p->setPen(borderColor); |
|
3826 |
const QLine lines[4] = { |
|
3827 |
QLine(groove.left() + 1, groove.top(), |
|
3828 |
groove.right() - 1, groove.top()), |
|
3829 |
QLine(groove.left() + 1, groove.bottom(), |
|
3830 |
groove.right() - 1, groove.bottom()), |
|
3831 |
QLine(groove.left(), groove.top() + 1, |
|
3832 |
groove.left(), groove.bottom() - 1), |
|
3833 |
QLine(groove.right(), groove.top() + 1, |
|
3834 |
groove.right(), groove.bottom() - 1) }; |
|
3835 |
p->drawLines(lines, 4); |
|
3836 |
||
3837 |
p->setPen(alphaCornerColor); |
|
3838 |
const QPoint points[4] = { |
|
3839 |
QPoint(groove.left(), groove.top()), |
|
3840 |
QPoint(groove.left(), groove.bottom()), |
|
3841 |
QPoint(groove.right(), groove.top()), |
|
3842 |
QPoint(groove.right(), groove.bottom()) }; |
|
3843 |
p->drawPoints(points, 4); |
|
3844 |
} else { |
|
3845 |
p->setPen(borderColor); |
|
3846 |
const QLine lines[4] = { |
|
3847 |
QLine(groove.left() + 1, groove.top(), |
|
3848 |
groove.right() - 1, groove.top()), |
|
3849 |
QLine(groove.left() + 1, groove.bottom(), |
|
3850 |
groove.right() - 1, groove.bottom()), |
|
3851 |
QLine(groove.left(), groove.top() + 1, |
|
3852 |
groove.left(), groove.bottom() - 1), |
|
3853 |
QLine(groove.right(), groove.top() + 1, |
|
3854 |
groove.right(), groove.bottom() - 1) }; |
|
3855 |
p->drawLines(lines, 4); |
|
3856 |
||
3857 |
p->setPen(alphaCornerColor); |
|
3858 |
const QPoint points[4] = { |
|
3859 |
QPoint(groove.left(), groove.top()), |
|
3860 |
QPoint(groove.right(), groove.top()), |
|
3861 |
QPoint(groove.left(), groove.bottom()), |
|
3862 |
QPoint(groove.right(), groove.bottom()) }; |
|
3863 |
p->drawPoints(points, 4); |
|
3864 |
} |
|
3865 |
END_STYLE_PIXMAPCACHE |
|
3866 |
} |
|
3867 |
||
3868 |
if ((option->subControls & SC_SliderHandle) && handle.isValid()) { |
|
3869 |
QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size()); |
|
3870 |
if (ticksAbove && !ticksBelow) |
|
3871 |
handlePixmapName += QLatin1String("-flipped"); |
|
3872 |
if ((option->activeSubControls & SC_SliderHandle) && (option->state & State_Sunken)) |
|
3873 |
handlePixmapName += QLatin1String("-sunken"); |
|
3874 |
||
3875 |
if (!QPixmapCache::find(handlePixmapName, cache)) { |
|
3876 |
cache = QPixmap(handle.size()); |
|
3877 |
cache.fill(Qt::white); |
|
3878 |
QRect pixmapRect(0, 0, handle.width(), handle.height()); |
|
3879 |
QPainter handlePainter(&cache); |
|
3880 |
handlePainter.fillRect(pixmapRect, option->palette.background()); |
|
3881 |
||
3882 |
// draw handle |
|
3883 |
if (horizontal) { |
|
3884 |
QPainterPath path; |
|
3885 |
if (ticksAbove && !ticksBelow) { |
|
3886 |
path.moveTo(QPoint(pixmapRect.right(), pixmapRect.bottom())); |
|
3887 |
path.lineTo(QPoint(pixmapRect.right(), pixmapRect.bottom() - 10)); |
|
3888 |
path.lineTo(QPoint(pixmapRect.right() - 5, pixmapRect.bottom() - 14)); |
|
3889 |
path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.bottom() - 10)); |
|
3890 |
path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.bottom())); |
|
3891 |
path.lineTo(QPoint(pixmapRect.right(), pixmapRect.bottom())); |
|
3892 |
} else { |
|
3893 |
path.moveTo(QPoint(pixmapRect.right(), pixmapRect.top() + 1)); |
|
3894 |
path.lineTo(QPoint(pixmapRect.right(), pixmapRect.top() + 10)); |
|
3895 |
path.lineTo(QPoint(pixmapRect.right() - 5, pixmapRect.top() + 14)); |
|
3896 |
path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.top() + 10)); |
|
3897 |
path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.top() + 1)); |
|
3898 |
path.lineTo(QPoint(pixmapRect.right(), pixmapRect.top() + 1)); |
|
3899 |
} |
|
3900 |
if (slider->state & State_Enabled) { |
|
3901 |
QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(), |
|
3902 |
pixmapRect.center().x(), pixmapRect.bottom()); |
|
3903 |
if ((option->activeSubControls & SC_SliderHandle) && (option->state & State_Sunken)) { |
|
3904 |
gradient.setColorAt(0, gradientStartColor.lighter(110)); |
|
3905 |
gradient.setColorAt(1, gradientStopColor.lighter(110)); |
|
3906 |
} else { |
|
3907 |
gradient.setColorAt(0, gradientStartColor); |
|
3908 |
gradient.setColorAt(1, gradientStopColor); |
|
3909 |
} |
|
3910 |
handlePainter.fillPath(path, gradient); |
|
3911 |
} else { |
|
3912 |
handlePainter.fillPath(path, slider->palette.background()); |
|
3913 |
} |
|
3914 |
} else { |
|
3915 |
QPainterPath path; |
|
3916 |
if (ticksAbove && !ticksBelow) { |
|
3917 |
path.moveTo(QPoint(pixmapRect.right(), pixmapRect.top() + 1)); |
|
3918 |
path.lineTo(QPoint(pixmapRect.right() - 10, pixmapRect.top() + 1)); |
|
3919 |
path.lineTo(QPoint(pixmapRect.right() - 14, pixmapRect.top() + 5)); |
|
3920 |
path.lineTo(QPoint(pixmapRect.right() - 10, pixmapRect.bottom())); |
|
3921 |
path.lineTo(QPoint(pixmapRect.right(), pixmapRect.bottom())); |
|
3922 |
path.lineTo(QPoint(pixmapRect.right(), pixmapRect.top() + 1)); |
|
3923 |
} else { |
|
3924 |
path.moveTo(QPoint(pixmapRect.left() + 1, pixmapRect.top() + 1)); |
|
3925 |
path.lineTo(QPoint(pixmapRect.left() + 10, pixmapRect.top() + 1)); |
|
3926 |
path.lineTo(QPoint(pixmapRect.left() + 14, pixmapRect.top() + 5)); |
|
3927 |
path.lineTo(QPoint(pixmapRect.left() + 10, pixmapRect.bottom())); |
|
3928 |
path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.bottom())); |
|
3929 |
path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.top() + 1)); |
|
3930 |
} |
|
3931 |
if (slider->state & State_Enabled) { |
|
3932 |
QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(), |
|
3933 |
pixmapRect.center().x(), pixmapRect.bottom()); |
|
3934 |
gradient.setColorAt(0, gradientStartColor); |
|
3935 |
gradient.setColorAt(1, gradientStopColor); |
|
3936 |
handlePainter.fillPath(path, gradient); |
|
3937 |
} else { |
|
3938 |
handlePainter.fillPath(path, slider->palette.background()); |
|
3939 |
} |
|
3940 |
} |
|
3941 |
||
3942 |
QImage image; |
|
3943 |
if (horizontal) { |
|
3944 |
image = QImage((ticksAbove && !ticksBelow) ? qt_plastique_slider_horizontalhandle_up : qt_plastique_slider_horizontalhandle); |
|
3945 |
} else { |
|
3946 |
image = QImage((ticksAbove && !ticksBelow) ? qt_plastique_slider_verticalhandle_left : qt_plastique_slider_verticalhandle); |
|
3947 |
} |
|
3948 |
||
3949 |
image.setColor(1, borderColor.rgba()); |
|
3950 |
image.setColor(2, gradientStartColor.rgba()); |
|
3951 |
image.setColor(3, alphaCornerColor.rgba()); |
|
3952 |
if (option->state & State_Enabled) { |
|
3953 |
image.setColor(4, 0x80ffffff); |
|
3954 |
image.setColor(5, 0x25000000); |
|
3955 |
} |
|
3956 |
handlePainter.drawImage(pixmapRect, image); |
|
3957 |
handlePainter.end(); |
|
3958 |
QPixmapCache::insert(handlePixmapName, cache); |
|
3959 |
} |
|
3960 |
||
3961 |
painter->drawPixmap(handle.topLeft(), cache); |
|
3962 |
||
3963 |
if (slider->state & State_HasFocus) { |
|
3964 |
QStyleOptionFocusRect fropt; |
|
3965 |
fropt.QStyleOption::operator=(*slider); |
|
3966 |
fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget); |
|
3967 |
proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); |
|
3968 |
} |
|
3969 |
} |
|
3970 |
||
3971 |
if (option->subControls & SC_SliderTickmarks) { |
|
3972 |
QPen oldPen = painter->pen(); |
|
3973 |
painter->setPen(borderColor); |
|
3974 |
int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); |
|
3975 |
int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); |
|
3976 |
int interval = slider->tickInterval; |
|
3977 |
if (interval <= 0) { |
|
3978 |
interval = slider->singleStep; |
|
3979 |
if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval, |
|
3980 |
available) |
|
3981 |
- QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, |
|
3982 |
0, available) < 3) |
|
3983 |
interval = slider->pageStep; |
|
3984 |
} |
|
3985 |
if (interval <= 0) |
|
3986 |
interval = 1; |
|
3987 |
||
3988 |
int v = slider->minimum; |
|
3989 |
int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); |
|
3990 |
QVarLengthArray<QLine, 32> lines; |
|
3991 |
while (v <= slider->maximum + 1) { |
|
3992 |
if (v == slider->maximum + 1 && interval == 1) |
|
3993 |
break; |
|
3994 |
const int v_ = qMin(v, slider->maximum); |
|
3995 |
int pos = sliderPositionFromValue(slider->minimum, slider->maximum, |
|
3996 |
v_, (horizontal |
|
3997 |
? slider->rect.width() |
|
3998 |
: slider->rect.height()) - len, |
|
3999 |
slider->upsideDown) + len / 2; |
|
4000 |
||
4001 |
int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0); |
|
4002 |
||
4003 |
if (horizontal) { |
|
4004 |
if (ticksAbove) { |
|
4005 |
lines.append(QLine(pos, slider->rect.top() + extra, |
|
4006 |
pos, slider->rect.top() + tickSize)); |
|
4007 |
} |
|
4008 |
if (ticksBelow) { |
|
4009 |
lines.append(QLine(pos, slider->rect.bottom() - extra, |
|
4010 |
pos, slider->rect.bottom() - tickSize)); |
|
4011 |
} |
|
4012 |
} else { |
|
4013 |
if (ticksAbove) { |
|
4014 |
lines.append(QLine(slider->rect.left() + extra, pos, |
|
4015 |
slider->rect.left() + tickSize, pos)); |
|
4016 |
} |
|
4017 |
if (ticksBelow) { |
|
4018 |
lines.append(QLine(slider->rect.right() - extra, pos, |
|
4019 |
slider->rect.right() - tickSize, pos)); |
|
4020 |
} |
|
4021 |
} |
|
4022 |
||
4023 |
// in the case where maximum is max int |
|
4024 |
int nextInterval = v + interval; |
|
4025 |
if (nextInterval < v) |
|
4026 |
break; |
|
4027 |
v = nextInterval; |
|
4028 |
} |
|
4029 |
painter->drawLines(lines.constData(), lines.size()); |
|
4030 |
painter->setPen(oldPen); |
|
4031 |
} |
|
4032 |
} |
|
4033 |
break; |
|
4034 |
#endif // QT_NO_SLIDER |
|
4035 |
#ifndef QT_NO_SPINBOX |
|
4036 |
case CC_SpinBox: |
|
4037 |
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
4038 |
painter->save(); |
|
4039 |
bool upSunken = (spinBox->activeSubControls & SC_SpinBoxUp) && (spinBox->state & (State_Sunken | State_On)); |
|
4040 |
bool downSunken = (spinBox->activeSubControls & SC_SpinBoxDown) && (spinBox->state & (State_Sunken | State_On)); |
|
4041 |
bool reverse = (spinBox->direction == Qt::RightToLeft); |
|
4042 |
||
4043 |
// Rects |
|
4044 |
QRect upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); |
|
4045 |
QRect downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); |
|
4046 |
QRect buttonRect = upRect | downRect; |
|
4047 |
||
4048 |
// Brushes |
|
4049 |
QBrush corner = qMapBrushToRect(option->palette.shadow(), buttonRect); |
|
4050 |
qBrushSetAlphaF(&corner, qreal(0.25)); |
|
4051 |
QBrush border = qMapBrushToRect(option->palette.shadow(), buttonRect); |
|
4052 |
qBrushSetAlphaF(&border, qreal(0.4)); |
|
4053 |
||
4054 |
QVarLengthArray<QPoint, 4> points; |
|
4055 |
||
4056 |
Q_D(const QPlastiqueStyle); |
|
4057 |
if (spinBox->buttonSymbols == QAbstractSpinBox::NoButtons) { |
|
4058 |
QRect filledRect = option->rect.adjusted(1, 1, -1, -1); |
|
4059 |
QBrush baseBrush = qMapBrushToRect(option->palette.base(), filledRect); |
|
4060 |
painter->setBrushOrigin(filledRect.topLeft()); |
|
4061 |
painter->fillRect(filledRect.adjusted(1, 1, -1, -1), baseBrush); |
|
4062 |
qt_plastique_draw_frame(painter, option->rect, option, QFrame::Sunken); |
|
4063 |
} else { |
|
4064 |
d->drawPartialFrame(painter, |
|
4065 |
option, |
|
4066 |
proxy()->subControlRect(CC_SpinBox, spinBox, SC_SpinBoxEditField, widget), |
|
4067 |
widget); |
|
4068 |
} |
|
4069 |
// Paint buttons |
|
4070 |
if (spinBox->buttonSymbols == QAbstractSpinBox::NoButtons) { |
|
4071 |
painter->restore(); |
|
4072 |
break; |
|
4073 |
} |
|
4074 |
// Button outlines |
|
4075 |
painter->setPen(QPen(border, 0)); |
|
4076 |
if (!reverse) |
|
4077 |
painter->drawLine(buttonRect.topLeft() + QPoint(0, 1), buttonRect.bottomLeft() + QPoint(0, -1)); |
|
4078 |
else |
|
4079 |
painter->drawLine(buttonRect.topRight() + QPoint(0, -1), buttonRect.bottomRight() + QPoint(0, 1)); |
|
4080 |
||
4081 |
if (!reverse) { |
|
4082 |
const QLine lines[4] = { |
|
4083 |
QLine(upRect.left(), upRect.top(), upRect.right() - 2, upRect.top()), |
|
4084 |
QLine(upRect.left() + 1, upRect.bottom(), upRect.right() - 1, upRect.bottom()), |
|
4085 |
QLine(downRect.left(), downRect.bottom(), downRect.right() - 2, downRect.bottom()), |
|
4086 |
QLine(buttonRect.right(), buttonRect.top() + 2, buttonRect.right(), buttonRect.bottom() - 2) }; |
|
4087 |
painter->drawLines(lines, 4); |
|
4088 |
||
4089 |
points.append(QPoint(upRect.right() - 1, upRect.top() + 1)); |
|
4090 |
points.append(QPoint(downRect.right() - 1, downRect.bottom() - 1)); |
|
4091 |
painter->drawPoints(points.constData(), points.size()); |
|
4092 |
points.clear(); |
|
4093 |
painter->setPen(QPen(corner, 0)); |
|
4094 |
points.append(QPoint(upRect.right() - 1, upRect.top())); |
|
4095 |
points.append(QPoint(upRect.right(), upRect.top() + 1)); |
|
4096 |
points.append(QPoint(upRect.right(), downRect.bottom() - 1)); |
|
4097 |
points.append(QPoint(upRect.right() - 1, downRect.bottom())); |
|
4098 |
} else { |
|
4099 |
const QLine lines[4] = { |
|
4100 |
QLine(upRect.right(), upRect.top(), upRect.left() + 2, upRect.top()), |
|
4101 |
QLine(upRect.right() - 1, upRect.bottom(), upRect.left() + 1, upRect.bottom()), |
|
4102 |
QLine(downRect.right(), downRect.bottom(), downRect.left() + 2, downRect.bottom()), |
|
4103 |
QLine(buttonRect.left(), buttonRect.top() + 2, buttonRect.left(), buttonRect.bottom() - 2) }; |
|
4104 |
painter->drawLines(lines, 4); |
|
4105 |
||
4106 |
points.append(QPoint(upRect.left() + 1, upRect.top() + 1)); |
|
4107 |
points.append(QPoint(downRect.left() + 1, downRect.bottom() - 1)); |
|
4108 |
painter->drawPoints(points.constData(), points.size()); |
|
4109 |
points.clear(); |
|
4110 |
painter->setPen(QPen(corner, 0)); |
|
4111 |
points.append(QPoint(upRect.left() + 1, upRect.top())); |
|
4112 |
points.append(QPoint(upRect.left(), upRect.top() + 1)); |
|
4113 |
points.append(QPoint(upRect.left(), downRect.bottom() - 1)); |
|
4114 |
points.append(QPoint(upRect.left() + 1, downRect.bottom())); |
|
4115 |
} |
|
4116 |
painter->drawPoints(points.constData(), points.size()); |
|
4117 |
points.clear(); |
|
4118 |
||
4119 |
// Button colors |
|
4120 |
QBrush buttonGradientBrush; |
|
4121 |
QBrush leftLineGradientBrush; |
|
4122 |
QBrush rightLineGradientBrush; |
|
4123 |
QBrush sunkenButtonGradientBrush; |
|
4124 |
QBrush sunkenLeftLineGradientBrush; |
|
4125 |
QBrush sunkenRightLineGradientBrush; |
|
4126 |
QBrush buttonBrush = qMapBrushToRect(option->palette.button(), buttonRect); |
|
4127 |
if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) { |
|
4128 |
buttonGradientBrush = buttonBrush; |
|
4129 |
sunkenButtonGradientBrush = qBrushDark(buttonBrush, 108); |
|
4130 |
leftLineGradientBrush = qBrushLight(buttonBrush, 105); |
|
4131 |
rightLineGradientBrush = qBrushDark(buttonBrush, 105); |
|
4132 |
sunkenLeftLineGradientBrush = qBrushDark(buttonBrush, 110); |
|
4133 |
sunkenRightLineGradientBrush = qBrushDark(buttonBrush, 106); |
|
4134 |
} else { |
|
4135 |
// Generate gradients |
|
4136 |
QLinearGradient buttonGradient(buttonRect.topLeft(), buttonRect.bottomLeft()); |
|
4137 |
buttonGradient.setColorAt(0.0, buttonBrush.color().lighter(104)); |
|
4138 |
buttonGradient.setColorAt(1.0, buttonBrush.color().darker(110)); |
|
4139 |
buttonGradientBrush = QBrush(buttonGradient); |
|
4140 |
||
4141 |
QLinearGradient buttonGradient2(buttonRect.topLeft(), buttonRect.bottomLeft()); |
|
4142 |
buttonGradient2.setColorAt(0.0, buttonBrush.color().darker(113)); |
|
4143 |
buttonGradient2.setColorAt(1.0, buttonBrush.color().darker(103)); |
|
4144 |
sunkenButtonGradientBrush = QBrush(buttonGradient2); |
|
4145 |
||
4146 |
QLinearGradient buttonGradient3(buttonRect.topLeft(), buttonRect.bottomLeft()); |
|
4147 |
buttonGradient3.setColorAt(0.0, buttonBrush.color().lighter(105)); |
|
4148 |
buttonGradient3.setColorAt(1.0, buttonBrush.color()); |
|
4149 |
leftLineGradientBrush = QBrush(buttonGradient3); |
|
4150 |
||
4151 |
QLinearGradient buttonGradient4(buttonRect.topLeft(), buttonRect.bottomLeft()); |
|
4152 |
buttonGradient4.setColorAt(0.0, buttonBrush.color()); |
|
4153 |
buttonGradient4.setColorAt(1.0, buttonBrush.color().darker(110)); |
|
4154 |
rightLineGradientBrush = QBrush(buttonGradient4); |
|
4155 |
||
4156 |
QLinearGradient buttonGradient5(buttonRect.topLeft(), buttonRect.bottomLeft()); |
|
4157 |
buttonGradient5.setColorAt(0.0, buttonBrush.color().darker(113)); |
|
4158 |
buttonGradient5.setColorAt(1.0, buttonBrush.color().darker(107)); |
|
4159 |
sunkenLeftLineGradientBrush = QBrush(buttonGradient5); |
|
4160 |
||
4161 |
QLinearGradient buttonGradient6(buttonRect.topLeft(), buttonRect.bottomLeft()); |
|
4162 |
buttonGradient6.setColorAt(0.0, buttonBrush.color().darker(108)); |
|
4163 |
buttonGradient6.setColorAt(1.0, buttonBrush.color().darker(103)); |
|
4164 |
sunkenRightLineGradientBrush = QBrush(buttonGradient6); |
|
4165 |
} |
|
4166 |
||
4167 |
// Main fill |
|
4168 |
painter->fillRect(upRect.adjusted(2, 2, -2, -2), |
|
4169 |
qMapBrushToRect(upSunken ? sunkenButtonGradientBrush |
|
4170 |
: buttonGradientBrush, upRect)); |
|
4171 |
painter->fillRect(downRect.adjusted(2, 2, -2, -2), |
|
4172 |
qMapBrushToRect(downSunken ? sunkenButtonGradientBrush |
|
4173 |
: buttonGradientBrush, downRect)); |
|
4174 |
||
4175 |
// Top line |
|
4176 |
painter->setPen(QPen(qBrushLight(qMapBrushToRect(upSunken ? sunkenButtonGradientBrush |
|
4177 |
: buttonGradientBrush, upRect), 105), 0)); |
|
4178 |
if (!reverse) { |
|
4179 |
painter->drawLine(upRect.left() + 1, upRect.top() + 1, |
|
4180 |
upRect.right() - 2, upRect.top() + 1); |
|
4181 |
} else { |
|
4182 |
painter->drawLine(upRect.right() - 1, upRect.top() + 1, |
|
4183 |
upRect.left() + 2, upRect.top() + 1); |
|
4184 |
} |
|
4185 |
painter->setPen(QPen(qBrushLight(qMapBrushToRect(downSunken ? sunkenButtonGradientBrush |
|
4186 |
: buttonGradientBrush, downRect), 105), 0)); |
|
4187 |
if (!reverse) { |
|
4188 |
painter->drawLine(downRect.left() + 1, downRect.top() + 1, |
|
4189 |
downRect.right() - 1, downRect.top() + 1); |
|
4190 |
} else { |
|
4191 |
painter->drawLine(downRect.right() - 1, downRect.top() + 1, |
|
4192 |
downRect.left() + 1, downRect.top() + 1); |
|
4193 |
} |
|
4194 |
||
4195 |
// Left line |
|
4196 |
painter->setPen(QPen(qMapBrushToRect(upSunken ? sunkenLeftLineGradientBrush |
|
4197 |
: leftLineGradientBrush, upRect), 1)); |
|
4198 |
if (!reverse) { |
|
4199 |
painter->drawLine(upRect.left() + 1, upRect.top() + 2, |
|
4200 |
upRect.left() + 1, upRect.bottom() - 1); |
|
4201 |
} else { |
|
4202 |
painter->drawLine(upRect.left() + 1, upRect.top() + 2, |
|
4203 |
upRect.left() + 1, upRect.bottom() - 1); |
|
4204 |
} |
|
4205 |
painter->setPen(QPen(qMapBrushToRect(downSunken ? sunkenLeftLineGradientBrush |
|
4206 |
: leftLineGradientBrush, downRect), 1)); |
|
4207 |
if (!reverse) { |
|
4208 |
painter->drawLine(downRect.left() + 1, downRect.top() + 2, |
|
4209 |
downRect.left() + 1, downRect.bottom() - 1); |
|
4210 |
} else { |
|
4211 |
painter->drawLine(downRect.left() + 1, downRect.top() + 1, |
|
4212 |
downRect.left() + 1, downRect.bottom() - 2); |
|
4213 |
} |
|
4214 |
||
4215 |
// Bottom line |
|
4216 |
painter->setPen(QPen(qBrushDark(qMapBrushToRect(upSunken ? sunkenButtonGradientBrush |
|
4217 |
: buttonGradientBrush, upRect), 105), 0)); |
|
4218 |
if (!reverse) { |
|
4219 |
painter->drawLine(upRect.left() + 2, upRect.bottom() - 1, |
|
4220 |
upRect.right() - 1, upRect.bottom() - 1); |
|
4221 |
} else { |
|
4222 |
painter->drawLine(upRect.right() - 2, upRect.bottom() - 1, |
|
4223 |
upRect.left() + 1, upRect.bottom() - 1); |
|
4224 |
} |
|
4225 |
painter->setPen(QPen(qBrushDark(qMapBrushToRect(downSunken ? sunkenButtonGradientBrush |
|
4226 |
: buttonGradientBrush, downRect), 105), 0)); |
|
4227 |
if (!reverse) { |
|
4228 |
painter->drawLine(downRect.left() + 2, downRect.bottom() - 1, |
|
4229 |
downRect.right() - 2, downRect.bottom() - 1); |
|
4230 |
} else { |
|
4231 |
painter->drawLine(downRect.right() - 2, downRect.bottom() - 1, |
|
4232 |
downRect.left() + 2, downRect.bottom() - 1); |
|
4233 |
} |
|
4234 |
||
4235 |
// Right line |
|
4236 |
painter->setPen(QPen(qMapBrushToRect(upSunken ? sunkenRightLineGradientBrush |
|
4237 |
: rightLineGradientBrush, upRect), 1)); |
|
4238 |
if (!reverse) { |
|
4239 |
painter->drawLine(upRect.right() - 1, upRect.top() + 2, |
|
4240 |
upRect.right() - 1, upRect.bottom() - 1); |
|
4241 |
} else { |
|
4242 |
painter->drawLine(upRect.right() - 1, upRect.top() + 2, |
|
4243 |
upRect.right() - 1, upRect.bottom() - 1); |
|
4244 |
} |
|
4245 |
painter->setPen(QPen(qMapBrushToRect(downSunken ? sunkenRightLineGradientBrush |
|
4246 |
: rightLineGradientBrush, downRect), 1)); |
|
4247 |
if (!reverse) { |
|
4248 |
painter->drawLine(downRect.right() - 1, downRect.top() + 1, |
|
4249 |
downRect.right() - 1, downRect.bottom() - 2); |
|
4250 |
} else { |
|
4251 |
painter->drawLine(downRect.right() - 1, downRect.top() + 2, |
|
4252 |
downRect.right() - 1, downRect.bottom() - 1); |
|
4253 |
} |
|
4254 |
||
4255 |
QBrush indicatorBrush = qMapBrushToRect(option->palette.buttonText(), buttonRect); |
|
4256 |
painter->setPen(QPen(indicatorBrush, 0)); |
|
4257 |
if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) { |
|
4258 |
QPoint center; |
|
4259 |
if (spinBox->subControls & SC_SpinBoxUp) { |
|
4260 |
// ....... |
|
4261 |
// ...X... |
|
4262 |
// ...X... |
|
4263 |
// .XXXXX. |
|
4264 |
// ...X... |
|
4265 |
// ...X... |
|
4266 |
// ....... |
|
4267 |
center = upRect.center(); |
|
4268 |
if (upSunken) { |
|
4269 |
++center.rx(); |
|
4270 |
++center.ry(); |
|
4271 |
} |
|
4272 |
painter->drawLine(center.x(), center.y() - 2, center.x(), center.y() + 2); |
|
4273 |
painter->drawLine(center.x() - 2, center.y(), center.x() + 2, center.y()); |
|
4274 |
} |
|
4275 |
if (spinBox->subControls & SC_SpinBoxDown) { |
|
4276 |
// ....... |
|
4277 |
// ....... |
|
4278 |
// ....... |
|
4279 |
// .XXXXX. |
|
4280 |
// ....... |
|
4281 |
// ....... |
|
4282 |
// ....... |
|
4283 |
center = downRect.center(); |
|
4284 |
if (downSunken) { |
|
4285 |
++center.rx(); |
|
4286 |
++center.ry(); |
|
4287 |
} |
|
4288 |
painter->drawLine(center.x() - 2, center.y(), center.x() + 2, center.y()); |
|
4289 |
} |
|
4290 |
} else { |
|
4291 |
int offset; |
|
4292 |
int centerX; |
|
4293 |
if (spinBox->subControls & SC_SpinBoxUp) { |
|
4294 |
// ........... |
|
4295 |
// .....X..... |
|
4296 |
// ....XXX.... |
|
4297 |
// ...XXXXX... |
|
4298 |
// ..XXXXXXX.. |
|
4299 |
// ........... |
|
4300 |
offset = upSunken ? 1 : 0; |
|
4301 |
QRect upArrowRect(upRect.center().x() - 3 + offset, upRect.center().y() - 2 + offset, 7, 4); |
|
4302 |
centerX = upArrowRect.center().x(); |
|
4303 |
painter->drawPoint(centerX, upArrowRect.top()); |
|
4304 |
const QLine lines[3] = { |
|
4305 |
QLine(centerX - 1, upArrowRect.top() + 1, centerX + 1, upArrowRect.top() + 1), |
|
4306 |
QLine(centerX - 2, upArrowRect.top() + 2, centerX + 2, upArrowRect.top() + 2), |
|
4307 |
QLine(centerX - 3, upArrowRect.top() + 3, centerX + 3, upArrowRect.top() + 3) }; |
|
4308 |
painter->drawLines(lines, 3); |
|
4309 |
} |
|
4310 |
if (spinBox->subControls & SC_SpinBoxDown) { |
|
4311 |
// ........... |
|
4312 |
// ..XXXXXXX.. |
|
4313 |
// ...XXXXX... |
|
4314 |
// ....XXX.... |
|
4315 |
// .....X..... |
|
4316 |
// ........... |
|
4317 |
offset = downSunken ? 1 : 0; |
|
4318 |
QRect downArrowRect(downRect.center().x() - 3 + offset, downRect.center().y() - 2 + offset + 1, 7, 4); |
|
4319 |
centerX = downArrowRect.center().x(); |
|
4320 |
const QLine lines[3] = { |
|
4321 |
QLine(centerX - 3, downArrowRect.top(), centerX + 3, downArrowRect.top()), |
|
4322 |
QLine(centerX - 2, downArrowRect.top() + 1, centerX + 2, downArrowRect.top() + 1), |
|
4323 |
QLine(centerX - 1, downArrowRect.top() + 2, centerX + 1, downArrowRect.top() + 2) }; |
|
4324 |
painter->drawLines(lines, 3); |
|
4325 |
painter->drawPoint(centerX, downArrowRect.top() + 3); |
|
4326 |
} |
|
4327 |
} |
|
4328 |
painter->restore(); |
|
4329 |
} |
|
4330 |
break; |
|
4331 |
#endif // QT_NO_SPINBOX |
|
4332 |
#ifndef QT_NO_COMBOBOX |
|
4333 |
case CC_ComboBox: |
|
4334 |
if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
4335 |
bool sunken = comboBox->state & State_On; // play dead if combobox has no items |
|
4336 |
bool reverse = comboBox->direction == Qt::RightToLeft; |
|
4337 |
int menuButtonWidth = 16; |
|
4338 |
int xoffset = sunken ? (reverse ? -1 : 1) : 0; |
|
4339 |
int yoffset = sunken ? 1 : 0; |
|
4340 |
QRect rect = comboBox->rect; |
|
4341 |
QPen oldPen = painter->pen(); |
|
4342 |
||
4343 |
// Fill |
|
4344 |
if (comboBox->editable) { |
|
4345 |
// Button colors |
|
4346 |
QBrush alphaCornerBrush = qBrushDark(option->palette.button(), 165); |
|
4347 |
qBrushSetAlphaF(&alphaCornerBrush, 0.5); |
|
4348 |
QBrush buttonGradientBrush; |
|
4349 |
QBrush leftLineGradientBrush; |
|
4350 |
QBrush rightLineGradientBrush; |
|
4351 |
QBrush sunkenButtonGradientBrush; |
|
4352 |
QBrush sunkenLeftLineGradientBrush; |
|
4353 |
QBrush sunkenRightLineGradientBrush; |
|
4354 |
QBrush button = option->palette.button(); |
|
4355 |
if (button.gradient() || !button.texture().isNull()) { |
|
4356 |
buttonGradientBrush = button; |
|
4357 |
sunkenButtonGradientBrush = qBrushDark(button, 108); |
|
4358 |
leftLineGradientBrush = qBrushLight(button, 105); |
|
4359 |
rightLineGradientBrush = qBrushDark(button, 105); |
|
4360 |
sunkenLeftLineGradientBrush = qBrushDark(button, 110); |
|
4361 |
sunkenRightLineGradientBrush = qBrushDark(button, 106); |
|
4362 |
} else { |
|
4363 |
// Generate gradients |
|
4364 |
QLinearGradient buttonGradient(option->rect.topLeft(), option->rect.bottomLeft()); |
|
4365 |
buttonGradient.setColorAt(0.0, button.color().lighter(104)); |
|
4366 |
buttonGradient.setColorAt(1.0, button.color().darker(110)); |
|
4367 |
buttonGradientBrush = QBrush(buttonGradient); |
|
4368 |
||
4369 |
QLinearGradient buttonGradient2(option->rect.topLeft(), option->rect.bottomLeft()); |
|
4370 |
buttonGradient2.setColorAt(0.0, button.color().darker(113)); |
|
4371 |
buttonGradient2.setColorAt(1.0, button.color().darker(103)); |
|
4372 |
sunkenButtonGradientBrush = QBrush(buttonGradient2); |
|
4373 |
||
4374 |
QLinearGradient buttonGradient3(option->rect.topLeft(), option->rect.bottomLeft()); |
|
4375 |
buttonGradient3.setColorAt(0.0, button.color().lighter(105)); |
|
4376 |
buttonGradient3.setColorAt(1.0, button.color()); |
|
4377 |
leftLineGradientBrush = QBrush(buttonGradient3); |
|
4378 |
||
4379 |
QLinearGradient buttonGradient4(option->rect.topLeft(), option->rect.bottomLeft()); |
|
4380 |
buttonGradient4.setColorAt(0.0, button.color()); |
|
4381 |
buttonGradient4.setColorAt(1.0, button.color().darker(110)); |
|
4382 |
rightLineGradientBrush = QBrush(buttonGradient4); |
|
4383 |
||
4384 |
QLinearGradient buttonGradient5(option->rect.topLeft(), option->rect.bottomLeft()); |
|
4385 |
buttonGradient5.setColorAt(0.0, button.color().darker(113)); |
|
4386 |
buttonGradient5.setColorAt(1.0, button.color().darker(107)); |
|
4387 |
sunkenLeftLineGradientBrush = QBrush(buttonGradient5); |
|
4388 |
||
4389 |
QLinearGradient buttonGradient6(option->rect.topLeft(), option->rect.bottomLeft()); |
|
4390 |
buttonGradient6.setColorAt(0.0, button.color().darker(108)); |
|
4391 |
buttonGradient6.setColorAt(1.0, button.color().darker(103)); |
|
4392 |
sunkenRightLineGradientBrush = QBrush(buttonGradient6); |
|
4393 |
} |
|
4394 |
||
4395 |
// ComboBox starts with a lineedit in place already. |
|
4396 |
QRect buttonRect; |
|
4397 |
if (!reverse) { |
|
4398 |
buttonRect.setRect(rect.right() - menuButtonWidth, rect.top(), menuButtonWidth + 1, rect.height()); |
|
4399 |
} else { |
|
4400 |
buttonRect.setRect(rect.left(), rect.top(), menuButtonWidth + 1, rect.height()); |
|
4401 |
} |
|
4402 |
||
4403 |
Q_D(const QPlastiqueStyle); |
|
4404 |
d->drawPartialFrame(painter, |
|
4405 |
option, |
|
4406 |
proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget), |
|
4407 |
widget); |
|
4408 |
||
4409 |
QBrush border = qMapBrushToRect(option->palette.shadow(), buttonRect); |
|
4410 |
qBrushSetAlphaF(&border, qreal(0.4)); |
|
4411 |
painter->setPen(QPen(border, 0)); |
|
4412 |
if (!reverse) |
|
4413 |
painter->drawLine(buttonRect.topLeft() + QPoint(0, 1), buttonRect.bottomLeft() + QPoint(0, -1)); |
|
4414 |
else |
|
4415 |
painter->drawLine(buttonRect.topRight() + QPoint(0, -1), buttonRect.bottomRight() + QPoint(0, 1)); |
|
4416 |
||
4417 |
// Outline the button border |
|
4418 |
if (!reverse) { |
|
4419 |
const QLine lines[3] = { |
|
4420 |
QLine(buttonRect.left(), buttonRect.top(), |
|
4421 |
buttonRect.right() - 2, buttonRect.top()), |
|
4422 |
QLine(buttonRect.right(), buttonRect.top() + 2, |
|
4423 |
buttonRect.right(), buttonRect.bottom() - 2), |
|
4424 |
QLine(buttonRect.left(), buttonRect.bottom(), |
|
4425 |
buttonRect.right() - 2, buttonRect.bottom()) }; |
|
4426 |
painter->drawLines(lines, 3); |
|
4427 |
{ |
|
4428 |
const QPoint points[2] = { |
|
4429 |
QPoint(buttonRect.right() - 1, buttonRect.top() + 1), |
|
4430 |
QPoint(buttonRect.right() - 1, buttonRect.bottom() - 1) }; |
|
4431 |
painter->drawPoints(points, 2); |
|
4432 |
} |
|
4433 |
||
4434 |
QBrush corner = qMapBrushToRect(option->palette.shadow(), buttonRect); |
|
4435 |
qBrushSetAlphaF(&corner, qreal(0.16)); |
|
4436 |
painter->setPen(QPen(corner, 0)); |
|
4437 |
{ |
|
4438 |
const QPoint points[4] = { |
|
4439 |
QPoint(buttonRect.right() - 1, buttonRect.top()), |
|
4440 |
QPoint(buttonRect.right() - 1, buttonRect.bottom()), |
|
4441 |
QPoint(buttonRect.right(), buttonRect.top() + 1), |
|
4442 |
QPoint(buttonRect.right(), buttonRect.bottom() - 1) }; |
|
4443 |
painter->drawPoints(points, 4); |
|
4444 |
} |
|
4445 |
} else { |
|
4446 |
const QLine lines[3] = { |
|
4447 |
QLine(buttonRect.right(), buttonRect.top(), |
|
4448 |
buttonRect.left() + 2, buttonRect.top()), |
|
4449 |
QLine(buttonRect.left(), buttonRect.top() + 2, |
|
4450 |
buttonRect.left(), buttonRect.bottom() - 2), |
|
4451 |
QLine(buttonRect.right(), buttonRect.bottom(), |
|
4452 |
buttonRect.left() + 2, buttonRect.bottom()) }; |
|
4453 |
painter->drawLines(lines, 3); |
|
4454 |
{ |
|
4455 |
const QPoint points[2] = { |
|
4456 |
QPoint(buttonRect.left() + 1, buttonRect.top() + 1), |
|
4457 |
QPoint(buttonRect.left() + 1, buttonRect.bottom() - 1) }; |
|
4458 |
painter->drawPoints(points, 2); |
|
4459 |
} |
|
4460 |
||
4461 |
QBrush corner = qMapBrushToRect(option->palette.shadow(), buttonRect); |
|
4462 |
qBrushSetAlphaF(&corner, qreal(0.16)); |
|
4463 |
painter->setPen(QPen(corner, 0)); |
|
4464 |
{ |
|
4465 |
const QPoint points[4] = { |
|
4466 |
QPoint(buttonRect.left() + 1, buttonRect.top()), |
|
4467 |
QPoint(buttonRect.left() + 1, buttonRect.bottom()), |
|
4468 |
QPoint(buttonRect.left(), buttonRect.top() + 1), |
|
4469 |
QPoint(buttonRect.left(), buttonRect.bottom() - 1) }; |
|
4470 |
painter->drawPoints(points, 4); |
|
4471 |
} |
|
4472 |
} |
|
4473 |
||
4474 |
QRect fillRect = buttonRect.adjusted(2, 2, -2, -2); |
|
4475 |
// Main fill |
|
4476 |
painter->fillRect(fillRect, |
|
4477 |
qMapBrushToRect(sunken ? sunkenButtonGradientBrush |
|
4478 |
: buttonGradientBrush, option->rect)); |
|
4479 |
||
4480 |
// Top line |
|
4481 |
painter->setPen(QPen(qBrushLight(qMapBrushToRect(sunken ? sunkenButtonGradientBrush |
|
4482 |
: buttonGradientBrush, option->rect), 105), 0)); |
|
4483 |
if (!reverse) { |
|
4484 |
painter->drawLine(QPointF(buttonRect.left() + 1, buttonRect.top() + 1), |
|
4485 |
QPointF(buttonRect.right() - 2, buttonRect.top() + 1)); |
|
4486 |
} else { |
|
4487 |
painter->drawLine(QPointF(buttonRect.right() - 1, buttonRect.top() + 1), |
|
4488 |
QPointF(buttonRect.left() + 2, buttonRect.top() + 1)); |
|
4489 |
} |
|
4490 |
||
4491 |
// Bottom line |
|
4492 |
painter->setPen(QPen(qBrushDark(qMapBrushToRect(sunken ? sunkenButtonGradientBrush |
|
4493 |
: buttonGradientBrush, option->rect), 105), 0)); |
|
4494 |
if (!reverse) { |
|
4495 |
painter->drawLine(QPointF(buttonRect.left() + 1, buttonRect.bottom() - 1), |
|
4496 |
QPointF(buttonRect.right() - 2, buttonRect.bottom() - 1)); |
|
4497 |
} else { |
|
4498 |
painter->drawLine(QPointF(buttonRect.right() - 1, buttonRect.bottom() - 1), |
|
4499 |
QPointF(buttonRect.left() + 2, buttonRect.bottom() - 1)); |
|
4500 |
} |
|
4501 |
||
4502 |
// Left line |
|
4503 |
painter->setPen(QPen(qMapBrushToRect(sunken ? sunkenLeftLineGradientBrush |
|
4504 |
: leftLineGradientBrush, option->rect), 1)); |
|
4505 |
if (!reverse) { |
|
4506 |
painter->drawLine(QPointF(buttonRect.left() + 1, buttonRect.top() + 2), |
|
4507 |
QPointF(buttonRect.left() + 1, buttonRect.bottom() - 2)); |
|
4508 |
} else { |
|
4509 |
painter->drawLine(QPointF(buttonRect.left() + 1, buttonRect.top() + 2), |
|
4510 |
QPointF(buttonRect.left() + 1, buttonRect.bottom() - 2)); |
|
4511 |
} |
|
4512 |
||
4513 |
// Right line |
|
4514 |
painter->setPen(QPen(qMapBrushToRect(sunken ? sunkenRightLineGradientBrush |
|
4515 |
: rightLineGradientBrush, option->rect), 1)); |
|
4516 |
if (!reverse) { |
|
4517 |
painter->drawLine(QPointF(buttonRect.right() - 1, buttonRect.top() + 2), |
|
4518 |
QPointF(buttonRect.right() - 1, buttonRect.bottom() - 2)); |
|
4519 |
} else { |
|
4520 |
painter->drawLine(QPointF(buttonRect.right() - 1, buttonRect.top() + 2), |
|
4521 |
QPointF(buttonRect.right() - 1, buttonRect.bottom() - 2)); |
|
4522 |
} |
|
4523 |
} else { |
|
4524 |
// Start with a standard panel button fill |
|
4525 |
QStyleOptionButton buttonOption; |
|
4526 |
buttonOption.QStyleOption::operator=(*comboBox); |
|
4527 |
if (!sunken) { |
|
4528 |
buttonOption.state &= ~State_Sunken; |
|
4529 |
} |
|
4530 |
proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget); |
|
4531 |
||
4532 |
// Draw the menu button separator line |
|
4533 |
QBrush border = qMapBrushToRect(option->palette.shadow(), rect); |
|
4534 |
qBrushSetAlphaF(&border, qreal(0.35)); |
|
4535 |
painter->setPen(QPen(border, 0)); |
|
4536 |
if (!reverse) { |
|
4537 |
painter->drawLine(rect.right() - menuButtonWidth + xoffset, rect.top() + 1, |
|
4538 |
rect.right() - menuButtonWidth + xoffset, rect.bottom() - 1); |
|
4539 |
} else { |
|
4540 |
painter->drawLine(rect.left() + menuButtonWidth + xoffset, rect.top() + 1, |
|
4541 |
rect.left() + menuButtonWidth + xoffset, rect.bottom() - 1); |
|
4542 |
} |
|
4543 |
} |
|
4544 |
||
4545 |
// Draw the little arrow |
|
4546 |
if (comboBox->subControls & SC_ComboBoxArrow) { |
|
4547 |
int left = !reverse ? rect.right() - menuButtonWidth : rect.left(); |
|
4548 |
int right = !reverse ? rect.right() : rect.left() + menuButtonWidth; |
|
4549 |
QRect arrowRect((left + right) / 2 - 3 + xoffset, |
|
4550 |
rect.center().y() - 1 + yoffset, 7, 4); |
|
4551 |
painter->setPen(QPen(qMapBrushToRect(option->palette.buttonText(), rect), 0)); |
|
4552 |
const QLine lines[3] = { |
|
4553 |
QLine(arrowRect.topLeft(), arrowRect.topRight()), |
|
4554 |
QLine(arrowRect.left() + 1, arrowRect.top() + 1, |
|
4555 |
arrowRect.right() - 1, arrowRect.top() + 1), |
|
4556 |
QLine(arrowRect.left() + 2, arrowRect.top() + 2, |
|
4557 |
arrowRect.right() - 2, arrowRect.top() + 2) }; |
|
4558 |
painter->drawLines(lines, 3); |
|
4559 |
painter->drawPoint(arrowRect.center().x(), arrowRect.bottom()); |
|
4560 |
} |
|
4561 |
||
4562 |
// Draw the focus rect |
|
4563 |
if ((option->state & State_HasFocus) && !comboBox->editable |
|
4564 |
&& ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) { |
|
4565 |
QStyleOptionFocusRect focus; |
|
4566 |
focus.rect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget) |
|
4567 |
.adjusted(-2, 0, 2, 0); |
|
4568 |
proxy()->drawPrimitive(PE_FrameFocusRect, &focus, painter, widget); |
|
4569 |
} |
|
4570 |
||
4571 |
painter->setPen(oldPen); |
|
4572 |
} |
|
4573 |
break; |
|
4574 |
#endif // QT_NO_COMBOBOX |
|
4575 |
case CC_TitleBar: |
|
4576 |
if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) { |
|
4577 |
painter->save(); |
|
4578 |
bool active = (titleBar->titleBarState & State_Active); |
|
4579 |
QRect fullRect = titleBar->rect; |
|
4580 |
||
4581 |
// ### use palette colors instead |
|
4582 |
QColor titleBarGradientStart(active ? 0x3b508a : 0x6e6e6e); |
|
4583 |
QColor titleBarGradientStop(active ? 0x5d6e9e : 0x818181); |
|
4584 |
QColor titleBarFrameBorder(0x393939); |
|
4585 |
QColor titleBarAlphaCorner(active ? 0x4b5e7f : 0x6a6a6a); |
|
4586 |
QColor titleBarInnerTopLine(active ? 0x8e98ba : 0xa4a4a4); |
|
4587 |
QColor titleBarInnerInnerTopLine(active ? 0x57699b : 0x808080); |
|
4588 |
QColor leftCorner(active ? 0x6f7ea8 : 0x8e8e8e); |
|
4589 |
QColor rightCorner(active ? 0x44537d : 0x676767); |
|
4590 |
QColor textColor(active ? 0x282e40 : 0x282e40); |
|
4591 |
QColor textAlphaColor(active ? 0x3f4862 : 0x3f4862); |
|
4592 |
||
4593 |
#ifdef QT3_SUPPORT |
|
4594 |
if (widget && widget->inherits("Q3DockWindowTitleBar")) { |
|
4595 |
QStyleOptionDockWidgetV2 dockwidget; |
|
4596 |
dockwidget.QStyleOption::operator=(*option); |
|
4597 |
dockwidget.title = titleBar->text; |
|
4598 |
proxy()->drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget); |
|
4599 |
} else |
|
4600 |
#endif // QT3_SUPPORT |
|
4601 |
||
4602 |
{ |
|
4603 |
// Fill title bar gradient |
|
4604 |
qt_plastique_draw_gradient(painter, option->rect.adjusted(1, 1, -1, 0), |
|
4605 |
titleBarGradientStart, |
|
4606 |
titleBarGradientStop); |
|
4607 |
||
4608 |
// Frame and rounded corners |
|
4609 |
painter->setPen(titleBarFrameBorder); |
|
4610 |
||
4611 |
// top border line |
|
4612 |
{ |
|
4613 |
const QLine lines[3] = { |
|
4614 |
QLine(fullRect.left() + 2, fullRect.top(), fullRect.right() - 2, fullRect.top()), |
|
4615 |
QLine(fullRect.left(), fullRect.top() + 2, fullRect.left(), fullRect.bottom()), |
|
4616 |
QLine(fullRect.right(), fullRect.top() + 2, fullRect.right(), fullRect.bottom()) }; |
|
4617 |
painter->drawLines(lines, 3); |
|
4618 |
const QPoint points[2] = { |
|
4619 |
QPoint(fullRect.left() + 1, fullRect.top() + 1), |
|
4620 |
QPoint(fullRect.right() - 1, fullRect.top() + 1) }; |
|
4621 |
painter->drawPoints(points, 2); |
|
4622 |
} |
|
4623 |
||
4624 |
// alpha corners |
|
4625 |
painter->setPen(titleBarAlphaCorner); |
|
4626 |
{ |
|
4627 |
const QPoint points[4] = { |
|
4628 |
QPoint(fullRect.left() + 2, fullRect.top() + 1), |
|
4629 |
QPoint(fullRect.left() + 1, fullRect.top() + 2), |
|
4630 |
QPoint(fullRect.right() - 2, fullRect.top() + 1), |
|
4631 |
QPoint(fullRect.right() - 1, fullRect.top() + 2) }; |
|
4632 |
painter->drawPoints(points, 4); |
|
4633 |
} |
|
4634 |
||
4635 |
// inner top line |
|
4636 |
painter->setPen(titleBarInnerTopLine); |
|
4637 |
painter->drawLine(fullRect.left() + 3, fullRect.top() + 1, fullRect.right() - 3, fullRect.top() + 1); |
|
4638 |
||
4639 |
// inner inner top line |
|
4640 |
painter->setPen(titleBarInnerInnerTopLine); |
|
4641 |
painter->drawLine(fullRect.left() + 2, fullRect.top() + 2, fullRect.right() - 2, fullRect.top() + 2); |
|
4642 |
||
4643 |
// left and right inner |
|
4644 |
painter->setPen(leftCorner); |
|
4645 |
painter->drawLine(fullRect.left() + 1, fullRect.top() + 3, fullRect.left() + 1, fullRect.bottom()); |
|
4646 |
painter->setPen(rightCorner); |
|
4647 |
painter->drawLine(fullRect.right() - 1, fullRect.top() + 3, fullRect.right() - 1, fullRect.bottom()); |
|
4648 |
||
4649 |
if (titleBar->titleBarState & Qt::WindowMinimized) { |
|
4650 |
painter->setPen(titleBarFrameBorder); |
|
4651 |
painter->drawLine(fullRect.left() + 2, fullRect.bottom(), fullRect.right() - 2, fullRect.bottom()); |
|
4652 |
{ |
|
4653 |
const QPoint points[2] = { |
|
4654 |
QPoint(fullRect.left() + 1, fullRect.bottom() - 1), |
|
4655 |
QPoint(fullRect.right() - 1, fullRect.bottom() - 1) }; |
|
4656 |
painter->drawPoints(points, 2); |
|
4657 |
} |
|
4658 |
painter->setPen(rightCorner); |
|
4659 |
painter->drawLine(fullRect.left() + 2, fullRect.bottom() - 1, fullRect.right() - 2, fullRect.bottom() - 1); |
|
4660 |
painter->setPen(titleBarAlphaCorner); |
|
4661 |
{ |
|
4662 |
const QPoint points[4] = { |
|
4663 |
QPoint(fullRect.left() + 1, fullRect.bottom() - 2), |
|
4664 |
QPoint(fullRect.left() + 2, fullRect.bottom() - 1), |
|
4665 |
QPoint(fullRect.right() - 1, fullRect.bottom() - 2), |
|
4666 |
QPoint(fullRect.right() - 2, fullRect.bottom() - 1) }; |
|
4667 |
painter->drawPoints(points, 4); |
|
4668 |
} |
|
4669 |
} |
|
4670 |
// draw title |
|
4671 |
QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget); |
|
4672 |
||
4673 |
QFont font = painter->font(); |
|
4674 |
font.setBold(true); |
|
4675 |
painter->setFont(font); |
|
4676 |
painter->setPen(titleBar->palette.text().color()); |
|
4677 |
||
4678 |
// Attempt to align left if there is not enough room for the title |
|
4679 |
// text. Otherwise, align center. QWorkspace does elliding for us, |
|
4680 |
// and it doesn't know about the bold title, so we need to work |
|
4681 |
// around some of the width mismatches. |
|
4682 |
bool tooWide = (QFontMetrics(font).width(titleBar->text) > textRect.width()); |
|
4683 |
QTextOption option((tooWide ? Qt::AlignLeft : Qt::AlignHCenter) | Qt::AlignVCenter); |
|
4684 |
option.setWrapMode(QTextOption::NoWrap); |
|
4685 |
||
4686 |
painter->drawText(textRect.adjusted(1, 1, 1, 1), titleBar->text, option); |
|
4687 |
painter->setPen(titleBar->palette.highlightedText().color()); |
|
4688 |
painter->drawText(textRect, titleBar->text, option); |
|
4689 |
} |
|
4690 |
||
4691 |
// min button |
|
4692 |
if ((titleBar->subControls & SC_TitleBarMinButton) |
|
4693 |
&& (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) |
|
4694 |
&& !(titleBar->titleBarState & Qt::WindowMinimized)) { |
|
4695 |
bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver); |
|
4696 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken); |
|
4697 |
||
4698 |
QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget); |
|
4699 |
qt_plastique_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken); |
|
4700 |
||
4701 |
int xoffset = minButtonRect.width() / 3; |
|
4702 |
int yoffset = minButtonRect.height() / 3; |
|
4703 |
||
4704 |
QRect minButtonIconRect(minButtonRect.left() + xoffset, minButtonRect.top() + yoffset, |
|
4705 |
minButtonRect.width() - xoffset * 2, minButtonRect.height() - yoffset * 2); |
|
4706 |
||
4707 |
painter->setPen(textColor); |
|
4708 |
{ |
|
4709 |
const QLine lines[2] = { |
|
4710 |
QLine(minButtonIconRect.center().x() - 2, |
|
4711 |
minButtonIconRect.center().y() + 3, |
|
4712 |
minButtonIconRect.center().x() + 3, |
|
4713 |
minButtonIconRect.center().y() + 3), |
|
4714 |
QLine(minButtonIconRect.center().x() - 2, |
|
4715 |
minButtonIconRect.center().y() + 4, |
|
4716 |
minButtonIconRect.center().x() + 3, |
|
4717 |
minButtonIconRect.center().y() + 4) }; |
|
4718 |
painter->drawLines(lines, 2); |
|
4719 |
} |
|
4720 |
painter->setPen(textAlphaColor); |
|
4721 |
{ |
|
4722 |
const QLine lines[2] = { |
|
4723 |
QLine(minButtonIconRect.center().x() - 3, |
|
4724 |
minButtonIconRect.center().y() + 3, |
|
4725 |
minButtonIconRect.center().x() - 3, |
|
4726 |
minButtonIconRect.center().y() + 4), |
|
4727 |
QLine(minButtonIconRect.center().x() + 4, |
|
4728 |
minButtonIconRect.center().y() + 3, |
|
4729 |
minButtonIconRect.center().x() + 4, |
|
4730 |
minButtonIconRect.center().y() + 4) }; |
|
4731 |
painter->drawLines(lines, 2); |
|
4732 |
} |
|
4733 |
} |
|
4734 |
||
4735 |
// max button |
|
4736 |
if ((titleBar->subControls & SC_TitleBarMaxButton) |
|
4737 |
&& (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) |
|
4738 |
&& !(titleBar->titleBarState & Qt::WindowMaximized)) { |
|
4739 |
bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver); |
|
4740 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken); |
|
4741 |
||
4742 |
QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget); |
|
4743 |
qt_plastique_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken); |
|
4744 |
||
4745 |
int xoffset = maxButtonRect.width() / 3; |
|
4746 |
int yoffset = maxButtonRect.height() / 3; |
|
4747 |
||
4748 |
QRect maxButtonIconRect(maxButtonRect.left() + xoffset, maxButtonRect.top() + yoffset, |
|
4749 |
maxButtonRect.width() - xoffset * 2, maxButtonRect.height() - yoffset * 2); |
|
4750 |
||
4751 |
painter->setPen(textColor); |
|
4752 |
painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1)); |
|
4753 |
painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1, |
|
4754 |
maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1); |
|
4755 |
painter->setPen(textAlphaColor); |
|
4756 |
const QPoint points[4] = { |
|
4757 |
maxButtonIconRect.topLeft(), maxButtonIconRect.topRight(), |
|
4758 |
maxButtonIconRect.bottomLeft(), maxButtonIconRect.bottomRight() }; |
|
4759 |
painter->drawPoints(points, 4); |
|
4760 |
} |
|
4761 |
||
4762 |
// close button |
|
4763 |
if (titleBar->subControls & SC_TitleBarCloseButton && titleBar->titleBarFlags & Qt::WindowSystemMenuHint) { |
|
4764 |
bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver); |
|
4765 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken); |
|
4766 |
||
4767 |
QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget); |
|
4768 |
qt_plastique_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken); |
|
4769 |
||
4770 |
int xoffset = closeButtonRect.width() / 3; |
|
4771 |
int yoffset = closeButtonRect.height() / 3; |
|
4772 |
||
4773 |
QRect closeIconRect(closeButtonRect.left() + xoffset, closeButtonRect.top() + yoffset, |
|
4774 |
closeButtonRect.width() - xoffset * 2, closeButtonRect.height() - yoffset * 2); |
|
4775 |
||
4776 |
painter->setPen(textAlphaColor); |
|
4777 |
{ |
|
4778 |
const QLine lines[4] = { |
|
4779 |
QLine(closeIconRect.left() + 1, closeIconRect.top(), |
|
4780 |
closeIconRect.right(), closeIconRect.bottom() - 1), |
|
4781 |
QLine(closeIconRect.left(), closeIconRect.top() + 1, |
|
4782 |
closeIconRect.right() - 1, closeIconRect.bottom()), |
|
4783 |
QLine(closeIconRect.right() - 1, closeIconRect.top(), |
|
4784 |
closeIconRect.left(), closeIconRect.bottom() - 1), |
|
4785 |
QLine(closeIconRect.right(), closeIconRect.top() + 1, |
|
4786 |
closeIconRect.left() + 1, closeIconRect.bottom()) }; |
|
4787 |
painter->drawLines(lines, 4); |
|
4788 |
const QPoint points[4] = { |
|
4789 |
closeIconRect.topLeft(), closeIconRect.topRight(), |
|
4790 |
closeIconRect.bottomLeft(), closeIconRect.bottomRight() }; |
|
4791 |
painter->drawPoints(points, 4); |
|
4792 |
} |
|
4793 |
painter->setPen(textColor); |
|
4794 |
{ |
|
4795 |
const QLine lines[2] = { |
|
4796 |
QLine(closeIconRect.left() + 1, closeIconRect.top() + 1, |
|
4797 |
closeIconRect.right() - 1, closeIconRect.bottom() - 1), |
|
4798 |
QLine(closeIconRect.left() + 1, closeIconRect.bottom() - 1, |
|
4799 |
closeIconRect.right() - 1, closeIconRect.top() + 1) }; |
|
4800 |
painter->drawLines(lines, 2); |
|
4801 |
} |
|
4802 |
} |
|
4803 |
||
4804 |
// normalize button |
|
4805 |
if ((titleBar->subControls & SC_TitleBarNormalButton) && |
|
4806 |
(((titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) && |
|
4807 |
(titleBar->titleBarState & Qt::WindowMinimized)) || |
|
4808 |
((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) && |
|
4809 |
(titleBar->titleBarState & Qt::WindowMaximized)))) { |
|
4810 |
bool hover = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver); |
|
4811 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken); |
|
4812 |
||
4813 |
QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget); |
|
4814 |
qt_plastique_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken); |
|
4815 |
int xoffset = int(normalButtonRect.width() / 3.5); |
|
4816 |
int yoffset = int(normalButtonRect.height() / 3.5); |
|
4817 |
||
4818 |
QRect normalButtonIconRect(normalButtonRect.left() + xoffset, normalButtonRect.top() + yoffset, |
|
4819 |
normalButtonRect.width() - xoffset * 2, normalButtonRect.height() - yoffset * 2); |
|
4820 |
||
4821 |
QRect frontWindowRect = normalButtonIconRect.adjusted(0, 3, -3, 0); |
|
4822 |
painter->setPen(textColor); |
|
4823 |
painter->drawRect(frontWindowRect.adjusted(0, 0, -1, -1)); |
|
4824 |
painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1, |
|
4825 |
frontWindowRect.right() - 1, frontWindowRect.top() + 1); |
|
4826 |
painter->setPen(textAlphaColor); |
|
4827 |
{ |
|
4828 |
const QPoint points[4] = { |
|
4829 |
frontWindowRect.topLeft(), frontWindowRect.topRight(), |
|
4830 |
frontWindowRect.bottomLeft(), frontWindowRect.bottomRight() }; |
|
4831 |
painter->drawPoints(points, 4); |
|
4832 |
} |
|
4833 |
||
4834 |
QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3); |
|
4835 |
QRegion clipRegion = backWindowRect; |
|
4836 |
clipRegion -= frontWindowRect; |
|
4837 |
painter->save(); |
|
4838 |
painter->setClipRegion(clipRegion); |
|
4839 |
painter->setPen(textColor); |
|
4840 |
painter->drawRect(backWindowRect.adjusted(0, 0, -1, -1)); |
|
4841 |
painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1, |
|
4842 |
backWindowRect.right() - 1, backWindowRect.top() + 1); |
|
4843 |
painter->setPen(textAlphaColor); |
|
4844 |
{ |
|
4845 |
const QPoint points[4] = { |
|
4846 |
backWindowRect.topLeft(), backWindowRect.topRight(), |
|
4847 |
backWindowRect.bottomLeft(), backWindowRect.bottomRight() }; |
|
4848 |
painter->drawPoints(points, 4); |
|
4849 |
} |
|
4850 |
painter->restore(); |
|
4851 |
} |
|
4852 |
||
4853 |
// context help button |
|
4854 |
if (titleBar->subControls & SC_TitleBarContextHelpButton |
|
4855 |
&& (titleBar->titleBarFlags & Qt::WindowContextHelpButtonHint)) { |
|
4856 |
bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver); |
|
4857 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken); |
|
4858 |
||
4859 |
QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget); |
|
4860 |
||
4861 |
qt_plastique_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken); |
|
4862 |
||
4863 |
QColor blend; |
|
4864 |
// ### Use palette colors |
|
4865 |
if (active) { |
|
4866 |
blend = mergedColors(QColor(hover ? 0x7d8bb1 : 0x55689a), |
|
4867 |
QColor(hover ? 0x939ebe : 0x7381ab)); |
|
4868 |
} else { |
|
4869 |
blend = mergedColors(QColor(hover ? 0x9e9e9e : 0x818181), |
|
4870 |
QColor(hover ? 0xababab : 0x929292)); |
|
4871 |
} |
|
4872 |
QImage image(qt_titlebar_context_help); |
|
4873 |
image.setColor(4, textColor.rgba()); |
|
4874 |
image.setColor(3, mergedColors(blend, textColor, 30).rgba()); |
|
4875 |
image.setColor(2, mergedColors(blend, textColor, 70).rgba()); |
|
4876 |
image.setColor(1, mergedColors(blend, textColor, 90).rgba()); |
|
4877 |
||
4878 |
painter->drawImage(contextHelpButtonRect, image); |
|
4879 |
} |
|
4880 |
||
4881 |
// shade button |
|
4882 |
if (titleBar->subControls & SC_TitleBarShadeButton) { |
|
4883 |
bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver); |
|
4884 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken); |
|
4885 |
||
4886 |
QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget); |
|
4887 |
qt_plastique_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken); |
|
4888 |
||
4889 |
int xoffset = shadeButtonRect.width() / 3; |
|
4890 |
int yoffset = shadeButtonRect.height() / 3; |
|
4891 |
||
4892 |
QRect shadeButtonIconRect(shadeButtonRect.left() + xoffset, shadeButtonRect.top() + yoffset, |
|
4893 |
shadeButtonRect.width() - xoffset * 2, shadeButtonRect.height() - yoffset * 2); |
|
4894 |
||
4895 |
QPainterPath path(shadeButtonIconRect.bottomLeft()); |
|
4896 |
path.lineTo(shadeButtonIconRect.center().x(), shadeButtonIconRect.bottom() - shadeButtonIconRect.height() / 2); |
|
4897 |
path.lineTo(shadeButtonIconRect.bottomRight()); |
|
4898 |
path.lineTo(shadeButtonIconRect.bottomLeft()); |
|
4899 |
||
4900 |
painter->setPen(textAlphaColor); |
|
4901 |
painter->setBrush(textColor); |
|
4902 |
painter->drawPath(path); |
|
4903 |
} |
|
4904 |
||
4905 |
// unshade button |
|
4906 |
if (titleBar->subControls & SC_TitleBarUnshadeButton) { |
|
4907 |
bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver); |
|
4908 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken); |
|
4909 |
||
4910 |
QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget); |
|
4911 |
qt_plastique_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken); |
|
4912 |
||
4913 |
int xoffset = unshadeButtonRect.width() / 3; |
|
4914 |
int yoffset = unshadeButtonRect.height() / 3; |
|
4915 |
||
4916 |
QRect unshadeButtonIconRect(unshadeButtonRect.left() + xoffset, unshadeButtonRect.top() + yoffset, |
|
4917 |
unshadeButtonRect.width() - xoffset * 2, unshadeButtonRect.height() - yoffset * 2); |
|
4918 |
||
4919 |
int midY = unshadeButtonIconRect.bottom() - unshadeButtonIconRect.height() / 2; |
|
4920 |
QPainterPath path(QPoint(unshadeButtonIconRect.left(), midY)); |
|
4921 |
path.lineTo(unshadeButtonIconRect.right(), midY); |
|
4922 |
path.lineTo(unshadeButtonIconRect.center().x(), unshadeButtonIconRect.bottom()); |
|
4923 |
path.lineTo(unshadeButtonIconRect.left(), midY); |
|
4924 |
||
4925 |
painter->setPen(textAlphaColor); |
|
4926 |
painter->setBrush(textColor); |
|
4927 |
painter->drawPath(path); |
|
4928 |
} |
|
4929 |
||
4930 |
// from qwindowsstyle.cpp |
|
4931 |
if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) { |
|
4932 |
bool hover = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_MouseOver); |
|
4933 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_Sunken); |
|
4934 |
||
4935 |
QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget); |
|
4936 |
if (hover) |
|
4937 |
qt_plastique_draw_mdibutton(painter, titleBar, iconRect, hover, sunken); |
|
4938 |
||
4939 |
if (!titleBar->icon.isNull()) { |
|
4940 |
titleBar->icon.paint(painter, iconRect); |
|
4941 |
} else { |
|
4942 |
QStyleOption tool(0); |
|
4943 |
tool.palette = titleBar->palette; |
|
4944 |
QPixmap pm = standardPixmap(SP_TitleBarMenuButton, &tool, widget); |
|
4945 |
tool.rect = iconRect; |
|
4946 |
painter->save(); |
|
4947 |
proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm); |
|
4948 |
painter->restore(); |
|
4949 |
} |
|
4950 |
} |
|
4951 |
painter->restore(); |
|
4952 |
} |
|
4953 |
break; |
|
4954 |
#ifndef QT_NO_DIAL |
|
4955 |
case CC_Dial: |
|
4956 |
if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option)) |
|
4957 |
QStyleHelper::drawDial(dial, painter); |
|
4958 |
break; |
|
4959 |
#endif // QT_NO_DIAL |
|
4960 |
default: |
|
4961 |
QWindowsStyle::drawComplexControl(control, option, painter, widget); |
|
4962 |
break; |
|
4963 |
} |
|
4964 |
} |
|
4965 |
||
4966 |
/*! |
|
4967 |
\reimp |
|
4968 |
*/ |
|
4969 |
QSize QPlastiqueStyle::sizeFromContents(ContentsType type, const QStyleOption *option, |
|
4970 |
const QSize &size, const QWidget *widget) const |
|
4971 |
{ |
|
4972 |
QSize newSize = QWindowsStyle::sizeFromContents(type, option, size, widget); |
|
4973 |
||
4974 |
switch (type) { |
|
4975 |
case CT_RadioButton: |
|
4976 |
++newSize.rheight(); |
|
4977 |
++newSize.rwidth(); |
|
4978 |
break; |
|
4979 |
#ifndef QT_NO_SLIDER |
|
4980 |
case CT_Slider: |
|
4981 |
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
4982 |
int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); |
|
4983 |
if (slider->tickPosition & QSlider::TicksBelow) { |
|
4984 |
if (slider->orientation == Qt::Horizontal) |
|
4985 |
newSize.rheight() += tickSize; |
|
4986 |
else |
|
4987 |
newSize.rwidth() += tickSize; |
|
4988 |
} |
|
4989 |
if (slider->tickPosition & QSlider::TicksAbove) { |
|
4990 |
if (slider->orientation == Qt::Horizontal) |
|
4991 |
newSize.rheight() += tickSize; |
|
4992 |
else |
|
4993 |
newSize.rwidth() += tickSize; |
|
4994 |
} |
|
4995 |
} |
|
4996 |
break; |
|
4997 |
#endif // QT_NO_SLIDER |
|
4998 |
#ifndef QT_NO_SCROLLBAR |
|
4999 |
case CT_ScrollBar: |
|
5000 |
if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
5001 |
int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget); |
|
5002 |
int scrollBarSliderMinimum = proxy()->pixelMetric(PM_ScrollBarSliderMin, option, widget); |
|
5003 |
if (scrollBar->orientation == Qt::Horizontal) { |
|
5004 |
newSize = QSize(scrollBarExtent * 3 + scrollBarSliderMinimum, scrollBarExtent); |
|
5005 |
} else { |
|
5006 |
newSize = QSize(scrollBarExtent, scrollBarExtent * 3 + scrollBarSliderMinimum); |
|
5007 |
} |
|
5008 |
} |
|
5009 |
break; |
|
5010 |
#endif // QT_NO_SCROLLBAR |
|
5011 |
#ifndef QT_NO_SPINBOX |
|
5012 |
case CT_SpinBox: |
|
5013 |
// Make sure the size is odd |
|
5014 |
newSize.setHeight(sizeFromContents(CT_LineEdit, option, size, widget).height()); |
|
5015 |
newSize.rheight() -= ((1 - newSize.rheight()) & 1); |
|
5016 |
break; |
|
5017 |
#endif |
|
5018 |
#ifndef QT_NO_TOOLBUTTON |
|
5019 |
case CT_ToolButton: |
|
5020 |
newSize.rheight() += 3; |
|
5021 |
newSize.rwidth() += 3; |
|
5022 |
break; |
|
5023 |
#endif |
|
5024 |
#ifndef QT_NO_COMBOBOX |
|
5025 |
case CT_ComboBox: |
|
5026 |
newSize = sizeFromContents(CT_PushButton, option, size, widget); |
|
5027 |
newSize.rwidth() += 30; // Make room for drop-down indicator |
|
5028 |
newSize.rheight() += 4; |
|
5029 |
break; |
|
5030 |
#endif |
|
5031 |
case CT_MenuItem: |
|
5032 |
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
5033 |
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5034 |
newSize.setHeight(menuItem->text.isEmpty() ? 2 : menuItem->fontMetrics.height()); |
0 | 5035 |
} |
5036 |
break; |
|
5037 |
case CT_MenuBarItem: |
|
5038 |
newSize.setHeight(newSize.height()); |
|
5039 |
break; |
|
5040 |
default: |
|
5041 |
break; |
|
5042 |
} |
|
5043 |
||
5044 |
return newSize; |
|
5045 |
} |
|
5046 |
||
5047 |
/*! |
|
5048 |
\reimp |
|
5049 |
*/ |
|
5050 |
QRect QPlastiqueStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const |
|
5051 |
{ |
|
5052 |
QRect rect; |
|
5053 |
switch (element) { |
|
5054 |
case SE_RadioButtonIndicator: |
|
5055 |
rect = visualRect(option->direction, option->rect, |
|
5056 |
QWindowsStyle::subElementRect(element, option, widget)).adjusted(0, 0, 1, 1); |
|
5057 |
break; |
|
5058 |
#ifndef QT_NO_PROGRESSBAR |
|
5059 |
case SE_ProgressBarLabel: |
|
5060 |
case SE_ProgressBarContents: |
|
5061 |
case SE_ProgressBarGroove: |
|
5062 |
return option->rect; |
|
5063 |
#endif // QT_NO_PROGRESSBAR |
|
5064 |
default: |
|
5065 |
return QWindowsStyle::subElementRect(element, option, widget); |
|
5066 |
} |
|
5067 |
||
5068 |
return visualRect(option->direction, option->rect, rect); |
|
5069 |
} |
|
5070 |
||
5071 |
/*! |
|
5072 |
\reimp |
|
5073 |
*/ |
|
5074 |
QRect QPlastiqueStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option, |
|
5075 |
SubControl subControl, const QWidget *widget) const |
|
5076 |
{ |
|
5077 |
QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget); |
|
5078 |
||
5079 |
switch (control) { |
|
5080 |
#ifndef QT_NO_SLIDER |
|
5081 |
case CC_Slider: |
|
5082 |
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
5083 |
int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); |
|
5084 |
||
5085 |
switch (subControl) { |
|
5086 |
case SC_SliderHandle: |
|
5087 |
if (slider->orientation == Qt::Horizontal) { |
|
5088 |
rect.setWidth(11); |
|
5089 |
rect.setHeight(15); |
|
5090 |
int centerY = slider->rect.center().y() - rect.height() / 2; |
|
5091 |
if (slider->tickPosition & QSlider::TicksAbove) |
|
5092 |
centerY += tickSize; |
|
5093 |
if (slider->tickPosition & QSlider::TicksBelow) |
|
5094 |
centerY -= tickSize; |
|
5095 |
rect.moveTop(centerY); |
|
5096 |
} else { |
|
5097 |
rect.setWidth(15); |
|
5098 |
rect.setHeight(11); |
|
5099 |
int centerX = slider->rect.center().x() - rect.width() / 2; |
|
5100 |
if (slider->tickPosition & QSlider::TicksAbove) |
|
5101 |
centerX += tickSize; |
|
5102 |
if (slider->tickPosition & QSlider::TicksBelow) |
|
5103 |
centerX -= tickSize; |
|
5104 |
rect.moveLeft(centerX); |
|
5105 |
} |
|
5106 |
break; |
|
5107 |
case SC_SliderGroove: { |
|
5108 |
QPoint grooveCenter = slider->rect.center(); |
|
5109 |
if (slider->orientation == Qt::Horizontal) { |
|
5110 |
rect.setHeight(14); |
|
5111 |
--grooveCenter.ry(); |
|
5112 |
if (slider->tickPosition & QSlider::TicksAbove) |
|
5113 |
grooveCenter.ry() += tickSize; |
|
5114 |
if (slider->tickPosition & QSlider::TicksBelow) |
|
5115 |
grooveCenter.ry() -= tickSize; |
|
5116 |
} else { |
|
5117 |
rect.setWidth(14); |
|
5118 |
--grooveCenter.rx(); |
|
5119 |
if (slider->tickPosition & QSlider::TicksAbove) |
|
5120 |
grooveCenter.rx() += tickSize; |
|
5121 |
if (slider->tickPosition & QSlider::TicksBelow) |
|
5122 |
grooveCenter.rx() -= tickSize; |
|
5123 |
} |
|
5124 |
rect.moveCenter(grooveCenter); |
|
5125 |
break; |
|
5126 |
} |
|
5127 |
default: |
|
5128 |
break; |
|
5129 |
} |
|
5130 |
} |
|
5131 |
break; |
|
5132 |
#endif // QT_NO_SLIDER |
|
5133 |
#ifndef QT_NO_SCROLLBAR |
|
5134 |
case CC_ScrollBar: |
|
5135 |
if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
5136 |
int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollBar, widget); |
|
5137 |
int sliderMaxLength = ((scrollBar->orientation == Qt::Horizontal) ? |
|
5138 |
scrollBar->rect.width() : scrollBar->rect.height()) - (scrollBarExtent * 3); |
|
5139 |
int sliderMinLength = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget); |
|
5140 |
int sliderLength; |
|
5141 |
||
5142 |
// calculate slider length |
|
5143 |
if (scrollBar->maximum != scrollBar->minimum) { |
|
5144 |
uint valueRange = scrollBar->maximum - scrollBar->minimum; |
|
5145 |
sliderLength = (scrollBar->pageStep * sliderMaxLength) / (valueRange + scrollBar->pageStep); |
|
5146 |
||
5147 |
if (sliderLength < sliderMinLength || valueRange > INT_MAX / 2) |
|
5148 |
sliderLength = sliderMinLength; |
|
5149 |
if (sliderLength > sliderMaxLength) |
|
5150 |
sliderLength = sliderMaxLength; |
|
5151 |
} else { |
|
5152 |
sliderLength = sliderMaxLength; |
|
5153 |
} |
|
5154 |
||
5155 |
int sliderStart = scrollBarExtent + sliderPositionFromValue(scrollBar->minimum, |
|
5156 |
scrollBar->maximum, |
|
5157 |
scrollBar->sliderPosition, |
|
5158 |
sliderMaxLength - sliderLength, |
|
5159 |
scrollBar->upsideDown); |
|
5160 |
||
5161 |
QRect scrollBarRect = scrollBar->rect; |
|
5162 |
||
5163 |
switch (subControl) { |
|
5164 |
case SC_ScrollBarSubLine: // top/left button |
|
5165 |
if (scrollBar->orientation == Qt::Horizontal) { |
|
5166 |
rect.setRect(scrollBarRect.left(), scrollBarRect.top(), scrollBarRect.width() - scrollBarExtent, scrollBarRect.height()); |
|
5167 |
} else { |
|
5168 |
rect.setRect(scrollBarRect.left(), scrollBarRect.top(), scrollBarRect.width(), scrollBarRect.height() - scrollBarExtent); |
|
5169 |
} |
|
5170 |
break; |
|
5171 |
case SC_ScrollBarAddLine: // bottom/right button |
|
5172 |
if (scrollBar->orientation == Qt::Horizontal) { |
|
5173 |
rect.setRect(scrollBarRect.right() - (scrollBarExtent - 1), scrollBarRect.top(), scrollBarExtent, scrollBarRect.height()); |
|
5174 |
} else { |
|
5175 |
rect.setRect(scrollBarRect.left(), scrollBarRect.bottom() - (scrollBarExtent - 1), scrollBarRect.width(), scrollBarExtent); |
|
5176 |
} |
|
5177 |
break; |
|
5178 |
case SC_ScrollBarSubPage: |
|
5179 |
if (scrollBar->orientation == Qt::Horizontal) { |
|
5180 |
rect.setRect(scrollBarRect.left() + scrollBarExtent, scrollBarRect.top(), |
|
5181 |
sliderStart - (scrollBarRect.left() + scrollBarExtent), scrollBarRect.height()); |
|
5182 |
} else { |
|
5183 |
rect.setRect(scrollBarRect.left(), scrollBarRect.top() + scrollBarExtent, |
|
5184 |
scrollBarRect.width(), sliderStart - (scrollBarRect.left() + scrollBarExtent)); |
|
5185 |
} |
|
5186 |
break; |
|
5187 |
case SC_ScrollBarAddPage: |
|
5188 |
if (scrollBar->orientation == Qt::Horizontal) |
|
5189 |
rect.setRect(sliderStart + sliderLength, 0, |
|
5190 |
sliderMaxLength - sliderStart - sliderLength + scrollBarExtent, scrollBarRect.height()); |
|
5191 |
else |
|
5192 |
rect.setRect(0, sliderStart + sliderLength, |
|
5193 |
scrollBarRect.width(), sliderMaxLength - sliderStart - sliderLength + scrollBarExtent); |
|
5194 |
break; |
|
5195 |
case SC_ScrollBarGroove: |
|
5196 |
if (scrollBar->orientation == Qt::Horizontal) { |
|
5197 |
rect = scrollBarRect.adjusted(scrollBarExtent, 0, -2 * scrollBarExtent, 0); |
|
5198 |
} else { |
|
5199 |
rect = scrollBarRect.adjusted(0, scrollBarExtent, 0, -2 * scrollBarExtent); |
|
5200 |
} |
|
5201 |
break; |
|
5202 |
case SC_ScrollBarSlider: |
|
5203 |
if (scrollBar->orientation == Qt::Horizontal) { |
|
5204 |
rect.setRect(sliderStart, 0, sliderLength, scrollBarRect.height()); |
|
5205 |
} else { |
|
5206 |
rect.setRect(0, sliderStart, scrollBarRect.width(), sliderLength); |
|
5207 |
} |
|
5208 |
break; |
|
5209 |
default: |
|
5210 |
break; |
|
5211 |
} |
|
5212 |
rect = visualRect(scrollBar->direction, scrollBarRect, rect); |
|
5213 |
} |
|
5214 |
break; |
|
5215 |
#endif // QT_NO_SCROLLBAR |
|
5216 |
#ifndef QT_NO_SPINBOX |
|
5217 |
case CC_SpinBox: |
|
5218 |
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
5219 |
int center = spinBox->rect.height() / 2; |
|
5220 |
switch (subControl) { |
|
5221 |
case SC_SpinBoxUp: |
|
5222 |
if (spinBox->buttonSymbols == QAbstractSpinBox::NoButtons) |
|
5223 |
return QRect(); |
|
5224 |
rect = visualRect(spinBox->direction, spinBox->rect, rect); |
|
5225 |
rect.setRect(spinBox->rect.right() - 16, spinBox->rect.top(), 17, center + 1); |
|
5226 |
rect = visualRect(spinBox->direction, spinBox->rect, rect); |
|
5227 |
break; |
|
5228 |
case SC_SpinBoxDown: |
|
5229 |
if (spinBox->buttonSymbols == QAbstractSpinBox::NoButtons) |
|
5230 |
return QRect(); |
|
5231 |
rect = visualRect(spinBox->direction, spinBox->rect, rect); |
|
5232 |
rect.setRect(spinBox->rect.right() - 16, spinBox->rect.top() + center, 17, spinBox->rect.height() - center); |
|
5233 |
rect = visualRect(spinBox->direction, spinBox->rect, rect); |
|
5234 |
break; |
|
5235 |
case SC_SpinBoxEditField: |
|
5236 |
if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) { |
|
5237 |
rect = spinBox->rect.adjusted(0, 0, -16, 0); |
|
5238 |
} else { |
|
5239 |
rect = spinBox->rect; |
|
5240 |
} |
|
5241 |
rect.adjust(blueFrameWidth, blueFrameWidth, -blueFrameWidth, -blueFrameWidth); |
|
5242 |
rect = visualRect(spinBox->direction, spinBox->rect, rect); |
|
5243 |
break; |
|
5244 |
default: |
|
5245 |
break; |
|
5246 |
} |
|
5247 |
} |
|
5248 |
break; |
|
5249 |
#endif // QT_NO_SPINBOX |
|
5250 |
#ifndef QT_NO_COMBOBOX |
|
5251 |
case CC_ComboBox: |
|
5252 |
switch (subControl) { |
|
5253 |
case SC_ComboBoxArrow: |
|
5254 |
rect = visualRect(option->direction, option->rect, rect); |
|
5255 |
rect.setRect(rect.right() - 17, rect.top() - 2, |
|
5256 |
19, rect.height() + 4); |
|
5257 |
rect = visualRect(option->direction, option->rect, rect); |
|
5258 |
break; |
|
5259 |
case SC_ComboBoxEditField: { |
|
5260 |
if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
5261 |
int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth); |
|
5262 |
rect = visualRect(option->direction, option->rect, rect); |
|
5263 |
||
5264 |
if (box->editable) { |
|
5265 |
rect = box->rect.adjusted(blueFrameWidth, blueFrameWidth, -blueFrameWidth, -blueFrameWidth); |
|
5266 |
rect.setRight(rect.right() - 16); // Overlaps the combobox button by 2 pixels |
|
5267 |
} else { |
|
5268 |
rect.setRect(option->rect.left() + frameWidth, option->rect.top() + frameWidth, |
|
5269 |
option->rect.width() - 16 - 2 * frameWidth, |
|
5270 |
option->rect.height() - 2 * frameWidth); |
|
5271 |
rect.setLeft(rect.left() + 2); |
|
5272 |
rect.setRight(rect.right() - 2); |
|
5273 |
if (box->state & (State_Sunken | State_On)) |
|
5274 |
rect.translate(1, 1); |
|
5275 |
} |
|
5276 |
rect = visualRect(option->direction, option->rect, rect); |
|
5277 |
} |
|
5278 |
break; |
|
5279 |
} |
|
5280 |
default: |
|
5281 |
break; |
|
5282 |
} |
|
5283 |
break; |
|
5284 |
#endif // QT_NO_COMBOBOX |
|
5285 |
case CC_TitleBar: |
|
5286 |
if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) { |
|
5287 |
SubControl sc = subControl; |
|
5288 |
QRect &ret = rect; |
|
5289 |
const int indent = 3; |
|
5290 |
const int controlTopMargin = 4; |
|
5291 |
const int controlBottomMargin = 3; |
|
5292 |
const int controlWidthMargin = 1; |
|
5293 |
const int controlHeight = tb->rect.height() - controlTopMargin - controlBottomMargin; |
|
5294 |
const int delta = controlHeight + controlWidthMargin; |
|
5295 |
int offset = 0; |
|
5296 |
||
5297 |
bool isMinimized = tb->titleBarState & Qt::WindowMinimized; |
|
5298 |
bool isMaximized = tb->titleBarState & Qt::WindowMaximized; |
|
5299 |
||
5300 |
switch (sc) { |
|
5301 |
case SC_TitleBarLabel: |
|
5302 |
if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) { |
|
5303 |
ret = tb->rect; |
|
5304 |
if (tb->titleBarFlags & Qt::WindowSystemMenuHint) |
|
5305 |
ret.adjust(delta, 0, -delta, 0); |
|
5306 |
if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) |
|
5307 |
ret.adjust(0, 0, -delta, 0); |
|
5308 |
if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint) |
|
5309 |
ret.adjust(0, 0, -delta, 0); |
|
5310 |
if (tb->titleBarFlags & Qt::WindowShadeButtonHint) |
|
5311 |
ret.adjust(0, 0, -delta, 0); |
|
5312 |
if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) |
|
5313 |
ret.adjust(0, 0, -delta, 0); |
|
5314 |
ret.adjusted(indent, 0, -indent, 0); |
|
5315 |
} |
|
5316 |
break; |
|
5317 |
case SC_TitleBarContextHelpButton: |
|
5318 |
if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) |
|
5319 |
offset += delta; |
|
5320 |
case SC_TitleBarMinButton: |
|
5321 |
if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) |
|
5322 |
offset += delta; |
|
5323 |
else if (sc == SC_TitleBarMinButton) |
|
5324 |
break; |
|
5325 |
case SC_TitleBarNormalButton: |
|
5326 |
if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) |
|
5327 |
offset += delta; |
|
5328 |
else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) |
|
5329 |
offset += delta; |
|
5330 |
else if (sc == SC_TitleBarNormalButton) |
|
5331 |
break; |
|
5332 |
case SC_TitleBarMaxButton: |
|
5333 |
if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) |
|
5334 |
offset += delta; |
|
5335 |
else if (sc == SC_TitleBarMaxButton) |
|
5336 |
break; |
|
5337 |
case SC_TitleBarShadeButton: |
|
5338 |
if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) |
|
5339 |
offset += delta; |
|
5340 |
else if (sc == SC_TitleBarShadeButton) |
|
5341 |
break; |
|
5342 |
case SC_TitleBarUnshadeButton: |
|
5343 |
if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) |
|
5344 |
offset += delta; |
|
5345 |
else if (sc == SC_TitleBarUnshadeButton) |
|
5346 |
break; |
|
5347 |
case SC_TitleBarCloseButton: |
|
5348 |
if (tb->titleBarFlags & Qt::WindowSystemMenuHint) |
|
5349 |
offset += delta; |
|
5350 |
else if (sc == SC_TitleBarCloseButton) |
|
5351 |
break; |
|
5352 |
ret.setRect(tb->rect.right() - indent - offset, tb->rect.top() + controlTopMargin, |
|
5353 |
controlHeight, controlHeight); |
|
5354 |
break; |
|
5355 |
case SC_TitleBarSysMenu: |
|
5356 |
if (tb->titleBarFlags & Qt::WindowSystemMenuHint) { |
|
5357 |
ret.setRect(tb->rect.left() + controlWidthMargin + indent, tb->rect.top() + controlTopMargin, |
|
5358 |
controlHeight, controlHeight); |
|
5359 |
} |
|
5360 |
break; |
|
5361 |
default: |
|
5362 |
break; |
|
5363 |
} |
|
5364 |
ret = visualRect(tb->direction, tb->rect, ret); |
|
5365 |
} |
|
5366 |
break; |
|
5367 |
default: |
|
5368 |
break; |
|
5369 |
} |
|
5370 |
||
5371 |
return rect; |
|
5372 |
} |
|
5373 |
||
5374 |
/*! |
|
5375 |
\reimp |
|
5376 |
*/ |
|
5377 |
int QPlastiqueStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, |
|
5378 |
QStyleHintReturn *returnData) const |
|
5379 |
{ |
|
5380 |
int ret = 0; |
|
5381 |
switch (hint) { |
|
5382 |
case SH_WindowFrame_Mask: |
|
5383 |
ret = 1; |
|
5384 |
if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask *>(returnData)) { |
|
5385 |
mask->region = option->rect; |
|
5386 |
mask->region -= QRect(option->rect.left(), option->rect.top(), 2, 1); |
|
5387 |
mask->region -= QRect(option->rect.right() - 1, option->rect.top(), 2, 1); |
|
5388 |
mask->region -= QRect(option->rect.left(), option->rect.top() + 1, 1, 1); |
|
5389 |
mask->region -= QRect(option->rect.right(), option->rect.top() + 1, 1, 1); |
|
5390 |
||
5391 |
const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option); |
|
5392 |
if (titleBar && (titleBar->titleBarState & Qt::WindowMinimized)) { |
|
5393 |
mask->region -= QRect(option->rect.left(), option->rect.bottom(), 2, 1); |
|
5394 |
mask->region -= QRect(option->rect.right() - 1, option->rect.bottom(), 2, 1); |
|
5395 |
mask->region -= QRect(option->rect.left(), option->rect.bottom() - 1, 1, 1); |
|
5396 |
mask->region -= QRect(option->rect.right(), option->rect.bottom() - 1, 1, 1); |
|
5397 |
} else { |
|
5398 |
mask->region -= QRect(option->rect.bottomLeft(), QSize(1, 1)); |
|
5399 |
mask->region -= QRect(option->rect.bottomRight(), QSize(1, 1)); |
|
5400 |
} |
|
5401 |
} |
|
5402 |
break; |
|
5403 |
case SH_TitleBar_NoBorder: |
|
5404 |
ret = 1; |
|
5405 |
break; |
|
5406 |
case SH_TitleBar_AutoRaise: |
|
5407 |
ret = 1; |
|
5408 |
break; |
|
5409 |
case SH_ItemView_ShowDecorationSelected: |
|
5410 |
ret = true; |
|
5411 |
break; |
|
5412 |
case SH_ToolBox_SelectedPageTitleBold: |
|
5413 |
case SH_ScrollBar_MiddleClickAbsolutePosition: |
|
5414 |
ret = true; |
|
5415 |
break; |
|
5416 |
case SH_MainWindow_SpaceBelowMenuBar: |
|
5417 |
ret = 0; |
|
5418 |
break; |
|
5419 |
case SH_FormLayoutWrapPolicy: |
|
5420 |
ret = QFormLayout::DontWrapRows; |
|
5421 |
break; |
|
5422 |
case SH_FormLayoutFieldGrowthPolicy: |
|
5423 |
ret = QFormLayout::ExpandingFieldsGrow; |
|
5424 |
break; |
|
5425 |
case SH_FormLayoutFormAlignment: |
|
5426 |
ret = Qt::AlignLeft | Qt::AlignTop; |
|
5427 |
break; |
|
5428 |
case SH_FormLayoutLabelAlignment: |
|
5429 |
ret = Qt::AlignRight; |
|
5430 |
break; |
|
5431 |
case SH_MessageBox_TextInteractionFlags: |
|
5432 |
ret = Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse; |
|
5433 |
break; |
|
5434 |
case SH_LineEdit_PasswordCharacter: |
|
5435 |
ret = QCommonStyle::styleHint(hint, option, widget, returnData); |
|
5436 |
break; |
|
5437 |
case SH_ItemView_ArrowKeysNavigateIntoChildren: |
|
5438 |
ret = true; |
|
5439 |
break; |
|
5440 |
case SH_Menu_SubMenuPopupDelay: |
|
5441 |
ret = 96; // from Plastik |
|
5442 |
break; |
|
5443 |
#ifdef Q_WS_X11 |
|
5444 |
case SH_DialogButtonBox_ButtonsHaveIcons: |
|
5445 |
ret = true; |
|
5446 |
break; |
|
5447 |
#endif |
|
5448 |
#ifndef Q_OS_WIN |
|
5449 |
case SH_Menu_AllowActiveAndDisabled: |
|
5450 |
ret = false; |
|
5451 |
break; |
|
5452 |
#endif |
|
5453 |
default: |
|
5454 |
ret = QWindowsStyle::styleHint(hint, option, widget, returnData); |
|
5455 |
break; |
|
5456 |
} |
|
5457 |
return ret; |
|
5458 |
} |
|
5459 |
||
5460 |
/*! |
|
5461 |
\reimp |
|
5462 |
*/ |
|
5463 |
QStyle::SubControl QPlastiqueStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, |
|
5464 |
const QPoint &pos, const QWidget *widget) const |
|
5465 |
{ |
|
5466 |
SubControl ret = SC_None; |
|
5467 |
switch (control) { |
|
5468 |
#ifndef QT_NO_SCROLLBAR |
|
5469 |
case CC_ScrollBar: |
|
5470 |
if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
5471 |
QRect slider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); |
|
5472 |
if (slider.contains(pos)) { |
|
5473 |
ret = SC_ScrollBarSlider; |
|
5474 |
break; |
|
5475 |
} |
|
5476 |
||
5477 |
QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); |
|
5478 |
if (scrollBarAddLine.contains(pos)) { |
|
5479 |
ret = SC_ScrollBarAddLine; |
|
5480 |
break; |
|
5481 |
} |
|
5482 |
||
5483 |
QRect scrollBarSubPage = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubPage, widget); |
|
5484 |
if (scrollBarSubPage.contains(pos)) { |
|
5485 |
ret = SC_ScrollBarSubPage; |
|
5486 |
break; |
|
5487 |
} |
|
5488 |
||
5489 |
QRect scrollBarAddPage = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddPage, widget); |
|
5490 |
if (scrollBarAddPage.contains(pos)) { |
|
5491 |
ret = SC_ScrollBarAddPage; |
|
5492 |
break; |
|
5493 |
} |
|
5494 |
||
5495 |
QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); |
|
5496 |
if (scrollBarSubLine.contains(pos)) { |
|
5497 |
ret = SC_ScrollBarSubLine; |
|
5498 |
break; |
|
5499 |
} |
|
5500 |
} |
|
5501 |
break; |
|
5502 |
#endif // QT_NO_SCROLLBAR |
|
5503 |
default: |
|
5504 |
break; |
|
5505 |
} |
|
5506 |
||
5507 |
return ret != SC_None ? ret : QWindowsStyle::hitTestComplexControl(control, option, pos, widget); |
|
5508 |
} |
|
5509 |
||
5510 |
/*! |
|
5511 |
\reimp |
|
5512 |
*/ |
|
5513 |
int QPlastiqueStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const |
|
5514 |
{ |
|
5515 |
int ret = -1; |
|
5516 |
switch (metric) { |
|
5517 |
case PM_MenuVMargin: |
|
5518 |
case PM_MenuHMargin: |
|
5519 |
ret = 0; |
|
5520 |
break; |
|
5521 |
case PM_ButtonShiftHorizontal: |
|
5522 |
case PM_ButtonShiftVertical: |
|
5523 |
ret = 1; |
|
5524 |
break; |
|
5525 |
case PM_ButtonDefaultIndicator: |
|
5526 |
ret = 0; |
|
5527 |
break; |
|
5528 |
#ifndef QT_NO_SLIDER |
|
5529 |
case PM_SliderThickness: |
|
5530 |
ret = 15; |
|
5531 |
break; |
|
5532 |
case PM_SliderLength: |
|
5533 |
case PM_SliderControlThickness: |
|
5534 |
ret = 11; |
|
5535 |
break; |
|
5536 |
case PM_SliderTickmarkOffset: |
|
5537 |
ret = 5; |
|
5538 |
break; |
|
5539 |
case PM_SliderSpaceAvailable: |
|
5540 |
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
5541 |
int size = 15; |
|
5542 |
if (slider->tickPosition & QSlider::TicksBelow) |
|
5543 |
++size; |
|
5544 |
if (slider->tickPosition & QSlider::TicksAbove) |
|
5545 |
++size; |
|
5546 |
ret = size; |
|
5547 |
break; |
|
5548 |
} |
|
5549 |
#endif // QT_NO_SLIDER |
|
5550 |
case PM_ScrollBarExtent: |
|
5551 |
ret = 16; |
|
5552 |
break; |
|
5553 |
case PM_ScrollBarSliderMin: |
|
5554 |
ret = 26; |
|
5555 |
break; |
|
5556 |
case PM_ProgressBarChunkWidth: |
|
5557 |
ret = 1; |
|
5558 |
break; |
|
5559 |
case PM_MenuBarItemSpacing: |
|
5560 |
ret = 3; |
|
5561 |
break; |
|
5562 |
case PM_MenuBarVMargin: |
|
5563 |
ret = 2; |
|
5564 |
break; |
|
5565 |
case PM_MenuBarHMargin: |
|
5566 |
ret = 0; |
|
5567 |
break; |
|
5568 |
case PM_MenuBarPanelWidth: |
|
5569 |
ret = 1; |
|
5570 |
break; |
|
5571 |
case PM_ToolBarHandleExtent: |
|
5572 |
ret = 9; |
|
5573 |
break; |
|
5574 |
case PM_ToolBarSeparatorExtent: |
|
5575 |
ret = 2; |
|
5576 |
break; |
|
5577 |
case PM_ToolBarItemSpacing: |
|
5578 |
ret = 1; |
|
5579 |
break; |
|
5580 |
case PM_ToolBarItemMargin: |
|
5581 |
ret = 1; |
|
5582 |
break; |
|
5583 |
case PM_ToolBarFrameWidth: |
|
5584 |
ret = 2; |
|
5585 |
break; |
|
5586 |
case PM_SplitterWidth: |
|
5587 |
ret = 6; |
|
5588 |
break; |
|
5589 |
case PM_DockWidgetSeparatorExtent: |
|
5590 |
ret = 6; |
|
5591 |
break; |
|
5592 |
case PM_DockWidgetHandleExtent: |
|
5593 |
ret = 20; |
|
5594 |
break; |
|
5595 |
case PM_DefaultFrameWidth: |
|
5596 |
#ifndef QT_NO_MENU |
|
5597 |
if (qobject_cast<const QMenu *>(widget)) { |
|
5598 |
ret = 1; |
|
5599 |
break; |
|
5600 |
} |
|
5601 |
#endif |
|
5602 |
ret = 2; |
|
5603 |
break; |
|
5604 |
case PM_MdiSubWindowFrameWidth: |
|
5605 |
ret = 4; |
|
5606 |
break; |
|
5607 |
case PM_TitleBarHeight: |
|
5608 |
#ifdef QT3_SUPPORT |
|
5609 |
if (widget && widget->inherits("Q3DockWindowTitleBar")) { |
|
5610 |
// Q3DockWindow has smaller title bars than QDockWidget |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5611 |
ret = qMax(widget->fontMetrics().height(), 20); |
0 | 5612 |
} else |
5613 |
#endif |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5614 |
ret = qMax(widget ? widget->fontMetrics().height() : |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5615 |
(option ? option->fontMetrics.height() : 0), 30); |
0 | 5616 |
break; |
5617 |
case PM_MaximumDragDistance: |
|
5618 |
return -1; |
|
5619 |
case PM_DockWidgetTitleMargin: |
|
5620 |
return 2; |
|
5621 |
case PM_LayoutHorizontalSpacing: |
|
5622 |
case PM_LayoutVerticalSpacing: |
|
5623 |
return -1; // rely on layoutHorizontalSpacing() |
|
5624 |
case PM_LayoutLeftMargin: |
|
5625 |
case PM_LayoutTopMargin: |
|
5626 |
case PM_LayoutRightMargin: |
|
5627 |
case PM_LayoutBottomMargin: |
|
5628 |
{ |
|
5629 |
bool isWindow = false; |
|
5630 |
if (option) { |
|
5631 |
isWindow = (option->state & State_Window); |
|
5632 |
} else if (widget) { |
|
5633 |
isWindow = widget->isWindow(); |
|
5634 |
} |
|
5635 |
||
5636 |
if (isWindow) { |
|
5637 |
ret = 11; |
|
5638 |
} else { |
|
5639 |
ret = 9; |
|
5640 |
} |
|
5641 |
} |
|
5642 |
default: |
|
5643 |
break; |
|
5644 |
} |
|
5645 |
||
5646 |
return ret != -1 ? ret : QWindowsStyle::pixelMetric(metric, option, widget); |
|
5647 |
} |
|
5648 |
||
5649 |
/*! |
|
5650 |
\reimp |
|
5651 |
*/ |
|
5652 |
QPalette QPlastiqueStyle::standardPalette() const |
|
5653 |
{ |
|
5654 |
QPalette palette; |
|
5655 |
||
5656 |
palette.setBrush(QPalette::Disabled, QPalette::WindowText, QColor(QRgb(0xff808080))); |
|
5657 |
palette.setBrush(QPalette::Disabled, QPalette::Button, QColor(QRgb(0xffdddfe4))); |
|
5658 |
palette.setBrush(QPalette::Disabled, QPalette::Light, QColor(QRgb(0xffffffff))); |
|
5659 |
palette.setBrush(QPalette::Disabled, QPalette::Midlight, QColor(QRgb(0xffffffff))); |
|
5660 |
palette.setBrush(QPalette::Disabled, QPalette::Dark, QColor(QRgb(0xff555555))); |
|
5661 |
palette.setBrush(QPalette::Disabled, QPalette::Mid, QColor(QRgb(0xffc7c7c7))); |
|
5662 |
palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(QRgb(0xffc7c7c7))); |
|
5663 |
palette.setBrush(QPalette::Disabled, QPalette::BrightText, QColor(QRgb(0xffffffff))); |
|
5664 |
palette.setBrush(QPalette::Disabled, QPalette::ButtonText, QColor(QRgb(0xff808080))); |
|
5665 |
palette.setBrush(QPalette::Disabled, QPalette::Base, QColor(QRgb(0xffefefef))); |
|
5666 |
palette.setBrush(QPalette::Disabled, QPalette::AlternateBase, palette.color(QPalette::Disabled, QPalette::Base).darker(110)); |
|
5667 |
palette.setBrush(QPalette::Disabled, QPalette::Window, QColor(QRgb(0xffefefef))); |
|
5668 |
palette.setBrush(QPalette::Disabled, QPalette::Shadow, QColor(QRgb(0xff000000))); |
|
5669 |
palette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(QRgb(0xff567594))); |
|
5670 |
palette.setBrush(QPalette::Disabled, QPalette::HighlightedText, QColor(QRgb(0xffffffff))); |
|
5671 |
palette.setBrush(QPalette::Disabled, QPalette::Link, QColor(QRgb(0xff0000ee))); |
|
5672 |
palette.setBrush(QPalette::Disabled, QPalette::LinkVisited, QColor(QRgb(0xff52188b))); |
|
5673 |
palette.setBrush(QPalette::Active, QPalette::WindowText, QColor(QRgb(0xff000000))); |
|
5674 |
palette.setBrush(QPalette::Active, QPalette::Button, QColor(QRgb(0xffdddfe4))); |
|
5675 |
palette.setBrush(QPalette::Active, QPalette::Light, QColor(QRgb(0xffffffff))); |
|
5676 |
palette.setBrush(QPalette::Active, QPalette::Midlight, QColor(QRgb(0xffffffff))); |
|
5677 |
palette.setBrush(QPalette::Active, QPalette::Dark, QColor(QRgb(0xff555555))); |
|
5678 |
palette.setBrush(QPalette::Active, QPalette::Mid, QColor(QRgb(0xffc7c7c7))); |
|
5679 |
palette.setBrush(QPalette::Active, QPalette::Text, QColor(QRgb(0xff000000))); |
|
5680 |
palette.setBrush(QPalette::Active, QPalette::BrightText, QColor(QRgb(0xffffffff))); |
|
5681 |
palette.setBrush(QPalette::Active, QPalette::ButtonText, QColor(QRgb(0xff000000))); |
|
5682 |
palette.setBrush(QPalette::Active, QPalette::Base, QColor(QRgb(0xffffffff))); |
|
5683 |
palette.setBrush(QPalette::Active, QPalette::AlternateBase, palette.color(QPalette::Active, QPalette::Base).darker(110)); |
|
5684 |
palette.setBrush(QPalette::Active, QPalette::Window, QColor(QRgb(0xffefefef))); |
|
5685 |
palette.setBrush(QPalette::Active, QPalette::Shadow, QColor(QRgb(0xff000000))); |
|
5686 |
palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(QRgb(0xff678db2))); |
|
5687 |
palette.setBrush(QPalette::Active, QPalette::HighlightedText, QColor(QRgb(0xffffffff))); |
|
5688 |
palette.setBrush(QPalette::Active, QPalette::Link, QColor(QRgb(0xff0000ee))); |
|
5689 |
palette.setBrush(QPalette::Active, QPalette::LinkVisited, QColor(QRgb(0xff52188b))); |
|
5690 |
palette.setBrush(QPalette::Inactive, QPalette::WindowText, QColor(QRgb(0xff000000))); |
|
5691 |
palette.setBrush(QPalette::Inactive, QPalette::Button, QColor(QRgb(0xffdddfe4))); |
|
5692 |
palette.setBrush(QPalette::Inactive, QPalette::Light, QColor(QRgb(0xffffffff))); |
|
5693 |
palette.setBrush(QPalette::Inactive, QPalette::Midlight, QColor(QRgb(0xffffffff))); |
|
5694 |
palette.setBrush(QPalette::Inactive, QPalette::Dark, QColor(QRgb(0xff555555))); |
|
5695 |
palette.setBrush(QPalette::Inactive, QPalette::Mid, QColor(QRgb(0xffc7c7c7))); |
|
5696 |
palette.setBrush(QPalette::Inactive, QPalette::Text, QColor(QRgb(0xff000000))); |
|
5697 |
palette.setBrush(QPalette::Inactive, QPalette::BrightText, QColor(QRgb(0xffffffff))); |
|
5698 |
palette.setBrush(QPalette::Inactive, QPalette::ButtonText, QColor(QRgb(0xff000000))); |
|
5699 |
palette.setBrush(QPalette::Inactive, QPalette::Base, QColor(QRgb(0xffffffff))); |
|
5700 |
palette.setBrush(QPalette::Inactive, QPalette::AlternateBase, palette.color(QPalette::Inactive, QPalette::Base).darker(110)); |
|
5701 |
palette.setBrush(QPalette::Inactive, QPalette::Window, QColor(QRgb(0xffefefef))); |
|
5702 |
palette.setBrush(QPalette::Inactive, QPalette::Shadow, QColor(QRgb(0xff000000))); |
|
5703 |
palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(QRgb(0xff678db2))); |
|
5704 |
palette.setBrush(QPalette::Inactive, QPalette::HighlightedText, QColor(QRgb(0xffffffff))); |
|
5705 |
palette.setBrush(QPalette::Inactive, QPalette::Link, QColor(QRgb(0xff0000ee))); |
|
5706 |
palette.setBrush(QPalette::Inactive, QPalette::LinkVisited, QColor(QRgb(0xff52188b))); |
|
5707 |
return palette; |
|
5708 |
} |
|
5709 |
||
5710 |
/*! |
|
5711 |
\reimp |
|
5712 |
*/ |
|
5713 |
void QPlastiqueStyle::polish(QWidget *widget) |
|
5714 |
{ |
|
5715 |
if (qobject_cast<QPushButton *>(widget) |
|
5716 |
#ifndef QT_NO_COMBOBOX |
|
5717 |
|| qobject_cast<QComboBox *>(widget) |
|
5718 |
#endif |
|
5719 |
#ifndef QT_NO_SPINBOX |
|
5720 |
|| qobject_cast<QAbstractSpinBox *>(widget) |
|
5721 |
#endif |
|
5722 |
|| qobject_cast<QCheckBox *>(widget) |
|
5723 |
#ifndef QT_NO_GROUPBOX |
|
5724 |
|| qobject_cast<QGroupBox *>(widget) |
|
5725 |
#endif |
|
5726 |
|| qobject_cast<QRadioButton *>(widget) |
|
5727 |
#ifndef QT_NO_SPLITTER |
|
5728 |
|| qobject_cast<QSplitterHandle *>(widget) |
|
5729 |
#endif |
|
5730 |
#ifndef QT_NO_TABBAR |
|
5731 |
|| qobject_cast<QTabBar *>(widget) |
|
5732 |
#endif |
|
5733 |
) { |
|
5734 |
widget->setAttribute(Qt::WA_Hover); |
|
5735 |
} |
|
5736 |
||
5737 |
if (widget->inherits("QWorkspaceTitleBar") |
|
5738 |
|| widget->inherits("QDockSeparator") |
|
5739 |
|| widget->inherits("QDockWidgetSeparator") |
|
5740 |
|| widget->inherits("Q3DockWindowResizeHandle")) { |
|
5741 |
widget->setAttribute(Qt::WA_Hover); |
|
5742 |
} |
|
5743 |
||
5744 |
if (false // to simplify the #ifdefs |
|
5745 |
#ifndef QT_NO_MENUBAR |
|
5746 |
|| qobject_cast<QMenuBar *>(widget) |
|
5747 |
#endif |
|
5748 |
#ifdef QT3_SUPPORT |
|
5749 |
|| widget->inherits("Q3ToolBar") |
|
5750 |
#endif |
|
5751 |
#ifndef QT_NO_TOOLBAR |
|
5752 |
|| qobject_cast<QToolBar *>(widget) |
|
5753 |
|| (widget && qobject_cast<QToolBar *>(widget->parent())) |
|
5754 |
#endif |
|
5755 |
) { |
|
5756 |
widget->setBackgroundRole(QPalette::Window); |
|
5757 |
} |
|
5758 |
||
5759 |
#ifndef QT_NO_PROGRESSBAR |
|
5760 |
if (AnimateBusyProgressBar && qobject_cast<QProgressBar *>(widget)) |
|
5761 |
widget->installEventFilter(this); |
|
5762 |
#endif |
|
5763 |
||
5764 |
#if defined QPlastique_MaskButtons |
|
5765 |
if (qobject_cast<QPushButton *>(widget) || qobject_cast<QToolButton *>(widget)) |
|
5766 |
widget->installEventFilter(this); |
|
5767 |
#endif |
|
5768 |
} |
|
5769 |
||
5770 |
/*! |
|
5771 |
\reimp |
|
5772 |
*/ |
|
5773 |
void QPlastiqueStyle::unpolish(QWidget *widget) |
|
5774 |
{ |
|
5775 |
if (qobject_cast<QPushButton *>(widget) |
|
5776 |
#ifndef QT_NO_COMBOBOX |
|
5777 |
|| qobject_cast<QComboBox *>(widget) |
|
5778 |
#endif |
|
5779 |
#ifndef QT_NO_SPINBOX |
|
5780 |
|| qobject_cast<QAbstractSpinBox *>(widget) |
|
5781 |
#endif |
|
5782 |
|| qobject_cast<QCheckBox *>(widget) |
|
5783 |
#ifndef QT_NO_GROUPBOX |
|
5784 |
|| qobject_cast<QGroupBox *>(widget) |
|
5785 |
#endif |
|
5786 |
#ifndef QT_NO_SPLITTER |
|
5787 |
|| qobject_cast<QSplitterHandle *>(widget) |
|
5788 |
#endif |
|
5789 |
#ifndef QT_NO_TABBAR |
|
5790 |
|| qobject_cast<QTabBar *>(widget) |
|
5791 |
#endif |
|
5792 |
|| qobject_cast<QRadioButton *>(widget)) { |
|
5793 |
widget->setAttribute(Qt::WA_Hover, false); |
|
5794 |
} |
|
5795 |
||
5796 |
if (widget->inherits("QWorkspaceTitleBar") |
|
5797 |
|| widget->inherits("QDockSeparator") |
|
5798 |
|| widget->inherits("QDockWidgetSeparator") |
|
5799 |
|| widget->inherits("Q3DockWindowResizeHandle")) { |
|
5800 |
widget->setAttribute(Qt::WA_Hover, false); |
|
5801 |
} |
|
5802 |
||
5803 |
if (false // to simplify the #ifdefs |
|
5804 |
#ifndef QT_NO_MENUBAR |
|
5805 |
|| qobject_cast<QMenuBar *>(widget) |
|
5806 |
#endif |
|
5807 |
#ifndef QT_NO_TOOLBOX |
|
5808 |
|| qobject_cast<QToolBox *>(widget) |
|
5809 |
#endif |
|
5810 |
#ifdef QT3_SUPPORT |
|
5811 |
|| widget->inherits("Q3ToolBar") |
|
5812 |
#endif |
|
5813 |
#ifndef QT_NO_TOOLBAR |
|
5814 |
|| qobject_cast<QToolBar *>(widget) |
|
5815 |
|| (widget && qobject_cast<QToolBar *>(widget->parent())) |
|
5816 |
#endif |
|
5817 |
) { |
|
5818 |
widget->setBackgroundRole(QPalette::Button); |
|
5819 |
} |
|
5820 |
||
5821 |
#ifndef QT_NO_PROGRESSBAR |
|
5822 |
if (AnimateBusyProgressBar && qobject_cast<QProgressBar *>(widget)) { |
|
5823 |
Q_D(QPlastiqueStyle); |
|
5824 |
widget->removeEventFilter(this); |
|
5825 |
d->bars.removeAll(static_cast<QProgressBar*>(widget)); |
|
5826 |
} |
|
5827 |
#endif |
|
5828 |
||
5829 |
#if defined QPlastique_MaskButtons |
|
5830 |
if (qobject_cast<QPushButton *>(widget) || qobject_cast<QToolButton *>(widget)) |
|
5831 |
widget->removeEventFilter(this); |
|
5832 |
#endif |
|
5833 |
} |
|
5834 |
||
5835 |
/*! |
|
5836 |
\reimp |
|
5837 |
*/ |
|
5838 |
void QPlastiqueStyle::polish(QApplication *app) |
|
5839 |
{ |
|
5840 |
QWindowsStyle::polish(app); |
|
5841 |
} |
|
5842 |
||
5843 |
/*! |
|
5844 |
\reimp |
|
5845 |
*/ |
|
5846 |
void QPlastiqueStyle::polish(QPalette &pal) |
|
5847 |
{ |
|
5848 |
QWindowsStyle::polish(pal); |
|
5849 |
pal.setBrush(QPalette::AlternateBase, pal.base().color().darker(110)); |
|
5850 |
#ifdef Q_WS_MAC |
|
5851 |
pal.setBrush(QPalette::Shadow, Qt::black); |
|
5852 |
#endif |
|
5853 |
} |
|
5854 |
||
5855 |
/*! |
|
5856 |
\reimp |
|
5857 |
*/ |
|
5858 |
void QPlastiqueStyle::unpolish(QApplication *app) |
|
5859 |
{ |
|
5860 |
QWindowsStyle::unpolish(app); |
|
5861 |
} |
|
5862 |
||
5863 |
/*! |
|
5864 |
\internal |
|
5865 |
*/ |
|
5866 |
QIcon QPlastiqueStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, |
|
5867 |
const QWidget *widget) const |
|
5868 |
{ |
|
5869 |
return QWindowsStyle::standardIconImplementation(standardIcon, option, widget); |
|
5870 |
} |
|
5871 |
||
5872 |
/*! |
|
5873 |
\reimp |
|
5874 |
*/ |
|
5875 |
QPixmap QPlastiqueStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, |
|
5876 |
const QWidget *widget) const |
|
5877 |
{ |
|
5878 |
return QWindowsStyle::standardPixmap(standardPixmap, opt, widget); |
|
5879 |
} |
|
5880 |
||
5881 |
// this works as long as we have at most 16 different control types |
|
5882 |
#define CT1(c) CT2(c, c) |
|
5883 |
#define CT2(c1, c2) (((uint)c1 << 16) | (uint)c2) |
|
5884 |
||
5885 |
/*! |
|
5886 |
\internal |
|
5887 |
*/ |
|
5888 |
int QPlastiqueStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, |
|
5889 |
QSizePolicy::ControlType control2, |
|
5890 |
Qt::Orientation orientation, |
|
5891 |
const QStyleOption * /* option */, |
|
5892 |
const QWidget * /* widget */) const |
|
5893 |
{ |
|
5894 |
const int ButtonMask = QSizePolicy::ButtonBox | QSizePolicy::PushButton; |
|
5895 |
||
5896 |
if (control2 == QSizePolicy::ButtonBox) |
|
5897 |
return 11; |
|
5898 |
||
5899 |
if ((control1 | control2) & ButtonMask) |
|
5900 |
return (orientation == Qt::Horizontal) ? 10 : 9; |
|
5901 |
||
5902 |
switch (CT2(control1, control2)) { |
|
5903 |
case CT1(QSizePolicy::Label): |
|
5904 |
case CT2(QSizePolicy::Label, QSizePolicy::DefaultType): |
|
5905 |
case CT2(QSizePolicy::Label, QSizePolicy::CheckBox): |
|
5906 |
case CT2(QSizePolicy::Label, QSizePolicy::ComboBox): |
|
5907 |
case CT2(QSizePolicy::Label, QSizePolicy::LineEdit): |
|
5908 |
case CT2(QSizePolicy::Label, QSizePolicy::RadioButton): |
|
5909 |
case CT2(QSizePolicy::Label, QSizePolicy::Slider): |
|
5910 |
case CT2(QSizePolicy::Label, QSizePolicy::SpinBox): |
|
5911 |
case CT2(QSizePolicy::Label, QSizePolicy::ToolButton): |
|
5912 |
return 5; |
|
5913 |
case CT2(QSizePolicy::CheckBox, QSizePolicy::RadioButton): |
|
5914 |
case CT2(QSizePolicy::RadioButton, QSizePolicy::CheckBox): |
|
5915 |
case CT1(QSizePolicy::CheckBox): |
|
5916 |
if (orientation == Qt::Vertical) |
|
5917 |
return 2; |
|
5918 |
case CT1(QSizePolicy::RadioButton): |
|
5919 |
if (orientation == Qt::Vertical) |
|
5920 |
return 1; |
|
5921 |
} |
|
5922 |
||
5923 |
if (orientation == Qt::Horizontal |
|
5924 |
&& (control2 & (QSizePolicy::CheckBox | QSizePolicy::RadioButton))) |
|
5925 |
return 8; |
|
5926 |
||
5927 |
if ((control1 | control2) & (QSizePolicy::Frame |
|
5928 |
| QSizePolicy::GroupBox |
|
5929 |
| QSizePolicy::TabWidget)) { |
|
5930 |
return 11; |
|
5931 |
} |
|
5932 |
||
5933 |
if ((control1 | control2) & (QSizePolicy::Line | QSizePolicy::Slider |
|
5934 |
| QSizePolicy::LineEdit | QSizePolicy::ComboBox |
|
5935 |
| QSizePolicy::SpinBox)) |
|
5936 |
return 7; |
|
5937 |
||
5938 |
return 6; |
|
5939 |
} |
|
5940 |
||
5941 |
/*! |
|
5942 |
\reimp |
|
5943 |
*/ |
|
5944 |
bool QPlastiqueStyle::eventFilter(QObject *watched, QEvent *event) |
|
5945 |
{ |
|
5946 |
#ifndef QT_NO_PROGRESSBAR |
|
5947 |
Q_D(QPlastiqueStyle); |
|
5948 |
||
5949 |
switch (event->type()) { |
|
5950 |
case QEvent::Show: |
|
5951 |
if (QProgressBar *bar = qobject_cast<QProgressBar *>(watched)) { |
|
5952 |
d->bars.append(bar); |
|
5953 |
if (d->bars.size() == 1) { |
|
5954 |
Q_ASSERT(ProgressBarFps > 0); |
|
5955 |
d->timer.start(); |
|
5956 |
d->progressBarAnimateTimer = startTimer(1000 / ProgressBarFps); |
|
5957 |
} |
|
5958 |
} |
|
5959 |
break; |
|
5960 |
case QEvent::Destroy: |
|
5961 |
case QEvent::Hide: |
|
5962 |
if(!d->bars.isEmpty()) { |
|
5963 |
d->bars.removeAll(reinterpret_cast<QProgressBar*>(watched)); |
|
5964 |
if (d->bars.isEmpty()) { |
|
5965 |
killTimer(d->progressBarAnimateTimer); |
|
5966 |
d->progressBarAnimateTimer = 0; |
|
5967 |
} |
|
5968 |
} |
|
5969 |
break; |
|
5970 |
#if defined QPlastique_MaskButtons |
|
5971 |
case QEvent::Resize: |
|
5972 |
if (qobject_cast<QPushButton *>(watched) || qobject_cast<QToolButton *>(watched)) { |
|
5973 |
QWidget *widget = qobject_cast<QWidget *>(watched); |
|
5974 |
QRect rect = widget->rect(); |
|
5975 |
QRegion region(rect); |
|
5976 |
region -= QRect(rect.left(), rect.top(), 2, 1); |
|
5977 |
region -= QRect(rect.left(), rect.top() + 1, 1, 1); |
|
5978 |
region -= QRect(rect.left(), rect.bottom(), 2, 1); |
|
5979 |
region -= QRect(rect.left(), rect.bottom() - 1, 1, 1); |
|
5980 |
region -= QRect(rect.right() - 1, rect.top(), 2, 1); |
|
5981 |
region -= QRect(rect.right(), rect.top() + 1, 1, 1); |
|
5982 |
region -= QRect(rect.right() - 1, rect.bottom(), 2, 1); |
|
5983 |
region -= QRect(rect.right(), rect.bottom() - 1, 1, 1); |
|
5984 |
widget->setMask(region); |
|
5985 |
} |
|
5986 |
break; |
|
5987 |
#endif |
|
5988 |
default: |
|
5989 |
break; |
|
5990 |
} |
|
5991 |
#endif // QT_NO_PROGRESSBAR |
|
5992 |
||
5993 |
return QWindowsStyle::eventFilter(watched, event); |
|
5994 |
} |
|
5995 |
||
5996 |
/*! |
|
5997 |
\reimp |
|
5998 |
*/ |
|
5999 |
void QPlastiqueStyle::timerEvent(QTimerEvent *event) |
|
6000 |
{ |
|
6001 |
#ifndef QT_NO_PROGRESSBAR |
|
6002 |
Q_D(QPlastiqueStyle); |
|
6003 |
||
6004 |
if (event->timerId() == d->progressBarAnimateTimer) { |
|
6005 |
Q_ASSERT(ProgressBarFps > 0); |
|
6006 |
d->animateStep = d->timer.elapsed() / (1000 / ProgressBarFps); |
|
6007 |
foreach (QProgressBar *bar, d->bars) { |
|
6008 |
if (AnimateProgressBar || (bar->minimum() == 0 && bar->maximum() == 0)) |
|
6009 |
bar->update(); |
|
6010 |
} |
|
6011 |
} |
|
6012 |
#endif // QT_NO_PROGRESSBAR |
|
6013 |
event->ignore(); |
|
6014 |
} |
|
6015 |
||
6016 |
QT_END_NAMESPACE |
|
6017 |
||
6018 |
#endif // !defined(QT_NO_STYLE_PLASTIQUE) || defined(QT_PLUGIN) |