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/qplastiquestyle.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**
     
    4444#if !defined(QT_NO_STYLE_PLASTIQUE) || defined(QT_PLUGIN)
    4545
    46 static bool UsePixmapCache = true;
    4746static const bool AnimateBusyProgressBar = true;
    4847static const bool AnimateProgressBar = false;
     
    5251
    5352#include "qwindowsstyle_p.h"
     53#include <private/qstylehelper_p.h>
    5454#include <qapplication.h>
    5555#include <qbitmap.h>
     
    9999static const int windowsArrowHMargin     =  6; // arrow horizontal margin
    100100static const int windowsTabSpacing       = 12; // space between text and tab
    101 static const int windowsCheckMarkHMargin =  2; // horiz. margins of check mark
    102101static const int windowsRightBorder      = 15; // right border on windows
    103102static const int windowsCheckMarkWidth   = 12; // checkmarks width on windows
     
    491490        QPixmap pixmap;
    492491        QString name = QString::fromLatin1("qbrushtexture-alpha-%1-%2").arg(alpha).arg(texture.cacheKey());
    493         if (UsePixmapCache && !QPixmapCache::find(name, pixmap)) {
     492        if (!QPixmapCache::find(name, pixmap)) {
    494493            QImage image = texture.toImage();
    495494            QRgb *rgb = reinterpret_cast<QRgb *>(image.bits());
     
    552551        QPixmap pixmap;
    553552        QString name = QString::fromLatin1("qbrushtexture-light-%1-%2").arg(light).arg(texture.cacheKey());
    554         if (UsePixmapCache && !QPixmapCache::find(name, pixmap)) {
     553        if (!QPixmapCache::find(name, pixmap)) {
    555554            QImage image = texture.toImage();
    556555            QRgb *rgb = reinterpret_cast<QRgb *>(image.bits());
     
    611610        QPixmap pixmap;
    612611        QString name = QString::fromLatin1("qbrushtexture-dark-%1-%2").arg(dark).arg(brush.texture().cacheKey());
    613         if (UsePixmapCache && !QPixmapCache::find(name, pixmap)) {
     612        if (!QPixmapCache::find(name, pixmap)) {
    614613            QImage image = texture.toImage();
    615614            QRgb *rgb = reinterpret_cast<QRgb *>(image.bits());
     
    731730}
    732731
    733 static QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
    734 {
    735     QString tmp;
    736     const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option);
    737     tmp.sprintf("%s-%d-%d-%d-%lld-%dx%d", key.toLatin1().constData(), uint(option->state),
    738                 option->direction, complexOption ? uint(complexOption->activeSubControls) : uint(0),
    739                 option->palette.cacheKey(), size.width(), size.height());
    740     return tmp;
    741 }
    742 
    743732static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart,
    744733                                       const QColor &gradientStop)
     
    750739    QRect r = rect;
    751740
    752     bool doPixmapCache = UsePixmapCache
    753         && painter->deviceTransform().isIdentity()
     741    bool doPixmapCache = painter->deviceTransform().isIdentity()
    754742        && painter->worldMatrix().isIdentity();
    755743    if (doPixmapCache && QPixmapCache::find(gradientName, cache)) {
     
    1006994#endif
    1007995{
    1008     if (!qgetenv("QT_STYLE_NO_PIXMAPCACHE").isNull())
    1009         UsePixmapCache = false;
    1010996}
    1011997
     
    10711057    frameOpt.lineWidth = q->pixelMetric(QStyle::PM_DefaultFrameWidth);
    10721058    frameOpt.midLineWidth = 0;
    1073     frameOpt.state |= QStyle::State_Sunken;
     1059    frameOpt.state = option->state | QStyle::State_Sunken;
     1060    frameOpt.palette = option->palette;
    10741061    q->drawPrimitive(QStyle::PE_PanelLineEdit, &frameOpt, painter, widget);
    10751062    painter->restore();
     
    11081095    QColor gradientStartColor = option->palette.button().color().lighter(104);
    11091096    QColor gradientStopColor = option->palette.button().color().darker(105);
    1110     QColor baseGradientStartColor = option->palette.base().color().darker(101);
    1111     QColor baseGradientStopColor = option->palette.base().color().darker(106);
    11121097    QColor highlightedGradientStartColor = option->palette.button().color().lighter(101);
    11131098    QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85);
     
    11331118    switch (element) {
    11341119    case PE_IndicatorButtonDropDown:
    1135         drawPrimitive(PE_PanelButtonTool, option, painter, widget);
     1120        proxy()->drawPrimitive(PE_PanelButtonTool, option, painter, widget);
    11361121        break;
    11371122    case PE_FrameDefaultButton: {
     
    11791164            }
    11801165
    1181             int borderThickness = pixelMetric(PM_TabBarBaseOverlap, twf, widget);
     1166            int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, twf, widget);
    11821167            bool reverse = (twf->direction == Qt::RightToLeft);
    11831168
     
    13581343            } else {
    13591344                frameV2.state &= ~(State_Sunken | State_HasFocus);
    1360                 drawPrimitive(PE_Frame, &frameV2, painter, widget);
     1345                proxy()->drawPrimitive(PE_Frame, &frameV2, painter, widget);
    13611346            }
    13621347        }
     
    15161501        }
    15171502#endif
    1518         QString pixmapName = uniqueName(QLatin1String("toolbarhandle"), option, rect.size());
    1519         if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
     1503        QString pixmapName = QStyleHelper::uniqueName(QLatin1String("toolbarhandle"), option, rect.size());
     1504        if (!QPixmapCache::find(pixmapName, cache)) {
    15201505            cache = QPixmap(rect.size());
    15211506            cache.fill(Qt::transparent);
     
    15471532            }
    15481533            cachePainter.end();
    1549             if (UsePixmapCache)
    1550                 QPixmapCache::insert(pixmapName, cache);
     1534            QPixmapCache::insert(pixmapName, cache);
    15511535        }
    15521536        painter->drawPixmap(rect.topLeft(), cache);
     
    18581842        button.QStyleOption::operator=(*option);
    18591843        button.state &= ~State_MouseOver;
    1860         drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget);
     1844        proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget);
    18611845        break;
    18621846    }
     
    18641848        painter->save();
    18651849        bool active = (option->state & State_Active);
    1866         int titleBarStop = option->rect.top() + pixelMetric(PM_TitleBarHeight, option, widget);
     1850        int titleBarStop = option->rect.top() + proxy()->pixelMetric(PM_TitleBarHeight, option, widget);
    18671851
    18681852        QPalette palette = option->palette;
     
    19931977                               adjustedRect.right() - adjustedRect.left() - 1,
    19941978                               adjustedRect.bottom() - adjustedRect.top() - 1);
    1995             qt_plastique_draw_gradient(painter, gradientRect, baseGradientStartColor, baseGradientStopColor);
     1979            if (option->palette.base().style() == Qt::SolidPattern) {
     1980                QColor baseGradientStartColor = option->palette.base().color().darker(101);
     1981                QColor baseGradientStopColor = option->palette.base().color().darker(106);
     1982                qt_plastique_draw_gradient(painter, gradientRect, baseGradientStartColor, baseGradientStopColor);
     1983            } else {
     1984                painter->fillRect(gradientRect, option->palette.base());
     1985            }
    19961986            // draw "+" or "-"
    19971987            painter->setPen(alphaTextColor);
     
    20742064            bool reverseShadow = false;
    20752065
    2076             int borderThickness = pixelMetric(PM_TabBarBaseOverlap, tab, widget);
     2066            int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
    20772067            int marginLeft = 0;
    20782068            if ((atBeginning && !selected) || (selected && leftCornerWidget && ((tab->position == QStyleOptionTab::Beginning) || onlyTab))) {
     
    25862576            }
    25872577
    2588             double vc6_workaround = ((bar->progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * rect.width());
    2589             int progressIndicatorPos = int(vc6_workaround);
     2578            int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum) * rect.width();
    25902579
    25912580            bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted)
     
    26472636            if (vertical) {
    26482637                rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
    2649                 QTransform m;
    2650                 m.translate(rect.height()-1, 0);
     2638                QTransform m = QTransform::fromTranslate(rect.height()-1, 0);
    26512639                m.rotate(90.0);
    26522640                painter->setTransform(m, true);
     
    27832771            painter->setPen(QPen());
    27842772
    2785             QString progressBarName = uniqueName(QLatin1String("progressBarContents"),
     2773            QString progressBarName = QStyleHelper::uniqueName(QLatin1String("progressBarContents"),
    27862774                                                 option, rect.size());
    27872775            QPixmap cache;
    2788             if ((!UsePixmapCache || !QPixmapCache::find(progressBarName, cache)) && rect.height() > 7) {
     2776            if (!QPixmapCache::find(progressBarName, cache) && rect.height() > 7) {
    27892777                QSize size = rect.size();
    27902778                cache = QPixmap(QSize(size.width() - 6 + 30, size.height() - 6));
     
    28192807                }
    28202808
    2821                 if (UsePixmapCache)
    2822                     QPixmapCache::insert(progressBarName, cache);
     2809                QPixmapCache::insert(progressBarName, cache);
    28232810            }
    28242811            painter->setClipRect(progressBar.adjusted(1, 0, -1, -1));
     
    28442831        if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
    28452832            QPixmap cache;
    2846             QString pixmapName = uniqueName(QLatin1String("headersection"), option, option->rect.size());
    2847             pixmapName += QLatin1String("-") + QString::number(int(header->position));
    2848             pixmapName += QLatin1String("-") + QString::number(int(header->orientation));
    2849 
    2850             if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
     2833            QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size());
     2834            pixmapName += QString::number(- int(header->position));
     2835            pixmapName += QString::number(- int(header->orientation));
     2836
     2837            if (!QPixmapCache::find(pixmapName, cache)) {
    28512838                cache = QPixmap(option->rect.size());
    28522839                cache.fill(Qt::white);
     
    28922879
    28932880                cachePainter.end();
    2894                 if (UsePixmapCache)
    2895                     QPixmapCache::insert(pixmapName, cache);
     2881                QPixmapCache::insert(pixmapName, cache);
    28962882            }
    28972883            painter->drawPixmap(option->rect.topLeft(), cache);
     
    29162902                if (!menuItem->text.isEmpty()) {
    29172903                    painter->setFont(menuItem->font);
    2918                     drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,
     2904                    proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,
    29192905                                 menuItem->palette, menuItem->state & State_Enabled, menuItem->text,
    29202906                                 QPalette::Text);
     
    29592945                        button.state |= State_On;
    29602946                    button.palette = menuItem->palette;
    2961                     drawPrimitive(PE_IndicatorRadioButton, &button, painter, widget);
     2947                    proxy()->drawPrimitive(PE_IndicatorRadioButton, &button, painter, widget);
    29622948                } else {
    29632949                    if (menuItem->icon.isNull()) {
     
    29682954                            button.state |= State_On;
    29692955                        button.palette = menuItem->palette;
    2970                         drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget);
     2956                        proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget);
    29712957                    } else if (checked) {
    29722958                        int iconSize = qMax(menuItem->maxIconWidth, 20);
     
    30803066                else
    30813067                    newMI.palette.setColor(QPalette::ButtonText, textBrush.color());
    3082                 drawPrimitive(arrow, &newMI, painter, widget);
     3068                proxy()->drawPrimitive(arrow, &newMI, painter, widget);
    30833069            }
    30843070
     
    30923078        if ((option->state & State_Selected)) {
    30933079            QPixmap cache;
    3094             QString pixmapName = uniqueName(QLatin1String("menubaritem"), option, option->rect.size());
    3095             if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
     3080            QString pixmapName = QStyleHelper::uniqueName(QLatin1String("menubaritem"), option, option->rect.size());
     3081            if (!QPixmapCache::find(pixmapName, cache)) {
    30963082                cache = QPixmap(option->rect.size());
    30973083                cache.fill(Qt::white);
     
    31433129                cachePainter.drawLines(lines, 2);
    31443130                cachePainter.end();
    3145                 if (UsePixmapCache)
    3146                     QPixmapCache::insert(pixmapName, cache);
     3131                QPixmapCache::insert(pixmapName, cache);
    31473132            }
    31483133            painter->drawPixmap(option->rect.topLeft(), cache);
     
    33293314            // Draw the text centered
    33303315            QFont font = painter->font();
    3331             font.setPointSize(font.pointSize() - 1);
     3316            font.setPointSize(QFontInfo(font).pointSize() - 1);
    33323317            painter->setFont(font);
    33333318            painter->setPen(dockWidget->palette.windowText().color());
     
    34563441            bool sunken = scrollBar->state & State_Sunken;
    34573442
    3458             QString addLinePixmapName = uniqueName(QLatin1String("scrollbar_addline"), option, option->rect.size());
     3443            QString addLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_addline"), option, option->rect.size());
    34593444            QPixmap cache;
    3460             if (!UsePixmapCache || !QPixmapCache::find(addLinePixmapName, cache)) {
     3445            if (!QPixmapCache::find(addLinePixmapName, cache)) {
    34613446                cache = QPixmap(option->rect.size());
    34623447                cache.fill(Qt::white);
     
    35173502                }
    35183503                addLinePainter.end();
    3519                 if (UsePixmapCache)
    3520                     QPixmapCache::insert(addLinePixmapName, cache);
     3504                QPixmapCache::insert(addLinePixmapName, cache);
    35213505            }
    35223506            painter->drawPixmap(option->rect.topLeft(), cache);
     
    35293513            bool horizontal = scrollBar->orientation == Qt::Horizontal;
    35303514
    3531             QString groovePixmapName = uniqueName(QLatin1String("scrollbar_groove"), option, option->rect.size());
     3515            QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_groove"), option, option->rect.size());
    35323516            if (sunken)
    35333517                groovePixmapName += QLatin1String("-sunken");
     
    35363520
    35373521            QPixmap cache;
    3538             if (!UsePixmapCache || !QPixmapCache::find(groovePixmapName, cache)) {
     3522            if (!QPixmapCache::find(groovePixmapName, cache)) {
    35393523                cache = QPixmap(option->rect.size());
    35403524                cache.fill(option->palette.background().color());
     
    35623546
    35633547                groovePainter.end();
    3564                 if (UsePixmapCache)
    3565                     QPixmapCache::insert(groovePixmapName, cache);
     3548                QPixmapCache::insert(groovePixmapName, cache);
    35663549            }
    35673550            painter->drawPixmap(option->rect.topLeft(), cache);
     
    35803563            QRect button1;
    35813564            QRect button2;
    3582             int scrollBarExtent = pixelMetric(PM_ScrollBarExtent, option, widget);
     3565            int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget);
    35833566            if (horizontal) {
    35843567                button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(), scrollBarExtent, scrollBarSubLine.height());
     
    35893572            }
    35903573
    3591             QString subLinePixmapName = uniqueName(QLatin1String("scrollbar_subline"), option, button1.size());
     3574            QString subLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_subline"), option, button1.size());
    35923575            QPixmap cache;
    3593             if (!UsePixmapCache || !QPixmapCache::find(subLinePixmapName, cache)) {
     3576            if (!QPixmapCache::find(subLinePixmapName, cache)) {
    35943577                cache = QPixmap(button1.size());
    35953578                cache.fill(Qt::white);
     
    36513634                }
    36523635                subLinePainter.end();
    3653                 if (UsePixmapCache)
    3654                     QPixmapCache::insert(subLinePixmapName, cache);
     3636                QPixmapCache::insert(subLinePixmapName, cache);
    36553637            }
    36563638            painter->drawPixmap(button1.topLeft(), cache);
     
    36653647            // The slider
    36663648            if (option->rect.isValid()) {
    3667                 QString sliderPixmapName = uniqueName(QLatin1String("scrollbar_slider"), option, option->rect.size());
     3649                QString sliderPixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_slider"), option, option->rect.size());
    36683650                if (horizontal)
    36693651                    sliderPixmapName += QLatin1String("-horizontal");
    36703652
    36713653                QPixmap cache;
    3672                 if (!UsePixmapCache || !QPixmapCache::find(sliderPixmapName, cache)) {
     3654                if (!QPixmapCache::find(sliderPixmapName, cache)) {
    36733655                    cache = QPixmap(option->rect.size());
    36743656                    cache.fill(Qt::white);
     
    37213703                    sliderPainter.drawLines(lines, 2);
    37223704
    3723                     int sliderMinLength = pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget);
     3705                    int sliderMinLength = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget);
    37243706                    if ((horizontal && scrollBar->rect.width() > sliderMinLength)
    37253707                        || (!horizontal && scrollBar->rect.height() > sliderMinLength)) {
     
    37413723                    sliderPainter.end();
    37423724                    // insert the slider into the cache
    3743                     if (UsePixmapCache)
    3744                         QPixmapCache::insert(sliderPixmapName, cache);
     3725                    QPixmapCache::insert(sliderPixmapName, cache);
    37453726                }
    37463727                painter->drawPixmap(option->rect.topLeft(), cache);
     
    37613742            } else if (!comboBox->currentIcon.isNull()) {
    37623743                {
    3763                     QRect editRect = subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget);
     3744                    QRect editRect = proxy()->subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget);
    37643745                    if (comboBox->direction == Qt::RightToLeft)
    37653746                        editRect.adjust(0, 2, -2, -2);
     
    37743755                        QRect iconRect(editRect);
    37753756                        iconRect.setWidth(comboBox->iconSize.width() + 5);
    3776                         iconRect = alignedRect(QApplication::layoutDirection(),
     3757                        iconRect = alignedRect(comboBox->direction,
    37773758                                               Qt::AlignLeft | Qt::AlignVCenter,
    37783759                                               iconRect.size(), editRect);
    37793760                        painter->fillRect(iconRect, option->palette.brush(QPalette::Base));
    3780                         drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
     3761                        proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
    37813762                    }
    37823763                    painter->restore();
     
    38213802    case CC_Slider:
    38223803        if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
    3823             QRect grooveRegion = subControlRect(CC_Slider, option, SC_SliderGroove, widget);
    3824             QRect handle = subControlRect(CC_Slider, option, SC_SliderHandle, widget);
    3825             QRect ticks = subControlRect(CC_Slider, option, SC_SliderTickmarks, widget);
     3804            QRect grooveRegion = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
     3805            QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
     3806            QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget);
    38263807            bool horizontal = slider->orientation == Qt::Horizontal;
    38273808            bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
     
    38863867
    38873868            if ((option->subControls & SC_SliderHandle) && handle.isValid()) {
    3888                 QString handlePixmapName = uniqueName(QLatin1String("slider_handle"), option, handle.size());
     3869                QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size());
    38893870                if (ticksAbove && !ticksBelow)
    38903871                    handlePixmapName += QLatin1String("-flipped");
     
    38923873                    handlePixmapName += QLatin1String("-sunken");
    38933874
    3894                 if (!UsePixmapCache || !QPixmapCache::find(handlePixmapName, cache)) {
     3875                if (!QPixmapCache::find(handlePixmapName, cache)) {
    38953876                    cache = QPixmap(handle.size());
    38963877                    cache.fill(Qt::white);
     
    39753956                    handlePainter.drawImage(pixmapRect, image);
    39763957                    handlePainter.end();
    3977                     if (UsePixmapCache)
    3978                         QPixmapCache::insert(handlePixmapName, cache);
     3958                    QPixmapCache::insert(handlePixmapName, cache);
    39793959                }
    39803960
     
    39853965                    fropt.QStyleOption::operator=(*slider);
    39863966                    fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
    3987                     drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
     3967                    proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
    39883968                }
    39893969            }
     
    39923972                QPen oldPen = painter->pen();
    39933973                painter->setPen(borderColor);
    3994                 int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget);
    3995                 int available = pixelMetric(PM_SliderSpaceAvailable, slider, widget);
     3974                int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
     3975                int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
    39963976                int interval = slider->tickInterval;
    39973977                if (interval <= 0) {
     
    40073987
    40083988                int v = slider->minimum;
    4009                 int len = pixelMetric(PM_SliderLength, slider, widget);
     3989                int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
    40103990                QVarLengthArray<QLine, 32> lines;
    40113991                while (v <= slider->maximum + 1) {
     
    40624042
    40634043            // Rects
    4064             QRect upRect = subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
    4065             QRect downRect = subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
     4044            QRect upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
     4045            QRect downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
    40664046            QRect buttonRect = upRect | downRect;
    40674047
     
    40844064                d->drawPartialFrame(painter,
    40854065                                    option,
    4086                                     subControlRect(CC_SpinBox, spinBox, SC_SpinBoxEditField, widget),
     4066                                    proxy()->subControlRect(CC_SpinBox, spinBox, SC_SpinBoxEditField, widget),
    40874067                                    widget);
    40884068            }
     
    44244404                d->drawPartialFrame(painter,
    44254405                                option,
    4426                                 subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget),
     4406                                proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget),
    44274407                                widget);
    44284408
     
    45484528                    buttonOption.state &= ~State_Sunken;
    45494529                }
    4550                 drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget);
     4530                proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget);
    45514531
    45524532                // Draw the menu button separator line
     
    45814561
    45824562            // Draw the focus rect
    4583             if (((option->state & State_HasFocus) && (option->state & State_KeyboardFocusChange)) && !comboBox->editable) {
     4563            if ((option->state & State_HasFocus) && !comboBox->editable
     4564                && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) {
    45844565                QStyleOptionFocusRect focus;
    4585                 focus.rect = subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget)
     4566                focus.rect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget)
    45864567                             .adjusted(-2, 0, 2, 0);
    4587                 drawPrimitive(PE_FrameFocusRect, &focus, painter, widget);
     4568                proxy()->drawPrimitive(PE_FrameFocusRect, &focus, painter, widget);
    45884569            }
    45894570
     
    46154596                dockwidget.QStyleOption::operator=(*option);
    46164597                dockwidget.title = titleBar->text;
    4617                 drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget);
     4598                proxy()->drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget);
    46184599            } else
    46194600#endif // QT3_SUPPORT
     
    46884669                }
    46894670                // draw title
    4690                 QRect textRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget);
     4671                QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget);
    46914672
    46924673                QFont font = painter->font();
     
    47154696                bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken);
    47164697
    4717                 QRect minButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget);
     4698                QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget);
    47184699                qt_plastique_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken);
    47194700
     
    47594740                bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken);
    47604741
    4761                 QRect maxButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget);
     4742                QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget);
    47624743                qt_plastique_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken);
    47634744
     
    47844765                bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken);
    47854766
    4786                 QRect closeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget);
     4767                QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget);
    47874768                qt_plastique_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken);
    47884769
     
    48304811                bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken);
    48314812
    4832                 QRect normalButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget);
     4813                QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget);
    48334814                qt_plastique_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken);
    48344815                int xoffset = int(normalButtonRect.width() / 3.5);
     
    48764857                bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken);
    48774858
    4878                 QRect contextHelpButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget);
     4859                QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget);
    48794860
    48804861                qt_plastique_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken);
     
    49034884                bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken);
    49044885
    4905                 QRect shadeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget);
     4886                QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget);
    49064887                qt_plastique_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken);
    49074888
     
    49274908                bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken);
    49284909
    4929                 QRect unshadeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget);
     4910                QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget);
    49304911                qt_plastique_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken);
    49314912
     
    49524933                bool sunken = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_Sunken);
    49534934
    4954                 QRect iconRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget);
     4935                QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget);
    49554936                if (hover)
    49564937                    qt_plastique_draw_mdibutton(painter, titleBar, iconRect, hover, sunken);
     
    49644945                    tool.rect = iconRect;
    49654946                    painter->save();
    4966                     drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);
     4947                    proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);
    49674948                    painter->restore();
    49684949                }
     
    49714952        }
    49724953        break;
     4954#ifndef QT_NO_DIAL
     4955    case CC_Dial:
     4956        if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option))
     4957            QStyleHelper::drawDial(dial, painter);
     4958        break;
     4959#endif // QT_NO_DIAL
    49734960    default:
    49744961        QWindowsStyle::drawComplexControl(control, option, painter, widget);
     
    49934980    case CT_Slider:
    49944981        if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
    4995             int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget);
     4982            int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
    49964983            if (slider->tickPosition & QSlider::TicksBelow) {
    49974984                if (slider->orientation == Qt::Horizontal)
     
    50124999    case CT_ScrollBar:
    50135000        if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
    5014             int scrollBarExtent = pixelMetric(PM_ScrollBarExtent, option, widget);
    5015             int scrollBarSliderMinimum = pixelMetric(PM_ScrollBarSliderMin, option, widget);
     5001            int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget);
     5002            int scrollBarSliderMinimum = proxy()->pixelMetric(PM_ScrollBarSliderMin, option, widget);
    50165003            if (scrollBar->orientation == Qt::Horizontal) {
    50175004                newSize = QSize(scrollBarExtent * 3 + scrollBarSliderMinimum, scrollBarExtent);
     
    50455032        if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
    50465033            if (menuItem->menuItemType == QStyleOptionMenuItem::Separator)
    5047                 newSize.setHeight(menuItem->text.isEmpty() ? 2 : menuItem->fontMetrics.lineSpacing());
     5034                newSize.setHeight(menuItem->text.isEmpty() ? 2 : menuItem->fontMetrics.height());
    50485035        }
    50495036        break;
     
    50945081    case CC_Slider:
    50955082        if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
    5096             int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget);
     5083            int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
    50975084
    50985085            switch (subControl) {
     
    51475134    case CC_ScrollBar:
    51485135        if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
    5149             int scrollBarExtent = pixelMetric(PM_ScrollBarExtent, scrollBar, widget);
     5136            int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollBar, widget);
    51505137            int sliderMaxLength = ((scrollBar->orientation == Qt::Horizontal) ?
    51515138                                   scrollBar->rect.width() : scrollBar->rect.height()) - (scrollBarExtent * 3);
    5152             int sliderMinLength = pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget);
     5139            int sliderMinLength = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget);
    51535140            int sliderLength;
    51545141
     
    52725259        case SC_ComboBoxEditField: {
    52735260            if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
    5274                 int frameWidth = pixelMetric(PM_DefaultFrameWidth);
     5261                int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth);
    52755262                rect = visualRect(option->direction, option->rect, rect);
    52765263
     
    54545441        ret = 96; // from Plastik
    54555442        break;
     5443#ifdef Q_WS_X11
     5444    case SH_DialogButtonBox_ButtonsHaveIcons:
     5445        ret = true;
     5446        break;
     5447#endif
     5448#ifndef Q_OS_WIN
     5449    case SH_Menu_AllowActiveAndDisabled:
     5450        ret = false;
     5451        break;
     5452#endif
    54565453    default:
    54575454        ret = QWindowsStyle::styleHint(hint, option, widget, returnData);
     
    54725469    case CC_ScrollBar:
    54735470        if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
    5474             QRect slider = subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);
     5471            QRect slider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);
    54755472            if (slider.contains(pos)) {
    54765473                ret = SC_ScrollBarSlider;
     
    54785475            }
    54795476
    5480             QRect scrollBarAddLine = subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);
     5477            QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);
    54815478            if (scrollBarAddLine.contains(pos)) {
    54825479                ret = SC_ScrollBarAddLine;
     
    54845481            }
    54855482
    5486             QRect scrollBarSubPage = subControlRect(control, scrollBar, SC_ScrollBarSubPage, widget);
     5483            QRect scrollBarSubPage = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubPage, widget);
    54875484            if (scrollBarSubPage.contains(pos)) {
    54885485                ret = SC_ScrollBarSubPage;
     
    54905487            }
    54915488
    5492             QRect scrollBarAddPage = subControlRect(control, scrollBar, SC_ScrollBarAddPage, widget);
     5489            QRect scrollBarAddPage = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddPage, widget);
    54935490            if (scrollBarAddPage.contains(pos)) {
    54945491                ret = SC_ScrollBarAddPage;
     
    54965493            }
    54975494
    5498             QRect scrollBarSubLine = subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);
     5495            QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);
    54995496            if (scrollBarSubLine.contains(pos)) {
    55005497                ret = SC_ScrollBarSubLine;
     
    55225519        ret = 0;
    55235520        break;
    5524     case PM_ToolBarIconSize:
    5525         ret = 24;
    5526         break;
    55275521    case PM_ButtonShiftHorizontal:
    55285522    case PM_ButtonShiftVertical:
     
    56155609        if (widget && widget->inherits("Q3DockWindowTitleBar")) {
    56165610            // Q3DockWindow has smaller title bars than QDockWidget
    5617             ret = qMax(widget->fontMetrics().lineSpacing(), 20);
     5611            ret = qMax(widget->fontMetrics().height(), 20);
    56185612        } else
    56195613#endif
    5620         ret = qMax(widget ? widget->fontMetrics().lineSpacing() :
    5621                    (option ? option->fontMetrics.lineSpacing() : 0), 30);
     5614        ret = qMax(widget ? widget->fontMetrics().height() :
     5615                   (option ? option->fontMetrics.height() : 0), 30);
    56225616        break;
    56235617    case PM_MaximumDragDistance:
Note: See TracChangeset for help on using the changeset viewer.