Changeset 561 for trunk/src/gui/styles/qwindowsstyle.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/styles/qwindowsstyle.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 42 42 #include "qwindowsstyle.h" 43 43 #include "qwindowsstyle_p.h" 44 #include <private/q pixmapdata_p.h>44 #include <private/qstylehelper_p.h> 45 45 46 46 #if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN) … … 68 68 #include "qwizard.h" 69 69 #include "qlistview.h" 70 #include <private/qmath_p.h> 71 #include <qmath.h> 72 70 73 71 74 #ifdef Q_WS_X11 … … 112 115 #include <limits.h> 113 116 QT_END_INCLUDE_NAMESPACE 114 115 static const int windowsItemFrame = 2; // menu item frame width116 static const int windowsSepHeight = 9; // separator item height117 static const int windowsItemHMargin = 3; // menu item hor text margin118 static const int windowsItemVMargin = 2; // menu item ver text margin119 static const int windowsArrowHMargin = 6; // arrow horizontal margin120 static const int windowsTabSpacing = 12; // space between text and tab121 static const int windowsCheckMarkHMargin = 2; // horiz. margins of check mark122 static const int windowsRightBorder = 15; // right border on windows123 static const int windowsCheckMarkWidth = 12; // checkmarks width on windows124 125 static bool use2000style = true;126 117 127 118 enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight }; … … 223 214 case QEvent::Show: 224 215 if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) { 225 d->bars << bar; 226 if (d->bars.size() == 1) { 227 Q_ASSERT(d->animationFps> 0); 228 d->animateTimer = startTimer(1000 / d->animationFps); 216 if (!d->bars.contains(bar)) { 217 d->bars << bar; 218 if (d->bars.size() == 1) { 219 Q_ASSERT(d->animationFps> 0); 220 d->animateTimer = startTimer(1000 / d->animationFps); 221 } 229 222 } 230 223 } … … 266 259 QWindowsStyle::QWindowsStyle() : QCommonStyle(*new QWindowsStylePrivate) 267 260 { 268 #if defined(Q_OS_WIN32)269 use2000style = QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95;270 #endif271 261 } 272 262 … … 278 268 QWindowsStyle::QWindowsStyle(QWindowsStylePrivate &dd) : QCommonStyle(dd) 279 269 { 280 #if defined(Q_OS_WIN32)281 use2000style = QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95;282 #endif283 270 } 284 271 … … 302 289 QWindowsStylePrivate *d = const_cast<QWindowsStylePrivate*>(d_func()); 303 290 // We only need the overhead when shortcuts are sometimes hidden 304 if (! styleHint(SH_UnderlineShortcut, 0) && app)291 if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app) 305 292 app->installEventFilter(this); 306 293 … … 403 390 #ifndef QT_NO_SLIDER 404 391 case PM_SliderLength: 405 ret = 11;392 ret = int(QStyleHelper::dpiScaled(11.)); 406 393 break; 407 394 … … 425 412 int thick = 6; // Magic constant to get 5 + 16 + 5 426 413 if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks) 427 thick += p ixelMetric(PM_SliderLength, sl, widget) / 4;414 thick += proxy()->pixelMetric(PM_SliderLength, sl, widget) / 4; 428 415 429 416 space -= thick; … … 451 438 452 439 case PM_SmallIconSize: 453 ret = 16;440 ret = int(QStyleHelper::dpiScaled(16.)); 454 441 break; 455 442 456 443 case PM_LargeIconSize: 457 ret = 32;444 ret = int(QStyleHelper::dpiScaled(32.)); 458 445 break; 459 446 460 447 case PM_IconViewIconSize: 461 ret = pixelMetric(PM_LargeIconSize, opt, widget); 462 break; 463 464 case PM_ToolBarIconSize: 465 ret = 24; 466 break; 448 ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget); 449 break; 450 467 451 case PM_DockWidgetTitleMargin: 468 ret = 2;452 ret = int(QStyleHelper::dpiScaled(2.)); 469 453 break; 470 454 case PM_DockWidgetTitleBarButtonMargin: 471 ret = 4;455 ret = int(QStyleHelper::dpiScaled(4.)); 472 456 break; 473 457 #if defined(Q_WS_WIN) … … 551 535 break; 552 536 case PM_ToolBarHandleExtent: 553 ret = 10;537 ret = int(QStyleHelper::dpiScaled(10.)); 554 538 break; 555 539 default: … … 934 918 #endif //QT_NO_IMAGEFORMAT_XPM 935 919 920 #ifdef Q_OS_WIN 921 static QPixmap loadIconFromShell32( int resourceId, int size ) 922 { 923 #ifdef Q_OS_WINCE 924 HMODULE hmod = LoadLibrary(L"ceshell.dll"); 925 #else 926 HMODULE hmod = LoadLibrary(L"shell32.dll"); 927 #endif 928 if( hmod ) { 929 HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size, size, 0); 930 if( iconHandle ) { 931 QPixmap iconpixmap = QPixmap::fromWinHICON( iconHandle ); 932 DestroyIcon(iconHandle); 933 return iconpixmap; 934 } 935 } 936 return QPixmap(); 937 } 938 #endif 939 936 940 /*! 937 941 \reimp … … 1023 1027 { 1024 1028 HICON iconHandle = LoadIcon(NULL, IDI_INFORMATION); 1025 desktopIcon = convertHIconToPixmap( iconHandle );1029 desktopIcon = QPixmap::fromWinHICON( iconHandle ); 1026 1030 DestroyIcon(iconHandle); 1027 1031 break; … … 1030 1034 { 1031 1035 HICON iconHandle = LoadIcon(NULL, IDI_WARNING); 1032 desktopIcon = convertHIconToPixmap( iconHandle );1036 desktopIcon = QPixmap::fromWinHICON( iconHandle ); 1033 1037 DestroyIcon(iconHandle); 1034 1038 break; … … 1037 1041 { 1038 1042 HICON iconHandle = LoadIcon(NULL, IDI_ERROR); 1039 desktopIcon = convertHIconToPixmap( iconHandle );1043 desktopIcon = QPixmap::fromWinHICON( iconHandle ); 1040 1044 DestroyIcon(iconHandle); 1041 1045 break; … … 1044 1048 { 1045 1049 HICON iconHandle = LoadIcon(NULL, IDI_QUESTION); 1046 desktopIcon = convertHIconToPixmap( iconHandle );1050 desktopIcon = QPixmap::fromWinHICON( iconHandle ); 1047 1051 DestroyIcon(iconHandle); 1048 1052 break; … … 1059 1063 iconInfo.cbSize = sizeof(iconInfo); 1060 1064 if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_SMALLICON, &iconInfo) == S_OK) { 1061 pixmap = convertHIconToPixmap(iconInfo.hIcon);1065 pixmap = QPixmap::fromWinHICON(iconInfo.hIcon); 1062 1066 DestroyIcon(iconInfo.hIcon); 1063 1067 return pixmap; … … 1065 1069 } 1066 1070 } 1071 break; 1072 default: 1067 1073 break; 1068 1074 } … … 1134 1140 break; 1135 1141 case SH_ItemView_ChangeHighlightOnFocus: 1136 #if defined(Q_WS_WIN) 1137 if (QSysInfo::WindowsVersion != QSysInfo::WV_95 && QSysInfo::WindowsVersion != QSysInfo::WV_NT) 1138 ret = 1; 1139 else 1140 #endif 1141 ret = 0; 1142 ret = 1; 1142 1143 break; 1143 1144 case SH_ToolBox_SelectedPageTitleBold: … … 1147 1148 #if defined(Q_WS_WIN) 1148 1149 case SH_UnderlineShortcut: 1150 { 1149 1151 ret = 1; 1150 if (QSysInfo::WindowsVersion != QSysInfo::WV_95 1151 && QSysInfo::WindowsVersion != QSysInfo::WV_98 1152 && QSysInfo::WindowsVersion != QSysInfo::WV_NT) { 1153 BOOL cues; 1154 SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0); 1155 ret = int(cues); 1156 // Do nothing if we always paint underlines 1157 Q_D(const QWindowsStyle); 1158 if (!ret && widget && d) { 1152 BOOL cues = false; 1153 SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0); 1154 ret = int(cues); 1155 // Do nothing if we always paint underlines 1156 Q_D(const QWindowsStyle); 1157 if (!ret && widget && d) { 1159 1158 #ifndef QT_NO_MENUBAR 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1159 const QMenuBar *menuBar = qobject_cast<const QMenuBar *>(widget); 1160 if (!menuBar && qobject_cast<const QMenu *>(widget)) { 1161 QWidget *w = QApplication::activeWindow(); 1162 if (w && w != widget) 1163 menuBar = qFindChild<QMenuBar *>(w); 1164 } 1165 // If we paint a menu bar draw underlines if is in the keyboardState 1166 if (menuBar) { 1167 if (menuBar->d_func()->keyboardState || d->altDown()) 1168 ret = 1; 1169 // Otherwise draw underlines if the toplevel widget has seen an alt-press 1170 } else 1172 1171 #endif // QT_NO_MENUBAR 1173 1174 1175 1176 1177 }1178 break;1172 if (d->hasSeenAlt(widget)) { 1173 ret = 1; 1174 } 1175 } 1176 break; 1177 } 1179 1178 #endif 1180 1179 #ifndef QT_NO_RUBBERBAND … … 1217 1216 case SH_ItemView_ArrowKeysNavigateIntoChildren: 1218 1217 ret = true; 1218 break; 1219 case SH_DialogButtonBox_ButtonsHaveIcons: 1220 ret = 0; 1219 1221 break; 1220 1222 default: … … 1273 1275 if (opt->state & State_Horizontal) { 1274 1276 int x = opt->rect.width() / 2 - 4; 1275 if ( QApplication::layoutDirection()== Qt::RightToLeft)1277 if (opt->direction == Qt::RightToLeft) 1276 1278 x -= 2; 1277 1279 if (opt->rect.height() > 4) { … … 1314 1316 && (!(opt->state & State_Enabled) 1315 1317 || !(opt->state & State_MouseOver && opt->state & State_AutoRaise)) 1316 && (opt->state & State_On) && use2000style) {1318 && (opt->state & State_On)) { 1317 1319 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern); 1318 1320 stippled = true; … … 1387 1389 int size = qMin(r.height(), r.width()); 1388 1390 QPixmap pixmap; 1389 QString pixmapName; 1390 pixmapName.sprintf("%s-%s-%d-%d-%d-%lld", 1391 "$qt_ia", metaObject()->className(), 1392 uint(opt->state), pe, 1393 size, opt->palette.cacheKey()); 1391 QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-") + QLatin1String(metaObject()->className()), opt, QSize(size, size)) 1392 + QLatin1Char('-') + QString::number(pe); 1394 1393 if (!QPixmapCache::find(pixmapName, pixmap)) { 1395 1394 int border = size/5; … … 1421 1420 1422 1421 if (opt->state & State_Sunken) { 1423 bsx = p ixelMetric(PM_ButtonShiftHorizontal, opt, w);1424 bsy = p ixelMetric(PM_ButtonShiftVertical, opt, w);1422 bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, w); 1423 bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, w); 1425 1424 } 1426 1425 … … 1511 1510 if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) { 1512 1511 //### check for d->alt_down 1513 if (!(fropt->state & State_KeyboardFocusChange) && ! styleHint(SH_UnderlineShortcut, opt))1512 if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt)) 1514 1513 return; 1515 1514 QRect r = opt->rect; … … 1578 1577 int xOffset = 0; 1579 1578 int yOffset = 0; 1580 int indicatorWidth = p ixelMetric(PM_ExclusiveIndicatorWidth);1581 int indicatorHeight = p ixelMetric(PM_ExclusiveIndicatorWidth);1579 int indicatorWidth = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth); 1580 int indicatorHeight = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth); 1582 1581 if (ir.width() > indicatorWidth) 1583 1582 xOffset += (ir.width() - indicatorWidth)/2; … … 1628 1627 popupPal.setColor(QPalette::Midlight, frame->palette.light().color()); 1629 1628 } 1630 if ( use2000style &&pe == PE_Frame && (frame->state & State_Raised))1629 if (pe == PE_Frame && (frame->state & State_Raised)) 1631 1630 qDrawWinButton(p, frame->rect, popupPal, frame->state & State_Sunken); 1632 else if ( use2000style &&pe == PE_Frame && (frame->state & State_Sunken))1631 else if (pe == PE_Frame && (frame->state & State_Sunken)) 1633 1632 { 1634 1633 popupPal.setColor(QPalette::Midlight, frame->palette.background().color()); … … 1736 1735 case PE_FrameDockWidget: 1737 1736 if (qstyleoption_cast<const QStyleOptionFrame *>(opt)) { 1738 drawPrimitive(QStyle::PE_FrameWindow, opt, p, w);1737 proxy()->drawPrimitive(QStyle::PE_FrameWindow, opt, p, w); 1739 1738 } 1740 1739 break; … … 1755 1754 1756 1755 int space = 2; 1757 int chunksize = p ixelMetric(PM_ProgressBarChunkWidth, opt, w) - space;1756 int chunksize = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, w) - space; 1758 1757 if (!vertical) { 1759 1758 if (opt->rect.width() <= chunksize) … … 1781 1780 #endif // QT_NO_PROGRESSBAR 1782 1781 1783 case PE_FrameTabWidget: 1784 if (use2000style) { 1785 QRect rect = opt->rect; 1786 QPalette pal = opt->palette; 1787 qDrawWinButton(p, opt->rect, opt->palette, false, 0); 1788 break; 1789 } 1782 case PE_FrameTabWidget: { 1783 qDrawWinButton(p, opt->rect, opt->palette, false, 0); 1784 break; 1785 } 1790 1786 default: 1791 1787 QCommonStyle::drawPrimitive(pe, opt, p, w); … … 1814 1810 QRect r = opt->rect; 1815 1811 QStyleHintReturnMask mask; 1816 if ( styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))1812 if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask)) 1817 1813 p->setClipRegion(mask.region); 1818 1814 p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap); … … 1846 1842 1847 1843 // windows always has a check column, regardless whether we have an icon or not 1848 int checkcol = qMax (menuitem->maxIconWidth,windowsCheckMarkWidth);1844 int checkcol = qMax<int>(menuitem->maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth); 1849 1845 1850 1846 QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button); … … 1883 1879 QPixmap pixmap; 1884 1880 if (checked) 1885 pixmap = menuitem->icon.pixmap(p ixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);1881 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On); 1886 1882 else 1887 pixmap = menuitem->icon.pixmap(p ixelMetric(PM_SmallIconSize, opt, widget), mode);1883 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode); 1888 1884 int pixw = pixmap.width(); 1889 1885 int pixh = pixmap.height(); … … 1902 1898 if (act) 1903 1899 newMi.state |= State_On; 1904 newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + windowsItemFrame, menuitem->rect.y() + windowsItemFrame, 1905 checkcol - 2 * windowsItemFrame, menuitem->rect.height() - 2*windowsItemFrame)); 1906 drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget); 1900 newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + QWindowsStylePrivate::windowsItemFrame, 1901 menuitem->rect.y() + QWindowsStylePrivate::windowsItemFrame, 1902 checkcol - 2 * QWindowsStylePrivate::windowsItemFrame, 1903 menuitem->rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame)); 1904 proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget); 1907 1905 } 1908 1906 p->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color()); … … 1914 1912 } 1915 1913 1916 int xm = windowsItemFrame + checkcol +windowsItemHMargin;1914 int xm = QWindowsStylePrivate::windowsItemFrame + checkcol + QWindowsStylePrivate::windowsItemHMargin; 1917 1915 int xpos = menuitem->rect.x() + xm; 1918 QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); 1916 QRect textRect(xpos, y + QWindowsStylePrivate::windowsItemVMargin, 1917 w - xm - QWindowsStylePrivate::windowsRightBorder - tab + 1, h - 2 * QWindowsStylePrivate::windowsItemVMargin); 1919 1918 QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); 1920 1919 QString s = menuitem->text; … … 1923 1922 int t = s.indexOf(QLatin1Char('\t')); 1924 1923 int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; 1925 if (! styleHint(SH_UnderlineShortcut, menuitem, widget))1924 if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget)) 1926 1925 text_flags |= Qt::TextHideMnemonic; 1927 1926 text_flags |= Qt::AlignLeft; … … 1929 1928 QRect vShortcutRect = visualRect(opt->direction, menuitem->rect, 1930 1929 QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom()))); 1931 if (dis && !act && styleHint(SH_EtchDisabledText, opt, widget)) {1930 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) { 1932 1931 p->setPen(menuitem->palette.light().color()); 1933 1932 p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1)); … … 1941 1940 font.setBold(true); 1942 1941 p->setFont(font); 1943 if (dis && !act && styleHint(SH_EtchDisabledText, opt, widget)) {1942 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) { 1944 1943 p->setPen(menuitem->palette.light().color()); 1945 1944 p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t)); … … 1950 1949 } 1951 1950 if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow 1952 int dim = (h - 2 * windowsItemFrame) / 2;1951 int dim = (h - 2 * QWindowsStylePrivate::windowsItemFrame) / 2; 1953 1952 PrimitiveElement arrow; 1954 1953 arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight; 1955 xpos = x + w - windowsArrowHMargin -windowsItemFrame - dim;1954 xpos = x + w - QWindowsStylePrivate::windowsArrowHMargin - QWindowsStylePrivate::windowsItemFrame - dim; 1956 1955 QRect vSubMenuRect = visualRect(opt->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim)); 1957 1956 QStyleOptionMenuItem newMI = *menuitem; … … 1961 1960 newMI.palette.setColor(QPalette::ButtonText, 1962 1961 newMI.palette.highlightedText().color()); 1963 drawPrimitive(arrow, &newMI, p, widget);1962 proxy()->drawPrimitive(arrow, &newMI, p, widget); 1964 1963 } 1965 1964 … … 1983 1982 mbi->rect.height(), mbi->palette, active && down, 1, 0, &b); 1984 1983 if (active && down) { 1985 newMbi.rect.translate(p ixelMetric(PM_ButtonShiftHorizontal, mbi, widget),1986 p ixelMetric(PM_ButtonShiftVertical, mbi, widget));1984 newMbi.rect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, mbi, widget), 1985 proxy()->pixelMetric(PM_ButtonShiftVertical, mbi, widget)); 1987 1986 p->setBrushOrigin(p->brushOrigin() - QPoint(1, 1)); 1988 1987 } … … 2018 2017 && tab->selectedPosition 2019 2018 == QStyleOptionTab::PreviousIsSelected)); 2020 int tabBarAlignment = styleHint(SH_TabBar_Alignment, tab, widget);2019 int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget); 2021 2020 bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft) 2022 2021 || (rtlHorTabs … … 2032 2031 QColor shadow = tab->palette.shadow().color(); 2033 2032 QColor background = tab->palette.background().color(); 2034 int borderThinkness = p ixelMetric(PM_TabBarBaseOverlap, tab, widget);2033 int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget); 2035 2034 if (selected) 2036 2035 borderThinkness /= 2; … … 2063 2062 p->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness)); 2064 2063 p->drawPoint(x1 + 1, y1 + 1); 2065 if (!use2000style) {2066 p->setPen(midlight);2067 p->drawLine(x1 + 1, y1 + 2, x1 + 1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));2068 }2069 2064 } 2070 2065 // Top … … 2074 2069 p->setPen(light); 2075 2070 p->drawLine(beg, y1, end, y1); 2076 if (!use2000style) {2077 p->setPen(midlight);2078 p->drawLine(beg, y1 + 1, end, y1 + 1);2079 }2080 2071 } 2081 2072 // Right … … 2107 2098 p->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness)); 2108 2099 p->drawPoint(x1 + 1, y2 - 1); 2109 if (!use2000style) {2110 p->setPen(midlight);2111 p->drawLine(x1 + 1, y2 - 2, x1 + 1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));2112 }2113 2100 } 2114 2101 // Bottom … … 2149 2136 p->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1); 2150 2137 p->drawPoint(x1 + 1, y1 + 1); 2151 if (!use2000style) {2152 p->setPen(midlight);2153 p->drawLine(x1 + 2, y1 + 1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1 + 1);2154 }2155 2138 } 2156 2139 // Left … … 2160 2143 p->setPen(light); 2161 2144 p->drawLine(x1, beg, x1, end); 2162 if (!use2000style) {2163 p->setPen(midlight);2164 p->drawLine(x1 + 1, beg, x1 + 1, end);2165 }2166 2145 } 2167 2146 // Bottom … … 2195 2174 p->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1); 2196 2175 p->drawPoint(x2 - 1, y1 + 1); 2197 if (!use2000style) {2198 p->setPen(midlight);2199 p->drawLine(x2 - 3, y1 + 1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1 + 1);2200 p->drawPoint(x2 - 1, y1);2201 }2202 2176 } 2203 2177 // Right … … 2236 2210 case CE_ScrollBarSubLine: 2237 2211 case CE_ScrollBarAddLine: { 2238 if ( use2000style &&(opt->state & State_Sunken)) {2212 if ((opt->state & State_Sunken)) { 2239 2213 p->setPen(opt->palette.dark().color()); 2240 2214 p->setBrush(opt->palette.brush(QPalette::Button)); … … 2264 2238 QStyleOption arrowOpt = *opt; 2265 2239 arrowOpt.rect = opt->rect.adjusted(4, 4, -4, -4); 2266 drawPrimitive(arrow, &arrowOpt, p, widget);2240 proxy()->drawPrimitive(arrow, &arrowOpt, p, widget); 2267 2241 break; } 2268 2242 case CE_ScrollBarAddPage: … … 2353 2327 break; 2354 2328 } 2355 if( QApplication::layoutDirection()== Qt::RightToLeft){ //reverse layout changes the order of Beginning/end2329 if(opt->direction == Qt::RightToLeft){ //reverse layout changes the order of Beginning/end 2356 2330 bool tmp = paintLeftBorder; 2357 2331 paintRightBorder=paintLeftBorder; … … 2450 2424 if (pb->minimum == 0 && pb->maximum == 0) { 2451 2425 Q_D(const QWindowsStyle); 2452 const int unit_width = p ixelMetric(PM_ProgressBarChunkWidth, pb, widget);2426 const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget); 2453 2427 QStyleOptionProgressBarV2 pbBits = *pb; 2454 2428 Q_ASSERT(unit_width >0); … … 2474 2448 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight); 2475 2449 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect(); 2476 drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);2450 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); 2477 2451 x += reverse ? -unit_width : unit_width; 2478 2452 } … … 2485 2459 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight); 2486 2460 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect(); 2487 drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);2461 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); 2488 2462 x += reverse ? -unit_width : unit_width; 2489 2463 } … … 2524 2498 bool floating = false; 2525 2499 bool active = dwOpt->state & State_Active; 2526 int menuOffset = 0; //used to center text when floated2527 2500 QColor inactiveCaptionTextColor = d->inactiveCaptionText; 2528 2501 if (dwOpt->movable) { … … 2539 2512 right = d->inactiveGradientCaptionColor; 2540 2513 } 2541 menuOffset = 2;2542 2514 QBrush fillBrush(left); 2543 2515 if (left != right) { … … 2573 2545 titleRect.height(), titleRect.width()); 2574 2546 } 2575 drawItemText(p, titleRect,2547 proxy()->drawItemText(p, titleRect, 2576 2548 Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, palette, 2577 2549 dwOpt->state & State_Enabled, dwOpt->title, … … 2603 2575 = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt); 2604 2576 bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar; 2605 int m = p ixelMetric(PM_DockWidgetTitleMargin, opt, w);2577 int m = proxy()->pixelMetric(PM_DockWidgetTitleMargin, opt, w); 2606 2578 if (verticalTitleBar) { 2607 2579 r.adjust(0, 0, 0, -m); 2608 2580 } else { 2609 if ( QApplication::layoutDirection()== Qt::LeftToRight)2581 if (opt->direction == Qt::LeftToRight) 2610 2582 r.adjust(m, 0, 0, 0); 2611 2583 else … … 2637 2609 case CC_Slider: 2638 2610 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 2639 int thickness = p ixelMetric(PM_SliderControlThickness, slider, widget);2640 int len = p ixelMetric(PM_SliderLength, slider, widget);2611 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); 2612 int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); 2641 2613 int ticks = slider->tickPosition; 2642 QRect groove = subControlRect(CC_Slider, slider, SC_SliderGroove, widget);2643 QRect handle = subControlRect(CC_Slider, slider, SC_SliderHandle, widget);2614 QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove, widget); 2615 QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle, widget); 2644 2616 2645 2617 if ((slider->subControls & SC_SliderGroove) && groove.isValid()) { … … 2712 2684 fropt.QStyleOption::operator=(*slider); 2713 2685 fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget); 2714 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);2686 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); 2715 2687 } 2716 2688 … … 3024 2996 if (cmb->frame) { 3025 2997 QPalette shadePal = opt->palette; 3026 if (use2000style) 3027 shadePal.setColor(QPalette::Midlight, shadePal.button().color()); 2998 shadePal.setColor(QPalette::Midlight, shadePal.button().color()); 3028 2999 qDrawWinPanel(p, opt->rect, shadePal, true, &editBrush); 3029 3000 } … … 3035 3006 State flags = State_None; 3036 3007 3037 QRect ar = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);3008 QRect ar = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget); 3038 3009 bool sunkenArrow = cmb->activeSubControls == SC_ComboBoxArrow 3039 3010 && cmb->state & State_Sunken; … … 3054 3025 if (opt->state & State_Enabled) 3055 3026 flags |= State_Enabled; 3027 if (opt->state & State_HasFocus) 3028 flags |= State_HasFocus; 3056 3029 3057 3030 if (sunkenArrow) … … 3061 3034 arrowOpt.palette = cmb->palette; 3062 3035 arrowOpt.state = flags; 3063 drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);3036 proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget); 3064 3037 } 3065 3038 3066 3039 if (cmb->subControls & SC_ComboBoxEditField) { 3067 QRect re = subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);3040 QRect re = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget); 3068 3041 if (cmb->state & State_HasFocus && !cmb->editable) 3069 3042 p->fillRect(re.x(), re.y(), re.width(), re.height(), … … 3085 3058 focus.state |= State_FocusAtBorder; 3086 3059 focus.backgroundColor = cmb->palette.highlight().color(); 3087 drawPrimitive(PE_FrameFocusRect, &focus, p, widget);3060 proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget); 3088 3061 } 3089 3062 } … … 3099 3072 if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) { 3100 3073 QBrush editBrush = sb->palette.brush(QPalette::Base); 3101 QRect r = subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);3074 QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget); 3102 3075 QPalette shadePal = sb->palette; 3103 if (use2000style) 3104 shadePal.setColor(QPalette::Midlight, shadePal.button().color()); 3076 shadePal.setColor(QPalette::Midlight, shadePal.button().color()); 3105 3077 qDrawWinPanel(p, r, shadePal, true, &editBrush); 3106 3078 } … … 3130 3102 : PE_IndicatorSpinUp); 3131 3103 3132 copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);3104 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget); 3133 3105 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On), 3134 3106 ©.palette.brush(QPalette::Button)); … … 3138 3110 lightCopy.rect.adjust(1, 1, 1, 1); 3139 3111 lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light()); 3140 drawPrimitive(pe, &lightCopy, p, widget);3141 } 3142 drawPrimitive(pe, ©, p, widget);3112 proxy()->drawPrimitive(pe, &lightCopy, p, widget); 3113 } 3114 proxy()->drawPrimitive(pe, ©, p, widget); 3143 3115 } 3144 3116 … … 3163 3135 : PE_IndicatorSpinDown); 3164 3136 3165 copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);3137 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget); 3166 3138 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On), 3167 3139 ©.palette.brush(QPalette::Button)); … … 3171 3143 lightCopy.rect.adjust(1, 1, 1, 1); 3172 3144 lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light()); 3173 drawPrimitive(pe, &lightCopy, p, widget);3174 } 3175 drawPrimitive(pe, ©, p, widget);3145 proxy()->drawPrimitive(pe, &lightCopy, p, widget); 3146 } 3147 proxy()->drawPrimitive(pe, ©, p, widget); 3176 3148 } 3177 3149 } 3178 3150 break; 3179 3151 #endif // QT_NO_SPINBOX 3152 3180 3153 default: 3181 3154 QCommonStyle::drawComplexControl(cc, opt, p, widget); … … 3196 3169 int defwidth = 0; 3197 3170 if (btn->features & QStyleOptionButton::AutoDefaultButton) 3198 defwidth = 2 * pixelMetric(PM_ButtonDefaultIndicator, btn, widget); 3171 defwidth = 2 * proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget); 3172 int minwidth = int(QStyleHelper::dpiScaled(75.)); 3173 int minheight = int(QStyleHelper::dpiScaled(23.)); 3174 3199 3175 #ifndef QT_QWS_SMALL_PUSHBUTTON 3200 if (w < 75+ defwidth && !btn->text.isEmpty())3201 w = 75+ defwidth;3202 if (h < 23+ defwidth)3203 h = 23+ defwidth;3176 if (w < minwidth + defwidth && !btn->text.isEmpty()) 3177 w = minwidth + defwidth; 3178 if (h < minheight + defwidth) 3179 h = minheight + defwidth; 3204 3180 #endif 3205 3181 sz = QSize(w, h); … … 3213 3189 3214 3190 if (mi->menuItemType == QStyleOptionMenuItem::Separator) { 3215 sz = QSize(10, windowsSepHeight);3191 sz = QSize(10, QWindowsStylePrivate::windowsSepHeight); 3216 3192 } 3217 3193 else if (mi->icon.isNull()) { … … 3221 3197 3222 3198 if (mi->menuItemType != QStyleOptionMenuItem::Separator && !mi->icon.isNull()) { 3223 int iconExtent = p ixelMetric(PM_SmallIconSize, opt, widget);3199 int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); 3224 3200 sz.setHeight(qMax(sz.height(), 3225 3201 mi->icon.actualSize(QSize(iconExtent, iconExtent)).height() 3226 + 2 * windowsItemFrame));3202 + 2 * QWindowsStylePrivate::windowsItemFrame)); 3227 3203 } 3228 3204 int maxpmw = mi->maxIconWidth; 3229 int tabSpacing = use2000style ? 20 :windowsTabSpacing;3205 int tabSpacing = 20; 3230 3206 if (mi->text.contains(QLatin1Char('\t'))) 3231 3207 w += tabSpacing; 3232 3208 else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu) 3233 w += 2 * windowsArrowHMargin;3209 w += 2 * QWindowsStylePrivate::windowsArrowHMargin; 3234 3210 else if (mi->menuItemType == QStyleOptionMenuItem::DefaultItem) { 3235 3211 // adjust the font and add the difference in size. … … 3242 3218 } 3243 3219 3244 int checkcol = qMax (maxpmw,windowsCheckMarkWidth); // Windows always shows a check column3220 int checkcol = qMax<int>(maxpmw, QWindowsStylePrivate::windowsCheckMarkWidth); // Windows always shows a check column 3245 3221 w += checkcol; 3246 w += windowsRightBorder + 10;3222 w += QWindowsStylePrivate::windowsRightBorder + 10; 3247 3223 sz.setWidth(w); 3248 3224 } … … 3252 3228 case CT_MenuBarItem: 3253 3229 if (!sz.isEmpty()) 3254 sz += QSize( windowsItemHMargin * 4,windowsItemVMargin * 2);3230 sz += QSize(QWindowsStylePrivate::windowsItemHMargin * 4, QWindowsStylePrivate::windowsItemVMargin * 2); 3255 3231 break; 3256 3232 #endif … … 3381 3357 && pSHGetStockIconInfo) 3382 3358 { 3383 icon.addPixmap( standardPixmap(SP_VistaShield, option, widget)); //fetches small icon3359 icon.addPixmap(proxy()->standardPixmap(SP_VistaShield, option, widget)); //fetches small icon 3384 3360 QSHSTOCKICONINFO iconInfo; //append large icon 3385 3361 memset(&iconInfo, 0, sizeof(iconInfo)); 3386 3362 iconInfo.cbSize = sizeof(iconInfo); 3387 3363 if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_LARGEICON, &iconInfo) == S_OK) { 3388 icon.addPixmap( convertHIconToPixmap(iconInfo.hIcon));3364 icon.addPixmap(QPixmap::fromWinHICON(iconInfo.hIcon)); 3389 3365 DestroyIcon(iconInfo.hIcon); 3390 3366 }
Note:
See TracChangeset
for help on using the changeset viewer.