Changeset 561 for trunk/src/gui/styles/qwindowsxpstyle.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/qwindowsxpstyle.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 ** … … 47 47 #include <private/qpaintengine_raster_p.h> 48 48 #include <private/qapplication_p.h> 49 #include <private/qstylehelper_p.h> 50 #include <private/qwidget_p.h> 49 51 #include <qlibrary.h> 50 52 #include <qpainter.h> … … 125 127 // General const values 126 128 static const int windowsItemFrame = 2; // menu item frame width 127 static const int windowsSepHeight = 9; // separator item height128 129 static const int windowsItemHMargin = 3; // menu item hor text margin 129 130 static const int windowsItemVMargin = 0; // menu item ver text margin 130 131 static const int windowsArrowHMargin = 6; // arrow horizontal margin 131 static const int windowsCheckMarkHMargin = 0; // horiz. margins of check mark132 132 static const int windowsRightBorder = 12; // right border on windows 133 133 134 134 // External function calls 135 135 extern Q_GUI_EXPORT HDC qt_win_display_dc(); 136 extern QRegion qt_region_from_HRGN(HRGN rgn); 136 137 137 138 … … 161 162 162 163 if (!htheme) { 163 htheme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), 164 (TCHAR*)name.utf16()); 164 htheme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), (wchar_t*)name.utf16()); 165 165 if (htheme) { 166 166 if (!QWindowsXPStylePrivate::handleMap) … … 261 261 cleanupHandleMap(); 262 262 if (limboWidget) { 263 if ( qApp->closingDown())263 if (QApplication::closingDown()) 264 264 delete limboWidget; 265 265 else … … 301 301 if (!limboWidget) { 302 302 limboWidget = new QWidget(0); 303 limboWidget->createWinId(); 303 304 limboWidget->setObjectName(QLatin1String("xp_limbo_widget")); 305 // We dont need this internal widget to appear in QApplication::topLevelWidgets() 306 if (QWidgetPrivate::allWidgets) 307 QWidgetPrivate::allWidgets->remove(limboWidget); 304 308 } 305 309 … … 446 450 } 447 451 452 448 453 /*! \internal 449 454 Returns a QRegion of the region of the part … … 457 462 return QRegion(); 458 463 459 QRegion rgn = QRegion(0,0,1,1); 460 const bool success = CombineRgn(rgn.handle(), hRgn, 0, RGN_COPY) != ERROR; 464 HRGN dest = CreateRectRgn(0, 0, 0, 0); 465 const bool success = CombineRgn(dest, hRgn, 0, RGN_COPY) != ERROR; 466 467 QRegion region; 468 469 if (success) 470 region = qt_region_from_HRGN(dest); 471 461 472 DeleteObject(hRgn); 462 if (success)463 return rgn; 464 return QRegion();473 DeleteObject(dest); 474 475 return region; 465 476 } 466 477 … … 581 592 register unsigned int alphaValue = (*buffer) & 0xFF000000; 582 593 if (alphaValue == 0xFF000000) { 583 *buffer &= 0x00FFFFFF;594 *buffer = 0; 584 595 valueChange = true; 585 596 } else if (alphaValue == 0) { … … 608 619 QPainter *painter = themeData.painter; 609 620 Q_ASSERT_X(painter != 0, "QWindowsXPStylePrivate::drawBackground()", "Trying to draw a theme part without a painter"); 610 if (!painter )621 if (!painter || !painter->isActive()) 611 622 return; 612 623 613 624 painter->save(); 614 625 615 QMatrix m = painter->matrix(); 616 bool complexXForm = m.m11() != 1.0 || m.m22() != 1.0 || m.m12() != 0.0 || m.m21() != 0.0; 626 bool complexXForm = painter->deviceTransform().type() > QTransform::TxTranslate; 627 628 bool translucentToplevel = false; 629 QPaintDevice *pdev = painter->device(); 630 if (pdev->devType() == QInternal::Widget) { 631 QWidget *win = ((QWidget *) pdev)->window(); 632 translucentToplevel = win->testAttribute(Qt::WA_TranslucentBackground); 633 } 617 634 618 635 bool useFallback = painter->paintEngine()->getDC() == 0 … … 621 638 || complexXForm 622 639 || themeData.mirrorVertically 623 || (themeData.mirrorHorizontally && pDrawThemeBackgroundEx == 0); 640 || (themeData.mirrorHorizontally && pDrawThemeBackgroundEx == 0) 641 || translucentToplevel; 642 624 643 if (!useFallback) 625 644 drawBackgroundDirectly(themeData); … … 1026 1045 QWindowsStyle, QCommonStyle, and QStyle, but the 1027 1046 QWindowsXPStyle overloads of drawComplexControl(), drawControl(), 1028 drawControlMask(), drawPrimitive(), subControlRect(), and1047 drawControlMask(), drawPrimitive(), proxy()->subControlRect(), and 1029 1048 sizeFromContents(), are documented here. 1030 1049 … … 1193 1212 otherOption.shape = (twfOption->shape == QTabBar::RoundedNorth 1194 1213 ? QTabBar::RoundedEast : QTabBar::RoundedSouth); 1195 int overlap = p ixelMetric(PM_TabBarBaseOverlap, &otherOption, widget);1196 int borderThickness = p ixelMetric(PM_DefaultFrameWidth, option, widget);1214 int overlap = proxy()->pixelMetric(PM_TabBarBaseOverlap, &otherOption, widget); 1215 int borderThickness = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); 1197 1216 rect.adjust(-overlap + borderThickness, 0, -overlap + borderThickness, 0); 1198 1217 } … … 1203 1222 MARGINS borderSize; 1204 1223 if (widget) { 1205 HTHEME theme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), L"Button"); 1224 XPThemeData buttontheme(widget, 0, QLatin1String("Button")); 1225 HTHEME theme = buttontheme.handle(); 1206 1226 if (theme) { 1207 1227 int stateId; … … 1217 1237 stateId = PBS_NORMAL; 1218 1238 1219 int border = p ixelMetric(PM_DefaultFrameWidth, btn, widget);1239 int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget); 1220 1240 rect = option->rect.adjusted(border, border, -border, -border); 1221 1241 … … 1533 1553 1534 1554 if (panel->lineWidth > 0) 1535 drawPrimitive(PE_FrameLineEdit, panel, p, widget);1555 proxy()->drawPrimitive(PE_FrameLineEdit, panel, p, widget); 1536 1556 return; 1537 1557 } … … 1547 1567 bool useGradient = true; 1548 1568 const int maxlength = 256; 1549 WCHARthemeFileName[maxlength];1550 WCHARthemeColor[maxlength];1569 wchar_t themeFileName[maxlength]; 1570 wchar_t themeColor[maxlength]; 1551 1571 // Due to a a scaling issue with the XP Silver theme, tab gradients are not used with it 1552 1572 if (pGetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength, NULL, 0) == S_OK) { 1553 WCHAR* offset;1573 wchar_t *offset = 0; 1554 1574 if ((offset = wcsrchr(themeFileName, QChar(QLatin1Char('\\')).unicode())) != NULL) { 1555 1575 offset++; … … 1562 1582 // code, when using the HDC directly.. 1563 1583 if (useGradient) { 1564 QStyleOptionTabWidgetFrame frameOpt = *tab;1584 QStyleOptionTabWidgetFrameV2 frameOpt = *tab; 1565 1585 frameOpt.rect = widget->rect(); 1566 1586 QRect contentsRect = subElementRect(SE_TabWidgetTabContents, &frameOpt, widget); … … 1618 1638 stateId = FS_INACTIVE; 1619 1639 1620 int fwidth = p ixelMetric(PM_DockWidgetFrameWidth, frm, widget);1640 int fwidth = proxy()->pixelMetric(PM_DockWidgetFrameWidth, frm, widget); 1621 1641 1622 1642 XPThemeData theme(widget, p, name, 0, stateId); … … 1792 1812 1793 1813 case PE_IndicatorToolBarSeparator: 1794 1814 if (option->rect.height() < 3) { 1815 // XP style requires a few pixels for the separator 1816 // to be visible. 1817 QWindowsStyle::drawPrimitive(pe, option, p, widget); 1818 return; 1819 } 1795 1820 name = QLatin1String("TOOLBAR"); 1796 1821 partId = TP_SEPARATOR; … … 1821 1846 button.QStyleOption::operator=(*option); 1822 1847 button.state &= ~State_MouseOver; 1823 drawPrimitive(PE_IndicatorCheckBox, &button, p, widget);1848 proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, p, widget); 1824 1849 return; 1825 1850 } … … 1914 1939 name = QLatin1String("BUTTON"); 1915 1940 partId = BP_PUSHBUTTON; 1916 bool justFlat = ( btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken))1917 || ( btn->features & QStyleOptionButton::CommandLinkButton1941 bool justFlat = ((btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken))) 1942 || ((btn->features & QStyleOptionButton::CommandLinkButton) 1918 1943 && !(flags & State_MouseOver) 1919 1944 && !(btn->features & QStyleOptionButton::DefaultButton)); … … 1949 1974 QStyleOptionButton newBtn = *btn; 1950 1975 newBtn.rect = QRect(ir.right() - mbiw - 1, 1 + (ir.height()/2) - (mbih/2), mbiw, mbih); 1951 drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);1976 proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); 1952 1977 } 1953 1978 return; … … 1972 1997 bool firstTab = tab->position == QStyleOptionTab::Beginning; 1973 1998 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab; 1974 bool leftAligned = styleHint(SH_TabBar_Alignment, tab, widget) == Qt::AlignLeft;1975 bool centerAligned = styleHint(SH_TabBar_Alignment, tab, widget) == Qt::AlignCenter;1976 int borderThickness = p ixelMetric(PM_DefaultFrameWidth, option, widget);1977 int tabOverlap = p ixelMetric(PM_TabBarTabOverlap, option, widget);1999 bool leftAligned = proxy()->styleHint(SH_TabBar_Alignment, tab, widget) == Qt::AlignLeft; 2000 bool centerAligned = proxy()->styleHint(SH_TabBar_Alignment, tab, widget) == Qt::AlignCenter; 2001 int borderThickness = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); 2002 int tabOverlap = proxy()->pixelMetric(PM_TabBarTabOverlap, option, widget); 1978 2003 1979 2004 if (isDisabled) … … 2120 2145 mode = QIcon::Active; 2121 2146 QPixmap pixmap = checked ? 2122 menuitem->icon.pixmap(p ixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On) :2123 menuitem->icon.pixmap(p ixelMetric(PM_SmallIconSize, option, widget), mode);2147 menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On) : 2148 menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode); 2124 2149 int pixw = pixmap.width(); 2125 2150 int pixh = pixmap.height(); … … 2147 2172 menuitem->rect.height() - 2*windowsItemFrame); 2148 2173 newMi.rect = visualRect(option->direction, option->rect, checkMarkRect); 2149 drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);2174 proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget); 2150 2175 } 2151 2176 … … 2164 2189 int t = s.indexOf(QLatin1Char('\t')); 2165 2190 int text_flags = Qt::AlignVCenter|Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine | Qt::AlignLeft; 2166 if (! styleHint(SH_UnderlineShortcut, menuitem, widget))2191 if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget)) 2167 2192 text_flags |= Qt::TextHideMnemonic; 2168 2193 // draw tab text ---------------- 2169 2194 if (t >= 0) { 2170 2195 QRect vShortcutRect = visualRect(option->direction, option->rect, QRect(textRect.topRight(), menuitem->rect.bottomRight())); 2171 if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) {2196 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { 2172 2197 p->setPen(menuitem->palette.light().color()); 2173 2198 p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1)); … … 2181 2206 font.setBold(true); 2182 2207 p->setFont(font); 2183 if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) {2208 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { 2184 2209 p->setPen(menuitem->palette.light().color()); 2185 2210 p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t)); … … 2202 2227 if (act) 2203 2228 newMI.palette.setColor(QPalette::ButtonText, newMI.palette.highlightedText().color()); 2204 drawPrimitive(arrow, &newMI, p, widget);2229 proxy()->drawPrimitive(arrow, &newMI, p, widget); 2205 2230 } 2206 2231 } … … 2219 2244 QPalette::ColorRole textRole = dis ? QPalette::Text: 2220 2245 act ? QPalette::HighlightedText : QPalette::ButtonText; 2221 QPixmap pix = mbi->icon.pixmap(p ixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal);2246 QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal); 2222 2247 2223 2248 uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; 2224 if (! styleHint(SH_UnderlineShortcut, mbi, widget))2249 if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget)) 2225 2250 alignment |= Qt::TextHideMnemonic; 2226 2251 … … 2237 2262 { 2238 2263 int buttonMargin = 4; 2239 int mw = p ixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget);2240 int fw = p ixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget);2264 int mw = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget); 2265 int fw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget); 2241 2266 bool isFloating = widget && widget->isWindow(); 2242 2267 bool isActive = dwOpt->state & State_Active; … … 2259 2284 2260 2285 if (dwOpt->closable) { 2261 QSize sz = standardIcon(QStyle::SP_TitleBarCloseButton, dwOpt, widget).actualSize(QSize(10, 10));2286 QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarCloseButton, dwOpt, widget).actualSize(QSize(10, 10)); 2262 2287 titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0); 2263 2288 } 2264 2289 2265 2290 if (dwOpt->floatable) { 2266 QSize sz = standardIcon(QStyle::SP_TitleBarMaxButton, dwOpt, widget).actualSize(QSize(10, 10));2291 QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarMaxButton, dwOpt, widget).actualSize(QSize(10, 10)); 2267 2292 titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0); 2268 2293 } … … 2270 2295 if (isFloating) { 2271 2296 titleRect.adjust(0, -fw, 0, 0); 2272 if (widget != 0 && widget->windowIcon().cacheKey() != qApp->windowIcon().cacheKey())2297 if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey()) 2273 2298 titleRect.adjust(titleRect.height() + mw, 0, 0, 0); 2274 2299 } else { … … 2317 2342 2318 2343 QIcon ico = widget->windowIcon(); 2319 bool hasIcon = (ico.cacheKey() != qApp->windowIcon().cacheKey());2344 bool hasIcon = (ico.cacheKey() != QApplication::windowIcon().cacheKey()); 2320 2345 if (hasIcon) { 2321 2346 QPixmap pxIco = ico.pixmap(titleHeight); 2322 if (!verticalTitleBar && QApplication::layoutDirection()== Qt::RightToLeft)2347 if (!verticalTitleBar && dwOpt->direction == Qt::RightToLeft) 2323 2348 p->drawPixmap(rect.width() - titleHeight - pxIco.width(), rect.bottom() - titleHeight - 2, pxIco); 2324 2349 else … … 2450 2475 } 2451 2476 if (sub & SC_SpinBoxUp) { 2452 theme.rect = subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);2477 theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); 2453 2478 partId = SPNP_UP; 2454 2479 if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) || !(flags & State_Enabled)) … … 2465 2490 } 2466 2491 if (sub & SC_SpinBoxDown) { 2467 theme.rect = subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);2492 theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); 2468 2493 partId = SPNP_DOWN; 2469 2494 if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) || !(flags & State_Enabled)) … … 2502 2527 } 2503 2528 if (!cmb->editable) { 2504 QRect re = subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget);2529 QRect re = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget); 2505 2530 if (option->state & State_HasFocus) { 2506 2531 p->fillRect(re, option->palette.highlight()); … … 2517 2542 if (sub & SC_ComboBoxArrow) { 2518 2543 XPThemeData theme(widget, p, QLatin1String("COMBOBOX")); 2519 theme.rect = subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget);2544 theme.rect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget); 2520 2545 partId = CP_DROPDOWNBUTTON; 2521 2546 if (!(flags & State_Enabled)) … … 2545 2570 bool isRTL = option->direction == Qt::RightToLeft; 2546 2571 if (sub & SC_ScrollBarAddLine) { 2547 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget);2572 theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget); 2548 2573 partId = SBP_ARROWBTN; 2549 2574 if (!(flags & State_Enabled)) … … 2560 2585 } 2561 2586 if (sub & SC_ScrollBarSubLine) { 2562 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget);2587 theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget); 2563 2588 partId = SBP_ARROWBTN; 2564 2589 if (!(flags & State_Enabled)) … … 2575 2600 } 2576 2601 if (maxedOut) { 2577 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);2578 theme.rect = theme.rect.united( subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget));2579 theme.rect = theme.rect.united( subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget));2602 theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); 2603 theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget)); 2604 theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget)); 2580 2605 partId = scrollbar->orientation == Qt::Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT; 2581 2606 stateId = SCRBS_DISABLED; … … 2585 2610 } else { 2586 2611 if (sub & SC_ScrollBarSubPage) { 2587 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget);2612 theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget); 2588 2613 partId = flags & State_Horizontal ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT; 2589 2614 if (!(flags & State_Enabled)) … … 2600 2625 } 2601 2626 if (sub & SC_ScrollBarAddPage) { 2602 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget);2627 theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget); 2603 2628 partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT; 2604 2629 if (!(flags & State_Enabled)) … … 2615 2640 } 2616 2641 if (sub & SC_ScrollBarSlider) { 2617 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);2642 theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); 2618 2643 if (!(flags & State_Enabled)) 2619 2644 stateId = SCRBS_DISABLED; … … 2626 2651 2627 2652 // Draw handle 2628 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);2653 theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); 2629 2654 theme.partId = flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT; 2630 2655 theme.stateId = stateId; … … 2661 2686 if (!gripperBounds.isEmpty()) { 2662 2687 p->save(); 2663 XPThemeData grippBackground = theme;2664 grippBackground.partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;2665 2688 theme.rect = gripperBounds; 2666 2689 p->setClipRegion(d->region(theme));// Only change inside the region of the gripper 2667 d->drawBackground(grippBackground);// The gutter is the grippers background2668 2690 d->drawBackground(theme); // Transparent gripper ontop of background 2669 2691 p->restore(); … … 2682 2704 QRegion tickreg = slrect; 2683 2705 if (sub & SC_SliderGroove) { 2684 theme.rect = subControlRect(CC_Slider, option, SC_SliderGroove, widget);2706 theme.rect = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); 2685 2707 if (slider->orientation == Qt::Horizontal) { 2686 2708 partId = TKP_TRACK; … … 2698 2720 } 2699 2721 if (sub & SC_SliderTickmarks) { 2700 int tickOffset = p ixelMetric(PM_SliderTickmarkOffset, slider, widget);2722 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); 2701 2723 int ticks = slider->tickPosition; 2702 int thickness = p ixelMetric(PM_SliderControlThickness, slider, widget);2703 int len = p ixelMetric(PM_SliderLength, slider, widget);2704 int available = p ixelMetric(PM_SliderSpaceAvailable, slider, widget);2724 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); 2725 int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); 2726 int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); 2705 2727 int interval = slider->tickInterval; 2706 2728 if (interval <= 0) { … … 2758 2780 } 2759 2781 if (sub & SC_SliderHandle) { 2760 theme.rect = subControlRect(CC_Slider, option, SC_SliderHandle, widget);2782 theme.rect = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); 2761 2783 if (slider->orientation == Qt::Horizontal) { 2762 2784 if (slider->tickPosition == QSlider::TicksAbove) … … 2804 2826 fropt.QStyleOption::operator=(*slider); 2805 2827 fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget); 2806 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);2828 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); 2807 2829 } 2808 2830 } … … 2814 2836 = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { 2815 2837 QRect button, menuarea; 2816 button = subControlRect(cc, toolbutton, SC_ToolButton, widget);2817 menuarea = subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget);2838 button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget); 2839 menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget); 2818 2840 2819 2841 State bflags = toolbutton->state & ~State_Sunken; 2820 2842 State mflags = bflags; 2821 2822 if ( bflags & State_AutoRaise) {2843 bool autoRaise = flags & State_AutoRaise; 2844 if (autoRaise) { 2823 2845 if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) { 2824 2846 bflags &= ~State_Raised; … … 2835 2857 } 2836 2858 } 2837 2859 2838 2860 QStyleOption tool(0); 2839 2861 tool.palette = toolbutton->palette; 2840 2862 if (toolbutton->subControls & SC_ToolButton) { 2841 if (flags & (State_Sunken | State_On | State_Raised) || ! (flags & State_AutoRaise)) {2842 if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup ) {2863 if (flags & (State_Sunken | State_On | State_Raised) || !autoRaise) { 2864 if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup && autoRaise) { 2843 2865 XPThemeData theme(widget, p, QLatin1String("TOOLBAR")); 2844 2866 theme.partId = TP_SPLITBUTTON; … … 2859 2881 d->drawBackground(theme); 2860 2882 } else { 2861 tool.rect = button;2883 tool.rect = option->rect; 2862 2884 tool.state = bflags; 2863 if (widget && !qobject_cast<QToolBar*>(widget->parentWidget()) 2864 && !(bflags & State_AutoRaise)) 2865 drawPrimitive(PE_PanelButtonBevel, &tool, p, widget); 2885 if (autoRaise) // for tool bars 2886 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); 2866 2887 else 2867 drawPrimitive(PE_PanelButtonTool, &tool, p, widget);2888 proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, widget); 2868 2889 } 2869 2890 } … … 2875 2896 fr.rect.adjust(3, 3, -3, -3); 2876 2897 if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup) 2877 fr.rect.adjust(0, 0, -p ixelMetric(QStyle::PM_MenuButtonIndicator,2898 fr.rect.adjust(0, 0, -proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, 2878 2899 toolbutton, widget), 0); 2879 drawPrimitive(PE_FrameFocusRect, &fr, p, widget);2900 proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p, widget); 2880 2901 } 2881 2902 QStyleOptionToolButton label = *toolbutton; 2882 2903 label.state = bflags; 2883 2904 int fw = 2; 2905 if (!autoRaise) 2906 label.state &= ~State_Sunken; 2884 2907 label.rect = button.adjusted(fw, fw, -fw, -fw); 2885 drawControl(CE_ToolButtonLabel, &label, p, widget);2908 proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget); 2886 2909 2887 2910 if (toolbutton->subControls & SC_ToolButtonMenu) { 2888 2911 tool.rect = menuarea; 2889 2912 tool.state = mflags; 2890 drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); 2913 if (autoRaise) { 2914 proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); 2915 } else { 2916 tool.state = mflags; 2917 menuarea.adjust(-2, 0, 0, 0); 2918 // Draw menu button 2919 if ((bflags & State_Sunken) != (mflags & State_Sunken)){ 2920 p->save(); 2921 p->setClipRect(menuarea); 2922 tool.rect = option->rect; 2923 proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, 0); 2924 p->restore(); 2925 } 2926 // Draw arrow 2927 p->save(); 2928 p->setPen(option->palette.dark().color()); 2929 p->drawLine(menuarea.left(), menuarea.top() + 3, 2930 menuarea.left(), menuarea.bottom() - 3); 2931 p->setPen(option->palette.light().color()); 2932 p->drawLine(menuarea.left() - 1, menuarea.top() + 3, 2933 menuarea.left() - 1, menuarea.bottom() - 3); 2934 2935 tool.rect = menuarea.adjusted(2, 3, -2, -1); 2936 proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget); 2937 p->restore(); 2938 } 2891 2939 } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) { 2892 int mbi = p ixelMetric(PM_MenuButtonIndicator, toolbutton, widget);2940 int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget); 2893 2941 QRect ir = toolbutton->rect; 2894 2942 QStyleOptionToolButton newBtn = *toolbutton; 2895 2943 newBtn.rect = QRect(ir.right() + 4 - mbi, ir.height() - mbi + 4, mbi - 5, mbi - 5); 2896 drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);2944 proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); 2897 2945 } 2898 2946 } … … 2926 2974 d->drawBackground(theme); 2927 2975 2928 QRect ir = subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget);2976 QRect ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget); 2929 2977 2930 2978 int result = TST_NONE; … … 2945 2993 } 2946 2994 if (sub & SC_TitleBarSysMenu && tb->titleBarFlags & Qt::WindowSystemMenuHint) { 2947 theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarSysMenu, widget);2995 theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarSysMenu, widget); 2948 2996 partId = WP_SYSBUTTON; 2949 2997 if ((widget && !widget->isEnabled()) || !isActive) … … 2963 3011 pGetThemePartSize(theme.handle(), qt_win_display_dc(), theme.partId, theme.stateId, 0, TS_TRUE, &sz); 2964 3012 if (sz.cx == 0 || sz.cy == 0) { 2965 int iconSize = p ixelMetric(PM_SmallIconSize, tb, widget);2966 QPixmap pm = standardIcon(SP_TitleBarMenuButton, tb, widget).pixmap(iconSize, iconSize);3013 int iconSize = proxy()->pixelMetric(PM_SmallIconSize, tb, widget); 3014 QPixmap pm = proxy()->standardIcon(SP_TitleBarMenuButton, tb, widget).pixmap(iconSize, iconSize); 2967 3015 p->save(); 2968 3016 drawItemPixmap(p, theme.rect, Qt::AlignCenter, pm); … … 2976 3024 if (sub & SC_TitleBarMinButton && tb->titleBarFlags & Qt::WindowMinimizeButtonHint 2977 3025 && !(tb->titleBarState & Qt::WindowMinimized)) { 2978 theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarMinButton, widget);3026 theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarMinButton, widget); 2979 3027 partId = WP_MINBUTTON; 2980 3028 if (widget && !widget->isEnabled()) … … 2994 3042 if (sub & SC_TitleBarMaxButton && tb->titleBarFlags & Qt::WindowMaximizeButtonHint 2995 3043 && !(tb->titleBarState & Qt::WindowMaximized)) { 2996 theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarMaxButton, widget);3044 theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarMaxButton, widget); 2997 3045 partId = WP_MAXBUTTON; 2998 3046 if (widget && !widget->isEnabled()) … … 3012 3060 if (sub & SC_TitleBarContextHelpButton 3013 3061 && tb->titleBarFlags & Qt::WindowContextHelpButtonHint) { 3014 theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarContextHelpButton, widget);3062 theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarContextHelpButton, widget); 3015 3063 partId = WP_HELPBUTTON; 3016 3064 if (widget && !widget->isEnabled()) … … 3034 3082 && (tb->titleBarState & Qt::WindowMaximized))); 3035 3083 if (drawNormalButton) { 3036 theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarNormalButton, widget);3084 theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarNormalButton, widget); 3037 3085 partId = WP_RESTOREBUTTON; 3038 3086 if (widget && !widget->isEnabled()) … … 3052 3100 if (sub & SC_TitleBarShadeButton && tb->titleBarFlags & Qt::WindowShadeButtonHint 3053 3101 && !(tb->titleBarState & Qt::WindowMinimized)) { 3054 theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarShadeButton, widget);3102 theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarShadeButton, widget); 3055 3103 partId = WP_MINBUTTON; 3056 3104 if (widget && !widget->isEnabled()) … … 3070 3118 if (sub & SC_TitleBarUnshadeButton && tb->titleBarFlags & Qt::WindowShadeButtonHint 3071 3119 && tb->titleBarState & Qt::WindowMinimized) { 3072 theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarUnshadeButton, widget);3120 theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarUnshadeButton, widget); 3073 3121 partId = WP_RESTOREBUTTON; 3074 3122 if (widget && !widget->isEnabled()) … … 3087 3135 } 3088 3136 if (sub & SC_TitleBarCloseButton && tb->titleBarFlags & Qt::WindowSystemMenuHint) { 3089 theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarCloseButton, widget);3137 theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarCloseButton, widget); 3090 3138 //partId = titlebar->testWFlags(Qt::WA_WState_Tool) ? WP_SMALLCLOSEBUTTON : WP_CLOSEBUTTON; 3091 3139 partId = WP_CLOSEBUTTON; … … 3115 3163 3116 3164 if (option->subControls & SC_MdiCloseButton) { 3117 buttonRect = subControlRect(CC_MdiControls, option, SC_MdiCloseButton, widget);3165 buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiCloseButton, widget); 3118 3166 if (theme.isValid()) { 3119 3167 theme.partId = WP_MDICLOSEBUTTON; … … 3131 3179 } 3132 3180 if (option->subControls & SC_MdiNormalButton) { 3133 buttonRect = subControlRect(CC_MdiControls, option, SC_MdiNormalButton, widget);3181 buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiNormalButton, widget); 3134 3182 if (theme.isValid()) { 3135 3183 theme.partId = WP_MDIRESTOREBUTTON; … … 3147 3195 } 3148 3196 if (option->subControls & QStyle::SC_MdiMinButton) { 3149 buttonRect = subControlRect(CC_MdiControls, option, SC_MdiMinButton, widget);3197 buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiMinButton, widget); 3150 3198 if (theme.isValid()) { 3151 3199 theme.partId = WP_MDIMINBUTTON; … … 3165 3213 break; 3166 3214 #endif //QT_NO_WORKSPACE 3215 #ifndef QT_NO_DIAL 3216 case CC_Dial: 3217 if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option)) 3218 QStyleHelper::drawDial(dial, p); 3219 break; 3220 #endif // QT_NO_DIAL 3167 3221 default: 3168 3222 QWindowsStyle::drawComplexControl(cc, option, p, widget); … … 3224 3278 3225 3279 case PM_SplitterWidth: 3226 res = qMax( 5, QApplication::globalStrut().width());3280 res = qMax(int(QStyleHelper::dpiScaled(5.)), QApplication::globalStrut().width()); 3227 3281 break; 3228 3282 … … 3234 3288 SIZE size; 3235 3289 pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size); 3236 res = (pm == PM_IndicatorWidth ? size.cx+2 : res = size.cy+2);3290 res = (pm == PM_IndicatorWidth) ? size.cx : size.cy; 3237 3291 } 3238 3292 } … … 3246 3300 SIZE size; 3247 3301 pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size); 3248 res = (pm == PM_ExclusiveIndicatorWidth ? size.cx+2 : res = size.cy+2);3302 res = (pm == PM_ExclusiveIndicatorWidth) ? size.cx : size.cy; 3249 3303 } 3250 3304 } … … 3272 3326 pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size); 3273 3327 res = size.cy; 3274 }3275 }3276 break;3277 3278 case PM_MenuButtonIndicator:3279 {3280 XPThemeData theme(widget, 0, QLatin1String("TOOLBAR"), TP_SPLITBUTTONDROPDOWN);3281 if (theme.isValid()) {3282 SIZE size;3283 pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);3284 res = size.cx;3285 3328 } 3286 3329 } … … 3318 3361 #ifndef QT_NO_TOOLBAR 3319 3362 case PM_ToolBarHandleExtent: 3320 res = 8;3363 res = int(QStyleHelper::dpiScaled(8.)); 3321 3364 break; 3322 3365 … … 3333 3376 break; 3334 3377 case PM_DockWidgetSeparatorExtent: 3335 res = 4;3378 res = int(QStyleHelper::dpiScaled(4.)); 3336 3379 break; 3337 3380 case PM_DockWidgetTitleMargin: 3338 res = 4;3381 res = int(QStyleHelper::dpiScaled(4.)); 3339 3382 break; 3340 3383 … … 3345 3388 else 3346 3389 res = 0; 3390 break; 3391 3392 case PM_ButtonDefaultIndicator: 3393 res = 0; 3347 3394 break; 3348 3395 … … 3428 3475 const int delta = buttonWidth + 2; 3429 3476 int controlTop = option->rect.bottom() - buttonHeight - 2; 3430 const int frameWidth = p ixelMetric(PM_MdiSubWindowFrameWidth, option, widget);3477 const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget); 3431 3478 const bool sysmenuHint = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0; 3432 3479 const bool minimizeHint = (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) != 0; … … 3513 3560 const int controlTop = 6; 3514 3561 const int controlHeight = height - controlTop - 3; 3515 const int iconExtent = p ixelMetric(PM_SmallIconSize);3562 const int iconExtent = proxy()->pixelMetric(PM_SmallIconSize); 3516 3563 QSize iconSize = tb->icon.actualSize(QSize(iconExtent, iconExtent)); 3517 3564 if (tb->icon.isNull()) … … 3522 3569 } 3523 3570 break; 3571 default: 3572 break; 3524 3573 } 3525 3574 } … … 3547 3596 case SC_ComboBoxListBoxPopup: 3548 3597 rect = cmb->rect; 3598 break; 3599 3600 default: 3549 3601 break; 3550 3602 } … … 3612 3664 case CT_ComboBox: 3613 3665 { 3614 HTHEME theme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), L"Button"); 3666 XPThemeData buttontheme(widget, 0, QLatin1String("Button")); 3667 HTHEME theme = buttontheme.handle(); 3615 3668 MARGINS borderSize; 3616 3669 if (theme) { … … 3634 3687 //Spinbox adds frame twice 3635 3688 sz = QWindowsStyle::sizeFromContents(ct, option, contentsSize, widget); 3636 int border = p ixelMetric(PM_SpinBoxFrameWidth, option, widget);3689 int border = proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget); 3637 3690 sz -= QSize(2*border, 2*border); 3638 3691 } … … 3727 3780 const QStyleOptionTitleBar *titlebar = qstyleoption_cast<const QStyleOptionTitleBar *>(option); 3728 3781 if (mask && titlebar) { 3782 // Note certain themes will not return the whole window frame but only the titlebar part when 3783 // queried This function needs to return the entire window mask, hence we will only fetch the mask for the 3784 // titlebar itself and add the remaining part of the window rect at the bottom. 3785 int tbHeight = proxy()->pixelMetric(PM_TitleBarHeight, option, widget); 3786 QRect titleBarRect = option->rect; 3787 titleBarRect.setHeight(tbHeight); 3729 3788 XPThemeData themeData; 3730 3789 if (titlebar->titleBarState & Qt::WindowMinimized) { 3731 themeData = XPThemeData(widget, 0, QLatin1String("WINDOW"), WP_MINCAPTION, CS_ACTIVE, option->rect);3790 themeData = XPThemeData(widget, 0, QLatin1String("WINDOW"), WP_MINCAPTION, CS_ACTIVE, titleBarRect); 3732 3791 } else 3733 themeData = XPThemeData(widget, 0, QLatin1String("WINDOW"), WP_CAPTION, CS_ACTIVE, option->rect); 3734 mask->region = d->region(themeData); 3792 themeData = XPThemeData(widget, 0, QLatin1String("WINDOW"), WP_CAPTION, CS_ACTIVE, titleBarRect); 3793 mask->region = d->region(themeData) + 3794 QRect(0, tbHeight, option->rect.width(), option->rect.height() - tbHeight); 3735 3795 } 3736 3796 } … … 3787 3847 } 3788 3848 } 3849 break; 3850 default: 3789 3851 break; 3790 3852 } … … 3909 3971 } 3910 3972 break; 3973 default: 3974 break; 3911 3975 } 3912 3976
Note:
See TracChangeset
for help on using the changeset viewer.