Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/styles/qwindowsxpstyle.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    4747#include <private/qpaintengine_raster_p.h>
    4848#include <private/qapplication_p.h>
     49#include <private/qstylehelper_p.h>
     50#include <private/qwidget_p.h>
    4951#include <qlibrary.h>
    5052#include <qpainter.h>
     
    125127// General const values
    126128static const int windowsItemFrame        =  2; // menu item frame width
    127 static const int windowsSepHeight        =  9; // separator item height
    128129static const int windowsItemHMargin      =  3; // menu item hor text margin
    129130static const int windowsItemVMargin      =  0; // menu item ver text margin
    130131static const int windowsArrowHMargin     =  6; // arrow horizontal margin
    131 static const int windowsCheckMarkHMargin =  0; // horiz. margins of check mark
    132132static const int windowsRightBorder      = 12; // right border on windows
    133133
    134134// External function calls
    135135extern Q_GUI_EXPORT HDC qt_win_display_dc();
     136extern QRegion qt_region_from_HRGN(HRGN rgn);
    136137
    137138
     
    161162
    162163    if (!htheme) {
    163         htheme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget),
    164                                 (TCHAR*)name.utf16());
     164        htheme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), (wchar_t*)name.utf16());
    165165        if (htheme) {
    166166            if (!QWindowsXPStylePrivate::handleMap)
     
    261261    cleanupHandleMap();
    262262    if (limboWidget) {
    263         if (qApp->closingDown())
     263        if (QApplication::closingDown())
    264264            delete limboWidget;
    265265        else
     
    301301    if (!limboWidget) {
    302302        limboWidget = new QWidget(0);
     303        limboWidget->createWinId();
    303304        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);
    304308    }
    305309
     
    446450}
    447451
     452
    448453/*! \internal
    449454    Returns a QRegion of the region of the part
     
    457462        return QRegion();
    458463
    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
    461472    DeleteObject(hRgn);
    462     if (success)
    463         return rgn;
    464     return QRegion();
     473    DeleteObject(dest);
     474
     475    return region;
    465476}
    466477
     
    581592            register unsigned int alphaValue = (*buffer) & 0xFF000000;
    582593            if (alphaValue == 0xFF000000) {
    583                 *buffer &= 0x00FFFFFF;
     594                *buffer = 0;
    584595                valueChange = true;
    585596            } else if (alphaValue == 0) {
     
    608619    QPainter *painter = themeData.painter;
    609620    Q_ASSERT_X(painter != 0, "QWindowsXPStylePrivate::drawBackground()", "Trying to draw a theme part without a painter");
    610     if (!painter)
     621    if (!painter || !painter->isActive())
    611622        return;
    612623
    613624    painter->save();
    614625
    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    }
    617634
    618635    bool useFallback = painter->paintEngine()->getDC() == 0
     
    621638                       || complexXForm
    622639                       || themeData.mirrorVertically
    623                        || (themeData.mirrorHorizontally && pDrawThemeBackgroundEx == 0);
     640                       || (themeData.mirrorHorizontally && pDrawThemeBackgroundEx == 0)
     641                       || translucentToplevel;
     642
    624643    if (!useFallback)
    625644        drawBackgroundDirectly(themeData);
     
    10261045    QWindowsStyle, QCommonStyle, and QStyle, but the
    10271046    QWindowsXPStyle overloads of drawComplexControl(), drawControl(),
    1028     drawControlMask(), drawPrimitive(), subControlRect(), and
     1047    drawControlMask(), drawPrimitive(), proxy()->subControlRect(), and
    10291048    sizeFromContents(), are documented here.
    10301049
     
    11931212            otherOption.shape = (twfOption->shape == QTabBar::RoundedNorth
    11941213                                ? QTabBar::RoundedEast : QTabBar::RoundedSouth);
    1195             int overlap = pixelMetric(PM_TabBarBaseOverlap, &otherOption, widget);
    1196             int borderThickness = pixelMetric(PM_DefaultFrameWidth, option, widget);
     1214            int overlap = proxy()->pixelMetric(PM_TabBarBaseOverlap, &otherOption, widget);
     1215            int borderThickness = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget);
    11971216            rect.adjust(-overlap + borderThickness, 0, -overlap + borderThickness, 0);
    11981217        }
     
    12031222            MARGINS borderSize;
    12041223            if (widget) {
    1205                 HTHEME theme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), L"Button");
     1224                XPThemeData buttontheme(widget, 0, QLatin1String("Button"));
     1225                HTHEME theme = buttontheme.handle();
    12061226                if (theme) {
    12071227                    int stateId;
     
    12171237                        stateId = PBS_NORMAL;
    12181238
    1219                     int border = pixelMetric(PM_DefaultFrameWidth, btn, widget);
     1239                    int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
    12201240                    rect = option->rect.adjusted(border, border, -border, -border);
    12211241
     
    15331553
    15341554            if (panel->lineWidth > 0)
    1535                 drawPrimitive(PE_FrameLineEdit, panel, p, widget);
     1555                proxy()->drawPrimitive(PE_FrameLineEdit, panel, p, widget);
    15361556            return;
    15371557        }
     
    15471567                bool useGradient = true;
    15481568                const int maxlength = 256;
    1549                 WCHAR themeFileName[maxlength];
    1550                 WCHAR themeColor[maxlength];
     1569                wchar_t themeFileName[maxlength];
     1570                wchar_t themeColor[maxlength];
    15511571                // Due to a a scaling issue with the XP Silver theme, tab gradients are not used with it
    15521572                if (pGetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength, NULL, 0) == S_OK) {
    1553                     WCHAR* offset;
     1573                    wchar_t *offset = 0;
    15541574                    if ((offset = wcsrchr(themeFileName, QChar(QLatin1Char('\\')).unicode())) != NULL) {
    15551575                        offset++;
     
    15621582                // code, when using the HDC directly..
    15631583                if (useGradient) {
    1564                     QStyleOptionTabWidgetFrame frameOpt = *tab;
     1584                    QStyleOptionTabWidgetFrameV2 frameOpt = *tab;
    15651585                    frameOpt.rect = widget->rect();
    15661586                    QRect contentsRect = subElementRect(SE_TabWidgetTabContents, &frameOpt, widget);
     
    16181638                stateId = FS_INACTIVE;
    16191639
    1620             int fwidth = pixelMetric(PM_DockWidgetFrameWidth, frm, widget);
     1640            int fwidth = proxy()->pixelMetric(PM_DockWidgetFrameWidth, frm, widget);
    16211641
    16221642            XPThemeData theme(widget, p, name, 0, stateId);
     
    17921812
    17931813    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        }
    17951820        name = QLatin1String("TOOLBAR");
    17961821        partId = TP_SEPARATOR;
     
    18211846        button.QStyleOption::operator=(*option);
    18221847        button.state &= ~State_MouseOver;
    1823         drawPrimitive(PE_IndicatorCheckBox, &button, p, widget);
     1848        proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, p, widget);
    18241849        return;
    18251850    }
     
    19141939            name = QLatin1String("BUTTON");
    19151940            partId = BP_PUSHBUTTON;
    1916             bool justFlat = (btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken))
    1917                 || (btn->features & QStyleOptionButton::CommandLinkButton
     1941            bool justFlat = ((btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken)))
     1942                || ((btn->features & QStyleOptionButton::CommandLinkButton)
    19181943                    && !(flags & State_MouseOver)
    19191944                    && !(btn->features & QStyleOptionButton::DefaultButton));
     
    19491974                QStyleOptionButton newBtn = *btn;
    19501975                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);
    19521977            }
    19531978            return;
     
    19721997            bool firstTab = tab->position == QStyleOptionTab::Beginning;
    19731998            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 = pixelMetric(PM_DefaultFrameWidth, option, widget);
    1977             int tabOverlap = pixelMetric(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);
    19782003
    19792004            if (isDisabled)
     
    21202145                    mode = QIcon::Active;
    21212146                QPixmap pixmap = checked ?
    2122                                  menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On) :
    2123                                  menuitem->icon.pixmap(pixelMetric(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);
    21242149                int pixw = pixmap.width();
    21252150                int pixh = pixmap.height();
     
    21472172                                            menuitem->rect.height() - 2*windowsItemFrame);
    21482173                newMi.rect = visualRect(option->direction, option->rect, checkMarkRect);
    2149                 drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
     2174                proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
    21502175            }
    21512176
     
    21642189                int t = s.indexOf(QLatin1Char('\t'));
    21652190                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))
    21672192                    text_flags |= Qt::TextHideMnemonic;
    21682193                // draw tab text ----------------
    21692194                if (t >= 0) {
    21702195                    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)) {
    21722197                        p->setPen(menuitem->palette.light().color());
    21732198                        p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1));
     
    21812206                    font.setBold(true);
    21822207                p->setFont(font);
    2183                 if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) {
     2208                if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) {
    21842209                    p->setPen(menuitem->palette.light().color());
    21852210                    p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t));
     
    22022227                if (act)
    22032228                    newMI.palette.setColor(QPalette::ButtonText, newMI.palette.highlightedText().color());
    2204                 drawPrimitive(arrow, &newMI, p, widget);
     2229                proxy()->drawPrimitive(arrow, &newMI, p, widget);
    22052230            }
    22062231        }
     
    22192244            QPalette::ColorRole textRole = dis ? QPalette::Text:
    22202245                                           act ? QPalette::HighlightedText : QPalette::ButtonText;
    2221             QPixmap pix = mbi->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal);
     2246            QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal);
    22222247
    22232248            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))
    22252250                alignment |= Qt::TextHideMnemonic;
    22262251
     
    22372262        {
    22382263            int buttonMargin = 4;
    2239             int mw = pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget);
    2240             int fw = pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget);
     2264            int mw = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget);
     2265            int fw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget);
    22412266            bool isFloating = widget && widget->isWindow();
    22422267            bool isActive = dwOpt->state & State_Active;
     
    22592284
    22602285            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));
    22622287                titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0);
    22632288            }
    22642289
    22652290            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));
    22672292                titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0);
    22682293            }
     
    22702295            if (isFloating) {
    22712296                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())
    22732298                    titleRect.adjust(titleRect.height() + mw, 0, 0, 0);
    22742299            } else {
     
    23172342
    23182343                QIcon ico = widget->windowIcon();
    2319                 bool hasIcon = (ico.cacheKey() != qApp->windowIcon().cacheKey());
     2344                bool hasIcon = (ico.cacheKey() != QApplication::windowIcon().cacheKey());
    23202345                if (hasIcon) {
    23212346                    QPixmap pxIco = ico.pixmap(titleHeight);
    2322                     if (!verticalTitleBar && QApplication::layoutDirection() == Qt::RightToLeft)
     2347                    if (!verticalTitleBar && dwOpt->direction == Qt::RightToLeft)
    23232348                        p->drawPixmap(rect.width() - titleHeight - pxIco.width(), rect.bottom() - titleHeight - 2, pxIco);
    23242349                    else
     
    24502475            }
    24512476            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);
    24532478                partId = SPNP_UP;
    24542479                if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) || !(flags & State_Enabled))
     
    24652490            }
    24662491            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);
    24682493                partId = SPNP_DOWN;
    24692494                if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) || !(flags & State_Enabled))
     
    25022527                }
    25032528                if (!cmb->editable) {
    2504                     QRect re = subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget);
     2529                    QRect re = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget);
    25052530                    if (option->state & State_HasFocus) {
    25062531                        p->fillRect(re, option->palette.highlight());
     
    25172542            if (sub & SC_ComboBoxArrow) {
    25182543                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);
    25202545                partId = CP_DROPDOWNBUTTON;
    25212546                if (!(flags & State_Enabled))
     
    25452570            bool isRTL  = option->direction == Qt::RightToLeft;
    25462571            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);
    25482573                partId = SBP_ARROWBTN;
    25492574                if (!(flags & State_Enabled))
     
    25602585            }
    25612586            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);
    25632588                partId = SBP_ARROWBTN;
    25642589                if (!(flags & State_Enabled))
     
    25752600            }
    25762601            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));
    25802605                partId = scrollbar->orientation == Qt::Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
    25812606                stateId = SCRBS_DISABLED;
     
    25852610            } else {
    25862611                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);
    25882613                    partId = flags & State_Horizontal ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT;
    25892614                    if (!(flags & State_Enabled))
     
    26002625                }
    26012626                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);
    26032628                    partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
    26042629                    if (!(flags & State_Enabled))
     
    26152640                }
    26162641                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);
    26182643                    if (!(flags & State_Enabled))
    26192644                        stateId = SCRBS_DISABLED;
     
    26262651
    26272652                    // Draw handle
    2628                     theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
     2653                    theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
    26292654                    theme.partId = flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT;
    26302655                    theme.stateId = stateId;
     
    26612686                    if (!gripperBounds.isEmpty()) {
    26622687                        p->save();
    2663                         XPThemeData grippBackground = theme;
    2664                         grippBackground.partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
    26652688                        theme.rect = gripperBounds;
    26662689                        p->setClipRegion(d->region(theme));// Only change inside the region of the gripper
    2667                         d->drawBackground(grippBackground);// The gutter is the grippers background
    26682690                        d->drawBackground(theme);          // Transparent gripper ontop of background
    26692691                        p->restore();
     
    26822704            QRegion tickreg = slrect;
    26832705            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);
    26852707                if (slider->orientation == Qt::Horizontal) {
    26862708                    partId = TKP_TRACK;
     
    26982720            }
    26992721            if (sub & SC_SliderTickmarks) {
    2700                 int tickOffset = pixelMetric(PM_SliderTickmarkOffset, slider, widget);
     2722                int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
    27012723                int ticks = slider->tickPosition;
    2702                 int thickness = pixelMetric(PM_SliderControlThickness, slider, widget);
    2703                 int len = pixelMetric(PM_SliderLength, slider, widget);
    2704                 int available = pixelMetric(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);
    27052727                int interval = slider->tickInterval;
    27062728                if (interval <= 0) {
     
    27582780            }
    27592781            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);
    27612783                if (slider->orientation == Qt::Horizontal) {
    27622784                    if (slider->tickPosition == QSlider::TicksAbove)
     
    28042826                fropt.QStyleOption::operator=(*slider);
    28052827                fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
    2806                 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
     2828                proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
    28072829            }
    28082830        }
     
    28142836            = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
    28152837            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);
    28182840
    28192841            State bflags = toolbutton->state & ~State_Sunken;
    28202842            State mflags = bflags;
    2821 
    2822             if (bflags & State_AutoRaise) {
     2843            bool autoRaise = flags & State_AutoRaise;
     2844            if (autoRaise) {
    28232845                if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) {
    28242846                    bflags &= ~State_Raised;
     
    28352857                }
    28362858            }
    2837            
     2859
    28382860            QStyleOption tool(0);
    28392861            tool.palette = toolbutton->palette;
    28402862            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) {
    28432865                        XPThemeData theme(widget, p, QLatin1String("TOOLBAR"));
    28442866                        theme.partId = TP_SPLITBUTTON;
     
    28592881                        d->drawBackground(theme);
    28602882                    } else {
    2861                         tool.rect = button;
     2883                        tool.rect = option->rect;
    28622884                        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);
    28662887                        else
    2867                             drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
     2888                            proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, widget);
    28682889                    }
    28692890                }
     
    28752896                fr.rect.adjust(3, 3, -3, -3);
    28762897                if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup)
    2877                     fr.rect.adjust(0, 0, -pixelMetric(QStyle::PM_MenuButtonIndicator,
     2898                    fr.rect.adjust(0, 0, -proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator,
    28782899                                                      toolbutton, widget), 0);
    2879                 drawPrimitive(PE_FrameFocusRect, &fr, p, widget);
     2900                proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p, widget);
    28802901            }
    28812902            QStyleOptionToolButton label = *toolbutton;
    28822903            label.state = bflags;
    28832904            int fw = 2;
     2905            if (!autoRaise)
     2906                label.state &= ~State_Sunken;
    28842907            label.rect = button.adjusted(fw, fw, -fw, -fw);
    2885             drawControl(CE_ToolButtonLabel, &label, p, widget);
     2908            proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget);
    28862909
    28872910            if (toolbutton->subControls & SC_ToolButtonMenu) {
    28882911                tool.rect = menuarea;
    28892912                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                }
    28912939            } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) {
    2892                 int mbi = pixelMetric(PM_MenuButtonIndicator, toolbutton, widget);
     2940                int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget);
    28932941                QRect ir = toolbutton->rect;
    28942942                QStyleOptionToolButton newBtn = *toolbutton;
    28952943                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);
    28972945            }
    28982946        }
     
    29262974                    d->drawBackground(theme);
    29272975
    2928                     QRect ir = subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget);
     2976                    QRect ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget);
    29292977
    29302978                    int result = TST_NONE;
     
    29452993                }
    29462994                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);
    29482996                    partId = WP_SYSBUTTON;
    29492997                    if ((widget && !widget->isEnabled()) || !isActive)
     
    29633011                        pGetThemePartSize(theme.handle(), qt_win_display_dc(), theme.partId, theme.stateId, 0, TS_TRUE, &sz);
    29643012                        if (sz.cx == 0 || sz.cy == 0) {
    2965                             int iconSize = pixelMetric(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);
    29673015                            p->save();
    29683016                            drawItemPixmap(p, theme.rect, Qt::AlignCenter, pm);
     
    29763024                if (sub & SC_TitleBarMinButton && tb->titleBarFlags & Qt::WindowMinimizeButtonHint
    29773025                        && !(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);
    29793027                    partId = WP_MINBUTTON;
    29803028                    if (widget && !widget->isEnabled())
     
    29943042                if (sub & SC_TitleBarMaxButton && tb->titleBarFlags & Qt::WindowMaximizeButtonHint
    29953043                        && !(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);
    29973045                    partId = WP_MAXBUTTON;
    29983046                    if (widget && !widget->isEnabled())
     
    30123060                if (sub & SC_TitleBarContextHelpButton
    30133061                    && 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);
    30153063                    partId = WP_HELPBUTTON;
    30163064                    if (widget && !widget->isEnabled())
     
    30343082                                        && (tb->titleBarState & Qt::WindowMaximized)));
    30353083                if (drawNormalButton) {
    3036                     theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarNormalButton, widget);
     3084                    theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarNormalButton, widget);
    30373085                    partId = WP_RESTOREBUTTON;
    30383086                    if (widget && !widget->isEnabled())
     
    30523100                if (sub & SC_TitleBarShadeButton && tb->titleBarFlags & Qt::WindowShadeButtonHint
    30533101                        && !(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);
    30553103                    partId = WP_MINBUTTON;
    30563104                    if (widget && !widget->isEnabled())
     
    30703118                if (sub & SC_TitleBarUnshadeButton && tb->titleBarFlags & Qt::WindowShadeButtonHint
    30713119                        && 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);
    30733121                    partId = WP_RESTOREBUTTON;
    30743122                    if (widget && !widget->isEnabled())
     
    30873135                }
    30883136                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);
    30903138                    //partId = titlebar->testWFlags(Qt::WA_WState_Tool) ? WP_SMALLCLOSEBUTTON : WP_CLOSEBUTTON;
    30913139                    partId = WP_CLOSEBUTTON;
     
    31153163
    31163164            if (option->subControls & SC_MdiCloseButton) {
    3117                 buttonRect = subControlRect(CC_MdiControls, option, SC_MdiCloseButton, widget);
     3165                buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiCloseButton, widget);
    31183166                if (theme.isValid()) {
    31193167                    theme.partId = WP_MDICLOSEBUTTON;
     
    31313179            }
    31323180            if (option->subControls & SC_MdiNormalButton) {
    3133                 buttonRect = subControlRect(CC_MdiControls, option, SC_MdiNormalButton, widget);
     3181                buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiNormalButton, widget);
    31343182                if (theme.isValid()) {
    31353183                    theme.partId = WP_MDIRESTOREBUTTON;
     
    31473195            }
    31483196            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);
    31503198                if (theme.isValid()) {
    31513199                    theme.partId = WP_MDIMINBUTTON;
     
    31653213        break;
    31663214#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
    31673221    default:
    31683222        QWindowsStyle::drawComplexControl(cc, option, p, widget);
     
    32243278
    32253279    case PM_SplitterWidth:
    3226         res = qMax(5, QApplication::globalStrut().width());
     3280        res = qMax(int(QStyleHelper::dpiScaled(5.)), QApplication::globalStrut().width());
    32273281        break;
    32283282
     
    32343288                SIZE size;
    32353289                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;
    32373291            }
    32383292        }
     
    32463300                SIZE size;
    32473301                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;
    32493303            }
    32503304        }
     
    32723326                pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
    32733327                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;
    32853328            }
    32863329        }
     
    33183361#ifndef QT_NO_TOOLBAR
    33193362    case PM_ToolBarHandleExtent:
    3320         res = 8;
     3363        res = int(QStyleHelper::dpiScaled(8.));
    33213364        break;
    33223365
     
    33333376    break;
    33343377    case PM_DockWidgetSeparatorExtent:
    3335         res = 4;
     3378        res = int(QStyleHelper::dpiScaled(4.));
    33363379        break;
    33373380    case PM_DockWidgetTitleMargin:
    3338         res = 4;
     3381        res = int(QStyleHelper::dpiScaled(4.));
    33393382        break;
    33403383
     
    33453388        else
    33463389            res = 0;
     3390        break;
     3391
     3392    case PM_ButtonDefaultIndicator:
     3393        res = 0;
    33473394        break;
    33483395
     
    34283475            const int delta = buttonWidth + 2;
    34293476            int controlTop = option->rect.bottom() - buttonHeight - 2;
    3430             const int frameWidth = pixelMetric(PM_MdiSubWindowFrameWidth, option, widget);
     3477            const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget);
    34313478            const bool sysmenuHint  = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0;
    34323479            const bool minimizeHint = (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) != 0;
     
    35133560                    const int controlTop = 6;
    35143561                    const int controlHeight = height - controlTop - 3;
    3515                     const int iconExtent = pixelMetric(PM_SmallIconSize);
     3562                    const int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
    35163563                    QSize iconSize = tb->icon.actualSize(QSize(iconExtent, iconExtent));
    35173564                    if (tb->icon.isNull())
     
    35223569                }
    35233570                break;
     3571            default:
     3572                break;
    35243573            }
    35253574        }
     
    35473596            case SC_ComboBoxListBoxPopup:
    35483597                rect = cmb->rect;
     3598                break;
     3599
     3600            default:
    35493601                break;
    35503602            }
     
    36123664    case CT_ComboBox:
    36133665        {
    3614             HTHEME theme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), L"Button");
     3666            XPThemeData buttontheme(widget, 0, QLatin1String("Button"));
     3667            HTHEME theme = buttontheme.handle();
    36153668            MARGINS borderSize;
    36163669            if (theme) {
     
    36343687            //Spinbox adds frame twice
    36353688            sz = QWindowsStyle::sizeFromContents(ct, option, contentsSize, widget);
    3636             int border = pixelMetric(PM_SpinBoxFrameWidth, option, widget);
     3689            int border = proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget);
    36373690            sz -= QSize(2*border, 2*border);
    36383691        }
     
    37273780            const QStyleOptionTitleBar *titlebar = qstyleoption_cast<const QStyleOptionTitleBar *>(option);
    37283781            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);
    37293788                XPThemeData themeData;
    37303789                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);
    37323791                } 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);
    37353795            }
    37363796        }
     
    37873847            }
    37883848        }
     3849        break;
     3850    default:
    37893851        break;
    37903852    }
     
    39093971        }
    39103972        break;
     3973    default:
     3974        break;
    39113975    }
    39123976
Note: See TracChangeset for help on using the changeset viewer.