1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtGui module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
42 #include "qwindowsstyle.h"
43 #include "qwindowsstyle_p.h"
45 #if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
47 #include <private/qsystemlibrary_p.h>
48 #include "qapplication.h"
50 #include "qdrawutil.h" // for now
54 #include <private/qmenubar_p.h>
55 #include "qpaintengine.h"
57 #include "qrubberband.h"
58 #include "qstyleoption.h"
62 #include "qmainwindow.h"
64 #include "qtextstream.h"
65 #include "qpixmapcache.h"
67 #include "qlistview.h"
68 #include <private/qmath_p.h>
70 #include <qpa/qplatformtheme.h>
71 #include <private/qguiapplication_p.h>
73 #include <private/qstylehelper_p.h>
74 #include <private/qstyleanimation_p.h>
80 QT_BEGIN_INCLUDE_NAMESPACE
81 #include "qt_windows.h"
82 QT_END_INCLUDE_NAMESPACE
83 # ifndef COLOR_GRADIENTACTIVECAPTION
84 # define COLOR_GRADIENTACTIVECAPTION 27
86 # ifndef COLOR_GRADIENTINACTIVECAPTION
87 # define COLOR_GRADIENTINACTIVECAPTION 28
97 WCHAR szPath[MAX_PATH];
100 #define _SHGFI_SMALLICON 0x000000001
101 #define _SHGFI_LARGEICON 0x000000000
102 #define _SHGFI_ICON 0x000000100
103 #define _SIID_SHIELD 77
105 typedef HRESULT (WINAPI *PtrSHGetStockIconInfo)(int siid, int uFlags, QSHSTOCKICONINFO *psii);
106 static PtrSHGetStockIconInfo pSHGetStockIconInfo = 0;
108 Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &);
109 Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon);
112 QT_BEGIN_INCLUDE_NAMESPACE
114 QT_END_INCLUDE_NAMESPACE
116 enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight };
121 QWindowsStylePrivate::QWindowsStylePrivate()
122 : alt_down(false), menuBarTimer(0)
124 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
125 if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
126 && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) {
127 QSystemLibrary shellLib(QLatin1String("shell32"));
128 pSHGetStockIconInfo = (PtrSHGetStockIconInfo)shellLib.resolve("SHGetStockIconInfo");
133 // Returns true if the toplevel parent of \a widget has seen the Alt-key
134 bool QWindowsStylePrivate::hasSeenAlt(const QWidget *widget) const
136 widget = widget->window();
137 return seenAlt.contains(widget);
143 bool QWindowsStyle::eventFilter(QObject *o, QEvent *e)
145 // Records Alt- and Focus events
146 if (!o->isWidgetType())
147 return QObject::eventFilter(o, e);
149 QWidget *widget = qobject_cast<QWidget*>(o);
152 case QEvent::KeyPress:
153 if (static_cast<QKeyEvent *>(e)->key() == Qt::Key_Alt) {
154 widget = widget->window();
156 // Alt has been pressed - find all widgets that care
157 QList<QWidget *> l = widget->findChildren<QWidget *>();
158 for (int pos=0 ; pos < l.size() ; ++pos) {
159 QWidget *w = l.at(pos);
160 if (w->isWindow() || !w->isVisible() ||
161 w->style()->styleHint(SH_UnderlineShortcut, 0, w))
164 // Update states before repainting
165 d->seenAlt.append(widget);
168 // Repaint all relevant widgets
169 for (int pos = 0; pos < l.size(); ++pos)
173 case QEvent::KeyRelease:
174 if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Alt) {
175 widget = widget->window();
177 // Update state and repaint the menu bars.
179 #ifndef QT_NO_MENUBAR
180 QList<QMenuBar *> l = widget->findChildren<QMenuBar *>();
181 for (int i = 0; i < l.size(); ++i)
187 // Reset widget when closing
188 d->seenAlt.removeAll(widget);
189 d->seenAlt.removeAll(widget->window());
194 return QCommonStyle::eventFilter(o, e);
199 \brief The QWindowsStyle class provides a Microsoft Windows-like look and feel.
204 This style is Qt's default GUI style on Windows.
206 \image qwindowsstyle.png
207 \sa QWindowsXPStyle, QMacStyle, QPlastiqueStyle
211 Constructs a QWindowsStyle object.
213 QWindowsStyle::QWindowsStyle() : QCommonStyle(*new QWindowsStylePrivate)
220 Constructs a QWindowsStyle object.
222 QWindowsStyle::QWindowsStyle(QWindowsStylePrivate &dd) : QCommonStyle(dd)
227 /*! Destroys the QWindowsStyle object. */
228 QWindowsStyle::~QWindowsStyle()
233 static inline QRgb colorref2qrgb(COLORREF col)
235 return qRgb(GetRValue(col), GetGValue(col), GetBValue(col));
240 void QWindowsStyle::polish(QApplication *app)
242 QCommonStyle::polish(app);
243 QWindowsStylePrivate *d = const_cast<QWindowsStylePrivate*>(d_func());
244 // We only need the overhead when shortcuts are sometimes hidden
245 if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app)
246 app->installEventFilter(this);
248 d->activeCaptionColor = app->palette().highlight().color();
249 d->activeGradientCaptionColor = app->palette().highlight() .color();
250 d->inactiveCaptionColor = app->palette().dark().color();
251 d->inactiveGradientCaptionColor = app->palette().dark().color();
252 d->inactiveCaptionText = app->palette().background().color();
254 #if defined(Q_OS_WIN) //fetch native title bar colors
255 if(app->desktopSettingsAware()){
256 DWORD activeCaption = GetSysColor(COLOR_ACTIVECAPTION);
257 DWORD gradientActiveCaption = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
258 DWORD inactiveCaption = GetSysColor(COLOR_INACTIVECAPTION);
259 DWORD gradientInactiveCaption = GetSysColor(COLOR_GRADIENTINACTIVECAPTION);
260 DWORD inactiveCaptionText = GetSysColor(COLOR_INACTIVECAPTIONTEXT);
261 d->activeCaptionColor = colorref2qrgb(activeCaption);
262 d->activeGradientCaptionColor = colorref2qrgb(gradientActiveCaption);
263 d->inactiveCaptionColor = colorref2qrgb(inactiveCaption);
264 d->inactiveGradientCaptionColor = colorref2qrgb(gradientInactiveCaption);
265 d->inactiveCaptionText = colorref2qrgb(inactiveCaptionText);
271 void QWindowsStyle::unpolish(QApplication *app)
273 QCommonStyle::unpolish(app);
274 app->removeEventFilter(this);
278 void QWindowsStyle::polish(QWidget *widget)
280 QCommonStyle::polish(widget);
284 void QWindowsStyle::unpolish(QWidget *widget)
286 QCommonStyle::unpolish(widget);
292 void QWindowsStyle::polish(QPalette &pal)
294 QCommonStyle::polish(pal);
300 int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWidget *widget) const
305 case PM_ButtonDefaultIndicator:
306 case PM_ButtonShiftHorizontal:
307 case PM_ButtonShiftVertical:
312 case PM_DockWidgetSeparatorExtent:
313 ret = int(QStyleHelper::dpiScaled(4.));
316 case PM_TabBarTabShiftHorizontal:
319 case PM_TabBarTabShiftVertical:
323 case PM_MaximumDragDistance:
324 ret = QCommonStyle::pixelMetric(PM_MaximumDragDistance);
330 case PM_SliderLength:
331 ret = int(QStyleHelper::dpiScaled(11.));
334 // Returns the number of pixels to use for the business part of the
335 // slider (i.e., the non-tickmark portion). The remaining space is shared
336 // equally between the tickmark regions.
337 case PM_SliderControlThickness:
338 if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
339 int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
340 int ticks = sl->tickPosition;
342 if (ticks & QSlider::TicksAbove)
344 if (ticks & QSlider::TicksBelow)
351 int thick = 6; // Magic constant to get 5 + 16 + 5
352 if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks)
353 thick += proxy()->pixelMetric(PM_SliderLength, sl, widget) / 4;
357 thick += (space * 2) / (n + 2);
363 #endif // QT_NO_SLIDER
366 case PM_MenuBarHMargin:
370 case PM_MenuBarVMargin:
374 case PM_MenuBarPanelWidth:
378 case PM_SmallIconSize:
379 ret = int(QStyleHelper::dpiScaled(16.));
382 case PM_LargeIconSize:
383 ret = int(QStyleHelper::dpiScaled(32.));
386 case PM_IconViewIconSize:
387 ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget);
390 case PM_DockWidgetTitleMargin:
391 ret = int(QStyleHelper::dpiScaled(2.));
393 case PM_DockWidgetTitleBarButtonMargin:
394 ret = int(QStyleHelper::dpiScaled(4.));
396 #if defined(Q_WS_WIN)
397 case PM_DockWidgetFrameWidth:
398 #if defined(Q_OS_WINCE)
399 ret = GetSystemMetrics(SM_CXDLGFRAME);
401 ret = GetSystemMetrics(SM_CXFRAME);
405 case PM_DockWidgetFrameWidth:
414 #if defined(Q_OS_WIN)
415 case PM_TitleBarHeight:
416 if (widget && (widget->windowType() == Qt::Tool)) {
417 // MS always use one less than they say
418 #if defined(Q_OS_WINCE)
419 ret = GetSystemMetrics(SM_CYCAPTION) - 1;
421 ret = GetSystemMetrics(SM_CYSMCAPTION) - 1;
424 ret = GetSystemMetrics(SM_CYCAPTION) - 1;
429 case PM_ScrollBarExtent:
432 NONCLIENTMETRICS ncm;
433 ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONT);
434 if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0))
435 ret = qMax(ncm.iScrollHeight, ncm.iScrollWidth);
438 ret = QCommonStyle::pixelMetric(pm, opt, widget);
443 case PM_SplitterWidth:
444 ret = qMax(4, QApplication::globalStrut().width());
447 #if defined(Q_OS_WIN)
448 case PM_MdiSubWindowFrameWidth:
449 #if defined(Q_OS_WINCE)
450 ret = GetSystemMetrics(SM_CYDLGFRAME);
452 ret = GetSystemMetrics(SM_CYFRAME);
456 case PM_ToolBarItemMargin:
459 case PM_ToolBarItemSpacing:
462 case PM_ToolBarHandleExtent:
463 ret = int(QStyleHelper::dpiScaled(10.));
466 ret = QCommonStyle::pixelMetric(pm, opt, widget);
473 #ifndef QT_NO_IMAGEFORMAT_XPM
476 static const char * const qt_menu_xpm[] = {
567 static const char * const qt_close_xpm[] = {
582 static const char * const qt_maximize_xpm[]={
597 static const char * const qt_minimize_xpm[] = {
612 static const char * const qt_normalizeup_xpm[] = {
627 static const char * const qt_help_xpm[] = {
642 static const char * const qt_shade_xpm[] = {
657 static const char * const qt_unshade_xpm[] = {
672 static const char * dock_widget_close_xpm[] = {
686 static const char * const information_xpm[]={
693 "...........********.............",
694 "........***aaaaaaaa***..........",
695 "......**aaaaaaaaaaaaaa**........",
696 ".....*aaaaaaaaaaaaaaaaaa*.......",
697 "....*aaaaaaaabbbbaaaaaaaac......",
698 "...*aaaaaaaabbbbbbaaaaaaaac.....",
699 "..*aaaaaaaaabbbbbbaaaaaaaaac....",
700 ".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
701 ".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
702 "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
703 "*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
704 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
705 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
706 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
707 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
708 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
709 ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
710 ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
711 "..*aaaaaaaaaabbbbbaaaaaaaaac***.",
712 "...caaaaaaabbbbbbbbbaaaaaac****.",
713 "....caaaaaaaaaaaaaaaaaaaac****..",
714 ".....caaaaaaaaaaaaaaaaaac****...",
715 "......ccaaaaaaaaaaaaaacc****....",
716 ".......*cccaaaaaaaaccc*****.....",
717 "........***cccaaaac*******......",
718 "..........****caaac*****........",
719 ".............*caaac**...........",
720 "...............caac**...........",
721 "................cac**...........",
722 ".................cc**...........",
723 "..................***...........",
724 "...................**..........."};
726 static const char* const warning_xpm[]={
732 ".............***................",
733 "............*aaa*...............",
734 "...........*aaaaa*b.............",
735 "...........*aaaaa*bb............",
736 "..........*aaaaaaa*bb...........",
737 "..........*aaaaaaa*bb...........",
738 ".........*aaaaaaaaa*bb..........",
739 ".........*aaaaaaaaa*bb..........",
740 "........*aaaaaaaaaaa*bb.........",
741 "........*aaaa***aaaa*bb.........",
742 ".......*aaaa*****aaaa*bb........",
743 ".......*aaaa*****aaaa*bb........",
744 "......*aaaaa*****aaaaa*bb.......",
745 "......*aaaaa*****aaaaa*bb.......",
746 ".....*aaaaaa*****aaaaaa*bb......",
747 ".....*aaaaaa*****aaaaaa*bb......",
748 "....*aaaaaaaa***aaaaaaaa*bb.....",
749 "....*aaaaaaaa***aaaaaaaa*bb.....",
750 "...*aaaaaaaaa***aaaaaaaaa*bb....",
751 "...*aaaaaaaaaa*aaaaaaaaaa*bb....",
752 "..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
753 "..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
754 ".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
755 ".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
756 "*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
757 "*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
758 "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
759 "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
760 ".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
761 "..*************************bbbbb",
762 "....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
763 ".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
765 static const char* const critical_xpm[]={
771 "...........********.............",
772 ".........************...........",
773 ".......****************.........",
774 "......******************........",
775 ".....********************a......",
776 "....**********************a.....",
777 "...************************a....",
778 "..*******b**********b*******a...",
779 "..******bbb********bbb******a...",
780 ".******bbbbb******bbbbb******a..",
781 ".*******bbbbb****bbbbb*******a..",
782 "*********bbbbb**bbbbb*********a.",
783 "**********bbbbbbbbbb**********a.",
784 "***********bbbbbbbb***********aa",
785 "************bbbbbb************aa",
786 "************bbbbbb************aa",
787 "***********bbbbbbbb***********aa",
788 "**********bbbbbbbbbb**********aa",
789 "*********bbbbb**bbbbb*********aa",
790 ".*******bbbbb****bbbbb*******aa.",
791 ".******bbbbb******bbbbb******aa.",
792 "..******bbb********bbb******aaa.",
793 "..*******b**********b*******aa..",
794 "...************************aaa..",
795 "....**********************aaa...",
796 "....a********************aaa....",
797 ".....a******************aaa.....",
798 "......a****************aaa......",
799 ".......aa************aaaa.......",
800 ".........aa********aaaaa........",
801 "...........aaaaaaaaaaa..........",
802 ".............aaaaaaa............"};
804 static const char *const question_xpm[] = {
811 "...........********.............",
812 "........***aaaaaaaa***..........",
813 "......**aaaaaaaaaaaaaa**........",
814 ".....*aaaaaaaaaaaaaaaaaa*.......",
815 "....*aaaaaaaaaaaaaaaaaaaac......",
816 "...*aaaaaaaabbbbbbaaaaaaaac.....",
817 "..*aaaaaaaabaaabbbbaaaaaaaac....",
818 ".*aaaaaaaabbaaaabbbbaaaaaaaac...",
819 ".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
820 "*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
821 "*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
822 "*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
823 "*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
824 "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
825 "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
826 "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
827 ".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
828 ".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
829 "..*aaaaaaaaaabbbbaaaaaaaaaac***.",
830 "...caaaaaaaaaabbaaaaaaaaaac****.",
831 "....caaaaaaaaaaaaaaaaaaaac****..",
832 ".....caaaaaaaaaaaaaaaaaac****...",
833 "......ccaaaaaaaaaaaaaacc****....",
834 ".......*cccaaaaaaaaccc*****.....",
835 "........***cccaaaac*******......",
836 "..........****caaac*****........",
837 ".............*caaac**...........",
838 "...............caac**...........",
839 "................cac**...........",
840 ".................cc**...........",
841 "..................***...........",
842 "...................**..........."};
844 #endif //QT_NO_IMAGEFORMAT_XPM
849 QPixmap QWindowsStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
850 const QWidget *widget) const
852 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
854 switch(standardPixmap) {
856 case SP_DriveDVDIcon:
857 case SP_DriveNetIcon:
861 case SP_FileLinkIcon:
863 case SP_DirClosedIcon:
865 case SP_ComputerIcon:
867 case SP_FileDialogNewFolder:
871 if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
872 QPlatformTheme::StandardPixmap sp = static_cast<QPlatformTheme::StandardPixmap>(standardPixmap);
873 desktopIcon = theme->standardPixmap(sp, QSizeF(16, 16));
876 case SP_MessageBoxInformation:
877 case SP_MessageBoxWarning:
878 case SP_MessageBoxCritical:
879 case SP_MessageBoxQuestion:
880 if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
881 QPlatformTheme::StandardPixmap sp = static_cast<QPlatformTheme::StandardPixmap>(standardPixmap);
882 desktopIcon = theme->standardPixmap(sp, QSizeF());
888 if (!desktopIcon.isNull()) {
892 #ifndef QT_NO_IMAGEFORMAT_XPM
893 switch (standardPixmap) {
894 case SP_TitleBarMenuButton:
895 return QPixmap(qt_menu_xpm);
896 case SP_TitleBarShadeButton:
897 return QPixmap(qt_shade_xpm);
898 case SP_TitleBarUnshadeButton:
899 return QPixmap(qt_unshade_xpm);
900 case SP_TitleBarNormalButton:
901 return QPixmap(qt_normalizeup_xpm);
902 case SP_TitleBarMinButton:
903 return QPixmap(qt_minimize_xpm);
904 case SP_TitleBarMaxButton:
905 return QPixmap(qt_maximize_xpm);
906 case SP_TitleBarCloseButton:
907 return QPixmap(qt_close_xpm);
908 case SP_TitleBarContextHelpButton:
909 return QPixmap(qt_help_xpm);
910 case SP_DockWidgetCloseButton:
911 return QPixmap(dock_widget_close_xpm);
912 case SP_MessageBoxInformation:
913 return QPixmap(information_xpm);
914 case SP_MessageBoxWarning:
915 return QPixmap(warning_xpm);
916 case SP_MessageBoxCritical:
917 return QPixmap(critical_xpm);
918 case SP_MessageBoxQuestion:
919 return QPixmap(question_xpm);
923 #endif //QT_NO_IMAGEFORMAT_XPM
924 return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
928 int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget,
929 QStyleHintReturn *returnData) const
934 case SH_EtchDisabledText:
935 case SH_Slider_SnapToValue:
936 case SH_PrintDialog_RightAlignButtons:
937 case SH_FontDialog_SelectAssociatedText:
938 case SH_Menu_AllowActiveAndDisabled:
939 case SH_MenuBar_AltKeyNavigation:
940 case SH_MenuBar_MouseTracking:
941 case SH_Menu_MouseTracking:
942 case SH_ComboBox_ListMouseTracking:
943 case SH_ScrollBar_StopMouseOverSlider:
944 case SH_MainWindow_SpaceBelowMenuBar:
948 case SH_ItemView_ShowDecorationSelected:
949 #ifndef QT_NO_LISTVIEW
950 if (qobject_cast<const QListView*>(widget))
954 case SH_ItemView_ChangeHighlightOnFocus:
957 case SH_ToolBox_SelectedPageTitleBold:
961 #if defined(Q_OS_WIN)
962 case SH_UnderlineShortcut:
966 SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0);
968 // Do nothing if we always paint underlines
969 Q_D(const QWindowsStyle);
970 if (!ret && widget && d) {
971 #ifndef QT_NO_MENUBAR
972 const QMenuBar *menuBar = qobject_cast<const QMenuBar *>(widget);
973 if (!menuBar && qobject_cast<const QMenu *>(widget)) {
974 QWidget *w = QApplication::activeWindow();
975 if (w && w != widget)
976 menuBar = w->findChild<QMenuBar *>();
978 // If we paint a menu bar draw underlines if is in the keyboardState
980 if (menuBar->d_func()->keyboardState || d->altDown())
982 // Otherwise draw underlines if the toplevel widget has seen an alt-press
984 #endif // QT_NO_MENUBAR
985 if (d->hasSeenAlt(widget)) {
992 #ifndef QT_NO_RUBBERBAND
993 case SH_RubberBand_Mask:
994 if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
996 if (rbOpt->shape == QRubberBand::Rectangle) {
998 if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData)) {
999 mask->region = opt->rect;
1001 if (widget && widget->isWindow())
1003 mask->region -= opt->rect.adjusted(size, size, -size, -size);
1008 #endif // QT_NO_RUBBERBAND
1009 case SH_LineEdit_PasswordCharacter:
1012 if (widget && (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) {
1013 const QFontMetrics &fm = widget->fontMetrics();
1014 if (fm.inFont(QChar(0x25CF)))
1016 else if (fm.inFont(QChar(0x2022)))
1024 #ifndef QT_NO_WIZARD
1025 case SH_WizardStyle:
1026 ret = QWizard::ModernStyle;
1029 case SH_ItemView_ArrowKeysNavigateIntoChildren:
1032 case SH_DialogButtonBox_ButtonsHaveIcons:
1036 ret = QCommonStyle::styleHint(hint, opt, widget, returnData);
1043 void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
1044 const QWidget *w) const
1046 // Used to restore across fallthrough cases. Currently only used in PE_IndicatorCheckBox
1047 bool doRestore = false;
1050 #ifndef QT_NO_TOOLBAR
1051 case PE_IndicatorToolBarSeparator:
1053 QRect rect = opt->rect;
1054 const int margin = 2;
1055 QPen oldPen = p->pen();
1056 if(opt->state & State_Horizontal){
1057 const int offset = rect.width()/2;
1058 p->setPen(QPen(opt->palette.dark().color()));
1059 p->drawLine(rect.bottomLeft().x() + offset,
1060 rect.bottomLeft().y() - margin,
1061 rect.topLeft().x() + offset,
1062 rect.topLeft().y() + margin);
1063 p->setPen(QPen(opt->palette.light().color()));
1064 p->drawLine(rect.bottomLeft().x() + offset + 1,
1065 rect.bottomLeft().y() - margin,
1066 rect.topLeft().x() + offset + 1,
1067 rect.topLeft().y() + margin);
1069 else{ //Draw vertical separator
1070 const int offset = rect.height()/2;
1071 p->setPen(QPen(opt->palette.dark().color()));
1072 p->drawLine(rect.topLeft().x() + margin ,
1073 rect.topLeft().y() + offset,
1074 rect.topRight().x() - margin,
1075 rect.topRight().y() + offset);
1076 p->setPen(QPen(opt->palette.light().color()));
1077 p->drawLine(rect.topLeft().x() + margin ,
1078 rect.topLeft().y() + offset + 1,
1079 rect.topRight().x() - margin,
1080 rect.topRight().y() + offset + 1);
1085 case PE_IndicatorToolBarHandle:
1087 p->translate(opt->rect.x(), opt->rect.y());
1088 if (opt->state & State_Horizontal) {
1089 int x = opt->rect.width() / 2 - 4;
1090 if (opt->direction == Qt::RightToLeft)
1092 if (opt->rect.height() > 4) {
1093 qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
1094 opt->palette, false, 1, 0);
1095 qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4,
1096 opt->palette, false, 1, 0);
1099 if (opt->rect.width() > 4) {
1100 int y = opt->rect.height() / 2 - 4;
1101 qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
1102 opt->palette, false, 1, 0);
1103 qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3,
1104 opt->palette, false, 1, 0);
1110 #endif // QT_NO_TOOLBAR
1111 case PE_FrameButtonTool:
1112 case PE_PanelButtonTool: {
1113 QPen oldPen = p->pen();
1114 #ifndef QT_NO_DOCKWIDGET
1115 if (w && w->inherits("QDockWidgetTitleButton")) {
1116 if (const QWidget *dw = w->parentWidget())
1117 if (dw->isWindow()){
1118 qDrawWinButton(p, opt->rect.adjusted(1, 1, 0, 0), opt->palette, opt->state & (State_Sunken | State_On),
1119 &opt->palette.button());
1124 #endif // QT_NO_DOCKWIDGET
1127 bool panel = (pe == PE_PanelButtonTool);
1128 if ((!(opt->state & State_Sunken ))
1129 && (!(opt->state & State_Enabled)
1130 || !(opt->state & State_MouseOver && opt->state & State_AutoRaise))
1131 && (opt->state & State_On)) {
1132 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1135 fill = opt->palette.brush(QPalette::Button);
1139 if (opt->state & (State_Raised | State_Sunken | State_On)) {
1140 if (opt->state & State_AutoRaise) {
1141 if(opt->state & (State_Enabled | State_Sunken | State_On)){
1143 qDrawShadePanel(p, opt->rect, opt->palette,
1144 opt->state & (State_Sunken | State_On), 1, &fill);
1146 qDrawShadeRect(p, opt->rect, opt->palette,
1147 opt->state & (State_Sunken | State_On), 1);
1150 p->setPen(opt->palette.button().color());
1151 p->drawRect(opt->rect.adjusted(1,1,-2,-2));
1154 qDrawWinButton(p, opt->rect, opt->palette,
1155 opt->state & (State_Sunken | State_On), panel ? &fill : 0);
1158 p->fillRect(opt->rect, fill);
1162 case PE_PanelButtonCommand:
1163 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1165 State flags = opt->state;
1166 QPalette pal = opt->palette;
1167 QRect r = opt->rect;
1168 if (! (flags & State_Sunken) && (flags & State_On))
1169 fill = QBrush(pal.light().color(), Qt::Dense4Pattern);
1171 fill = pal.brush(QPalette::Button);
1173 if (btn->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
1174 p->setPen(pal.dark().color());
1176 p->drawRect(r.adjusted(0, 0, -1, -1));
1177 } else if (flags & (State_Raised | State_On | State_Sunken)) {
1178 qDrawWinButton(p, r, pal, flags & (State_Sunken | State_On),
1181 p->fillRect(r, fill);
1185 case PE_FrameDefaultButton: {
1186 QPen oldPen = p->pen();
1187 p->setPen(opt->palette.shadow().color());
1188 QRect rect = opt->rect;
1189 rect.adjust(0, 0, -1, -1);
1194 case PE_IndicatorArrowUp:
1195 case PE_IndicatorArrowDown:
1196 case PE_IndicatorArrowRight:
1197 case PE_IndicatorArrowLeft:
1199 if (opt->rect.width() <= 1 || opt->rect.height() <= 1)
1201 QRect r = opt->rect;
1202 int size = qMin(r.height(), r.width());
1204 QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-")
1205 % QLatin1String(metaObject()->className()), opt, QSize(size, size))
1206 % HexString<uint>(pe);
1207 if (!QPixmapCache::find(pixmapName, pixmap)) {
1208 int border = size/5;
1209 int sqsize = 2*(size/2);
1210 QImage image(sqsize, sqsize, QImage::Format_ARGB32_Premultiplied);
1212 QPainter imagePainter(&image);
1216 case PE_IndicatorArrowUp:
1217 a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize - border, sqsize/2);
1219 case PE_IndicatorArrowDown:
1220 a.setPoints(3, border, sqsize/2, sqsize/2, sqsize - border, sqsize - border, sqsize/2);
1222 case PE_IndicatorArrowRight:
1223 a.setPoints(3, sqsize - border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
1225 case PE_IndicatorArrowLeft:
1226 a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
1235 if (opt->state & State_Sunken) {
1236 bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, w);
1237 bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, w);
1240 QRect bounds = a.boundingRect();
1241 int sx = sqsize / 2 - bounds.center().x() - 1;
1242 int sy = sqsize / 2 - bounds.center().y() - 1;
1243 imagePainter.translate(sx + bsx, sy + bsy);
1244 imagePainter.setPen(opt->palette.buttonText().color());
1245 imagePainter.setBrush(opt->palette.buttonText());
1247 if (!(opt->state & State_Enabled)) {
1248 imagePainter.translate(1, 1);
1249 imagePainter.setBrush(opt->palette.light().color());
1250 imagePainter.setPen(opt->palette.light().color());
1251 imagePainter.drawPolygon(a);
1252 imagePainter.translate(-1, -1);
1253 imagePainter.setBrush(opt->palette.mid().color());
1254 imagePainter.setPen(opt->palette.mid().color());
1257 imagePainter.drawPolygon(a);
1259 pixmap = QPixmap::fromImage(image);
1260 QPixmapCache::insert(pixmapName, pixmap);
1262 int xOffset = r.x() + (r.width() - size)/2;
1263 int yOffset = r.y() + (r.height() - size)/2;
1264 p->drawPixmap(xOffset, yOffset, pixmap);
1267 case PE_IndicatorCheckBox: {
1269 if (opt->state & State_NoChange)
1270 fill = QBrush(opt->palette.base().color(), Qt::Dense4Pattern);
1271 else if (opt->state & State_Sunken)
1272 fill = opt->palette.button();
1273 else if (opt->state & State_Enabled)
1274 fill = opt->palette.base();
1276 fill = opt->palette.background();
1279 qDrawWinPanel(p, opt->rect, opt->palette, true, &fill);
1280 if (opt->state & State_NoChange)
1281 p->setPen(opt->palette.dark().color());
1283 p->setPen(opt->palette.text().color());
1285 case PE_IndicatorViewItemCheck:
1290 if (pe == PE_IndicatorViewItemCheck) {
1291 const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt);
1292 p->setPen(itemViewOpt
1293 && itemViewOpt->showDecorationSelected
1294 && opt->state & State_Selected
1295 ? opt->palette.highlightedText().color()
1296 : opt->palette.text().color());
1297 if (opt->state & State_NoChange)
1298 p->setBrush(opt->palette.brush(QPalette::Button));
1299 p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, 11, 11);
1301 if (!(opt->state & State_Off)) {
1304 xx = opt->rect.x() + 3;
1305 yy = opt->rect.y() + 5;
1306 for (i = 0; i < 3; ++i) {
1307 lines[i] = QLineF(xx, yy, xx, yy + 2);
1312 for (i = 3; i < 7; ++i) {
1313 lines[i] = QLineF(xx, yy, xx, yy + 2);
1317 p->drawLines(lines, 7);
1322 case PE_FrameFocusRect:
1323 if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
1324 //### check for d->alt_down
1325 if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt))
1327 QRect r = opt->rect;
1329 p->setBackgroundMode(Qt::TransparentMode);
1330 QColor bg_col = fropt->backgroundColor;
1331 if (!bg_col.isValid())
1332 bg_col = p->background().color();
1333 // Create an "XOR" color.
1334 QColor patternCol((bg_col.red() ^ 0xff) & 0xff,
1335 (bg_col.green() ^ 0xff) & 0xff,
1336 (bg_col.blue() ^ 0xff) & 0xff);
1337 p->setBrush(QBrush(patternCol, Qt::Dense4Pattern));
1338 p->setBrushOrigin(r.topLeft());
1339 p->setPen(Qt::NoPen);
1340 p->drawRect(r.left(), r.top(), r.width(), 1); // Top
1341 p->drawRect(r.left(), r.bottom(), r.width(), 1); // Bottom
1342 p->drawRect(r.left(), r.top(), 1, r.height()); // Left
1343 p->drawRect(r.right(), r.top(), 1, r.height()); // Right
1347 case PE_IndicatorRadioButton:
1349 #define PTSARRLEN(x) sizeof(x)/(sizeof(QPoint))
1350 static const QPoint pts1[] = { // dark lines
1351 QPoint(1, 9), QPoint(1, 8), QPoint(0, 7), QPoint(0, 4), QPoint(1, 3), QPoint(1, 2),
1352 QPoint(2, 1), QPoint(3, 1), QPoint(4, 0), QPoint(7, 0), QPoint(8, 1), QPoint(9, 1)
1354 static const QPoint pts2[] = { // black lines
1355 QPoint(2, 8), QPoint(1, 7), QPoint(1, 4), QPoint(2, 3), QPoint(2, 2), QPoint(3, 2),
1356 QPoint(4, 1), QPoint(7, 1), QPoint(8, 2), QPoint(9, 2)
1358 static const QPoint pts3[] = { // background lines
1359 QPoint(2, 9), QPoint(3, 9), QPoint(4, 10), QPoint(7, 10), QPoint(8, 9), QPoint(9, 9),
1360 QPoint(9, 8), QPoint(10, 7), QPoint(10, 4), QPoint(9, 3)
1362 static const QPoint pts4[] = { // white lines
1363 QPoint(2, 10), QPoint(3, 10), QPoint(4, 11), QPoint(7, 11), QPoint(8, 10),
1364 QPoint(9, 10), QPoint(10, 9), QPoint(10, 8), QPoint(11, 7), QPoint(11, 4),
1365 QPoint(10, 3), QPoint(10, 2)
1367 static const QPoint pts5[] = { // inner fill
1368 QPoint(4, 2), QPoint(7, 2), QPoint(9, 4), QPoint(9, 7), QPoint(7, 9), QPoint(4, 9),
1369 QPoint(2, 7), QPoint(2, 4)
1372 // make sure the indicator is square
1373 QRect ir = opt->rect;
1375 if (opt->rect.width() < opt->rect.height()) {
1376 ir.setTop(opt->rect.top() + (opt->rect.height() - opt->rect.width()) / 2);
1377 ir.setHeight(opt->rect.width());
1378 } else if (opt->rect.height() < opt->rect.width()) {
1379 ir.setLeft(opt->rect.left() + (opt->rect.width() - opt->rect.height()) / 2);
1380 ir.setWidth(opt->rect.height());
1384 bool down = opt->state & State_Sunken;
1385 bool enabled = opt->state & State_Enabled;
1386 bool on = opt->state & State_On;
1389 //center when rect is larger than indicator size
1392 int indicatorWidth = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
1393 int indicatorHeight = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
1394 if (ir.width() > indicatorWidth)
1395 xOffset += (ir.width() - indicatorWidth)/2;
1396 if (ir.height() > indicatorHeight)
1397 yOffset += (ir.height() - indicatorHeight)/2;
1398 p->translate(xOffset, yOffset);
1400 p->translate(ir.x(), ir.y());
1402 p->setPen(opt->palette.dark().color());
1403 p->drawPolyline(pts1, PTSARRLEN(pts1));
1405 p->setPen(opt->palette.shadow().color());
1406 p->drawPolyline(pts2, PTSARRLEN(pts2));
1408 p->setPen(opt->palette.midlight().color());
1409 p->drawPolyline(pts3, PTSARRLEN(pts3));
1411 p->setPen(opt->palette.light().color());
1412 p->drawPolyline(pts4, PTSARRLEN(pts4));
1414 QColor fillColor = (down || !enabled)
1415 ? opt->palette.button().color()
1416 : opt->palette.base().color();
1417 p->setPen(fillColor);
1418 p->setBrush(fillColor) ;
1419 p->drawPolygon(pts5, PTSARRLEN(pts5));
1421 p->translate(-ir.x(), -ir.y()); // restore translate
1424 p->setPen(Qt::NoPen);
1425 p->setBrush(opt->palette.text());
1426 p->drawRect(ir.x() + 5, ir.y() + 4, 2, 4);
1427 p->drawRect(ir.x() + 4, ir.y() + 5, 4, 2);
1435 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
1436 if (frame->lineWidth == 2 || pe == PE_Frame) {
1437 QPalette popupPal = frame->palette;
1438 if (pe == PE_FrameMenu) {
1439 popupPal.setColor(QPalette::Light, frame->palette.background().color());
1440 popupPal.setColor(QPalette::Midlight, frame->palette.light().color());
1442 if (pe == PE_Frame && (frame->state & State_Raised))
1443 qDrawWinButton(p, frame->rect, popupPal, frame->state & State_Sunken);
1444 else if (pe == PE_Frame && (frame->state & State_Sunken))
1446 popupPal.setColor(QPalette::Midlight, frame->palette.background().color());
1447 qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
1450 qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
1452 QCommonStyle::drawPrimitive(pe, opt, p, w);
1455 QPalette popupPal = opt->palette;
1456 popupPal.setColor(QPalette::Light, opt->palette.background().color());
1457 popupPal.setColor(QPalette::Midlight, opt->palette.light().color());
1458 qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
1461 #endif // QT_NO_FRAME
1462 case PE_FrameButtonBevel:
1463 case PE_PanelButtonBevel: {
1465 bool panel = pe != PE_FrameButtonBevel;
1466 p->setBrushOrigin(opt->rect.topLeft());
1467 if (!(opt->state & State_Sunken) && (opt->state & State_On))
1468 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1470 fill = opt->palette.brush(QPalette::Button);
1472 if (opt->state & (State_Raised | State_On | State_Sunken)) {
1473 qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On),
1477 p->fillRect(opt->rect, fill);
1479 p->drawRect(opt->rect);
1482 case PE_FrameWindow: {
1483 QPalette popupPal = opt->palette;
1484 popupPal.setColor(QPalette::Light, opt->palette.background().color());
1485 popupPal.setColor(QPalette::Midlight, opt->palette.light().color());
1486 qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
1488 #ifndef QT_NO_DOCKWIDGET
1489 case PE_IndicatorDockWidgetResizeHandle:
1491 case PE_FrameDockWidget:
1492 if (qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
1493 proxy()->drawPrimitive(QStyle::PE_FrameWindow, opt, p, w);
1496 #endif // QT_NO_DOCKWIDGET
1498 case PE_FrameStatusBarItem:
1499 qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 0);
1502 case PE_IndicatorProgressChunk:
1504 bool vertical = false, inverted = false;
1505 if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
1506 vertical = (pb2->orientation == Qt::Vertical);
1507 inverted = pb2->invertedAppearance;
1511 int chunksize = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, w) - space;
1513 if (opt->rect.width() <= chunksize)
1517 p->fillRect(opt->rect.x() + space, opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
1518 opt->palette.brush(QPalette::Highlight));
1520 p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
1521 opt->palette.brush(QPalette::Highlight));
1523 if (opt->rect.height() <= chunksize)
1527 p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height() - space,
1528 opt->palette.brush(QPalette::Highlight));
1530 p->fillRect(opt->rect.x(), opt->rect.y() + space, opt->rect.width(), opt->rect.height() - space,
1531 opt->palette.brush(QPalette::Highlight));
1536 case PE_FrameTabWidget: {
1537 qDrawWinButton(p, opt->rect, opt->palette, false, 0);
1541 QCommonStyle::drawPrimitive(pe, opt, p, w);
1546 void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p,
1547 const QWidget *widget) const
1550 #ifndef QT_NO_RUBBERBAND
1552 if (qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
1553 // ### workaround for slow general painter path
1554 QPixmap tiledPixmap(16, 16);
1555 QPainter pixmapPainter(&tiledPixmap);
1556 pixmapPainter.setPen(Qt::NoPen);
1557 pixmapPainter.setBrush(Qt::Dense4Pattern);
1558 pixmapPainter.setBackground(Qt::white);
1559 pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
1560 pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
1561 pixmapPainter.end();
1562 tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
1564 QRect r = opt->rect;
1565 QStyleHintReturnMask mask;
1566 if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
1567 p->setClipRegion(mask.region);
1568 p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
1573 #endif // QT_NO_RUBBERBAND
1575 #if !defined(QT_NO_MENU) && !defined(QT_NO_MAINWINDOW)
1576 case CE_MenuBarEmptyArea:
1577 if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) {
1578 p->fillRect(opt->rect, opt->palette.button());
1579 QPen oldPen = p->pen();
1580 p->setPen(QPen(opt->palette.dark().color()));
1581 p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight());
1588 if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
1590 menuitem->rect.getRect(&x, &y, &w, &h);
1591 int tab = menuitem->tabWidth;
1592 bool dis = !(menuitem->state & State_Enabled);
1593 bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
1594 ? menuitem->checked : false;
1595 bool act = menuitem->state & State_Selected;
1597 // windows always has a check column, regardless whether we have an icon or not
1598 int checkcol = qMax<int>(menuitem->maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
1600 QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
1601 p->fillRect(menuitem->rect.adjusted(0, 0, -1, 0), fill);
1603 if (menuitem->menuItemType == QStyleOptionMenuItem::Separator){
1604 int yoff = y-1 + h / 2;
1605 p->setPen(menuitem->palette.dark().color());
1606 p->drawLine(x + 2, yoff, x + w - 4, yoff);
1607 p->setPen(menuitem->palette.light().color());
1608 p->drawLine(x + 2, yoff + 1, x + w - 4, yoff + 1);
1612 QRect vCheckRect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x(), menuitem->rect.y(), checkcol, menuitem->rect.height()));
1613 if (!menuitem->icon.isNull() && checked) {
1615 qDrawShadePanel(p, vCheckRect,
1616 menuitem->palette, true, 1,
1617 &menuitem->palette.brush(QPalette::Button));
1619 QBrush fill(menuitem->palette.light().color(), Qt::Dense4Pattern);
1620 qDrawShadePanel(p, vCheckRect, menuitem->palette, true, 1, &fill);
1623 p->fillRect(vCheckRect, menuitem->palette.brush(QPalette::Button));
1626 // On Windows Style, if we have a checkable item and an icon we
1627 // draw the icon recessed to indicate an item is checked. If we
1628 // have no icon, we draw a checkmark instead.
1629 if (!menuitem->icon.isNull()) {
1630 QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
1632 mode = QIcon::Active;
1635 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
1637 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
1638 int pixw = pixmap.width();
1639 int pixh = pixmap.height();
1640 if (act && !dis && !checked)
1641 qDrawShadePanel(p, vCheckRect, menuitem->palette, false, 1,
1642 &menuitem->palette.brush(QPalette::Button));
1643 QRect pmr(0, 0, pixw, pixh);
1644 pmr.moveCenter(vCheckRect.center());
1645 p->setPen(menuitem->palette.text().color());
1646 p->drawPixmap(pmr.topLeft(), pixmap);
1647 } else if (checked) {
1648 QStyleOptionMenuItem newMi = *menuitem;
1649 newMi.state = State_None;
1651 newMi.state |= State_Enabled;
1653 newMi.state |= State_On;
1654 newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + QWindowsStylePrivate::windowsItemFrame,
1655 menuitem->rect.y() + QWindowsStylePrivate::windowsItemFrame,
1656 checkcol - 2 * QWindowsStylePrivate::windowsItemFrame,
1657 menuitem->rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
1658 proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
1660 p->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color());
1664 discol = menuitem->palette.text().color();
1668 int xm = int(QWindowsStylePrivate::windowsItemFrame) + checkcol + int(QWindowsStylePrivate::windowsItemHMargin);
1669 int xpos = menuitem->rect.x() + xm;
1670 QRect textRect(xpos, y + QWindowsStylePrivate::windowsItemVMargin,
1671 w - xm - QWindowsStylePrivate::windowsRightBorder - tab + 1, h - 2 * QWindowsStylePrivate::windowsItemVMargin);
1672 QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
1673 QString s = menuitem->text;
1674 if (!s.isEmpty()) { // draw text
1676 int t = s.indexOf(QLatin1Char('\t'));
1677 int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
1678 if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
1679 text_flags |= Qt::TextHideMnemonic;
1680 text_flags |= Qt::AlignLeft;
1682 QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
1683 QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
1684 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1685 p->setPen(menuitem->palette.light().color());
1686 p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1));
1689 p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
1692 QFont font = menuitem->font;
1693 if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
1696 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1697 p->setPen(menuitem->palette.light().color());
1698 p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t));
1701 p->drawText(vTextRect, text_flags, s.left(t));
1704 if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
1705 int dim = (h - 2 * QWindowsStylePrivate::windowsItemFrame) / 2;
1706 PrimitiveElement arrow;
1707 arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
1708 xpos = x + w - QWindowsStylePrivate::windowsArrowHMargin - QWindowsStylePrivate::windowsItemFrame - dim;
1709 QRect vSubMenuRect = visualRect(opt->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
1710 QStyleOptionMenuItem newMI = *menuitem;
1711 newMI.rect = vSubMenuRect;
1712 newMI.state = dis ? State_None : State_Enabled;
1714 newMI.palette.setColor(QPalette::ButtonText,
1715 newMI.palette.highlightedText().color());
1716 proxy()->drawPrimitive(arrow, &newMI, p, widget);
1721 #endif // QT_NO_MENU
1722 #ifndef QT_NO_MENUBAR
1723 case CE_MenuBarItem:
1724 if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
1725 bool active = mbi->state & State_Selected;
1726 bool hasFocus = mbi->state & State_HasFocus;
1727 bool down = mbi->state & State_Sunken;
1728 QStyleOptionMenuItem newMbi = *mbi;
1729 p->fillRect(mbi->rect, mbi->palette.brush(QPalette::Button));
1730 if (active || hasFocus) {
1731 QBrush b = mbi->palette.brush(QPalette::Button);
1733 p->setBrushOrigin(p->brushOrigin() + QPoint(1, 1));
1734 if (active && hasFocus)
1735 qDrawShadeRect(p, mbi->rect.x(), mbi->rect.y(), mbi->rect.width(),
1736 mbi->rect.height(), mbi->palette, active && down, 1, 0, &b);
1737 if (active && down) {
1738 newMbi.rect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, mbi, widget),
1739 proxy()->pixelMetric(PM_ButtonShiftVertical, mbi, widget));
1740 p->setBrushOrigin(p->brushOrigin() - QPoint(1, 1));
1743 QCommonStyle::drawControl(ce, &newMbi, p, widget);
1746 #endif // QT_NO_MENUBAR
1747 #ifndef QT_NO_TABBAR
1748 case CE_TabBarTabShape:
1749 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
1750 bool rtlHorTabs = (tab->direction == Qt::RightToLeft
1751 && (tab->shape == QTabBar::RoundedNorth
1752 || tab->shape == QTabBar::RoundedSouth));
1753 bool selected = tab->state & State_Selected;
1754 bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
1756 && tab->position == QStyleOptionTab::Beginning));
1757 bool firstTab = ((!rtlHorTabs
1758 && tab->position == QStyleOptionTab::Beginning)
1760 && tab->position == QStyleOptionTab::End));
1761 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
1762 bool previousSelected =
1764 && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
1766 && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
1769 && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
1771 && tab->selectedPosition
1772 == QStyleOptionTab::PreviousIsSelected));
1773 int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
1774 bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
1776 && tabBarAlignment == Qt::AlignRight);
1778 bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
1780 && tabBarAlignment == Qt::AlignLeft);
1782 QColor light = tab->palette.light().color();
1783 QColor dark = tab->palette.dark().color();
1784 QColor shadow = tab->palette.shadow().color();
1785 int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
1787 borderThinkness /= 2;
1788 QRect r2(opt->rect);
1790 int x2 = r2.right();
1792 int y2 = r2.bottom();
1793 switch (tab->shape) {
1795 QCommonStyle::drawControl(ce, tab, p, widget);
1797 case QTabBar::RoundedNorth: {
1800 x1 += onlyOne || firstTab ? borderThinkness : 0;
1801 x2 -= onlyOne || lastTab ? borderThinkness : 0;
1804 p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 2), tab->palette.background());
1808 p->fillRect(QRect(x1,y2-1,x2-x1,1), tab->palette.background());
1809 p->fillRect(QRect(x1,y2,x2-x1,1), tab->palette.background());
1812 if (firstTab || selected || onlyOne || !previousSelected) {
1814 p->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
1815 p->drawPoint(x1 + 1, y1 + 1);
1819 int beg = x1 + (previousSelected ? 0 : 2);
1820 int end = x2 - (nextSelected ? 0 : 2);
1822 p->drawLine(beg, y1, end, y1);
1825 if (lastTab || selected || onlyOne || !nextSelected) {
1827 p->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1828 p->drawPoint(x2 - 1, y1 + 1);
1830 p->drawLine(x2 - 1, y1 + 2, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1833 case QTabBar::RoundedSouth: {
1836 x1 += firstTab ? borderThinkness : 0;
1837 x2 -= lastTab ? borderThinkness : 0;
1840 p->fillRect(QRect(x1 + 1, y1 + 2, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
1844 p->fillRect(QRect(x1, y1 + 1, (x2 - 1)-x1, 1), tab->palette.background());
1845 p->fillRect(QRect(x1, y1, (x2 - 1)-x1, 1), tab->palette.background());
1848 if (firstTab || selected || onlyOne || !previousSelected) {
1850 p->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
1851 p->drawPoint(x1 + 1, y2 - 1);
1855 int beg = x1 + (previousSelected ? 0 : 2);
1856 int end = x2 - (nextSelected ? 0 : 2);
1858 p->drawLine(beg, y2, end, y2);
1860 p->drawLine(beg, y2 - 1, end, y2 - 1);
1863 if (lastTab || selected || onlyOne || !nextSelected) {
1865 p->drawLine(x2, y2 - 2, x2, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1866 p->drawPoint(x2 - 1, y2 - 1);
1868 p->drawLine(x2 - 1, y2 - 2, x2 - 1, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1871 case QTabBar::RoundedWest: {
1874 y1 += firstTab ? borderThinkness : 0;
1875 y2 -= lastTab ? borderThinkness : 0;
1878 p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 2, (y2 - y1) - 1), tab->palette.background());
1882 p->fillRect(QRect(x2 - 1, y1, 1, y2-y1), tab->palette.background());
1883 p->fillRect(QRect(x2, y1, 1, y2-y1), tab->palette.background());
1886 if (firstTab || selected || onlyOne || !previousSelected) {
1888 p->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
1889 p->drawPoint(x1 + 1, y1 + 1);
1893 int beg = y1 + (previousSelected ? 0 : 2);
1894 int end = y2 - (nextSelected ? 0 : 2);
1896 p->drawLine(x1, beg, x1, end);
1899 if (lastTab || selected || onlyOne || !nextSelected) {
1901 p->drawLine(x1 + 3, y2, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
1902 p->drawPoint(x1 + 2, y2 - 1);
1904 p->drawLine(x1 + 3, y2 - 1, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
1905 p->drawPoint(x1 + 1, y2 - 1);
1906 p->drawPoint(x1 + 2, y2);
1909 case QTabBar::RoundedEast: {
1912 y1 += firstTab ? borderThinkness : 0;
1913 y2 -= lastTab ? borderThinkness : 0;
1916 p->fillRect(QRect(x1 + 2, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
1920 p->fillRect(QRect(x1 + 1, y1, 1, (y2 - 1)-y1),tab->palette.background());
1921 p->fillRect(QRect(x1, y1, 1, (y2-1)-y1), tab->palette.background());
1924 if (firstTab || selected || onlyOne || !previousSelected) {
1926 p->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
1927 p->drawPoint(x2 - 1, y1 + 1);
1931 int beg = y1 + (previousSelected ? 0 : 2);
1932 int end = y2 - (nextSelected ? 0 : 2);
1934 p->drawLine(x2, beg, x2, end);
1936 p->drawLine(x2 - 1, beg, x2 - 1, end);
1939 if (lastTab || selected || onlyOne || !nextSelected) {
1941 p->drawLine(x2 - 2, y2, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
1942 p->drawPoint(x2 - 1, y2 - 1);
1944 p->drawLine(x2 - 2, y2 - 1, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
1950 #endif // QT_NO_TABBAR
1951 case CE_ToolBoxTabShape:
1952 qDrawShadePanel(p, opt->rect, opt->palette,
1953 opt->state & (State_Sunken | State_On), 1,
1954 &opt->palette.brush(QPalette::Button));
1956 #ifndef QT_NO_SPLITTER
1958 p->eraseRect(opt->rect);
1960 #endif // QT_NO_SPLITTER
1961 #ifndef QT_NO_SCROLLBAR
1962 case CE_ScrollBarSubLine:
1963 case CE_ScrollBarAddLine: {
1964 if ((opt->state & State_Sunken)) {
1965 p->setPen(opt->palette.dark().color());
1966 p->setBrush(opt->palette.brush(QPalette::Button));
1967 p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
1969 QStyleOption buttonOpt = *opt;
1970 if (!(buttonOpt.state & State_Sunken))
1971 buttonOpt.state |= State_Raised;
1972 QPalette pal(opt->palette);
1973 pal.setColor(QPalette::Button, opt->palette.light().color());
1974 pal.setColor(QPalette::Light, opt->palette.button().color());
1975 qDrawWinButton(p, opt->rect, pal, opt->state & (State_Sunken | State_On),
1976 &opt->palette.brush(QPalette::Button));
1978 PrimitiveElement arrow;
1979 if (opt->state & State_Horizontal) {
1980 if (ce == CE_ScrollBarAddLine)
1981 arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft;
1983 arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
1985 if (ce == CE_ScrollBarAddLine)
1986 arrow = PE_IndicatorArrowDown;
1988 arrow = PE_IndicatorArrowUp;
1990 QStyleOption arrowOpt = *opt;
1991 arrowOpt.rect = opt->rect.adjusted(4, 4, -4, -4);
1992 proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
1994 case CE_ScrollBarAddPage:
1995 case CE_ScrollBarSubPage: {
1997 QBrush bg = p->background();
1998 Qt::BGMode bg_mode = p->backgroundMode();
1999 p->setPen(Qt::NoPen);
2000 p->setBackgroundMode(Qt::OpaqueMode);
2002 if (opt->state & State_Sunken) {
2003 br = QBrush(opt->palette.shadow().color(), Qt::Dense4Pattern);
2004 p->setBackground(opt->palette.dark().color());
2007 QPixmap pm = opt->palette.brush(QPalette::Light).texture();
2008 br = !pm.isNull() ? QBrush(pm) : QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
2009 p->setBackground(opt->palette.background().color());
2012 p->drawRect(opt->rect);
2013 p->setBackground(bg);
2014 p->setBackgroundMode(bg_mode);
2016 case CE_ScrollBarSlider:
2017 if (!(opt->state & State_Enabled)) {
2018 QPixmap pm = opt->palette.brush(QPalette::Light).texture();
2019 QBrush br = !pm.isNull() ? QBrush(pm) : QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
2020 p->setPen(Qt::NoPen);
2022 p->setBackgroundMode(Qt::OpaqueMode);
2023 p->drawRect(opt->rect);
2025 QStyleOptionButton buttonOpt;
2026 buttonOpt.QStyleOption::operator=(*opt);
2027 buttonOpt.state = State_Enabled | State_Raised;
2029 QPalette pal(opt->palette);
2030 pal.setColor(QPalette::Button, opt->palette.light().color());
2031 pal.setColor(QPalette::Light, opt->palette.button().color());
2032 qDrawWinButton(p, opt->rect, pal, false, &opt->palette.brush(QPalette::Button));
2035 #endif // QT_NO_SCROLLBAR
2036 case CE_HeaderSection: {
2038 if (opt->state & State_On)
2039 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
2041 fill = opt->palette.brush(QPalette::Button);
2043 if (opt->state & (State_Raised | State_Sunken)) {
2044 qDrawWinButton(p, opt->rect, opt->palette, opt->state & State_Sunken, &fill);
2046 p->fillRect(opt->rect, fill);
2049 #ifndef QT_NO_TOOLBAR
2051 if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
2052 // Reserve the beveled appearance only for mainwindow toolbars
2053 if (!(widget && qobject_cast<const QMainWindow*> (widget->parentWidget())))
2056 QRect rect = opt->rect;
2057 bool paintLeftBorder = true;
2058 bool paintRightBorder = true;
2059 bool paintBottomBorder = true;
2061 switch (toolbar->toolBarArea){
2062 case Qt::BottomToolBarArea :
2063 switch(toolbar->positionOfLine){
2064 case QStyleOptionToolBar::Beginning:
2065 case QStyleOptionToolBar::OnlyOne:
2066 paintBottomBorder = false;
2070 case Qt::TopToolBarArea :
2071 switch(toolbar->positionWithinLine){
2072 case QStyleOptionToolBar::Beginning:
2073 paintLeftBorder = false;
2075 case QStyleOptionToolBar::End:
2076 paintRightBorder = false;
2078 case QStyleOptionToolBar::OnlyOne:
2079 paintRightBorder = false;
2080 paintLeftBorder = false;
2084 if(opt->direction == Qt::RightToLeft){ //reverse layout changes the order of Beginning/end
2085 bool tmp = paintLeftBorder;
2086 paintRightBorder=paintLeftBorder;
2087 paintLeftBorder=tmp;
2090 case Qt::RightToolBarArea :
2091 switch (toolbar->positionOfLine){
2092 case QStyleOptionToolBar::Beginning:
2093 case QStyleOptionToolBar::OnlyOne:
2094 paintRightBorder = false;
2100 case Qt::LeftToolBarArea :
2101 switch (toolbar->positionOfLine){
2102 case QStyleOptionToolBar::Beginning:
2103 case QStyleOptionToolBar::OnlyOne:
2104 paintLeftBorder = false;
2116 p->setPen(QPen(opt->palette.light().color()));
2117 p->drawLine(rect.topLeft().x(),
2119 rect.topRight().x(),
2120 rect.topRight().y());
2122 if (paintLeftBorder){
2123 p->setPen(QPen(opt->palette.light().color()));
2124 p->drawLine(rect.topLeft().x(),
2126 rect.bottomLeft().x(),
2127 rect.bottomLeft().y());
2130 if (paintRightBorder){
2131 p->setPen(QPen(opt->palette.dark().color()));
2132 p->drawLine(rect.topRight().x(),
2133 rect.topRight().y(),
2134 rect.bottomRight().x(),
2135 rect.bottomRight().y());
2138 if (paintBottomBorder){
2139 p->setPen(QPen(opt->palette.dark().color()));
2140 p->drawLine(rect.bottomLeft().x(),
2141 rect.bottomLeft().y(),
2142 rect.bottomRight().x(),
2143 rect.bottomRight().y());
2149 #endif // QT_NO_TOOLBAR
2151 case CE_ProgressBarContents:
2152 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
2153 QRect rect = pb->rect;
2154 if (!rect.isValid())
2157 bool vertical = false;
2158 bool inverted = false;
2160 // Get extra style options if version 2
2161 const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt);
2163 vertical = (pb2->orientation == Qt::Vertical);
2164 inverted = pb2->invertedAppearance;
2168 rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height
2170 m.translate(0, -(rect.height() + rect.y()*2));
2172 QPalette pal2 = pb->palette;
2173 // Correct the highlight color if it is the same as the background
2174 if (pal2.highlight() == pal2.background())
2175 pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
2176 QPalette::Highlight));
2177 bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
2180 int w = rect.width();
2181 Q_D(const QWindowsStyle);
2182 if (pb->minimum == 0 && pb->maximum == 0) {
2183 const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget);
2184 QStyleOptionProgressBarV2 pbBits = *pb;
2185 Q_ASSERT(unit_width >0);
2188 pbBits.palette = pal2;
2191 int chunkCount = w / unit_width + 1;
2192 if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject)))
2193 step = (animation->animationStep() / 3) % chunkCount;
2195 d->startAnimation(new QProgressStyleAnimation(d->animationFps, opt->styleObject));
2196 int chunksInRow = 5;
2197 int myY = pbBits.rect.y();
2198 int myHeight = pbBits.rect.height();
2199 int chunksToDraw = chunksInRow;
2201 if(step > chunkCount - 5)chunksToDraw = (chunkCount - step);
2203 p->setClipRect(m.mapRect(QRectF(rect)).toRect());
2205 int x0 = reverse ? rect.left() + rect.width() - unit_width*(step) - unit_width : rect.left() + unit_width * step;
2208 for (int i = 0; i < chunksToDraw ; ++i) {
2209 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
2210 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
2211 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
2212 x += reverse ? -unit_width : unit_width;
2214 //Draw wrap-around chunks
2215 if( step > chunkCount-5){
2216 x0 = reverse ? rect.left() + rect.width() - unit_width : rect.left() ;
2218 int chunksToDraw = step - (chunkCount - chunksInRow);
2219 for (int i = 0; i < chunksToDraw ; ++i) {
2220 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
2221 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
2222 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
2223 x += reverse ? -unit_width : unit_width;
2226 p->restore(); //restore state
2229 d->stopAnimation(opt->styleObject);
2230 QCommonStyle::drawControl(ce, opt, p, widget);
2235 #ifndef QT_NO_DOCKWIDGET
2236 case CE_DockWidgetTitle:
2238 if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
2239 Q_D(const QWindowsStyle);
2241 const QStyleOptionDockWidgetV2 *v2
2242 = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
2243 bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
2245 QRect rect = dwOpt->rect;
2248 if (verticalTitleBar) {
2254 p->translate(r.left(), r.top() + r.width());
2256 p->translate(-r.left(), -r.top());
2259 bool floating = false;
2260 bool active = dwOpt->state & State_Active;
2261 QColor inactiveCaptionTextColor = d->inactiveCaptionText;
2262 if (dwOpt->movable) {
2266 if (widget && widget->isWindow()) {
2269 left = d->activeCaptionColor;
2270 right = d->activeGradientCaptionColor;
2272 left = d->inactiveCaptionColor;
2273 right = d->inactiveGradientCaptionColor;
2275 QBrush fillBrush(left);
2276 if (left != right) {
2277 QPoint p1(r.x(), r.top() + r.height()/2);
2278 QPoint p2(rect.right(), r.top() + r.height()/2);
2279 QLinearGradient lg(p1, p2);
2280 lg.setColorAt(0, left);
2281 lg.setColorAt(1, right);
2284 p->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
2287 if (!dwOpt->title.isEmpty()) {
2288 QFont oldFont = p->font();
2290 QFont font = oldFont;
2294 QPalette palette = dwOpt->palette;
2295 palette.setColor(QPalette::Window, inactiveCaptionTextColor);
2296 QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, opt, widget);
2297 if (verticalTitleBar) {
2298 titleRect = QRect(r.left() + rect.bottom()
2299 - titleRect.bottom(),
2300 r.top() + titleRect.left() - rect.left(),
2301 titleRect.height(), titleRect.width());
2303 proxy()->drawItemText(p, titleRect,
2304 Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, palette,
2305 dwOpt->state & State_Enabled, dwOpt->title,
2306 floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText);
2307 p->setFont(oldFont);
2309 if (verticalTitleBar)
2313 #endif // QT_NO_DOCKWIDGET
2315 QCommonStyle::drawControl(ce, opt, p, widget);
2320 QRect QWindowsStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const
2324 case SE_SliderFocusRect:
2325 case SE_ToolBoxTabContents:
2326 r = visualRect(opt->direction, opt->rect, opt->rect);
2328 case SE_DockWidgetTitleBarText: {
2329 r = QCommonStyle::subElementRect(sr, opt, w);
2330 const QStyleOptionDockWidgetV2 *v2
2331 = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
2332 bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
2333 int m = proxy()->pixelMetric(PM_DockWidgetTitleMargin, opt, w);
2334 if (verticalTitleBar) {
2335 r.adjust(0, 0, 0, -m);
2337 if (opt->direction == Qt::LeftToRight)
2338 r.adjust(m, 0, 0, 0);
2340 r.adjust(0, 0, -m, 0);
2344 case SE_ProgressBarContents:
2345 r = QCommonStyle::subElementRect(SE_ProgressBarGroove, opt, w);
2346 r.adjust(3, 3, -3, -3);
2349 r = QCommonStyle::subElementRect(sr, opt, w);
2356 void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
2357 QPainter *p, const QWidget *widget) const
2360 #ifndef QT_NO_SLIDER
2362 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
2363 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
2364 int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
2365 int ticks = slider->tickPosition;
2366 QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
2367 QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
2369 if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
2370 int mid = thickness / 2;
2372 if (ticks & QSlider::TicksAbove)
2374 if (ticks & QSlider::TicksBelow)
2377 p->setPen(slider->palette.shadow().color());
2378 if (slider->orientation == Qt::Horizontal) {
2379 qDrawWinPanel(p, groove.x(), groove.y() + mid - 2,
2380 groove.width(), 4, slider->palette, true);
2381 p->drawLine(groove.x() + 1, groove.y() + mid - 1,
2382 groove.x() + groove.width() - 3, groove.y() + mid - 1);
2384 qDrawWinPanel(p, groove.x() + mid - 2, groove.y(),
2385 4, groove.height(), slider->palette, true);
2386 p->drawLine(groove.x() + mid - 1, groove.y() + 1,
2387 groove.x() + mid - 1, groove.y() + groove.height() - 3);
2391 if (slider->subControls & SC_SliderTickmarks) {
2392 QStyleOptionSlider tmpSlider = *slider;
2393 tmpSlider.subControls = SC_SliderTickmarks;
2394 QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
2397 if (slider->subControls & SC_SliderHandle) {
2407 const QColor c0 = slider->palette.shadow().color();
2408 const QColor c1 = slider->palette.dark().color();
2409 // const QColor c2 = g.button();
2410 const QColor c3 = slider->palette.midlight().color();
2411 const QColor c4 = slider->palette.light().color();
2414 if (slider->state & State_Enabled) {
2415 handleBrush = slider->palette.color(QPalette::Button);
2417 handleBrush = QBrush(slider->palette.color(QPalette::Button),
2422 int x = handle.x(), y = handle.y(),
2423 wi = handle.width(), he = handle.height();
2430 Qt::Orientation orient = slider->orientation;
2431 bool tickAbove = slider->tickPosition == QSlider::TicksAbove;
2432 bool tickBelow = slider->tickPosition == QSlider::TicksBelow;
2434 if (slider->state & State_HasFocus) {
2435 QStyleOptionFocusRect fropt;
2436 fropt.QStyleOption::operator=(*slider);
2437 fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
2438 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
2441 if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
2442 Qt::BGMode oldMode = p->backgroundMode();
2443 p->setBackgroundMode(Qt::OpaqueMode);
2444 qDrawWinButton(p, QRect(x, y, wi, he), slider->palette, false,
2446 p->setBackgroundMode(oldMode);
2450 QSliderDirection dir;
2452 if (orient == Qt::Horizontal)
2469 d = (wi + 1) / 2 - 1;
2470 a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d);
2474 d = (wi + 1) / 2 - 1;
2475 a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1);
2478 d = (he + 1) / 2 - 1;
2480 a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
2483 d = (he + 1) / 2 - 1;
2485 a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1);
2489 QBrush oldBrush = p->brush();
2490 p->setPen(Qt::NoPen);
2491 p->setBrush(handleBrush);
2492 Qt::BGMode oldMode = p->backgroundMode();
2493 p->setBackgroundMode(Qt::OpaqueMode);
2494 p->drawRect(x1, y1, x2-x1+1, y2-y1+1);
2496 p->setBrush(oldBrush);
2497 p->setBackgroundMode(oldMode);
2501 p->drawLine(x1, y1, x2, y1);
2503 p->drawLine(x1, y1+1, x2, y1+1);
2505 if (dir != SlLeft) {
2507 p->drawLine(x1+1, y1+1, x1+1, y2);
2509 p->drawLine(x1, y1, x1, y2);
2511 if (dir != SlRight) {
2513 p->drawLine(x2, y1, x2, y2);
2515 p->drawLine(x2-1, y1+1, x2-1, y2-1);
2517 if (dir != SlDown) {
2519 p->drawLine(x1, y2, x2, y2);
2521 p->drawLine(x1+1, y2-1, x2-1, y2-1);
2527 p->drawLine(x1, y1, x1+d, y1-d);
2530 p->drawLine(x2, y1, x2-d, y1-d);
2533 p->drawLine(x1+1, y1, x1+1+d, y1-d);
2535 p->drawLine(x2-1, y1, x2-1-d, y1-d);
2539 p->drawLine(x1, y2, x1+d, y2+d);
2542 p->drawLine(x2, y2, x2-d, y2+d);
2545 p->drawLine(x1+1, y2, x1+1+d, y2+d);
2547 p->drawLine(x2-1, y2, x2-1-d, y2+d);
2551 p->drawLine(x1, y1, x1-d, y1+d);
2554 p->drawLine(x1, y2, x1-d, y2-d);
2557 p->drawLine(x1, y1+1, x1-d, y1+1+d);
2559 p->drawLine(x1, y2-1, x1-d, y2-1-d);
2563 p->drawLine(x2, y1, x2+d, y1+d);
2566 p->drawLine(x2, y2, x2+d, y2-d);
2569 p->drawLine(x2, y1+1, x2+d, y1+1+d);
2571 p->drawLine(x2, y2-1, x2+d, y2-1-d);
2577 #endif // QT_NO_SLIDER
2578 #ifndef QT_NO_SCROLLBAR
2580 if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
2581 QStyleOptionSlider newScrollbar = *scrollbar;
2582 if (scrollbar->minimum == scrollbar->maximum)
2583 newScrollbar.state &= ~State_Enabled; //do not draw the slider.
2584 QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
2587 #endif // QT_NO_SCROLLBAR
2588 #ifndef QT_NO_COMBOBOX
2590 if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
2591 QBrush editBrush = cmb->palette.brush(QPalette::Base);
2592 if ((cmb->subControls & SC_ComboBoxFrame)) {
2594 QPalette shadePal = opt->palette;
2595 shadePal.setColor(QPalette::Midlight, shadePal.button().color());
2596 qDrawWinPanel(p, opt->rect, shadePal, true, &editBrush);
2599 p->fillRect(opt->rect, editBrush);
2602 if (cmb->subControls & SC_ComboBoxArrow) {
2603 State flags = State_None;
2605 QRect ar = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
2606 bool sunkenArrow = cmb->activeSubControls == SC_ComboBoxArrow
2607 && cmb->state & State_Sunken;
2609 p->setPen(cmb->palette.dark().color());
2610 p->setBrush(cmb->palette.brush(QPalette::Button));
2611 p->drawRect(ar.adjusted(0,0,-1,-1));
2613 // Make qDrawWinButton use the right colors for drawing the shade of the button
2614 QPalette pal(cmb->palette);
2615 pal.setColor(QPalette::Button, cmb->palette.light().color());
2616 pal.setColor(QPalette::Light, cmb->palette.button().color());
2617 qDrawWinButton(p, ar, pal, false,
2618 &cmb->palette.brush(QPalette::Button));
2621 ar.adjust(2, 2, -2, -2);
2622 if (opt->state & State_Enabled)
2623 flags |= State_Enabled;
2624 if (opt->state & State_HasFocus)
2625 flags |= State_HasFocus;
2628 flags |= State_Sunken;
2629 QStyleOption arrowOpt(0);
2630 arrowOpt.rect = ar.adjusted(1, 1, -1, -1);
2631 arrowOpt.palette = cmb->palette;
2632 arrowOpt.state = flags;
2633 proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
2636 if (cmb->subControls & SC_ComboBoxEditField) {
2637 QRect re = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
2638 if (cmb->state & State_HasFocus && !cmb->editable)
2639 p->fillRect(re.x(), re.y(), re.width(), re.height(),
2640 cmb->palette.brush(QPalette::Highlight));
2642 if (cmb->state & State_HasFocus) {
2643 p->setPen(cmb->palette.highlightedText().color());
2644 p->setBackground(cmb->palette.highlight());
2647 p->setPen(cmb->palette.text().color());
2648 p->setBackground(cmb->palette.background());
2651 if (cmb->state & State_HasFocus && !cmb->editable) {
2652 QStyleOptionFocusRect focus;
2653 focus.QStyleOption::operator=(*cmb);
2654 focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget);
2655 focus.state |= State_FocusAtBorder;
2656 focus.backgroundColor = cmb->palette.highlight().color();
2657 proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
2662 #endif // QT_NO_COMBOBOX
2663 #ifndef QT_NO_SPINBOX
2665 if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
2666 QStyleOptionSpinBox copy = *sb;
2667 PrimitiveElement pe;
2668 bool enabled = opt->state & State_Enabled;
2669 if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
2670 QBrush editBrush = sb->palette.brush(QPalette::Base);
2671 QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);
2672 QPalette shadePal = sb->palette;
2673 shadePal.setColor(QPalette::Midlight, shadePal.button().color());
2674 qDrawWinPanel(p, r, shadePal, true, &editBrush);
2677 QPalette shadePal(opt->palette);
2678 shadePal.setColor(QPalette::Button, opt->palette.light().color());
2679 shadePal.setColor(QPalette::Light, opt->palette.button().color());
2681 if (sb->subControls & SC_SpinBoxUp) {
2682 copy.subControls = SC_SpinBoxUp;
2683 QPalette pal2 = sb->palette;
2684 if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
2685 pal2.setCurrentColorGroup(QPalette::Disabled);
2686 copy.state &= ~State_Enabled;
2689 copy.palette = pal2;
2691 if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
2692 copy.state |= State_On;
2693 copy.state |= State_Sunken;
2695 copy.state |= State_Raised;
2696 copy.state &= ~State_Sunken;
2698 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
2699 : PE_IndicatorSpinUp);
2701 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);
2702 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
2703 ©.palette.brush(QPalette::Button));
2704 copy.rect.adjust(4, 1, -5, -1);
2705 if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled))
2706 && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
2708 QStyleOptionSpinBox lightCopy = copy;
2709 lightCopy.rect.adjust(1, 1, 1, 1);
2710 lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
2711 proxy()->drawPrimitive(pe, &lightCopy, p, widget);
2713 proxy()->drawPrimitive(pe, ©, p, widget);
2716 if (sb->subControls & SC_SpinBoxDown) {
2717 copy.subControls = SC_SpinBoxDown;
2718 copy.state = sb->state;
2719 QPalette pal2 = sb->palette;
2720 if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
2721 pal2.setCurrentColorGroup(QPalette::Disabled);
2722 copy.state &= ~State_Enabled;
2724 copy.palette = pal2;
2726 if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
2727 copy.state |= State_On;
2728 copy.state |= State_Sunken;
2730 copy.state |= State_Raised;
2731 copy.state &= ~State_Sunken;
2733 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
2734 : PE_IndicatorSpinDown);
2736 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
2737 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
2738 ©.palette.brush(QPalette::Button));
2739 copy.rect.adjust(4, 0, -5, -1);
2740 if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled))
2741 && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
2743 QStyleOptionSpinBox lightCopy = copy;
2744 lightCopy.rect.adjust(1, 1, 1, 1);
2745 lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
2746 proxy()->drawPrimitive(pe, &lightCopy, p, widget);
2748 proxy()->drawPrimitive(pe, ©, p, widget);
2752 #endif // QT_NO_SPINBOX
2755 QCommonStyle::drawComplexControl(cc, opt, p, widget);
2760 QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
2761 const QSize &csz, const QWidget *widget) const
2766 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2767 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
2771 if (btn->features & QStyleOptionButton::AutoDefaultButton)
2772 defwidth = 2 * proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget);
2773 int minwidth = int(QStyleHelper::dpiScaled(75.));
2774 int minheight = int(QStyleHelper::dpiScaled(23.));
2776 #ifndef QT_QWS_SMALL_PUSHBUTTON
2777 if (w < minwidth + defwidth && !btn->text.isEmpty())
2778 w = minwidth + defwidth;
2779 if (h < minheight + defwidth)
2780 h = minheight + defwidth;
2787 if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
2789 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
2791 if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
2792 sz = QSize(10, QWindowsStylePrivate::windowsSepHeight);
2794 else if (mi->icon.isNull()) {
2795 sz.setHeight(sz.height() - 2);
2799 if (mi->menuItemType != QStyleOptionMenuItem::Separator && !mi->icon.isNull()) {
2800 int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
2801 sz.setHeight(qMax(sz.height(),
2802 mi->icon.actualSize(QSize(iconExtent, iconExtent)).height()
2803 + 2 * QWindowsStylePrivate::windowsItemFrame));
2805 int maxpmw = mi->maxIconWidth;
2806 int tabSpacing = 20;
2807 if (mi->text.contains(QLatin1Char('\t')))
2809 else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
2810 w += 2 * QWindowsStylePrivate::windowsArrowHMargin;
2811 else if (mi->menuItemType == QStyleOptionMenuItem::DefaultItem) {
2812 // adjust the font and add the difference in size.
2813 // it would be better if the font could be adjusted in the initStyleOption qmenu func!!
2814 QFontMetrics fm(mi->font);
2815 QFont fontBold = mi->font;
2816 fontBold.setBold(true);
2817 QFontMetrics fmBold(fontBold);
2818 w += fmBold.width(mi->text) - fm.width(mi->text);
2821 int checkcol = qMax<int>(maxpmw, QWindowsStylePrivate::windowsCheckMarkWidth); // Windows always shows a check column
2823 w += int(QWindowsStylePrivate::windowsRightBorder) + 10;
2827 #endif // QT_NO_MENU
2828 #ifndef QT_NO_MENUBAR
2829 case CT_MenuBarItem:
2831 sz += QSize(QWindowsStylePrivate::windowsItemHMargin * 4, QWindowsStylePrivate::windowsItemVMargin * 2);
2834 // Otherwise, fall through
2836 if (qstyleoption_cast<const QStyleOptionToolButton *>(opt))
2837 return sz += QSize(7, 6);
2838 // Otherwise, fall through
2841 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
2849 QIcon QWindowsStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option,
2850 const QWidget *widget) const
2855 switch (standardIcon) {
2856 case SP_DriveCDIcon:
2857 case SP_DriveDVDIcon:
2858 case SP_DriveNetIcon:
2859 case SP_DriveHDIcon:
2860 case SP_DriveFDIcon:
2862 case SP_FileLinkIcon:
2863 case SP_DesktopIcon:
2864 case SP_ComputerIcon:
2865 if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
2866 QPlatformTheme::StandardPixmap sp = static_cast<QPlatformTheme::StandardPixmap>(standardIcon);
2867 for (int size = 16 ; size <= 32 ; size += 16) {
2868 pixmap = theme->standardPixmap(sp, QSizeF(size, size));
2869 icon.addPixmap(pixmap, QIcon::Normal);
2874 case SP_DirLinkIcon:
2875 if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
2876 QPlatformTheme::StandardPixmap spOff = static_cast<QPlatformTheme::StandardPixmap>(standardIcon);
2877 QPlatformTheme::StandardPixmap spOn = standardIcon == SP_DirIcon ? QPlatformTheme::DirOpenIcon :
2878 QPlatformTheme::DirLinkOpenIcon;
2879 for (int size = 16 ; size <= 32 ; size += 16) {
2880 QSizeF pixSize(size, size);
2881 pixmap = theme->standardPixmap(spOff, pixSize);
2882 icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
2883 pixmap = theme->standardPixmap(spOn, pixSize);
2884 icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
2888 case SP_VistaShield:
2889 if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
2890 QPlatformTheme::StandardPixmap sp = static_cast<QPlatformTheme::StandardPixmap>(standardIcon);
2891 pixmap = theme->standardPixmap(sp, QSizeF(32, 32));
2900 icon = QCommonStyle::standardIcon(standardIcon, option, widget);
2908 #endif // QT_NO_STYLE_WINDOWS