Qt 4.8
qcleanlooksstyle.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qcleanlooksstyle.h"
43 #include "qcleanlooksstyle_p.h"
44 
45 #if !defined(QT_NO_STYLE_CLEANLOOKS) || defined(QT_PLUGIN)
46 
47 #include "qwindowsstyle_p.h"
48 #include <qcombobox.h>
49 #include <qpushbutton.h>
50 #include <qpainter.h>
51 #include <qdir.h>
52 #include <qhash.h>
53 #include <qstyleoption.h>
54 #include <qapplication.h>
55 #include <qmainwindow.h>
56 #include <qfont.h>
57 #include <qgroupbox.h>
58 #include <qprocess.h>
59 #include <qpixmapcache.h>
60 #include <qdialogbuttonbox.h>
61 #include <qscrollbar.h>
62 #include <qspinbox.h>
63 #include <qslider.h>
64 #include <qsplitter.h>
65 #include <qprogressbar.h>
66 #include <qtoolbar.h>
67 #include <qwizard.h>
68 #include <qlibrary.h>
69 #include <private/qstylehelper_p.h>
70 
72 
73 using namespace QStyleHelper;
74 
75 enum Direction {
80 };
81 
82 // from windows style
83 static const int windowsItemFrame = 2; // menu item frame width
84 static const int windowsItemHMargin = 3; // menu item hor text margin
85 static const int windowsItemVMargin = 8; // menu item ver text margin
86 static const int windowsRightBorder = 15; // right border on windows
87 
88 /* XPM */
89 static const char * const dock_widget_close_xpm[] = {
90  "11 13 7 1",
91  " c None",
92  ". c #D5CFCB",
93  "+ c #8F8B88",
94  "@ c #6C6A67",
95  "# c #ABA6A3",
96  "$ c #B5B0AC",
97  "% c #A4A09D",
98  " ",
99  " +@@@@@@@+ ",
100  "+# #+",
101  "@ $@ @$ @",
102  "@ @@@ @@@ @",
103  "@ @@@@@ @",
104  "@ @@@ @",
105  "@ @@@@@ @",
106  "@ @@@ @@@ @",
107  "@ $@ @$ @",
108  "+% #+",
109  " +@@@@@@@+ ",
110  " "};
111 
112 static const char * const qt_cleanlooks_arrow_down_xpm[] = {
113  "11 7 2 1",
114  " c None",
115  "x c #000000",
116  " ",
117  " x x ",
118  " xxx xxx ",
119  " xxxxxxx ",
120  " xxxxx ",
121  " xxx ",
122  " x "};
123 
124 static const char * const qt_cleanlooks_arrow_up_xpm[] = {
125  "11 7 2 1",
126  " c None",
127  "x c #000000",
128  " x ",
129  " xxx ",
130  " xxxxx ",
131  " xxxxxxx ",
132  " xxx xxx ",
133  " x x ",
134  " "};
135 
136 static const char * const dock_widget_restore_xpm[] = {
137  "11 13 7 1",
138  " c None",
139  ". c #D5CFCB",
140  "+ c #8F8B88",
141  "@ c #6C6A67",
142  "# c #ABA6A3",
143  "$ c #B5B0AC",
144  "% c #A4A09D",
145  " ",
146  " +@@@@@@@+ ",
147  "+# #+",
148  "@ #@@@# @",
149  "@ @ @ @",
150  "@ #@@@# @ @",
151  "@ @ @ @ @",
152  "@ @ @@@ @",
153  "@ @ @ @",
154  "@ #@@@# @",
155  "+% #+",
156  " +@@@@@@@+ ",
157  " "};
158 
159 static const char * const workspace_minimize[] = {
160  "11 13 7 1",
161  " c None",
162  ". c #D5CFCB",
163  "+ c #8F8B88",
164  "@ c #6C6A67",
165  "# c #ABA6A3",
166  "$ c #B5B0AC",
167  "% c #A4A09D",
168  " ",
169  " +@@@@@@@+ ",
170  "+# #+",
171  "@ @",
172  "@ @",
173  "@ @",
174  "@ @@@@@@@ @",
175  "@ @@@@@@@ @",
176  "@ @",
177  "@ @",
178  "+% #+",
179  " +@@@@@@@+ ",
180  " "};
181 
182 
183 static const char * const qt_titlebar_context_help[] = {
184  "10 10 3 1",
185  " c None",
186  "# c #000000",
187  "+ c #444444",
188  " +####+ ",
189  " ### ### ",
190  " ## ## ",
191  " +##+ ",
192  " +## ",
193  " ## ",
194  " ## ",
195  " ",
196  " ## ",
197  " ## "};
198 
199 static const char * const qt_cleanlooks_radiobutton[] = {
200  "13 13 9 1",
201  " c None",
202  ". c #ABA094",
203  "+ c #B7ADA0",
204  "@ c #C4BBB2",
205  "# c #DDD4CD",
206  "$ c #E7E1E0",
207  "% c #F4EFED",
208  "& c #FFFAF9",
209  "* c #FCFEFB",
210  " #@...@# ",
211  " @+@#$$#+@ ",
212  " @+$%%***&@@ ",
213  "#+$%**&&**&+#",
214  "@@$&&******#@",
215  ".#**********.",
216  ".$&******&*&.",
217  ".$*&******&*.",
218  "+#********&#@",
219  "#+*********+#",
220  " @@*******@@ ",
221  " @+#%*%#+@ ",
222  " #@...+# "};
223 
224 static const char * const qt_cleanlooks_radiobutton_checked[] = {
225  "13 13 20 1",
226  " c None",
227  ". c #A8ABAE",
228  "+ c #596066",
229  "@ c #283138",
230  "# c #A9ACAF",
231  "$ c #A6A9AB",
232  "% c #6B7378",
233  "& c #8C9296",
234  "* c #A2A6AA",
235  "= c #61696F",
236  "- c #596065",
237  "; c #93989C",
238  "> c #777E83",
239  ", c #60686E",
240  "' c #252D33",
241  ") c #535B62",
242  "! c #21292E",
243  "~ c #242B31",
244  "{ c #1F262B",
245  "] c #41484E",
246  " ",
247  " ",
248  " ",
249  " .+@+# ",
250  " $%&*&=# ",
251  " -&;>,'+ ",
252  " @*>,)!@ ",
253  " +&,)~{+ ",
254  " #='!{]# ",
255  " #+@+# ",
256  " ",
257  " ",
258  " "};
259 
260 
261 static const char * const qt_scrollbar_button_arrow_left[] = {
262  "4 7 2 1",
263  " c None",
264  "* c #BFBFBF",
265  " *",
266  " **",
267  " ***",
268  "****",
269  " ***",
270  " **",
271  " *"};
272 
273 static const char * const qt_scrollbar_button_arrow_right[] = {
274  "4 7 2 1",
275  " c None",
276  "* c #BFBFBF",
277  "* ",
278  "** ",
279  "*** ",
280  "****",
281  "*** ",
282  "** ",
283  "* "};
284 
285 static const char * const qt_scrollbar_button_arrow_up[] = {
286  "7 4 2 1",
287  " c None",
288  "* c #BFBFBF",
289  " * ",
290  " *** ",
291  " ***** ",
292  "*******"};
293 
294 static const char * const qt_scrollbar_button_arrow_down[] = {
295  "7 4 2 1",
296  " c None",
297  "* c #BFBFBF",
298  "*******",
299  " ***** ",
300  " *** ",
301  " * "};
302 
303 static const char * const qt_spinbox_button_arrow_down[] = {
304  "7 4 2 1",
305  " c None",
306  "* c #BFBFBF",
307  "*******",
308  " ***** ",
309  " *** ",
310  " * "};
311 
312 static const char * const qt_spinbox_button_arrow_up[] = {
313  "7 4 2 1",
314  " c None",
315  "* c #BFBFBF",
316  " * ",
317  " *** ",
318  " ***** ",
319  "*******"};
320 
321 static const char * const qt_scrollbar_button_left[] = {
322  "16 16 6 1",
323  " c None",
324  ". c #BFBFBF",
325  "+ c #979797",
326  "# c #FAFAFA",
327  "< c #FAFAFA",
328  "* c #FAFAFA",
329  " .++++++++++++++",
330  ".+#############+",
331  "+# <+",
332  "+# <+",
333  "+# <+",
334  "+# <+",
335  "+# <+",
336  "+# <+",
337  "+# <+",
338  "+# <+",
339  "+# <+",
340  "+# <+",
341  "+# <+",
342  "+# <+",
343  ".+<<<<<<<<<<<<<+",
344  " .++++++++++++++"};
345 
346 static const char * const qt_scrollbar_button_right[] = {
347  "16 16 6 1",
348  " c None",
349  ". c #BFBFBF",
350  "+ c #979797",
351  "# c #FAFAFA",
352  "< c #FAFAFA",
353  "* c #FAFAFA",
354  "++++++++++++++. ",
355  "+#############+.",
356  "+# <+",
357  "+# <+",
358  "+# <+",
359  "+# <+",
360  "+# <+",
361  "+# <+",
362  "+# <+",
363  "+# <+",
364  "+# <+",
365  "+# <+",
366  "+# <+",
367  "+# <+",
368  "+<<<<<<<<<<<<<+.",
369  "++++++++++++++. "};
370 
371 static const char * const qt_scrollbar_button_up[] = {
372  "16 16 6 1",
373  " c None",
374  ". c #BFBFBF",
375  "+ c #979797",
376  "# c #FAFAFA",
377  "< c #FAFAFA",
378  "* c #FAFAFA",
379  " .++++++++++++. ",
380  ".+############+.",
381  "+# <+",
382  "+# <+",
383  "+# <+",
384  "+# <+",
385  "+# <+",
386  "+# <+",
387  "+# <+",
388  "+# <+",
389  "+# <+",
390  "+# <+",
391  "+# <+",
392  "+# <+",
393  "+<<<<<<<<<<<<<<+",
394  "++++++++++++++++"};
395 
396 static const char * const qt_scrollbar_button_down[] = {
397  "16 16 6 1",
398  " c None",
399  ". c #BFBFBF",
400  "+ c #979797",
401  "# c #FAFAFA",
402  "< c #FAFAFA",
403  "* c #FAFAFA",
404  "++++++++++++++++",
405  "+##############+",
406  "+# <+",
407  "+# <+",
408  "+# <+",
409  "+# <+",
410  "+# <+",
411  "+# <+",
412  "+# <+",
413  "+# <+",
414  "+# <+",
415  "+# <+",
416  "+# <+",
417  "+# <+",
418  ".+<<<<<<<<<<<<+.",
419  " .++++++++++++. "};
420 
421 static const char * const qt_cleanlooks_menuitem_checkbox_checked[] = {
422  "8 7 6 1",
423  " g None",
424  ". g #959595",
425  "+ g #676767",
426  "@ g #454545",
427  "# g #1D1D1D",
428  "0 g #101010",
429  " ..",
430  " .+ ",
431  " .+ ",
432  "0 .@ ",
433  "@#++. ",
434  " @# ",
435  " . "};
436 
437 static const char * const qt_cleanlooks_checkbox_checked[] = {
438  "13 13 3 1",
439  " c None",
440  ". c #272D33",
441  "% c #666666",
442 
443  " ",
444  " % ",
445  " %. ",
446  " %.% ",
447  " %.. ",
448  " %.% %.. ",
449  " %..%..% ",
450  " %...% ",
451  " %..% ",
452  " %.% ",
453  " % ",
454  " ",
455  " "};
456 
457 static void qt_cleanlooks_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart,
458  const QColor &gradientStop, Direction direction = TopDown, QBrush bgBrush = QBrush())
459 {
460  int x = rect.center().x();
461  int y = rect.center().y();
462  QLinearGradient *gradient;
463  switch(direction) {
464  case FromLeft:
465  gradient = new QLinearGradient(rect.left(), y, rect.right(), y);
466  break;
467  case FromRight:
468  gradient = new QLinearGradient(rect.right(), y, rect.left(), y);
469  break;
470  case BottomUp:
471  gradient = new QLinearGradient(x, rect.bottom(), x, rect.top());
472  break;
473  case TopDown:
474  default:
475  gradient = new QLinearGradient(x, rect.top(), x, rect.bottom());
476  break;
477  }
478  if (bgBrush.gradient())
479  gradient->setStops(bgBrush.gradient()->stops());
480  else {
481  gradient->setColorAt(0, gradientStart);
482  gradient->setColorAt(1, gradientStop);
483  }
484  painter->fillRect(rect, *gradient);
485  delete gradient;
486 }
487 
488 static void qt_cleanlooks_draw_buttongradient(QPainter *painter, const QRect &rect, const QColor &gradientStart,
489  const QColor &gradientMid, const QColor &gradientStop, Direction direction = TopDown,
490  QBrush bgBrush = QBrush())
491 {
492  int x = rect.center().x();
493  int y = rect.center().y();
494  QLinearGradient *gradient;
495  bool horizontal = false;
496  switch(direction) {
497  case FromLeft:
498  horizontal = true;
499  gradient = new QLinearGradient(rect.left(), y, rect.right(), y);
500  break;
501  case FromRight:
502  horizontal = true;
503  gradient = new QLinearGradient(rect.right(), y, rect.left(), y);
504  break;
505  case BottomUp:
506  gradient = new QLinearGradient(x, rect.bottom(), x, rect.top());
507  break;
508  case TopDown:
509  default:
510  gradient = new QLinearGradient(x, rect.top(), x, rect.bottom());
511  break;
512  }
513  if (bgBrush.gradient())
514  gradient->setStops(bgBrush.gradient()->stops());
515  else {
516  int size = horizontal ? rect.width() : rect.height() ;
517  if (size > 4) {
518  float edge = 4.0/(float)size;
519  gradient->setColorAt(0, gradientStart);
520  gradient->setColorAt(edge, gradientMid.lighter(104));
521  gradient->setColorAt(1.0 - edge, gradientMid.darker(100));
522  gradient->setColorAt(1.0, gradientStop);
523  }
524  }
525  painter->fillRect(rect, *gradient);
526  delete gradient;
527 }
528 
529 static void qt_cleanlooks_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken)
530 {
531  QColor dark;
532  dark.setHsv(option->palette.button().color().hue(),
533  qMin(255, (int)(option->palette.button().color().saturation()*1.9)),
534  qMin(255, (int)(option->palette.button().color().value()*0.7)));
535 
536  QColor highlight = option->palette.highlight().color();
537 
538  bool active = (option->titleBarState & QStyle::State_Active);
539  QColor titleBarHighlight(255, 255, 255, 60);
540 
541  if (sunken)
542  painter->fillRect(tmp.adjusted(1, 1, -1, -1), option->palette.highlight().color().darker(120));
543  else if (hover)
544  painter->fillRect(tmp.adjusted(1, 1, -1, -1), QColor(255, 255, 255, 20));
545 
546  QColor mdiButtonGradientStartColor;
547  QColor mdiButtonGradientStopColor;
548 
549  mdiButtonGradientStartColor = QColor(0, 0, 0, 40);
550  mdiButtonGradientStopColor = QColor(255, 255, 255, 60);
551 
552  if (sunken)
553  titleBarHighlight = highlight.darker(130);
554 
555  QLinearGradient gradient(tmp.center().x(), tmp.top(), tmp.center().x(), tmp.bottom());
556  gradient.setColorAt(0, mdiButtonGradientStartColor);
557  gradient.setColorAt(1, mdiButtonGradientStopColor);
558  QColor mdiButtonBorderColor(active ? option->palette.highlight().color().darker(180): dark.darker(110));
559 
560  painter->setPen(QPen(mdiButtonBorderColor, 1));
561  const QLine lines[4] = {
562  QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()),
563  QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()),
564  QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2),
565  QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2)
566  };
567  painter->drawLines(lines, 4);
568  const QPoint points[4] = {
569  QPoint(tmp.left() + 1, tmp.top() + 1),
570  QPoint(tmp.right() - 1, tmp.top() + 1),
571  QPoint(tmp.left() + 1, tmp.bottom() - 1),
572  QPoint(tmp.right() - 1, tmp.bottom() - 1)
573  };
574  painter->drawPoints(points, 4);
575 
576  painter->setPen(titleBarHighlight);
577  painter->drawLine(tmp.left() + 2, tmp.top() + 1, tmp.right() - 2, tmp.top() + 1);
578  painter->drawLine(tmp.left() + 1, tmp.top() + 2, tmp.left() + 1, tmp.bottom() - 2);
579 
580  painter->setPen(QPen(gradient, 1));
581  painter->drawLine(tmp.right() + 1, tmp.top() + 2, tmp.right() + 1, tmp.bottom() - 2);
582  painter->drawPoint(tmp.right() , tmp.top() + 1);
583 
584  painter->drawLine(tmp.left() + 2, tmp.bottom() + 1, tmp.right() - 2, tmp.bottom() + 1);
585  painter->drawPoint(tmp.left() + 1, tmp.bottom());
586  painter->drawPoint(tmp.right() - 1, tmp.bottom());
587  painter->drawPoint(tmp.right() , tmp.bottom() - 1);
588 }
589 
611 {
612  setObjectName(QLatin1String("CleanLooks"));
613 }
614 
624 {
625 }
626 
631 {
632 }
633 
652 void QCleanlooksStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
653  bool enabled, const QString& text, QPalette::ColorRole textRole) const
654 {
655  if (text.isEmpty())
656  return;
657 
658  QPen savedPen = painter->pen();
659  if (textRole != QPalette::NoRole) {
660  painter->setPen(QPen(pal.brush(textRole), savedPen.widthF()));
661  }
662  if (!enabled) {
663  QPen pen = painter->pen();
664  painter->setPen(pen);
665  }
666  painter->drawText(rect, alignment, text);
667  painter->setPen(savedPen);
668 }
669 
670 static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50)
671 {
672  const int maxFactor = 100;
673  QColor tmp = colorA;
674  tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor);
675  tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor);
676  tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor);
677  return tmp;
678 }
679 
684  const QStyleOption *option,
685  QPainter *painter, const QWidget *widget) const
686 {
687  Q_ASSERT(option);
688  QRect rect = option->rect;
689  int state = option->state;
690  QColor button = option->palette.button().color();
691  QColor buttonShadow = option->palette.button().color().darker(110);
692  QColor buttonShadowAlpha = buttonShadow;
693  buttonShadowAlpha.setAlpha(128);
694  QColor darkOutline;
695  QColor dark;
696  darkOutline.setHsv(button.hue(),
697  qMin(255, (int)(button.saturation()*3.0)),
698  qMin(255, (int)(button.value()*0.6)));
699  dark.setHsv(button.hue(),
700  qMin(255, (int)(button.saturation()*1.9)),
701  qMin(255, (int)(button.value()*0.7)));
702  QColor tabFrameColor = mergedColors(option->palette.background().color(),
703  dark.lighter(135), 60);
704 
705  switch(elem) {
706 #ifndef QT_NO_TABBAR
707  case PE_FrameTabBarBase:
708  if (const QStyleOptionTabBarBase *tbb
709  = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) {
710  painter->save();
711  painter->setPen(QPen(darkOutline.lighter(110), 0));
712  switch (tbb->shape) {
713  case QTabBar::RoundedNorth: {
714  QRegion region(tbb->rect);
715  region -= tbb->selectedTabRect;
716  painter->drawLine(tbb->rect.topLeft(), tbb->rect.topRight());
717  painter->setClipRegion(region);
718  painter->setPen(option->palette.light().color());
719  painter->drawLine(tbb->rect.topLeft() + QPoint(0, 1),
720  tbb->rect.topRight() + QPoint(0, 1));
721  }
722  break;
724  painter->drawLine(tbb->rect.left(), tbb->rect.top(), tbb->rect.left(), tbb->rect.bottom());
725  break;
727  painter->drawLine(tbb->rect.left(), tbb->rect.bottom(),
728  tbb->rect.right(), tbb->rect.bottom());
729  break;
731  painter->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight());
732  break;
737  painter->restore();
738  QWindowsStyle::drawPrimitive(elem, option, painter, widget);
739  return;
740  }
741  painter->restore();
742  }
743  return;
744 #endif // QT_NO_TABBAR
746  {
747  QStyleOptionButton button;
748  button.QStyleOption::operator=(*option);
749  button.state &= ~State_MouseOver;
750  proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget);
751  }
752  return;
754  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
755  QRect r = header->rect;
756  QImage arrow;
757  if (header->sortIndicator & QStyleOptionHeader::SortUp)
759  else if (header->sortIndicator & QStyleOptionHeader::SortDown)
761  if (!arrow.isNull()) {
762  r.setSize(arrow.size());
763  r.moveCenter(header->rect.center());
764  arrow.setColor(1, header->palette.foreground().color().rgba());
765  painter->drawImage(r, arrow);
766  }
767  }
768  break;
770  proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
771  break;
773  {
774  QRect rect = option->rect;
775  const int margin = 6;
776  if (option->state & State_Horizontal) {
777  const int offset = rect.width()/2;
778  painter->setPen(QPen(option->palette.background().color().darker(110)));
779  painter->drawLine(rect.bottomLeft().x() + offset,
780  rect.bottomLeft().y() - margin,
781  rect.topLeft().x() + offset,
782  rect.topLeft().y() + margin);
783  painter->setPen(QPen(option->palette.background().color().lighter(110)));
784  painter->drawLine(rect.bottomLeft().x() + offset + 1,
785  rect.bottomLeft().y() - margin,
786  rect.topLeft().x() + offset + 1,
787  rect.topLeft().y() + margin);
788  } else { //Draw vertical separator
789  const int offset = rect.height()/2;
790  painter->setPen(QPen(option->palette.background().color().darker(110)));
791  painter->drawLine(rect.topLeft().x() + margin ,
792  rect.topLeft().y() + offset,
793  rect.topRight().x() - margin,
794  rect.topRight().y() + offset);
795  painter->setPen(QPen(option->palette.background().color().lighter(110)));
796  painter->drawLine(rect.topLeft().x() + margin ,
797  rect.topLeft().y() + offset + 1,
798  rect.topRight().x() - margin,
799  rect.topRight().y() + offset + 1);
800  }
801  }
802  break;
803  case PE_Frame:
804  painter->save();
805  painter->setPen(dark.lighter(108));
806  painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
807  painter->restore();
808  break;
809  case PE_FrameMenu:
810  painter->save();
811  {
812  painter->setPen(QPen(darkOutline, 1));
813  painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
814  QColor frameLight = option->palette.background().color().lighter(160);
815  QColor frameShadow = option->palette.background().color().darker(110);
816 
817  //paint beveleffect
818  QRect frame = option->rect.adjusted(1, 1, -1, -1);
819  painter->setPen(frameLight);
820  painter->drawLine(frame.topLeft(), frame.bottomLeft());
821  painter->drawLine(frame.topLeft(), frame.topRight());
822 
823  painter->setPen(frameShadow);
824  painter->drawLine(frame.topRight(), frame.bottomRight());
825  painter->drawLine(frame.bottomLeft(), frame.bottomRight());
826  }
827  painter->restore();
828  break;
829  case PE_FrameDockWidget:
830 
831  painter->save();
832  {
833  QColor softshadow = option->palette.background().color().darker(120);
834 
835  QRect rect= option->rect;
836  painter->setPen(softshadow);
837  painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
838  painter->setPen(QPen(option->palette.light(), 0));
839  painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), QPoint(rect.left() + 1, rect.bottom() - 1));
840  painter->setPen(QPen(option->palette.background().color().darker(120), 0));
841  painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1), QPoint(rect.right() - 2, rect.bottom() - 1));
842  painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1), QPoint(rect.right() - 1, rect.bottom() - 1));
843 
844  }
845  painter->restore();
846  break;
847  case PE_PanelButtonTool:
848  painter->save();
849  if ((option->state & State_Enabled || option->state & State_On) || !(option->state & State_AutoRaise)) {
850  QPen oldPen = painter->pen();
851 
852  if (widget && widget->inherits("QDockWidgetTitleButton")) {
853  if (option->state & State_MouseOver)
854  proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
855  } else {
856  proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
857  }
858  }
859  painter->restore();
860  break;
862  {
863  QStyleOption dockWidgetHandle = *option;
864  bool horizontal = option->state & State_Horizontal;
865  if (horizontal)
866  dockWidgetHandle.state &= ~State_Horizontal;
867  else
868  dockWidgetHandle.state |= State_Horizontal;
869  proxy()->drawControl(CE_Splitter, &dockWidgetHandle, painter, widget);
870  }
871  break;
872  case PE_FrameWindow:
873  painter->save();
874  {
875  QRect rect= option->rect;
876  painter->setPen(QPen(dark.darker(150), 0));
877  painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
878  painter->setPen(QPen(option->palette.light(), 0));
879  painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
880  QPoint(rect.left() + 1, rect.bottom() - 1));
881  painter->setPen(QPen(option->palette.background().color().darker(120), 0));
882  painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1),
883  QPoint(rect.right() - 2, rect.bottom() - 1));
884  painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1),
885  QPoint(rect.right() - 1, rect.bottom() - 1));
886  }
887  painter->restore();
888  break;
889 #ifndef QT_NO_LINEEDIT
890  case PE_FrameLineEdit:
891  // fall through
892 #endif // QT_NO_LINEEDIT
893 #ifdef QT3_SUPPORT
894  if (widget && widget->inherits("Q3ToolBar")) {
895  proxy()->drawPrimitive(PE_Q3Separator, option, painter, widget);
896  break;
897  }
898 #endif
899  {
900  QPen oldPen = painter->pen();
901  if (option->state & State_Enabled) {
902  painter->setPen(QPen(option->palette.background(), 0));
903  painter->drawRect(rect.adjusted(0, 0, 0, 0));
904  painter->drawRect(rect.adjusted(1, 1, -1, -1));
905  } else {
906  painter->fillRect(rect, option->palette.background());
907  }
908  QRect r = rect.adjusted(0, 1, 0, -1);
909  painter->setPen(buttonShadowAlpha);
910  painter->drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1));
911  const QPoint points[8] = {
912  QPoint(r.right() - 1, r.top()),
913  QPoint(r.right(), r.top() + 1),
914  QPoint(r.right() - 1, r.bottom()),
915  QPoint(r.right(), r.bottom() - 1),
916  QPoint(r.left() + 1, r.top() ),
917  QPoint(r.left(), r.top() + 1),
918  QPoint(r.left() + 1, r.bottom() ),
919  QPoint(r.left(), r.bottom() - 1)
920  };
921  painter->drawPoints(points, 8);
922  painter->setPen(QPen(option->palette.background().color(), 1));
923  painter->drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1));
924 
925  if (option->state & State_HasFocus) {
926  QColor darkoutline = option->palette.highlight().color().darker(150);
927  QColor innerline = mergedColors(option->palette.highlight().color(), Qt::white);
928  painter->setPen(QPen(innerline, 0));
929  painter->drawRect(rect.adjusted(1, 2, -2, -3));
930  painter->setPen(QPen(darkoutline, 0));
931  }
932  else {
933  QColor highlight = Qt::white;
934  highlight.setAlpha(130);
935  painter->setPen(option->palette.base().color().darker(120));
936  painter->drawLine(QPoint(r.left() + 1, r.top() + 1),
937  QPoint(r.right() - 1, r.top() + 1));
938  painter->drawLine(QPoint(r.left() + 1, r.top() + 1),
939  QPoint(r.left() + 1, r.bottom() - 1));
940  painter->setPen(option->palette.base().color());
941  painter->drawLine(QPoint(r.right() - 1, r.top() + 1),
942  QPoint(r.right() - 1, r.bottom() - 1));
943  painter->setPen(highlight);
944  painter->drawLine(QPoint(r.left() + 1, r.bottom() + 1),
945  QPoint(r.right() - 1, r.bottom() + 1));
946  painter->drawPoint(QPoint(r.left(), r.bottom()));
947  painter->drawPoint(QPoint(r.right(), r.bottom() ));
948  painter->setPen(QPen(darkOutline.lighter(115), 1));
949  }
950  painter->drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
951  painter->drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2));
952  painter->drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right() - 2, r.bottom()));
953  const QPoint points2[4] = {
954  QPoint(r.right() - 1, r.bottom() - 1),
955  QPoint(r.right() - 1, r.top() + 1),
956  QPoint(r.left() + 1, r.bottom() - 1),
957  QPoint(r.left() + 1, r.top() + 1)
958  };
959  painter->drawPoints(points2, 4);
960  painter->drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top()));
961  painter->setPen(oldPen);
962  }
963  break;
965  painter->save();
966  if (const QStyleOptionButton *checkbox = qstyleoption_cast<const QStyleOptionButton*>(option)) {
967  QRect checkRect;
968  checkRect.setX(rect.left() );
969  checkRect.setY(rect.top() );
970  checkRect.setWidth(rect.width() - 1);
971  checkRect.setHeight(rect.height() - 1);
972  if (state & State_Sunken)
973  painter->setBrush(dark.lighter(130));
974  else
975  painter->setBrush(option->palette.base());
976  painter->setPen(QPen(dark.lighter(110), 0));
977  painter->drawRect(checkRect);
978  if (checkbox->state & (State_On | State_Sunken | State_NoChange)) {
980  QColor fillColor = option->palette.text().color();
981  image.setColor(1, fillColor.rgba());
982  fillColor.setAlpha(100);
983  image.setColor(2, fillColor.rgba());
984  painter->drawImage(rect, image);
985  if (checkbox->state & State_NoChange) {
986  QColor bgc = option->palette.background().color();
987  bgc.setAlpha(127);
988  painter->fillRect(checkRect.adjusted(1, 1, -1, -1), bgc);
989  }
990  }
991  }
992  painter->restore();
993  break;
995  painter->save();
996  {
998  QRect checkRect = rect.adjusted(0, 0, 0, 0);
999  if (state & (State_On )) {
1000  painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton));
1001  painter->drawImage(checkRect, QImage(qt_cleanlooks_radiobutton_checked));
1002  }
1003  else if (state & State_Sunken) {
1004  painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton));
1005  QColor bgc = buttonShadow;
1007  painter->setBrush(bgc);
1008  painter->setPen(Qt::NoPen);
1009  painter->drawEllipse(rect.adjusted(1, 1, -1, -1)); }
1010  else {
1011  painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton));
1012  }
1013  }
1014  painter->restore();
1015  break;
1017  painter->save();
1018  if (option->state & State_Horizontal) {
1019  for (int i = rect.height()/5; i <= 4*(rect.height()/5) ; ++i) {
1020  int y = rect.topLeft().y() + i + 1;
1021  int x1 = rect.topLeft().x() + 3;
1022  int x2 = rect.topRight().x() - 2;
1023 
1024  if (i % 2 == 0)
1025  painter->setPen(QPen(option->palette.light(), 0));
1026  else
1027  painter->setPen(QPen(dark.lighter(110), 0));
1028  painter->drawLine(x1, y, x2, y);
1029  }
1030  }
1031  else { //vertical toolbar
1032  for (int i = rect.width()/5; i <= 4*(rect.width()/5) ; ++i) {
1033  int x = rect.topLeft().x() + i + 1;
1034  int y1 = rect.topLeft().y() + 3;
1035  int y2 = rect.topLeft().y() + 5;
1036 
1037  if (i % 2 == 0)
1038  painter->setPen(QPen(option->palette.light(), 0));
1039  else
1040  painter->setPen(QPen(dark.lighter(110), 0));
1041  painter->drawLine(x, y1, x, y2);
1042  }
1043  }
1044  painter->restore();
1045  break;
1046  case PE_FrameDefaultButton:
1047  case PE_FrameFocusRect:
1048  if (const QStyleOptionFocusRect *focusFrame = qstyleoption_cast<const QStyleOptionFocusRect *>(option)) {
1049  if (!(focusFrame->state & State_KeyboardFocusChange))
1050  return;
1051  QRect rect = focusFrame->rect;
1052  painter->save();
1054  painter->setBrush(QBrush(dark.darker(120), Qt::Dense4Pattern));
1055  painter->setBrushOrigin(rect.topLeft());
1056  painter->setPen(Qt::NoPen);
1057  const QRect rects[4] = {
1058  QRect(rect.left(), rect.top(), rect.width(), 1), // Top
1059  QRect(rect.left(), rect.bottom(), rect.width(), 1), // Bottom
1060  QRect(rect.left(), rect.top(), 1, rect.height()), // Left
1061  QRect(rect.right(), rect.top(), 1, rect.height()) // Right
1062  };
1063  painter->drawRects(rects, 4);
1064  painter->restore();
1065  }
1066  break;
1067  case PE_PanelButtonCommand:
1068  {
1069  bool isDefault = false;
1070  bool isFlat = false;
1071  bool isDown = (option->state & State_Sunken) || (option->state & State_On);
1072  QPen oldPen = painter->pen();
1073  QBrush oldBrush = painter->brush();
1074  QRect r;
1075 
1076  if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option)) {
1077  isDefault = (button->features & QStyleOptionButton::DefaultButton) && (button->state & State_Enabled);
1078  isFlat = (button->features & QStyleOptionButton::Flat);
1079  }
1080 
1081  if (isFlat && !isDown) {
1082  if (isDefault) {
1083  r = option->rect.adjusted(0, 1, 0, -1);
1084  painter->setPen(QPen(Qt::black, 0));
1085  const QLine lines[4] = {
1086  QLine(QPoint(r.left() + 2, r.top()),
1087  QPoint(r.right() - 2, r.top())),
1088  QLine(QPoint(r.left(), r.top() + 2),
1089  QPoint(r.left(), r.bottom() - 2)),
1090  QLine(QPoint(r.right(), r.top() + 2),
1091  QPoint(r.right(), r.bottom() - 2)),
1092  QLine(QPoint(r.left() + 2, r.bottom()),
1093  QPoint(r.right() - 2, r.bottom()))
1094  };
1095  painter->drawLines(lines, 4);
1096  const QPoint points[4] = {
1097  QPoint(r.right() - 1, r.bottom() - 1),
1098  QPoint(r.right() - 1, r.top() + 1),
1099  QPoint(r.left() + 1, r.bottom() - 1),
1100  QPoint(r.left() + 1, r.top() + 1)
1101  };
1102  painter->drawPoints(points, 4);
1103  painter->setPen(oldPen);
1104  }
1105  return;
1106  }
1107 
1108  BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("pushbutton-%1").arg(isDefault))
1109  r = rect.adjusted(0, 1, 0, -1);
1110 
1111  bool isEnabled = (option->state & State_Enabled);
1112 
1113  QColor highlightedGradientStartColor = option->palette.button().color().lighter(107);
1114  QColor highlightedGradientMidColor = option->palette.button().color().lighter(105);
1115  QColor highlightedGradientStopColor = buttonShadow.lighter(107);
1116  QColor gradientStartColor = option->palette.button().color().lighter(108);
1117 
1118  QColor buttonColor = option->palette.button().color();
1119  QColor gradientMidColor = option->palette.button().color();
1120  QColor gradientStopColor;
1121  gradientStopColor.setHsv(buttonColor.hue(),
1122  qMin(255, (int)(buttonColor.saturation()*1.9)),
1123  qMin(255, (int)(buttonColor.value()*0.96)));
1124 
1125  QRect gradRect = rect.adjusted(1, 2, -1, -2);
1126  // gradient fill
1127  QRect innerBorder = r.adjusted(1, 1, -1, 0);
1128 
1129  if (isDown) {
1130  QBrush fillColor = gradientStopColor.darker(110);
1131  if (option->palette.button().gradient())
1132  fillColor = option->palette.button();
1133  p->fillRect(gradRect, fillColor);
1134  p->setPen(gradientStopColor.darker(125));
1135  p->drawLine(innerBorder.topLeft(), innerBorder.topRight());
1136  p->drawLine(innerBorder.topLeft(), innerBorder.bottomLeft());
1137  } else {
1138  if (isEnabled && option->state & State_MouseOver ) {
1140  highlightedGradientStartColor,
1141  highlightedGradientMidColor,
1142  highlightedGradientStopColor, TopDown, option->palette.button());
1143  } else {
1145  gradientStartColor,
1146  gradientMidColor,
1147  gradientStopColor, TopDown, option->palette.button());
1148  }
1149  }
1150 
1151  bool hasFocus = option->state & State_HasFocus;
1152 
1153  if (!isEnabled)
1154  p->setPen(QPen(dark.lighter(115)));
1155  else if (isDefault)
1156  p->setPen(QPen(Qt::black, 1));
1157  else
1158  p->setPen(QPen(darkOutline, 1));
1159 
1160  p->drawLine(QPoint(r.left(), r.top() + 2),
1161  QPoint(r.left(), r.bottom() - 2));
1162  p->drawLine(QPoint(r.right(), r.top() + 2),
1163  QPoint(r.right(), r.bottom() - 2));
1164  p->drawLine(QPoint(r.left() + 2, r.bottom()),
1165  QPoint(r.right() - 2, r.bottom()));
1166  const QPoint points[4] = {
1167  QPoint(r.right() - 1, r.bottom() - 1),
1168  QPoint(r.right() - 1, r.top() + 1),
1169  QPoint(r.left() + 1, r.bottom() - 1),
1170  QPoint(r.left() + 1, r.top() + 1)
1171  };
1172  p->drawPoints(points, 4);
1173 
1174  if (!isDefault && !hasFocus && isEnabled)
1175  p->setPen(QPen(darkOutline.darker(110), 0));
1176 
1177  p->drawLine(QPoint(r.left() + 2, r.top()),
1178  QPoint(r.right() - 2, r.top()));
1179 
1180  QColor highlight = Qt::white;
1181  highlight.setAlpha(110);
1182  p->setPen(highlight);
1183  p->drawLine(QPoint(r.left() + 1, r.top() + 2),
1184  QPoint(r.left() + 1, r.bottom() - 2));
1185  p->drawLine(QPoint(r.left() + 3, r.bottom() + 1),
1186  QPoint(r.right() - 3, r.bottom() + 1));
1187 
1188  QColor topShadow = darkOutline;
1189  topShadow.setAlpha(60);
1190 
1191  p->setPen(topShadow);
1192  const QPoint points2[8] = {
1193  QPoint(r.right(), r.top() + 1),
1194  QPoint(r.right() - 1, r.top() ),
1195  QPoint(r.right(), r.bottom() - 1),
1196  QPoint(r.right() - 1, r.bottom() ),
1197  QPoint(r.left() + 1, r.bottom()),
1198  QPoint(r.left(), r.bottom() - 1),
1199  QPoint(r.left() + 1, r.top()),
1200  QPoint(r.left(), r.top() + 1)
1201  };
1202  p->drawPoints(points2, 8);
1203 
1204  topShadow.setAlpha(30);
1205  p->setPen(topShadow);
1206 
1207  p->drawLine(QPoint(r.right() - 1, r.top() + 2),
1208  QPoint(r.right() - 1, r.bottom() - 2));
1209  p->drawLine(QPoint(r.left() + 2, r.top() - 1),
1210  QPoint(r.right() - 2, r.top() - 1));
1211 
1212  if (isDefault) {
1213  r.adjust(-1, -1, 1, 1);
1214  p->setPen(buttonShadowAlpha.darker(120));
1215  const QLine lines[4] = {
1216  QLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0)),
1217  QLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0)),
1218  QLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3)),
1219  QLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3))
1220  };
1221  p->drawLines(lines, 4);
1222  const QPoint points3[8] = {
1223  r.topRight() + QPoint(-2, 1),
1224  r.topRight() + QPoint(-1, 2),
1225  r.bottomRight() + QPoint(-1, -2),
1226  r.bottomRight() + QPoint(-2, -1),
1227  r.topLeft() + QPoint(1, 2),
1228  r.topLeft() + QPoint(2, 1),
1229  r.bottomLeft() + QPoint(1, -2),
1230  r.bottomLeft() + QPoint(2, -1)
1231  };
1232  p->drawPoints(points3, 8);
1233  }
1234  painter->setPen(oldPen);
1235  painter->setBrush(oldBrush);
1237  }
1238  break;
1239 #ifndef QT_NO_TABBAR
1240  case PE_FrameTabWidget:
1241  painter->save();
1242  {
1243  painter->fillRect(option->rect, tabFrameColor);
1244  }
1245 #ifndef QT_NO_TABWIDGET
1246  if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {
1247  QColor borderColor = darkOutline.lighter(110);
1248  QColor alphaCornerColor = mergedColors(borderColor, option->palette.background().color());
1249 
1250  int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, twf, widget);
1251  bool reverse = (twf->direction == Qt::RightToLeft);
1252  QRect tabBarRect;
1253 
1254  switch (twf->shape) {
1255  case QTabBar::RoundedNorth:
1256  if (reverse) {
1257  tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width()
1258  - twf->tabBarSize.width() + 1,
1259  twf->rect.top(),
1260  twf->tabBarSize.width(), borderThickness);
1261  } else {
1262  tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(),
1263  twf->rect.top(),
1264  twf->tabBarSize.width(), borderThickness);
1265  }
1266  break ;
1267  case QTabBar::RoundedWest:
1268  tabBarRect = QRect(twf->rect.left(),
1269  twf->rect.top() + twf->leftCornerWidgetSize.height(),
1270  borderThickness,
1271  twf->tabBarSize.height());
1272  tabBarRect = tabBarRect; //adjust
1273  break ;
1274  case QTabBar::RoundedEast:
1275  tabBarRect = QRect(twf->rect.right() - borderThickness + 1,
1276  twf->rect.top() + twf->leftCornerWidgetSize.height(),
1277  0,
1278  twf->tabBarSize.height());
1279  break ;
1280  case QTabBar::RoundedSouth:
1281  if (reverse) {
1282  tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width() - twf->tabBarSize.width() + 1,
1283  twf->rect.bottom() + 1,
1284  twf->tabBarSize.width(),
1285  borderThickness);
1286  } else {
1287  tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(),
1288  twf->rect.bottom() + 1,
1289  twf->tabBarSize.width(),
1290  borderThickness);
1291  }
1292  break;
1293  default:
1294  break;
1295  }
1296 
1297  QRegion region(twf->rect);
1298  region -= tabBarRect;
1299  painter->setClipRegion(region);
1300 
1301  // Outer border
1302  QLine leftLine = QLine(twf->rect.topLeft() + QPoint(0, 2), twf->rect.bottomLeft() - QPoint(0, 2));
1303  QLine rightLine = QLine(twf->rect.topRight(), twf->rect.bottomRight() - QPoint(0, 2));
1304  QLine bottomLine = QLine(twf->rect.bottomLeft() + QPoint(2, 0), twf->rect.bottomRight() - QPoint(2, 0));
1305  QLine topLine = QLine(twf->rect.topLeft(), twf->rect.topRight());
1306 
1307  painter->setPen(borderColor);
1308  painter->drawLine(topLine);
1309 
1310  // Inner border
1311  QLine innerLeftLine = QLine(leftLine.p1() + QPoint(1, 0), leftLine.p2() + QPoint(1, 0));
1312  QLine innerRightLine = QLine(rightLine.p1() - QPoint(1, -1), rightLine.p2() - QPoint(1, 0));
1313  QLine innerBottomLine = QLine(bottomLine.p1() - QPoint(0, 1), bottomLine.p2() - QPoint(0, 1));
1314  QLine innerTopLine = QLine(topLine.p1() + QPoint(0, 1), topLine.p2() + QPoint(-1, 1));
1315 
1316  // Rounded Corner
1317  QPoint leftBottomOuterCorner = QPoint(innerLeftLine.p2() + QPoint(0, 1));
1318  QPoint leftBottomInnerCorner1 = QPoint(leftLine.p2() + QPoint(0, 1));
1319  QPoint leftBottomInnerCorner2 = QPoint(bottomLine.p1() - QPoint(1, 0));
1320  QPoint rightBottomOuterCorner = QPoint(innerRightLine.p2() + QPoint(0, 1));
1321  QPoint rightBottomInnerCorner1 = QPoint(rightLine.p2() + QPoint(0, 1));
1322  QPoint rightBottomInnerCorner2 = QPoint(bottomLine.p2() + QPoint(1, 0));
1323  QPoint leftTopOuterCorner = QPoint(innerLeftLine.p1() - QPoint(0, 1));
1324  QPoint leftTopInnerCorner1 = QPoint(leftLine.p1() - QPoint(0, 1));
1325  QPoint leftTopInnerCorner2 = QPoint(topLine.p1() - QPoint(1, 0));
1326 
1327  painter->setPen(borderColor);
1328  painter->drawLine(leftLine);
1329  painter->drawLine(rightLine);
1330  painter->drawLine(bottomLine);
1331  painter->drawPoint(leftBottomOuterCorner);
1332  painter->drawPoint(rightBottomOuterCorner);
1333  painter->drawPoint(leftTopOuterCorner);
1334 
1335  painter->setPen(option->palette.light().color());
1336  painter->drawLine(innerLeftLine);
1337  painter->drawLine(innerTopLine);
1338 
1339  painter->setPen(buttonShadowAlpha);
1340  painter->drawLine(innerRightLine);
1341  painter->drawLine(innerBottomLine);
1342 
1343  painter->setPen(alphaCornerColor);
1344  const QPoint points[6] = {
1345  leftBottomInnerCorner1,
1346  leftBottomInnerCorner2,
1347  rightBottomInnerCorner1,
1348  rightBottomInnerCorner2,
1349  leftTopInnerCorner1,
1350  leftTopInnerCorner2
1351  };
1352  painter->drawPoints(points, 6);
1353  }
1354 #endif // QT_NO_TABWIDGET
1355  painter->restore();
1356  break ;
1357 
1358  case PE_FrameStatusBarItem:
1359  break;
1360  case PE_IndicatorTabClose:
1361  {
1362  Q_D(const QCleanlooksStyle);
1363  if (d->tabBarcloseButtonIcon.isNull())
1364  d->tabBarcloseButtonIcon = standardIcon(SP_DialogCloseButton, option, widget);
1365  if ((option->state & State_Enabled) && (option->state & State_MouseOver))
1366  proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
1367  QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On);
1368  proxy()->drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap);
1369  }
1370  break;
1371 
1372 #endif // QT_NO_TABBAR
1373  default:
1374  QWindowsStyle::drawPrimitive(elem, option, painter, widget);
1375  break;
1376  }
1377 }
1378 
1383  const QWidget *widget) const
1384 {
1385  QColor button = option->palette.button().color();
1386  QColor dark;
1387  dark.setHsv(button.hue(),
1388  qMin(255, (int)(button.saturation()*1.9)),
1389  qMin(255, (int)(button.value()*0.7)));
1390  QColor darkOutline;
1391  darkOutline.setHsv(button.hue(),
1392  qMin(255, (int)(button.saturation()*2.0)),
1393  qMin(255, (int)(button.value()*0.6)));
1394  QRect rect = option->rect;
1395  QColor shadow = mergedColors(option->palette.background().color().darker(120),
1396  dark.lighter(130), 60);
1397  QColor tabFrameColor = mergedColors(option->palette.background().color(),
1398  dark.lighter(135), 60);
1399 
1400  QColor highlight = option->palette.highlight().color();
1401 
1402  switch(element) {
1403  case CE_RadioButton: //fall through
1404  case CE_CheckBox:
1405  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
1406  bool hover = (btn->state & State_MouseOver && btn->state & State_Enabled);
1407  if (hover)
1408  painter->fillRect(rect, btn->palette.background().color().lighter(104));
1409  QStyleOptionButton copy = *btn;
1410  copy.rect.adjust(2, 0, -2, 0);
1411  QWindowsStyle::drawControl(element, &copy, painter, widget);
1412  }
1413  break;
1414  case CE_Splitter:
1415  painter->save();
1416  {
1417  // hover appearance
1418  QBrush fillColor = option->palette.background().color();
1419  if (option->state & State_MouseOver && option->state & State_Enabled)
1420  fillColor = fillColor.color().lighter(106);
1421 
1422  painter->fillRect(option->rect, fillColor);
1423 
1424  QColor grooveColor = mergedColors(dark.lighter(110), option->palette.button().color(),40);
1425  QColor gripShadow = grooveColor.darker(110);
1426  QPalette palette = option->palette;
1427  bool vertical = !(option->state & State_Horizontal);
1428  QRect scrollBarSlider = option->rect;
1429  int gripMargin = 4;
1430  //draw grips
1431  if (vertical) {
1432  for( int i = -20; i< 20 ; i += 2) {
1433  painter->setPen(QPen(gripShadow, 1));
1434  painter->drawLine(
1435  QPoint(scrollBarSlider.center().x() + i ,
1436  scrollBarSlider.top() + gripMargin),
1437  QPoint(scrollBarSlider.center().x() + i,
1438  scrollBarSlider.bottom() - gripMargin));
1439  painter->setPen(QPen(palette.light(), 1));
1440  painter->drawLine(
1441  QPoint(scrollBarSlider.center().x() + i + 1,
1442  scrollBarSlider.top() + gripMargin ),
1443  QPoint(scrollBarSlider.center().x() + i + 1,
1444  scrollBarSlider.bottom() - gripMargin));
1445  }
1446  } else {
1447  for (int i = -20; i < 20 ; i += 2) {
1448  painter->setPen(QPen(gripShadow, 1));
1449  painter->drawLine(
1450  QPoint(scrollBarSlider.left() + gripMargin ,
1451  scrollBarSlider.center().y()+ i),
1452  QPoint(scrollBarSlider.right() - gripMargin,
1453  scrollBarSlider.center().y()+ i));
1454  painter->setPen(QPen(palette.light(), 1));
1455  painter->drawLine(
1456  QPoint(scrollBarSlider.left() + gripMargin,
1457  scrollBarSlider.center().y() + 1 + i),
1458  QPoint(scrollBarSlider.right() - gripMargin,
1459  scrollBarSlider.center().y() + 1 + i));
1460 
1461  }
1462  }
1463  }
1464  painter->restore();
1465  break;
1466 #ifndef QT_NO_SIZEGRIP
1467  case CE_SizeGrip:
1468  painter->save();
1469  {
1470  int x, y, w, h;
1471  option->rect.getRect(&x, &y, &w, &h);
1472  int sw = qMin(h, w);
1473  if (h > w)
1474  painter->translate(0, h - w);
1475  else
1476  painter->translate(w - h, 0);
1477 
1478  int sx = x;
1479  int sy = y;
1480  int s = 4;
1481  if (option->direction == Qt::RightToLeft) {
1482  sx = x + sw;
1483  for (int i = 0; i < 4; ++i) {
1484  painter->setPen(QPen(option->palette.light().color(), 1));
1485  painter->drawLine(x, sy - 1 , sx + 1, sw);
1486  painter->setPen(QPen(dark.lighter(120), 1));
1487  painter->drawLine(x, sy, sx, sw);
1488  sx -= s;
1489  sy += s;
1490  }
1491  } else {
1492  for (int i = 0; i < 4; ++i) {
1493  painter->setPen(QPen(option->palette.light().color(), 1));
1494  painter->drawLine(sx - 1, sw, sw, sy - 1);
1495  painter->setPen(QPen(dark.lighter(120), 1));
1496  painter->drawLine(sx, sw, sw, sy);
1497  sx += s;
1498  sy += s;
1499  }
1500  }
1501  }
1502  painter->restore();
1503  break;
1504 #endif // QT_NO_SIZEGRIP
1505 #ifndef QT_NO_TOOLBAR
1506  case CE_ToolBar:
1507  painter->save();
1508  if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
1509  QRect rect = option->rect;
1510 
1511  bool paintLeftBorder = true;
1512  bool paintRightBorder = true;
1513  bool paintBottomBorder = true;
1514 
1515  switch (toolbar->toolBarArea) {
1516  case Qt::BottomToolBarArea:
1517  switch(toolbar->positionOfLine) {
1520  paintBottomBorder = false;
1521  default:
1522  break;
1523  }
1524  case Qt::TopToolBarArea:
1525  switch (toolbar->positionWithinLine) {
1527  paintLeftBorder = false;
1528  break;
1530  paintRightBorder = false;
1531  break;
1533  paintRightBorder = false;
1534  paintLeftBorder = false;
1535  default:
1536  break;
1537  }
1538  if (toolbar->direction == Qt::RightToLeft) { //reverse layout changes the order of Beginning/end
1539  bool tmp = paintLeftBorder;
1540  paintRightBorder=paintLeftBorder;
1541  paintLeftBorder=tmp;
1542  }
1543  break;
1544  case Qt::RightToolBarArea:
1545  switch (toolbar->positionOfLine) {
1548  paintRightBorder = false;
1549  break;
1550  default:
1551  break;
1552  }
1553  break;
1554  case Qt::LeftToolBarArea:
1555  switch (toolbar->positionOfLine) {
1558  paintLeftBorder = false;
1559  break;
1560  default:
1561  break;
1562  }
1563  break;
1564  default:
1565  break;
1566  }
1567 
1568  QColor light = option->palette.background().color().lighter(110);
1569 
1570  //draw top border
1571  painter->setPen(QPen(light));
1572  painter->drawLine(rect.topLeft().x(),
1573  rect.topLeft().y(),
1574  rect.topRight().x(),
1575  rect.topRight().y());
1576 
1577  if (paintLeftBorder) {
1578  painter->setPen(QPen(light));
1579  painter->drawLine(rect.topLeft().x(),
1580  rect.topLeft().y(),
1581  rect.bottomLeft().x(),
1582  rect.bottomLeft().y());
1583  }
1584 
1585  if (paintRightBorder) {
1586  painter->setPen(QPen(shadow));
1587  painter->drawLine(rect.topRight().x(),
1588  rect.topRight().y(),
1589  rect.bottomRight().x(),
1590  rect.bottomRight().y());
1591  }
1592 
1593  if (paintBottomBorder) {
1594  painter->setPen(QPen(shadow));
1595  painter->drawLine(rect.bottomLeft().x(),
1596  rect.bottomLeft().y(),
1597  rect.bottomRight().x(),
1598  rect.bottomRight().y());
1599  }
1600  }
1601  painter->restore();
1602  break;
1603 #endif // QT_NO_TOOLBAR
1604 #ifndef QT_NO_DOCKWIDGET
1605  case CE_DockWidgetTitle:
1606  painter->save();
1607  if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
1608  const QStyleOptionDockWidgetV2 *v2
1610  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
1611 
1612  QRect rect = dwOpt->rect;
1613  QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget);
1614  QRect r = rect.adjusted(0, 0, -1, 0);
1615  if (verticalTitleBar)
1616  r.adjust(0, 0, 0, -1);
1617  painter->setPen(option->palette.light().color());
1618  painter->drawRect(r.adjusted(1, 1, 1, 1));
1619  painter->setPen(shadow);
1620  painter->drawRect(r);
1621 
1622  if (verticalTitleBar) {
1623  QRect r = rect;
1624  QSize s = r.size();
1625  s.transpose();
1626  r.setSize(s);
1627 
1628  titleRect = QRect(r.left() + rect.bottom()
1629  - titleRect.bottom(),
1630  r.top() + titleRect.left() - rect.left(),
1631  titleRect.height(), titleRect.width());
1632 
1633  painter->translate(r.left(), r.top() + r.width());
1634  painter->rotate(-90);
1635  painter->translate(-r.left(), -r.top());
1636 
1637  rect = r;
1638  }
1639 
1640  if (!dwOpt->title.isEmpty()) {
1641  QString titleText
1642  = painter->fontMetrics().elidedText(dwOpt->title,
1643  Qt::ElideRight, titleRect.width());
1644  proxy()->drawItemText(painter,
1645  titleRect,
1647  dwOpt->state & State_Enabled, titleText,
1649  }
1650  }
1651  painter->restore();
1652  break;
1653 #endif // QT_NO_DOCKWIDGET
1654  case CE_HeaderSection:
1655  painter->save();
1656  // Draws the header in tables.
1657  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
1658  QPixmap cache;
1659  QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size());
1660  pixmapName += QString::number(- int(header->position));
1661  pixmapName += QString::number(- int(header->orientation));
1662  QRect r = option->rect;
1663  QColor gradientStopColor;
1664  QColor gradientStartColor = option->palette.button().color();
1665  gradientStopColor.setHsv(gradientStartColor.hue(),
1666  qMin(255, (int)(gradientStartColor.saturation()*2)),
1667  qMin(255, (int)(gradientStartColor.value()*0.96)));
1668  QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
1669  if (option->palette.background().gradient()) {
1670  gradient.setStops(option->palette.background().gradient()->stops());
1671  } else {
1672  gradient.setColorAt(0, gradientStartColor);
1673  gradient.setColorAt(0.8, gradientStartColor);
1674  gradient.setColorAt(1, gradientStopColor);
1675  }
1676  painter->fillRect(r, gradient);
1677 
1678  if (!QPixmapCache::find(pixmapName, cache)) {
1679  cache = QPixmap(r.size());
1680  cache.fill(Qt::transparent);
1681  QRect pixmapRect(0, 0, r.width(), r.height());
1682  QPainter cachePainter(&cache);
1683  if (header->orientation == Qt::Vertical) {
1684  cachePainter.setPen(QPen(dark));
1685  cachePainter.drawLine(pixmapRect.topRight(), pixmapRect.bottomRight());
1686  if (header->position != QStyleOptionHeader::End) {
1687  cachePainter.setPen(QPen(shadow));
1688  cachePainter.drawLine(pixmapRect.bottomLeft() + QPoint(3, -1), pixmapRect.bottomRight() + QPoint(-3, -1)); cachePainter.setPen(QPen(option->palette.light().color()));
1689  cachePainter.drawLine(pixmapRect.bottomLeft() + QPoint(3, 0), pixmapRect.bottomRight() + QPoint(-3, 0)); }
1690  } else {
1691  cachePainter.setPen(QPen(dark));
1692  cachePainter.drawLine(pixmapRect.bottomLeft(), pixmapRect.bottomRight());
1693  cachePainter.setPen(QPen(shadow));
1694  cachePainter.drawLine(pixmapRect.topRight() + QPoint(-1, 3), pixmapRect.bottomRight() + QPoint(-1, -3)); cachePainter.setPen(QPen(option->palette.light().color()));
1695  cachePainter.drawLine(pixmapRect.topRight() + QPoint(0, 3), pixmapRect.bottomRight() + QPoint(0, -3)); }
1696  cachePainter.end();
1697  QPixmapCache::insert(pixmapName, cache);
1698  }
1699  painter->drawPixmap(r.topLeft(), cache);
1700  }
1701  painter->restore();
1702  break;
1703  case CE_ProgressBarGroove:
1704  painter->save();
1705  {
1706  painter->fillRect(rect, option->palette.base());
1707  QColor borderColor = dark.lighter(110);
1708  painter->setPen(QPen(borderColor, 0));
1709  const QLine lines[4] = {
1710  QLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top())),
1711  QLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom())),
1712  QLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1)),
1713  QLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1))
1714  };
1715  painter->drawLines(lines, 4);
1716  QColor alphaCorner = mergedColors(borderColor, option->palette.background().color());
1717  QColor innerShadow = mergedColors(borderColor, option->palette.base().color());
1718 
1719  //corner smoothing
1720  painter->setPen(alphaCorner);
1721  const QPoint points[4] = {
1722  rect.topRight(),
1723  rect.topLeft(),
1724  rect.bottomRight(),
1725  rect.bottomLeft()
1726  };
1727  painter->drawPoints(points, 4);
1728 
1729  //inner shadow
1730  painter->setPen(innerShadow);
1731  painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
1732  QPoint(rect.right() - 1, rect.top() + 1));
1733  painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
1734  QPoint(rect.left() + 1, rect.bottom() + 1));
1735 
1736  }
1737  painter->restore();
1738  break;
1740  painter->save();
1741  if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
1742  QRect rect = bar->rect;
1743  bool vertical = false;
1744  bool inverted = false;
1745  bool indeterminate = (bar->minimum == 0 && bar->maximum == 0);
1746 
1747  // Get extra style options if version 2
1748  if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
1749  vertical = (bar2->orientation == Qt::Vertical);
1750  inverted = bar2->invertedAppearance;
1751  }
1752 
1753  // If the orientation is vertical, we use a transform to rotate
1754  // the progress bar 90 degrees clockwise. This way we can use the
1755  // same rendering code for both orientations.
1756  if (vertical) {
1757  rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
1758  QTransform m = QTransform::fromTranslate(rect.height()-1, -1.0);
1759  m.rotate(90.0);
1760  painter->setTransform(m, true);
1761  }
1762 
1763  int maxWidth = rect.width() - 4;
1764  int minWidth = 4;
1765  qreal progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar
1766  int progressBarWidth = (progress - bar->minimum) * qreal(maxWidth) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum);
1767  int width = indeterminate ? maxWidth : qMax(minWidth, progressBarWidth);
1768 
1769  bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical;
1770  if (inverted)
1771  reverse = !reverse;
1772 
1773  QRect progressBar;
1774  if (!indeterminate) {
1775  if (!reverse) {
1776  progressBar.setRect(rect.left() + 1, rect.top() + 1, width + 1, rect.height() - 3);
1777  } else {
1778  progressBar.setRect(rect.right() - 1 - width, rect.top() + 1, width + 1, rect.height() - 3);
1779  }
1780  } else {
1781  Q_D(const QCleanlooksStyle);
1782  int slideWidth = ((rect.width() - 4) * 2) / 3;
1783  int step = ((d->animateStep * slideWidth) / d->animationFps) % slideWidth;
1784  if ((((d->animateStep * slideWidth) / d->animationFps) % (2 * slideWidth)) >= slideWidth)
1785  step = slideWidth - step;
1786  progressBar.setRect(rect.left() + 1 + step, rect.top() + 1,
1787  slideWidth / 2, rect.height() - 3);
1788  }
1790  painter->setPen(QPen(highlight.darker(140), 0));
1791 
1792  QColor highlightedGradientStartColor = highlight.lighter(100);
1793  QColor highlightedGradientStopColor = highlight.lighter(130);
1794 
1795  QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(),
1796  rect.bottomLeft().y()*2));
1797 
1798  gradient.setColorAt(0, highlightedGradientStartColor);
1799  gradient.setColorAt(1, highlightedGradientStopColor);
1800 
1801  painter->setBrush(gradient);
1802  painter->drawRect(progressBar);
1803 
1804  painter->setPen(QPen(highlight.lighter(120), 0));
1805  painter->drawLine(QPoint(progressBar.left() + 1, progressBar.top() + 1),
1806  QPoint(progressBar.right(), progressBar.top() + 1));
1807  painter->drawLine(QPoint(progressBar.left() + 1, progressBar.top() + 1),
1808  QPoint(progressBar.left() + 1, progressBar.bottom() - 1));
1809 
1810  painter->setPen(QPen(highlightedGradientStartColor, 7.0));//QPen(option->palette.highlight(), 3));
1811 
1812  painter->save();
1813  painter->setClipRect(progressBar.adjusted(2, 2, -1, -1));
1814  for (int x = progressBar.left() - 32; x < rect.right() ; x+=18) {
1815  painter->drawLine(x, progressBar.bottom() + 1, x + 23, progressBar.top() - 2);
1816  }
1817  painter->restore();
1818 
1819  }
1820  painter->restore();
1821  break;
1822  case CE_MenuBarItem:
1823  painter->save();
1824  if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
1825  {
1826  QStyleOptionMenuItem item = *mbi;
1827  item.rect = mbi->rect.adjusted(0, 3, 0, -1);
1828  QColor highlightOutline = highlight.darker(125);
1829  QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()*2));
1830 
1831  if (option->palette.button().gradient()) {
1832  gradient.setStops(option->palette.button().gradient()->stops());
1833  } else {
1834  gradient.setColorAt(0, option->palette.button().color());
1835  gradient.setColorAt(1, option->palette.button().color().darker(110));
1836  }
1837  painter->fillRect(rect, gradient);
1838 
1839  QCommonStyle::drawControl(element, &item, painter, widget);
1840 
1841  bool act = mbi->state & State_Selected && mbi->state & State_Sunken;
1842  bool dis = !(mbi->state & State_Enabled);
1843 
1844  QRect r = option->rect;
1845  if (act) {
1846  qt_cleanlooks_draw_gradient(painter, r.adjusted(1, 1, -1, -1),
1847  highlight,
1848  highlightOutline, TopDown,
1849  option->palette.highlight());
1850 
1851  painter->setPen(QPen(highlightOutline, 0));
1852  const QLine lines[4] = {
1853  QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())),
1854  QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())),
1855  QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())),
1856  QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()))
1857  };
1858  painter->drawLines(lines, 4);
1859 
1860  //draw text
1863  if (!styleHint(SH_UnderlineShortcut, mbi, widget))
1864  alignment |= Qt::TextHideMnemonic;
1865  proxy()->drawItemText(painter, item.rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole);
1866  }
1867 
1868  }
1869  painter->restore();
1870  break;
1871  case CE_MenuItem:
1872  painter->save();
1873  // Draws one item in a popup menu.
1874  if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
1875  QColor highlightOutline = highlight.darker(125);
1876  QColor menuBackground = option->palette.background().color().lighter(104);
1877  QColor borderColor = option->palette.background().color().darker(160);
1878  QColor alphaCornerColor;
1879 
1880  if (widget) {
1881  // ### backgroundrole/foregroundrole should be part of the style option
1882  alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor);
1883  } else {
1884  alphaCornerColor = mergedColors(option->palette.background().color(), borderColor);
1885  }
1886  if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
1887  painter->fillRect(menuItem->rect, menuBackground);
1888  int w = 0;
1889  if (!menuItem->text.isEmpty()) {
1890  painter->setFont(menuItem->font);
1891  proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,
1892  menuItem->palette, menuItem->state & State_Enabled, menuItem->text,
1893  QPalette::Text);
1894  w = menuItem->fontMetrics.width(menuItem->text) + 5;
1895  }
1896  painter->setPen(shadow.lighter(106));
1897  bool reverse = menuItem->direction == Qt::RightToLeft;
1898  painter->drawLine(menuItem->rect.left() + 5 + (reverse ? 0 : w), menuItem->rect.center().y(),
1899  menuItem->rect.right() - 5 - (reverse ? w : 0), menuItem->rect.center().y());
1900  painter->restore();
1901  break;
1902  }
1903  bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled;
1904  if (selected) {
1905  QRect r = option->rect.adjusted(1, 0, -2, -1);
1906  qt_cleanlooks_draw_gradient(painter, r, highlight,
1907  highlightOutline, TopDown,
1908  highlight);
1909  r = r.adjusted(-1, 0, 1, 0);
1910  painter->setPen(QPen(highlightOutline, 0));
1911  const QLine lines[4] = {
1912  QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1)),
1913  QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1)),
1914  QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())),
1915  QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()))
1916  };
1917  painter->drawLines(lines, 4);
1918  } else {
1919  painter->fillRect(option->rect, menuBackground);
1920  }
1921 
1922  bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
1923  bool checked = menuItem->checked;
1924  bool sunken = menuItem->state & State_Sunken;
1925  bool enabled = menuItem->state & State_Enabled;
1926 
1927  bool ignoreCheckMark = false;
1928  int checkcol = qMax(menuItem->maxIconWidth, 20);
1929 
1930 #ifndef QT_NO_COMBOBOX
1931  if (qobject_cast<const QComboBox*>(widget))
1932  ignoreCheckMark = true; //ignore the checkmarks provided by the QComboMenuDelegate
1933 #endif
1934 
1935  if (!ignoreCheckMark) {
1936  // Check
1937  QRect checkRect(option->rect.left() + 7, option->rect.center().y() - 6, 13, 13);
1938  checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect);
1939  if (checkable) {
1940  if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
1941  // Radio button
1942  if (checked || sunken) {
1944  painter->setPen(Qt::NoPen);
1945 
1946  QPalette::ColorRole textRole = !enabled ? QPalette::Text:
1948  painter->setBrush(option->palette.brush( option->palette.currentColorGroup(), textRole));
1949  painter->drawEllipse(checkRect.adjusted(4, 4, -4, -4));
1950  }
1951  } else {
1952  // Check box
1953  if (menuItem->icon.isNull()) {
1954  if (checked || sunken) {
1956  if (enabled && (menuItem->state & State_Selected)) {
1957  image.setColor(1, 0x55ffffff);
1958  image.setColor(2, 0xAAffffff);
1959  image.setColor(3, 0xBBffffff);
1960  image.setColor(4, 0xFFffffff);
1961  image.setColor(5, 0x33ffffff);
1962  } else {
1963  image.setColor(1, 0x55000000);
1964  image.setColor(2, 0xAA000000);
1965  image.setColor(3, 0xBB000000);
1966  image.setColor(4, 0xFF000000);
1967  image.setColor(5, 0x33000000);
1968  }
1969  painter->drawImage(QPoint(checkRect.center().x() - image.width() / 2,
1970  checkRect.center().y() - image.height() / 2), image);
1971  }
1972  }
1973  }
1974  }
1975  } else { //ignore checkmark
1976  if (menuItem->icon.isNull())
1977  checkcol = 0;
1978  else
1979  checkcol = menuItem->maxIconWidth;
1980  }
1981 
1982  // Text and icon, ripped from windows style
1983  bool dis = !(menuItem->state & State_Enabled);
1984  bool act = menuItem->state & State_Selected;
1985  const QStyleOption *opt = option;
1986  const QStyleOptionMenuItem *menuitem = menuItem;
1987 
1988  QPainter *p = painter;
1989  QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
1990  QRect(menuitem->rect.x(), menuitem->rect.y(),
1991  checkcol, menuitem->rect.height()));
1992  if (!menuItem->icon.isNull()) {
1993  QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
1994  if (act && !dis)
1995  mode = QIcon::Active;
1996  QPixmap pixmap;
1997 
1998  int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget);
1999  QSize iconSize(smallIconSize, smallIconSize);
2000 #ifndef QT_NO_COMBOBOX
2001  if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget))
2002  iconSize = combo->iconSize();
2003 #endif // QT_NO_COMBOBOX
2004  if (checked)
2005  pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On);
2006  else
2007  pixmap = menuItem->icon.pixmap(iconSize, mode);
2008 
2009  int pixw = pixmap.width();
2010  int pixh = pixmap.height();
2011 
2012  QRect pmr(0, 0, pixw, pixh);
2013  pmr.moveCenter(vCheckRect.center());
2014  painter->setPen(menuItem->palette.text().color());
2015  if (checkable && checked) {
2016  QStyleOption opt = *option;
2017  if (act) {
2018  QColor activeColor = mergedColors(option->palette.background().color(),
2019  option->palette.highlight().color());
2020  opt.palette.setBrush(QPalette::Button, activeColor);
2021  }
2022  opt.state |= State_Sunken;
2023  opt.rect = vCheckRect;
2024  proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);
2025  }
2026  painter->drawPixmap(pmr.topLeft(), pixmap);
2027  }
2028  if (selected) {
2029  painter->setPen(menuItem->palette.highlightedText().color());
2030  } else {
2031  painter->setPen(menuItem->palette.text().color());
2032  }
2033  int x, y, w, h;
2034  menuitem->rect.getRect(&x, &y, &w, &h);
2035  int tab = menuitem->tabWidth;
2036  QColor discol;
2037  if (dis) {
2038  discol = menuitem->palette.text().color();
2039  p->setPen(discol);
2040  }
2041  int xm = windowsItemFrame + checkcol + windowsItemHMargin;
2042  int xpos = menuitem->rect.x() + xm;
2043 
2044  QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
2045  QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
2046  QString s = menuitem->text;
2047  if (!s.isEmpty()) { // draw text
2048  p->save();
2049  int t = s.indexOf(QLatin1Char('\t'));
2051  if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
2052  text_flags |= Qt::TextHideMnemonic;
2053  text_flags |= Qt::AlignLeft;
2054  if (t >= 0) {
2055  QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
2056  QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
2057  if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) {
2058  p->setPen(menuitem->palette.light().color());
2059  p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, s.mid(t + 1));
2060  p->setPen(discol);
2061  }
2062  p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
2063  s = s.left(t);
2064  }
2065  QFont font = menuitem->font;
2066  // font may not have any "hard" flags set. We override
2067  // the point size so that when it is resolved against the device, this font will win.
2068  // This is mainly to handle cases where someone sets the font on the window
2069  // and then the combo inherits it and passes it onward. At that point the resolve mask
2070  // is very, very weak. This makes it stonger.
2071  font.setPointSizeF(QFontInfo(menuItem->font).pointSizeF());
2072 
2074  font.setBold(true);
2075 
2076  p->setFont(font);
2077  if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) {
2078  p->setPen(menuitem->palette.light().color());
2079  p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, s.left(t));
2080  p->setPen(discol);
2081  }
2082  p->drawText(vTextRect, text_flags, s.left(t));
2083  p->restore();
2084  }
2085 
2086  // Arrow
2087  if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
2088  int dim = (menuItem->rect.height() - 4) / 2;
2089  PrimitiveElement arrow;
2091  int xpos = menuItem->rect.left() + menuItem->rect.width() - 3 - dim;
2092  QRect vSubMenuRect = visualRect(option->direction, menuItem->rect,
2093  QRect(xpos, menuItem->rect.top() + menuItem->rect.height() / 2 - dim / 2, dim, dim));
2094  QStyleOptionMenuItem newMI = *menuItem;
2095  newMI.rect = vSubMenuRect;
2096  newMI.state = !enabled ? State_None : State_Enabled;
2097  if (selected)
2099  newMI.palette.highlightedText().color());
2100  proxy()->drawPrimitive(arrow, &newMI, painter, widget);
2101  }
2102  }
2103  painter->restore();
2104  break;
2105  case CE_MenuHMargin:
2106  case CE_MenuVMargin:
2107  break;
2108  case CE_MenuEmptyArea:
2109  break;
2110  case CE_PushButtonLabel:
2111  if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
2112  QRect ir = button->rect;
2113  uint tf = Qt::AlignVCenter;
2114  if (styleHint(SH_UnderlineShortcut, button, widget))
2115  tf |= Qt::TextShowMnemonic;
2116  else
2117  tf |= Qt::TextHideMnemonic;
2118 
2119  if (!button->icon.isNull()) {
2120  //Center both icon and text
2121  QPoint point;
2122 
2123  QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal
2124  : QIcon::Disabled;
2125  if (mode == QIcon::Normal && button->state & State_HasFocus)
2126  mode = QIcon::Active;
2127  QIcon::State state = QIcon::Off;
2128  if (button->state & State_On)
2129  state = QIcon::On;
2130 
2131  QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
2132  int w = pixmap.width();
2133  int h = pixmap.height();
2134 
2135  if (!button->text.isEmpty())
2136  w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 2;
2137 
2138  point = QPoint(ir.x() + ir.width() / 2 - w / 2,
2139  ir.y() + ir.height() / 2 - h / 2);
2140 
2141  if (button->direction == Qt::RightToLeft)
2142  point.rx() += pixmap.width();
2143 
2144  painter->drawPixmap(visualPos(button->direction, button->rect, point), pixmap);
2145 
2146  if (button->direction == Qt::RightToLeft)
2147  ir.translate(-point.x() - 2, 0);
2148  else
2149  ir.translate(point.x() + pixmap.width(), 0);
2150 
2151  // left-align text if there is
2152  if (!button->text.isEmpty())
2153  tf |= Qt::AlignLeft;
2154 
2155  } else {
2156  tf |= Qt::AlignHCenter;
2157  }
2158 
2159  if (button->features & QStyleOptionButton::HasMenu)
2160  ir = ir.adjusted(0, 0, -proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget), 0);
2161  proxy()->drawItemText(painter, ir, tf, button->palette, (button->state & State_Enabled),
2162  button->text, QPalette::ButtonText);
2163  }
2164  break;
2165  case CE_MenuBarEmptyArea:
2166  painter->save();
2167  {
2168  QColor shadow = mergedColors(option->palette.background().color().darker(120),
2169  dark.lighter(140), 60);
2170 
2171  QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()*2));
2172  gradient.setColorAt(0, option->palette.button().color());
2173  gradient.setColorAt(1, option->palette.button().color().darker(110));
2174  painter->fillRect(rect, gradient);
2175 
2176 #ifndef QT_NO_MAINWINDOW
2177  if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) {
2178  QPen oldPen = painter->pen();
2179  painter->setPen(QPen(shadow));
2180  painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
2181  }
2182 #endif // QT_NO_MAINWINDOW
2183  }
2184  painter->restore();
2185  break;
2186 #ifndef QT_NO_TABBAR
2187  case CE_TabBarTabShape:
2188  painter->save();
2189  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
2190 
2191  bool rtlHorTabs = (tab->direction == Qt::RightToLeft
2192  && (tab->shape == QTabBar::RoundedNorth
2193  || tab->shape == QTabBar::RoundedSouth));
2194  bool selected = tab->state & State_Selected;
2195  bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
2196  || (rtlHorTabs
2197  && tab->position == QStyleOptionTab::Beginning));
2198  bool onlyTab = tab->position == QStyleOptionTab::OnlyOneTab;
2199  bool leftCornerWidget = (tab->cornerWidgets & QStyleOptionTab::LeftCornerWidget);
2200 
2201  bool atBeginning = ((tab->position == (tab->direction == Qt::LeftToRight ?
2203 
2204  bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
2205  bool previousSelected =
2206  ((!rtlHorTabs
2207  && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
2208  || (rtlHorTabs
2209  && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
2210  bool nextSelected =
2211  ((!rtlHorTabs
2212  && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
2213  || (rtlHorTabs
2214  && tab->selectedPosition
2216  int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
2217  bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
2218  || (rtlHorTabs
2219  && tabBarAlignment == Qt::AlignRight);
2220 
2221  bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
2222  || (rtlHorTabs
2223  && tabBarAlignment == Qt::AlignLeft);
2224 
2225  QColor light = tab->palette.light().color();
2226 
2227  QColor background = tab->palette.background().color();
2228  int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
2229  if (selected)
2230  borderThinkness /= 2;
2231  QRect r2(option->rect);
2232  int x1 = r2.left();
2233  int x2 = r2.right();
2234  int y1 = r2.top();
2235  int y2 = r2.bottom();
2236 
2237  QTransform rotMatrix;
2238  bool flip = false;
2239  painter->setPen(shadow);
2240  QColor activeHighlight = option->palette.color(QPalette::Normal, QPalette::Highlight);
2241  switch (tab->shape) {
2242  case QTabBar::RoundedNorth:
2243  break;
2244  case QTabBar::RoundedSouth:
2245  rotMatrix.rotate(180);
2246  rotMatrix.translate(0, -rect.height() + 1);
2247  rotMatrix.scale(-1, 1);
2248  painter->setTransform(rotMatrix, true);
2249  break;
2250  case QTabBar::RoundedWest:
2251  rotMatrix.rotate(180 + 90);
2252  rotMatrix.scale(-1, 1);
2253  flip = true;
2254  painter->setTransform(rotMatrix, true);
2255  break;
2256  case QTabBar::RoundedEast:
2257  rotMatrix.rotate(90);
2258  rotMatrix.translate(0, - rect.width() + 1);
2259  flip = true;
2260  painter->setTransform(rotMatrix, true);
2261  break;
2262  default:
2263  painter->restore();
2264  QWindowsStyle::drawControl(element, tab, painter, widget);
2265  return;
2266  }
2267 
2268  if (flip) {
2269  QRect tmp = rect;
2270  rect = QRect(tmp.y(), tmp.x(), tmp.height(), tmp.width());
2271  int temp = x1;
2272  x1 = y1;
2273  y1 = temp;
2274  temp = x2;
2275  x2 = y2;
2276  y2 = temp;
2277  }
2278 
2279  QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
2280  if (option->palette.button().gradient()) {
2281  if (selected)
2282  gradient.setStops(option->palette.background().gradient()->stops());
2283  else
2284  gradient.setStops(option->palette.background().gradient()->stops());
2285  }
2286  else if (selected) {
2287  gradient.setColorAt(0, option->palette.background().color().lighter(104));
2288  gradient.setColorAt(1, tabFrameColor);
2289  painter->fillRect(rect.adjusted(0, 2, 0, -1), gradient);
2290  } else {
2291  y1 += 2;
2292  gradient.setColorAt(0, option->palette.background().color());
2293  gradient.setColorAt(1, dark.lighter(120));
2294  painter->fillRect(rect.adjusted(0, 2, 0, -2), gradient);
2295  }
2296 
2297  // Delete border
2298  if (selected) {
2299  painter->setPen(QPen(activeHighlight, 0));
2300  painter->drawLine(x1 + 1, y1 + 1, x2 - 1, y1 + 1);
2301  painter->drawLine(x1 , y1 + 2, x2 , y1 + 2);
2302  } else {
2303  painter->setPen(dark);
2304  painter->drawLine(x1, y2 - 1, x2 + 2, y2 - 1 );
2305  if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedWest) {
2306  painter->setPen(light);
2307  painter->drawLine(x1, y2 , x2, y2 );
2308  }
2309  }
2310  // Left
2311  if (atBeginning || selected ) {
2312  painter->setPen(light);
2313  painter->drawLine(x1 + 1, y1 + 2 + 1, x1 + 1, y2 - ((onlyOne || atBeginning) && selected && leftAligned ? 0 : borderThinkness) - (atBeginning && leftCornerWidget ? 1 : 0));
2314  painter->drawPoint(x1 + 1, y1 + 1);
2315  painter->setPen(dark);
2316  painter->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || atBeginning) && leftAligned ? 0 : borderThinkness) - (atBeginning && leftCornerWidget ? 1 : 0));
2317  }
2318  // Top
2319  {
2320  int beg = x1 + (previousSelected ? 0 : 2);
2321  int end = x2 - (nextSelected ? 0 : 2);
2322  painter->setPen(light);
2323 
2324  if (!selected)painter->drawLine(beg - 2, y1 + 1, end, y1 + 1);
2325 
2326  if (selected)
2327  painter->setPen(QPen(activeHighlight.darker(150), 0));
2328  else
2329  painter->setPen(darkOutline);
2330  painter->drawLine(beg, y1 , end, y1);
2331 
2332  if (atBeginning|| selected) {
2333  painter->drawPoint(beg - 1, y1 + 1);
2334  } else if (!atBeginning) {
2335  painter->drawPoint(beg - 1, y1);
2336  painter->drawPoint(beg - 2, y1);
2337  if (!lastTab) {
2338  painter->setPen(dark.lighter(130));
2339  painter->drawPoint(end + 1, y1);
2340  painter->drawPoint(end + 2 , y1);
2341  painter->drawPoint(end + 2, y1 + 1);
2342  }
2343  }
2344  }
2345  // Right
2346  if (lastTab || selected || onlyOne || !nextSelected) {
2347  painter->setPen(darkOutline);
2348  painter->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
2349  if (selected)
2350  painter->setPen(QPen(activeHighlight.darker(150), 0));
2351  else
2352  painter->setPen(darkOutline);
2353  painter->drawPoint(x2 - 1, y1 + 1);
2354 
2355  if (selected) {
2356  painter->setPen(background.darker(110));
2357  painter->drawLine(x2 - 1, y1 + 3, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
2358  }
2359  }
2360  }
2361  painter->restore();
2362  break;
2363 
2364 #endif // QT_NO_TABBAR
2365  default:
2366  QWindowsStyle::drawControl(element,option,painter,widget);
2367  break;
2368  }
2369 }
2370 
2375 {
2377  palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(98, 140, 178));
2378  palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(145, 141, 126));
2379  palette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 141, 126));
2380 
2381  QColor backGround(239, 235, 231);
2382 
2383  QColor light = backGround.lighter(150);
2384  QColor base = Qt::white;
2385  QColor dark = QColor(170, 156, 143).darker(110);
2386  dark = backGround.darker(150);
2387  QColor darkDisabled = QColor(209, 200, 191).darker(110);
2388 
2389  //### Find the correct disabled text color
2390  palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(190, 190, 190));
2391 
2392  palette.setBrush(QPalette::Window, backGround);
2393  palette.setBrush(QPalette::Mid, backGround.darker(130));
2394  palette.setBrush(QPalette::Light, light);
2395 
2396  palette.setBrush(QPalette::Active, QPalette::Base, base);
2397  palette.setBrush(QPalette::Inactive, QPalette::Base, base);
2398  palette.setBrush(QPalette::Disabled, QPalette::Base, backGround);
2399 
2400  palette.setBrush(QPalette::Midlight, palette.mid().color().lighter(110));
2401 
2402  palette.setBrush(QPalette::All, QPalette::Dark, dark);
2403  palette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
2404 
2405  QColor button = backGround;
2406 
2407  palette.setBrush(QPalette::Button, button);
2408 
2409  QColor shadow = dark.darker(135);
2410  palette.setBrush(QPalette::Shadow, shadow);
2411  palette.setBrush(QPalette::Disabled, QPalette::Shadow, shadow.lighter(150));
2412  palette.setBrush(QPalette::HighlightedText, QColor(QRgb(0xffffffff)));
2413  return palette;
2414 }
2415 
2420  QPainter *painter, const QWidget *widget) const
2421 {
2422  QColor button = option->palette.button().color();
2423  QColor dark;
2424  QColor grooveColor;
2425  QColor darkOutline;
2426  dark.setHsv(button.hue(),
2427  qMin(255, (int)(button.saturation()*1.9)),
2428  qMin(255, (int)(button.value()*0.7)));
2429  grooveColor.setHsv(button.hue(),
2430  qMin(255, (int)(button.saturation()*2.6)),
2431  qMin(255, (int)(button.value()*0.9)));
2432  darkOutline.setHsv(button.hue(),
2433  qMin(255, (int)(button.saturation()*3.0)),
2434  qMin(255, (int)(button.value()*0.6)));
2435 
2436  QColor alphaCornerColor;
2437  if (widget) {
2438  // ### backgroundrole/foregroundrole should be part of the style option
2439  alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), darkOutline);
2440  } else {
2441  alphaCornerColor = mergedColors(option->palette.background().color(), darkOutline);
2442  }
2443  QColor gripShadow = grooveColor.darker(110);
2444  QColor buttonShadow = option->palette.button().color().darker(110);
2445 
2446  QColor gradientStartColor = option->palette.button().color().lighter(108);
2447  QColor gradientStopColor = mergedColors(option->palette.button().color().darker(108), dark.lighter(150), 70);
2448 
2449  QPalette palette = option->palette;
2450 
2451  switch (control) {
2452 #ifndef QT_NO_SPINBOX
2453  case CC_SpinBox:
2454  if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
2455  QPixmap cache;
2456  QString pixmapName = QStyleHelper::uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size());
2457  if (!QPixmapCache::find(pixmapName, cache)) {
2458  cache = QPixmap(spinBox->rect.size());
2459  cache.fill(Qt::transparent);
2460  QRect pixmapRect(0, 0, spinBox->rect.width(), spinBox->rect.height());
2461  QPainter cachePainter(&cache);
2462 
2463  bool isEnabled = (spinBox->state & State_Enabled);
2464  //bool focus = isEnabled && (spinBox->state & State_HasFocus);
2465  bool hover = isEnabled && (spinBox->state & State_MouseOver);
2466  bool sunken = (spinBox->state & State_Sunken);
2467  bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp);
2468  bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown);
2469 
2470  QRect rect = pixmapRect;
2471  QStyleOptionSpinBox spinBoxCopy = *spinBox;
2472  spinBoxCopy.rect = pixmapRect;
2473  QRect upRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxUp, widget);
2474  QRect downRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxDown, widget);
2475 
2476  int fw = spinBoxCopy.frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, &spinBoxCopy, widget) : 0;
2477  cachePainter.fillRect(rect.adjusted(1, qMax(fw - 1, 0), -1, -fw),
2478  option->palette.base());
2479 
2480  QRect r = rect.adjusted(0, 1, 0, -1);
2481  if (spinBox->frame) {
2482 
2483  QColor topShadow = darkOutline;
2484  topShadow.setAlpha(60);
2485  cachePainter.setPen(topShadow);
2486 
2487  // antialias corners
2488  const QPoint points[8] = {
2489  QPoint(r.right(), r.top() + 1),
2490  QPoint(r.right() - 1, r.top() ),
2491  QPoint(r.right(), r.bottom() - 1),
2492  QPoint(r.right() - 1, r.bottom() ),
2493  QPoint(r.left() + 1, r.bottom()),
2494  QPoint(r.left(), r.bottom() - 1),
2495  QPoint(r.left() + 1, r.top()),
2496  QPoint(r.left(), r.top() + 1)
2497  };
2498  cachePainter.drawPoints(points, 8);
2499 
2500  // draw frame
2501  topShadow.setAlpha(30);
2502  cachePainter.setPen(topShadow);
2503  cachePainter.drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1));
2504 
2505  cachePainter.setPen(QPen(option->palette.background().color(), 1));
2506  cachePainter.drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1));
2507  QColor highlight = Qt::white;
2508  highlight.setAlpha(130);
2509  cachePainter.setPen(option->palette.base().color().darker(120));
2510  cachePainter.drawLine(QPoint(r.left() + 1, r.top() + 1),
2511  QPoint(r.right() - 1, r.top() + 1));
2512  cachePainter.drawLine(QPoint(r.left() + 1, r.top() + 1),
2513  QPoint(r.left() + 1, r.bottom() - 1));
2514  cachePainter.setPen(option->palette.base().color());
2515  cachePainter.drawLine(QPoint(r.right() - 1, r.top() + 1),
2516  QPoint(r.right() - 1, r.bottom() - 1));
2517  cachePainter.drawLine(QPoint(r.left() + 1, r.bottom() - 1),
2518  QPoint(r.right() - 1, r.bottom() - 1));
2519  cachePainter.setPen(highlight);
2520  cachePainter.drawLine(QPoint(r.left() + 3, r.bottom() + 1),
2521  QPoint(r.right() - 3, r.bottom() + 1));
2522 
2523  cachePainter.setPen(QPen(darkOutline, 1));
2524 
2525  // top and bottom lines
2526  const QLine lines[4] = {
2527  QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom())),
2528  QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())),
2529  QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)),
2530  QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2))
2531  };
2532  cachePainter.drawLines(lines, 4);
2533  }
2534 
2535  // gradients
2536  qt_cleanlooks_draw_gradient(&cachePainter, upRect,
2537  gradientStartColor.darker(106),
2538  gradientStopColor, TopDown, option->palette.button());
2539  qt_cleanlooks_draw_gradient(&cachePainter, downRect.adjusted(0, 0, 0, 1),
2540  gradientStartColor.darker(106),
2541  gradientStopColor, TopDown, option->palette.button());
2542  if (isEnabled) {
2543  if(upIsActive) {
2544  if (sunken) {
2545  cachePainter.fillRect(upRect.adjusted(1, 0, 0, 0), gradientStopColor.darker(110));
2546  } else if (hover) {
2547  qt_cleanlooks_draw_gradient(&cachePainter, upRect.adjusted(1, 0, 0, 0),
2548  gradientStartColor.lighter(110),
2549  gradientStopColor.lighter(110), TopDown, option->palette.button());
2550  }
2551  }
2552  if(downIsActive) {
2553  if (sunken) {
2554  cachePainter.fillRect(downRect.adjusted(1, 0, 0, 1), gradientStopColor.darker(110));
2555 
2556  } else if (hover) {
2557  qt_cleanlooks_draw_gradient(&cachePainter, downRect.adjusted(1, 0, 0, 1),
2558  gradientStartColor.lighter(110),
2559  gradientStopColor.lighter(110), TopDown, option->palette.button());
2560  }
2561  }
2562  }
2563 
2564  if (spinBox->frame) {
2565  // rounded corners
2566  const QPoint points[4] = {
2567  QPoint(r.left() + 1, r.bottom() - 1),
2568  QPoint(r.left() + 1, r.top() + 1),
2569  QPoint(r.right() - 1, r.bottom() - 1),
2570  QPoint(r.right() - 1, r.top() + 1)
2571  };
2572  cachePainter.drawPoints(points, 4);
2573 
2574  if (option->state & State_HasFocus) {
2575  QColor darkoutline = option->palette.highlight().color().darker(150);
2576  QColor innerline = mergedColors(option->palette.highlight().color(), Qt::white);
2577  cachePainter.setPen(QPen(innerline, 0));
2578  if (spinBox->direction == Qt::LeftToRight) {
2579  cachePainter.drawRect(rect.adjusted(1, 2, -3 -downRect.width(), -3));
2580  cachePainter.setPen(QPen(darkoutline, 0));
2581  const QLine lines[4] = {
2582  QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom())),
2583  QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top())),
2584  QLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1)),
2585  QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2))
2586  };
2587  cachePainter.drawLines(lines, 4);
2588  cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1));
2589  cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1));
2590  cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
2591  } else {
2592  cachePainter.drawRect(rect.adjusted(downRect.width() + 2, 2, -2, -3));
2593  cachePainter.setPen(QPen(darkoutline, 0));
2594  cachePainter.drawLine(QPoint(r.left() + downRect.width(), r.bottom()), QPoint(r.right()- 2 - 1, r.bottom()));
2595  cachePainter.drawLine(QPoint(r.left() + downRect.width(), r.top()), QPoint(r.right() - 2 - 1, r.top()));
2596 
2597  cachePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2));
2598  cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() - 1));
2599  cachePainter.drawPoint(QPoint(r.right() - 1, r.top() + 1));
2600  cachePainter.drawLine(QPoint(r.left() + downRect.width() + 1, r.top()),
2601  QPoint(r.left() + downRect.width() + 1, r.bottom()));
2602  }
2603  }
2604  }
2605 
2606  // outline the up/down buttons
2607  cachePainter.setPen(darkOutline);
2608  QColor light = option->palette.light().color().lighter();
2609 
2610  if (spinBox->direction == Qt::RightToLeft) {
2611  cachePainter.drawLine(upRect.right(), upRect.top() - 1, upRect.right(), downRect.bottom() + 1);
2612  cachePainter.setPen(light);
2613  cachePainter.drawLine(upRect.right() - 1, upRect.top() + 3, upRect.right() - 1, downRect.bottom() );
2614  } else {
2615  cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.left(), downRect.bottom() + 1);
2616  cachePainter.setPen(light);
2617  cachePainter.drawLine(upRect.left() + 1, upRect.top() , upRect.left() + 1, downRect.bottom() );
2618  }
2619  if (upIsActive && sunken) {
2620  cachePainter.setPen(gradientStopColor.darker(130));
2621  cachePainter.drawLine(upRect.left() + 1, upRect.top(), upRect.left() + 1, upRect.bottom());
2622  cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.right(), upRect.top() - 1);
2623  } else {
2624  cachePainter.setPen(light);
2625  cachePainter.drawLine(upRect.topLeft() + QPoint(1, -1), upRect.topRight() + QPoint(-1, -1));
2626  cachePainter.setPen(darkOutline);
2627  cachePainter.drawLine(upRect.bottomLeft(), upRect.bottomRight());
2628  }
2629  if (downIsActive && sunken) {
2630  cachePainter.setPen(gradientStopColor.darker(130));
2631  cachePainter.drawLine(downRect.left() + 1, downRect.top(), downRect.left() + 1, downRect.bottom() + 1);
2632  cachePainter.drawLine(downRect.left(), downRect.top(), downRect.right(), downRect.top());
2633  cachePainter.setPen(gradientStopColor.darker(110));
2634  cachePainter.drawLine(downRect.left(), downRect.bottom() + 1, downRect.right(), downRect.bottom() + 1);
2635  } else {
2636  cachePainter.setPen(light);
2637  cachePainter.drawLine(downRect.topLeft() + QPoint(2,0), downRect.topRight());
2638  }
2639 
2640  if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) {
2641  int centerX = upRect.center().x();
2642  int centerY = upRect.center().y();
2643  cachePainter.setPen(spinBox->palette.foreground().color());
2644 
2645  // plus/minus
2646  if (spinBox->activeSubControls == SC_SpinBoxUp && sunken) {
2647  cachePainter.drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
2648  cachePainter.drawLine(1 + centerX, 1 + centerY - 2, 1 + centerX, 1 + centerY + 2);
2649  } else {
2650  cachePainter.drawLine(centerX - 2, centerY, centerX + 2, centerY);
2651  cachePainter.drawLine(centerX, centerY - 2, centerX, centerY + 2);
2652  }
2653 
2654  centerX = downRect.center().x();
2655  centerY = downRect.center().y();
2656  if (spinBox->activeSubControls == SC_SpinBoxDown && sunken) {
2657  cachePainter.drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
2658  } else {
2659  cachePainter.drawLine(centerX - 2, centerY, centerX + 2, centerY);
2660  }
2661  } else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows){
2662  // arrows
2664  upArrow.setColor(1, spinBox->palette.foreground().color().rgba());
2665 
2666  cachePainter.drawImage(upRect.center().x() - upArrow.width() / 2,
2667  upRect.center().y() - upArrow.height() / 2,
2668  upArrow);
2669 
2671  downArrow.setColor(1, spinBox->palette.foreground().color().rgba());
2672 
2673  cachePainter.drawImage(downRect.center().x() - downArrow.width() / 2,
2674  downRect.center().y() - downArrow.height() / 2 + 1,
2675  downArrow);
2676  }
2677 
2678  QColor disabledColor = option->palette.background().color();
2679  disabledColor.setAlpha(150);
2680  if (!(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled))
2681  cachePainter.fillRect(upRect.adjusted(1, 0, 0, 0), disabledColor);
2682  if (!(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
2683  cachePainter.fillRect(downRect.adjusted(1, 0, 0, 0), disabledColor);
2684  }
2685  cachePainter.end();
2686  QPixmapCache::insert(pixmapName, cache);
2687  }
2688  painter->drawPixmap(spinBox->rect.topLeft(), cache);
2689  }
2690  break;
2691 #endif // QT_NO_SPINBOX
2692  case CC_TitleBar:
2693  painter->save();
2694  if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
2695  const int buttonMargin = 5;
2696  bool active = (titleBar->titleBarState & State_Active);
2697  QRect fullRect = titleBar->rect;
2698  QPalette palette = option->palette;
2699  QColor highlight = option->palette.highlight().color();
2700 
2701  QColor titleBarFrameBorder(active ? highlight.darker(180): dark.darker(110));
2702  QColor titleBarHighlight(active ? highlight.lighter(120): palette.background().color().lighter(120));
2703  QColor textColor(active ? 0xffffff : 0xff000000);
2704  QColor textAlphaColor(active ? 0xffffff : 0xff000000 );
2705 
2706 #ifdef QT3_SUPPORT
2707  if (widget && widget->inherits("Q3DockWindowTitleBar")) {
2708  QStyleOptionDockWidgetV2 dockwidget;
2709  dockwidget.QStyleOption::operator=(*option);
2710  proxy()->drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget);
2711  } else
2712 #endif // QT3_SUPPORT
2713  {
2714  // Fill title bar gradient
2715  QColor titlebarColor = QColor(active ? highlight: palette.background().color());
2716  QLinearGradient gradient(option->rect.center().x(), option->rect.top(),
2717  option->rect.center().x(), option->rect.bottom());
2718 
2719  gradient.setColorAt(0, titlebarColor.lighter(114));
2720  gradient.setColorAt(0.5, titlebarColor.lighter(102));
2721  gradient.setColorAt(0.51, titlebarColor.darker(104));
2722  gradient.setColorAt(1, titlebarColor);
2723  painter->fillRect(option->rect.adjusted(1, 1, -1, 0), gradient);
2724 
2725  // Frame and rounded corners
2726  painter->setPen(titleBarFrameBorder);
2727 
2728  // top outline
2729  painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top());
2730  painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom());
2731  const QPoint points[5] = {
2732  QPoint(fullRect.left() + 4, fullRect.top() + 1),
2733  QPoint(fullRect.left() + 3, fullRect.top() + 1),
2734  QPoint(fullRect.left() + 2, fullRect.top() + 2),
2735  QPoint(fullRect.left() + 1, fullRect.top() + 3),
2736  QPoint(fullRect.left() + 1, fullRect.top() + 4)
2737  };
2738  painter->drawPoints(points, 5);
2739 
2740  painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom());
2741  const QPoint points2[5] = {
2742  QPoint(fullRect.right() - 3, fullRect.top() + 1),
2743  QPoint(fullRect.right() - 4, fullRect.top() + 1),
2744  QPoint(fullRect.right() - 2, fullRect.top() + 2),
2745  QPoint(fullRect.right() - 1, fullRect.top() + 3),
2746  QPoint(fullRect.right() - 1, fullRect.top() + 4)
2747  };
2748  painter->drawPoints(points2, 5);
2749 
2750  // draw bottomline
2751  painter->drawLine(fullRect.right(), fullRect.bottom(), fullRect.left(), fullRect.bottom());
2752 
2753  // top highlight
2754  painter->setPen(titleBarHighlight);
2755  painter->drawLine(fullRect.left() + 6, fullRect.top() + 1, fullRect.right() - 6, fullRect.top() + 1);
2756  }
2757  // draw title
2758  QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget);
2759  QFont font = painter->font();
2760  font.setBold(true);
2761  painter->setFont(font);
2762  painter->setPen(active? (titleBar->palette.text().color().lighter(120)) :
2763  titleBar->palette.text().color() );
2764  // Note workspace also does elliding but it does not use the correct font
2765  QString title = QFontMetrics(font).elidedText(titleBar->text, Qt::ElideRight, textRect.width() - 14);
2766  painter->drawText(textRect.adjusted(1, 1, 1, 1), title, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
2767  painter->setPen(Qt::white);
2768  if (active)
2769  painter->drawText(textRect, title, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
2770  // min button
2771  if ((titleBar->subControls & SC_TitleBarMinButton) && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
2772  !(titleBar->titleBarState& Qt::WindowMinimized)) {
2773  QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget);
2774  if (minButtonRect.isValid()) {
2775  bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver);
2776  bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken);
2777  qt_cleanlooks_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken);
2778  QRect minButtonIconRect = minButtonRect.adjusted(buttonMargin ,buttonMargin , -buttonMargin, -buttonMargin);
2779  painter->setPen(textColor);
2780  painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 3,
2781  minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 3);
2782  painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 4,
2783  minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 4);
2784  painter->setPen(textAlphaColor);
2785  painter->drawLine(minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 3,
2786  minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 4);
2787  painter->drawLine(minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 3,
2788  minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 4);
2789  }
2790  }
2791  // max button
2792  if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
2793  !(titleBar->titleBarState & Qt::WindowMaximized)) {
2794  QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget);
2795  if (maxButtonRect.isValid()) {
2796  bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver);
2797  bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken);
2798  qt_cleanlooks_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken);
2799 
2800  QRect maxButtonIconRect = maxButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
2801 
2802  painter->setPen(textColor);
2803  painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1));
2804  painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1,
2805  maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1);
2806  painter->setPen(textAlphaColor);
2807  const QPoint points[4] = {
2808  maxButtonIconRect.topLeft(),
2809  maxButtonIconRect.topRight(),
2810  maxButtonIconRect.bottomLeft(),
2811  maxButtonIconRect.bottomRight()
2812  };
2813  painter->drawPoints(points, 4);
2814  }
2815  }
2816 
2817  // close button
2818  if ((titleBar->subControls & SC_TitleBarCloseButton) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) {
2819  QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget);
2820  if (closeButtonRect.isValid()) {
2821  bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver);
2822  bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken);
2823  qt_cleanlooks_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken);
2824  QRect closeIconRect = closeButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
2825  painter->setPen(textAlphaColor);
2826  const QLine lines[4] = {
2827  QLine(closeIconRect.left() + 1, closeIconRect.top(),
2828  closeIconRect.right(), closeIconRect.bottom() - 1),
2829  QLine(closeIconRect.left(), closeIconRect.top() + 1,
2830  closeIconRect.right() - 1, closeIconRect.bottom()),
2831  QLine(closeIconRect.right() - 1, closeIconRect.top(),
2832  closeIconRect.left(), closeIconRect.bottom() - 1),
2833  QLine(closeIconRect.right(), closeIconRect.top() + 1,
2834  closeIconRect.left() + 1, closeIconRect.bottom())
2835  };
2836  painter->drawLines(lines, 4);
2837  const QPoint points[4] = {
2838  closeIconRect.topLeft(),
2839  closeIconRect.topRight(),
2840  closeIconRect.bottomLeft(),
2841  closeIconRect.bottomRight()
2842  };
2843  painter->drawPoints(points, 4);
2844 
2845  painter->setPen(textColor);
2846  painter->drawLine(closeIconRect.left() + 1, closeIconRect.top() + 1,
2847  closeIconRect.right() - 1, closeIconRect.bottom() - 1);
2848  painter->drawLine(closeIconRect.left() + 1, closeIconRect.bottom() - 1,
2849  closeIconRect.right() - 1, closeIconRect.top() + 1);
2850  }
2851  }
2852 
2853  // normalize button
2854  if ((titleBar->subControls & SC_TitleBarNormalButton) &&
2855  (((titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
2856  (titleBar->titleBarState & Qt::WindowMinimized)) ||
2857  ((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
2858  (titleBar->titleBarState & Qt::WindowMaximized)))) {
2859  QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget);
2860  if (normalButtonRect.isValid()) {
2861 
2862  bool hover = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver);
2863  bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken);
2864  QRect normalButtonIconRect = normalButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
2865  qt_cleanlooks_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken);
2866 
2867  QRect frontWindowRect = normalButtonIconRect.adjusted(0, 3, -3, 0);
2868  painter->setPen(textColor);
2869  painter->drawRect(frontWindowRect.adjusted(0, 0, -1, -1));
2870  painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1,
2871  frontWindowRect.right() - 1, frontWindowRect.top() + 1);
2872  painter->setPen(textAlphaColor);
2873  const QPoint points[4] = {
2874  frontWindowRect.topLeft(),
2875  frontWindowRect.topRight(),
2876  frontWindowRect.bottomLeft(),
2877  frontWindowRect.bottomRight()
2878  };
2879  painter->drawPoints(points, 4);
2880 
2881  QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3);
2882  QRegion clipRegion = backWindowRect;
2883  clipRegion -= frontWindowRect;
2884  painter->save();
2885  painter->setClipRegion(clipRegion);
2886  painter->setPen(textColor);
2887  painter->drawRect(backWindowRect.adjusted(0, 0, -1, -1));
2888  painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1,
2889  backWindowRect.right() - 1, backWindowRect.top() + 1);
2890  painter->setPen(textAlphaColor);
2891  const QPoint points2[4] = {
2892  backWindowRect.topLeft(),
2893  backWindowRect.topRight(),
2894  backWindowRect.bottomLeft(),
2895  backWindowRect.bottomRight()
2896  };
2897  painter->drawPoints(points2, 4);
2898  painter->restore();
2899  }
2900  }
2901 
2902  // context help button
2903  if (titleBar->subControls & SC_TitleBarContextHelpButton
2904  && (titleBar->titleBarFlags & Qt::WindowContextHelpButtonHint)) {
2905  QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget);
2906  if (contextHelpButtonRect.isValid()) {
2907  bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver);
2908  bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken);
2909  qt_cleanlooks_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken);
2910 
2911  QColor blend;
2913  QColor alpha = textColor;
2914  alpha.setAlpha(128);
2915  image.setColor(1, textColor.rgba());
2916  image.setColor(2, alpha.rgba());
2918  painter->drawImage(contextHelpButtonRect.adjusted(4, 4, -4, -4), image);
2919  }
2920  }
2921 
2922  // shade button
2923  if (titleBar->subControls & SC_TitleBarShadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) {
2924  QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget);
2925  if (shadeButtonRect.isValid()) {
2926  bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver);
2927  bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken);
2928  qt_cleanlooks_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken);
2930  image.setColor(1, textColor.rgba());
2931  painter->drawImage(shadeButtonRect.adjusted(5, 7, -5, -7), image);
2932  }
2933  }
2934 
2935  // unshade button
2936  if (titleBar->subControls & SC_TitleBarUnshadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) {
2937  QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget);
2938  if (unshadeButtonRect.isValid()) {
2939  bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver);
2940  bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken);
2941  qt_cleanlooks_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken);
2943  image.setColor(1, textColor.rgba());
2944  painter->drawImage(unshadeButtonRect.adjusted(5, 7, -5, -7), image);
2945  }
2946  }
2947 
2948  if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) {
2949  QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget);
2950  if (iconRect.isValid()) {
2951  if (!titleBar->icon.isNull()) {
2952  titleBar->icon.paint(painter, iconRect);
2953  } else {
2954  QStyleOption tool(0);
2955  tool.palette = titleBar->palette;
2956  QPixmap pm = standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16);
2957  tool.rect = iconRect;
2958  painter->save();
2959  proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);
2960  painter->restore();
2961  }
2962  }
2963  }
2964  }
2965  painter->restore();
2966  break;
2967 #ifndef QT_NO_SCROLLBAR
2968  case CC_ScrollBar:
2969  painter->save();
2970  if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
2971  bool isEnabled = scrollBar->state & State_Enabled;
2972  bool reverse = scrollBar->direction == Qt::RightToLeft;
2973  bool horizontal = scrollBar->orientation == Qt::Horizontal;
2974  bool sunken = scrollBar->state & State_Sunken;
2975 
2976  painter->fillRect(option->rect, option->palette.background());
2977 
2978  QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);
2979  QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);
2980  QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);
2981  QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget);
2982 
2983  // paint groove
2984  if (scrollBar->subControls & SC_ScrollBarGroove) {
2985  painter->setBrush(grooveColor);
2986  painter->setPen(Qt::NoPen);
2987  if (horizontal) {
2988  painter->drawRect(grooveRect);
2989  painter->setPen(darkOutline);
2990  painter->drawLine(grooveRect.topLeft(), grooveRect.topRight());
2991  painter->drawLine(grooveRect.bottomLeft(), grooveRect.bottomRight());
2992  } else {
2993  painter->drawRect(grooveRect);
2994  painter->setPen(darkOutline);
2995  painter->drawLine(grooveRect.topLeft(), grooveRect.bottomLeft());
2996  painter->drawLine(grooveRect.topRight(), grooveRect.bottomRight());
2997  }
2998  }
2999  //paint slider
3000  if (scrollBar->subControls & SC_ScrollBarSlider) {
3001  QRect pixmapRect = scrollBarSlider;
3002  if (horizontal)
3003  pixmapRect.adjust(-1, 0, 0, -1);
3004  else
3005  pixmapRect.adjust(0, -1, -1, 0);
3006 
3007  if (isEnabled) {
3008  QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(),
3009  pixmapRect.center().x(), pixmapRect.bottom());
3010  if (!horizontal)
3011  gradient = QLinearGradient(pixmapRect.left(), pixmapRect.center().y(),
3012  pixmapRect.right(), pixmapRect.center().y());
3013 
3014  if (option->palette.button().gradient()) {
3015  gradient.setStops(option->palette.button().gradient()->stops());
3016  } else {
3017  if (sunken || (option->state & State_MouseOver &&
3018  (scrollBar->activeSubControls & SC_ScrollBarSlider))) {
3019  gradient.setColorAt(0, gradientStartColor.lighter(110));
3020  gradient.setColorAt(1, gradientStopColor.lighter(110));
3021  } else {
3022  gradient.setColorAt(0, gradientStartColor);
3023  gradient.setColorAt(1, gradientStopColor);
3024  }
3025  }
3026  painter->setPen(QPen(darkOutline, 0));
3027  painter->setBrush(gradient);
3028  painter->drawRect(pixmapRect);
3029 
3030 
3031  //calculate offsets used by highlight and shadow
3032  int yoffset, xoffset;
3033  if (option->state & State_Horizontal) {
3034  xoffset = 0;
3035  yoffset = 1;
3036  } else {
3037  xoffset = 1;
3038  yoffset = 0;
3039  }
3040  //draw slider highlights
3041  painter->setPen(QPen(gradientStopColor, 0));
3042  painter->drawLine(scrollBarSlider.left() + xoffset,
3043  scrollBarSlider.bottom() - yoffset,
3044  scrollBarSlider.right() - xoffset,
3045  scrollBarSlider.bottom() - yoffset);
3046  painter->drawLine(scrollBarSlider.right() - xoffset,
3047  scrollBarSlider.top() + yoffset,
3048  scrollBarSlider.right() - xoffset,
3049  scrollBarSlider.bottom() - yoffset);
3050 
3051  //draw slider shadow
3052  painter->setPen(QPen(gradientStartColor, 0));
3053  painter->drawLine(scrollBarSlider.left() + xoffset,
3054  scrollBarSlider.top() + yoffset,
3055  scrollBarSlider.right() - xoffset,
3056  scrollBarSlider.top() + yoffset);
3057  painter->drawLine(scrollBarSlider.left() + xoffset,
3058  scrollBarSlider.top() + yoffset,
3059  scrollBarSlider.left() + xoffset,
3060  scrollBarSlider.bottom() - yoffset);
3061  } else {
3062  QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(),
3063  pixmapRect.center().x(), pixmapRect.bottom());
3064  if (!horizontal) {
3065  gradient = QLinearGradient(pixmapRect.left(), pixmapRect.center().y(),
3066  pixmapRect.right(), pixmapRect.center().y());
3067  }
3068  if (sunken) {
3069  gradient.setColorAt(0, gradientStartColor.lighter(110));
3070  gradient.setColorAt(1, gradientStopColor.lighter(110));
3071  } else {
3072  gradient.setColorAt(0, gradientStartColor);
3073  gradient.setColorAt(1, gradientStopColor);
3074  }
3075  painter->setPen(darkOutline);
3076  painter->setBrush(gradient);
3077  painter->drawRect(pixmapRect);
3078  }
3079  int gripMargin = 4;
3080  //draw grips
3081  if (horizontal) {
3082  for (int i = -3; i< 6 ; i += 3) {
3083  painter->setPen(QPen(gripShadow, 1));
3084  painter->drawLine(
3085  QPoint(scrollBarSlider.center().x() + i ,
3086  scrollBarSlider.top() + gripMargin),
3087  QPoint(scrollBarSlider.center().x() + i,
3088  scrollBarSlider.bottom() - gripMargin));
3089  painter->setPen(QPen(palette.light(), 1));
3090  painter->drawLine(
3091  QPoint(scrollBarSlider.center().x() + i + 1,
3092  scrollBarSlider.top() + gripMargin ),
3093  QPoint(scrollBarSlider.center().x() + i + 1,
3094  scrollBarSlider.bottom() - gripMargin));
3095  }
3096  } else {
3097  for (int i = -3; i < 6 ; i += 3) {
3098  painter->setPen(QPen(gripShadow, 1));
3099  painter->drawLine(
3100  QPoint(scrollBarSlider.left() + gripMargin ,
3101  scrollBarSlider.center().y()+ i),
3102  QPoint(scrollBarSlider.right() - gripMargin,
3103  scrollBarSlider.center().y()+ i));
3104  painter->setPen(QPen(palette.light(), 1));
3105  painter->drawLine(
3106  QPoint(scrollBarSlider.left() + gripMargin,
3107  scrollBarSlider.center().y() + 1 + i),
3108  QPoint(scrollBarSlider.right() - gripMargin,
3109  scrollBarSlider.center().y() + 1 + i));
3110  }
3111  }
3112  }
3113 
3114  // The SubLine (up/left) buttons
3115  if (scrollBar->subControls & SC_ScrollBarSubLine) {
3116  //int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget);
3117  QRect pixmapRect = scrollBarSubLine;
3118  if (isEnabled ) {
3119  QRect fillRect = pixmapRect.adjusted(1, 1, -1, -1);
3120  // Gradients
3121  if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) {
3123  QRect(fillRect),
3124  gradientStopColor.darker(120),
3125  gradientStopColor.darker(120),
3126  horizontal ? TopDown : FromLeft, option->palette.button());
3127  } else {
3129  QRect(fillRect),
3130  gradientStartColor.lighter(105),
3131  gradientStopColor,
3132  horizontal ? TopDown : FromLeft, option->palette.button());
3133  }
3134  }
3135  // Details
3136  QImage subButton;
3137  if (horizontal) {
3139  } else {
3140  subButton = QImage(qt_scrollbar_button_up);
3141  }
3142  subButton.setColor(1, alphaCornerColor.rgba());
3143  subButton.setColor(2, darkOutline.rgba());
3144  if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) {
3145  subButton.setColor(3, gradientStopColor.darker(140).rgba());
3146  subButton.setColor(4, gradientStopColor.darker(120).rgba());
3147  } else {
3148  subButton.setColor(3, gradientStartColor.lighter(105).rgba());
3149  subButton.setColor(4, gradientStopColor.rgba());
3150  }
3151  subButton.setColor(5, scrollBar->palette.text().color().rgba());
3152  painter->drawImage(pixmapRect, subButton);
3153 
3154  // Arrows
3155  PrimitiveElement arrow;
3156  if (option->state & State_Horizontal)
3158  else
3159  arrow = PE_IndicatorArrowUp;
3160  QStyleOption arrowOpt = *option;
3161  arrowOpt.rect = scrollBarSubLine.adjusted(3, 3, -2, -2);
3162  proxy()->drawPrimitive(arrow, &arrowOpt, painter, widget);
3163 
3164 
3165  // The AddLine (down/right) button
3166  if (scrollBar->subControls & SC_ScrollBarAddLine) {
3167  QString addLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_addline"), option, QSize(16, 16));
3168  QRect pixmapRect = scrollBarAddLine;
3169  if (isEnabled) {
3170  QRect fillRect = pixmapRect.adjusted(1, 1, -1, -1);
3171  // Gradients
3172  if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) {
3174  fillRect,
3175  gradientStopColor.darker(120),
3176  gradientStopColor.darker(120),
3177  horizontal ? TopDown: FromLeft, option->palette.button());
3178  } else {
3180  fillRect,
3181  gradientStartColor.lighter(105),
3182  gradientStopColor,
3183  horizontal ? TopDown : FromLeft, option->palette.button());
3184  }
3185  }
3186  // Details
3187  QImage addButton;
3188  if (horizontal) {
3190  } else {
3191  addButton = QImage(qt_scrollbar_button_down);
3192  }
3193  addButton.setColor(1, alphaCornerColor.rgba());
3194  addButton.setColor(2, darkOutline.rgba());
3195  if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) {
3196  addButton.setColor(3, gradientStopColor.darker(140).rgba());
3197  addButton.setColor(4, gradientStopColor.darker(120).rgba());
3198  } else {
3199  addButton.setColor(3, gradientStartColor.lighter(105).rgba());
3200  addButton.setColor(4, gradientStopColor.rgba());
3201  }
3202  addButton.setColor(5, scrollBar->palette.text().color().rgba());
3203  painter->drawImage(pixmapRect, addButton);
3204 
3205  PrimitiveElement arrow;
3206  if (option->state & State_Horizontal)
3208  else
3209  arrow = PE_IndicatorArrowDown;
3210 
3211  QStyleOption arrowOpt = *option;
3212  arrowOpt.rect = scrollBarAddLine.adjusted(3, 3, -2, -2);
3213  proxy()->drawPrimitive(arrow, &arrowOpt, painter, widget);
3214  }
3215  }
3216  }
3217  painter->restore();
3218  break;;
3219 #endif // QT_NO_SCROLLBAR
3220 #ifndef QT_NO_COMBOBOX
3221  case CC_ComboBox:
3222  painter->save();
3223  if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
3224  bool sunken = comboBox->state & State_On; // play dead, if combobox has no items
3225  bool isEnabled = (comboBox->state & State_Enabled);
3226  bool focus = isEnabled && (comboBox->state & State_HasFocus);
3227  QPixmap cache;
3228  QString pixmapName = QStyleHelper::uniqueName(QLatin1String("combobox"), option, comboBox->rect.size());
3229  if (sunken)
3230  pixmapName += QLatin1String("-sunken");
3231  if (comboBox->editable)
3232  pixmapName += QLatin1String("-editable");
3233  if (isEnabled)
3234  pixmapName += QLatin1String("-enabled");
3235 
3236  if (!QPixmapCache::find(pixmapName, cache)) {
3237  cache = QPixmap(comboBox->rect.size());
3238  cache.fill(Qt::transparent);
3239  QPainter cachePainter(&cache);
3240  QRect pixmapRect(0, 0, comboBox->rect.width(), comboBox->rect.height());
3241  QStyleOptionComboBox comboBoxCopy = *comboBox;
3242  comboBoxCopy.rect = pixmapRect;
3243 
3244  QRect rect = pixmapRect;
3245  QRect downArrowRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy,
3246  SC_ComboBoxArrow, widget);
3247  QRect editRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy,
3248  SC_ComboBoxEditField, widget);
3249  // Draw a push button
3250  if (comboBox->editable) {
3251  QStyleOptionFrame buttonOption;
3252  buttonOption.QStyleOption::operator=(*comboBox);
3253  buttonOption.rect = rect;
3254  buttonOption.state = comboBox->state & (State_Enabled | State_MouseOver);
3255 
3256  if (sunken) {
3257  buttonOption.state |= State_Sunken;
3258  buttonOption.state &= ~State_MouseOver;
3259  }
3260 
3261  proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget);
3262 
3263  //remove shadow from left side of edit field when pressed:
3264  if (comboBox->direction != Qt::RightToLeft)
3265  cachePainter.fillRect(editRect.left() - 1, editRect.top() + 1, editRect.left(),
3266  editRect.bottom() - 3, option->palette.base());
3267 
3268  cachePainter.setPen(dark.lighter(110));
3269  if (!sunken) {
3270  int borderSize = 2;
3271  if (comboBox->direction == Qt::RightToLeft) {
3272  cachePainter.drawLine(QPoint(downArrowRect.right() - 1, downArrowRect.top() + borderSize ),
3273  QPoint(downArrowRect.right() - 1, downArrowRect.bottom() - borderSize));
3274  cachePainter.setPen(option->palette.light().color());
3275  cachePainter.drawLine(QPoint(downArrowRect.right(), downArrowRect.top() + borderSize),
3276  QPoint(downArrowRect.right(), downArrowRect.bottom() - borderSize));
3277  } else {
3278  cachePainter.drawLine(QPoint(downArrowRect.left() , downArrowRect.top() + borderSize),
3279  QPoint(downArrowRect.left() , downArrowRect.bottom() - borderSize));
3280  cachePainter.setPen(option->palette.light().color());
3281  cachePainter.drawLine(QPoint(downArrowRect.left() + 1, downArrowRect.top() + borderSize),
3282  QPoint(downArrowRect.left() + 1, downArrowRect.bottom() - borderSize));
3283  }
3284  } else {
3285  if (comboBox->direction == Qt::RightToLeft) {
3286  cachePainter.drawLine(QPoint(downArrowRect.right(), downArrowRect.top() + 2),
3287  QPoint(downArrowRect.right(), downArrowRect.bottom() - 2));
3288 
3289  } else {
3290  cachePainter.drawLine(QPoint(downArrowRect.left(), downArrowRect.top() + 2),
3291  QPoint(downArrowRect.left(), downArrowRect.bottom() - 2));
3292  }
3293  }
3294  } else {
3295  QStyleOptionButton buttonOption;
3296  buttonOption.QStyleOption::operator=(*comboBox);
3297  buttonOption.rect = rect;
3298  buttonOption.state = comboBox->state & (State_Enabled | State_MouseOver);
3299  if (sunken) {
3300  buttonOption.state |= State_Sunken;
3301  buttonOption.state &= ~State_MouseOver;
3302  }
3303  proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget);
3304 
3305  cachePainter.setPen(buttonShadow.darker(102));
3306  int borderSize = 4;
3307 
3308  if (!sunken) {
3309  if (comboBox->direction == Qt::RightToLeft) {
3310  cachePainter.drawLine(QPoint(downArrowRect.right() + 1, downArrowRect.top() + borderSize),
3311  QPoint(downArrowRect.right() + 1, downArrowRect.bottom() - borderSize));
3312  cachePainter.setPen(option->palette.light().color());
3313  cachePainter.drawLine(QPoint(downArrowRect.right(), downArrowRect.top() + borderSize),
3314  QPoint(downArrowRect.right(), downArrowRect.bottom() - borderSize));
3315  } else {
3316  cachePainter.drawLine(QPoint(downArrowRect.left() - 1, downArrowRect.top() + borderSize),
3317  QPoint(downArrowRect.left() - 1, downArrowRect.bottom() - borderSize));
3318  cachePainter.setPen(option->palette.light().color());
3319  cachePainter.drawLine(QPoint(downArrowRect.left() , downArrowRect.top() + borderSize),
3320  QPoint(downArrowRect.left() , downArrowRect.bottom() - borderSize));
3321  }
3322  } else {
3323  cachePainter.setPen(dark.lighter(110));
3324  if (comboBox->direction == Qt::RightToLeft) {
3325  cachePainter.drawLine(QPoint(downArrowRect.right() + 1, downArrowRect.top() + borderSize),
3326  QPoint(downArrowRect.right() + 1, downArrowRect.bottom() - borderSize));
3327 
3328  } else {
3329  cachePainter.drawLine(QPoint(downArrowRect.left() - 1, downArrowRect.top() + borderSize),
3330  QPoint(downArrowRect.left() - 1, downArrowRect.bottom() - borderSize));
3331  }
3332  }
3333  }
3334 
3335 
3336  if (comboBox->subControls & SC_ComboBoxArrow) {
3337  if (comboBox->editable) {
3338  // Draw the down arrow
3340  downArrow.setColor(1, comboBox->palette.foreground().color().rgba());
3341  cachePainter.drawImage(downArrowRect.center().x() - downArrow.width() / 2,
3342  downArrowRect.center().y() - downArrow.height() / 2 + 1, downArrow);
3343  } else {
3344  // Draw the up/down arrow
3346  upArrow.setColor(1, comboBox->palette.foreground().color().rgba());
3348  downArrow.setColor(1, comboBox->palette.foreground().color().rgba());
3349  cachePainter.drawImage(downArrowRect.center().x() - downArrow.width() / 2,
3350  downArrowRect.center().y() - upArrow.height() - 1 , upArrow);
3351  cachePainter.drawImage(downArrowRect.center().x() - downArrow.width() / 2,
3352  downArrowRect.center().y() + 2, downArrow);
3353  }
3354  }
3355  // Draw the focus rect
3356  if (focus && !comboBox->editable
3357  && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) {
3358  QStyleOptionFocusRect focus;
3359  focus.rect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxEditField, widget)
3360  .adjusted(0, 2, option->direction == Qt::RightToLeft ? 1 : -1, -2);
3361  proxy()->drawPrimitive(PE_FrameFocusRect, &focus, &cachePainter, widget);
3362  }
3363  cachePainter.end();
3364  QPixmapCache::insert(pixmapName, cache);
3365  }
3366  painter->drawPixmap(comboBox->rect.topLeft(), cache);
3367  }
3368  painter->restore();
3369  break;
3370 #endif // QT_NO_COMBOBOX
3371 #ifndef QT_NO_GROUPBOX
3372  case CC_GroupBox:
3373  painter->save();
3374  if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
3375  QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget);
3376  QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget);
3377  bool flat = groupBox->features & QStyleOptionFrameV2::Flat;
3378 
3379  if(!flat) {
3380  if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
3381  QStyleOptionFrameV2 frame;
3382  frame.QStyleOption::operator=(*groupBox);
3383  frame.features = groupBox->features;
3384  frame.lineWidth = groupBox->lineWidth;
3385  frame.midLineWidth = groupBox->midLineWidth;
3386  frame.rect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget);
3387 
3388  painter->save();
3389  QRegion region(groupBox->rect);
3390  bool ltr = groupBox->direction == Qt::LeftToRight;
3391  region -= checkBoxRect.united(textRect).adjusted(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);
3392  if (!groupBox->text.isEmpty() || groupBox->subControls & SC_GroupBoxCheckBox)
3393  painter->setClipRegion(region);
3394  frame.palette.setBrush(QPalette::Dark, option->palette.mid().color().lighter(110));
3395  proxy()->drawPrimitive(PE_FrameGroupBox, &frame, painter);
3396  painter->restore();
3397  }
3398  }
3399  // Draw title
3400  if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
3401  if (!groupBox->text.isEmpty()) {
3402  QColor textColor = groupBox->textColor;
3403  if (textColor.isValid())
3404  painter->setPen(textColor);
3405  int alignment = int(groupBox->textAlignment);
3406  if (!styleHint(QStyle::SH_UnderlineShortcut, option, widget))
3407  alignment |= Qt::TextHideMnemonic;
3408  if (flat) {
3409  QFont font = painter->font();
3410  font.setBold(true);
3411  painter->setFont(font);
3412  if (groupBox->subControls & SC_GroupBoxCheckBox) {
3413  textRect.adjust(checkBoxRect.right() + 4, 0, checkBoxRect.right() + 4, 0);
3414  }
3415  }
3416  painter->drawText(textRect, Qt::TextShowMnemonic | Qt::AlignLeft| alignment, groupBox->text);
3417  }
3418  }
3419  if (groupBox->subControls & SC_GroupBoxCheckBox) {
3420  QStyleOptionButton box;
3421  box.QStyleOption::operator=(*groupBox);
3422  box.rect = checkBoxRect;
3423  proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
3424  }
3425  }
3426  painter->restore();
3427  break;
3428 #endif // QT_NO_GROUPBOX
3429 #ifndef QT_NO_SLIDER
3430  case CC_Slider:
3431  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
3432  QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
3433  QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
3434 
3435  bool horizontal = slider->orientation == Qt::Horizontal;
3436  bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
3437  bool ticksBelow = slider->tickPosition & QSlider::TicksBelow;
3438  QColor activeHighlight = option->palette.color(QPalette::Normal, QPalette::Highlight);
3439  QPixmap cache;
3440 
3441  QBrush oldBrush = painter->brush();
3442  QPen oldPen = painter->pen();
3443 
3444  QColor shadowAlpha(Qt::black);
3445  shadowAlpha.setAlpha(10);
3446  QColor highlightAlpha(Qt::white);
3447  highlightAlpha.setAlpha(80);
3448 
3449  if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
3450  QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_groove"), option, groove.size());
3451  QRect pixmapRect(0, 0, groove.width(), groove.height());
3452 
3453  // draw background groove
3454  if (!QPixmapCache::find(groovePixmapName, cache)) {
3455  cache = QPixmap(pixmapRect.size());
3456  cache.fill(Qt::transparent);
3457  QPainter groovePainter(&cache);
3458 
3459  groovePainter.setPen(shadowAlpha);
3460  groovePainter.drawLine(1, 0, groove.width(), 0);
3461  groovePainter.drawLine(0, 0, 0, groove.height() - 1);
3462 
3463  groovePainter.setPen(highlightAlpha);
3464  groovePainter.drawLine(1, groove.height() - 1, groove.width() - 1, groove.height() - 1);
3465  groovePainter.drawLine(groove.width() - 1, 1, groove.width() - 1, groove.height() - 1);
3466  QLinearGradient gradient;
3467  if (horizontal) {
3468  gradient.setStart(pixmapRect.center().x(), pixmapRect.top());
3469  gradient.setFinalStop(pixmapRect.center().x(), pixmapRect.bottom());
3470  }
3471  else {
3472  gradient.setStart(pixmapRect.left(), pixmapRect.center().y());
3473  gradient.setFinalStop(pixmapRect.right(), pixmapRect.center().y());
3474  }
3475  groovePainter.setPen(QPen(darkOutline.darker(110), 0));
3476  gradient.setColorAt(0, grooveColor.darker(110));//dark.lighter(120));
3477  gradient.setColorAt(1, grooveColor.lighter(110));//palette.button().color().darker(115));
3478  groovePainter.setBrush(gradient);
3479  groovePainter.drawRect(pixmapRect.adjusted(1, 1, -2, -2));
3480  groovePainter.end();
3481  QPixmapCache::insert(groovePixmapName, cache);
3482  }
3483  painter->drawPixmap(groove.topLeft(), cache);
3484 
3485  // draw blue groove highlight
3486  QRect clipRect;
3487  groovePixmapName += QLatin1String("_blue");
3488  if (!QPixmapCache::find(groovePixmapName, cache)) {
3489  cache = QPixmap(pixmapRect.size());
3490  cache.fill(Qt::transparent);
3491  QPainter groovePainter(&cache);
3492  QLinearGradient gradient;
3493  if (horizontal) {
3494  gradient.setStart(pixmapRect.center().x(), pixmapRect.top());
3495  gradient.setFinalStop(pixmapRect.center().x(), pixmapRect.bottom());
3496  }
3497  else {
3498  gradient.setStart(pixmapRect.left(), pixmapRect.center().y());
3499  gradient.setFinalStop(pixmapRect.right(), pixmapRect.center().y());
3500  }
3501  groovePainter.setPen(QPen(activeHighlight.darker(150), 0));
3502  gradient.setColorAt(0, activeHighlight.darker(120));
3503  gradient.setColorAt(1, activeHighlight.lighter(160));
3504  groovePainter.setBrush(gradient);
3505  groovePainter.drawRect(pixmapRect.adjusted(1, 1, -2, -2));
3506  groovePainter.end();
3507  QPixmapCache::insert(groovePixmapName, cache);
3508  }
3509  if (horizontal) {
3510  if (slider->upsideDown)
3511  clipRect = QRect(handle.right(), groove.top(), groove.right() - handle.right(), groove.height());
3512  else
3513  clipRect = QRect(groove.left(), groove.top(), handle.left(), groove.height());
3514  } else {
3515  if (slider->upsideDown)
3516  clipRect = QRect(groove.left(), handle.bottom(), groove.width(), groove.height() - handle.bottom());
3517  else
3518  clipRect = QRect(groove.left(), groove.top(), groove.width(), handle.top() - groove.top());
3519  }
3520  painter->save();
3521  painter->setClipRect(clipRect.adjusted(0, 0, 1, 1));
3522  painter->drawPixmap(groove.topLeft(), cache);
3523  painter->restore();
3524  }
3525 
3526  // draw handle
3527  if ((option->subControls & SC_SliderHandle) ) {
3528  QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size());
3529  if (!QPixmapCache::find(handlePixmapName, cache)) {
3530  cache = QPixmap(handle.size());
3531  cache.fill(Qt::transparent);
3532  QRect pixmapRect(0, 0, handle.width(), handle.height());
3533  QPainter handlePainter(&cache);
3534 
3535  QColor gradientStartColor = mergedColors(option->palette.button().color().lighter(155),
3536  dark.lighter(155), 50);
3537  QColor gradientStopColor = gradientStartColor.darker(108);
3538  QRect gradRect = pixmapRect.adjusted(2, 2, -2, -2);
3539 
3540  QColor gradientBgStartColor = gradientStartColor;
3541  QColor gradientBgStopColor = gradientStopColor;
3542 
3543  QColor outline = option->state & State_Enabled ? dark : dark.lighter(130);
3544  if (option->state & State_Enabled && option->activeSubControls & SC_SliderHandle) {
3545  gradientBgStartColor = option->palette.highlight().color().lighter(180);
3546  gradientBgStopColor = option->palette.highlight().color().lighter(110);
3547  outline = option->palette.highlight().color().darker(130);
3548  }
3549 
3550  // gradient fill
3551  QRect r = pixmapRect.adjusted(1, 1, -1, -1);
3552 
3553  qt_cleanlooks_draw_gradient(&handlePainter, gradRect,
3554  gradientBgStartColor,
3555  gradientBgStopColor,
3556  horizontal ? TopDown : FromLeft, option->palette.button());
3557 
3558  handlePainter.setPen(QPen(outline.darker(110), 1));
3559  handlePainter.drawLine(QPoint(r.left(), r.top() + 3), QPoint(r.left(), r.bottom() - 3));
3560  handlePainter.drawLine(QPoint(r.right(), r.top() + 3), QPoint(r.right(), r.bottom() - 3));
3561  handlePainter.drawLine(QPoint(r.left() + 3, r.bottom()), QPoint(r.right() - 3, r.bottom()));
3562 
3563  handlePainter.save();
3564  handlePainter.setRenderHint(QPainter::Antialiasing);
3565  handlePainter.translate(0.5, 0.5);
3566  const QLine lines[4] = {
3567  QLine(QPoint(r.left(), r.bottom() - 2), QPoint(r.left() + 2, r.bottom())),
3568  QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left() + 2, r.top())),
3569  QLine(QPoint(r.right(), r.bottom() - 2), QPoint(r.right() - 2, r.bottom())),
3570  QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right() - 2, r.top()))
3571  };
3572  handlePainter.drawLines(lines, 4);
3573  handlePainter.restore();;
3574  handlePainter.setPen(QPen(outline.darker(130), 1));
3575  handlePainter.drawLine(QPoint(r.left() + 3, r.top()), QPoint(r.right() - 3, r.top()));
3576  QColor cornerAlpha = outline.darker(120);
3577  cornerAlpha.setAlpha(80);
3578 
3579  handlePainter.setPen(cornerAlpha);
3580  if (horizontal) {
3581  handlePainter.drawLine(QPoint(r.left() + 6, r.top()), QPoint(r.left() + 6, r.bottom()));
3582  handlePainter.drawLine(QPoint(r.right() - 6, r.top()), QPoint(r.right() - 6, r.bottom()));
3583  } else {
3584  handlePainter.drawLine(QPoint(r.left(), r.top() + 6), QPoint(r.right(), r.top() + 6));
3585  handlePainter.drawLine(QPoint(r.left(), r.bottom() - 6), QPoint(r.right(), r.bottom() - 6));
3586  }
3587 
3588  //handle shadow
3589  handlePainter.setPen(shadowAlpha);
3590  handlePainter.drawLine(QPoint(r.left() + 2, r.bottom() + 1), QPoint(r.right() - 2, r.bottom() + 1));
3591  handlePainter.drawLine(QPoint(r.right() + 1, r.bottom() - 3), QPoint(r.right() + 1, r.top() + 4));
3592  handlePainter.drawLine(QPoint(r.right() - 1, r.bottom()), QPoint(r.right() + 1, r.bottom() - 2));
3593 
3594  qt_cleanlooks_draw_gradient(&handlePainter, horizontal ?
3595  gradRect.adjusted(6, 0, -6, 0) : gradRect.adjusted(0, 6, 0, -6),
3596  gradientStartColor,
3597  gradientStopColor.darker(106),
3598  horizontal ? TopDown : FromLeft,
3599  option->palette.button());
3600 
3601  //draw grips
3602  for (int i = -3; i< 6 ; i += 3) {
3603  for (int j = -3; j< 6 ; j += 3) {
3604  handlePainter.fillRect(r.center().x() + i, r.center().y() + j, 2, 2, highlightAlpha);
3605  handlePainter.setPen(gripShadow);
3606  handlePainter.drawPoint(r.center().x() + i, r.center().y() + j );
3607  }
3608  }
3609  handlePainter.end();
3610  QPixmapCache::insert(handlePixmapName, cache);
3611  }
3612 
3613  painter->drawPixmap(handle.topLeft(), cache);
3614 
3615  if (slider->state & State_HasFocus) {
3616  QStyleOptionFocusRect fropt;
3617  fropt.QStyleOption::operator=(*slider);
3618  fropt.rect = slider->rect;
3619  proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
3620  }
3621  }
3622  if (option->subControls & SC_SliderTickmarks) {
3623  painter->setPen(darkOutline);
3624  int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
3625  int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
3626  int interval = slider->tickInterval;
3627  if (interval <= 0) {
3628  interval = slider->singleStep;
3629  if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
3630  available)
3631  - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
3632  0, available) < 3)
3633  interval = slider->pageStep;
3634  }
3635  if (interval <= 0)
3636  interval = 1;
3637 
3638  int v = slider->minimum;
3639  int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
3640  while (v <= slider->maximum + 1) {
3641  if (v == slider->maximum + 1 && interval == 1)
3642  break;
3643  const int v_ = qMin(v, slider->maximum);
3644  int pos = sliderPositionFromValue(slider->minimum, slider->maximum,
3645  v_, (horizontal
3646  ? slider->rect.width()
3647  : slider->rect.height()) - len,
3648  slider->upsideDown) + len / 2;
3649  int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0);
3650 
3651  if (horizontal) {
3652  if (ticksAbove) {
3653  painter->drawLine(pos, slider->rect.top() + extra,
3654  pos, slider->rect.top() + tickSize);
3655  }
3656  if (ticksBelow) {
3657  painter->drawLine(pos, slider->rect.bottom() - extra,
3658  pos, slider->rect.bottom() - tickSize);
3659  }
3660  } else {
3661  if (ticksAbove) {
3662  painter->drawLine(slider->rect.left() + extra, pos,
3663  slider->rect.left() + tickSize, pos);
3664  }
3665  if (ticksBelow) {
3666  painter->drawLine(slider->rect.right() - extra, pos,
3667  slider->rect.right() - tickSize, pos);
3668  }
3669  }
3670  // in the case where maximum is max int
3671  int nextInterval = v + interval;
3672  if (nextInterval < v)
3673  break;
3674  v = nextInterval;
3675  }
3676  }
3677  painter->setBrush(oldBrush);
3678  painter->setPen(oldPen);
3679  }
3680  break;
3681 #endif // QT_NO_SLIDER
3682 #ifndef QT_NO_DIAL
3683  case CC_Dial:
3684  if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option))
3685  QStyleHelper::drawDial(dial, painter);
3686  break;
3687 #endif // QT_NO_DIAL
3688  default:
3689  QWindowsStyle::drawComplexControl(control, option, painter, widget);
3690  break;
3691  }
3692 }
3693 
3697 int QCleanlooksStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
3698 {
3699  int ret = -1;
3700  switch (metric) {
3702  ret = 2;
3703  break;
3705  ret = 0;
3706  break;
3709  ret = 0;
3710  break;
3711  case PM_MessageBoxIconSize:
3712  ret = 48;
3713  break;
3714  case PM_ListViewIconSize:
3715  ret = 24;
3716  break;
3718  case PM_SplitterWidth:
3719  ret = 6;
3720  break;
3721  case PM_ScrollBarSliderMin:
3722  ret = 26;
3723  break;
3724  case PM_MenuPanelWidth: //menu framewidth
3725  ret = 2;
3726  break;
3727  case PM_TitleBarHeight:
3728  ret = 24;
3729  break;
3730  case PM_ScrollBarExtent:
3731  ret = 15;
3732  break;
3733  case PM_SliderThickness:
3734  ret = 15;
3735  break;
3736  case PM_SliderLength:
3737  ret = 27;
3738  break;
3740  ret = 1;
3741  break;
3742  case PM_MenuBarVMargin:
3743  ret = 1;
3744  break;
3745  case PM_DefaultFrameWidth:
3746  ret = 2;
3747  break;
3748  case PM_SpinBoxFrameWidth:
3749  ret = 3;
3750  break;
3751  case PM_MenuBarItemSpacing:
3752  ret = 6;
3753  break;
3754  case PM_MenuBarHMargin:
3755  ret = 0;
3756  break;
3758  ret = 9;
3759  break;
3760  case PM_ToolBarItemSpacing:
3761  ret = 2;
3762  break;
3763  case PM_ToolBarFrameWidth:
3764  ret = 0;
3765  break;
3766  case PM_ToolBarItemMargin:
3767  ret = 1;
3768  break;
3769  case PM_SmallIconSize:
3770  ret = 16;
3771  break;
3772  case PM_ButtonIconSize:
3773  ret = 24;
3774  break;
3775  case PM_MenuVMargin:
3776  case PM_MenuHMargin:
3777  ret = 0;
3778  break;
3780  ret = 4;
3781  break;
3783  return -1;
3786  return 20;
3787  default:
3788  break;
3789  }
3790 
3791  return ret != -1 ? ret : QWindowsStyle::pixelMetric(metric, option, widget);
3792 }
3793 
3798  const QSize &size, const QWidget *widget) const
3799 {
3800  QSize newSize = QWindowsStyle::sizeFromContents(type, option, size, widget);
3801  switch (type) {
3802  case CT_PushButton:
3803  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
3804  if (!btn->text.isEmpty() && newSize.width() < 80)
3805  newSize.setWidth(80);
3806  if (!btn->icon.isNull() && btn->iconSize.height() > 16)
3807  newSize -= QSize(0, 2);
3808  newSize += QSize(0, 1);
3809  }
3810  if (const QPushButton *button = qobject_cast<const QPushButton *>(widget)) {
3811  if (qobject_cast<const QDialogButtonBox *>(button->parentWidget())) {
3812  if (newSize.height() < 32)
3813  newSize.setHeight(32);
3814  }
3815  }
3816  break;
3817 #ifndef QT_NO_GROUPBOX
3818  case CT_GroupBox:
3819  // Since we use a bold font we have to recalculate base width
3820  if (const QGroupBox *gb = qobject_cast<const QGroupBox*>(widget)) {
3821  QFont font = gb->font();
3822  font.setBold(true);
3823  QFontMetrics metrics(font);
3824  int baseWidth = metrics.width(gb->title()) + metrics.width(QLatin1Char(' '));
3825  if (gb->isCheckable()) {
3826  baseWidth += proxy()->pixelMetric(QStyle::PM_IndicatorWidth, option, widget);
3827  baseWidth += proxy()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, option, widget);
3828  }
3829  newSize.setWidth(qMax(baseWidth, newSize.width()));
3830  }
3831  newSize += QSize(0, 1);
3832  break;
3833 #endif //QT_NO_GROUPBOX
3834  case CT_RadioButton:
3835  case CT_CheckBox:
3836  newSize += QSize(0, 1);
3837  break;
3838  case CT_ToolButton:
3839 #ifndef QT_NO_TOOLBAR
3840  if (widget && qobject_cast<QToolBar *>(widget->parentWidget()))
3841  newSize += QSize(4, 6);
3842 #endif // QT_NO_TOOLBAR
3843  break;
3844  case CT_SpinBox:
3845  newSize += QSize(0, -2);
3846  break;
3847  case CT_ComboBox:
3848  newSize += QSize(2, 4);
3849  break;
3850  case CT_LineEdit:
3851  newSize += QSize(0, 4);
3852  break;
3853  case CT_MenuBarItem:
3854  newSize += QSize(0, 2);
3855  break;
3856  case CT_MenuItem:
3857  if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
3858  if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
3859  if (!menuItem->text.isEmpty()) {
3860  newSize.setHeight(menuItem->fontMetrics.height());
3861  }
3862  }
3863 #ifndef QT_NO_COMBOBOX
3864  else if (!menuItem->icon.isNull()) {
3865  if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget)) {
3866  newSize.setHeight(qMax(combo->iconSize().height() + 2, newSize.height()));
3867  }
3868  }
3869 #endif // QT_NO_COMBOBOX
3870  }
3871  break;
3872  case CT_SizeGrip:
3873  newSize += QSize(4, 4);
3874  break;
3875  case CT_MdiControls:
3876  if (const QStyleOptionComplex *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(option)) {
3877  int width = 0;
3878  if (styleOpt->subControls & SC_MdiMinButton)
3879  width += 19 + 1;
3880  if (styleOpt->subControls & SC_MdiNormalButton)
3881  width += 19 + 1;
3882  if (styleOpt->subControls & SC_MdiCloseButton)
3883  width += 19 + 1;
3884  newSize = QSize(width, 19);
3885  } else {
3886  newSize = QSize(60, 19);
3887  }
3888  break;
3889  default:
3890  break;
3891  }
3892  return newSize;
3893 }
3894 
3899 {
3900  QWindowsStyle::polish(app);
3901 }
3902 
3907 {
3908  QWindowsStyle::polish(widget);
3909  if (qobject_cast<QAbstractButton*>(widget)
3910 #ifndef QT_NO_COMBOBOX
3911  || qobject_cast<QComboBox *>(widget)
3912 #endif
3913 #ifndef QT_NO_PROGRESSBAR
3914  || qobject_cast<QProgressBar *>(widget)
3915 #endif
3916 #ifndef QT_NO_SCROLLBAR
3917  || qobject_cast<QScrollBar *>(widget)
3918 #endif
3919 #ifndef QT_NO_SPLITTER
3920  || qobject_cast<QSplitterHandle *>(widget)
3921 #endif
3922  || qobject_cast<QAbstractSlider *>(widget)
3923 #ifndef QT_NO_SPINBOX
3924  || qobject_cast<QAbstractSpinBox *>(widget)
3925 #endif
3926  || (widget->inherits("QWorkspaceChild"))
3927  || (widget->inherits("QDockSeparator"))
3928  || (widget->inherits("QDockWidgetSeparator"))
3929  ) {
3930  widget->setAttribute(Qt::WA_Hover, true);
3931  }
3932 }
3933 
3938 {
3939  QWindowsStyle::polish(pal);
3940  //this is a workaround for some themes such as Human, where the contrast
3941  //between text and background is too low.
3942  QColor highlight = pal.highlight().color();
3943  QColor highlightText = pal.highlightedText().color();
3944  if (qAbs(qGray(highlight.rgb()) - qGray(highlightText.rgb())) < 150) {
3945  if (qGray(highlightText.rgb()) < 128)
3946  pal.setBrush(QPalette::Highlight, highlight.lighter(145));
3947  }
3948 }
3949 
3954 {
3955  QWindowsStyle::unpolish(widget);
3956  if (qobject_cast<QAbstractButton*>(widget)
3957 #ifndef QT_NO_COMBOBOX
3958  || qobject_cast<QComboBox *>(widget)
3959 #endif
3960 #ifndef QT_NO_PROGRESSBAR
3961  || qobject_cast<QProgressBar *>(widget)
3962 #endif
3963 #ifndef QT_NO_SCROLLBAR
3964  || qobject_cast<QScrollBar *>(widget)
3965 #endif
3966 #ifndef QT_NO_SPLITTER
3967  || qobject_cast<QSplitterHandle *>(widget)
3968 #endif
3969  || qobject_cast<QAbstractSlider *>(widget)
3970 #ifndef QT_NO_SPINBOX
3971  || qobject_cast<QAbstractSpinBox *>(widget)
3972 #endif
3973  || (widget->inherits("QWorkspaceChild"))
3974  || (widget->inherits("QDockSeparator"))
3975  || (widget->inherits("QDockWidgetSeparator"))
3976  ) {
3977  widget->setAttribute(Qt::WA_Hover, false);
3978  }
3979 }
3980 
3985 {
3987 }
3988 
3993  SubControl subControl, const QWidget *widget) const
3994 {
3995  QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget);
3996 
3997  switch (control) {
3998 #ifndef QT_NO_SLIDER
3999  case CC_Slider:
4000  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
4001  int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
4002  switch (subControl) {
4003  case SC_SliderHandle: {
4004  if (slider->orientation == Qt::Horizontal) {
4007  int centerY = slider->rect.center().y() - rect.height() / 2;
4008  if (slider->tickPosition & QSlider::TicksAbove)
4009  centerY += tickSize;
4010  if (slider->tickPosition & QSlider::TicksBelow)
4011  centerY -= tickSize;
4012  rect.moveTop(centerY);
4013  } else {
4016  int centerX = slider->rect.center().x() - rect.width() / 2;
4017  if (slider->tickPosition & QSlider::TicksAbove)
4018  centerX += tickSize;
4019  if (slider->tickPosition & QSlider::TicksBelow)
4020  centerX -= tickSize;
4021  rect.moveLeft(centerX);
4022  }
4023  }
4024  break;
4025  case SC_SliderGroove: {
4026  QPoint grooveCenter = slider->rect.center();
4027  if (slider->orientation == Qt::Horizontal) {
4028  rect.setHeight(7);
4029  if (slider->tickPosition & QSlider::TicksAbove)
4030  grooveCenter.ry() += tickSize;
4031  if (slider->tickPosition & QSlider::TicksBelow)
4032  grooveCenter.ry() -= tickSize;
4033  } else {
4034  rect.setWidth(7);
4035  if (slider->tickPosition & QSlider::TicksAbove)
4036  grooveCenter.rx() += tickSize;
4037  if (slider->tickPosition & QSlider::TicksBelow)
4038  grooveCenter.rx() -= tickSize;
4039  }
4040  rect.moveCenter(grooveCenter);
4041  break;
4042  }
4043  default:
4044  break;
4045  }
4046  }
4047  break;
4048 #endif // QT_NO_SLIDER
4049  case CC_ScrollBar:
4050  break;
4051 #ifndef QT_NO_SPINBOX
4052  case CC_SpinBox:
4053  if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
4054  QSize bs;
4055  int center = spinbox->rect.height() / 2;
4056  int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
4057  int y = fw;
4058  bs.setHeight(qMax(8, spinbox->rect.height()/2 - y));
4059  bs.setWidth(15);
4060  int x, lx, rx;
4061  x = spinbox->rect.width() - y - bs.width() + 2;
4062  lx = fw;
4063  rx = x - fw;
4064  switch (subControl) {
4065  case SC_SpinBoxUp:
4066  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
4067  return QRect();
4068  rect = QRect(x, fw, bs.width(), center - fw);
4069  break;
4070  case SC_SpinBoxDown:
4071  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
4072  return QRect();
4073 
4074  rect = QRect(x, center, bs.width(), spinbox->rect.bottom() - center - fw + 1);
4075  break;
4076  case SC_SpinBoxEditField:
4077  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) {
4078  rect = QRect(lx, fw, spinbox->rect.width() - 2*fw, spinbox->rect.height() - 2*fw);
4079  } else {
4080  rect = QRect(lx, fw, rx - qMax(fw - 1, 0), spinbox->rect.height() - 2*fw);
4081  }
4082  break;
4083  case SC_SpinBoxFrame:
4084  rect = spinbox->rect;
4085  default:
4086  break;
4087  }
4088  rect = visualRect(spinbox->direction, spinbox->rect, rect);
4089  }
4090  break;
4091 #endif // Qt_NO_SPINBOX
4092 #ifndef QT_NO_GROUPBOX
4093  case CC_GroupBox:
4094  if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
4095  int topMargin = 0;
4096  int topHeight = 0;
4097  int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget);
4098  bool flat = groupBox->features & QStyleOptionFrameV2::Flat;
4099  if (!groupBox->text.isEmpty()) {
4100  topHeight = groupBox->fontMetrics.height();
4101  if (verticalAlignment & Qt::AlignVCenter)
4102  topMargin = topHeight / 2;
4103  else if (verticalAlignment & Qt::AlignTop)
4104  topMargin = topHeight;
4105  }
4106  QRect frameRect = groupBox->rect;
4107  frameRect.setTop(topMargin);
4108  if (subControl == SC_GroupBoxFrame) {
4109  return rect;
4110  }
4111  else if (subControl == SC_GroupBoxContents) {
4112  if( flat ) {
4113  int margin = 0;
4114  int leftMarginExtension = 16;
4115  rect = frameRect.adjusted(leftMarginExtension + margin, margin + topHeight, -margin, -margin);
4116  }
4117  break;
4118  }
4119  if(flat) {
4120  if (const QGroupBox *groupBoxWidget = qobject_cast<const QGroupBox *>(widget)) {
4121  //Prepare metrics for a bold font
4122  QFont font = widget->font();
4123  font.setBold(true);
4124  QFontMetrics fontMetrics(font);
4125 
4126  QSize textRect = fontMetrics.boundingRect(groupBoxWidget->title()).size() + QSize(2, 2);
4127  if (subControl == SC_GroupBoxCheckBox) {
4128  int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget);
4129  int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget);
4130  rect.setWidth(indicatorWidth);
4131  rect.setHeight(indicatorHeight);
4132  rect.moveTop((fontMetrics.height() - indicatorHeight) / 2 + 2);
4133  } else if (subControl == SC_GroupBoxLabel) {
4134  rect.setSize(textRect);
4135  }
4136  }
4137  }
4138  }
4139  return rect;
4140 #ifndef QT_NO_COMBOBOX
4141  case CC_ComboBox:
4142  switch (subControl) {
4143  case SC_ComboBoxArrow:
4144  rect = visualRect(option->direction, option->rect, rect);
4145  rect.setRect(rect.right() - 18, rect.top() - 2,
4146  19, rect.height() + 4);
4147  rect = visualRect(option->direction, option->rect, rect);
4148  break;
4149  case SC_ComboBoxEditField: {
4150  int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth);
4151  rect = visualRect(option->direction, option->rect, rect);
4152  rect.setRect(option->rect.left() + frameWidth, option->rect.top() + frameWidth,
4153  option->rect.width() - 19 - 2 * frameWidth,
4154  option->rect.height() - 2 * frameWidth);
4155  if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
4156  if (!box->editable) {
4157  rect.adjust(2, 0, 0, 0);
4158  if (box->state & (State_Sunken | State_On))
4159  rect.translate(1, 1);
4160  }
4161  }
4162  rect = visualRect(option->direction, option->rect, rect);
4163  break;
4164  }
4165  default:
4166  break;
4167  }
4168  break;
4169 #endif // QT_NO_COMBOBOX
4170 #endif //QT_NO_GROUPBOX
4171  case CC_TitleBar:
4172  if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
4173  SubControl sc = subControl;
4174  QRect &ret = rect;
4175  const int indent = 3;
4176  const int controlTopMargin = 3;
4177  const int controlBottomMargin = 3;
4178  const int controlWidthMargin = 2;
4179  const int controlHeight = tb->rect.height() - controlTopMargin - controlBottomMargin ;
4180  const int delta = controlHeight + controlWidthMargin;
4181  int offset = 0;
4182 
4183  bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
4184  bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
4185 
4186  switch (sc) {
4187  case SC_TitleBarLabel:
4188  if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) {
4189  ret = tb->rect;
4190  if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
4191  ret.adjust(delta, 0, -delta, 0);
4192  if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
4193  ret.adjust(0, 0, -delta, 0);
4194  if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
4195  ret.adjust(0, 0, -delta, 0);
4196  if (tb->titleBarFlags & Qt::WindowShadeButtonHint)
4197  ret.adjust(0, 0, -delta, 0);
4198  if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
4199  ret.adjust(0, 0, -delta, 0);
4200  }
4201  break;
4203  if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
4204  offset += delta;
4205  case SC_TitleBarMinButton:
4206  if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
4207  offset += delta;
4208  else if (sc == SC_TitleBarMinButton)
4209  break;
4211  if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
4212  offset += delta;
4213  else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
4214  offset += delta;
4215  else if (sc == SC_TitleBarNormalButton)
4216  break;
4217  case SC_TitleBarMaxButton:
4218  if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
4219  offset += delta;
4220  else if (sc == SC_TitleBarMaxButton)
4221  break;
4223  if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
4224  offset += delta;
4225  else if (sc == SC_TitleBarShadeButton)
4226  break;
4228  if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
4229  offset += delta;
4230  else if (sc == SC_TitleBarUnshadeButton)
4231  break;
4233  if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
4234  offset += delta;
4235  else if (sc == SC_TitleBarCloseButton)
4236  break;
4237  ret.setRect(tb->rect.right() - indent - offset, tb->rect.top() + controlTopMargin,
4238  controlHeight, controlHeight);
4239  break;
4240  case SC_TitleBarSysMenu:
4241  if (tb->titleBarFlags & Qt::WindowSystemMenuHint) {
4242  ret.setRect(tb->rect.left() + controlWidthMargin + indent, tb->rect.top() + controlTopMargin,
4243  controlHeight, controlHeight);
4244  }
4245  break;
4246  default:
4247  break;
4248  }
4249  ret = visualRect(tb->direction, tb->rect, ret);
4250  }
4251  break;
4252  default:
4253  break;
4254  }
4255 
4256  return rect;
4257 }
4258 
4259 
4263 QRect QCleanlooksStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
4264 {
4265  return QWindowsStyle::itemPixmapRect(r, flags, pixmap);
4266 }
4267 
4272  int alignment, const QPixmap &pixmap) const
4273 {
4274  QWindowsStyle::drawItemPixmap(painter, rect, alignment, pixmap);
4275 }
4276 
4281  const QPoint &pt, const QWidget *w) const
4282 {
4283  return QWindowsStyle::hitTestComplexControl(cc, opt, pt, w);
4284 }
4285 
4290  const QStyleOption *opt) const
4291 {
4292  return QWindowsStyle::generatedIconPixmap(iconMode, pixmap, opt);
4293 }
4294 
4299  QStyleHintReturn *returnData) const
4300 {
4301  int ret = 0;
4302  switch (hint) {
4304  ret = true;
4305  break;
4306  case SH_EtchDisabledText:
4307  ret = 1;
4308  break;
4310  ret = false;
4311  break;
4313  ret = 0;
4314  break;
4316  ret = 1;
4317  break;
4318  case SH_TitleBar_AutoRaise:
4319  ret = 1;
4320  break;
4321  case SH_TitleBar_NoBorder:
4322  ret = 1;
4323  break;
4325  ret = true;
4326  break;
4328  if (option) {
4329  ret = option->palette.background().color().darker(120).rgb();
4330  break;
4331  }
4332  case SH_ComboBox_Popup:
4333 #ifdef QT3_SUPPORT
4334  if (widget && widget->inherits("Q3ComboBox"))
4335  return 0;
4336 #endif
4337  if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option))
4338  ret = !cmb->editable;
4339  else
4340  ret = 0;
4341  break;
4342  case SH_WindowFrame_Mask:
4343  ret = 1;
4344  if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask *>(returnData)) {
4345  //left rounded corner
4346  mask->region = option->rect;
4347  mask->region -= QRect(option->rect.left(), option->rect.top(), 5, 1);
4348  mask->region -= QRect(option->rect.left(), option->rect.top() + 1, 3, 1);
4349  mask->region -= QRect(option->rect.left(), option->rect.top() + 2, 2, 1);
4350  mask->region -= QRect(option->rect.left(), option->rect.top() + 3, 1, 2);
4351 
4352  //right rounded corner
4353  mask->region -= QRect(option->rect.right() - 4, option->rect.top(), 5, 1);
4354  mask->region -= QRect(option->rect.right() - 2, option->rect.top() + 1, 3, 1);
4355  mask->region -= QRect(option->rect.right() - 1, option->rect.top() + 2, 2, 1);
4356  mask->region -= QRect(option->rect.right() , option->rect.top() + 3, 1, 2);
4357  }
4358  break;
4361  break;
4363  ret = true;
4364  break;
4366  ret = false;
4367  break;
4368 #ifndef QT_NO_WIZARD
4369  case SH_WizardStyle:
4370  ret = QWizard::ClassicStyle;
4371  break;
4372 #endif
4374  ret = false;
4375  break;
4377  ret = 225; // default from GtkMenu
4378  break;
4379  default:
4380  ret = QWindowsStyle::styleHint(hint, option, widget, returnData);
4381  break;
4382  }
4383  return ret;
4384 }
4385 
4388 {
4389  QRect r = QWindowsStyle::subElementRect(sr, opt, w);
4390  switch (sr) {
4392  r.adjust(0, 1, 0, -1);
4393  break;
4395  const QStyleOptionDockWidgetV2 *v2
4397  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
4398  if (verticalTitleBar) {
4399  r.adjust(0, 0, 0, -4);
4400  } else {
4401  if (opt->direction == Qt::LeftToRight)
4402  r.adjust(4, 0, 0, 0);
4403  else
4404  r.adjust(0, 0, -4, 0);
4405  }
4406 
4407  break;
4408  }
4410  r = subElementRect(SE_ProgressBarGroove, opt, w);
4411  break;
4412  default:
4413  break;
4414  }
4415  return r;
4416 }
4417 
4422  const QStyleOption *option,
4423  const QWidget *widget) const
4424 {
4425  return QWindowsStyle::standardIconImplementation(standardIcon, option, widget);
4426 }
4427 
4432  const QWidget *widget) const
4433 {
4434  QPixmap pixmap;
4435 
4436 #ifndef QT_NO_IMAGEFORMAT_XPM
4437  switch (standardPixmap) {
4439  return QPixmap((const char **)dock_widget_restore_xpm);
4440  case SP_TitleBarMinButton:
4441  return QPixmap((const char **)workspace_minimize);
4444  return QPixmap((const char **)dock_widget_close_xpm);
4445 
4446  default:
4447  break;
4448  }
4449 #endif //QT_NO_IMAGEFORMAT_XPM
4450 
4451  return QWindowsStyle::standardPixmap(standardPixmap, opt, widget);
4452 }
4453 
4455 
4456 #endif // QT_NO_STYLE_CLEANLOOKS || QT_PLUGIN
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
#define BEGIN_STYLE_PIXMAPCACHE(a)
Definition: qstyle_p.h:76
void polish(QWidget *widget)
Reimplemented Function
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
Definition: qpainter.cpp:9547
void setBackgroundMode(Qt::BGMode mode)
Sets the background mode of the painter to the given mode.
Definition: qpainter.cpp:3998
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
void setFinalStop(const QPointF &stop)
Sets the final stop point of this linear gradient in logical coordinates to stop. ...
Definition: qbrush.cpp:1875
void setRed(int red)
Sets the red color component of this color to red.
Definition: qcolor.cpp:1143
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
static const char *const dock_widget_close_xpm[]
void polish(QApplication *)
Reimplemented Function
void unpolish(QApplication *)
Reimplemented Function
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition: qpalette.h:140
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
static const char *const qt_scrollbar_button_left[]
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
unsigned int QRgb
Definition: qrgb.h:53
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
const QBrush & base() const
Returns the base brush of the current color group.
Definition: qpalette.h:130
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
Reimplemented Function
int type
Definition: qmetatype.cpp:239
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
void setColor(int i, QRgb c)
Sets the color at the given index in the color table, to the given to colorValue. ...
Definition: qimage.cpp:1850
StyleHint
This enum describes the available style hints.
Definition: qstyle.h:640
double qreal
Definition: qglobal.h:1193
The QStyleHintReturn class provides style hints that return more than basic data types.
Definition: qstyleoption.h:907
static const char *const qt_scrollbar_button_arrow_left[]
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition: qbrush.cpp:1475
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QStyleOptionDockWidget class is used to describe the parameters for drawing a dock widget...
Definition: qstyleoption.h:504
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=0) const
Reimplemented Function
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
ushort hue
Returns the hue color component of this color.
Definition: qcolor.h:250
QPointer< QWidget > widget
static void qt_cleanlooks_draw_buttongradient(QPainter *painter, const QRect &rect, const QColor &gradientStart, const QColor &gradientMid, const QColor &gradientStop, Direction direction=TopDown, QBrush bgBrush=QBrush())
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
static QPoint visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
Returns the given logicalPosition converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2109
The QLine class provides a two-dimensional vector using integer precision.
Definition: qline.h:57
void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the array points using the current pen&#39;s color.
Definition: qpainter.cpp:3816
void moveLeft(int pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s left edge at the given x coordinate...
Definition: qrect.h:350
const QGradient * gradient() const
Returns the gradient describing this brush.
Definition: qbrush.cpp:871
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
#define QT_NO_SPLITTER
QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
QPoint p1() const
Returns the line&#39;s start point.
Definition: qline.h:132
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
virtual QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
Returns the area within the given rectangle in which to draw the specified pixmap according to the de...
Definition: qstyle.cpp:497
void rotate(qreal a)
Rotates the coordinate system the given angle clockwise.
Definition: qpainter.cpp:3287
const QBrush & background() const
Use window() instead.
Definition: qpalette.h:134
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
QFont font
the font used for the menu item text
Definition: qstyleoption.h:454
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
ComplexControl
This enum describes the available complex controls.
Definition: qstyle.h:386
QPoint p2() const
Returns the line&#39;s end point.
Definition: qline.h:137
QRect united(const QRect &other) const
Returns the bounding rectangle of this rectangle and the given rectangle.
Definition: qrect.h:491
static C reverse(const C &l)
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
Definition: qpainter.cpp:2801
QFont font
the font currently set for the widget
Definition: qwidget.h:181
static const char *const qt_cleanlooks_radiobutton_checked[]
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
void setGreen(int green)
Sets the green color component of this color to green.
Definition: qcolor.cpp:1170
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
State
This enum describes the state for which a pixmap is intended to be used.
Definition: qicon.h:64
PixelMetric
This enum describes the various available pixel metrics.
Definition: qstyle.h:474
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
#define END_STYLE_PIXMAPCACHE
Definition: qstyle_p.h:96
static const char *const qt_scrollbar_button_arrow_up[]
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
The QPushButton widget provides a command button.
Definition: qpushbutton.h:57
The QStyleOptionToolBar class is used to describe the parameters for drawing a toolbar.
Definition: qstyleoption.h:369
int & ry()
Returns a reference to the y coordinate of this point.
Definition: qpoint.h:143
QPalette::ColorRole backgroundRole() const
Returns the background role of the widget.
Definition: qwidget.cpp:4677
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
Definition: qstyle.cpp:532
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
Reimplemented Function
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
static const char *const qt_scrollbar_button_up[]
QTransform & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qtransform.cpp:417
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void setY(int y)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:285
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static const char *const qt_scrollbar_button_right[]
static const char *const qt_spinbox_button_arrow_down[]
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
void drawControl(ControlElement ce, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
Reimplemented Function
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setBrushOrigin(int x, int y)
Sets the brush&#39;s origin to point (x, y).
Definition: qpainter.h:825
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const
Reimplemented Function
static const uint base
Definition: qurl.cpp:268
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen&#39;s color.
Definition: qpainter.h:676
NSToolbar * toolbar
static const char *const qt_cleanlooks_radiobutton[]
QString text
the text for the menu item
Definition: qstyleoption.h:450
static int sliderPositionFromValue(int min, int max, int val, int space, bool upsideDown=false)
Converts the given logicalValue to a pixel position.
Definition: qstyle.cpp:2176
bool frame
whether the spin box has a frame
Definition: qstyleoption.h:737
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
static const char *const qt_cleanlooks_arrow_up_xpm[]
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags=0) const
If the string text is wider than width, returns an elided version of the string (i.
StandardPixmap
This enum describes the available standard pixmaps.
Definition: qstyle.h:755
static const char *const qt_scrollbar_button_down[]
static QPixmap * find(const QString &key)
void setHsv(int h, int s, int v, int a=255)
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha componen...
Definition: qcolor.cpp:734
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
ColorGroup currentColorGroup() const
Returns the palette&#39;s current color group.
Definition: qpalette.h:104
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Reimplemented Function
QRect boundingRect(QChar) const
Returns the rectangle that is covered by ink if character ch were to be drawn at the origin of the co...
QGradientStops stops() const
Returns the stop points for this gradient.
Definition: qbrush.cpp:1520
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor=50)
int lineWidth
the line width for drawing the frame
Definition: qstyleoption.h:124
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
int width() const
Returns the width.
Definition: qsize.h:126
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
void drawRects(const QRectF *rects, int rectCount)
Draws the first rectCount of the given rectangles using the current pen and brush.
Definition: qpainter.cpp:3641
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
Definition: qpainter.cpp:4464
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
Definition: qpainter.cpp:2077
ushort value
Returns the value color component of this color.
Definition: qcolor.h:252
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
Definition: qpalette.h:206
void drawDial(const QStyleOptionSlider *option, QPainter *painter)
static void qt_cleanlooks_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart, const QColor &gradientStop, Direction direction=TopDown, QBrush bgBrush=QBrush())
void setBold(bool)
If enable is true sets the font&#39;s weight to QFont::Bold ; otherwise sets the weight to QFont::Normal...
Definition: qfont.h:352
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
Definition: qpainter.cpp:4873
static const int windowsItemFrame
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
virtual QPalette standardPalette() const
Returns the style&#39;s standard palette.
Definition: qstyle.cpp:2283
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
ushort saturation
Returns the saturation color component of this color.
Definition: qcolor.h:251
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
ContentsType
This enum describes the available contents types.
Definition: qstyle.h:602
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
const QFont & font() const
Returns the currently set font used for drawing text.
Definition: qpainter.cpp:4312
QCleanlooksStyle()
Constructs a QCleanlooksStyle object.
QTransform & rotate(qreal a, Qt::Axis axis=Qt::ZAxis)
Rotates the coordinate system counterclockwise by the given angle about the specified axis and return...
Definition: qtransform.cpp:615
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition: qicon.h:63
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
The QComboBox widget is a combined button and popup list.
Definition: qcombobox.h:62
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition: qpalette.h:128
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
The QStyleOptionFocusRect class is used to describe the parameters for drawing a focus rectangle with...
Definition: qstyleoption.h:103
int & rx()
Returns a reference to the x coordinate of this point.
Definition: qpoint.h:140
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void transpose()
Swaps the width and height values.
Definition: qsize.cpp:196
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
unsigned int uint
Definition: qglobal.h:996
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
int pixelMetric(PixelMetric pm, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
The QGroupBox widget provides a group box frame with a title.
Definition: qgroupbox.h:57
The QStyleOptionTabWidgetFrame class is used to describe the parameters for drawing the frame around ...
Definition: qstyleoption.h:175
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
The QStyleOptionTabBarBase class is used to describe the base of a tab bar, i.e.
Definition: qstyleoption.h:218
static const char *const qt_cleanlooks_arrow_down_xpm[]
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
MenuItemType menuItemType
the type of menu item
Definition: qstyleoption.h:445
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
void setBlue(int blue)
Sets the blue color component of this color to blue.
Definition: qcolor.cpp:1199
The QFontInfo class provides general information about fonts.
Definition: qfontinfo.h:54
void setX(int x)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:282
FrameFeatures features
a bitwise OR of the features that describe this frame.
Definition: qstyleoption.h:143
static const char *const qt_scrollbar_button_arrow_right[]
static const char *const qt_cleanlooks_checkbox_checked[]
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
static const char *const dock_widget_restore_xpm[]
QSize size() const
Returns the size of the image, i.
Definition: qimage.cpp:1587
static const char *const qt_cleanlooks_menuitem_checkbox_checked[]
void moveCenter(const QPoint &p)
Moves the rectangle, leaving the center point at the given position.
Definition: qrect.cpp:840
int styleHint(StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
QPoint topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:294
const QBrush & brush() const
Returns the painter&#39;s current brush.
Definition: qpainter.cpp:4232
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
#define QT_NO_PROGRESSBAR
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter.
Definition: qstyle.cpp:570
Q_GUI_EXPORT_INLINE int qGray(int r, int g, int b)
Definition: qrgb.h:75
static void qt_cleanlooks_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken)
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
The QCleanlooksStyle class provides a widget style similar to the Clearlooks style available in GNOME...
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
static const char *const qt_spinbox_button_arrow_up[]
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QPoint bottomLeft() const
Returns the position of the rectangle&#39;s bottom-left corner.
Definition: qrect.h:297
PrimitiveElement
This enum describes the various primitive elements.
Definition: qstyle.h:145
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
Definition: qbrush.h:280
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
static const char *const qt_scrollbar_button_arrow_down[]
QPalette standardPalette() const
Reimplemented Function
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition: qpalette.h:141
#define QT_NO_SPINBOX
int midLineWidth
the mid-line width for drawing the frame
Definition: qstyleoption.h:125
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int tabWidth
the tab width for the menu item
Definition: qstyleoption.h:453
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
void setStops(const QGradientStops &stops)
Replaces the current set of stop points with the given stopPoints.
Definition: qbrush.cpp:1504
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
static const char *const workspace_minimize[]
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
Definition: qcolor.cpp:1094
~QCleanlooksStyle()
Destroys the QCleanlooksStyle object.
The QStyleOptionGroupBox class describes the parameters for drawing a group box.
Definition: qstyleoption.h:834
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
qreal pointSizeF() const
Returns the point size of the matched window system font.
Definition: qfont.cpp:2710
int height() const
Returns the height.
Definition: qsize.h:129
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=0) const
Reimplemented Function
The QTextOption class provides a description of general rich text properties.
Definition: qtextoption.h:59
void getRect(int *x, int *y, int *w, int *h) const
Extracts the position of the rectangle&#39;s top-left corner to *x and *y, and its dimensions to *width a...
Definition: qrect.h:392
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
The QStyleOptionFrameV2 class is used to describe the parameters necessary for drawing a frame in Qt ...
Definition: qstyleoption.h:134
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
static const int windowsItemHMargin
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Definition: qpainter.cpp:5936
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
const QStyle * proxy() const
Definition: qstyle.cpp:2546
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
int styleHint(StyleHint hint, const QStyleOption *option=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
void setPointSizeF(qreal)
Sets the point size to pointSize.
Definition: qfont.cpp:1121
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition: qicon.cpp:693
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
ControlElement
This enum represents a control element.
Definition: qstyle.h:217
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
static QTransform fromTranslate(qreal dx, qreal dy)
Creates a matrix which corresponds to a translation of dx along the x axis and dy along the y axis...
Definition: qtransform.cpp:462
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
Reimplemented Function
QTransform & scale(qreal sx, qreal sy)
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the mat...
Definition: qtransform.cpp:485
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
static const char *const qt_titlebar_context_help[]
#define QT_NO_SCROLLBAR
The QStyleOptionComplex class is used to hold parameters that are common to all complex controls...
Definition: qstyleoption.h:687
bool isValid() const
Returns true if the color is valid; otherwise returns false.
Definition: qcolor.h:295
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
Definition: qcolor.cpp:1019
The QWindowsStyle class provides a Microsoft Windows-like look and feel.
Definition: qwindowsstyle.h:57
void moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top edge at the given y coordinate.
Definition: qrect.h:353
static const int windowsItemVMargin
The QStyleOptionProgressBar class is used to describe the parameters necessary for drawing a progress...
Definition: qstyleoption.h:396
int height() const
Returns the height of the font.
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
void drawPrimitive(PrimitiveElement elem, const QStyleOption *option, QPainter *painter, const QWidget *widget=0) const
Reimplemented Function
void setStart(const QPointF &start)
Sets the start point of this linear gradient in logical coordinates to start.
Definition: qbrush.cpp:1828
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
static const KeyPair *const end
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
int titleBarState
the state of the title bar
Definition: qstyleoption.h:824
#define QT_NO_COMBOBOX
static bool isRightToLeft()
Returns true if the application&#39;s layout direction is Qt::RightToLeft; otherwise returns false...
Definition: qapplication.h:233
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
Reimplemented Function
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
QRgb rgb() const
Returns the RGB value of the color.
Definition: qcolor.cpp:1051
#define enabled
void unpolish(QWidget *widget)
Reimplemented Function
bool end()
Ends painting.
Definition: qpainter.cpp:1929
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
#define text
Definition: qobjectdefs.h:80
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
Reimplemented Function
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const
Reimplemented Function
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition: qpalette.h:129
SubElement
This enum represents a sub-area of a widget.
Definition: qstyle.h:289
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
QColor light(int f=150) const
Use lighter(factor) instead.
Definition: qcolor.cpp:2391
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
Qt::LayoutDirection direction
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311
static const int windowsRightBorder
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60