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/qwindowsstyle.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**
     
    4242#include "qwindowsstyle.h"
    4343#include "qwindowsstyle_p.h"
    44 #include <private/qpixmapdata_p.h>
     44#include <private/qstylehelper_p.h>
    4545
    4646#if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
     
    6868#include "qwizard.h"
    6969#include "qlistview.h"
     70#include <private/qmath_p.h>
     71#include <qmath.h>
     72
    7073
    7174#ifdef Q_WS_X11
     
    112115#include <limits.h>
    113116QT_END_INCLUDE_NAMESPACE
    114 
    115 static const int windowsItemFrame        =  2; // menu item frame width
    116 static const int windowsSepHeight        =  9; // separator item height
    117 static const int windowsItemHMargin      =  3; // menu item hor text margin
    118 static const int windowsItemVMargin      =  2; // menu item ver text margin
    119 static const int windowsArrowHMargin     =  6; // arrow horizontal margin
    120 static const int windowsTabSpacing       = 12; // space between text and tab
    121 static const int windowsCheckMarkHMargin =  2; // horiz. margins of check mark
    122 static const int windowsRightBorder      = 15; // right border on windows
    123 static const int windowsCheckMarkWidth   = 12; // checkmarks width on windows
    124 
    125 static bool use2000style = true;
    126117
    127118enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight };
     
    223214    case QEvent::Show:
    224215        if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) {
    225             d->bars << bar;
    226             if (d->bars.size() == 1) {
    227                 Q_ASSERT(d->animationFps> 0);
    228                 d->animateTimer = startTimer(1000 / d->animationFps);
     216            if (!d->bars.contains(bar)) {
     217                d->bars << bar;
     218                if (d->bars.size() == 1) {
     219                    Q_ASSERT(d->animationFps> 0);
     220                    d->animateTimer = startTimer(1000 / d->animationFps);
     221                }
    229222            }
    230223        }
     
    266259QWindowsStyle::QWindowsStyle() : QCommonStyle(*new QWindowsStylePrivate)
    267260{
    268 #if defined(Q_OS_WIN32)
    269     use2000style = QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95;
    270 #endif
    271261}
    272262
     
    278268QWindowsStyle::QWindowsStyle(QWindowsStylePrivate &dd) : QCommonStyle(dd)
    279269{
    280 #if defined(Q_OS_WIN32)
    281     use2000style = QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95;
    282 #endif
    283270}
    284271
     
    302289    QWindowsStylePrivate *d = const_cast<QWindowsStylePrivate*>(d_func());
    303290    // We only need the overhead when shortcuts are sometimes hidden
    304     if (!styleHint(SH_UnderlineShortcut, 0) && app)
     291    if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app)
    305292        app->installEventFilter(this);
    306293
     
    403390#ifndef QT_NO_SLIDER
    404391    case PM_SliderLength:
    405         ret = 11;
     392        ret = int(QStyleHelper::dpiScaled(11.));
    406393        break;
    407394
     
    425412            int thick = 6;        // Magic constant to get 5 + 16 + 5
    426413            if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks)
    427                 thick += pixelMetric(PM_SliderLength, sl, widget) / 4;
     414                thick += proxy()->pixelMetric(PM_SliderLength, sl, widget) / 4;
    428415
    429416            space -= thick;
     
    451438
    452439    case PM_SmallIconSize:
    453         ret = 16;
     440        ret = int(QStyleHelper::dpiScaled(16.));
    454441        break;
    455442
    456443    case PM_LargeIconSize:
    457         ret = 32;
     444        ret = int(QStyleHelper::dpiScaled(32.));
    458445        break;
    459446
    460447    case PM_IconViewIconSize:
    461         ret = pixelMetric(PM_LargeIconSize, opt, widget);
    462         break;
    463 
    464     case PM_ToolBarIconSize:
    465         ret = 24;
    466         break;
     448        ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget);
     449        break;
     450
    467451    case PM_DockWidgetTitleMargin:
    468         ret = 2;
     452        ret = int(QStyleHelper::dpiScaled(2.));
    469453        break;
    470454    case PM_DockWidgetTitleBarButtonMargin:
    471         ret = 4;
     455        ret = int(QStyleHelper::dpiScaled(4.));
    472456        break;
    473457#if defined(Q_WS_WIN)
     
    551535        break;
    552536    case PM_ToolBarHandleExtent:
    553         ret = 10;
     537        ret = int(QStyleHelper::dpiScaled(10.));
    554538        break;
    555539    default:
     
    934918#endif //QT_NO_IMAGEFORMAT_XPM
    935919
     920#ifdef Q_OS_WIN
     921static QPixmap loadIconFromShell32( int resourceId, int size )
     922{
     923#ifdef Q_OS_WINCE
     924    HMODULE hmod = LoadLibrary(L"ceshell.dll");
     925#else
     926    HMODULE hmod = LoadLibrary(L"shell32.dll");
     927#endif
     928    if( hmod ) {
     929        HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size, size, 0);
     930        if( iconHandle ) {
     931            QPixmap iconpixmap = QPixmap::fromWinHICON( iconHandle );
     932            DestroyIcon(iconHandle);
     933            return iconpixmap;
     934        }
     935    }
     936    return QPixmap();
     937}
     938#endif
     939
    936940/*!
    937941 \reimp
     
    10231027        {
    10241028            HICON iconHandle = LoadIcon(NULL, IDI_INFORMATION);
    1025             desktopIcon = convertHIconToPixmap( iconHandle );
     1029            desktopIcon = QPixmap::fromWinHICON( iconHandle );
    10261030            DestroyIcon(iconHandle);
    10271031            break;
     
    10301034        {
    10311035            HICON iconHandle = LoadIcon(NULL, IDI_WARNING);
    1032             desktopIcon = convertHIconToPixmap( iconHandle );
     1036            desktopIcon = QPixmap::fromWinHICON( iconHandle );
    10331037            DestroyIcon(iconHandle);
    10341038            break;
     
    10371041        {
    10381042            HICON iconHandle = LoadIcon(NULL, IDI_ERROR);
    1039             desktopIcon = convertHIconToPixmap( iconHandle );
     1043            desktopIcon = QPixmap::fromWinHICON( iconHandle );
    10401044            DestroyIcon(iconHandle);
    10411045            break;
     
    10441048        {
    10451049            HICON iconHandle = LoadIcon(NULL, IDI_QUESTION);
    1046             desktopIcon = convertHIconToPixmap( iconHandle );
     1050            desktopIcon = QPixmap::fromWinHICON( iconHandle );
    10471051            DestroyIcon(iconHandle);
    10481052            break;
     
    10591063                iconInfo.cbSize = sizeof(iconInfo);
    10601064                if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_SMALLICON, &iconInfo) == S_OK) {
    1061                     pixmap = convertHIconToPixmap(iconInfo.hIcon);
     1065                    pixmap = QPixmap::fromWinHICON(iconInfo.hIcon);
    10621066                    DestroyIcon(iconInfo.hIcon);
    10631067                    return pixmap;
     
    10651069            }
    10661070        }
     1071        break;
     1072    default:
    10671073        break;
    10681074    }
     
    11341140        break;
    11351141    case SH_ItemView_ChangeHighlightOnFocus:
    1136 #if defined(Q_WS_WIN)
    1137         if (QSysInfo::WindowsVersion != QSysInfo::WV_95 && QSysInfo::WindowsVersion != QSysInfo::WV_NT)
    1138             ret = 1;
    1139         else
    1140 #endif
    1141             ret = 0;
     1142        ret = 1;
    11421143        break;
    11431144    case SH_ToolBox_SelectedPageTitleBold:
     
    11471148#if defined(Q_WS_WIN)
    11481149    case SH_UnderlineShortcut:
     1150    {
    11491151        ret = 1;
    1150         if (QSysInfo::WindowsVersion != QSysInfo::WV_95
    1151             && QSysInfo::WindowsVersion != QSysInfo::WV_98
    1152             && QSysInfo::WindowsVersion != QSysInfo::WV_NT) {
    1153             BOOL cues;
    1154             SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0);
    1155             ret = int(cues);
    1156             // Do nothing if we always paint underlines
    1157             Q_D(const QWindowsStyle);
    1158             if (!ret && widget && d) {
     1152        BOOL cues = false;
     1153        SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0);
     1154        ret = int(cues);
     1155        // Do nothing if we always paint underlines
     1156        Q_D(const QWindowsStyle);
     1157        if (!ret && widget && d) {
    11591158#ifndef QT_NO_MENUBAR
    1160                 const QMenuBar *menuBar = qobject_cast<const QMenuBar *>(widget);
    1161                 if (!menuBar && qobject_cast<const QMenu *>(widget)) {
    1162                     QWidget *w = QApplication::activeWindow();
    1163                     if (w && w != widget)
    1164                         menuBar = qFindChild<QMenuBar *>(w);
    1165                 }
    1166                 // If we paint a menu bar draw underlines if is in the keyboardState
    1167                 if (menuBar) {
    1168                     if (menuBar->d_func()->keyboardState || d->altDown())
    1169                         ret = 1;
    1170                     // Otherwise draw underlines if the toplevel widget has seen an alt-press
    1171                 } else
     1159            const QMenuBar *menuBar = qobject_cast<const QMenuBar *>(widget);
     1160            if (!menuBar && qobject_cast<const QMenu *>(widget)) {
     1161                QWidget *w = QApplication::activeWindow();
     1162                if (w && w != widget)
     1163                    menuBar = qFindChild<QMenuBar *>(w);
     1164            }
     1165            // If we paint a menu bar draw underlines if is in the keyboardState
     1166            if (menuBar) {
     1167                if (menuBar->d_func()->keyboardState || d->altDown())
     1168                    ret = 1;
     1169                // Otherwise draw underlines if the toplevel widget has seen an alt-press
     1170            } else
    11721171#endif // QT_NO_MENUBAR
    1173                 if (d->hasSeenAlt(widget)) {
    1174                     ret = 1;
    1175                 }
    1176             }
    1177         }
    1178         break;
     1172            if (d->hasSeenAlt(widget)) {
     1173                ret = 1;
     1174            }
     1175        }
     1176        break;
     1177    }
    11791178#endif
    11801179#ifndef QT_NO_RUBBERBAND
     
    12171216    case SH_ItemView_ArrowKeysNavigateIntoChildren:
    12181217        ret = true;
     1218        break;
     1219    case SH_DialogButtonBox_ButtonsHaveIcons:
     1220        ret = 0;
    12191221        break;
    12201222    default:
     
    12731275        if (opt->state & State_Horizontal) {
    12741276            int x = opt->rect.width() / 2 - 4;
    1275             if (QApplication::layoutDirection() == Qt::RightToLeft)
     1277            if (opt->direction == Qt::RightToLeft)
    12761278                x -= 2;
    12771279            if (opt->rect.height() > 4) {
     
    13141316            && (!(opt->state & State_Enabled)
    13151317                || !(opt->state & State_MouseOver && opt->state & State_AutoRaise))
    1316             && (opt->state & State_On) && use2000style) {
     1318            && (opt->state & State_On)) {
    13171319            fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
    13181320            stippled = true;
     
    13871389            int size = qMin(r.height(), r.width());
    13881390            QPixmap pixmap;
    1389             QString pixmapName;
    1390             pixmapName.sprintf("%s-%s-%d-%d-%d-%lld",
    1391                                "$qt_ia", metaObject()->className(),
    1392                                uint(opt->state), pe,
    1393                                size, opt->palette.cacheKey());
     1391            QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-") + QLatin1String(metaObject()->className()), opt, QSize(size, size))
     1392                  + QLatin1Char('-') + QString::number(pe);                               
    13941393            if (!QPixmapCache::find(pixmapName, pixmap)) {
    13951394                int border = size/5;
     
    14211420
    14221421                if (opt->state & State_Sunken) {
    1423                     bsx = pixelMetric(PM_ButtonShiftHorizontal, opt, w);
    1424                     bsy = pixelMetric(PM_ButtonShiftVertical, opt, w);
     1422                    bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, w);
     1423                    bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, w);
    14251424                }
    14261425
     
    15111510        if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
    15121511            //### check for d->alt_down
    1513             if (!(fropt->state & State_KeyboardFocusChange) && !styleHint(SH_UnderlineShortcut, opt))
     1512            if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt))
    15141513                return;
    15151514            QRect r = opt->rect;
     
    15781577            int xOffset = 0;
    15791578            int yOffset = 0;
    1580             int indicatorWidth = pixelMetric(PM_ExclusiveIndicatorWidth);
    1581             int indicatorHeight = pixelMetric(PM_ExclusiveIndicatorWidth);
     1579            int indicatorWidth = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
     1580            int indicatorHeight = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
    15821581            if (ir.width() > indicatorWidth)
    15831582                xOffset += (ir.width() - indicatorWidth)/2;
     
    16281627                    popupPal.setColor(QPalette::Midlight, frame->palette.light().color());
    16291628                }
    1630                 if (use2000style && pe == PE_Frame && (frame->state & State_Raised))
     1629                if (pe == PE_Frame && (frame->state & State_Raised))
    16311630                    qDrawWinButton(p, frame->rect, popupPal, frame->state & State_Sunken);
    1632                 else if (use2000style && pe == PE_Frame && (frame->state & State_Sunken))
     1631                else if (pe == PE_Frame && (frame->state & State_Sunken))
    16331632                {
    16341633                    popupPal.setColor(QPalette::Midlight, frame->palette.background().color());
     
    17361735case PE_FrameDockWidget:
    17371736        if (qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
    1738             drawPrimitive(QStyle::PE_FrameWindow, opt, p, w);
     1737            proxy()->drawPrimitive(QStyle::PE_FrameWindow, opt, p, w);
    17391738        }
    17401739    break;
     
    17551754
    17561755            int space = 2;
    1757             int chunksize = pixelMetric(PM_ProgressBarChunkWidth, opt, w) - space;
     1756            int chunksize = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, w) - space;
    17581757            if (!vertical) {
    17591758                if (opt->rect.width() <= chunksize)
     
    17811780#endif // QT_NO_PROGRESSBAR
    17821781
    1783     case PE_FrameTabWidget:
    1784         if (use2000style) {
    1785             QRect rect = opt->rect;
    1786             QPalette pal = opt->palette;
    1787             qDrawWinButton(p, opt->rect, opt->palette, false, 0);
    1788             break;
    1789        }
     1782    case PE_FrameTabWidget: {
     1783        qDrawWinButton(p, opt->rect, opt->palette, false, 0);
     1784        break;
     1785    }
    17901786    default:
    17911787        QCommonStyle::drawPrimitive(pe, opt, p, w);
     
    18141810            QRect r = opt->rect;
    18151811            QStyleHintReturnMask mask;
    1816             if (styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
     1812            if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
    18171813                p->setClipRegion(mask.region);
    18181814            p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
     
    18461842
    18471843            // windows always has a check column, regardless whether we have an icon or not
    1848             int checkcol = qMax(menuitem->maxIconWidth, windowsCheckMarkWidth);
     1844            int checkcol = qMax<int>(menuitem->maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
    18491845
    18501846            QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
     
    18831879                QPixmap pixmap;
    18841880                if (checked)
    1885                     pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
     1881                    pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
    18861882                else
    1887                     pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode);
     1883                    pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
    18881884                int pixw = pixmap.width();
    18891885                int pixh = pixmap.height();
     
    19021898                if (act)
    19031899                    newMi.state |= State_On;
    1904                 newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + windowsItemFrame, menuitem->rect.y() + windowsItemFrame,
    1905                                                                               checkcol - 2 * windowsItemFrame, menuitem->rect.height() - 2*windowsItemFrame));
    1906                 drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
     1900                newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + QWindowsStylePrivate::windowsItemFrame,
     1901                                                                              menuitem->rect.y() + QWindowsStylePrivate::windowsItemFrame,
     1902                                                                              checkcol - 2 * QWindowsStylePrivate::windowsItemFrame,
     1903                                                                              menuitem->rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
     1904                proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
    19071905            }
    19081906            p->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color());
     
    19141912            }
    19151913
    1916             int xm = windowsItemFrame + checkcol + windowsItemHMargin;
     1914            int xm = QWindowsStylePrivate::windowsItemFrame + checkcol + QWindowsStylePrivate::windowsItemHMargin;
    19171915            int xpos = menuitem->rect.x() + xm;
    1918             QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
     1916            QRect textRect(xpos, y + QWindowsStylePrivate::windowsItemVMargin,
     1917                           w - xm - QWindowsStylePrivate::windowsRightBorder - tab + 1, h - 2 * QWindowsStylePrivate::windowsItemVMargin);
    19191918            QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
    19201919            QString s = menuitem->text;
     
    19231922                int t = s.indexOf(QLatin1Char('\t'));
    19241923                int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
    1925                 if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
     1924                if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
    19261925                    text_flags |= Qt::TextHideMnemonic;
    19271926                text_flags |= Qt::AlignLeft;
     
    19291928                    QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
    19301929                        QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
    1931                     if (dis && !act && styleHint(SH_EtchDisabledText, opt, widget)) {
     1930                    if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
    19321931                        p->setPen(menuitem->palette.light().color());
    19331932                        p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1));
     
    19411940                    font.setBold(true);
    19421941                p->setFont(font);
    1943                 if (dis && !act && styleHint(SH_EtchDisabledText, opt, widget)) {
     1942                if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
    19441943                    p->setPen(menuitem->palette.light().color());
    19451944                    p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t));
     
    19501949            }
    19511950            if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
    1952                 int dim = (h - 2 * windowsItemFrame) / 2;
     1951                int dim = (h - 2 * QWindowsStylePrivate::windowsItemFrame) / 2;
    19531952                PrimitiveElement arrow;
    19541953                arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
    1955                 xpos = x + w - windowsArrowHMargin - windowsItemFrame - dim;
     1954                xpos = x + w - QWindowsStylePrivate::windowsArrowHMargin - QWindowsStylePrivate::windowsItemFrame - dim;
    19561955                QRect  vSubMenuRect = visualRect(opt->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
    19571956                QStyleOptionMenuItem newMI = *menuitem;
     
    19611960                    newMI.palette.setColor(QPalette::ButtonText,
    19621961                                           newMI.palette.highlightedText().color());
    1963                 drawPrimitive(arrow, &newMI, p, widget);
     1962                proxy()->drawPrimitive(arrow, &newMI, p, widget);
    19641963            }
    19651964
     
    19831982                                   mbi->rect.height(), mbi->palette, active && down, 1, 0, &b);
    19841983                if (active && down) {
    1985                     newMbi.rect.translate(pixelMetric(PM_ButtonShiftHorizontal, mbi, widget),
    1986                                        pixelMetric(PM_ButtonShiftVertical, mbi, widget));
     1984                    newMbi.rect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, mbi, widget),
     1985                                       proxy()->pixelMetric(PM_ButtonShiftVertical, mbi, widget));
    19871986                    p->setBrushOrigin(p->brushOrigin() - QPoint(1, 1));
    19881987                }
     
    20182017                     && tab->selectedPosition
    20192018                            == QStyleOptionTab::PreviousIsSelected));
    2020             int tabBarAlignment = styleHint(SH_TabBar_Alignment, tab, widget);
     2019            int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
    20212020            bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
    20222021                                || (rtlHorTabs
     
    20322031            QColor shadow = tab->palette.shadow().color();
    20332032            QColor background = tab->palette.background().color();
    2034             int borderThinkness = pixelMetric(PM_TabBarBaseOverlap, tab, widget);
     2033            int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
    20352034            if (selected)
    20362035                borderThinkness /= 2;
     
    20632062                    p->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
    20642063                    p->drawPoint(x1 + 1, y1 + 1);
    2065                     if (!use2000style) {
    2066                         p->setPen(midlight);
    2067                         p->drawLine(x1 + 1, y1 + 2, x1 + 1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
    2068                     }
    20692064                }
    20702065                // Top
     
    20742069                    p->setPen(light);
    20752070                    p->drawLine(beg, y1, end, y1);
    2076                     if (!use2000style) {
    2077                         p->setPen(midlight);
    2078                         p->drawLine(beg, y1 + 1, end, y1 + 1);
    2079                     }
    20802071                }
    20812072                // Right
     
    21072098                    p->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
    21082099                    p->drawPoint(x1 + 1, y2 - 1);
    2109                     if (!use2000style) {
    2110                         p->setPen(midlight);
    2111                         p->drawLine(x1 + 1, y2 - 2, x1 + 1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
    2112                     }
    21132100                }
    21142101                // Bottom
     
    21492136                    p->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
    21502137                    p->drawPoint(x1 + 1, y1 + 1);
    2151                     if (!use2000style) {
    2152                         p->setPen(midlight);
    2153                         p->drawLine(x1 + 2, y1 + 1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1 + 1);
    2154                     }
    21552138                }
    21562139                // Left
     
    21602143                    p->setPen(light);
    21612144                    p->drawLine(x1, beg, x1, end);
    2162                     if (!use2000style) {
    2163                         p->setPen(midlight);
    2164                         p->drawLine(x1 + 1, beg, x1 + 1, end);
    2165                     }
    21662145                }
    21672146                // Bottom
     
    21952174                    p->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
    21962175                    p->drawPoint(x2 - 1, y1 + 1);
    2197                     if (!use2000style) {
    2198                         p->setPen(midlight);
    2199                         p->drawLine(x2 - 3, y1 + 1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1 + 1);
    2200                         p->drawPoint(x2 - 1, y1);
    2201                     }
    22022176                }
    22032177                // Right
     
    22362210    case CE_ScrollBarSubLine:
    22372211    case CE_ScrollBarAddLine: {
    2238         if (use2000style && (opt->state & State_Sunken)) {
     2212        if ((opt->state & State_Sunken)) {
    22392213            p->setPen(opt->palette.dark().color());
    22402214            p->setBrush(opt->palette.brush(QPalette::Button));
     
    22642238        QStyleOption arrowOpt = *opt;
    22652239        arrowOpt.rect = opt->rect.adjusted(4, 4, -4, -4);
    2266         drawPrimitive(arrow, &arrowOpt, p, widget);
     2240        proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
    22672241        break; }
    22682242    case CE_ScrollBarAddPage:
     
    23532327                    break;
    23542328                }
    2355                 if(QApplication::layoutDirection() == Qt::RightToLeft){ //reverse layout changes the order of Beginning/end
     2329                if(opt->direction == Qt::RightToLeft){ //reverse layout changes the order of Beginning/end
    23562330                    bool tmp = paintLeftBorder;
    23572331                    paintRightBorder=paintLeftBorder;
     
    24502424            if (pb->minimum == 0 && pb->maximum == 0) {
    24512425                Q_D(const QWindowsStyle);
    2452                 const int unit_width = pixelMetric(PM_ProgressBarChunkWidth, pb, widget);
     2426                const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget);
    24532427                QStyleOptionProgressBarV2 pbBits = *pb;
    24542428                Q_ASSERT(unit_width >0);
     
    24742448                    pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
    24752449                    pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
    2476                     drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
     2450                    proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
    24772451                    x += reverse ? -unit_width : unit_width;
    24782452                }
     
    24852459                        pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
    24862460                        pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
    2487                         drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
     2461                        proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
    24882462                        x += reverse ? -unit_width : unit_width;
    24892463                    }
     
    25242498            bool floating = false;
    25252499            bool active = dwOpt->state & State_Active;
    2526             int menuOffset = 0; //used to center text when floated
    25272500            QColor inactiveCaptionTextColor = d->inactiveCaptionText;
    25282501            if (dwOpt->movable) {
     
    25392512                        right = d->inactiveGradientCaptionColor;
    25402513                    }
    2541                     menuOffset = 2;
    25422514                    QBrush fillBrush(left);
    25432515                    if (left != right) {
     
    25732545                                    titleRect.height(), titleRect.width());
    25742546                }
    2575                 drawItemText(p, titleRect,
     2547                proxy()->drawItemText(p, titleRect,
    25762548                            Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, palette,
    25772549                            dwOpt->state & State_Enabled, dwOpt->title,
     
    26032575            = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
    26042576        bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
    2605         int m = pixelMetric(PM_DockWidgetTitleMargin, opt, w);
     2577        int m = proxy()->pixelMetric(PM_DockWidgetTitleMargin, opt, w);
    26062578        if (verticalTitleBar) {
    26072579            r.adjust(0, 0, 0, -m);
    26082580        } else {
    2609             if (QApplication::layoutDirection() == Qt::LeftToRight)
     2581            if (opt->direction == Qt::LeftToRight)
    26102582                r.adjust(m, 0, 0, 0);
    26112583            else
     
    26372609    case CC_Slider:
    26382610        if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
    2639             int thickness  = pixelMetric(PM_SliderControlThickness, slider, widget);
    2640             int len        = pixelMetric(PM_SliderLength, slider, widget);
     2611            int thickness  = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
     2612            int len        = proxy()->pixelMetric(PM_SliderLength, slider, widget);
    26412613            int ticks = slider->tickPosition;
    2642             QRect groove = subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
    2643             QRect handle = subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
     2614            QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
     2615            QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
    26442616
    26452617            if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
     
    27122684                    fropt.QStyleOption::operator=(*slider);
    27132685                    fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
    2714                     drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
     2686                    proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
    27152687                }
    27162688
     
    30242996                if (cmb->frame) {
    30252997                    QPalette shadePal = opt->palette;
    3026                     if (use2000style)
    3027                         shadePal.setColor(QPalette::Midlight, shadePal.button().color());
     2998                    shadePal.setColor(QPalette::Midlight, shadePal.button().color());
    30282999                    qDrawWinPanel(p, opt->rect, shadePal, true, &editBrush);
    30293000                }
     
    30353006                State flags = State_None;
    30363007
    3037                 QRect ar = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
     3008                QRect ar = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
    30383009                bool sunkenArrow = cmb->activeSubControls == SC_ComboBoxArrow
    30393010                                   && cmb->state & State_Sunken;
     
    30543025                if (opt->state & State_Enabled)
    30553026                    flags |= State_Enabled;
     3027                if (opt->state & State_HasFocus)
     3028                    flags |= State_HasFocus;
    30563029
    30573030                if (sunkenArrow)
     
    30613034                arrowOpt.palette = cmb->palette;
    30623035                arrowOpt.state = flags;
    3063                 drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
     3036                proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
    30643037            }
    30653038
    30663039            if (cmb->subControls & SC_ComboBoxEditField) {
    3067                 QRect re = subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
     3040                QRect re = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
    30683041                if (cmb->state & State_HasFocus && !cmb->editable)
    30693042                    p->fillRect(re.x(), re.y(), re.width(), re.height(),
     
    30853058                    focus.state |= State_FocusAtBorder;
    30863059                    focus.backgroundColor = cmb->palette.highlight().color();
    3087                     drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
     3060                    proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
    30883061                }
    30893062            }
     
    30993072            if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
    31003073                QBrush editBrush = sb->palette.brush(QPalette::Base);
    3101                 QRect r = subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);
     3074                QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);
    31023075                QPalette shadePal = sb->palette;
    3103                 if (use2000style)
    3104                     shadePal.setColor(QPalette::Midlight, shadePal.button().color());
     3076                shadePal.setColor(QPalette::Midlight, shadePal.button().color());
    31053077                qDrawWinPanel(p, r, shadePal, true, &editBrush);
    31063078            }
     
    31303102                                                                       : PE_IndicatorSpinUp);
    31313103
    3132                 copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);
     3104                copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);
    31333105                qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
    31343106                                &copy.palette.brush(QPalette::Button));
     
    31383110                    lightCopy.rect.adjust(1, 1, 1, 1);
    31393111                    lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
    3140                     drawPrimitive(pe, &lightCopy, p, widget);
    3141                 }
    3142                 drawPrimitive(pe, &copy, p, widget);
     3112                    proxy()->drawPrimitive(pe, &lightCopy, p, widget);
     3113                }
     3114                proxy()->drawPrimitive(pe, &copy, p, widget);
    31433115            }
    31443116
     
    31633135                                                                       : PE_IndicatorSpinDown);
    31643136
    3165                 copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
     3137                copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
    31663138                qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
    31673139                                &copy.palette.brush(QPalette::Button));
     
    31713143                    lightCopy.rect.adjust(1, 1, 1, 1);
    31723144                    lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
    3173                     drawPrimitive(pe, &lightCopy, p, widget);
    3174                 }
    3175                 drawPrimitive(pe, &copy, p, widget);
     3145                    proxy()->drawPrimitive(pe, &lightCopy, p, widget);
     3146                }
     3147                proxy()->drawPrimitive(pe, &copy, p, widget);
    31763148            }
    31773149        }
    31783150        break;
    31793151#endif // QT_NO_SPINBOX
     3152
    31803153    default:
    31813154        QCommonStyle::drawComplexControl(cc, opt, p, widget);
     
    31963169            int defwidth = 0;
    31973170            if (btn->features & QStyleOptionButton::AutoDefaultButton)
    3198                 defwidth = 2 * pixelMetric(PM_ButtonDefaultIndicator, btn, widget);
     3171                defwidth = 2 * proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget);
     3172            int minwidth = int(QStyleHelper::dpiScaled(75.));
     3173            int minheight = int(QStyleHelper::dpiScaled(23.));
     3174
    31993175#ifndef QT_QWS_SMALL_PUSHBUTTON
    3200             if (w < 75 + defwidth && !btn->text.isEmpty())
    3201                 w = 75 + defwidth;
    3202             if (h < 23 + defwidth)
    3203                 h = 23 + defwidth;
     3176            if (w < minwidth + defwidth && !btn->text.isEmpty())
     3177                w = minwidth + defwidth;
     3178            if (h < minheight + defwidth)
     3179                h = minheight + defwidth;
    32043180#endif
    32053181            sz = QSize(w, h);
     
    32133189
    32143190            if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
    3215                 sz = QSize(10, windowsSepHeight);
     3191                sz = QSize(10, QWindowsStylePrivate::windowsSepHeight);
    32163192            }
    32173193            else if (mi->icon.isNull()) {
     
    32213197
    32223198            if (mi->menuItemType != QStyleOptionMenuItem::Separator && !mi->icon.isNull()) {
    3223                 int iconExtent = pixelMetric(PM_SmallIconSize, opt, widget);
     3199                int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
    32243200                sz.setHeight(qMax(sz.height(),
    32253201                                  mi->icon.actualSize(QSize(iconExtent, iconExtent)).height()
    3226                                   + 2 * windowsItemFrame));
     3202                                  + 2 * QWindowsStylePrivate::windowsItemFrame));
    32273203            }
    32283204            int maxpmw = mi->maxIconWidth;
    3229             int tabSpacing = use2000style ? 20 :windowsTabSpacing;
     3205            int tabSpacing = 20;
    32303206            if (mi->text.contains(QLatin1Char('\t')))
    32313207                w += tabSpacing;
    32323208            else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
    3233                 w += 2 * windowsArrowHMargin;
     3209                w += 2 * QWindowsStylePrivate::windowsArrowHMargin;
    32343210            else if (mi->menuItemType == QStyleOptionMenuItem::DefaultItem) {
    32353211                // adjust the font and add the difference in size.
     
    32423218            }
    32433219
    3244             int checkcol = qMax(maxpmw, windowsCheckMarkWidth); // Windows always shows a check column
     3220            int checkcol = qMax<int>(maxpmw, QWindowsStylePrivate::windowsCheckMarkWidth); // Windows always shows a check column
    32453221            w += checkcol;
    3246             w += windowsRightBorder + 10;
     3222            w += QWindowsStylePrivate::windowsRightBorder + 10;
    32473223            sz.setWidth(w);
    32483224        }
     
    32523228    case CT_MenuBarItem:
    32533229        if (!sz.isEmpty())
    3254             sz += QSize(windowsItemHMargin * 4, windowsItemVMargin * 2);
     3230            sz += QSize(QWindowsStylePrivate::windowsItemHMargin * 4, QWindowsStylePrivate::windowsItemVMargin * 2);
    32553231        break;
    32563232#endif
     
    33813357                && pSHGetStockIconInfo)
    33823358            {
    3383                 icon.addPixmap(standardPixmap(SP_VistaShield, option, widget)); //fetches small icon
     3359                icon.addPixmap(proxy()->standardPixmap(SP_VistaShield, option, widget)); //fetches small icon
    33843360                QSHSTOCKICONINFO iconInfo; //append large icon
    33853361                memset(&iconInfo, 0, sizeof(iconInfo));
    33863362                iconInfo.cbSize = sizeof(iconInfo);
    33873363                if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_LARGEICON, &iconInfo) == S_OK) {
    3388                     icon.addPixmap(convertHIconToPixmap(iconInfo.hIcon));
     3364                    icon.addPixmap(QPixmap::fromWinHICON(iconInfo.hIcon));
    33893365                    DestroyIcon(iconInfo.hIcon);
    33903366                }
Note: See TracChangeset for help on using the changeset viewer.