Qt 4.8
qwindowsstyle.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 "qwindowsstyle.h"
43 #include "qwindowsstyle_p.h"
44 
45 #if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
46 
47 #include <private/qsystemlibrary_p.h>
48 #include "qapplication.h"
49 #include "qbitmap.h"
50 #include "qdrawutil.h" // for now
51 #include "qevent.h"
52 #include "qmenu.h"
53 #include "qmenubar.h"
54 #include <private/qmenubar_p.h>
55 #include "qpaintengine.h"
56 #include "qpainter.h"
57 #include "qprogressbar.h"
58 #include "qrubberband.h"
59 #include "qstyleoption.h"
60 #include "qtabbar.h"
61 #include "qwidget.h"
62 #include "qdebug.h"
63 #include "qmainwindow.h"
64 #include "qfile.h"
65 #include "qtextstream.h"
66 #include "qpixmapcache.h"
67 #include "qwizard.h"
68 #include "qlistview.h"
69 #include <private/qmath_p.h>
70 #include <qmath.h>
71 
72 #ifdef Q_WS_X11
73 #include "qfileinfo.h"
74 #include "qdir.h"
75 #include <private/qt_x11_p.h>
76 #endif
77 
78 #include <private/qstylehelper_p.h>
79 
81 
82 #if defined(Q_WS_WIN)
83 
85 #include "qt_windows.h"
87 # ifndef COLOR_GRADIENTACTIVECAPTION
88 # define COLOR_GRADIENTACTIVECAPTION 27
89 # endif
90 # ifndef COLOR_GRADIENTINACTIVECAPTION
91 # define COLOR_GRADIENTINACTIVECAPTION 28
92 # endif
93 
94 
95 typedef struct
96 {
97  DWORD cbSize;
98  HICON hIcon;
100  int iIcon;
101  WCHAR szPath[MAX_PATH];
103 
104 #define _SHGFI_SMALLICON 0x000000001
105 #define _SHGFI_LARGEICON 0x000000000
106 #define _SHGFI_ICON 0x000000100
107 #define _SIID_SHIELD 77
108 
109 typedef HRESULT (WINAPI *PtrSHGetStockIconInfo)(int siid, int uFlags, QSHSTOCKICONINFO *psii);
111 
112 #endif //Q_WS_WIN
113 
115 #include <limits.h>
117 
119 
120 /*
121  \internal
122 */
124  : alt_down(false), menuBarTimer(0), animationFps(10), animateTimer(0), animateStep(0)
125 {
126 #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
129  QSystemLibrary shellLib(QLatin1String("shell32"));
130  pSHGetStockIconInfo = (PtrSHGetStockIconInfo)shellLib.resolve("SHGetStockIconInfo");
131  }
132 #endif
133  startTime.start();
134 }
135 
137 {
138  if (!animatedProgressBars.contains(bar)) {
139  animatedProgressBars << bar;
140  if (!animateTimer) {
141  Q_ASSERT(animationFps > 0);
142  animateTimer = o->startTimer(1000 / animationFps);
143  }
144  }
145 }
146 
148 {
152  animateTimer = 0;
153  }
154 }
155 
156 // Returns true if the toplevel parent of \a widget has seen the Alt-key
158 {
159  widget = widget->window();
160  return seenAlt.contains(widget);
161 }
162 
167 {
168 #ifndef QT_NO_PROGRESSBAR
170  if (event->timerId() == d->animateTimer) {
171  Q_ASSERT(d->animationFps> 0);
172  d->animateStep = d->startTime.elapsed() / (1000 / d->animationFps);
173  foreach (QProgressBar *bar, d->animatedProgressBars)
174  bar->update();
175  }
176 #endif // QT_NO_PROGRESSBAR
177  event->ignore();
178 }
179 
184 {
185  // Records Alt- and Focus events
186  if (!o->isWidgetType())
187  return QObject::eventFilter(o, e);
188 
191  switch(e->type()) {
192  case QEvent::KeyPress:
193  if (static_cast<QKeyEvent *>(e)->key() == Qt::Key_Alt) {
194  widget = widget->window();
195 
196  // Alt has been pressed - find all widgets that care
197  QList<QWidget *> l = widget->findChildren<QWidget *>();
198  for (int pos=0 ; pos < l.size() ;) {
199  QWidget *w = l.at(pos);
200  if (w->isWindow() || !w->isVisible() ||
201  w->style()->styleHint(SH_UnderlineShortcut, 0, w)) {
202  l.removeAt(pos);
203  continue;
204  }
205  pos++;
206  }
207  // Update states before repainting
208  d->seenAlt.append(widget);
209  d->alt_down = true;
210 
211  // Repaint all relevant widgets
212  for (int pos = 0; pos < l.size(); ++pos)
213  l.at(pos)->update();
214  }
215  break;
216  case QEvent::KeyRelease:
217  if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Alt) {
218  widget = widget->window();
219 
220  // Update state and repaint the menu bars.
221  d->alt_down = false;
222 #ifndef QT_NO_MENUBAR
223  QList<QMenuBar *> l = widget->findChildren<QMenuBar *>();
224  for (int i = 0; i < l.size(); ++i)
225  l.at(i)->update();
226 #endif
227  }
228  break;
229  case QEvent::Close:
230  // Reset widget when closing
231  d->seenAlt.removeAll(widget);
232  d->seenAlt.removeAll(widget->window());
233  break;
234 #ifndef QT_NO_PROGRESSBAR
235  case QEvent::StyleChange:
236  case QEvent::Paint:
237  case QEvent::Show:
238  if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) {
239  // Animation by timer for progress bars that have their min and
240  // max values the same
241  if (bar->minimum() == bar->maximum())
242  d->startAnimation(this, bar);
243  else
244  d->stopAnimation(this, bar);
245  }
246  break;
247  case QEvent::Destroy:
248  case QEvent::Hide:
249  // Do static_cast because there is no type info when getting
250  // the destroy event. We know that it is a QProgressBar, since
251  // we only install a widget event filter for QScrollBars.
252  d->stopAnimation(this, static_cast<QProgressBar *>(o));
253  break;
254 #endif // QT_NO_PROGRESSBAR
255  default:
256  break;
257  }
258  return QCommonStyle::eventFilter(o, e);
259 }
260 
280 {
281 }
282 
292 {
293 }
294 
295 
298 {
299 }
300 
301 #ifdef Q_WS_WIN
302 static inline QRgb colorref2qrgb(COLORREF col)
303 {
304  return qRgb(GetRValue(col), GetGValue(col), GetBValue(col));
305 }
306 #endif
307 
310 {
312  QWindowsStylePrivate *d = const_cast<QWindowsStylePrivate*>(d_func());
313  // We only need the overhead when shortcuts are sometimes hidden
314  if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app)
315  app->installEventFilter(this);
316 
317  d->activeCaptionColor = app->palette().highlight().color();
319  d->inactiveCaptionColor = app->palette().dark().color();
322 
323 #if defined(Q_WS_WIN) //fetch native title bar colors
324  if(app->desktopSettingsAware()){
325  DWORD activeCaption = GetSysColor(COLOR_ACTIVECAPTION);
326  DWORD gradientActiveCaption = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
327  DWORD inactiveCaption = GetSysColor(COLOR_INACTIVECAPTION);
328  DWORD gradientInactiveCaption = GetSysColor(COLOR_GRADIENTINACTIVECAPTION);
329  DWORD inactiveCaptionText = GetSysColor(COLOR_INACTIVECAPTIONTEXT);
330  d->activeCaptionColor = colorref2qrgb(activeCaption);
331  d->activeGradientCaptionColor = colorref2qrgb(gradientActiveCaption);
332  d->inactiveCaptionColor = colorref2qrgb(inactiveCaption);
333  d->inactiveGradientCaptionColor = colorref2qrgb(gradientInactiveCaption);
334  d->inactiveCaptionText = colorref2qrgb(inactiveCaptionText);
335  }
336 #endif
337 }
338 
341 {
343  app->removeEventFilter(this);
344 }
345 
348 {
349  QCommonStyle::polish(widget);
350 #ifndef QT_NO_PROGRESSBAR
351  if (qobject_cast<QProgressBar *>(widget))
352  widget->installEventFilter(this);
353 #endif
354 }
355 
358 {
359  QCommonStyle::unpolish(widget);
360 #ifndef QT_NO_PROGRESSBAR
361  if (QProgressBar *bar=qobject_cast<QProgressBar *>(widget)) {
363  widget->removeEventFilter(this);
364  d->stopAnimation(this, bar);
365  }
366 #endif
367 }
368 
373 {
375 }
376 
381 {
382  int ret;
383 
384  switch (pm) {
388  case PM_MenuHMargin:
389  case PM_MenuVMargin:
390  ret = 1;
391  break;
392 #ifndef QT_NO_TABBAR
394  ret = 0;
395  break;
397  ret = 2;
398  break;
399 #endif
401 #if defined(Q_WS_WIN)
402  {
403  HDC hdcScreen = GetDC(0);
404  int dpi = GetDeviceCaps(hdcScreen, LOGPIXELSX);
405  ReleaseDC(0, hdcScreen);
406  ret = (int)(dpi * 1.375);
407  }
408 #else
409  ret = 60;
410 #endif
411  break;
412 
413 #ifndef QT_NO_SLIDER
414  case PM_SliderLength:
415  ret = int(QStyleHelper::dpiScaled(11.));
416  break;
417 
418  // Returns the number of pixels to use for the business part of the
419  // slider (i.e., the non-tickmark portion). The remaining space is shared
420  // equally between the tickmark regions.
422  if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
423  int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
424  int ticks = sl->tickPosition;
425  int n = 0;
426  if (ticks & QSlider::TicksAbove)
427  ++n;
428  if (ticks & QSlider::TicksBelow)
429  ++n;
430  if (!n) {
431  ret = space;
432  break;
433  }
434 
435  int thick = 6; // Magic constant to get 5 + 16 + 5
436  if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks)
437  thick += proxy()->pixelMetric(PM_SliderLength, sl, widget) / 4;
438 
439  space -= thick;
440  if (space > 0)
441  thick += (space * 2) / (n + 2);
442  ret = thick;
443  } else {
444  ret = 0;
445  }
446  break;
447 #endif // QT_NO_SLIDER
448 
449 #ifndef QT_NO_MENU
450  case PM_MenuBarHMargin:
451  ret = 0;
452  break;
453 
454  case PM_MenuBarVMargin:
455  ret = 0;
456  break;
457 
459  ret = 0;
460  break;
461 
462  case PM_SmallIconSize:
463  ret = int(QStyleHelper::dpiScaled(16.));
464  break;
465 
466  case PM_LargeIconSize:
467  ret = int(QStyleHelper::dpiScaled(32.));
468  break;
469 
470  case PM_IconViewIconSize:
471  ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget);
472  break;
473 
475  ret = int(QStyleHelper::dpiScaled(2.));
476  break;
478  ret = int(QStyleHelper::dpiScaled(4.));
479  break;
480 #if defined(Q_WS_WIN)
482 #if defined(Q_OS_WINCE)
483  ret = GetSystemMetrics(SM_CXDLGFRAME);
484 #else
485  ret = GetSystemMetrics(SM_CXFRAME);
486 #endif
487  break;
488 #else
490  ret = 4;
491  break;
492 #endif // Q_WS_WIN
493  break;
494 
495 #endif // QT_NO_MENU
496 
497 
498 #if defined(Q_WS_WIN)
499  case PM_TitleBarHeight:
500 #ifdef QT3_SUPPORT
501  // qt3 dockwindow height should be equal to tool windows
502  if (widget && widget->inherits("Q3DockWindowTitleBar")) {
503  ret = GetSystemMetrics(SM_CYSMCAPTION) - 1;
504  } else
505 #endif
506  if (widget && (widget->windowType() == Qt::Tool)) {
507  // MS always use one less than they say
508 #if defined(Q_OS_WINCE)
509  ret = GetSystemMetrics(SM_CYCAPTION) - 1;
510 #else
511  ret = GetSystemMetrics(SM_CYSMCAPTION) - 1;
512 #endif
513  } else {
514  ret = GetSystemMetrics(SM_CYCAPTION) - 1;
515  }
516 
517  break;
518 
519  case PM_ScrollBarExtent:
520  {
521 #ifndef Q_OS_WINCE
522  NONCLIENTMETRICS ncm;
523  ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONT);
524  if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0))
525  ret = qMax(ncm.iScrollHeight, ncm.iScrollWidth);
526  else
527 #endif
528  ret = QCommonStyle::pixelMetric(pm, opt, widget);
529  }
530  break;
531 #endif // Q_WS_WIN
532 
533  case PM_SplitterWidth:
534  ret = qMax(4, QApplication::globalStrut().width());
535  break;
536 
537 #if defined(Q_WS_WIN)
539 #if defined(Q_OS_WINCE)
540  ret = GetSystemMetrics(SM_CYDLGFRAME);
541 #else
542  ret = GetSystemMetrics(SM_CYFRAME);
543 #endif
544  break;
545  case PM_TextCursorWidth: {
546  DWORD caretWidth = 1;
547 #if defined(SPI_GETCARETWIDTH)
548  SystemParametersInfo(SPI_GETCARETWIDTH, 0, &caretWidth, 0);
549 #endif
550  ret = (int)caretWidth;
551  break; }
552 #endif
554  ret = 1;
555  break;
557  ret = 0;
558  break;
560  ret = int(QStyleHelper::dpiScaled(10.));
561  break;
562  default:
563  ret = QCommonStyle::pixelMetric(pm, opt, widget);
564  break;
565  }
566 
567  return ret;
568 }
569 
570 #ifndef QT_NO_IMAGEFORMAT_XPM
571 
572 /* XPM */
573 static const char * const qt_menu_xpm[] = {
574 "16 16 72 1",
575 " c None",
576 ". c #65AF36",
577 "+ c #66B036",
578 "@ c #77B94C",
579 "# c #A7D28C",
580 "$ c #BADBA4",
581 "% c #A4D088",
582 "& c #72B646",
583 "* c #9ACB7A",
584 "= c #7FBD56",
585 "- c #85C05F",
586 "; c #F4F9F0",
587 "> c #FFFFFF",
588 ", c #E5F1DC",
589 "' c #ECF5E7",
590 ") c #7ABA50",
591 "! c #83BF5C",
592 "~ c #AED595",
593 "{ c #D7EACA",
594 "] c #A9D28D",
595 "^ c #BCDDA8",
596 "/ c #C4E0B1",
597 "( c #81BE59",
598 "_ c #D0E7C2",
599 ": c #D4E9C6",
600 "< c #6FB542",
601 "[ c #6EB440",
602 "} c #88C162",
603 "| c #98CA78",
604 "1 c #F4F9F1",
605 "2 c #8FC56C",
606 "3 c #F1F8EC",
607 "4 c #E8F3E1",
608 "5 c #D4E9C7",
609 "6 c #74B748",
610 "7 c #80BE59",
611 "8 c #73B747",
612 "9 c #6DB43F",
613 "0 c #CBE4BA",
614 "a c #80BD58",
615 "b c #6DB33F",
616 "c c #FEFFFE",
617 "d c #68B138",
618 "e c #F9FCF7",
619 "f c #91C66F",
620 "g c #E8F3E0",
621 "h c #DCEDD0",
622 "i c #91C66E",
623 "j c #A3CF86",
624 "k c #C9E3B8",
625 "l c #B0D697",
626 "m c #E3F0DA",
627 "n c #95C873",
628 "o c #E6F2DE",
629 "p c #9ECD80",
630 "q c #BEDEAA",
631 "r c #C7E2B6",
632 "s c #79BA4F",
633 "t c #6EB441",
634 "u c #BCDCA7",
635 "v c #FAFCF8",
636 "w c #F6FAF3",
637 "x c #84BF5D",
638 "y c #EDF6E7",
639 "z c #FAFDF9",
640 "A c #88C263",
641 "B c #98CA77",
642 "C c #CDE5BE",
643 "D c #67B037",
644 "E c #D9EBCD",
645 "F c #6AB23C",
646 "G c #77B94D",
647 " .++++++++++++++",
648 ".+++++++++++++++",
649 "+++@#$%&+++*=+++",
650 "++-;>,>')+!>~+++",
651 "++{>]+^>/(_>:~<+",
652 "+[>>}+|>123>456+",
653 "+7>>8+->>90>~+++",
654 "+a>>b+a>c[0>~+++",
655 "+de>=+f>g+0>~+++",
656 "++h>i+j>k+0>~+++",
657 "++l>mno>p+q>rst+",
658 "++duv>wl++xy>zA+",
659 "++++B>Cb++++&D++",
660 "+++++0zE++++++++",
661 "++++++FG+++++++.",
662 "++++++++++++++. "};
663 
664 static const char * const qt_close_xpm[] = {
665 "10 10 2 1",
666 "# c #000000",
667 ". c None",
668 "..........",
669 ".##....##.",
670 "..##..##..",
671 "...####...",
672 "....##....",
673 "...####...",
674 "..##..##..",
675 ".##....##.",
676 "..........",
677 ".........."};
678 
679 static const char * const qt_maximize_xpm[]={
680 "10 10 2 1",
681 "# c #000000",
682 ". c None",
683 "#########.",
684 "#########.",
685 "#.......#.",
686 "#.......#.",
687 "#.......#.",
688 "#.......#.",
689 "#.......#.",
690 "#.......#.",
691 "#########.",
692 ".........."};
693 
694 static const char * const qt_minimize_xpm[] = {
695 "10 10 2 1",
696 "# c #000000",
697 ". c None",
698 "..........",
699 "..........",
700 "..........",
701 "..........",
702 "..........",
703 "..........",
704 "..........",
705 ".#######..",
706 ".#######..",
707 ".........."};
708 
709 static const char * const qt_normalizeup_xpm[] = {
710 "10 10 2 1",
711 "# c #000000",
712 ". c None",
713 "...######.",
714 "...######.",
715 "...#....#.",
716 ".######.#.",
717 ".######.#.",
718 ".#....###.",
719 ".#....#...",
720 ".#....#...",
721 ".######...",
722 ".........."};
723 
724 static const char * const qt_help_xpm[] = {
725 "10 10 2 1",
726 ". c None",
727 "# c #000000",
728 "..........",
729 "..######..",
730 ".##....##.",
731 "......##..",
732 ".....##...",
733 "....##....",
734 "....##....",
735 "..........",
736 "....##....",
737 ".........."};
738 
739 static const char * const qt_shade_xpm[] = {
740 "10 10 2 1",
741 "# c #000000",
742 ". c None",
743 "..........",
744 "..........",
745 "..........",
746 "..........",
747 "....#.....",
748 "...###....",
749 "..#####...",
750 ".#######..",
751 "..........",
752 ".........."};
753 
754 static const char * const qt_unshade_xpm[] = {
755 "10 10 2 1",
756 "# c #000000",
757 ". c None",
758 "..........",
759 "..........",
760 "..........",
761 ".#######..",
762 "..#####...",
763 "...###....",
764 "....#.....",
765 "..........",
766 "..........",
767 ".........."};
768 
769 static const char * dock_widget_close_xpm[] = {
770 "8 8 2 1",
771 "# c #000000",
772 ". c None",
773 "........",
774 ".##..##.",
775 "..####..",
776 "...##...",
777 "..####..",
778 ".##..##.",
779 "........",
780 "........"};
781 
782 /* XPM */
783 static const char * const information_xpm[]={
784 "32 32 5 1",
785 ". c None",
786 "c c #000000",
787 "* c #999999",
788 "a c #ffffff",
789 "b c #0000ff",
790 "...........********.............",
791 "........***aaaaaaaa***..........",
792 "......**aaaaaaaaaaaaaa**........",
793 ".....*aaaaaaaaaaaaaaaaaa*.......",
794 "....*aaaaaaaabbbbaaaaaaaac......",
795 "...*aaaaaaaabbbbbbaaaaaaaac.....",
796 "..*aaaaaaaaabbbbbbaaaaaaaaac....",
797 ".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
798 ".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
799 "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
800 "*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
801 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
802 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
803 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
804 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
805 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
806 ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
807 ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
808 "..*aaaaaaaaaabbbbbaaaaaaaaac***.",
809 "...caaaaaaabbbbbbbbbaaaaaac****.",
810 "....caaaaaaaaaaaaaaaaaaaac****..",
811 ".....caaaaaaaaaaaaaaaaaac****...",
812 "......ccaaaaaaaaaaaaaacc****....",
813 ".......*cccaaaaaaaaccc*****.....",
814 "........***cccaaaac*******......",
815 "..........****caaac*****........",
816 ".............*caaac**...........",
817 "...............caac**...........",
818 "................cac**...........",
819 ".................cc**...........",
820 "..................***...........",
821 "...................**..........."};
822 /* XPM */
823 static const char* const warning_xpm[]={
824 "32 32 4 1",
825 ". c None",
826 "a c #ffff00",
827 "* c #000000",
828 "b c #999999",
829 ".............***................",
830 "............*aaa*...............",
831 "...........*aaaaa*b.............",
832 "...........*aaaaa*bb............",
833 "..........*aaaaaaa*bb...........",
834 "..........*aaaaaaa*bb...........",
835 ".........*aaaaaaaaa*bb..........",
836 ".........*aaaaaaaaa*bb..........",
837 "........*aaaaaaaaaaa*bb.........",
838 "........*aaaa***aaaa*bb.........",
839 ".......*aaaa*****aaaa*bb........",
840 ".......*aaaa*****aaaa*bb........",
841 "......*aaaaa*****aaaaa*bb.......",
842 "......*aaaaa*****aaaaa*bb.......",
843 ".....*aaaaaa*****aaaaaa*bb......",
844 ".....*aaaaaa*****aaaaaa*bb......",
845 "....*aaaaaaaa***aaaaaaaa*bb.....",
846 "....*aaaaaaaa***aaaaaaaa*bb.....",
847 "...*aaaaaaaaa***aaaaaaaaa*bb....",
848 "...*aaaaaaaaaa*aaaaaaaaaa*bb....",
849 "..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
850 "..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
851 ".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
852 ".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
853 "*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
854 "*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
855 "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
856 "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
857 ".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
858 "..*************************bbbbb",
859 "....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
860 ".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
861 /* XPM */
862 static const char* const critical_xpm[]={
863 "32 32 4 1",
864 ". c None",
865 "a c #999999",
866 "* c #ff0000",
867 "b c #ffffff",
868 "...........********.............",
869 ".........************...........",
870 ".......****************.........",
871 "......******************........",
872 ".....********************a......",
873 "....**********************a.....",
874 "...************************a....",
875 "..*******b**********b*******a...",
876 "..******bbb********bbb******a...",
877 ".******bbbbb******bbbbb******a..",
878 ".*******bbbbb****bbbbb*******a..",
879 "*********bbbbb**bbbbb*********a.",
880 "**********bbbbbbbbbb**********a.",
881 "***********bbbbbbbb***********aa",
882 "************bbbbbb************aa",
883 "************bbbbbb************aa",
884 "***********bbbbbbbb***********aa",
885 "**********bbbbbbbbbb**********aa",
886 "*********bbbbb**bbbbb*********aa",
887 ".*******bbbbb****bbbbb*******aa.",
888 ".******bbbbb******bbbbb******aa.",
889 "..******bbb********bbb******aaa.",
890 "..*******b**********b*******aa..",
891 "...************************aaa..",
892 "....**********************aaa...",
893 "....a********************aaa....",
894 ".....a******************aaa.....",
895 "......a****************aaa......",
896 ".......aa************aaaa.......",
897 ".........aa********aaaaa........",
898 "...........aaaaaaaaaaa..........",
899 ".............aaaaaaa............"};
900 /* XPM */
901 static const char *const question_xpm[] = {
902 "32 32 5 1",
903 ". c None",
904 "c c #000000",
905 "* c #999999",
906 "a c #ffffff",
907 "b c #0000ff",
908 "...........********.............",
909 "........***aaaaaaaa***..........",
910 "......**aaaaaaaaaaaaaa**........",
911 ".....*aaaaaaaaaaaaaaaaaa*.......",
912 "....*aaaaaaaaaaaaaaaaaaaac......",
913 "...*aaaaaaaabbbbbbaaaaaaaac.....",
914 "..*aaaaaaaabaaabbbbaaaaaaaac....",
915 ".*aaaaaaaabbaaaabbbbaaaaaaaac...",
916 ".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
917 "*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
918 "*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
919 "*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
920 "*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
921 "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
922 "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
923 "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
924 ".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
925 ".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
926 "..*aaaaaaaaaabbbbaaaaaaaaaac***.",
927 "...caaaaaaaaaabbaaaaaaaaaac****.",
928 "....caaaaaaaaaaaaaaaaaaaac****..",
929 ".....caaaaaaaaaaaaaaaaaac****...",
930 "......ccaaaaaaaaaaaaaacc****....",
931 ".......*cccaaaaaaaaccc*****.....",
932 "........***cccaaaac*******......",
933 "..........****caaac*****........",
934 ".............*caaac**...........",
935 "...............caac**...........",
936 "................cac**...........",
937 ".................cc**...........",
938 "..................***...........",
939 "...................**..........."};
940 
941 #endif //QT_NO_IMAGEFORMAT_XPM
942 
943 #ifdef Q_OS_WIN
944 static QPixmap loadIconFromShell32( int resourceId, int size )
945 {
946 #ifdef Q_OS_WINCE
947  HMODULE hmod = LoadLibrary(L"ceshell");
948 #else
949  HMODULE hmod = QSystemLibrary::load(L"shell32");
950 #endif
951  if( hmod ) {
952  HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size, size, 0);
953  if( iconHandle ) {
954  QPixmap iconpixmap = QPixmap::fromWinHICON( iconHandle );
955  DestroyIcon(iconHandle);
956  return iconpixmap;
957  }
958  }
959  return QPixmap();
960 }
961 #endif
962 
967  const QWidget *widget) const
968 {
969 #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
970  QPixmap desktopIcon;
971  switch(standardPixmap) {
972  case SP_DriveCDIcon:
973  case SP_DriveDVDIcon:
974  {
975  desktopIcon = loadIconFromShell32(12, 16);
976  break;
977  }
978  case SP_DriveNetIcon:
979  {
980  desktopIcon = loadIconFromShell32(10, 16);
981  break;
982  }
983  case SP_DriveHDIcon:
984  {
985  desktopIcon = loadIconFromShell32(9, 16);
986  break;
987  }
988  case SP_DriveFDIcon:
989  {
990  desktopIcon = loadIconFromShell32(7, 16);
991  break;
992  }
993  case SP_FileIcon:
994  {
995  desktopIcon = loadIconFromShell32(1, 16);
996  break;
997  }
998  case SP_FileLinkIcon:
999  {
1000  desktopIcon = loadIconFromShell32(1, 16);
1001  QPainter painter(&desktopIcon);
1002  QPixmap link = loadIconFromShell32(30, 16);
1003  painter.drawPixmap(0, 0, 16, 16, link);
1004  break;
1005  }
1006  case SP_DirLinkIcon:
1007  {
1008  desktopIcon = loadIconFromShell32(4, 16);
1009  QPainter painter(&desktopIcon);
1010  QPixmap link = loadIconFromShell32(30, 16);
1011  painter.drawPixmap(0, 0, 16, 16, link);
1012  break;
1013  }
1014  case SP_DirClosedIcon:
1015  {
1016  desktopIcon = loadIconFromShell32(4, 16);
1017  break;
1018  }
1019  case SP_DesktopIcon:
1020  {
1021  desktopIcon = loadIconFromShell32(35, 16);
1022  break;
1023  }
1024  case SP_ComputerIcon:
1025  {
1026  desktopIcon = loadIconFromShell32(16, 16);
1027  break;
1028  }
1029  case SP_DirOpenIcon:
1030  {
1031  desktopIcon = loadIconFromShell32(5, 16);
1032  break;
1033  }
1035  {
1036  desktopIcon = loadIconFromShell32(319, 16);
1037  break;
1038  }
1039  case SP_DirHomeIcon:
1040  {
1041  desktopIcon = loadIconFromShell32(235, 16);
1042  break;
1043  }
1044  case SP_TrashIcon:
1045  {
1046  desktopIcon = loadIconFromShell32(191, 16);
1047  break;
1048  }
1050  {
1051  HICON iconHandle = LoadIcon(NULL, IDI_INFORMATION);
1052  desktopIcon = QPixmap::fromWinHICON( iconHandle );
1053  DestroyIcon(iconHandle);
1054  break;
1055  }
1056  case SP_MessageBoxWarning:
1057  {
1058  HICON iconHandle = LoadIcon(NULL, IDI_WARNING);
1059  desktopIcon = QPixmap::fromWinHICON( iconHandle );
1060  DestroyIcon(iconHandle);
1061  break;
1062  }
1063  case SP_MessageBoxCritical:
1064  {
1065  HICON iconHandle = LoadIcon(NULL, IDI_ERROR);
1066  desktopIcon = QPixmap::fromWinHICON( iconHandle );
1067  DestroyIcon(iconHandle);
1068  break;
1069  }
1070  case SP_MessageBoxQuestion:
1071  {
1072  HICON iconHandle = LoadIcon(NULL, IDI_QUESTION);
1073  desktopIcon = QPixmap::fromWinHICON( iconHandle );
1074  DestroyIcon(iconHandle);
1075  break;
1076  }
1077  case SP_VistaShield:
1078  {
1082  {
1083  QPixmap pixmap;
1084  QSHSTOCKICONINFO iconInfo;
1085  memset(&iconInfo, 0, sizeof(iconInfo));
1086  iconInfo.cbSize = sizeof(iconInfo);
1087  if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_SMALLICON, &iconInfo) == S_OK) {
1088  pixmap = QPixmap::fromWinHICON(iconInfo.hIcon);
1089  DestroyIcon(iconInfo.hIcon);
1090  return pixmap;
1091  }
1092  }
1093  }
1094  break;
1095  default:
1096  break;
1097  }
1098  if (!desktopIcon.isNull()) {
1099  return desktopIcon;
1100  }
1101 #endif
1102 #ifndef QT_NO_IMAGEFORMAT_XPM
1103  switch (standardPixmap) {
1104  case SP_TitleBarMenuButton:
1105  return QPixmap(qt_menu_xpm);
1107  return QPixmap(qt_shade_xpm);
1109  return QPixmap(qt_unshade_xpm);
1111  return QPixmap(qt_normalizeup_xpm);
1112  case SP_TitleBarMinButton:
1113  return QPixmap(qt_minimize_xpm);
1114  case SP_TitleBarMaxButton:
1115  return QPixmap(qt_maximize_xpm);
1117  return QPixmap(qt_close_xpm);
1119  return QPixmap(qt_help_xpm);
1123  return QPixmap(information_xpm);
1124  case SP_MessageBoxWarning:
1125  return QPixmap(warning_xpm);
1126  case SP_MessageBoxCritical:
1127  return QPixmap(critical_xpm);
1128  case SP_MessageBoxQuestion:
1129  return QPixmap(question_xpm);
1130  default:
1131  break;
1132  }
1133 #endif //QT_NO_IMAGEFORMAT_XPM
1134  return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
1135 }
1136 
1139  QStyleHintReturn *returnData) const
1140 {
1141  int ret = 0;
1142 
1143  switch (hint) {
1144  case SH_EtchDisabledText:
1145  case SH_Slider_SnapToValue:
1151  case SH_Menu_MouseTracking:
1155  ret = 1;
1156 
1157  break;
1159 #ifndef QT_NO_LISTVIEW
1160  if (qobject_cast<const QListView*>(widget))
1161  ret = 1;
1162 #endif
1163  break;
1165  ret = 1;
1166  break;
1168  ret = 0;
1169  break;
1170 
1171 #if defined(Q_WS_WIN)
1172  case SH_UnderlineShortcut:
1173  {
1174  ret = 1;
1175  BOOL cues = false;
1176  SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0);
1177  ret = int(cues);
1178  // Do nothing if we always paint underlines
1179  Q_D(const QWindowsStyle);
1180  if (!ret && widget && d) {
1181 #ifndef QT_NO_MENUBAR
1182  const QMenuBar *menuBar = qobject_cast<const QMenuBar *>(widget);
1183  if (!menuBar && qobject_cast<const QMenu *>(widget)) {
1185  if (w && w != widget)
1186  menuBar = w->findChild<QMenuBar *>();
1187  }
1188  // If we paint a menu bar draw underlines if is in the keyboardState
1189  if (menuBar) {
1190  if (menuBar->d_func()->keyboardState || d->altDown())
1191  ret = 1;
1192  // Otherwise draw underlines if the toplevel widget has seen an alt-press
1193  } else
1194 #endif // QT_NO_MENUBAR
1195  if (d->hasSeenAlt(widget)) {
1196  ret = 1;
1197  }
1198  }
1199  break;
1200  }
1201 #endif
1202 #ifndef QT_NO_RUBBERBAND
1203  case SH_RubberBand_Mask:
1204  if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
1205  ret = 0;
1206  if (rbOpt->shape == QRubberBand::Rectangle) {
1207  ret = true;
1208  if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData)) {
1209  mask->region = opt->rect;
1210  int size = 1;
1211  if (widget && widget->isWindow())
1212  size = 4;
1213  mask->region -= opt->rect.adjusted(size, size, -size, -size);
1214  }
1215  }
1216  }
1217  break;
1218 #endif // QT_NO_RUBBERBAND
1220  {
1221 #ifdef Q_WS_WIN
1223  const QFontMetrics &fm = widget->fontMetrics();
1224  if (fm.inFont(QChar(0x25CF)))
1225  ret = 0x25CF;
1226  else if (fm.inFont(QChar(0x2022)))
1227  ret = 0x2022;
1228  }
1229 #endif
1230  if (!ret)
1231  ret = '*';
1232  }
1233  break;
1234 #ifndef QT_NO_WIZARD
1235  case SH_WizardStyle:
1236  ret = QWizard::ModernStyle;
1237  break;
1238 #endif
1240  ret = true;
1241  break;
1243  ret = 0;
1244  break;
1245  default:
1246  ret = QCommonStyle::styleHint(hint, opt, widget, returnData);
1247  break;
1248  }
1249  return ret;
1250 }
1251 
1254  const QWidget *w) const
1255 {
1256  // Used to restore across fallthrough cases. Currently only used in PE_IndicatorCheckBox
1257  bool doRestore = false;
1258 
1259  switch (pe) {
1260 #ifndef QT_NO_TOOLBAR
1262  {
1263  QRect rect = opt->rect;
1264  const int margin = 2;
1265  QPen oldPen = p->pen();
1266  if(opt->state & State_Horizontal){
1267  const int offset = rect.width()/2;
1268  p->setPen(QPen(opt->palette.dark().color()));
1269  p->drawLine(rect.bottomLeft().x() + offset,
1270  rect.bottomLeft().y() - margin,
1271  rect.topLeft().x() + offset,
1272  rect.topLeft().y() + margin);
1273  p->setPen(QPen(opt->palette.light().color()));
1274  p->drawLine(rect.bottomLeft().x() + offset + 1,
1275  rect.bottomLeft().y() - margin,
1276  rect.topLeft().x() + offset + 1,
1277  rect.topLeft().y() + margin);
1278  }
1279  else{ //Draw vertical separator
1280  const int offset = rect.height()/2;
1281  p->setPen(QPen(opt->palette.dark().color()));
1282  p->drawLine(rect.topLeft().x() + margin ,
1283  rect.topLeft().y() + offset,
1284  rect.topRight().x() - margin,
1285  rect.topRight().y() + offset);
1286  p->setPen(QPen(opt->palette.light().color()));
1287  p->drawLine(rect.topLeft().x() + margin ,
1288  rect.topLeft().y() + offset + 1,
1289  rect.topRight().x() - margin,
1290  rect.topRight().y() + offset + 1);
1291  }
1292  p->setPen(oldPen);
1293  }
1294  break;
1296  p->save();
1297  p->translate(opt->rect.x(), opt->rect.y());
1298  if (opt->state & State_Horizontal) {
1299  int x = opt->rect.width() / 2 - 4;
1300  if (opt->direction == Qt::RightToLeft)
1301  x -= 2;
1302  if (opt->rect.height() > 4) {
1303  qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
1304  opt->palette, false, 1, 0);
1305  qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4,
1306  opt->palette, false, 1, 0);
1307  }
1308  } else {
1309  if (opt->rect.width() > 4) {
1310  int y = opt->rect.height() / 2 - 4;
1311  qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
1312  opt->palette, false, 1, 0);
1313  qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3,
1314  opt->palette, false, 1, 0);
1315  }
1316  }
1317  p->restore();
1318  break;
1319 
1320 #endif // QT_NO_TOOLBAR
1321  case PE_FrameButtonTool:
1322  case PE_PanelButtonTool: {
1323  QPen oldPen = p->pen();
1324 #ifndef QT_NO_DOCKWIDGET
1325  if (w && w->inherits("QDockWidgetTitleButton")) {
1326  if (const QWidget *dw = w->parentWidget())
1327  if (dw->isWindow()){
1328  qDrawWinButton(p, opt->rect.adjusted(1, 1, 0, 0), opt->palette, opt->state & (State_Sunken | State_On),
1329  &opt->palette.button());
1330 
1331  return;
1332  }
1333  }
1334 #endif // QT_NO_DOCKWIDGET
1335  QBrush fill;
1336  bool stippled;
1337  bool panel = (pe == PE_PanelButtonTool);
1338  if ((!(opt->state & State_Sunken ))
1339  && (!(opt->state & State_Enabled)
1340  || !(opt->state & State_MouseOver && opt->state & State_AutoRaise))
1341  && (opt->state & State_On)) {
1342  fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1343  stippled = true;
1344  } else {
1345  fill = opt->palette.brush(QPalette::Button);
1346  stippled = false;
1347  }
1348 
1349  if (opt->state & (State_Raised | State_Sunken | State_On)) {
1350  if (opt->state & State_AutoRaise) {
1351  if(opt->state & (State_Enabled | State_Sunken | State_On)){
1352  if (panel)
1353  qDrawShadePanel(p, opt->rect, opt->palette,
1354  opt->state & (State_Sunken | State_On), 1, &fill);
1355  else
1356  qDrawShadeRect(p, opt->rect, opt->palette,
1357  opt->state & (State_Sunken | State_On), 1);
1358  }
1359  if (stippled) {
1360  p->setPen(opt->palette.button().color());
1361  p->drawRect(opt->rect.adjusted(1,1,-2,-2));
1362  }
1363  } else {
1364  qDrawWinButton(p, opt->rect, opt->palette,
1365  opt->state & (State_Sunken | State_On), panel ? &fill : 0);
1366  }
1367  } else {
1368  p->fillRect(opt->rect, fill);
1369  }
1370  p->setPen(oldPen);
1371  break; }
1372  case PE_PanelButtonCommand:
1373  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1374  QBrush fill;
1375  State flags = opt->state;
1376  QPalette pal = opt->palette;
1377  QRect r = opt->rect;
1378  if (! (flags & State_Sunken) && (flags & State_On))
1379  fill = QBrush(pal.light().color(), Qt::Dense4Pattern);
1380  else
1381  fill = pal.brush(QPalette::Button);
1382 
1383  if (btn->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
1384  p->setPen(pal.dark().color());
1385  p->setBrush(fill);
1386  p->drawRect(r.adjusted(0, 0, -1, -1));
1387  } else if (flags & (State_Raised | State_Sunken | State_On | State_Sunken)) {
1388  qDrawWinButton(p, r, pal, flags & (State_Sunken | State_On),
1389  &fill);
1390  } else {
1391  p->fillRect(r, fill);
1392  }
1393  }
1394  break;
1395  case PE_FrameDefaultButton: {
1396  QPen oldPen = p->pen();
1397  p->setPen(opt->palette.shadow().color());
1398  QRect rect = opt->rect;
1399  rect.adjust(0, 0, -1, -1);
1400  p->drawRect(rect);
1401  p->setPen(oldPen);
1402  break;
1403  }
1404  case PE_IndicatorArrowUp:
1405  case PE_IndicatorArrowDown:
1407  case PE_IndicatorArrowLeft:
1408  {
1409  if (opt->rect.width() <= 1 || opt->rect.height() <= 1)
1410  break;
1411  QRect r = opt->rect;
1412  int size = qMin(r.height(), r.width());
1413  QPixmap pixmap;
1414  QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-")
1415  % QLatin1String(metaObject()->className()), opt, QSize(size, size))
1416  % HexString<uint>(pe);
1417  if (!QPixmapCache::find(pixmapName, pixmap)) {
1418  int border = size/5;
1419  int sqsize = 2*(size/2);
1420  QImage image(sqsize, sqsize, QImage::Format_ARGB32_Premultiplied);
1421  image.fill(0);
1422  QPainter imagePainter(&image);
1423 
1424  QPolygon a;
1425  switch (pe) {
1426  case PE_IndicatorArrowUp:
1427  a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize - border, sqsize/2);
1428  break;
1429  case PE_IndicatorArrowDown:
1430  a.setPoints(3, border, sqsize/2, sqsize/2, sqsize - border, sqsize - border, sqsize/2);
1431  break;
1433  a.setPoints(3, sqsize - border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
1434  break;
1435  case PE_IndicatorArrowLeft:
1436  a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
1437  break;
1438  default:
1439  break;
1440  }
1441 
1442  int bsx = 0;
1443  int bsy = 0;
1444 
1445  if (opt->state & State_Sunken) {
1446  bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, w);
1447  bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, w);
1448  }
1449 
1450  QRect bounds = a.boundingRect();
1451  int sx = sqsize / 2 - bounds.center().x() - 1;
1452  int sy = sqsize / 2 - bounds.center().y() - 1;
1453  imagePainter.translate(sx + bsx, sy + bsy);
1454  imagePainter.setPen(opt->palette.buttonText().color());
1455  imagePainter.setBrush(opt->palette.buttonText());
1456 
1457  if (!(opt->state & State_Enabled)) {
1458  imagePainter.translate(1, 1);
1459  imagePainter.setBrush(opt->palette.light().color());
1460  imagePainter.setPen(opt->palette.light().color());
1461  imagePainter.drawPolygon(a);
1462  imagePainter.translate(-1, -1);
1463  imagePainter.setBrush(opt->palette.mid().color());
1464  imagePainter.setPen(opt->palette.mid().color());
1465  }
1466 
1467  imagePainter.drawPolygon(a);
1468  imagePainter.end();
1469  pixmap = QPixmap::fromImage(image);
1470  QPixmapCache::insert(pixmapName, pixmap);
1471  }
1472  int xOffset = r.x() + (r.width() - size)/2;
1473  int yOffset = r.y() + (r.height() - size)/2;
1474  p->drawPixmap(xOffset, yOffset, pixmap);
1475  }
1476  break;
1477  case PE_IndicatorCheckBox: {
1478  QBrush fill;
1479  if (opt->state & State_NoChange)
1480  fill = QBrush(opt->palette.base().color(), Qt::Dense4Pattern);
1481  else if (opt->state & State_Sunken)
1482  fill = opt->palette.button();
1483  else if (opt->state & State_Enabled)
1484  fill = opt->palette.base();
1485  else
1486  fill = opt->palette.background();
1487  p->save();
1488  doRestore = true;
1489  qDrawWinPanel(p, opt->rect, opt->palette, true, &fill);
1490  if (opt->state & State_NoChange)
1491  p->setPen(opt->palette.dark().color());
1492  else
1493  p->setPen(opt->palette.text().color());
1494  } // Fall through!
1497  if (!doRestore) {
1498  p->save();
1499  doRestore = true;
1500  }
1502  const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt);
1503  p->setPen(itemViewOpt
1504  && itemViewOpt->showDecorationSelected
1505  && opt->state & State_Selected
1506  ? opt->palette.highlightedText().color()
1507  : opt->palette.text().color());
1508  if (opt->state & State_NoChange)
1510  p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, 11, 11);
1511  }
1512  if (!(opt->state & State_Off)) {
1513  QLineF lines[7];
1514  int i, xx, yy;
1515  xx = opt->rect.x() + 3;
1516  yy = opt->rect.y() + 5;
1517  for (i = 0; i < 3; ++i) {
1518  lines[i] = QLineF(xx, yy, xx, yy + 2);
1519  ++xx;
1520  ++yy;
1521  }
1522  yy -= 2;
1523  for (i = 3; i < 7; ++i) {
1524  lines[i] = QLineF(xx, yy, xx, yy + 2);
1525  ++xx;
1526  --yy;
1527  }
1528  p->drawLines(lines, 7);
1529  }
1530  if (doRestore)
1531  p->restore();
1532  break;
1533  case PE_FrameFocusRect:
1534  if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
1535  //### check for d->alt_down
1536  if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt))
1537  return;
1538  QRect r = opt->rect;
1539  p->save();
1541  QColor bg_col = fropt->backgroundColor;
1542  if (!bg_col.isValid())
1543  bg_col = p->background().color();
1544  // Create an "XOR" color.
1545  QColor patternCol((bg_col.red() ^ 0xff) & 0xff,
1546  (bg_col.green() ^ 0xff) & 0xff,
1547  (bg_col.blue() ^ 0xff) & 0xff);
1548  p->setBrush(QBrush(patternCol, Qt::Dense4Pattern));
1549  p->setBrushOrigin(r.topLeft());
1550  p->setPen(Qt::NoPen);
1551  p->drawRect(r.left(), r.top(), r.width(), 1); // Top
1552  p->drawRect(r.left(), r.bottom(), r.width(), 1); // Bottom
1553  p->drawRect(r.left(), r.top(), 1, r.height()); // Left
1554  p->drawRect(r.right(), r.top(), 1, r.height()); // Right
1555  p->restore();
1556  }
1557  break;
1559  {
1560 #define PTSARRLEN(x) sizeof(x)/(sizeof(QPoint))
1561  static const QPoint pts1[] = { // dark lines
1562  QPoint(1, 9), QPoint(1, 8), QPoint(0, 7), QPoint(0, 4), QPoint(1, 3), QPoint(1, 2),
1563  QPoint(2, 1), QPoint(3, 1), QPoint(4, 0), QPoint(7, 0), QPoint(8, 1), QPoint(9, 1)
1564  };
1565  static const QPoint pts2[] = { // black lines
1566  QPoint(2, 8), QPoint(1, 7), QPoint(1, 4), QPoint(2, 3), QPoint(2, 2), QPoint(3, 2),
1567  QPoint(4, 1), QPoint(7, 1), QPoint(8, 2), QPoint(9, 2)
1568  };
1569  static const QPoint pts3[] = { // background lines
1570  QPoint(2, 9), QPoint(3, 9), QPoint(4, 10), QPoint(7, 10), QPoint(8, 9), QPoint(9, 9),
1571  QPoint(9, 8), QPoint(10, 7), QPoint(10, 4), QPoint(9, 3)
1572  };
1573  static const QPoint pts4[] = { // white lines
1574  QPoint(2, 10), QPoint(3, 10), QPoint(4, 11), QPoint(7, 11), QPoint(8, 10),
1575  QPoint(9, 10), QPoint(10, 9), QPoint(10, 8), QPoint(11, 7), QPoint(11, 4),
1576  QPoint(10, 3), QPoint(10, 2)
1577  };
1578  static const QPoint pts5[] = { // inner fill
1579  QPoint(4, 2), QPoint(7, 2), QPoint(9, 4), QPoint(9, 7), QPoint(7, 9), QPoint(4, 9),
1580  QPoint(2, 7), QPoint(2, 4)
1581  };
1582 
1583  // make sure the indicator is square
1584  QRect ir = opt->rect;
1585 
1586  if (opt->rect.width() < opt->rect.height()) {
1587  ir.setTop(opt->rect.top() + (opt->rect.height() - opt->rect.width()) / 2);
1588  ir.setHeight(opt->rect.width());
1589  } else if (opt->rect.height() < opt->rect.width()) {
1590  ir.setLeft(opt->rect.left() + (opt->rect.width() - opt->rect.height()) / 2);
1591  ir.setWidth(opt->rect.height());
1592  }
1593 
1594  p->save();
1595  bool down = opt->state & State_Sunken;
1596  bool enabled = opt->state & State_Enabled;
1597  bool on = opt->state & State_On;
1598  QPolygon a;
1599 
1600  //center when rect is larger than indicator size
1601  int xOffset = 0;
1602  int yOffset = 0;
1603  int indicatorWidth = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
1604  int indicatorHeight = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
1605  if (ir.width() > indicatorWidth)
1606  xOffset += (ir.width() - indicatorWidth)/2;
1607  if (ir.height() > indicatorHeight)
1608  yOffset += (ir.height() - indicatorHeight)/2;
1609  p->translate(xOffset, yOffset);
1610 
1611  p->translate(ir.x(), ir.y());
1612 
1613  p->setPen(opt->palette.dark().color());
1614  p->drawPolyline(pts1, PTSARRLEN(pts1));
1615 
1616  p->setPen(opt->palette.shadow().color());
1617  p->drawPolyline(pts2, PTSARRLEN(pts2));
1618 
1619  p->setPen(opt->palette.midlight().color());
1620  p->drawPolyline(pts3, PTSARRLEN(pts3));
1621 
1622  p->setPen(opt->palette.light().color());
1623  p->drawPolyline(pts4, PTSARRLEN(pts4));
1624 
1625  QColor fillColor = (down || !enabled)
1626  ? opt->palette.button().color()
1627  : opt->palette.base().color();
1628  p->setPen(fillColor);
1629  p->setBrush(fillColor) ;
1630  p->drawPolygon(pts5, PTSARRLEN(pts5));
1631 
1632  p->translate(-ir.x(), -ir.y()); // restore translate
1633 
1634  if (on) {
1635  p->setPen(Qt::NoPen);
1636  p->setBrush(opt->palette.text());
1637  p->drawRect(ir.x() + 5, ir.y() + 4, 2, 4);
1638  p->drawRect(ir.x() + 4, ir.y() + 5, 4, 2);
1639  }
1640  p->restore();
1641  break;
1642  }
1643 #ifndef QT_NO_FRAME
1644  case PE_Frame:
1645  case PE_FrameMenu:
1646  if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
1647  if (frame->lineWidth == 2 || pe == PE_Frame) {
1648  QPalette popupPal = frame->palette;
1649  if (pe == PE_FrameMenu) {
1650  popupPal.setColor(QPalette::Light, frame->palette.background().color());
1651  popupPal.setColor(QPalette::Midlight, frame->palette.light().color());
1652  }
1653  if (pe == PE_Frame && (frame->state & State_Raised))
1654  qDrawWinButton(p, frame->rect, popupPal, frame->state & State_Sunken);
1655  else if (pe == PE_Frame && (frame->state & State_Sunken))
1656  {
1657  popupPal.setColor(QPalette::Midlight, frame->palette.background().color());
1658  qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
1659  }
1660  else
1661  qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
1662  } else {
1663  QCommonStyle::drawPrimitive(pe, opt, p, w);
1664  }
1665  } else {
1666  QPalette popupPal = opt->palette;
1667  popupPal.setColor(QPalette::Light, opt->palette.background().color());
1668  popupPal.setColor(QPalette::Midlight, opt->palette.light().color());
1669  qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
1670  }
1671  break;
1672 #endif // QT_NO_FRAME
1673  case PE_IndicatorBranch: {
1674  // This is _way_ too similar to the common style.
1675  static const int decoration_size = 9;
1676  int mid_h = opt->rect.x() + opt->rect.width() / 2;
1677  int mid_v = opt->rect.y() + opt->rect.height() / 2;
1678  int bef_h = mid_h;
1679  int bef_v = mid_v;
1680  int aft_h = mid_h;
1681  int aft_v = mid_v;
1682  if (opt->state & State_Children) {
1683  int delta = decoration_size / 2;
1684  bef_h -= delta;
1685  bef_v -= delta;
1686  aft_h += delta;
1687  aft_v += delta;
1688  p->drawLine(bef_h + 2, bef_v + 4, bef_h + 6, bef_v + 4);
1689  if (!(opt->state & State_Open))
1690  p->drawLine(bef_h + 4, bef_v + 2, bef_h + 4, bef_v + 6);
1691  QPen oldPen = p->pen();
1692  p->setPen(opt->palette.dark().color());
1693  p->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1);
1694  p->setPen(oldPen);
1695  }
1696  QBrush brush(opt->palette.dark().color(), Qt::Dense4Pattern);
1697  if (opt->state & State_Item) {
1698  if (opt->direction == Qt::RightToLeft)
1699  p->fillRect(opt->rect.left(), mid_v, bef_h - opt->rect.left(), 1, brush);
1700  else
1701  p->fillRect(aft_h, mid_v, opt->rect.right() - aft_h + 1, 1, brush);
1702  }
1703  if (opt->state & State_Sibling)
1704  p->fillRect(mid_h, aft_v, 1, opt->rect.bottom() - aft_v + 1, brush);
1706  p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush);
1707  break; }
1708  case PE_FrameButtonBevel:
1709  case PE_PanelButtonBevel: {
1710  QBrush fill;
1711  bool panel = pe != PE_FrameButtonBevel;
1712  p->setBrushOrigin(opt->rect.topLeft());
1713  if (!(opt->state & State_Sunken) && (opt->state & State_On))
1714  fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1715  else
1716  fill = opt->palette.brush(QPalette::Button);
1717 
1718  if (opt->state & (State_Raised | State_On | State_Sunken)) {
1719  qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On),
1720  panel ? &fill : 0);
1721  } else {
1722  if (panel)
1723  p->fillRect(opt->rect, fill);
1724  else
1725  p->drawRect(opt->rect);
1726  }
1727  break; }
1728  case PE_FrameWindow: {
1729  QPalette popupPal = opt->palette;
1730  popupPal.setColor(QPalette::Light, opt->palette.background().color());
1731  popupPal.setColor(QPalette::Midlight, opt->palette.light().color());
1732  qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
1733  break; }
1734 #ifndef QT_NO_DOCKWIDGET
1736  QPen oldPen = p->pen();
1737  p->setPen(opt->palette.light().color());
1738  if (opt->state & State_Horizontal) {
1739  p->drawLine(opt->rect.left(), opt->rect.top(),
1740  opt->rect.right(), opt->rect.top());
1741  p->setPen(opt->palette.dark().color());
1742  p->drawLine(opt->rect.left(), opt->rect.bottom() - 1,
1743  opt->rect.right(), opt->rect.bottom() - 1);
1744  p->setPen(opt->palette.shadow().color());
1745  p->drawLine(opt->rect.left(), opt->rect.bottom(),
1746  opt->rect.right(), opt->rect.bottom());
1747  } else {
1748  p->drawLine(opt->rect.left(), opt->rect.top(),
1749  opt->rect.left(), opt->rect.bottom());
1750  p->setPen(opt->palette.dark().color());
1751  p->drawLine(opt->rect.right() - 1, opt->rect.top(),
1752  opt->rect.right() - 1, opt->rect.bottom());
1753  p->setPen(opt->palette.shadow().color());
1754  p->drawLine(opt->rect.right(), opt->rect.top(),
1755  opt->rect.right(), opt->rect.bottom());
1756  }
1757  p->setPen(oldPen);
1758  break; }
1759 case PE_FrameDockWidget:
1760  if (qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
1762  }
1763  break;
1764 #endif // QT_NO_DOCKWIDGET
1765 
1766  case PE_FrameStatusBarItem:
1767  qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 0);
1768  break;
1769 
1770 #ifndef QT_NO_PROGRESSBAR
1772  {
1773  bool vertical = false, inverted = false;
1774  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
1775  vertical = (pb2->orientation == Qt::Vertical);
1776  inverted = pb2->invertedAppearance;
1777  }
1778 
1779  int space = 2;
1780  int chunksize = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, w) - space;
1781  if (!vertical) {
1782  if (opt->rect.width() <= chunksize)
1783  space = 0;
1784 
1785  if (inverted)
1786  p->fillRect(opt->rect.x() + space, opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
1788  else
1789  p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
1791  } else {
1792  if (opt->rect.height() <= chunksize)
1793  space = 0;
1794 
1795  if (inverted)
1796  p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height() - space,
1798  else
1799  p->fillRect(opt->rect.x(), opt->rect.y() + space, opt->rect.width(), opt->rect.height() - space,
1801  }
1802  }
1803  break;
1804 #endif // QT_NO_PROGRESSBAR
1805 
1806  case PE_FrameTabWidget: {
1807  qDrawWinButton(p, opt->rect, opt->palette, false, 0);
1808  break;
1809  }
1810  default:
1811  QCommonStyle::drawPrimitive(pe, opt, p, w);
1812  }
1813 }
1814 
1817  const QWidget *widget) const
1818 {
1819  switch (ce) {
1820 #ifndef QT_NO_RUBBERBAND
1821  case CE_RubberBand:
1822  if (qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
1823  // ### workaround for slow general painter path
1824  QPixmap tiledPixmap(16, 16);
1825  QPainter pixmapPainter(&tiledPixmap);
1826  pixmapPainter.setPen(Qt::NoPen);
1827  pixmapPainter.setBrush(Qt::Dense4Pattern);
1828  pixmapPainter.setBackground(Qt::white);
1829  pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
1830  pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
1831  pixmapPainter.end();
1832  tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
1833  p->save();
1834  QRect r = opt->rect;
1835  QStyleHintReturnMask mask;
1836  if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
1837  p->setClipRegion(mask.region);
1838  p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
1839  p->restore();
1840  return;
1841  }
1842  break;
1843 #endif // QT_NO_RUBBERBAND
1844 
1845 #if !defined(QT_NO_MENU) && !defined(QT_NO_MAINWINDOW)
1846  case CE_MenuBarEmptyArea:
1847  if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) {
1848  p->fillRect(opt->rect, opt->palette.button());
1849  QPen oldPen = p->pen();
1850  p->setPen(QPen(opt->palette.dark().color()));
1851  p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight());
1852  p->setPen(oldPen);
1853  }
1854  break;
1855 #endif
1856 #ifndef QT_NO_MENU
1857  case CE_MenuItem:
1858  if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
1859  int x, y, w, h;
1860  menuitem->rect.getRect(&x, &y, &w, &h);
1861  int tab = menuitem->tabWidth;
1862  bool dis = !(menuitem->state & State_Enabled);
1863  bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
1864  ? menuitem->checked : false;
1865  bool act = menuitem->state & State_Selected;
1866 
1867  // windows always has a check column, regardless whether we have an icon or not
1868  int checkcol = qMax<int>(menuitem->maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
1869 
1870  QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
1871  p->fillRect(menuitem->rect.adjusted(0, 0, -1, 0), fill);
1872 
1873  if (menuitem->menuItemType == QStyleOptionMenuItem::Separator){
1874  int yoff = y-1 + h / 2;
1875  p->setPen(menuitem->palette.dark().color());
1876  p->drawLine(x + 2, yoff, x + w - 4, yoff);
1877  p->setPen(menuitem->palette.light().color());
1878  p->drawLine(x + 2, yoff + 1, x + w - 4, yoff + 1);
1879  return;
1880  }
1881 
1882  QRect vCheckRect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x(), menuitem->rect.y(), checkcol, menuitem->rect.height()));
1883  if (!menuitem->icon.isNull() && checked) {
1884  if (act) {
1885  qDrawShadePanel(p, vCheckRect,
1886  menuitem->palette, true, 1,
1887  &menuitem->palette.brush(QPalette::Button));
1888  } else {
1889  QBrush fill(menuitem->palette.light().color(), Qt::Dense4Pattern);
1890  qDrawShadePanel(p, vCheckRect, menuitem->palette, true, 1, &fill);
1891  }
1892  } else if (!act) {
1893  p->fillRect(vCheckRect, menuitem->palette.brush(QPalette::Button));
1894  }
1895 
1896  // On Windows Style, if we have a checkable item and an icon we
1897  // draw the icon recessed to indicate an item is checked. If we
1898  // have no icon, we draw a checkmark instead.
1899  if (!menuitem->icon.isNull()) {
1900  QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
1901  if (act && !dis)
1902  mode = QIcon::Active;
1903  QPixmap pixmap;
1904  if (checked)
1905  pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
1906  else
1907  pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
1908  int pixw = pixmap.width();
1909  int pixh = pixmap.height();
1910  if (act && !dis && !checked)
1911  qDrawShadePanel(p, vCheckRect, menuitem->palette, false, 1,
1912  &menuitem->palette.brush(QPalette::Button));
1913  QRect pmr(0, 0, pixw, pixh);
1914  pmr.moveCenter(vCheckRect.center());
1915  p->setPen(menuitem->palette.text().color());
1916  p->drawPixmap(pmr.topLeft(), pixmap);
1917  } else if (checked) {
1918  QStyleOptionMenuItem newMi = *menuitem;
1919  newMi.state = State_None;
1920  if (!dis)
1921  newMi.state |= State_Enabled;
1922  if (act)
1923  newMi.state |= State_On;
1924  newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + QWindowsStylePrivate::windowsItemFrame,
1925  menuitem->rect.y() + QWindowsStylePrivate::windowsItemFrame,
1927  menuitem->rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
1928  proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
1929  }
1930  p->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color());
1931 
1932  QColor discol;
1933  if (dis) {
1934  discol = menuitem->palette.text().color();
1935  p->setPen(discol);
1936  }
1937 
1939  int xpos = menuitem->rect.x() + xm;
1942  QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
1943  QString s = menuitem->text;
1944  if (!s.isEmpty()) { // draw text
1945  p->save();
1946  int t = s.indexOf(QLatin1Char('\t'));
1948  if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
1949  text_flags |= Qt::TextHideMnemonic;
1950  text_flags |= Qt::AlignLeft;
1951  if (t >= 0) {
1952  QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
1953  QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
1954  if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1955  p->setPen(menuitem->palette.light().color());
1956  p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1));
1957  p->setPen(discol);
1958  }
1959  p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
1960  s = s.left(t);
1961  }
1962  QFont font = menuitem->font;
1963  if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
1964  font.setBold(true);
1965  p->setFont(font);
1966  if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1967  p->setPen(menuitem->palette.light().color());
1968  p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t));
1969  p->setPen(discol);
1970  }
1971  p->drawText(vTextRect, text_flags, s.left(t));
1972  p->restore();
1973  }
1974  if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
1975  int dim = (h - 2 * QWindowsStylePrivate::windowsItemFrame) / 2;
1976  PrimitiveElement arrow;
1979  QRect vSubMenuRect = visualRect(opt->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
1980  QStyleOptionMenuItem newMI = *menuitem;
1981  newMI.rect = vSubMenuRect;
1982  newMI.state = dis ? State_None : State_Enabled;
1983  if (act)
1985  newMI.palette.highlightedText().color());
1986  proxy()->drawPrimitive(arrow, &newMI, p, widget);
1987  }
1988 
1989  }
1990  break;
1991 #endif // QT_NO_MENU
1992 #ifndef QT_NO_MENUBAR
1993  case CE_MenuBarItem:
1994  if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
1995  bool active = mbi->state & State_Selected;
1996  bool hasFocus = mbi->state & State_HasFocus;
1997  bool down = mbi->state & State_Sunken;
1998  QStyleOptionMenuItem newMbi = *mbi;
1999  p->fillRect(mbi->rect, mbi->palette.brush(QPalette::Button));
2000  if (active || hasFocus) {
2001  QBrush b = mbi->palette.brush(QPalette::Button);
2002  if (active && down)
2003  p->setBrushOrigin(p->brushOrigin() + QPoint(1, 1));
2004  if (active && hasFocus)
2005  qDrawShadeRect(p, mbi->rect.x(), mbi->rect.y(), mbi->rect.width(),
2006  mbi->rect.height(), mbi->palette, active && down, 1, 0, &b);
2007  if (active && down) {
2008  newMbi.rect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, mbi, widget),
2009  proxy()->pixelMetric(PM_ButtonShiftVertical, mbi, widget));
2010  p->setBrushOrigin(p->brushOrigin() - QPoint(1, 1));
2011  }
2012  }
2013  QCommonStyle::drawControl(ce, &newMbi, p, widget);
2014  }
2015  break;
2016 #endif // QT_NO_MENUBAR
2017 #ifndef QT_NO_TABBAR
2018  case CE_TabBarTabShape:
2019  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
2020  bool rtlHorTabs = (tab->direction == Qt::RightToLeft
2021  && (tab->shape == QTabBar::RoundedNorth
2022  || tab->shape == QTabBar::RoundedSouth));
2023  bool selected = tab->state & State_Selected;
2024  bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
2025  || (rtlHorTabs
2026  && tab->position == QStyleOptionTab::Beginning));
2027  bool firstTab = ((!rtlHorTabs
2028  && tab->position == QStyleOptionTab::Beginning)
2029  || (rtlHorTabs
2030  && tab->position == QStyleOptionTab::End));
2031  bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
2032  bool previousSelected =
2033  ((!rtlHorTabs
2034  && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
2035  || (rtlHorTabs
2036  && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
2037  bool nextSelected =
2038  ((!rtlHorTabs
2039  && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
2040  || (rtlHorTabs
2041  && tab->selectedPosition
2043  int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
2044  bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
2045  || (rtlHorTabs
2046  && tabBarAlignment == Qt::AlignRight);
2047 
2048  bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
2049  || (rtlHorTabs
2050  && tabBarAlignment == Qt::AlignLeft);
2051 
2052  QColor light = tab->palette.light().color();
2053  QColor dark = tab->palette.dark().color();
2054  QColor shadow = tab->palette.shadow().color();
2055  int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
2056  if (selected)
2057  borderThinkness /= 2;
2058  QRect r2(opt->rect);
2059  int x1 = r2.left();
2060  int x2 = r2.right();
2061  int y1 = r2.top();
2062  int y2 = r2.bottom();
2063  switch (tab->shape) {
2064  default:
2065  QCommonStyle::drawControl(ce, tab, p, widget);
2066  break;
2067  case QTabBar::RoundedNorth: {
2068  if (!selected) {
2069  y1 += 2;
2070  x1 += onlyOne || firstTab ? borderThinkness : 0;
2071  x2 -= onlyOne || lastTab ? borderThinkness : 0;
2072  }
2073 
2074  p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 2), tab->palette.background());
2075 
2076  // Delete border
2077  if (selected) {
2078  p->fillRect(QRect(x1,y2-1,x2-x1,1), tab->palette.background());
2079  p->fillRect(QRect(x1,y2,x2-x1,1), tab->palette.background());
2080  }
2081  // Left
2082  if (firstTab || selected || onlyOne || !previousSelected) {
2083  p->setPen(light);
2084  p->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
2085  p->drawPoint(x1 + 1, y1 + 1);
2086  }
2087  // Top
2088  {
2089  int beg = x1 + (previousSelected ? 0 : 2);
2090  int end = x2 - (nextSelected ? 0 : 2);
2091  p->setPen(light);
2092  p->drawLine(beg, y1, end, y1);
2093  }
2094  // Right
2095  if (lastTab || selected || onlyOne || !nextSelected) {
2096  p->setPen(shadow);
2097  p->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
2098  p->drawPoint(x2 - 1, y1 + 1);
2099  p->setPen(dark);
2100  p->drawLine(x2 - 1, y1 + 2, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
2101  }
2102  break; }
2103  case QTabBar::RoundedSouth: {
2104  if (!selected) {
2105  y2 -= 2;
2106  x1 += firstTab ? borderThinkness : 0;
2107  x2 -= lastTab ? borderThinkness : 0;
2108  }
2109 
2110  p->fillRect(QRect(x1 + 1, y1 + 2, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
2111 
2112  // Delete border
2113  if (selected) {
2114  p->fillRect(QRect(x1, y1 + 1, (x2 - 1)-x1, 1), tab->palette.background());
2115  p->fillRect(QRect(x1, y1, (x2 - 1)-x1, 1), tab->palette.background());
2116  }
2117  // Left
2118  if (firstTab || selected || onlyOne || !previousSelected) {
2119  p->setPen(light);
2120  p->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
2121  p->drawPoint(x1 + 1, y2 - 1);
2122  }
2123  // Bottom
2124  {
2125  int beg = x1 + (previousSelected ? 0 : 2);
2126  int end = x2 - (nextSelected ? 0 : 2);
2127  p->setPen(shadow);
2128  p->drawLine(beg, y2, end, y2);
2129  p->setPen(dark);
2130  p->drawLine(beg, y2 - 1, end, y2 - 1);
2131  }
2132  // Right
2133  if (lastTab || selected || onlyOne || !nextSelected) {
2134  p->setPen(shadow);
2135  p->drawLine(x2, y2 - 2, x2, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
2136  p->drawPoint(x2 - 1, y2 - 1);
2137  p->setPen(dark);
2138  p->drawLine(x2 - 1, y2 - 2, x2 - 1, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
2139  }
2140  break; }
2141  case QTabBar::RoundedWest: {
2142  if (!selected) {
2143  x1 += 2;
2144  y1 += firstTab ? borderThinkness : 0;
2145  y2 -= lastTab ? borderThinkness : 0;
2146  }
2147 
2148  p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 2, (y2 - y1) - 1), tab->palette.background());
2149 
2150  // Delete border
2151  if (selected) {
2152  p->fillRect(QRect(x2 - 1, y1, 1, y2-y1), tab->palette.background());
2153  p->fillRect(QRect(x2, y1, 1, y2-y1), tab->palette.background());
2154  }
2155  // Top
2156  if (firstTab || selected || onlyOne || !previousSelected) {
2157  p->setPen(light);
2158  p->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
2159  p->drawPoint(x1 + 1, y1 + 1);
2160  }
2161  // Left
2162  {
2163  int beg = y1 + (previousSelected ? 0 : 2);
2164  int end = y2 - (nextSelected ? 0 : 2);
2165  p->setPen(light);
2166  p->drawLine(x1, beg, x1, end);
2167  }
2168  // Bottom
2169  if (lastTab || selected || onlyOne || !nextSelected) {
2170  p->setPen(shadow);
2171  p->drawLine(x1 + 3, y2, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
2172  p->drawPoint(x1 + 2, y2 - 1);
2173  p->setPen(dark);
2174  p->drawLine(x1 + 3, y2 - 1, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
2175  p->drawPoint(x1 + 1, y2 - 1);
2176  p->drawPoint(x1 + 2, y2);
2177  }
2178  break; }
2179  case QTabBar::RoundedEast: {
2180  if (!selected) {
2181  x2 -= 2;
2182  y1 += firstTab ? borderThinkness : 0;
2183  y2 -= lastTab ? borderThinkness : 0;
2184  }
2185 
2186  p->fillRect(QRect(x1 + 2, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
2187 
2188  // Delete border
2189  if (selected) {
2190  p->fillRect(QRect(x1 + 1, y1, 1, (y2 - 1)-y1),tab->palette.background());
2191  p->fillRect(QRect(x1, y1, 1, (y2-1)-y1), tab->palette.background());
2192  }
2193  // Top
2194  if (firstTab || selected || onlyOne || !previousSelected) {
2195  p->setPen(light);
2196  p->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
2197  p->drawPoint(x2 - 1, y1 + 1);
2198  }
2199  // Right
2200  {
2201  int beg = y1 + (previousSelected ? 0 : 2);
2202  int end = y2 - (nextSelected ? 0 : 2);
2203  p->setPen(shadow);
2204  p->drawLine(x2, beg, x2, end);
2205  p->setPen(dark);
2206  p->drawLine(x2 - 1, beg, x2 - 1, end);
2207  }
2208  // Bottom
2209  if (lastTab || selected || onlyOne || !nextSelected) {
2210  p->setPen(shadow);
2211  p->drawLine(x2 - 2, y2, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
2212  p->drawPoint(x2 - 1, y2 - 1);
2213  p->setPen(dark);
2214  p->drawLine(x2 - 2, y2 - 1, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
2215  }
2216  break; }
2217  }
2218  }
2219  break;
2220 #endif // QT_NO_TABBAR
2221  case CE_ToolBoxTabShape:
2222  qDrawShadePanel(p, opt->rect, opt->palette,
2223  opt->state & (State_Sunken | State_On), 1,
2224  &opt->palette.brush(QPalette::Button));
2225  break;
2226 #ifndef QT_NO_SPLITTER
2227  case CE_Splitter:
2228  p->eraseRect(opt->rect);
2229  break;
2230 #endif // QT_NO_SPLITTER
2231 #ifndef QT_NO_SCROLLBAR
2232  case CE_ScrollBarSubLine:
2233  case CE_ScrollBarAddLine: {
2234  if ((opt->state & State_Sunken)) {
2235  p->setPen(opt->palette.dark().color());
2237  p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
2238  } else {
2239  QStyleOption buttonOpt = *opt;
2240  if (!(buttonOpt.state & State_Sunken))
2241  buttonOpt.state |= State_Raised;
2242  QPalette pal(opt->palette);
2243  pal.setColor(QPalette::Button, opt->palette.light().color());
2244  pal.setColor(QPalette::Light, opt->palette.button().color());
2245  qDrawWinButton(p, opt->rect, pal, opt->state & (State_Sunken | State_On),
2246  &opt->palette.brush(QPalette::Button));
2247  }
2248  PrimitiveElement arrow;
2249  if (opt->state & State_Horizontal) {
2250  if (ce == CE_ScrollBarAddLine)
2252  else
2254  } else {
2255  if (ce == CE_ScrollBarAddLine)
2256  arrow = PE_IndicatorArrowDown;
2257  else
2258  arrow = PE_IndicatorArrowUp;
2259  }
2260  QStyleOption arrowOpt = *opt;
2261  arrowOpt.rect = opt->rect.adjusted(4, 4, -4, -4);
2262  proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
2263  break; }
2264  case CE_ScrollBarAddPage:
2265  case CE_ScrollBarSubPage: {
2266  QBrush br;
2267  QBrush bg = p->background();
2268  Qt::BGMode bg_mode = p->backgroundMode();
2269  p->setPen(Qt::NoPen);
2271 
2272  if (opt->state & State_Sunken) {
2273  br = QBrush(opt->palette.shadow().color(), Qt::Dense4Pattern);
2274  p->setBackground(opt->palette.dark().color());
2275  p->setBrush(br);
2276  } else {
2278  br = !pm.isNull() ? QBrush(pm) : QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
2279  p->setBackground(opt->palette.background().color());
2280  p->setBrush(br);
2281  }
2282  p->drawRect(opt->rect);
2283  p->setBackground(bg);
2284  p->setBackgroundMode(bg_mode);
2285  break; }
2286  case CE_ScrollBarSlider:
2287  if (!(opt->state & State_Enabled)) {
2289  QBrush br = !pm.isNull() ? QBrush(pm) : QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
2290  p->setPen(Qt::NoPen);
2291  p->setBrush(br);
2293  p->drawRect(opt->rect);
2294  } else {
2295  QStyleOptionButton buttonOpt;
2296  buttonOpt.QStyleOption::operator=(*opt);
2297  buttonOpt.state = State_Enabled | State_Raised;
2298 
2299  QPalette pal(opt->palette);
2300  pal.setColor(QPalette::Button, opt->palette.light().color());
2301  pal.setColor(QPalette::Light, opt->palette.button().color());
2302  qDrawWinButton(p, opt->rect, pal, false, &opt->palette.brush(QPalette::Button));
2303  }
2304  break;
2305 #endif // QT_NO_SCROLLBAR
2306  case CE_HeaderSection: {
2307  QBrush fill;
2308  if (opt->state & State_On)
2309  fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
2310  else
2311  fill = opt->palette.brush(QPalette::Button);
2312 
2313  if (opt->state & (State_Raised | State_Sunken)) {
2314  qDrawWinButton(p, opt->rect, opt->palette, opt->state & State_Sunken, &fill);
2315  } else {
2316  p->fillRect(opt->rect, fill);
2317  }
2318  break; }
2319 #ifndef QT_NO_TOOLBAR
2320  case CE_ToolBar:
2321  if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
2322  QRect rect = opt->rect;
2323 
2324  bool paintLeftBorder = true;
2325  bool paintRightBorder = true;
2326  bool paintBottomBorder = true;
2327 
2328  switch (toolbar->toolBarArea){
2329  case Qt::BottomToolBarArea :
2330  switch(toolbar->positionOfLine){
2333  paintBottomBorder = false;
2334  default:
2335  break;
2336  }
2337  case Qt::TopToolBarArea :
2338  switch(toolbar->positionWithinLine){
2340  paintLeftBorder = false;
2341  break;
2343  paintRightBorder = false;
2344  break;
2346  paintRightBorder = false;
2347  paintLeftBorder = false;
2348  default:
2349  break;
2350  }
2351  if(opt->direction == Qt::RightToLeft){ //reverse layout changes the order of Beginning/end
2352  bool tmp = paintLeftBorder;
2353  paintRightBorder=paintLeftBorder;
2354  paintLeftBorder=tmp;
2355  }
2356  break;
2357  case Qt::RightToolBarArea :
2358  switch (toolbar->positionOfLine){
2361  paintRightBorder = false;
2362  break;
2363  default:
2364  break;
2365  }
2366  break;
2367  case Qt::LeftToolBarArea :
2368  switch (toolbar->positionOfLine){
2371  paintLeftBorder = false;
2372  break;
2373  default:
2374  break;
2375  }
2376  break;
2377  default:
2378  break;
2379  }
2380 
2381 
2382  //draw top border
2383  p->setPen(QPen(opt->palette.light().color()));
2384  p->drawLine(rect.topLeft().x(),
2385  rect.topLeft().y(),
2386  rect.topRight().x(),
2387  rect.topRight().y());
2388 
2389  if (paintLeftBorder){
2390  p->setPen(QPen(opt->palette.light().color()));
2391  p->drawLine(rect.topLeft().x(),
2392  rect.topLeft().y(),
2393  rect.bottomLeft().x(),
2394  rect.bottomLeft().y());
2395  }
2396 
2397  if (paintRightBorder){
2398  p->setPen(QPen(opt->palette.dark().color()));
2399  p->drawLine(rect.topRight().x(),
2400  rect.topRight().y(),
2401  rect.bottomRight().x(),
2402  rect.bottomRight().y());
2403  }
2404 
2405  if (paintBottomBorder){
2406  p->setPen(QPen(opt->palette.dark().color()));
2407  p->drawLine(rect.bottomLeft().x(),
2408  rect.bottomLeft().y(),
2409  rect.bottomRight().x(),
2410  rect.bottomRight().y());
2411  }
2412  }
2413  break;
2414 
2415 
2416 #endif // QT_NO_TOOLBAR
2417 #ifndef QT_NO_PROGRESSBAR
2419  if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
2420  QRect rect = pb->rect;
2421  if (!rect.isValid())
2422  return;
2423 
2424  bool vertical = false;
2425  bool inverted = false;
2426 
2427  // Get extra style options if version 2
2429  if (pb2) {
2430  vertical = (pb2->orientation == Qt::Vertical);
2431  inverted = pb2->invertedAppearance;
2432  }
2433  QMatrix m;
2434  if (vertical) {
2435  rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height
2436  m.rotate(90);
2437  m.translate(0, -(rect.height() + rect.y()*2));
2438  }
2439  QPalette pal2 = pb->palette;
2440  // Correct the highlight color if it is the same as the background
2441  if (pal2.highlight() == pal2.background())
2442  pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
2444  bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
2445  if (inverted)
2446  reverse = !reverse;
2447  int w = rect.width();
2448  if (pb->minimum == 0 && pb->maximum == 0) {
2449  Q_D(const QWindowsStyle);
2450  const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget);
2451  QStyleOptionProgressBarV2 pbBits = *pb;
2452  Q_ASSERT(unit_width >0);
2453 
2454  pbBits.rect = rect;
2455  pbBits.palette = pal2;
2456 
2457  int chunkCount = w / unit_width + 1;
2458  int step = d->animateStep%chunkCount;
2459  int chunksInRow = 5;
2460  int myY = pbBits.rect.y();
2461  int myHeight = pbBits.rect.height();
2462  int chunksToDraw = chunksInRow;
2463 
2464  if(step > chunkCount - 5)chunksToDraw = (chunkCount - step);
2465  p->save();
2466  p->setClipRect(m.mapRect(QRectF(rect)).toRect());
2467 
2468  int x0 = reverse ? rect.left() + rect.width() - unit_width*(step) - unit_width : rect.left() + unit_width * step;
2469  int x = 0;
2470 
2471  for (int i = 0; i < chunksToDraw ; ++i) {
2472  pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
2473  pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
2474  proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
2475  x += reverse ? -unit_width : unit_width;
2476  }
2477  //Draw wrap-around chunks
2478  if( step > chunkCount-5){
2479  x0 = reverse ? rect.left() + rect.width() - unit_width : rect.left() ;
2480  x = 0;
2481  int chunksToDraw = step - (chunkCount - chunksInRow);
2482  for (int i = 0; i < chunksToDraw ; ++i) {
2483  pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
2484  pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
2485  proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
2486  x += reverse ? -unit_width : unit_width;
2487  }
2488  }
2489  p->restore(); //restore state
2490  }
2491  else {
2492  QCommonStyle::drawControl(ce, opt, p, widget);
2493  }
2494  }
2495  break;
2496 #endif // QT_NO_PROGRESSBAR
2497 
2498 #ifndef QT_NO_DOCKWIDGET
2499  case CE_DockWidgetTitle:
2500 
2501  if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
2502  Q_D(const QWindowsStyle);
2503 
2504  const QStyleOptionDockWidgetV2 *v2
2506  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
2507 
2508  QRect rect = dwOpt->rect;
2509  QRect r = rect;
2510 
2511  if (verticalTitleBar) {
2512  QSize s = r.size();
2513  s.transpose();
2514  r.setSize(s);
2515 
2516  p->save();
2517  p->translate(r.left(), r.top() + r.width());
2518  p->rotate(-90);
2519  p->translate(-r.left(), -r.top());
2520  }
2521 
2522  bool floating = false;
2523  bool active = dwOpt->state & State_Active;
2524  QColor inactiveCaptionTextColor = d->inactiveCaptionText;
2525  if (dwOpt->movable) {
2526  QColor left, right;
2527 
2528  //Titlebar gradient
2529  if (widget && widget->isWindow()) {
2530  floating = true;
2531  if (active) {
2532  left = d->activeCaptionColor;
2533  right = d->activeGradientCaptionColor;
2534  } else {
2535  left = d->inactiveCaptionColor;
2536  right = d->inactiveGradientCaptionColor;
2537  }
2538  QBrush fillBrush(left);
2539  if (left != right) {
2540  QPoint p1(r.x(), r.top() + r.height()/2);
2541  QPoint p2(rect.right(), r.top() + r.height()/2);
2542  QLinearGradient lg(p1, p2);
2543  lg.setColorAt(0, left);
2544  lg.setColorAt(1, right);
2545  fillBrush = lg;
2546  }
2547  p->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
2548  }
2549  p->setPen(dwOpt->palette.color(QPalette::Light));
2550  if (!widget || !widget->isWindow()) {
2551  p->drawLine(r.topLeft(), r.topRight());
2552  p->setPen(dwOpt->palette.color(QPalette::Dark));
2553  p->drawLine(r.bottomLeft(), r.bottomRight()); }
2554  }
2555  if (!dwOpt->title.isEmpty()) {
2556  QFont oldFont = p->font();
2557  if (floating) {
2558  QFont font = oldFont;
2559  font.setBold(true);
2560  p->setFont(font);
2561  }
2562  QPalette palette = dwOpt->palette;
2563  palette.setColor(QPalette::Window, inactiveCaptionTextColor);
2564  QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, opt, widget);
2565  if (verticalTitleBar) {
2566  titleRect = QRect(r.left() + rect.bottom()
2567  - titleRect.bottom(),
2568  r.top() + titleRect.left() - rect.left(),
2569  titleRect.height(), titleRect.width());
2570  }
2571  proxy()->drawItemText(p, titleRect,
2573  dwOpt->state & State_Enabled, dwOpt->title,
2574  floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText);
2575  p->setFont(oldFont);
2576  }
2577  if (verticalTitleBar)
2578  p->restore();
2579  }
2580  return;
2581 #endif // QT_NO_DOCKWIDGET
2582  default:
2583  QCommonStyle::drawControl(ce, opt, p, widget);
2584  }
2585 }
2586 
2589 {
2590  QRect r;
2591  switch (sr) {
2592  case SE_SliderFocusRect:
2593  case SE_ToolBoxTabContents:
2594  r = visualRect(opt->direction, opt->rect, opt->rect);
2595  break;
2597  r = QCommonStyle::subElementRect(sr, opt, w);
2598  const QStyleOptionDockWidgetV2 *v2
2600  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
2601  int m = proxy()->pixelMetric(PM_DockWidgetTitleMargin, opt, w);
2602  if (verticalTitleBar) {
2603  r.adjust(0, 0, 0, -m);
2604  } else {
2605  if (opt->direction == Qt::LeftToRight)
2606  r.adjust(m, 0, 0, 0);
2607  else
2608  r.adjust(0, 0, -m, 0);
2609  }
2610  break;
2611  }
2614  r.adjust(3, 3, -3, -3);
2615  break;
2616  default:
2617  r = QCommonStyle::subElementRect(sr, opt, w);
2618  }
2619  return r;
2620 }
2621 
2622 #ifdef QT3_SUPPORT
2623 Q_GLOBAL_STATIC_WITH_ARGS(QBitmap, globalVerticalLine, (1, 129))
2624 Q_GLOBAL_STATIC_WITH_ARGS(QBitmap, globalHorizontalLine, (128, 1))
2625 #endif
2626 
2629  QPainter *p, const QWidget *widget) const
2630 {
2631  switch (cc) {
2632 #ifndef QT_NO_SLIDER
2633  case CC_Slider:
2634  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
2635  int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
2636  int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
2637  int ticks = slider->tickPosition;
2638  QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
2639  QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
2640 
2641  if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
2642  int mid = thickness / 2;
2643 
2644  if (ticks & QSlider::TicksAbove)
2645  mid += len / 8;
2646  if (ticks & QSlider::TicksBelow)
2647  mid -= len / 8;
2648 
2649  p->setPen(slider->palette.shadow().color());
2650  if (slider->orientation == Qt::Horizontal) {
2651  qDrawWinPanel(p, groove.x(), groove.y() + mid - 2,
2652  groove.width(), 4, slider->palette, true);
2653  p->drawLine(groove.x() + 1, groove.y() + mid - 1,
2654  groove.x() + groove.width() - 3, groove.y() + mid - 1);
2655  } else {
2656  qDrawWinPanel(p, groove.x() + mid - 2, groove.y(),
2657  4, groove.height(), slider->palette, true);
2658  p->drawLine(groove.x() + mid - 1, groove.y() + 1,
2659  groove.x() + mid - 1, groove.y() + groove.height() - 3);
2660  }
2661  }
2662 
2663  if (slider->subControls & SC_SliderTickmarks) {
2664  QStyleOptionSlider tmpSlider = *slider;
2665  tmpSlider.subControls = SC_SliderTickmarks;
2666  QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
2667  }
2668 
2669  if (slider->subControls & SC_SliderHandle) {
2670  // 4444440
2671  // 4333310
2672  // 4322210
2673  // 4322210
2674  // 4322210
2675  // 4322210
2676  // *43210*
2677  // **410**
2678  // ***0***
2679  const QColor c0 = slider->palette.shadow().color();
2680  const QColor c1 = slider->palette.dark().color();
2681  // const QColor c2 = g.button();
2682  const QColor c3 = slider->palette.midlight().color();
2683  const QColor c4 = slider->palette.light().color();
2684  QBrush handleBrush;
2685 
2686  if (slider->state & State_Enabled) {
2687  handleBrush = slider->palette.color(QPalette::Button);
2688  } else {
2689  handleBrush = QBrush(slider->palette.color(QPalette::Button),
2691  }
2692 
2693 
2694  int x = handle.x(), y = handle.y(),
2695  wi = handle.width(), he = handle.height();
2696 
2697  int x1 = x;
2698  int x2 = x+wi-1;
2699  int y1 = y;
2700  int y2 = y+he-1;
2701 
2702  Qt::Orientation orient = slider->orientation;
2703  bool tickAbove = slider->tickPosition == QSlider::TicksAbove;
2704  bool tickBelow = slider->tickPosition == QSlider::TicksBelow;
2705 
2706  if (slider->state & State_HasFocus) {
2707  QStyleOptionFocusRect fropt;
2708  fropt.QStyleOption::operator=(*slider);
2709  fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
2710  proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
2711  }
2712 
2713  if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
2714  Qt::BGMode oldMode = p->backgroundMode();
2716  qDrawWinButton(p, QRect(x, y, wi, he), slider->palette, false,
2717  &handleBrush);
2718  p->setBackgroundMode(oldMode);
2719  return;
2720  }
2721 
2722  QSliderDirection dir;
2723 
2724  if (orient == Qt::Horizontal)
2725  if (tickAbove)
2726  dir = SlUp;
2727  else
2728  dir = SlDown;
2729  else
2730  if (tickAbove)
2731  dir = SlLeft;
2732  else
2733  dir = SlRight;
2734 
2735  QPolygon a;
2736 
2737  int d = 0;
2738  switch (dir) {
2739  case SlUp:
2740  y1 = y1 + wi/2;
2741  d = (wi + 1) / 2 - 1;
2742  a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d);
2743  break;
2744  case SlDown:
2745  y2 = y2 - wi/2;
2746  d = (wi + 1) / 2 - 1;
2747  a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1);
2748  break;
2749  case SlLeft:
2750  d = (he + 1) / 2 - 1;
2751  x1 = x1 + he/2;
2752  a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
2753  break;
2754  case SlRight:
2755  d = (he + 1) / 2 - 1;
2756  x2 = x2 - he/2;
2757  a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1);
2758  break;
2759  }
2760 
2761  QBrush oldBrush = p->brush();
2762  p->setPen(Qt::NoPen);
2763  p->setBrush(handleBrush);
2764  Qt::BGMode oldMode = p->backgroundMode();
2766  p->drawRect(x1, y1, x2-x1+1, y2-y1+1);
2767  p->drawPolygon(a);
2768  p->setBrush(oldBrush);
2769  p->setBackgroundMode(oldMode);
2770 
2771  if (dir != SlUp) {
2772  p->setPen(c4);
2773  p->drawLine(x1, y1, x2, y1);
2774  p->setPen(c3);
2775  p->drawLine(x1, y1+1, x2, y1+1);
2776  }
2777  if (dir != SlLeft) {
2778  p->setPen(c3);
2779  p->drawLine(x1+1, y1+1, x1+1, y2);
2780  p->setPen(c4);
2781  p->drawLine(x1, y1, x1, y2);
2782  }
2783  if (dir != SlRight) {
2784  p->setPen(c0);
2785  p->drawLine(x2, y1, x2, y2);
2786  p->setPen(c1);
2787  p->drawLine(x2-1, y1+1, x2-1, y2-1);
2788  }
2789  if (dir != SlDown) {
2790  p->setPen(c0);
2791  p->drawLine(x1, y2, x2, y2);
2792  p->setPen(c1);
2793  p->drawLine(x1+1, y2-1, x2-1, y2-1);
2794  }
2795 
2796  switch (dir) {
2797  case SlUp:
2798  p->setPen(c4);
2799  p->drawLine(x1, y1, x1+d, y1-d);
2800  p->setPen(c0);
2801  d = wi - d - 1;
2802  p->drawLine(x2, y1, x2-d, y1-d);
2803  d--;
2804  p->setPen(c3);
2805  p->drawLine(x1+1, y1, x1+1+d, y1-d);
2806  p->setPen(c1);
2807  p->drawLine(x2-1, y1, x2-1-d, y1-d);
2808  break;
2809  case SlDown:
2810  p->setPen(c4);
2811  p->drawLine(x1, y2, x1+d, y2+d);
2812  p->setPen(c0);
2813  d = wi - d - 1;
2814  p->drawLine(x2, y2, x2-d, y2+d);
2815  d--;
2816  p->setPen(c3);
2817  p->drawLine(x1+1, y2, x1+1+d, y2+d);
2818  p->setPen(c1);
2819  p->drawLine(x2-1, y2, x2-1-d, y2+d);
2820  break;
2821  case SlLeft:
2822  p->setPen(c4);
2823  p->drawLine(x1, y1, x1-d, y1+d);
2824  p->setPen(c0);
2825  d = he - d - 1;
2826  p->drawLine(x1, y2, x1-d, y2-d);
2827  d--;
2828  p->setPen(c3);
2829  p->drawLine(x1, y1+1, x1-d, y1+1+d);
2830  p->setPen(c1);
2831  p->drawLine(x1, y2-1, x1-d, y2-1-d);
2832  break;
2833  case SlRight:
2834  p->setPen(c4);
2835  p->drawLine(x2, y1, x2+d, y1+d);
2836  p->setPen(c0);
2837  d = he - d - 1;
2838  p->drawLine(x2, y2, x2+d, y2-d);
2839  d--;
2840  p->setPen(c3);
2841  p->drawLine(x2, y1+1, x2+d, y1+1+d);
2842  p->setPen(c1);
2843  p->drawLine(x2, y2-1, x2+d, y2-1-d);
2844  break;
2845  }
2846  }
2847  }
2848  break;
2849 #endif // QT_NO_SLIDER
2850 #ifndef QT_NO_SCROLLBAR
2851  case CC_ScrollBar:
2852  if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
2853  QStyleOptionSlider newScrollbar = *scrollbar;
2854  if (scrollbar->minimum == scrollbar->maximum)
2855  newScrollbar.state &= ~State_Enabled; //do not draw the slider.
2856  QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
2857  }
2858  break;
2859 #endif // QT_NO_SCROLLBAR
2860 #ifdef QT3_SUPPORT
2861  case CC_Q3ListView:
2862  if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
2863  int i;
2864  if (lv->subControls & SC_Q3ListView)
2865  QCommonStyle::drawComplexControl(cc, lv, p, widget);
2866  if (lv->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand)) {
2867  if (lv->items.isEmpty())
2868  break;
2869  QStyleOptionQ3ListViewItem item = lv->items.at(0);
2870  int y = lv->rect.y();
2871  int c;
2872  int dotoffset = 0;
2873  QPolygon dotlines;
2874  if ((lv->activeSubControls & SC_All) && (lv->subControls & SC_Q3ListViewExpand)) {
2875  c = 2;
2876  dotlines.resize(2);
2877  dotlines[0] = QPoint(lv->rect.right(), lv->rect.top());
2878  dotlines[1] = QPoint(lv->rect.right(), lv->rect.bottom());
2879  } else {
2880  int linetop = 0, linebot = 0;
2881  // each branch needs at most two lines, ie. four end points
2882  dotoffset = (item.itemY + item.height - y) % 2;
2883  dotlines.resize(item.childCount * 4);
2884  c = 0;
2885 
2886  // skip the stuff above the exposed rectangle
2887  for (i = 1; i < lv->items.size(); ++i) {
2888  QStyleOptionQ3ListViewItem child = lv->items.at(i);
2889  if (child.height + y > 0)
2890  break;
2891  y += child.totalHeight;
2892  }
2893  int bx = lv->rect.width() / 2;
2894 
2895  // paint stuff in the magical area
2896  while (i < lv->items.size() && y < lv->rect.height()) {
2897  QStyleOptionQ3ListViewItem child = lv->items.at(i);
2899  int lh;
2901  lh = child.height;
2902  else
2903  lh = p->fontMetrics().height() + 2 * lv->itemMargin;
2904  lh = qMax(lh, QApplication::globalStrut().height());
2905  if (lh % 2 > 0)
2906  ++lh;
2907  linebot = y + lh / 2;
2909  || (child.childCount > 0 && child.height > 0)) {
2910  // needs a box
2911  p->setPen(lv->palette.mid().color());
2912  p->drawRect(bx - 4, linebot - 4, 8, 8);
2913  // plus or minus
2914  p->setPen(lv->palette.text().color());
2915  p->drawLine(bx - 2, linebot, bx + 2, linebot);
2916  if (!(child.state & State_Open))
2917  p->drawLine(bx, linebot - 2, bx, linebot + 2);
2918  // dotlinery
2919  p->setPen(lv->palette.mid().color());
2920  dotlines[c++] = QPoint(bx, linetop);
2921  dotlines[c++] = QPoint(bx, linebot - 4);
2922  dotlines[c++] = QPoint(bx + 5, linebot);
2923  dotlines[c++] = QPoint(lv->rect.width(), linebot);
2924  linetop = linebot + 5;
2925  } else {
2926  // just dotlinery
2927  dotlines[c++] = QPoint(bx+1, linebot -1);
2928  dotlines[c++] = QPoint(lv->rect.width(), linebot -1);
2929  }
2930  y += child.totalHeight;
2931  }
2932  ++i;
2933  }
2934 
2935  // Expand line height to edge of rectangle if there's any
2936  // visible child below
2937  while (i < lv->items.size() && lv->items.at(i).height <= 0)
2938  ++i;
2939  if (i < lv->items.size())
2940  linebot = lv->rect.height();
2941 
2942  if (linetop < linebot) {
2943  dotlines[c++] = QPoint(bx, linetop);
2944  dotlines[c++] = QPoint(bx, linebot);
2945  }
2946  }
2947  p->setPen(lv->palette.text().color());
2948  QBitmap *verticalLine = globalVerticalLine();
2949  QBitmap *horizontalLine = globalHorizontalLine();
2950  static bool isInit = false;
2951  if (!isInit) {
2952  isInit = true;
2953  // make 128*1 and 1*128 bitmaps that can be used for
2954  // drawing the right sort of lines.
2955  verticalLine->clear();
2956  horizontalLine->clear();
2957  QPolygon a(64);
2958  QPainter p;
2959  p.begin(verticalLine);
2960  for(i = 0; i < 64; ++i)
2961  a.setPoint(i, 0, i * 2 + 1);
2962  p.setPen(Qt::color1);
2963  p.drawPoints(a);
2964  p.end();
2966  verticalLine->setMask(*verticalLine);
2967  p.begin(horizontalLine);
2968  for(i = 0; i < 64; ++i)
2969  a.setPoint(i, i * 2 + 1, 0);
2970  p.setPen(Qt::color1);
2971  p.drawPoints(a);
2972  p.end();
2974  horizontalLine->setMask(*horizontalLine);
2975  }
2976 
2977  int line; // index into dotlines
2978  if (lv->subControls & SC_Q3ListViewBranch) for(line = 0; line < c; line += 2) {
2979  // assumptions here: lines are horizontal or vertical.
2980  // lines always start with the numerically lowest
2981  // coordinate.
2982 
2983  // point ... relevant coordinate of current point
2984  // end ..... same coordinate of the end of the current line
2985  // other ... the other coordinate of the current point/line
2986  if (dotlines[line].y() == dotlines[line+1].y()) {
2987  int end = dotlines[line + 1].x();
2988  int point = dotlines[line].x();
2989  int other = dotlines[line].y();
2990  while (point < end) {
2991  int i = 128;
2992  if (i + point > end)
2993  i = end-point;
2994  p->drawPixmap(point, other, *horizontalLine, 0, 0, i, 1);
2995  point += i;
2996  }
2997  } else {
2998  int end = dotlines[line + 1].y();
2999  int point = dotlines[line].y();
3000  int other = dotlines[line].x();
3001  int pixmapoffset = ((point & 1) != dotoffset) ? 1 : 0;
3002  while(point < end) {
3003  int i = 128;
3004  if (i + point > end)
3005  i = end-point;
3006  p->drawPixmap(other, point, *verticalLine, 0, pixmapoffset, 1, i);
3007  point += i;
3008  }
3009  }
3010  }
3011  }
3012  }
3013  break;
3014 #endif // QT3_SUPPORT
3015 #ifndef QT_NO_COMBOBOX
3016  case CC_ComboBox:
3017  if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
3018  QBrush editBrush = cmb->palette.brush(QPalette::Base);
3019  if ((cmb->subControls & SC_ComboBoxFrame)) {
3020  if (cmb->frame) {
3021  QPalette shadePal = opt->palette;
3022  shadePal.setColor(QPalette::Midlight, shadePal.button().color());
3023  qDrawWinPanel(p, opt->rect, shadePal, true, &editBrush);
3024  }
3025  else {
3026  p->fillRect(opt->rect, editBrush);
3027  }
3028  }
3029  if (cmb->subControls & SC_ComboBoxArrow) {
3030  State flags = State_None;
3031 
3032  QRect ar = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
3033  bool sunkenArrow = cmb->activeSubControls == SC_ComboBoxArrow
3034  && cmb->state & State_Sunken;
3035  if (sunkenArrow) {
3036  p->setPen(cmb->palette.dark().color());
3037  p->setBrush(cmb->palette.brush(QPalette::Button));
3038  p->drawRect(ar.adjusted(0,0,-1,-1));
3039  } else {
3040  // Make qDrawWinButton use the right colors for drawing the shade of the button
3041  QPalette pal(cmb->palette);
3042  pal.setColor(QPalette::Button, cmb->palette.light().color());
3043  pal.setColor(QPalette::Light, cmb->palette.button().color());
3044  qDrawWinButton(p, ar, pal, false,
3045  &cmb->palette.brush(QPalette::Button));
3046  }
3047 
3048  ar.adjust(2, 2, -2, -2);
3049  if (opt->state & State_Enabled)
3050  flags |= State_Enabled;
3051  if (opt->state & State_HasFocus)
3052  flags |= State_HasFocus;
3053 
3054  if (sunkenArrow)
3055  flags |= State_Sunken;
3056  QStyleOption arrowOpt(0);
3057  arrowOpt.rect = ar.adjusted(1, 1, -1, -1);
3058  arrowOpt.palette = cmb->palette;
3059  arrowOpt.state = flags;
3060  proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
3061  }
3062 
3063  if (cmb->subControls & SC_ComboBoxEditField) {
3065  if (cmb->state & State_HasFocus && !cmb->editable)
3066  p->fillRect(re.x(), re.y(), re.width(), re.height(),
3067  cmb->palette.brush(QPalette::Highlight));
3068 
3069  if (cmb->state & State_HasFocus) {
3070  p->setPen(cmb->palette.highlightedText().color());
3071  p->setBackground(cmb->palette.highlight());
3072 
3073  } else {
3074  p->setPen(cmb->palette.text().color());
3075  p->setBackground(cmb->palette.background());
3076  }
3077 
3078  if (cmb->state & State_HasFocus && !cmb->editable) {
3079  QStyleOptionFocusRect focus;
3080  focus.QStyleOption::operator=(*cmb);
3081  focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget);
3082  focus.state |= State_FocusAtBorder;
3083  focus.backgroundColor = cmb->palette.highlight().color();
3084  proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
3085  }
3086  }
3087  }
3088  break;
3089 #endif // QT_NO_COMBOBOX
3090 #ifndef QT_NO_SPINBOX
3091  case CC_SpinBox:
3092  if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
3093  QStyleOptionSpinBox copy = *sb;
3094  PrimitiveElement pe;
3095  bool enabled = opt->state & State_Enabled;
3096  if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
3097  QBrush editBrush = sb->palette.brush(QPalette::Base);
3098  QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);
3099  QPalette shadePal = sb->palette;
3100  shadePal.setColor(QPalette::Midlight, shadePal.button().color());
3101  qDrawWinPanel(p, r, shadePal, true, &editBrush);
3102  }
3103 
3104  QPalette shadePal(opt->palette);
3105  shadePal.setColor(QPalette::Button, opt->palette.light().color());
3106  shadePal.setColor(QPalette::Light, opt->palette.button().color());
3107 
3108  if (sb->subControls & SC_SpinBoxUp) {
3109  copy.subControls = SC_SpinBoxUp;
3110  QPalette pal2 = sb->palette;
3111  if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
3113  copy.state &= ~State_Enabled;
3114  }
3115 
3116  copy.palette = pal2;
3117 
3118  if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
3119  copy.state |= State_On;
3120  copy.state |= State_Sunken;
3121  } else {
3122  copy.state |= State_Raised;
3123  copy.state &= ~State_Sunken;
3124  }
3125  pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
3126  : PE_IndicatorSpinUp);
3127 
3128  copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);
3129  qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
3130  &copy.palette.brush(QPalette::Button));
3131  copy.rect.adjust(4, 1, -5, -1);
3132  if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled))
3133  && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
3134  {
3135  QStyleOptionSpinBox lightCopy = copy;
3136  lightCopy.rect.adjust(1, 1, 1, 1);
3137  lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
3138  proxy()->drawPrimitive(pe, &lightCopy, p, widget);
3139  }
3140  proxy()->drawPrimitive(pe, &copy, p, widget);
3141  }
3142 
3143  if (sb->subControls & SC_SpinBoxDown) {
3144  copy.subControls = SC_SpinBoxDown;
3145  copy.state = sb->state;
3146  QPalette pal2 = sb->palette;
3147  if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
3149  copy.state &= ~State_Enabled;
3150  }
3151  copy.palette = pal2;
3152 
3153  if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
3154  copy.state |= State_On;
3155  copy.state |= State_Sunken;
3156  } else {
3157  copy.state |= State_Raised;
3158  copy.state &= ~State_Sunken;
3159  }
3160  pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
3162 
3163  copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
3164  qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
3165  &copy.palette.brush(QPalette::Button));
3166  copy.rect.adjust(4, 0, -5, -1);
3167  if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled))
3168  && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
3169  {
3170  QStyleOptionSpinBox lightCopy = copy;
3171  lightCopy.rect.adjust(1, 1, 1, 1);
3172  lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
3173  proxy()->drawPrimitive(pe, &lightCopy, p, widget);
3174  }
3175  proxy()->drawPrimitive(pe, &copy, p, widget);
3176  }
3177  }
3178  break;
3179 #endif // QT_NO_SPINBOX
3180 
3181  default:
3182  QCommonStyle::drawComplexControl(cc, opt, p, widget);
3183  }
3184 }
3185 
3188  const QSize &csz, const QWidget *widget) const
3189 {
3190  QSize sz(csz);
3191  switch (ct) {
3192  case CT_PushButton:
3193  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
3194  sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
3195  int w = sz.width(),
3196  h = sz.height();
3197  int defwidth = 0;
3198  if (btn->features & QStyleOptionButton::AutoDefaultButton)
3199  defwidth = 2 * proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget);
3200  int minwidth = int(QStyleHelper::dpiScaled(75.));
3201  int minheight = int(QStyleHelper::dpiScaled(23.));
3202 
3203 #ifndef QT_QWS_SMALL_PUSHBUTTON
3204  if (w < minwidth + defwidth && !btn->text.isEmpty())
3205  w = minwidth + defwidth;
3206  if (h < minheight + defwidth)
3207  h = minheight + defwidth;
3208 #endif
3209  sz = QSize(w, h);
3210  }
3211  break;
3212 #ifndef QT_NO_MENU
3213  case CT_MenuItem:
3214  if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
3215  int w = sz.width();
3216  sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
3217 
3218  if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
3220  }
3221  else if (mi->icon.isNull()) {
3222  sz.setHeight(sz.height() - 2);
3223  w -= 6;
3224  }
3225 
3226  if (mi->menuItemType != QStyleOptionMenuItem::Separator && !mi->icon.isNull()) {
3227  int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
3228  sz.setHeight(qMax(sz.height(),
3229  mi->icon.actualSize(QSize(iconExtent, iconExtent)).height()
3231  }
3232  int maxpmw = mi->maxIconWidth;
3233  int tabSpacing = 20;
3234  if (mi->text.contains(QLatin1Char('\t')))
3235  w += tabSpacing;
3236  else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
3238  else if (mi->menuItemType == QStyleOptionMenuItem::DefaultItem) {
3239  // adjust the font and add the difference in size.
3240  // it would be better if the font could be adjusted in the initStyleOption qmenu func!!
3241  QFontMetrics fm(mi->font);
3242  QFont fontBold = mi->font;
3243  fontBold.setBold(true);
3244  QFontMetrics fmBold(fontBold);
3245  w += fmBold.width(mi->text) - fm.width(mi->text);
3246  }
3247 
3248  int checkcol = qMax<int>(maxpmw, QWindowsStylePrivate::windowsCheckMarkWidth); // Windows always shows a check column
3249  w += checkcol;
3251  sz.setWidth(w);
3252  }
3253  break;
3254 #endif // QT_NO_MENU
3255 #ifndef QT_NO_MENUBAR
3256  case CT_MenuBarItem:
3257  if (!sz.isEmpty())
3259  break;
3260 #endif
3261  // Otherwise, fall through
3262  case CT_ToolButton:
3263  if (qstyleoption_cast<const QStyleOptionToolButton *>(opt))
3264  return sz += QSize(7, 6);
3265  // Otherwise, fall through
3266 
3267  default:
3268  sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
3269  }
3270  return sz;
3271 }
3272 
3277  const QWidget *widget) const
3278 {
3279  QIcon icon;
3280  QPixmap pixmap;
3281 #ifdef Q_OS_WIN
3282  switch (standardIcon) {
3284  {
3285  for (int size = 16 ; size <= 32 ; size += 16) {
3286  pixmap = loadIconFromShell32(319, size);
3287  icon.addPixmap(pixmap, QIcon::Normal);
3288  }
3289  break;
3290  }
3291  case SP_DirHomeIcon:
3292  {
3293  for (int size = 16 ; size <= 32 ; size += 16) {
3294  pixmap = loadIconFromShell32(235, size);
3295  icon.addPixmap(pixmap, QIcon::Normal);
3296  }
3297  break;
3298  }
3299  case SP_DirIcon:
3300  for (int size = 16 ; size <= 32 ; size += 16) {
3301  pixmap = loadIconFromShell32(4, size);
3302  icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
3303  pixmap = loadIconFromShell32(5, size);
3304  icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
3305  }
3306  break;
3307  case SP_DirLinkIcon:
3308  for (int size = 16 ; size <= 32 ; size += 16) {
3309  QPixmap link = loadIconFromShell32(30, size);
3310  pixmap = loadIconFromShell32(4, size);
3311  if (!pixmap.isNull() && !link.isNull()) {
3312  QPainter painter(&pixmap);
3313  painter.drawPixmap(0, 0, size, size, link);
3314  icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
3315  }
3316  link = loadIconFromShell32(30, size);
3317  pixmap = loadIconFromShell32(5, size);
3318  if (!pixmap.isNull() && !link.isNull()) {
3319  QPainter painter(&pixmap);
3320  painter.drawPixmap(0, 0, size, size, link);
3321  icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
3322  }
3323  }
3324  break;
3325  case SP_FileIcon:
3326  for (int size = 16 ; size <= 32 ; size += 16) {
3327  pixmap = loadIconFromShell32(1, size);
3328  icon.addPixmap(pixmap, QIcon::Normal);
3329  }
3330  break;
3331  case SP_ComputerIcon:
3332  for (int size = 16 ; size <= 32 ; size += 16) {
3333  pixmap = loadIconFromShell32(16, size);
3334  icon.addPixmap(pixmap, QIcon::Normal);
3335  }
3336  break;
3337 
3338  case SP_DesktopIcon:
3339  for (int size = 16 ; size <= 32 ; size += 16) {
3340  pixmap = loadIconFromShell32(35, size);
3341  icon.addPixmap(pixmap, QIcon::Normal);
3342  }
3343  break;
3344  case SP_DriveCDIcon:
3345  case SP_DriveDVDIcon:
3346  for (int size = 16 ; size <= 32 ; size += 16) {
3347  pixmap = loadIconFromShell32(12, size);
3348  icon.addPixmap(pixmap, QIcon::Normal);
3349  }
3350  break;
3351  case SP_DriveNetIcon:
3352  for (int size = 16 ; size <= 32 ; size += 16) {
3353  pixmap = loadIconFromShell32(10, size);
3354  icon.addPixmap(pixmap, QIcon::Normal);
3355  }
3356  break;
3357  case SP_DriveHDIcon:
3358  for (int size = 16 ; size <= 32 ; size += 16) {
3359  pixmap = loadIconFromShell32(9, size);
3360  icon.addPixmap(pixmap, QIcon::Normal);
3361  }
3362  break;
3363  case SP_DriveFDIcon:
3364  for (int size = 16 ; size <= 32 ; size += 16) {
3365  pixmap = loadIconFromShell32(7, size);
3366  icon.addPixmap(pixmap, QIcon::Normal);
3367  }
3368  break;
3369  case SP_FileLinkIcon:
3370  for (int size = 16 ; size <= 32 ; size += 16) {
3371  QPixmap link;
3372  link = loadIconFromShell32(30, size);
3373  pixmap = loadIconFromShell32(1, size);
3374  if (!pixmap.isNull() && !link.isNull()) {
3375  QPainter painter(&pixmap);
3376  painter.drawPixmap(0, 0, size, size, link);
3377  icon.addPixmap(pixmap, QIcon::Normal);
3378  }
3379  }
3380  break;
3381  case SP_VistaShield:
3382  {
3386  {
3387  icon.addPixmap(proxy()->standardPixmap(SP_VistaShield, option, widget)); //fetches small icon
3388  QSHSTOCKICONINFO iconInfo; //append large icon
3389  memset(&iconInfo, 0, sizeof(iconInfo));
3390  iconInfo.cbSize = sizeof(iconInfo);
3391  if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_LARGEICON, &iconInfo) == S_OK) {
3392  icon.addPixmap(QPixmap::fromWinHICON(iconInfo.hIcon));
3393  DestroyIcon(iconInfo.hIcon);
3394  }
3395  }
3396  }
3397  break;
3398  default:
3399  break;
3400  }
3401 #endif
3402 
3403  if (icon.isNull())
3404  icon = QCommonStyle::standardIconImplementation(standardIcon, option, widget);
3405  return icon;
3406 }
3407 
3408 
3409 
3411 
3412 #endif // QT_NO_STYLE_WINDOWS
T qobject_cast(QObject *object)
Definition: qobject.h:375
int startTimer(int interval)
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer...
Definition: qobject.cpp:1623
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
QElapsedTimer startTime
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
int height
the height of the item
Definition: qstyleoption.h:474
void polish(QApplication *)
Reimplemented Function
void unpolish(QApplication *)
Reimplemented Function
QColor inactiveGradientCaptionColor
QImage toImage() const
Converts the pixmap to a QImage.
Definition: qpixmap.cpp:542
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 QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
static const char *const qt_close_xpm[]
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
StyleHint
This enum describes the available style hints.
Definition: qstyle.h:640
The QStyleHintReturn class provides style hints that return more than basic data types.
Definition: qstyleoption.h:907
unsigned char c[8]
Definition: qnumeric_p.h:62
void addPixmap(const QPixmap &pixmap, Mode mode=Normal, State state=Off)
Adds pixmap to the icon, as a specialization for mode and state.
Definition: qicon.cpp:814
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
#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
static QPixmap fromWinHICON(HICON hicon)
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
EventRef event
QPointer< QWidget > widget
static const char *const information_xpm[]
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
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
static const char *const qt_menu_xpm[]
void startAnimation(QObject *o, QProgressBar *bar)
const QBrush & background() const
Returns the current background brush.
Definition: qpainter.cpp:2482
The QMatrix class specifies 2D transformations of a coordinate system.
Definition: qmatrix.h:61
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
static const char *const question_xpm[]
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:204
QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
#define PTSARRLEN(x)
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...
bool isVisible() const
Definition: qwidget.h:1005
void setMask(const QBitmap &)
Sets a mask bitmap.
Definition: qpixmap.cpp:822
static QSize globalStrut()
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.
ComplexControl
This enum describes the available complex controls.
Definition: qstyle.h:386
The QStyleOptionQ3ListView class is used to describe the parameters for drawing a Q3ListView...
Definition: qstyleoption.h:747
void fill(uint pixel)
Fills the entire image with the given pixelValue.
Definition: qimage.cpp:2032
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
~QWindowsStyle()
Destroys the QWindowsStyle object.
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or 0 if no application wi...
Qt::Orientation orientation
the progress bar&#39;s orientation (horizontal or vertical); the default orentation is Qt::Horizontal ...
Definition: qstyleoption.h:422
bool eventFilter(QObject *o, QEvent *e)
Reimplemented Function
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
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
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...
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int childCount
the number of children the item has
Definition: qstyleoption.h:477
The QStyleOptionToolBar class is used to describe the parameters for drawing a toolbar.
Definition: qstyleoption.h:369
QSliderDirection
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
Definition: qglobal.h:92
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
long ASN1_INTEGER_get ASN1_INTEGER * a
static QPalette palette()
Returns the application palette.
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
#define _SIID_SHIELD
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
The QProgressBar widget provides a horizontal or vertical progress bar.
Definition: qprogressbar.h:58
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
static const char *const qt_shade_xpm[]
static const WinVersion WindowsVersion
the version of the Windows operating system on which the application is run (Windows only) ...
Definition: qglobal.h:1613
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
bool hasSeenAlt(const QWidget *widget) const
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
T * qobject_cast(QObject *object)
Definition: qobject.h:375
static const char *const qt_maximize_xpm[]
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
bool load(bool onlySystemDirectory=true)
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
QMatrix & 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: qmatrix.cpp:922
static const char *const qt_help_xpm[]
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
QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen&#39;s color.
Definition: qpainter.h:676
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static const char * dock_widget_close_xpm[]
NSToolbar * toolbar
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
const char * className
Definition: qwizard.cpp:137
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
StandardPixmap
This enum describes the available standard pixmaps.
Definition: qstyle.h:755
static QPixmap * find(const QString &key)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
QStyle * style() const
Definition: qwidget.cpp:2742
bool begin(QPaintDevice *)
Begins painting the paint device and returns true if successful; otherwise returns false...
Definition: qpainter.cpp:1723
#define COLOR_GRADIENTINACTIVECAPTION
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
QColor backgroundColor
the background color on which the focus rectangle is being drawn
Definition: qstyleoption.h:109
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
void setCurrentColorGroup(ColorGroup cg)
Set the palette&#39;s current color group to cg.
Definition: qpalette.h:105
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
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
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
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
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
Definition: qpainter.cpp:2077
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
int totalHeight
the total height of the item, including its children
Definition: qstyleoption.h:475
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
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
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
The QStyleOptionQ3ListViewItem class is used to describe an item drawn in a Q3ListView.
Definition: qstyleoption.h:463
QMatrix & rotate(qreal a)
Rotates the coordinate system the given degrees counterclockwise.
Definition: qmatrix.cpp:990
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
QPoint brushOrigin() const
Returns the currently set brush origin.
Definition: qpainter.cpp:2168
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
static const char *const qt_normalizeup_xpm[]
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
Definition: qpainter.cpp:4873
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:475
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static const char *const warning_xpm[]
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
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
static QRgb colorref2qrgb(COLORREF col)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QColor dark(int f=200) const
Use darker(factor) instead.
Definition: qcolor.cpp:2447
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
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
const QBrush & midlight() const
Returns the midlight brush of the current color group.
Definition: qpalette.h:136
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition: qpalette.h:128
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
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
Q3ListViewItemFeatures features
the features for this item
Definition: qstyleoption.h:473
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
#define _SHGFI_LARGEICON
bool showDecorationSelected
whether the decoration should be highlighted on selected items
Definition: qstyleoption.h:553
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
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
T findChild(const QString &aName=QString()) const
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object.
Definition: qobject.h:158
int pixelMetric(PixelMetric pm, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
bool inFont(QChar) const
Returns true if character ch is a valid character in the font; otherwise returns false.
void qDrawWinButton(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:435
QList< const QWidget * > seenAlt
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
Definition: qpainter.cpp:5205
#define _SHGFI_ICON
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:303
int pixelMetric(PixelMetric m, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
void timerEvent(QTimerEvent *event)
Reimplemented Function
void polish(QPalette &)
Reimplemented Function
The State element defines configurations of objects and properties.
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
Definition: qbrush.cpp:785
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
The QStyleOptionRubberBand class is used to describe the parameters needed for drawing a rubber band...
Definition: qstyleoption.h:669
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 unpolish(QWidget *widget)
Reimplemented Function
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
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
int styleHint(StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
qreal dpiScaled(qreal value)
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 drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
Definition: qpainter.cpp:7146
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
const QBrush & shadow() const
Returns the shadow brush of the current color group.
Definition: qpalette.h:139
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
QWindowsStyle()
Constructs a QWindowsStyle object.
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
long HRESULT
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
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
static const char *const critical_xpm[]
void * resolve(const char *symbol)
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
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
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 QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
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
Qt::BGMode backgroundMode() const
Returns the current background mode.
Definition: qpainter.cpp:4026
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition: qpalette.h:141
#define SPI_GETKEYBOARDCUES
Definition: qt_windows.h:107
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
void eraseRect(const QRectF &)
Erases the area inside the given rectangle.
Definition: qpainter.cpp:7332
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
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
Definition: qrgb.h:69
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
The QCommonStyle class encapsulates the common Look and Feel of a GUI.
Definition: qcommonstyle.h:54
int key
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 installEventFilter(QObject *)
Installs an event filter filterObj on this object.
Definition: qobject.cpp:2070
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
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
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void setPoint(int index, int x, int y)
Sets the point at the given index to the point specified by ({x}, {y}).
Definition: qpolygon.h:120
QFactoryLoader * l
QRect boundingRect() const
Returns the bounding rectangle of the polygon, or QRect(0, 0, 0, 0) if the polygon is empty...
Definition: qpolygon.cpp:492
#define COLOR_GRADIENTACTIVECAPTION
static const char *const qt_minimize_xpm[]
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
const QStyle * proxy() const
Definition: qstyle.cpp:2546
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
void clear()
Clears the bitmap, setting all its bits to Qt::color0.
Definition: qbitmap.h:69
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
Definition: qglobal.h:91
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
static QPixmap loadIconFromShell32(int resourceId, int size)
static const char *const qt_unshade_xpm[]
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
int itemY
the Y-coordinate for the item
Definition: qstyleoption.h:476
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
void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
Definition: qpolygon.cpp:350
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition: qpalette.h:138
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt=0, const QWidget *widget=0) const
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
The QStyleOptionComplex class is used to hold parameters that are common to all complex controls...
Definition: qstyleoption.h:687
HRESULT(WINAPI * PtrSHGetStockIconInfo)(int siid, int uFlags, QSHSTOCKICONINFO *psii)
QList< QProgressBar * > animatedProgressBars
bool isValid() const
Returns true if the color is valid; otherwise returns false.
Definition: qcolor.h:295
The QStyleOptionViewItem class is used to describe the parameters used to draw an item in a view widg...
Definition: qstyleoption.h:539
QRegion region
the region for style hints that return a QRegion
Definition: qstyleoption.h:930
The QWindowsStyle class provides a Microsoft Windows-like look and feel.
Definition: qwindowsstyle.h:57
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
Definition: qsize.h:120
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
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
#define _SHGFI_SMALLICON
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
bool invertedAppearance
whether the progress bar&#39;s appearance is inverted
Definition: qstyleoption.h:423
Orientation
Definition: qnamespace.h:174
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
void drawPolyline(const QPointF *points, int pointCount)
Draws the polyline defined by the first pointCount points in points using the current pen...
Definition: qpainter.cpp:5055
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
Definition: qmatrix.cpp:389
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
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
void start()
Starts this timer.
BGMode
Definition: qnamespace.h:588
QList< T > findChildren(const QString &aName=QString()) const
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
Definition: qobject.h:162
#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS)
Declares a global static variable with the specified type and name.
Definition: qglobal.h:1982
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
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
#define enabled
void setBackground(const QBrush &bg)
Sets the background brush of the painter to the given brush.
Definition: qpainter.cpp:4258
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
bool end()
Ends painting.
Definition: qpainter.cpp:1929
static void flush()
Flushes the platform specific event queues.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
#define text
Definition: qobjectdefs.h:80
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
int styleHint(StyleHint sh, const QStyleOption *opt=0, const QWidget *w=0, QStyleHintReturn *shret=0) const
Reimplemented Function
QColor light(int f=150) const
Use lighter(factor) instead.
Definition: qcolor.cpp:2391
static PtrSHGetStockIconInfo pSHGetStockIconInfo
void killTimer(int id)
Kills the timer with timer identifier, id.
Definition: qobject.cpp:1650
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770
void stopAnimation(QObject *o, QProgressBar *bar)
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311
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
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480