00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "qcleanlooksstyle.h"
00025
00026 #if !defined(QT_NO_STYLE_CLEANLOOKS) || defined(QT_PLUGIN)
00027
00028 #include "qwindowsstyle_p.h"
00029 #include <qcombobox.h>
00030 #include <qpushbutton.h>
00031 #include <qpainter.h>
00032 #include <qdir.h>
00033 #include <qhash.h>
00034 #include <qstyleoption.h>
00035 #include <qapplication.h>
00036 #include <qmainwindow.h>
00037 #include <qfont.h>
00038 #include <qgroupbox.h>
00039 #include <qprocess.h>
00040 #include <qpixmapcache.h>
00041 #include <qdialogbuttonbox.h>
00042 #include <qscrollbar.h>
00043 #include <qspinbox.h>
00044 #include <qslider.h>
00045 #include <qsplitter.h>
00046 #include <qprogressbar.h>
00047
00048 static const bool UsePixmapCache = true;
00049
00050 enum Direction {
00051 TopDown,
00052 FromLeft,
00053 BottomUp,
00054 FromRight
00055 };
00056
00057
00058 static const int windowsItemFrame = 2;
00059 static const int windowsSepHeight = 6;
00060 static const int windowsItemHMargin = 3;
00061 static const int windowsItemVMargin = 8;
00062 static const int windowsArrowHMargin = 6;
00063 static const int windowsTabSpacing = 12;
00064 static const int windowsCheckMarkHMargin = 2;
00065 static const int windowsRightBorder = 15;
00066 static const int windowsCheckMarkWidth = 12;
00067
00068
00069 static const char * const dock_widget_close_xpm[] = {
00070 "11 13 7 1",
00071 " c None",
00072 ". c #D5CFCB",
00073 "+ c #8F8B88",
00074 "@ c #6C6A67",
00075 "# c #ABA6A3",
00076 "$ c #B5B0AC",
00077 "% c #A4A09D",
00078 " ",
00079 " +@@@@@@@+ ",
00080 "+# #+",
00081 "@ $@ @$ @",
00082 "@ @@@ @@@ @",
00083 "@ @@@@@ @",
00084 "@ @@@ @",
00085 "@ @@@@@ @",
00086 "@ @@@ @@@ @",
00087 "@ $@ @$ @",
00088 "+% #+",
00089 " +@@@@@@@+ ",
00090 " "};
00091
00092 static const char * const qt_cleanlooks_arrow_down_xpm[] = {
00093 "11 7 2 1",
00094 " c None",
00095 "x c #000000",
00096 " ",
00097 " x x ",
00098 " xxx xxx ",
00099 " xxxxxxx ",
00100 " xxxxx ",
00101 " xxx ",
00102 " x "};
00103
00104 static const char * const qt_cleanlooks_arrow_up_xpm[] = {
00105 "11 7 2 1",
00106 " c None",
00107 "x c #000000",
00108 " x ",
00109 " xxx ",
00110 " xxxxx ",
00111 " xxxxxxx ",
00112 " xxx xxx ",
00113 " x x ",
00114 " "};
00115
00116 static const char * const dock_widget_restore_xpm[] = {
00117 "11 13 7 1",
00118 " c None",
00119 ". c #D5CFCB",
00120 "+ c #8F8B88",
00121 "@ c #6C6A67",
00122 "# c #ABA6A3",
00123 "$ c #B5B0AC",
00124 "% c #A4A09D",
00125 " ",
00126 " +@@@@@@@+ ",
00127 "+# #+",
00128 "@ #@@@# @",
00129 "@ @ @ @",
00130 "@ #@@@# @ @",
00131 "@ @ @ @ @",
00132 "@ @ @@@ @",
00133 "@ @ @ @",
00134 "@ #@@@# @",
00135 "+% #+",
00136 " +@@@@@@@+ ",
00137 " "};
00138
00139 static const char * const workspace_minimize[] = {
00140 "11 13 7 1",
00141 " c None",
00142 ". c #D5CFCB",
00143 "+ c #8F8B88",
00144 "@ c #6C6A67",
00145 "# c #ABA6A3",
00146 "$ c #B5B0AC",
00147 "% c #A4A09D",
00148 " ",
00149 " +@@@@@@@+ ",
00150 "+# #+",
00151 "@ @",
00152 "@ @",
00153 "@ @",
00154 "@ @@@@@@@ @",
00155 "@ @@@@@@@ @",
00156 "@ @",
00157 "@ @",
00158 "+% #+",
00159 " +@@@@@@@+ ",
00160 " "};
00161
00162
00163 static const char * const qt_titlebar_context_help[] = {
00164 "27 27 5 1",
00165 " c None",
00166 ". c #0A0C12",
00167 "+ c #1B202D",
00168 "@ c #293144",
00169 "# c #3C435D",
00170 " ",
00171 " ",
00172 " ",
00173 " ",
00174 " ",
00175 " ",
00176 " ",
00177 " ",
00178 " +@##@+ ",
00179 " .@@@.+@@.. ",
00180 " .##+ +@@+. ",
00181 " .##@ @#@+. ",
00182 " .... +@+.. ",
00183 " .@+@@.. ",
00184 " +#@@+ ",
00185 " .##. ",
00186 " .++. ",
00187 " .++. ",
00188 " +##+ ",
00189 " .@@. ",
00190 " ",
00191 " ",
00192 " ",
00193 " ",
00194 " ",
00195 " ",
00196 " "};
00197
00198 static const char * const qt_cleanlooks_radiobutton[] = {
00199 "13 13 9 1",
00200 " c None",
00201 ". c #ABA094",
00202 "+ c #B7ADA0",
00203 "@ c #C4BBB2",
00204 "# c #DDD4CD",
00205 "$ c #E7E1E0",
00206 "% c #F4EFED",
00207 "& c #FFFAF9",
00208 "* c #FCFEFB",
00209 " #@...@# ",
00210 " @+@#$$#+@ ",
00211 " @+$%%***&@@ ",
00212 "#+$%**&&**&+#",
00213 "@@$&&******#@",
00214 ".#**********.",
00215 ".$&******&*&.",
00216 ".$*&******&*.",
00217 "+#********&#@",
00218 "#+*********+#",
00219 " @@*******@@ ",
00220 " @+#%*%#+@ ",
00221 " #@...+# "};
00222
00223 static const char * const qt_cleanlooks_radiobutton_checked[] = {
00224 "13 13 20 1",
00225 " c None",
00226 ". c #A8ABAE",
00227 "+ c #596066",
00228 "@ c #283138",
00229 "# c #A9ACAF",
00230 "$ c #A6A9AB",
00231 "% c #6B7378",
00232 "& c #8C9296",
00233 "* c #A2A6AA",
00234 "= c #61696F",
00235 "- c #596065",
00236 "; c #93989C",
00237 "> c #777E83",
00238 ", c #60686E",
00239 "' c #252D33",
00240 ") c #535B62",
00241 "! c #21292E",
00242 "~ c #242B31",
00243 "{ c #1F262B",
00244 "] c #41484E",
00245 " ",
00246 " ",
00247 " ",
00248 " .+@+# ",
00249 " $%&*&=# ",
00250 " -&;>,'+ ",
00251 " @*>,)!@ ",
00252 " +&,)~{+ ",
00253 " #='!{]# ",
00254 " #+@+# ",
00255 " ",
00256 " ",
00257 " "};
00258
00259
00260 static const char * const qt_scrollbar_button_arrow_left[] = {
00261 "4 7 2 1",
00262 " c None",
00263 "* c #BFBFBF",
00264 " *",
00265 " **",
00266 " ***",
00267 "****",
00268 " ***",
00269 " **",
00270 " *"};
00271
00272 static const char * const qt_scrollbar_button_arrow_right[] = {
00273 "4 7 2 1",
00274 " c None",
00275 "* c #BFBFBF",
00276 "* ",
00277 "** ",
00278 "*** ",
00279 "****",
00280 "*** ",
00281 "** ",
00282 "* "};
00283
00284 static const char * const qt_scrollbar_button_arrow_up[] = {
00285 "7 4 2 1",
00286 " c None",
00287 "* c #BFBFBF",
00288 " * ",
00289 " *** ",
00290 " ***** ",
00291 "*******"};
00292
00293 static const char * const qt_scrollbar_button_arrow_down[] = {
00294 "7 4 2 1",
00295 " c None",
00296 "* c #BFBFBF",
00297 "*******",
00298 " ***** ",
00299 " *** ",
00300 " * "};
00301
00302 static const char * const qt_spinbox_button_arrow_down[] = {
00303 "7 4 2 1",
00304 " c None",
00305 "* c #BFBFBF",
00306 "*******",
00307 " ***** ",
00308 " *** ",
00309 " * "};
00310
00311 static const char * const qt_spinbox_button_arrow_up[] = {
00312 "7 4 2 1",
00313 " c None",
00314 "* c #BFBFBF",
00315 " * ",
00316 " *** ",
00317 " ***** ",
00318 "*******"};
00319
00320 static const char * const qt_scrollbar_button_left[] = {
00321 "16 16 6 1",
00322 " c None",
00323 ". c #BFBFBF",
00324 "+ c #979797",
00325 "# c #FAFAFA",
00326 "< c #FAFAFA",
00327 "* c #FAFAFA",
00328 " .++++++++++++++",
00329 ".+#############+",
00330 "+# <+",
00331 "+# <+",
00332 "+# <+",
00333 "+# <+",
00334 "+# <+",
00335 "+# <+",
00336 "+# <+",
00337 "+# <+",
00338 "+# <+",
00339 "+# <+",
00340 "+# <+",
00341 "+# <+",
00342 ".+<<<<<<<<<<<<<+",
00343 " .++++++++++++++"};
00344
00345 static const char * const qt_scrollbar_button_right[] = {
00346 "16 16 6 1",
00347 " c None",
00348 ". c #BFBFBF",
00349 "+ c #979797",
00350 "# c #FAFAFA",
00351 "< c #FAFAFA",
00352 "* c #FAFAFA",
00353 "++++++++++++++. ",
00354 "+#############+.",
00355 "+# <+",
00356 "+# <+",
00357 "+# <+",
00358 "+# <+",
00359 "+# <+",
00360 "+# <+",
00361 "+# <+",
00362 "+# <+",
00363 "+# <+",
00364 "+# <+",
00365 "+# <+",
00366 "+# <+",
00367 "+<<<<<<<<<<<<<+.",
00368 "++++++++++++++. "};
00369
00370 static const char * const qt_scrollbar_button_up[] = {
00371 "16 16 6 1",
00372 " c None",
00373 ". c #BFBFBF",
00374 "+ c #979797",
00375 "# c #FAFAFA",
00376 "< c #FAFAFA",
00377 "* c #FAFAFA",
00378 " .++++++++++++. ",
00379 ".+############+.",
00380 "+# <+",
00381 "+# <+",
00382 "+# <+",
00383 "+# <+",
00384 "+# <+",
00385 "+# <+",
00386 "+# <+",
00387 "+# <+",
00388 "+# <+",
00389 "+# <+",
00390 "+# <+",
00391 "+# <+",
00392 "+<<<<<<<<<<<<<<+",
00393 "++++++++++++++++"};
00394
00395 static const char * const qt_scrollbar_button_down[] = {
00396 "16 16 6 1",
00397 " c None",
00398 ". c #BFBFBF",
00399 "+ c #979797",
00400 "# c #FAFAFA",
00401 "< c #FAFAFA",
00402 "* c #FAFAFA",
00403 "++++++++++++++++",
00404 "+##############+",
00405 "+# <+",
00406 "+# <+",
00407 "+# <+",
00408 "+# <+",
00409 "+# <+",
00410 "+# <+",
00411 "+# <+",
00412 "+# <+",
00413 "+# <+",
00414 "+# <+",
00415 "+# <+",
00416 "+# <+",
00417 ".+<<<<<<<<<<<<+.",
00418 " .++++++++++++. "};
00419
00420 static const char * const qt_cleanlooks_menuitem_checkbox_checked[] = {
00421 "8 7 6 1",
00422 " g None",
00423 ". g #959595",
00424 "+ g #676767",
00425 "@ g #454545",
00426 "# g #1D1D1D",
00427 "0 g #101010",
00428 " ..",
00429 " .+ ",
00430 " .+ ",
00431 "0 .@ ",
00432 "@#++. ",
00433 " @# ",
00434 " . "};
00435
00436 static const char * const qt_cleanlooks_checkbox_checked[] = {
00437 "13 13 8 1",
00438 " c None",
00439 "% c #ABB0B2",
00440 ". c #373E44",
00441 "+ c #444B52",
00442 "@ c #575E65",
00443 "# c #727981",
00444 "$ c #999EA0",
00445 "& c #BCC1C3",
00446 " ",
00447 " ",
00448 " %% ",
00449 " %# ",
00450 " %+ ",
00451 " %.% &.% ",
00452 " &..&@+ ",
00453 " %...$ ",
00454 " %.. ",
00455 " +% ",
00456 " & ",
00457 " ",
00458 " "};
00459
00460
00461 class QCleanlooksStylePrivate : public QWindowsStylePrivate
00462 {
00463 Q_DECLARE_PUBLIC(QCleanlooksStyle)
00464 public:
00465 QCleanlooksStylePrivate()
00466 : QWindowsStylePrivate()
00467 { }
00468 ~QCleanlooksStylePrivate()
00469 { }
00470 void lookupIconTheme() const;
00471 };
00472
00473 static void qt_cleanlooks_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart,
00474 const QColor &gradientStop, Direction direction = TopDown, QBrush bgBrush = QBrush())
00475 {
00476 int x = rect.center().x();
00477 int y = rect.center().y();
00478 QLinearGradient *gradient;
00479 switch(direction) {
00480 case FromLeft:
00481 gradient = new QLinearGradient(rect.left(), y, rect.right(), y);
00482 break;
00483 case FromRight:
00484 gradient = new QLinearGradient(rect.right(), y, rect.left(), y);
00485 break;
00486 case BottomUp:
00487 gradient = new QLinearGradient(x, rect.bottom(), x, rect.top());
00488 case TopDown:
00489 default:
00490 gradient = new QLinearGradient(x, rect.top(), x, rect.bottom());
00491 break;
00492 }
00493 if (bgBrush.gradient())
00494 gradient->setStops(bgBrush.gradient()->stops());
00495 else {
00496 gradient->setColorAt(0, gradientStart);
00497 gradient->setColorAt(1, gradientStop);
00498 }
00499 painter->fillRect(rect, *gradient);
00500 delete gradient;
00501 }
00502
00503 static QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
00504 {
00505 QString tmp;
00506 const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option);
00507 tmp.sprintf("%s-%d-%d-%d-%dx%d", key.toLatin1().constData(), uint(option->state),
00508 complexOption ? uint(complexOption->activeSubControls) : uint(0),
00509 option->palette.serialNumber(), size.width(), size.height());
00510 #ifndef QT_NO_SPINBOX
00511 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
00512 tmp.append(QLatin1Char('-'));
00513 tmp.append(QString::number(spinBox->buttonSymbols));
00514 tmp.append(QLatin1Char('-'));
00515 tmp.append(QString::number(spinBox->stepEnabled));
00516 tmp.append(QLatin1Char('-'));
00517 tmp.append(QLatin1Char(spinBox->frame ? '1' : '0'));
00518 }
00519 #endif // QT_NO_SPINBOX
00520 return tmp;
00521 }
00522
00523 static void qt_cleanlooks_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken)
00524 {
00525 QColor dark;
00526 dark.setHsv(option->palette.button().color().hue(),
00527 qMin(255, (int)(option->palette.button().color().saturation()*1.9)),
00528 qMin(255, (int)(option->palette.button().color().value()*0.7)));
00529
00530 QColor highlight = option->palette.highlight().color();
00531
00532 bool active = (option->titleBarState & QStyle::State_Active);
00533 QColor titleBarHighlight(active ? highlight.light(106): option->palette.background().color().light(106));
00534
00535 if (hover)
00536 painter->fillRect(tmp.adjusted(1, 1, -1, -1), QColor(255, 255, 255, 20));
00537 else if (sunken)
00538 painter->fillRect(tmp.adjusted(1, 1, -1, -1), option->palette.highlight().color().dark(130));
00539
00540 QColor mdiButtonGradientStartColor;
00541 QColor mdiButtonGradientStopColor;
00542
00543 mdiButtonGradientStartColor = QColor(active ? highlight.light(115): option->palette.background().color().light(115));
00544 mdiButtonGradientStopColor = QColor(active ? highlight.dark(110) : option->palette.background().color());
00545
00546 if (sunken)
00547 titleBarHighlight = highlight.dark(130);
00548
00549 QLinearGradient gradient(tmp.center().x(), tmp.top(), tmp.center().x(), tmp.bottom());
00550 gradient.setColorAt(0, mdiButtonGradientStartColor);
00551 gradient.setColorAt(1, mdiButtonGradientStopColor);
00552 QColor mdiButtonBorderColor(active ? option->palette.highlight().color().dark(180): dark.dark(110));
00553
00554 painter->setPen(QPen(mdiButtonBorderColor, 1));
00555 painter->drawLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top());
00556 painter->drawLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom());
00557 painter->drawLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2);
00558 painter->drawLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2);
00559 painter->drawPoint(tmp.left() + 1, tmp.top() + 1);
00560 painter->drawPoint(tmp.right() - 1, tmp.top() + 1);
00561 painter->drawPoint(tmp.left() + 1, tmp.bottom() - 1);
00562 painter->drawPoint(tmp.right() - 1, tmp.bottom() - 1);
00563
00564 painter->setPen(titleBarHighlight);
00565 painter->drawLine(tmp.left() + 2, tmp.top() + 1, tmp.right() - 2, tmp.top() + 1);
00566 painter->drawLine(tmp.left() + 1, tmp.top() + 2, tmp.left() + 1, tmp.bottom() - 2);
00567
00568 painter->setPen(QPen(gradient, 1));
00569 painter->drawLine(tmp.right() + 1, tmp.top() + 2, tmp.right() + 1, tmp.bottom() - 2);
00570 painter->drawPoint(tmp.right() , tmp.top() + 1);
00571
00572 painter->drawLine(tmp.left() + 2, tmp.bottom() + 1, tmp.right() - 2, tmp.bottom() + 1);
00573 painter->drawPoint(tmp.left() + 1, tmp.bottom());
00574 painter->drawPoint(tmp.right() - 1, tmp.bottom());
00575 painter->drawPoint(tmp.right() , tmp.bottom() - 1);
00576 }
00577
00595 QCleanlooksStyle::QCleanlooksStyle() : QWindowsStyle(*new QCleanlooksStylePrivate)
00596 {
00597 setObjectName(QLatin1String("CleanLooks"));
00598 }
00599
00603 QCleanlooksStyle::~QCleanlooksStyle()
00604 {
00605 }
00606
00625 void QCleanlooksStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
00626 bool enabled, const QString& text, QPalette::ColorRole textRole) const
00627 {
00628 if (text.isEmpty())
00629 return;
00630
00631 painter->save();
00632 QPen savedPen;
00633 if (textRole != QPalette::NoRole) {
00634 painter->setPen(pal.color(textRole));
00635 }
00636 if (!enabled) {
00637 QPen pen = painter->pen();
00638 painter->setPen(pen);
00639 }
00640 painter->drawText(rect, alignment, text);
00641 painter->restore();
00642 }
00643
00644 static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50)
00645 {
00646 const int maxFactor = 100;
00647 QColor tmp = colorA;
00648 tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor);
00649 tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor);
00650 tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor);
00651 return tmp;
00652 }
00653
00657 void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem,
00658 const QStyleOption *option,
00659 QPainter *painter, const QWidget *widget) const
00660 {
00661 Q_ASSERT(option);
00662 QRect rect = option->rect;
00663 int state = option->state;
00664 QColor button = option->palette.button().color();
00665 QColor buttonShadow = option->palette.button().color().dark(110);
00666 QColor buttonShadowAlpha = buttonShadow;
00667 buttonShadowAlpha.setAlpha(128);
00668 QColor darkOutline;
00669 QColor dark;
00670 darkOutline.setHsv(button.hue(),
00671 qMin(255, (int)(button.saturation()*3.0)),
00672 qMin(255, (int)(button.value()*0.6)));
00673 dark.setHsv(button.hue(),
00674 qMin(255, (int)(button.saturation()*1.9)),
00675 qMin(255, (int)(button.value()*0.7)));
00676 QColor tabFrameColor = mergedColors(option->palette.background().color(),
00677 dark.light(135), 60);
00678
00679 switch(elem) {
00680 #ifndef QT_NO_TABBAR
00681 case PE_FrameTabBarBase:
00682 if (const QStyleOptionTabBarBase *tbb
00683 = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) {
00684 QRegion region(tbb->rect);
00685 painter->save();
00686 painter->setPen(QPen(darkOutline.light(110), 0));
00687 switch (tbb->shape) {
00688 case QTabBar::RoundedNorth:
00689 region -= tbb->selectedTabRect;
00690 painter->setClipRegion(region);
00691 painter->drawLine(tbb->rect.topLeft(), tbb->rect.topRight());
00692 break;
00693 case QTabBar::RoundedWest:
00694 region -= tbb->selectedTabRect;
00695 painter->setClipRegion(region);
00696 painter->drawLine(tbb->rect.left(), tbb->rect.top(), tbb->rect.left(), tbb->rect.bottom());
00697 break;
00698 case QTabBar::RoundedSouth:
00699 region -= tbb->selectedTabRect;
00700 painter->setClipRegion(region);
00701 painter->drawLine(tbb->rect.left(), tbb->rect.bottom(),
00702 tbb->rect.right(), tbb->rect.bottom());
00703 break;
00704 case QTabBar::RoundedEast:
00705 region -= tbb->selectedTabRect;
00706 painter->setClipRegion(region);
00707 painter->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight());
00708 break;
00709 case QTabBar::TriangularNorth:
00710 case QTabBar::TriangularEast:
00711 case QTabBar::TriangularWest:
00712 case QTabBar::TriangularSouth:
00713 painter->restore();
00714 QWindowsStyle::drawPrimitive(elem, option, painter, widget);
00715 return;
00716 }
00717 painter->restore();
00718 }
00719 return;
00720 #endif // QT_NO_TABBAR
00721 case PE_IndicatorViewItemCheck:
00722 {
00723 QStyleOptionButton button;
00724 button.QStyleOption::operator=(*option);
00725 button.state &= ~State_MouseOver;
00726 drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget);
00727 }
00728 return;
00729 case PE_IndicatorHeaderArrow:
00730 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
00731 QRect r = header->rect;
00732 QImage arrow;
00733 if (header->sortIndicator & QStyleOptionHeader::SortUp)
00734 arrow = QImage(qt_cleanlooks_arrow_up_xpm);
00735 else if (header->sortIndicator & QStyleOptionHeader::SortDown)
00736 arrow = QImage(qt_cleanlooks_arrow_down_xpm);
00737 if (!arrow.isNull()) {
00738 r.setSize(arrow.size());
00739 r.moveCenter(header->rect.center());
00740 arrow.setColor(1, header->palette.foreground().color().rgba());
00741 painter->drawImage(r, arrow);
00742 }
00743 }
00744 break;
00745 case PE_IndicatorButtonDropDown:
00746 drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
00747 break;
00748 case PE_IndicatorToolBarSeparator:
00749 {
00750 QRect rect = option->rect;
00751 const int margin = 6;
00752 if (option->state & State_Horizontal) {
00753 const int offset = rect.width()/2;
00754 painter->setPen(QPen(option->palette.background().color().dark(110)));
00755 painter->drawLine(rect.bottomLeft().x() + offset,
00756 rect.bottomLeft().y() - margin,
00757 rect.topLeft().x() + offset,
00758 rect.topLeft().y() + margin);
00759 painter->setPen(QPen(option->palette.background().color().light(110)));
00760 painter->drawLine(rect.bottomLeft().x() + offset + 1,
00761 rect.bottomLeft().y() - margin,
00762 rect.topLeft().x() + offset + 1,
00763 rect.topLeft().y() + margin);
00764 } else {
00765 const int offset = rect.height()/2;
00766 painter->setPen(QPen(option->palette.background().color().dark(110)));
00767 painter->drawLine(rect.topLeft().x() + margin ,
00768 rect.topLeft().y() + offset,
00769 rect.topRight().x() - margin,
00770 rect.topRight().y() + offset);
00771 painter->setPen(QPen(option->palette.background().color().light(110)));
00772 painter->drawLine(rect.topLeft().x() + margin ,
00773 rect.topLeft().y() + offset + 1,
00774 rect.topRight().x() - margin,
00775 rect.topRight().y() + offset + 1);
00776 }
00777 }
00778 break;
00779 case PE_Frame:
00780 painter->save();
00781 painter->setPen(dark.light(108));
00782 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
00783 painter->restore();
00784 break;
00785 case PE_FrameMenu:
00786 painter->save();
00787 {
00788 painter->setPen(QPen(darkOutline, 1));
00789 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
00790 QColor frameLight = option->palette.background().color().light(160);
00791 QColor frameShadow = option->palette.background().color().dark(110);
00792
00793
00794 QRect frame = option->rect.adjusted(1, 1, -1, -1);
00795 painter->setPen(frameLight);
00796 painter->drawLine(frame.topLeft(), frame.bottomLeft());
00797 painter->drawLine(frame.topLeft(), frame.topRight());
00798
00799 painter->setPen(frameShadow);
00800 painter->drawLine(frame.topRight(), frame.bottomRight());
00801 painter->drawLine(frame.bottomLeft(), frame.bottomRight());
00802 }
00803 painter->restore();
00804 break;
00805 case PE_FrameDockWidget:
00806
00807 painter->save();
00808 {
00809 QColor softshadow = option->palette.background().color().dark(120);
00810
00811 QRect rect= option->rect;
00812 painter->setPen(softshadow);
00813 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
00814 painter->setPen(QPen(option->palette.light(), 0));
00815 painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), QPoint(rect.left() + 1, rect.bottom() - 1));
00816 painter->setPen(QPen(option->palette.background().color().dark(120), 0));
00817 painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1), QPoint(rect.right() - 2, rect.bottom() - 1));
00818 painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1), QPoint(rect.right() - 1, rect.bottom() - 1));
00819
00820 }
00821 painter->restore();
00822 break;
00823 case PE_PanelButtonTool:
00824 painter->save();
00825 if ((option->state & State_Enabled) || !(option->state & State_AutoRaise)) {
00826 QRect rect = option->rect;
00827 QPen oldPen = painter->pen();
00828
00829 if (widget && widget->inherits("QDockWidgetTitleButton")) {
00830 if (option->state & State_MouseOver)
00831 drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
00832 } else {
00833 drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
00834 }
00835 }
00836 painter->restore();
00837 break;
00838 case PE_IndicatorDockWidgetResizeHandle:
00839 {
00840 QStyleOption dockWidgetHandle = *option;
00841 bool horizontal = option->state & State_Horizontal;
00842 if (horizontal)
00843 dockWidgetHandle.state &= ~State_Horizontal;
00844 else
00845 dockWidgetHandle.state |= State_Horizontal;
00846 drawControl(CE_Splitter, &dockWidgetHandle, painter, widget);
00847 }
00848 break;
00849 case PE_FrameWindow:
00850 painter->save();
00851 {
00852 QRect rect= option->rect;
00853 painter->setPen(QPen(dark.dark(150), 0));
00854 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
00855 painter->setPen(QPen(option->palette.light(), 0));
00856 painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
00857 QPoint(rect.left() + 1, rect.bottom() - 1));
00858 painter->setPen(QPen(option->palette.background().color().dark(120), 0));
00859 painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1),
00860 QPoint(rect.right() - 2, rect.bottom() - 1));
00861 painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1),
00862 QPoint(rect.right() - 1, rect.bottom() - 1));
00863 }
00864 painter->restore();
00865 break;
00866 #ifndef QT_NO_LINEDIT
00867 case PE_FrameLineEdit:
00868
00869 #endif // QT_NO_LINEEDIT
00870 #ifdef QT3_SUPPORT
00871 if (widget && widget->inherits("Q3ToolBar")) {
00872 drawPrimitive(PE_Q3Separator, option, painter, widget);
00873 break;
00874 }
00875 #endif
00876 {
00877 QPen oldPen = painter->pen();
00878 if (option->state & State_Enabled) {
00879 painter->setPen(QPen(option->palette.background(), 0));
00880 painter->drawRect(rect.adjusted(0, 0, 0, 0));
00881 painter->drawRect(rect.adjusted(1, 1, -1, -1));
00882 } else {
00883 painter->fillRect(rect, option->palette.background());
00884 }
00885 QRect r = rect.adjusted(0, 1, 0, -1);
00886 painter->setPen(buttonShadowAlpha);
00887 painter->drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1));
00888 painter->drawPoint(r.right() - 1, r.top());
00889 painter->drawPoint(r.right(), r.top() + 1);
00890 painter->drawPoint(r.right() - 1, r.bottom());
00891 painter->drawPoint(r.right(), r.bottom() - 1);
00892 painter->drawPoint(r.left() + 1, r.top() );
00893 painter->drawPoint(r.left(), r.top() + 1);
00894 painter->drawPoint(r.left() + 1, r.bottom() );
00895 painter->drawPoint(r.left(), r.bottom() - 1);
00896 painter->setPen(QPen(option->palette.background().color(), 1));
00897 painter->drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1));
00898
00899 if (option->state & State_HasFocus) {
00900 QColor darkoutline = option->palette.highlight().color().dark(150);
00901 QColor innerline = mergedColors(option->palette.highlight().color(), Qt::white);
00902 painter->setPen(QPen(innerline, 0));
00903 painter->drawRect(rect.adjusted(1, 2, -2, -3));
00904 painter->setPen(QPen(darkoutline, 0));
00905 }
00906 else {
00907 QColor highlight = Qt::white;
00908 highlight.setAlpha(130);
00909 painter->setPen(option->palette.base().color().dark(120));
00910 painter->drawLine(QPoint(r.left() + 1, r.top() + 1),
00911 QPoint(r.right() - 1, r.top() + 1));
00912 painter->drawLine(QPoint(r.left() + 1, r.top() + 1),
00913 QPoint(r.left() + 1, r.bottom() - 1));
00914 painter->setPen(option->palette.base().color());
00915 painter->drawLine(QPoint(r.right() - 1, r.top() + 1),
00916 QPoint(r.right() - 1, r.bottom() - 1));
00917 painter->setPen(highlight);
00918 painter->drawLine(QPoint(r.left() + 1, r.bottom() + 1),
00919 QPoint(r.right() - 1, r.bottom() + 1));
00920 painter->drawPoint(QPoint(r.left(), r.bottom()));
00921 painter->drawPoint(QPoint(r.right(), r.bottom() ));
00922 painter->setPen(QPen(darkOutline.light(115), 1));
00923 }
00924 painter->drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
00925 painter->drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2));
00926 painter->drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right() - 2, r.bottom()));
00927 painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1));
00928 painter->drawPoint(QPoint(r.right() - 1, r.top() + 1));
00929 painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1));
00930 painter->drawPoint(QPoint(r.left() + 1, r.top() + 1));
00931 painter->drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top()));
00932 painter->setPen(oldPen);
00933 }
00934 break;
00935 case PE_IndicatorCheckBox:
00936 painter->save();
00937 if (const QStyleOptionButton *checkbox = qstyleoption_cast<const QStyleOptionButton*>(option)) {
00938 QRect checkRect;
00939 checkRect.setX(rect.left() );
00940 checkRect.setY(rect.top() );
00941 checkRect.setWidth(rect.width() - 1);
00942 checkRect.setHeight(rect.height() - 1);
00943 if (state & State_Sunken)
00944 painter->setBrush(dark.light(130));
00945 else
00946 painter->setBrush(option->palette.base());
00947 painter->setPen(QPen(dark.light(110), 0));
00948 painter->drawRect(checkRect);
00949 if (checkbox->state & (State_On | State_Sunken | State_NoChange)) {
00950 QImage image(qt_cleanlooks_checkbox_checked);
00951 painter->drawImage(rect, image);
00952 if (checkbox->state & State_NoChange) {
00953 QColor bgc = option->palette.background().color();
00954 bgc.setAlpha(127);
00955 painter->fillRect(checkRect.adjusted(1, 1, -1, -1), bgc);
00956 }
00957 }
00958 }
00959 painter->restore();
00960 break;
00961 case PE_IndicatorRadioButton:
00962 painter->save();
00963 {
00964 QRect checkRect = rect.adjusted(0, 0, 0, 0);
00965 if (state & (State_On )) {
00966 painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton));
00967 painter->drawImage(checkRect, QImage(qt_cleanlooks_radiobutton_checked));
00968 }
00969 else if (state & State_Sunken) {
00970 painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton));
00971 QColor bgc = buttonShadow;
00972 painter->setRenderHint(QPainter::Antialiasing);
00973 painter->setBrush(bgc);
00974 painter->setPen(Qt::NoPen);
00975 painter->drawEllipse(rect.adjusted(1, 1, -1, -1)); }
00976 else {
00977 painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton));
00978 }
00979 }
00980 painter->restore();
00981 break;
00982 case PE_IndicatorToolBarHandle:
00983 painter->save();
00984 if (option->state & State_Horizontal) {
00985 for (int i = rect.height()/5; i <= 4*(rect.height()/5) ; ++i) {
00986 int y = rect.topLeft().y() + i + 1;
00987 int x1 = rect.topLeft().x() + 3;
00988 int x2 = rect.topRight().x() - 2;
00989
00990 if (i % 2 == 0)
00991 painter->setPen(QPen(option->palette.light(), 0));
00992 else
00993 painter->setPen(QPen(dark.light(110), 0));
00994 painter->drawLine(x1, y, x2, y);
00995 }
00996 }
00997 else {
00998 for (int i = rect.width()/5; i <= 4*(rect.width()/5) ; ++i) {
00999 int x = rect.topLeft().x() + i + 1;
01000 int y1 = rect.topLeft().y() + 3;
01001 int y2 = rect.topLeft().y() + 5;
01002
01003 if (i % 2 == 0)
01004 painter->setPen(QPen(option->palette.light(), 0));
01005 else
01006 painter->setPen(QPen(dark.light(110), 0));
01007 painter->drawLine(x, y1, x, y2);
01008 }
01009 }
01010 painter->restore();
01011 break;
01012 case PE_FrameDefaultButton:
01013 case PE_FrameFocusRect:
01014 if (const QStyleOptionFocusRect *focusFrame = qstyleoption_cast<const QStyleOptionFocusRect *>(option)) {
01015 if (!(focusFrame->state & State_KeyboardFocusChange))
01016 return;
01017 QRect rect = focusFrame->rect;
01018 painter->save();
01019 painter->setBackgroundMode(Qt::TransparentMode);
01020 painter->setBrush(QBrush(dark.dark(120), Qt::Dense4Pattern));
01021 painter->setBrushOrigin(rect.topLeft());
01022 painter->setPen(Qt::NoPen);
01023 painter->drawRect(rect.left(), rect.top(), rect.width(), 1);
01024 painter->drawRect(rect.left(), rect.bottom(), rect.width(), 1);
01025 painter->drawRect(rect.left(), rect.top(), 1, rect.height());
01026 painter->drawRect(rect.right(), rect.top(), 1, rect.height());
01027 painter->restore();
01028 }
01029 break;
01030 case PE_PanelButtonCommand:
01031 painter->save();
01032 {
01033 bool down = (option->state & State_Sunken) || (option->state & State_On);
01034
01035 bool isDefault = false;
01036 QRect r = option->rect;
01037 r.adjust(0, 1, 0, -1);
01038 if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option)) {
01039 isDefault = (button->features & QStyleOptionButton::DefaultButton) &&(button->state & State_Enabled);
01040 if ((button->features & QStyleOptionButton::Flat) && !down) {
01041 if (isDefault) {
01042 painter->setPen(QPen(Qt::black, 0));
01043 painter->drawLine(QPoint(r.left() + 2, r.top()),
01044 QPoint(r.right() - 2, r.top()));
01045 painter->drawLine(QPoint(r.left(), r.top() + 2),
01046 QPoint(r.left(), r.bottom() - 2));
01047 painter->drawLine(QPoint(r.right(), r.top() + 2),
01048 QPoint(r.right(), r.bottom() - 2));
01049 painter->drawLine(QPoint(r.left() + 2, r.bottom()),
01050 QPoint(r.right() - 2, r.bottom()));
01051 painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1));
01052 painter->drawPoint(QPoint(r.right() - 1, r.top() + 1));
01053 painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1));
01054 painter->drawPoint(QPoint(r.left() + 1, r.top() + 1));
01055 }
01056 painter->restore();
01057 break;
01058 }
01059 }
01060 bool isEnabled = (option->state & State_Enabled);
01061
01062 QColor highlightedGradientStartColor = option->palette.button().color().light(107);
01063 QColor highlightedGradientStopColor = buttonShadow.light(107);
01064 QColor gradientStartColor = option->palette.button().color().light(108);
01065
01066 QColor buttonColor = option->palette.button().color();
01067 QColor gradientStopColor;
01068 gradientStopColor.setHsv(buttonColor.hue(),
01069 qMin(255, (int)(buttonColor.saturation()*1.9)),
01070 qMin(255, (int)(buttonColor.value()*0.94)));
01071
01072 QRect gradRect = rect.adjusted(1, 1, -1, -1);
01073 if (isEnabled) {
01074
01075 QRect innerBorder = r.adjusted(1, 1, -1, 0);
01076
01077 if (down) {
01078 painter->fillRect(gradRect, gradientStopColor.dark(110));
01079 painter->setPen(gradientStopColor.dark(125));
01080 painter->drawLine(innerBorder.topLeft(), innerBorder.topRight());
01081 painter->drawLine(innerBorder.topLeft(), innerBorder.bottomLeft());
01082 } else {
01083 if (option->state & State_Enabled && option->state & State_MouseOver ) {
01084 qt_cleanlooks_draw_gradient(painter, gradRect,
01085 highlightedGradientStartColor,
01086 highlightedGradientStopColor, TopDown, option->palette.button());
01087 } else {
01088 qt_cleanlooks_draw_gradient(painter, gradRect,
01089 gradientStartColor,
01090 gradientStopColor, TopDown, option->palette.button());
01091 }
01092 }
01093 } else {
01094 qt_cleanlooks_draw_gradient(painter, gradRect,
01095 gradientStartColor,
01096 gradientStopColor, TopDown, option->palette.button());
01097 }
01098
01099 bool hasFocus = option->state & State_HasFocus;
01100
01101 if (!isEnabled)
01102 painter->setPen(QPen(dark.light(115)));
01103 else if (isDefault)
01104 painter->setPen(QPen(Qt::black, 1));
01105 else
01106 painter->setPen(QPen(darkOutline, 1));
01107
01108 painter->drawLine(QPoint(r.left(), r.top() + 2),
01109 QPoint(r.left(), r.bottom() - 2));
01110 painter->drawLine(QPoint(r.right(), r.top() + 2),
01111 QPoint(r.right(), r.bottom() - 2));
01112 painter->drawLine(QPoint(r.left() + 2, r.bottom()),
01113 QPoint(r.right() - 2, r.bottom()));
01114 painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1));
01115 painter->drawPoint(QPoint(r.right() - 1, r.top() + 1));
01116 painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1));
01117 painter->drawPoint(QPoint(r.left() + 1, r.top() + 1));
01118
01119 if (!isDefault && !hasFocus && isEnabled)
01120 painter->setPen(QPen(darkOutline.dark(110), 0));
01121
01122 painter->drawLine(QPoint(r.left() + 2, r.top()),
01123 QPoint(r.right() - 2, r.top()));
01124
01125 QColor highlight = Qt::white;
01126 highlight.setAlpha(130);
01127 painter->setPen(highlight);
01128 painter->drawLine(QPoint(r.left() + 1, r.bottom() + 1),
01129 QPoint(r.right() - 1, r.bottom() + 1));
01130 painter->drawLine(QPoint(r.left() + 1, r.top() + 2),
01131 QPoint(r.left() + 1, r.bottom() - 2));
01132 painter->drawPoint(QPoint(r.left(), r.bottom()));
01133 painter->drawPoint(QPoint(r.right(), r.bottom() ));
01134
01135 painter->setPen(buttonShadowAlpha.dark(130));
01136 painter->drawPoint(QPoint(r.right(), r.top() + 1));
01137 painter->drawPoint(QPoint(r.right() - 1, r.top() ));
01138 painter->drawPoint(QPoint(r.right(), r.bottom() - 1));
01139 painter->drawPoint(QPoint(r.right() - 1, r.bottom() ));
01140 painter->drawPoint(QPoint(r.left() + 1, r.bottom()));
01141 painter->drawPoint(QPoint(r.left(), r.bottom() - 1));
01142 painter->drawPoint(QPoint(r.left() + 1, r.top()));
01143 painter->drawPoint(QPoint(r.left(), r.top() + 1));
01144 painter->setPen(buttonShadowAlpha);
01145 painter->drawLine(QPoint(r.right() - 1, r.top() + 2),
01146 QPoint(r.right() - 1, r.bottom() - 2));
01147 painter->drawLine(QPoint(r.left() + 2, r.top() - 1),
01148 QPoint(r.right() - 2, r.top() - 1));
01149
01150 if (isDefault) {
01151 r.adjust(-1, -1, 1, 1);
01152 painter->setPen(buttonShadowAlpha.dark(120));
01153 painter->drawLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0));
01154 painter->drawLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0));
01155 painter->drawLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3));
01156 painter->drawLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3));
01157 painter->drawPoint(r.topRight() + QPoint(-2, 1));
01158 painter->drawPoint(r.topRight() + QPoint(-1, 2));
01159 painter->drawPoint(r.bottomRight() + QPoint(-1, -2));
01160 painter->drawPoint(r.bottomRight() + QPoint(-2, -1));
01161 painter->drawPoint(r.topLeft() + QPoint(1, 2));
01162 painter->drawPoint(r.topLeft() + QPoint(2, 1));
01163 painter->drawPoint(r.bottomLeft() + QPoint(1, -2));
01164 painter->drawPoint(r.bottomLeft() + QPoint(2, -1));
01165 }
01166 }
01167 painter->restore();
01168 break;
01169 #ifndef QT_NO_TABBAR
01170 case PE_FrameTabWidget:
01171 painter->save();
01172 {
01173 painter->fillRect(option->rect, tabFrameColor);
01174 }
01175 #ifndef QT_NO_TABWIDGET
01176 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {
01177 QColor borderColor = darkOutline.light(110);
01178 QColor alphaCornerColor = mergedColors(borderColor, option->palette.background().color());
01179 QColor innerShadow = mergedColors(borderColor, option->palette.base().color());
01180
01181 int borderThickness = pixelMetric(PM_TabBarBaseOverlap, twf, widget);
01182 bool reverse = (twf->direction == Qt::RightToLeft);
01183 QRect tabBarRect;
01184
01185 switch (twf->shape) {
01186 case QTabBar::RoundedNorth:
01187 if (reverse) {
01188 tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width()
01189 - twf->tabBarSize.width() + 1,
01190 twf->rect.top(),
01191 twf->tabBarSize.width(), borderThickness);
01192 } else {
01193 tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(),
01194 twf->rect.top(),
01195 twf->tabBarSize.width(), borderThickness);
01196 }
01197 break ;
01198 case QTabBar::RoundedWest:
01199 tabBarRect = QRect(twf->rect.left(),
01200 twf->rect.top() + twf->leftCornerWidgetSize.height(),
01201 borderThickness,
01202 twf->tabBarSize.height());
01203 tabBarRect = tabBarRect;
01204 break ;
01205 case QTabBar::RoundedEast:
01206 tabBarRect = QRect(twf->rect.right() - borderThickness + 1,
01207 twf->rect.top() + twf->leftCornerWidgetSize.height(),
01208 0,
01209 twf->tabBarSize.height());
01210 break ;
01211 case QTabBar::RoundedSouth:
01212 if (reverse) {
01213 tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width() - twf->tabBarSize.width() + 1,
01214 twf->rect.bottom() + 1,
01215 twf->tabBarSize.width(),
01216 borderThickness);
01217 } else {
01218 tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(),
01219 twf->rect.bottom() + 1,
01220 twf->tabBarSize.width(),
01221 borderThickness);
01222 }
01223 break;
01224 default:
01225 break;
01226 }
01227
01228 QRegion region(twf->rect);
01229 region -= tabBarRect;
01230 painter->setClipRegion(region);
01231
01232
01233 QLine leftLine = QLine(twf->rect.topLeft() + QPoint(0, 2), twf->rect.bottomLeft() - QPoint(0, 2));
01234 QLine rightLine = QLine(twf->rect.topRight(), twf->rect.bottomRight() - QPoint(0, 2));
01235 QLine bottomLine = QLine(twf->rect.bottomLeft() + QPoint(2, 0), twf->rect.bottomRight() - QPoint(2, 0));
01236 QLine topLine = QLine(twf->rect.topLeft(), twf->rect.topRight());
01237
01238 painter->setPen(borderColor);
01239 painter->drawLine(topLine);
01240
01241
01242 QLine innerLeftLine = QLine(leftLine.p1() + QPoint(1, 0), leftLine.p2() + QPoint(1, 0));
01243 QLine innerRightLine = QLine(rightLine.p1() - QPoint(1, -1), rightLine.p2() - QPoint(1, 0));
01244 QLine innerBottomLine = QLine(bottomLine.p1() - QPoint(0, 1), bottomLine.p2() - QPoint(0, 1));
01245 QLine innerTopLine = QLine(topLine.p1() + QPoint(0, 1), topLine.p2() + QPoint(-1, 1));
01246
01247
01248 QPoint leftBottomOuterCorner = QPoint(innerLeftLine.p2() + QPoint(0, 1));
01249 QPoint leftBottomInnerCorner1 = QPoint(leftLine.p2() + QPoint(0, 1));
01250 QPoint leftBottomInnerCorner2 = QPoint(bottomLine.p1() - QPoint(1, 0));
01251 QPoint rightBottomOuterCorner = QPoint(innerRightLine.p2() + QPoint(0, 1));
01252 QPoint rightBottomInnerCorner1 = QPoint(rightLine.p2() + QPoint(0, 1));
01253 QPoint rightBottomInnerCorner2 = QPoint(bottomLine.p2() + QPoint(1, 0));
01254 QPoint leftTopOuterCorner = QPoint(innerLeftLine.p1() - QPoint(0, 1));
01255 QPoint leftTopInnerCorner1 = QPoint(leftLine.p1() - QPoint(0, 1));
01256 QPoint leftTopInnerCorner2 = QPoint(topLine.p1() - QPoint(1, 0));
01257
01258 painter->setPen(borderColor);
01259 painter->drawLine(leftLine);
01260 painter->drawLine(rightLine);
01261 painter->drawLine(bottomLine);
01262 painter->drawPoint(leftBottomOuterCorner);
01263 painter->drawPoint(rightBottomOuterCorner);
01264 painter->drawPoint(leftTopOuterCorner);
01265
01266 painter->setPen(option->palette.light().color());
01267 painter->drawLine(innerLeftLine);
01268 painter->drawLine(innerTopLine);
01269
01270 painter->setPen(buttonShadowAlpha);
01271 painter->drawLine(innerRightLine);
01272 painter->drawLine(innerBottomLine);
01273
01274 painter->setPen(alphaCornerColor);
01275 painter->drawPoint(leftBottomInnerCorner1);
01276 painter->drawPoint(leftBottomInnerCorner2);
01277 painter->drawPoint(rightBottomInnerCorner1);
01278 painter->drawPoint(rightBottomInnerCorner2);
01279 painter->drawPoint(leftTopInnerCorner1);
01280 painter->drawPoint(leftTopInnerCorner2);
01281 }
01282 #endif // QT_NO_TABWIDGET
01283 painter->restore();
01284 break ;
01285 #endif // QT_NO_TABBAR
01286 default:
01287 QWindowsStyle::drawPrimitive(elem, option, painter, widget);
01288 break;
01289 }
01290 }
01291
01295 void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter,
01296 const QWidget *widget) const
01297 {
01298 QColor button = option->palette.button().color();
01299 QColor dark;
01300 dark.setHsv(button.hue(),
01301 qMin(255, (int)(button.saturation()*1.9)),
01302 qMin(255, (int)(button.value()*0.7)));
01303 QColor darkOutline;
01304 darkOutline.setHsv(button.hue(),
01305 qMin(255, (int)(button.saturation()*2.0)),
01306 qMin(255, (int)(button.value()*0.6)));
01307 QRect rect = option->rect;
01308 QColor shadow = mergedColors(option->palette.background().color().dark(120),
01309 dark.light(130), 60);
01310 QColor tabFrameColor = mergedColors(option->palette.background().color(),
01311 dark.light(135), 60);
01312
01313 QColor highlight = option->palette.highlight().color();
01314 QColor highlightText = option->palette.highlightedText().color();
01315
01316 switch(element) {
01317 case CE_RadioButton:
01318 case CE_CheckBox:
01319 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
01320 bool hover = (btn->state & State_MouseOver && btn->state & State_Enabled);
01321 if (hover)
01322 painter->fillRect(rect, btn->palette.background().color().light(104));
01323 QStyleOptionButton copy = *btn;
01324 copy.rect.adjust(2, 0, -2, 0);
01325 QWindowsStyle::drawControl(element, ©, painter, widget);
01326 }
01327 break;
01328 case CE_Splitter:
01329 painter->save();
01330 {
01331
01332 QBrush fillColor = option->palette.background().color();
01333 if (option->state & State_MouseOver && option->state & State_Enabled)
01334 fillColor = fillColor.color().light(106);
01335
01336 painter->fillRect(option->rect, fillColor);
01337
01338 QColor grooveColor = mergedColors(dark.light(110), option->palette.button().color(),40);
01339 QColor gripShadow = grooveColor.dark(110);
01340 QPalette palette = option->palette;
01341 bool vertical = !(option->state & State_Horizontal);
01342 QRect scrollBarSlider = option->rect;
01343 int gripMargin = 4;
01344
01345 if (vertical) {
01346 for( int i = -20; i< 20 ; i += 2) {
01347 painter->setPen(QPen(gripShadow, 1));
01348 painter->drawLine(
01349 QPoint(scrollBarSlider.center().x() + i ,
01350 scrollBarSlider.top() + gripMargin),
01351 QPoint(scrollBarSlider.center().x() + i,
01352 scrollBarSlider.bottom() - gripMargin));
01353 painter->setPen(QPen(palette.light(), 1));
01354 painter->drawLine(
01355 QPoint(scrollBarSlider.center().x() + i + 1,
01356 scrollBarSlider.top() + gripMargin ),
01357 QPoint(scrollBarSlider.center().x() + i + 1,
01358 scrollBarSlider.bottom() - gripMargin));
01359 }
01360 } else {
01361 for (int i = -20; i < 20 ; i += 2) {
01362 painter->setPen(QPen(gripShadow, 1));
01363 painter->drawLine(
01364 QPoint(scrollBarSlider.left() + gripMargin ,
01365 scrollBarSlider.center().y()+ i),
01366 QPoint(scrollBarSlider.right() - gripMargin,
01367 scrollBarSlider.center().y()+ i));
01368 painter->setPen(QPen(palette.light(), 1));
01369 painter->drawLine(
01370 QPoint(scrollBarSlider.left() + gripMargin,
01371 scrollBarSlider.center().y() + 1 + i),
01372 QPoint(scrollBarSlider.right() - gripMargin,
01373 scrollBarSlider.center().y() + 1 + i));
01374
01375 }
01376 }
01377 }
01378 painter->restore();
01379 break;
01380 #ifndef QT_NO_SIZEGRIP
01381 case CE_SizeGrip:
01382 painter->save();
01383 {
01384 int x, y, w, h;
01385 option->rect.getRect(&x, &y, &w, &h);
01386 int sw = qMin(h, w);
01387 if (h > w)
01388 painter->translate(0, h - w);
01389 else
01390 painter->translate(w - h, 0);
01391
01392 int sx = x;
01393 int sy = y;
01394 int s = 4;
01395 if (option->direction == Qt::RightToLeft) {
01396 sx = x + sw;
01397 for (int i = 0; i < 4; ++i) {
01398 painter->setPen(QPen(option->palette.light().color(), 1));
01399 painter->drawLine(x, sy - 1 , sx + 1, sw);
01400 painter->setPen(QPen(dark.light(120), 1));
01401 painter->drawLine(x, sy, sx, sw);
01402 sx -= s;
01403 sy += s;
01404 }
01405 } else {
01406 for (int i = 0; i < 4; ++i) {
01407 painter->setPen(QPen(option->palette.light().color(), 1));
01408 painter->drawLine(sx - 1, sw, sw, sy - 1);
01409 painter->setPen(QPen(dark.light(120), 1));
01410 painter->drawLine(sx, sw, sw, sy);
01411 sx += s;
01412 sy += s;
01413 }
01414 }
01415 }
01416 painter->restore();
01417 break;
01418 #endif // QT_NO_SIZEGRIP
01419 #ifndef QT_NO_TOOLBAR
01420 case CE_ToolBar:
01421 painter->save();
01422 if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
01423 QRect rect = option->rect;
01424
01425 bool paintLeftBorder = true;
01426 bool paintRightBorder = true;
01427 bool paintBottomBorder = true;
01428
01429 switch (toolbar->toolBarArea) {
01430 case Qt::BottomToolBarArea:
01431 switch(toolbar->positionOfLine) {
01432 case QStyleOptionToolBar::Beginning:
01433 case QStyleOptionToolBar::OnlyOne:
01434 paintBottomBorder = false;
01435 default:
01436 break;
01437 }
01438 case Qt::TopToolBarArea:
01439 switch (toolbar->positionWithinLine) {
01440 case QStyleOptionToolBar::Beginning:
01441 paintLeftBorder = false;
01442 break;
01443 case QStyleOptionToolBar::End:
01444 paintRightBorder = false;
01445 break;
01446 case QStyleOptionToolBar::OnlyOne:
01447 paintRightBorder = false;
01448 paintLeftBorder = false;
01449 default:
01450 break;
01451 }
01452 if (QApplication::layoutDirection() == Qt::RightToLeft) {
01453 bool tmp = paintLeftBorder;
01454 paintRightBorder=paintLeftBorder;
01455 paintLeftBorder=tmp;
01456 }
01457 break;
01458 case Qt::RightToolBarArea:
01459 switch (toolbar->positionOfLine) {
01460 case QStyleOptionToolBar::Beginning:
01461 case QStyleOptionToolBar::OnlyOne:
01462 paintRightBorder = false;
01463 break;
01464 default:
01465 break;
01466 }
01467 break;
01468 case Qt::LeftToolBarArea:
01469 switch (toolbar->positionOfLine) {
01470 case QStyleOptionToolBar::Beginning:
01471 case QStyleOptionToolBar::OnlyOne:
01472 paintLeftBorder = false;
01473 break;
01474 default:
01475 break;
01476 }
01477 break;
01478 default:
01479 break;
01480 }
01481
01482 QColor light = option->palette.background().color().light(110);
01483
01484
01485 painter->setPen(QPen(light));
01486 painter->drawLine(rect.topLeft().x(),
01487 rect.topLeft().y(),
01488 rect.topRight().x(),
01489 rect.topRight().y());
01490
01491 if (paintLeftBorder) {
01492 painter->setPen(QPen(light));
01493 painter->drawLine(rect.topLeft().x(),
01494 rect.topLeft().y(),
01495 rect.bottomLeft().x(),
01496 rect.bottomLeft().y());
01497 }
01498
01499 if (paintRightBorder) {
01500 painter->setPen(QPen(shadow));
01501 painter->drawLine(rect.topRight().x(),
01502 rect.topRight().y(),
01503 rect.bottomRight().x(),
01504 rect.bottomRight().y());
01505 }
01506
01507 if (paintBottomBorder) {
01508 painter->setPen(QPen(shadow));
01509 painter->drawLine(rect.bottomLeft().x(),
01510 rect.bottomLeft().y(),
01511 rect.bottomRight().x(),
01512 rect.bottomRight().y());
01513 }
01514 }
01515 painter->restore();
01516 break;
01517 #endif // QT_NO_TOOLBAR
01518 #ifndef QT_NO_DOCKWIDGET
01519 case CE_DockWidgetTitle:
01520 painter->save();
01521 if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
01522 QRect r = dwOpt->rect.adjusted(0, 0, -1, 0);
01523 painter->setPen(option->palette.light().color());
01524 painter->drawRect(r.adjusted(1, 1, 1, 1));
01525 painter->setPen(shadow);
01526 painter->drawRect(r);
01527
01528 if (!dwOpt->title.isEmpty()) {
01529 const int indent = painter->fontMetrics().descent() + 2;
01530 drawItemText(painter, r.adjusted(indent + 1, 0, - indent - 1, -1),
01531 Qt::AlignLeft | Qt::AlignVCenter, dwOpt->palette,
01532 dwOpt->state & State_Enabled, dwOpt->title,
01533 QPalette::WindowText);
01534 }
01535 }
01536 painter->restore();
01537 break;
01538 #endif // QT_NO_DOCKWIDGET
01539 case CE_HeaderSection:
01540 painter->save();
01541
01542 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
01543 QPixmap cache;
01544 QString pixmapName = uniqueName(QLatin1String("headersection"), option, option->rect.size());
01545 pixmapName += QLatin1String("-") + QString::number(int(header->position));
01546 pixmapName += QLatin1String("-") + QString::number(int(header->orientation));
01547 QRect r = option->rect;
01548 QColor gradientStopColor;
01549 QColor gradientStartColor = option->palette.button().color();
01550 gradientStopColor.setHsv(gradientStartColor.hue(),
01551 qMin(255, (int)(gradientStartColor.saturation()*2)),
01552 qMin(255, (int)(gradientStartColor.value()*0.96)));
01553 QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
01554 if (option->palette.background().gradient()) {
01555 gradient.setStops(option->palette.background().gradient()->stops());
01556 } else {
01557 gradient.setColorAt(0, gradientStartColor);
01558 gradient.setColorAt(0.8, gradientStartColor);
01559 gradient.setColorAt(1, gradientStopColor);
01560 }
01561 painter->fillRect(r, gradient);
01562
01563 if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
01564 cache = QPixmap(r.size());
01565 cache.fill(Qt::transparent);
01566 QRect pixmapRect(0, 0, r.width(), r.height());
01567 QPainter cachePainter(&cache);
01568 if (header->orientation == Qt::Vertical) {
01569 cachePainter.setPen(QPen(dark));
01570 cachePainter.drawLine(pixmapRect.topRight(), pixmapRect.bottomRight());
01571 if (header->position != QStyleOptionHeader::End) {
01572 cachePainter.setPen(QPen(shadow));
01573 cachePainter.drawLine(pixmapRect.bottomLeft() + QPoint(3, -1), pixmapRect.bottomRight() + QPoint(-3, -1)); cachePainter.setPen(QPen(option->palette.light().color()));
01574 cachePainter.drawLine(pixmapRect.bottomLeft() + QPoint(3, 0), pixmapRect.bottomRight() + QPoint(-3, 0)); }
01575 } else {
01576 cachePainter.setPen(QPen(dark));
01577 cachePainter.drawLine(pixmapRect.bottomLeft(), pixmapRect.bottomRight());
01578 cachePainter.setPen(QPen(shadow));
01579 cachePainter.drawLine(pixmapRect.topRight() + QPoint(-1, 3), pixmapRect.bottomRight() + QPoint(-1, -3)); cachePainter.setPen(QPen(option->palette.light().color()));
01580 cachePainter.drawLine(pixmapRect.topRight() + QPoint(0, 3), pixmapRect.bottomRight() + QPoint(0, -3)); }
01581 cachePainter.end();
01582 if (UsePixmapCache)
01583 QPixmapCache::insert(pixmapName, cache);
01584 }
01585 painter->drawPixmap(r.topLeft(), cache);
01586 }
01587 painter->restore();
01588 break;
01589 case CE_ProgressBarGroove:
01590 painter->save();
01591 {
01592 painter->fillRect(rect, option->palette.base());
01593 QColor borderColor = dark.light(110);
01594 painter->setPen(QPen(borderColor, 0));
01595 painter->drawLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top()));
01596 painter->drawLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom()));
01597 painter->drawLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1));
01598 painter->drawLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1));
01599 QColor alphaCorner = mergedColors(borderColor, option->palette.background().color());
01600 QColor innerShadow = mergedColors(borderColor, option->palette.base().color());
01601
01602
01603 painter->setPen(alphaCorner);
01604 painter->drawPoint(rect.topRight());
01605 painter->drawPoint(rect.topLeft());
01606 painter->drawPoint(rect.bottomRight());
01607 painter->drawPoint(rect.bottomLeft());
01608
01609
01610 painter->setPen(innerShadow);
01611 painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
01612 QPoint(rect.right() - 1, rect.top() + 1));
01613 painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
01614 QPoint(rect.left() + 1, rect.bottom() + 1));
01615
01616 }
01617 painter->restore();
01618 break;
01619 case CE_ProgressBarContents:
01620 painter->save();
01621 if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
01622 QRect rect = bar->rect;
01623 bool vertical = false;
01624 bool inverted = false;
01625 bool indeterminate = (bar->minimum == 0 && bar->maximum == 0);
01626
01627
01628 if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
01629 vertical = (bar2->orientation == Qt::Vertical);
01630 inverted = bar2->invertedAppearance;
01631 }
01632
01633
01634
01635
01636 if (vertical) {
01637 rect = QRect(rect.left(), rect.top(), rect.height(), rect.width());
01638 QMatrix m;
01639 m.translate(rect.height()-1, -1.0);
01640 m.rotate(90.0);
01641 painter->setMatrix(m);
01642 }
01643
01644 int maxWidth = rect.width() - 4;
01645 int minWidth = 4;
01646 int progress = qMax(bar->progress, bar->minimum);
01647 int width = indeterminate ? maxWidth : qMax(int((((progress - bar->minimum))
01648 / double(bar->maximum - bar->minimum)) * maxWidth), minWidth);
01649
01650 bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical;
01651 if (inverted)
01652 reverse = !reverse;
01653
01654 QRect progressBar;
01655 if (!indeterminate) {
01656 if (!reverse) {
01657 progressBar.setRect(rect.left() + 1, rect.top() + 1, width + 1, rect.height() - 3);
01658 } else {
01659 progressBar.setRect(rect.right() - 1 - width, rect.top() + 1, width + 1, rect.height() - 3);
01660 }
01661 } else {
01662 int step = 0;
01663 int slideWidth = rect.width() / 2;
01664 progressBar.setRect(rect.left() + 1 + step, rect.top() + 1,
01665 slideWidth / 2, rect.height() - 3);
01666
01667 }
01668 QColor highlight = option->palette.color(QPalette::Normal, QPalette::Highlight);
01669 painter->setPen(QPen(highlight.dark(140), 0));
01670
01671 QColor highlightedGradientStartColor = highlight.light(100);
01672 QColor highlightedGradientStopColor = highlight.light(130);
01673
01674 QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(),
01675 rect.bottomLeft().y()*2));
01676
01677 gradient.setColorAt(0, highlightedGradientStartColor);
01678 gradient.setColorAt(1, highlightedGradientStopColor);
01679
01680 painter->setBrush(gradient);
01681 painter->drawRect(progressBar);
01682
01683 painter->setPen(QPen(highlight.light(120), 0));
01684 painter->drawLine(QPoint(progressBar.left() + 1, progressBar.top() + 1),
01685 QPoint(progressBar.right(), progressBar.top() + 1));
01686 painter->drawLine(QPoint(progressBar.left() + 1, progressBar.top() + 1),
01687 QPoint(progressBar.left() + 1, progressBar.bottom() - 1));
01688
01689 painter->setPen(QPen(highlightedGradientStartColor, 7.0));
01690
01691 painter->save();
01692 painter->setClipRect(progressBar.adjusted(2, 2, -1, -1));
01693 for (int x = rect.left() - 32; x< rect.right() ; x+=18) {
01694 painter->drawLine(x, progressBar.bottom() + 1, x + 23, progressBar.top() - 2);
01695 }
01696 painter->restore();
01697
01698 }
01699 painter->restore();
01700 break;
01701 case CE_MenuBarItem:
01702 painter->save();
01703 if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
01704 {
01705 QStyleOptionMenuItem item = *mbi;
01706 item.rect = mbi->rect.adjusted(0, 3, 0, -1);
01707 QColor highlightOutline = highlight.dark(125);
01708 QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()*2));
01709
01710 if (option->palette.button().gradient()) {
01711 gradient.setStops(option->palette.button().gradient()->stops());
01712 } else {
01713 gradient.setColorAt(0, option->palette.button().color());
01714 gradient.setColorAt(1, option->palette.button().color().dark(110));
01715 }
01716 painter->fillRect(rect, gradient);
01717
01718 QCommonStyle::drawControl(element, &item, painter, widget);
01719
01720 bool act = mbi->state & State_Selected && mbi->state & State_Sunken;
01721 bool dis = !(mbi->state & State_Enabled);
01722
01723 QRect r = option->rect;
01724 if (act) {
01725 qt_cleanlooks_draw_gradient(painter, r.adjusted(1, 1, -1, -1),
01726 highlight,
01727 highlightOutline, TopDown,
01728 option->palette.highlight());
01729
01730 painter->setPen(QPen(highlightOutline, 0));
01731 painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom()));
01732 painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom()));
01733 painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom()));
01734 painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()));
01735
01736
01737 QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText;
01738 uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
01739 if (!styleHint(SH_UnderlineShortcut, mbi, widget))
01740 alignment |= Qt::TextHideMnemonic;
01741 drawItemText(painter, item.rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole);
01742 }
01743
01744 }
01745 painter->restore();
01746 break;
01747 case CE_MenuItem:
01748 painter->save();
01749
01750 if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
01751 QColor highlightOutline = highlight.dark(125);
01752 QColor menuBackground = option->palette.background().color().light(104);
01753 QColor borderColor = option->palette.background().color().dark(160);
01754 QColor alphaCornerColor;
01755
01756 if (widget) {
01757
01758 alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor);
01759 } else {
01760 alphaCornerColor = mergedColors(option->palette.background().color(), borderColor);
01761 }
01762 QColor alphaTextColor = mergedColors(option->palette.background().color(), option->palette.text().color());
01763 if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
01764 painter->fillRect(menuItem->rect, menuBackground);
01765 int w = 0;
01766 if (!menuItem->text.isEmpty()) {
01767 painter->setFont(menuItem->font);
01768 drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,
01769 menuItem->palette, menuItem->state & State_Enabled, menuItem->text,
01770 QPalette::Text);
01771 w = menuItem->fontMetrics.width(menuItem->text) + 5;
01772 }
01773 painter->setPen(shadow.light(106));
01774 bool reverse = menuItem->direction == Qt::RightToLeft;
01775 painter->drawLine(menuItem->rect.left() + 5 + (reverse ? 0 : w), menuItem->rect.center().y(),
01776 menuItem->rect.right() - 5 - (reverse ? w : 0), menuItem->rect.center().y());
01777 painter->restore();
01778 break;
01779 }
01780 bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled;
01781 if (selected) {
01782 QRect r = option->rect.adjusted(1, 0, -2, -1);
01783 qt_cleanlooks_draw_gradient(painter, r, highlight,
01784 highlightOutline, TopDown,
01785 highlight);
01786 r = r.adjusted(-1, 0, 1, 0);
01787 painter->setPen(QPen(highlightOutline, 0));
01788 painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1));
01789 painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1));
01790 painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom()));
01791 painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()));
01792 } else {
01793 painter->fillRect(option->rect, menuBackground);
01794 }
01795
01796 bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
01797 bool checked = menuItem->checked;
01798 bool sunken = menuItem->state & State_Sunken;
01799 bool enabled = menuItem->state & State_Enabled;
01800
01801 bool ignoreCheckMark = false;
01802 int checkcol = qMax(menuItem->maxIconWidth, 20);
01803
01804 #ifndef QT_NO_COMBOBOX
01805 if (qobject_cast<const QComboBox*>(widget))
01806 ignoreCheckMark = true;
01807 #endif
01808
01809 if (!ignoreCheckMark) {
01810
01811 QRect checkRect(option->rect.left() + 7, option->rect.center().y() - 6, 13, 13);
01812 checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect);
01813 if (checkable) {
01814 if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
01815
01816 if (checked || sunken) {
01817 painter->setRenderHint(QPainter::Antialiasing);
01818 painter->setPen(Qt::NoPen);
01819
01820 QPalette::ColorRole textRole = !enabled ? QPalette::Text:
01821 selected ? QPalette::HighlightedText : QPalette::ButtonText;
01822 painter->setBrush(option->palette.brush( option->palette.currentColorGroup(), textRole));
01823 painter->drawEllipse(checkRect.adjusted(4, 4, -4, -4));
01824 }
01825 } else {
01826
01827 if (menuItem->icon.isNull()) {
01828 if (checked || sunken) {
01829 QImage image(qt_cleanlooks_menuitem_checkbox_checked);
01830 if (menuItem->state & State_Selected) {
01831 image.setColor(1, 0x55ffffff);
01832 image.setColor(2, 0xAAffffff);
01833 image.setColor(3, 0xBBffffff);
01834 image.setColor(4, 0xFFffffff);
01835 image.setColor(5, 0x33ffffff);
01836 } else {
01837 image.setColor(1, 0x55000000);
01838 image.setColor(2, 0xAA000000);
01839 image.setColor(3, 0xBB000000);
01840 image.setColor(4, 0xFF000000);
01841 image.setColor(5, 0x33000000);
01842 }
01843 painter->drawImage(QPoint(checkRect.center().x() - image.width() / 2,
01844 checkRect.center().y() - image.height() / 2), image);
01845 }
01846 } else if (checked) {
01847 int iconSize = qMax(menuItem->maxIconWidth, 20);
01848 QRect sunkenRect(option->rect.left() + 2,
01849 option->rect.top() + (option->rect.height() - iconSize) / 2,
01850 iconSize, iconSize);
01851 sunkenRect = visualRect(menuItem->direction, menuItem->rect, sunkenRect);
01852
01853 QStyleOption opt = *option;
01854 opt.state |= State_Sunken;
01855 opt.rect = sunkenRect;
01856 }
01857 }
01858 }
01859 } else {
01860 if (menuItem->icon.isNull())
01861 checkcol = 0;
01862 else
01863 checkcol = menuItem->maxIconWidth;
01864 }
01865
01866
01867 bool dis = !(menuItem->state & State_Enabled);
01868 bool act = menuItem->state & State_Selected;
01869 const QStyleOption *opt = option;
01870 const QStyleOptionMenuItem *menuitem = menuItem;
01871
01872 QPainter *p = painter;
01873 QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
01874 QRect(menuitem->rect.x(), menuitem->rect.y(),
01875 checkcol, menuitem->rect.height()));
01876 if (!menuItem->icon.isNull()) {
01877 QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
01878 if (act && !dis)
01879 mode = QIcon::Active;
01880 QPixmap pixmap;
01881 if (checked)
01882 pixmap = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On);
01883 else
01884 pixmap = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode);
01885 int pixw = pixmap.width();
01886 int pixh = pixmap.height();
01887
01888 QRect pmr(0, 0, pixw, pixh);
01889 pmr.moveCenter(vCheckRect.center());
01890 painter->setPen(menuItem->palette.text().color());
01891 if (checkable && checked)
01892 painter->drawPixmap(QPoint(pmr.left() + 1, pmr.top() + 1), pixmap);
01893 else
01894 painter->drawPixmap(pmr.topLeft(), pixmap);
01895 }
01896 if (selected) {
01897 painter->setPen(menuItem->palette.highlightedText().color());
01898 } else {
01899 painter->setPen(menuItem->palette.text().color());
01900 }
01901 int x, y, w, h;
01902 menuitem->rect.getRect(&x, &y, &w, &h);
01903 int tab = menuitem->tabWidth;
01904 QColor discol;
01905 if (dis) {
01906 discol = menuitem->palette.text().color();
01907 p->setPen(discol);
01908 }
01909 int xm = windowsItemFrame + checkcol + windowsItemHMargin;
01910 int xpos = menuitem->rect.x() + xm;
01911
01912 QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
01913 QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
01914 QString s = menuitem->text;
01915 if (!s.isEmpty()) {
01916 p->save();
01917 int t = s.indexOf(QLatin1Char('\t'));
01918 int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
01919 if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
01920 text_flags |= Qt::TextHideMnemonic;
01921 text_flags |= Qt::AlignLeft;
01922 if (t >= 0) {
01923 QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
01924 QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
01925 if (dis && !act) {
01926 p->setPen(menuitem->palette.light().color());
01927 p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, s.mid(t + 1));
01928 p->setPen(discol);
01929 }
01930 p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
01931 s = s.left(t);
01932 }
01933 QFont font = menuitem->font;
01934
01935 if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
01936 font.setBold(true);
01937
01938 p->setFont(font);
01939 if (dis && !act) {
01940 p->setPen(menuitem->palette.light().color());
01941 p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, s.left(t));
01942 p->setPen(discol);
01943 }
01944 p->drawText(vTextRect, text_flags, s.left(t));
01945 p->restore();
01946 }
01947
01948
01949 if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {
01950 int dim = (menuItem->rect.height() - 4) / 2;
01951 PrimitiveElement arrow;
01952 arrow = QApplication::isRightToLeft() ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
01953 int xpos = menuItem->rect.left() + menuItem->rect.width() - 1 - dim;
01954 QRect vSubMenuRect = visualRect(option->direction, menuItem->rect,
01955 QRect(xpos, menuItem->rect.top() + menuItem->rect.height() / 2 - dim / 2, dim, dim));
01956 QStyleOptionMenuItem newMI = *menuItem;
01957 newMI.rect = vSubMenuRect;
01958 newMI.state = !enabled ? State_None : State_Enabled;
01959 if (selected)
01960 newMI.palette.setColor(QPalette::ButtonText,
01961 newMI.palette.highlightedText().color());
01962 drawPrimitive(arrow, &newMI, painter, widget);
01963 }
01964 }
01965 painter->restore();
01966 break;
01967 case CE_MenuHMargin:
01968 case CE_MenuVMargin:
01969 break;
01970 case CE_MenuEmptyArea:
01971 break;
01972 case CE_PushButtonLabel:
01973 if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
01974 QRect ir = button->rect;
01975 uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic;
01976 if (!styleHint(SH_UnderlineShortcut, button, widget))
01977 tf |= Qt::TextHideMnemonic;
01978
01979 if (!button->icon.isNull()) {
01980
01981 QPoint point;
01982
01983 QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal
01984 : QIcon::Disabled;
01985 if (mode == QIcon::Normal && button->state & State_HasFocus)
01986 mode = QIcon::Active;
01987 QIcon::State state = QIcon::Off;
01988 if (button->state & State_On)
01989 state = QIcon::On;
01990
01991 QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
01992 int w = pixmap.width();
01993 int h = pixmap.height();
01994
01995 if (!button->text.isEmpty())
01996 w += button->fontMetrics.width(button->text) + 2;
01997
01998 point = QPoint(ir.x() + ir.width() / 2 - w / 2,
01999 ir.y() + ir.height() / 2 - h / 2);
02000
02001 if (button->direction == Qt::RightToLeft)
02002 point.rx() += pixmap.width();
02003
02004 painter->drawPixmap(visualPos(button->direction, button->rect, point), pixmap);
02005
02006 if (button->direction == Qt::RightToLeft)
02007 ir.translate(-point.x() - 2, 0);
02008 else
02009 ir.translate(point.x() + pixmap.width(), 0);
02010
02011
02012 if (!button->text.isEmpty())
02013 tf |= Qt::AlignLeft;
02014
02015 } else {
02016 tf |= Qt::AlignHCenter;
02017 }
02018
02019
02020
02021 if (button->fontMetrics.height() > 14)
02022 ir.translate(0, 1);
02023
02024 drawItemText(painter, ir, tf, button->palette, (button->state & State_Enabled),
02025 button->text, QPalette::ButtonText);
02026 }
02027 break;
02028 case CE_MenuBarEmptyArea:
02029 painter->save();
02030 {
02031 QColor shadow = mergedColors(option->palette.background().color().dark(120),
02032 dark.light(140), 60);
02033
02034 QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()*2));
02035 gradient.setColorAt(0, option->palette.button().color());
02036 gradient.setColorAt(1, option->palette.button().color().dark(110));
02037 painter->fillRect(rect, gradient);
02038
02039 #ifndef QT_NO_MAINWINDOW
02040 if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) {
02041 QPen oldPen = painter->pen();
02042 painter->setPen(QPen(shadow));
02043 painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
02044 }
02045 #endif // QT_NO_MAINWINDOW
02046 }
02047 painter->restore();
02048 break;
02049 #ifndef QT_NO_TABBAR
02050 case CE_TabBarTabShape:
02051 painter->save();
02052 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
02053
02054 bool rtlHorTabs = (tab->direction == Qt::RightToLeft
02055 && (tab->shape == QTabBar::RoundedNorth
02056 || tab->shape == QTabBar::RoundedSouth));
02057 bool selected = tab->state & State_Selected;
02058 bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
02059 || (rtlHorTabs
02060 && tab->position == QStyleOptionTab::Beginning));
02061 bool onlyTab = tab->position == QStyleOptionTab::OnlyOneTab;
02062 bool leftCornerWidget = (tab->cornerWidgets & QStyleOptionTab::LeftCornerWidget);
02063 bool atBeginning = ((tab->position == QStyleOptionTab::Beginning) || onlyTab);
02064
02065 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
02066 bool previousSelected =
02067 ((!rtlHorTabs
02068 && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
02069 || (rtlHorTabs
02070 && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
02071 bool nextSelected =
02072 ((!rtlHorTabs
02073 && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
02074 || (rtlHorTabs
02075 && tab->selectedPosition
02076 == QStyleOptionTab::PreviousIsSelected));
02077 int tabBarAlignment = styleHint(SH_TabBar_Alignment, tab, widget);
02078 bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
02079 || (rtlHorTabs
02080 && tabBarAlignment == Qt::AlignRight);
02081
02082 bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
02083 || (rtlHorTabs
02084 && tabBarAlignment == Qt::AlignLeft);
02085
02086 QColor light = tab->palette.light().color();
02087 QColor midlight = tab->palette.midlight().color();
02088
02089 QColor background = tab->palette.background().color();
02090 int borderThinkness = pixelMetric(PM_TabBarBaseOverlap, tab, widget);
02091 if (selected)
02092 borderThinkness /= 2;
02093 QRect r2(option->rect);
02094 int x1 = r2.left();
02095 int x2 = r2.right();
02096 int y1 = r2.top();
02097 int y2 = r2.bottom();
02098
02099 QMatrix rotMatrix;
02100 bool flip = false;
02101 painter->setPen(shadow);
02102 QColor activeHighlight = option->palette.color(QPalette::Normal, QPalette::Highlight);
02103 switch (tab->shape) {
02104 case QTabBar::RoundedNorth:
02105 break;
02106 case QTabBar::RoundedSouth:
02107 rotMatrix.rotate(180);
02108 rotMatrix.translate(0, -rect.height() + 1);
02109 rotMatrix.scale(-1, 1);
02110 painter->setMatrix(rotMatrix);
02111 break;
02112 case QTabBar::RoundedWest:
02113 rotMatrix.rotate(180 + 90);
02114 rotMatrix.scale(-1, 1);
02115 flip = true;
02116 painter->setMatrix(rotMatrix);
02117 break;
02118 case QTabBar::RoundedEast:
02119 rotMatrix.rotate(90);
02120 rotMatrix.translate(0, - rect.width() + 1);
02121 flip = true;
02122 painter->setMatrix(rotMatrix);
02123 break;
02124 default:
02125 painter->restore();
02126 QWindowsStyle::drawControl(element, tab, painter, widget);
02127 return;
02128 }
02129
02130 if (flip) {
02131 QRect tmp = rect;
02132 rect = QRect(tmp.y(), tmp.x(), tmp.height(), tmp.width());
02133 int temp = x1;
02134 x1 = y1;
02135 y1 = temp;
02136 temp = x2;
02137 x2 = y2;
02138 y2 = temp;
02139 }
02140
02141 QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
02142 if (option->palette.button().gradient()) {
02143 if (selected)
02144 gradient.setStops(option->palette.background().gradient()->stops());
02145 else
02146 gradient.setStops(option->palette.background().gradient()->stops());
02147 }
02148 else if (selected) {
02149 gradient.setColorAt(0, option->palette.background().color().light(104));
02150 gradient.setColorAt(1, tabFrameColor);
02151 painter->fillRect(rect.adjusted(0, 2, 0, -1), gradient);
02152 } else {
02153 y1 += 2;
02154 gradient.setColorAt(0, option->palette.background().color());
02155 gradient.setColorAt(1, dark.light(120));
02156 painter->fillRect(rect.adjusted(0, 2, 0, -2), gradient);
02157 }
02158
02159
02160 if (selected) {
02161 painter->setPen(QPen(activeHighlight, 0));
02162 painter->drawLine(x1 + 1, y1 + 1, x2 - 1, y1 + 1);
02163 painter->drawLine(x1 , y1 + 2, x2 , y1 + 2);
02164 } else {
02165 painter->setPen(dark);
02166 painter->drawLine(x1, y2 - 1, x2 + 2, y2 - 1 );
02167 if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedWest) {
02168 painter->setPen(light);
02169 painter->drawLine(x1, y2 , x2, y2 );
02170 }
02171 }
02172
02173 if (atBeginning || selected ) {
02174 painter->setPen(light);
02175 painter->drawLine(x1 + 1, y1 + 2 + 1, x1 + 1, y2 - ((onlyOne || atBeginning) && selected && leftAligned ? 0 : borderThinkness) - (atBeginning && leftCornerWidget ? 1 : 0));
02176 painter->drawPoint(x1 + 1, y1 + 1);
02177 painter->setPen(dark);
02178 painter->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || atBeginning) && leftAligned ? 0 : borderThinkness) - (atBeginning && leftCornerWidget ? 1 : 0));
02179 }
02180
02181 {
02182 int beg = x1 + (previousSelected ? 0 : 2);
02183 int end = x2 - (nextSelected ? 0 : 2);
02184 painter->setPen(light);
02185
02186 if (!selected)painter->drawLine(beg - 2, y1 + 1, end, y1 + 1);
02187
02188 if (selected)
02189 painter->setPen(QPen(activeHighlight.dark(150), 0));
02190 else
02191 painter->setPen(darkOutline);
02192 painter->drawLine(beg, y1 , end, y1);
02193
02194 if (atBeginning|| selected) {
02195 painter->drawPoint(beg - 1, y1 + 1);
02196 } else if (!atBeginning) {
02197 painter->drawPoint(beg - 1, y1);
02198 painter->drawPoint(beg - 2, y1);
02199 if (!lastTab) {
02200 painter->setPen(dark.light(130));
02201 painter->drawPoint(end + 1, y1);
02202 painter->drawPoint(end + 2 , y1);
02203 painter->drawPoint(end + 2, y1 + 1);
02204 }
02205 }
02206 }
02207
02208 if (lastTab || selected || onlyOne || !nextSelected) {
02209 painter->setPen(darkOutline);
02210 painter->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
02211 if (selected)
02212 painter->setPen(QPen(activeHighlight.dark(150), 0));
02213 else
02214 painter->setPen(darkOutline);
02215 painter->drawPoint(x2 - 1, y1 + 1);
02216
02217 if (selected) {
02218 painter->setPen(background.dark(110));
02219 painter->drawLine(x2 - 1, y1 + 3, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
02220 }
02221 }
02222 }
02223 painter->restore();
02224 break;
02225
02226 #endif // QT_NO_TABBAR
02227 default:
02228 QWindowsStyle::drawControl(element,option,painter,widget);
02229 break;
02230 }
02231 }
02232
02236 QPalette QCleanlooksStyle::standardPalette () const
02237 {
02238 QPalette palette = QWindowsStyle::standardPalette();
02239 palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(98, 140, 178));
02240 palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(145, 141, 126));
02241 palette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 141, 126));
02242
02243 QColor backGround(239, 235, 231);
02244
02245 QColor light = backGround.light(150);
02246 QColor base = Qt::white;
02247 QColor dark = QColor(170, 156, 143).dark(110);
02248 dark = backGround.dark(150);
02249 QColor darkDisabled = QColor(209, 200, 191).dark(110);
02250
02251
02252 palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(190, 190, 190));
02253
02254 palette.setBrush(QPalette::Window, backGround);
02255 palette.setBrush(QPalette::Mid, backGround.dark(130));
02256 palette.setBrush(QPalette::Light, light);
02257
02258 palette.setBrush(QPalette::Active, QPalette::Base, base);
02259 palette.setBrush(QPalette::Inactive, QPalette::Base, base);
02260 palette.setBrush(QPalette::Disabled, QPalette::Base, backGround);
02261
02262 palette.setBrush(QPalette::Midlight, palette.mid().color().light(110));
02263
02264 palette.setBrush(QPalette::All, QPalette::Dark, dark);
02265 palette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
02266
02267 QColor button = backGround;
02268
02269 palette.setBrush(QPalette::Button, button);
02270
02271 QColor shadow = dark.dark(135);
02272 palette.setBrush(QPalette::Shadow, shadow);
02273 palette.setBrush(QPalette::Disabled, QPalette::Shadow, shadow.light(150));
02274 palette.setBrush(QPalette::HighlightedText, QColor(QRgb(0xffffffff)));
02275 return palette;
02276 }
02277
02281 void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
02282 QPainter *painter, const QWidget *widget) const
02283 {
02284 QColor button = option->palette.button().color();
02285 QColor dark;
02286 QColor grooveColor;
02287 QColor darkOutline;
02288 dark.setHsv(button.hue(),
02289 qMin(255, (int)(button.saturation()*1.9)),
02290 qMin(255, (int)(button.value()*0.7)));
02291 grooveColor.setHsv(button.hue(),
02292 qMin(255, (int)(button.saturation()*2.6)),
02293 qMin(255, (int)(button.value()*0.9)));
02294 darkOutline.setHsv(button.hue(),
02295 qMin(255, (int)(button.saturation()*3.0)),
02296 qMin(255, (int)(button.value()*0.6)));
02297
02298 QColor alphaCornerColor;
02299 if (widget) {
02300
02301 alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), darkOutline);
02302 } else {
02303 alphaCornerColor = mergedColors(option->palette.background().color(), darkOutline);
02304 }
02305 QColor gripShadow = grooveColor.dark(110);
02306 QColor buttonShadow = option->palette.button().color().dark(110);
02307
02308 QColor gradientStartColor = option->palette.button().color().light(108);
02309 QColor gradientStopColor = mergedColors(option->palette.button().color().dark(108), dark.light(150), 70);
02310
02311 QColor highlightedGradientStartColor = option->palette.button().color();
02312 QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85);
02313
02314 QColor highlightedDarkInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 35);
02315 QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58);
02316
02317 QColor buttonShadowAlpha = option->palette.background().color().dark(105);
02318
02319 QPalette palette = option->palette;
02320
02321 switch (control) {
02322 #ifndef QT_NO_SPINBOX
02323 case CC_SpinBox:
02324 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
02325 QPixmap cache;
02326 QString pixmapName = uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size());
02327 if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
02328 cache = QPixmap(spinBox->rect.size());
02329 cache.fill(Qt::transparent);
02330 QRect pixmapRect(0, 0, spinBox->rect.width(), spinBox->rect.height());
02331 QPainter cachePainter(&cache);
02332
02333 bool isEnabled = (spinBox->state & State_Enabled);
02334
02335 bool hover = isEnabled && (spinBox->state & State_MouseOver);
02336 bool sunken = (spinBox->state & State_Sunken);
02337 bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp);
02338 bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown);
02339
02340 QRect rect = pixmapRect;
02341 QStyleOptionSpinBox spinBoxCopy = *spinBox;
02342 spinBoxCopy.rect = pixmapRect;
02343 QRect upRect = subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxUp, widget);
02344 QRect downRect = subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxDown, widget);
02345
02346 int fw = spinBoxCopy.frame ? pixelMetric(PM_SpinBoxFrameWidth, &spinBoxCopy, widget) : 0;
02347 cachePainter.fillRect(rect.adjusted(1, qMax(fw - 1, 0), -1, -fw),
02348 option->palette.base());
02349
02350 QRect r = rect.adjusted(0, 1, 0, -1);
02351 if (spinBox->frame) {
02352
02353 cachePainter.setPen(buttonShadowAlpha);
02354 cachePainter.drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1));
02355
02356 cachePainter.setPen(QPen(option->palette.background().color(), 1));
02357 cachePainter.drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1));
02358 QColor highlight = Qt::white;
02359 highlight.setAlpha(130);
02360 cachePainter.setPen(option->palette.base().color().dark(120));
02361 cachePainter.drawLine(QPoint(r.left() + 1, r.top() + 1),
02362 QPoint(r.right() - 1, r.top() + 1));
02363 cachePainter.drawLine(QPoint(r.left() + 1, r.top() + 1),
02364 QPoint(r.left() + 1, r.bottom() - 1));
02365 cachePainter.setPen(option->palette.base().color());
02366 cachePainter.drawLine(QPoint(r.right() - 1, r.top() + 1),
02367 QPoint(r.right() - 1, r.bottom() - 1));
02368 cachePainter.drawLine(QPoint(r.left() + 1, r.bottom() - 1),
02369 QPoint(r.right() - 1, r.bottom() - 1));
02370 cachePainter.setPen(highlight);
02371 cachePainter.drawLine(QPoint(r.left() + 2, r.bottom() + 1),
02372 QPoint(r.right() - 2, r.bottom() + 1));
02373 cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom()));
02374 cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() ));
02375 cachePainter.setPen(QPen(darkOutline.light(115), 1));
02376
02377
02378 cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom()));
02379 cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top()));
02380 cachePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2));
02381 cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
02382 cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
02383 }
02384
02385
02386 qt_cleanlooks_draw_gradient(&cachePainter, upRect,
02387 gradientStartColor.dark(106),
02388 gradientStopColor, TopDown, option->palette.button());
02389 qt_cleanlooks_draw_gradient(&cachePainter, downRect.adjusted(0, 0, 0, 1),
02390 gradientStartColor.dark(106),
02391 gradientStopColor, TopDown, option->palette.button());
02392 if (isEnabled) {
02393 if(upIsActive) {
02394 if (sunken) {
02395 cachePainter.fillRect(upRect.adjusted(1, 0, 0, 0), gradientStopColor.dark(110));
02396 } else if (hover) {
02397 qt_cleanlooks_draw_gradient(&cachePainter, upRect.adjusted(1, 0, 0, 0),
02398 gradientStartColor.light(110),
02399 gradientStopColor.light(110), TopDown, option->palette.button());
02400 }
02401 }
02402 if(downIsActive) {
02403 if (sunken) {
02404 cachePainter.fillRect(downRect.adjusted(1, 0, 0, 1), gradientStopColor.dark(110));
02405
02406 } else if (hover) {
02407 qt_cleanlooks_draw_gradient(&cachePainter, downRect.adjusted(1, 0, 0, 1),
02408 gradientStartColor.light(110),
02409 gradientStopColor.light(110), TopDown, option->palette.button());
02410 }
02411 }
02412 }
02413
02414 if (spinBox->frame) {
02415
02416 cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1));
02417 cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1));
02418 cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() - 1));
02419 cachePainter.drawPoint(QPoint(r.right() - 1, r.top() + 1));
02420
02421 if (option->state & State_HasFocus) {
02422 QColor darkoutline = option->palette.highlight().color().dark(150);
02423 QColor innerline = mergedColors(option->palette.highlight().color(), Qt::white);
02424 cachePainter.setPen(QPen(innerline, 0));
02425 if (spinBox->direction == Qt::LeftToRight) {
02426 cachePainter.drawRect(rect.adjusted(1, 2, -3 -downRect.width(), -3));
02427 cachePainter.setPen(QPen(darkoutline, 0));
02428 cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom()));
02429 cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top()));
02430 cachePainter.drawLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1));
02431 cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
02432 cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1));
02433 cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1));
02434 cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
02435 } else {
02436 cachePainter.drawRect(rect.adjusted(downRect.width() + 2, 2, -2, -3));
02437 cachePainter.setPen(QPen(darkoutline, 0));
02438 cachePainter.drawLine(QPoint(r.left() + downRect.width(), r.bottom()), QPoint(r.right()- 2 - 1, r.bottom()));
02439 cachePainter.drawLine(QPoint(r.left() + downRect.width(), r.top()), QPoint(r.right() - 2 - 1, r.top()));
02440
02441 cachePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2));
02442 cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() - 1));
02443 cachePainter.drawPoint(QPoint(r.right() - 1, r.top() + 1));
02444 cachePainter.drawLine(QPoint(r.left() + downRect.width() + 1, r.top()),
02445 QPoint(r.left() + downRect.width() + 1, r.bottom()));
02446 }
02447 }
02448 }
02449
02450
02451 cachePainter.setPen(darkOutline);
02452 QColor light = option->palette.light().color().light();
02453
02454 if (spinBox->direction == Qt::RightToLeft) {
02455 cachePainter.drawLine(upRect.right(), upRect.top() - 1, upRect.right(), downRect.bottom() + 1);
02456 cachePainter.setPen(light);
02457 cachePainter.drawLine(upRect.right() - 1, upRect.top() + 3, upRect.right() - 1, downRect.bottom() );
02458 } else {
02459 cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.left(), downRect.bottom() + 1);
02460 cachePainter.setPen(light);
02461 cachePainter.drawLine(upRect.left() + 1, upRect.top() , upRect.left() + 1, downRect.bottom() );
02462 }
02463 if (upIsActive && sunken) {
02464 cachePainter.setPen(gradientStopColor.dark(130));
02465 cachePainter.drawLine(upRect.left() + 1, upRect.top(), upRect.left() + 1, upRect.bottom());
02466 cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.right(), upRect.top() - 1);
02467 } else {
02468 cachePainter.setPen(light);
02469 cachePainter.drawLine(upRect.topLeft() + QPoint(1, -1), upRect.topRight() + QPoint(-1, -1));
02470 cachePainter.setPen(darkOutline);
02471 cachePainter.drawLine(upRect.bottomLeft(), upRect.bottomRight());
02472 }
02473 if (downIsActive && sunken) {
02474 cachePainter.setPen(gradientStopColor.dark(130));
02475 cachePainter.drawLine(downRect.left() + 1, downRect.top(), downRect.left() + 1, downRect.bottom() + 1);
02476 cachePainter.drawLine(downRect.left(), downRect.top(), downRect.right(), downRect.top());
02477 cachePainter.setPen(gradientStopColor.dark(110));
02478 cachePainter.drawLine(downRect.left(), downRect.bottom() + 1, downRect.right(), downRect.bottom() + 1);
02479 } else {
02480 cachePainter.setPen(light);
02481 cachePainter.drawLine(downRect.topLeft() + QPoint(2,0), downRect.topRight());
02482 }
02483
02484 if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) {
02485 int centerX = upRect.center().x();
02486 int centerY = upRect.center().y();
02487 cachePainter.setPen(spinBox->palette.foreground().color());
02488
02489
02490 if (spinBox->activeSubControls == SC_SpinBoxUp && sunken) {
02491 cachePainter.drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
02492 cachePainter.drawLine(1 + centerX, 1 + centerY - 2, 1 + centerX, 1 + centerY + 2);
02493 } else {
02494 cachePainter.drawLine(centerX - 2, centerY, centerX + 2, centerY);
02495 cachePainter.drawLine(centerX, centerY - 2, centerX, centerY + 2);
02496 }
02497
02498 centerX = downRect.center().x();
02499 centerY = downRect.center().y();
02500 if (spinBox->activeSubControls == SC_SpinBoxDown && sunken) {
02501 cachePainter.drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
02502 } else {
02503 cachePainter.drawLine(centerX - 2, centerY, centerX + 2, centerY);
02504 }
02505 } else {
02506
02507 QImage upArrow(qt_spinbox_button_arrow_up);
02508 upArrow.setColor(1, spinBox->palette.foreground().color().rgba());
02509
02510 cachePainter.drawImage(upRect.center().x() - upArrow.width() / 2,
02511 upRect.center().y() - upArrow.height() / 2,
02512 upArrow);
02513
02514 QImage downArrow(qt_spinbox_button_arrow_down);
02515 downArrow.setColor(1, spinBox->palette.foreground().color().rgba());
02516
02517 cachePainter.drawImage(downRect.center().x() - downArrow.width() / 2,
02518 downRect.center().y() - downArrow.height() / 2 + 1,
02519 downArrow);
02520 }
02521
02522 QColor disabledColor = option->palette.background().color();
02523 disabledColor.setAlpha(150);
02524 if (!(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled))
02525 cachePainter.fillRect(upRect, disabledColor);
02526 if (!(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled))
02527 cachePainter.fillRect(downRect.adjusted(0, 0, 0, 1), disabledColor);
02528
02529 cachePainter.end();
02530 if (UsePixmapCache)
02531 QPixmapCache::insert(pixmapName, cache);
02532 }
02533 painter->drawPixmap(spinBox->rect.topLeft(), cache);
02534 }
02535 break;
02536 #endif // QT_NO_SPINBOX
02537 case CC_TitleBar:
02538 painter->save();
02539 if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
02540 bool active = (titleBar->titleBarState & State_Active);
02541 QRect fullRect = titleBar->rect;
02542 QPalette palette = option->palette;
02543 QColor highlight = option->palette.highlight().color();
02544
02545 QColor titleBarGradientStart(active ? highlight: palette.background().color());
02546 QColor titleBarGradientStop(active ? highlight.dark(150): palette.background().color().dark(120));
02547 QColor titleBarFrameBorder(active ? highlight.dark(180): dark.dark(110));
02548 QColor titleBarHighlight(active ? highlight.light(120): palette.background().color().light(120));
02549 QColor textColor(active ? 0xffffff : 0xff000000);
02550 QColor textAlphaColor(active ? 0xffffff : 0xff000000 );
02551
02552
02553 qt_cleanlooks_draw_gradient(painter, option->rect.adjusted(1, 1, -1, 0),
02554 titleBarGradientStart,
02555 titleBarGradientStop, TopDown, active ? highlight : palette.background().color());
02556
02557
02558 painter->setPen(titleBarFrameBorder);
02559
02560
02561 painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top());
02562 painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom());
02563 painter->drawPoint(fullRect.left() + 4, fullRect.top() + 1);
02564 painter->drawPoint(fullRect.left() + 3, fullRect.top() + 1);
02565 painter->drawPoint(fullRect.left() + 2, fullRect.top() + 2);
02566 painter->drawPoint(fullRect.left() + 1, fullRect.top() + 3);
02567 painter->drawPoint(fullRect.left() + 1, fullRect.top() + 4);
02568
02569 painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom());
02570 painter->drawPoint(fullRect.right() - 3, fullRect.top() + 1);
02571 painter->drawPoint(fullRect.right() - 4, fullRect.top() + 1);
02572 painter->drawPoint(fullRect.right() - 2, fullRect.top() + 2);
02573 painter->drawPoint(fullRect.right() - 1, fullRect.top() + 3);
02574 painter->drawPoint(fullRect.right() - 1, fullRect.top() + 4);
02575
02576
02577 painter->drawLine(fullRect.right(), fullRect.bottom(), fullRect.left(), fullRect.bottom());
02578
02579
02580 painter->setPen(titleBarHighlight);
02581 painter->drawLine(fullRect.left() + 6, fullRect.top() + 1, fullRect.right() - 6, fullRect.top() + 1);
02582
02583
02584 QRect textRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget);
02585 QFont font = painter->font();
02586 font.setBold(true);
02587 painter->setFont(font);
02588 painter->setPen(active? (titleBar->palette.text().color().light(120)) :
02589 titleBar->palette.text().color() );
02590 painter->drawText(textRect.adjusted(1, 1, 1, 1), titleBar->text, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
02591 painter->setPen(Qt::white);
02592 if (active)
02593 painter->drawText(textRect, titleBar->text, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
02594
02595
02596 if ((titleBar->subControls & SC_TitleBarMinButton) && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint)) {
02597 bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver);
02598 bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken);
02599 QRect minButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget);
02600 qt_cleanlooks_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken);
02601
02602 int xoffset = 5;
02603 int yoffset = 5;
02604
02605 QRect minButtonIconRect(minButtonRect.left() + xoffset, minButtonRect.top() + yoffset,
02606 minButtonRect.width() - xoffset * 2, minButtonRect.height() - yoffset * 2);
02607
02608 painter->setPen(textColor);
02609 painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 3,
02610 minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 3);
02611 painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 4,
02612 minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 4);
02613 painter->setPen(textAlphaColor);
02614 painter->drawLine(minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 3,
02615 minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 4);
02616 painter->drawLine(minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 3,
02617 minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 4);
02618 }
02619
02620
02621 if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint)) {
02622 bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver);
02623 bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken);
02624 QRect maxButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget);
02625 qt_cleanlooks_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken);
02626
02627 int xoffset = maxButtonRect.width() / 3;
02628 int yoffset = maxButtonRect.height() / 3;
02629
02630 QRect maxButtonIconRect(maxButtonRect.left() + xoffset, maxButtonRect.top() + yoffset,
02631 maxButtonRect.width() - xoffset * 2, maxButtonRect.height() - yoffset * 2);
02632
02633 painter->setPen(textColor);
02634 painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1));
02635 painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1,
02636 maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1);
02637 painter->setPen(textAlphaColor);
02638 painter->drawPoint(maxButtonIconRect.topLeft());
02639 painter->drawPoint(maxButtonIconRect.topRight());
02640 painter->drawPoint(maxButtonIconRect.bottomLeft());
02641 painter->drawPoint(maxButtonIconRect.bottomRight());
02642 }
02643
02644
02645 if (titleBar->subControls & SC_TitleBarCloseButton) {
02646 bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver);
02647 bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken);
02648 QRect closeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget);
02649 qt_cleanlooks_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken);
02650
02651 int xoffset = 5;
02652 int yoffset = 5;
02653
02654 QRect closeIconRect(closeButtonRect.left() + xoffset, closeButtonRect.top() + yoffset,
02655 closeButtonRect.width() - xoffset * 2, closeButtonRect.height() - yoffset * 2);
02656
02657 painter->setPen(textAlphaColor);
02658 painter->drawLine(closeIconRect.left() + 1, closeIconRect.top(),
02659 closeIconRect.right(), closeIconRect.bottom() - 1);
02660 painter->drawLine(closeIconRect.left(), closeIconRect.top() + 1,
02661 closeIconRect.right() - 1, closeIconRect.bottom());
02662 painter->drawLine(closeIconRect.right() - 1, closeIconRect.top(),
02663 closeIconRect.left(), closeIconRect.bottom() - 1);
02664 painter->drawLine(closeIconRect.right(), closeIconRect.top() + 1,
02665 closeIconRect.left() + 1, closeIconRect.bottom());
02666 painter->drawPoint(closeIconRect.topLeft());
02667 painter->drawPoint(closeIconRect.topRight());
02668 painter->drawPoint(closeIconRect.bottomLeft());
02669 painter->drawPoint(closeIconRect.bottomRight());
02670
02671 painter->setPen(textColor);
02672 painter->drawLine(closeIconRect.left() + 1, closeIconRect.top() + 1,
02673 closeIconRect.right() - 1, closeIconRect.bottom() - 1);
02674 painter->drawLine(closeIconRect.left() + 1, closeIconRect.bottom() - 1,
02675 closeIconRect.right() - 1, closeIconRect.top() + 1);
02676 }
02677
02678
02679 if ((titleBar->subControls & SC_TitleBarNormalButton) &&
02680 (((titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
02681 (titleBar->titleBarState & Qt::WindowMinimized)) ||
02682 ((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
02683 (titleBar->titleBarState & Qt::WindowMaximized)))) {
02684 bool hover = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver);
02685 bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken);
02686
02687 QRect normalButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget);
02688 qt_cleanlooks_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken);
02689
02690 int xoffset = 5;
02691 int yoffset = 5;
02692
02693 QRect normalButtonIconRect(normalButtonRect.left() + xoffset, normalButtonRect.top() + yoffset,
02694 normalButtonRect.width() - xoffset * 2, normalButtonRect.height() - yoffset * 2);
02695
02696 QRect frontWindowRect = normalButtonIconRect.adjusted(0, 3, -3, 0);
02697 painter->setPen(textColor);
02698 painter->drawRect(frontWindowRect.adjusted(0, 0, -1, -1));
02699 painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1,
02700 frontWindowRect.right() - 1, frontWindowRect.top() + 1);
02701 painter->setPen(textAlphaColor);
02702 painter->drawPoint(frontWindowRect.topLeft());
02703 painter->drawPoint(frontWindowRect.topRight());
02704 painter->drawPoint(frontWindowRect.bottomLeft());
02705 painter->drawPoint(frontWindowRect.bottomRight());
02706
02707 QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3);
02708 QRegion clipRegion = backWindowRect;
02709 clipRegion -= frontWindowRect;
02710 painter->save();
02711 painter->setClipRegion(clipRegion);
02712 painter->setPen(textColor);
02713 painter->drawRect(backWindowRect.adjusted(0, 0, -1, -1));
02714 painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1,
02715 backWindowRect.right() - 1, backWindowRect.top() + 1);
02716 painter->setPen(textAlphaColor);
02717 painter->drawPoint(backWindowRect.topLeft());
02718 painter->drawPoint(backWindowRect.topRight());
02719 painter->drawPoint(backWindowRect.bottomLeft());
02720 painter->drawPoint(backWindowRect.bottomRight());
02721 painter->restore();
02722 }
02723
02724
02725 if (titleBar->subControls & SC_TitleBarContextHelpButton) {
02726 bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver);
02727 bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken);
02728 QRect contextHelpButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget);
02729
02730 qt_cleanlooks_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken);
02731
02732 QColor blend;
02733
02734 if (active) {
02735 blend = mergedColors(QColor(hover ? 0x7d8bb1 : 0x55689a),
02736 QColor(hover ? 0x939ebe : 0x7381ab));
02737 } else {
02738 blend = mergedColors(QColor(hover ? 0x9e9e9e : 0x818181),
02739 QColor(hover ? 0xababab : 0x929292));
02740 }
02741 QImage image(qt_titlebar_context_help);
02742 image.setColor(4, textColor.rgba());
02743 image.setColor(3, mergedColors(blend, textColor, 30).rgba());
02744 image.setColor(2, mergedColors(blend, textColor, 70).rgba());
02745 image.setColor(1, mergedColors(blend, textColor, 90).rgba());
02746
02747 painter->drawImage(contextHelpButtonRect, image);
02748 }
02749
02750
02751 if (titleBar->subControls & SC_TitleBarShadeButton) {
02752 bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver);
02753 bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken);
02754
02755 QRect shadeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget);
02756 qt_cleanlooks_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken);
02757 QImage image(qt_scrollbar_button_arrow_up);
02758 image.setColor(1, textColor.rgba());
02759 painter->drawImage(shadeButtonRect.adjusted(5, 7, -5, -7), image);
02760 }
02761
02762
02763 if (titleBar->subControls & SC_TitleBarUnshadeButton) {
02764 bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver);
02765 bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken);
02766
02767 QRect unshadeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget);
02768 qt_cleanlooks_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken);
02769 QImage image(qt_scrollbar_button_arrow_down);
02770 image.setColor(1, textColor.rgba());
02771 painter->drawImage(unshadeButtonRect.adjusted(5, 7, -5, -7), image);
02772 }
02773
02774 if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) {
02775 QRect iconRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget);
02776 if (!titleBar->icon.isNull()) {
02777 titleBar->icon.paint(painter, iconRect);
02778 } else {
02779 QStyleOption tool(0);
02780 tool.palette = ti