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/qwindowsvistastyle.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 "qwindowsvistastyle.h"
    4343#include "qwindowsvistastyle_p.h"
     44#include <private/qstylehelper_p.h>
    4445
    4546#if !defined(QT_NO_STYLE_WINDOWSVISTA) || defined(QT_PLUGIN)
     
    159160
    160161//convert Qt state flags to uxtheme button states
    161 int buttonStateId(int flags, int partId)
     162static int buttonStateId(int flags, int partId)
    162163{
    163164    int stateId = 0;
     
    190191}
    191192
    192 void Animation::paint(QPainter *painter, const QStyleOption *option)
     193void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option)
    193194{
    194195    Q_UNUSED(option);
     
    196197}
    197198
    198 /*
    199 * ! \internal
    200 *
    201 * Helperfunction to paint the current transition state
    202 * between two animation frames.
    203 *
    204 * The result is a blended image consisting of
    205 * ((alpha)*_primaryImage) + ((1-alpha)*_secondaryImage)
    206 *
     199/*! \internal
     200
     201  Helperfunction to paint the current transition state between two
     202  animation frames.
     203
     204  The result is a blended image consisting of ((alpha)*_primaryImage)
     205  + ((1-alpha)*_secondaryImage)
     206
    207207*/
    208 
    209 void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) {
     208void QWindowsVistaAnimation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) {
    210209    if (_secondaryImage.isNull() || _primaryImage.isNull())
    211210        return;
     
    248247}
    249248
    250 /*
    251 * ! \internal
    252 *
    253 * Paints a transition state. The result will be a mix between the
    254 * initial and final state of the transition, depending on the
    255 * time difference between _startTime and current time.
     249/*! \internal
     250  Paints a transition state. The result will be a mix between the
     251  initial and final state of the transition, depending on the time
     252  difference between _startTime and current time.
    256253*/
    257 
    258 void Transition::paint(QPainter *painter, const QStyleOption *option)
     254void QWindowsVistaTransition::paint(QPainter *painter, const QStyleOption *option)
    259255{
    260256    float alpha = 1.0;
     
    278274}
    279275
    280 /*
    281 * ! \internal
    282 *
    283 * Paints a pulse. The result will be a mix between the
    284 * primary and secondary pulse images depending on the
    285 * time difference between _startTime and current time.
     276/*! \internal
     277  Paints a pulse. The result will be a mix between the primary and
     278  secondary pulse images depending on the time difference between
     279  _startTime and current time.
    286280*/
    287 
    288 
    289 void Pulse::paint(QPainter *painter, const QStyleOption *option)
     281void QWindowsVistaPulse::paint(QPainter *painter, const QStyleOption *option)
    290282{
    291283    float alpha = 1.0;
     
    308300
    309301/*!
    310  \reimp
    311  *
    312  * Animations are used for some state transitions on specific widgets.
    313  *
    314  * Only one running animation can exist for a widget at any specific time.
    315  * Animations can be added through QWindowsVistaStylePrivate::startAnimation(Animation *)
    316  * and any existing animation on a widget can be retrieved with
    317  * QWindowsVistaStylePrivate::widgetAnimation(Widget *).
    318  *
    319  * Once an animation has been started, QWindowsVistaStylePrivate::timerEvent(QTimerEvent *)
    320  * will continuously call update() on the widget until it is stopped, meaning that drawPrimitive
    321  * will be called many times until the transition has completed. During this time, the result
    322  * will be retrieved by the Animation::paint(...) function and not by the style itself.
    323  *
    324  * To determine if a transition should occur, the style needs to know the previous state of the
    325  * widget as well as the current one. This is solved by updating dynamic properties on the widget
    326  * every time the function is called.
    327  *
    328  * Transitions interrupting existing transitions should always be smooth, so whenever a hover-transition
    329  * is started on a pulsating button, it uses the current frame of the pulse-animation as the
    330  * starting image for the hover transition.
    331  *
     302 \internal
     303 
     304  Animations are used for some state transitions on specific widgets.
     305 
     306  Only one running animation can exist for a widget at any specific
     307  time.  Animations can be added through
     308  QWindowsVistaStylePrivate::startAnimation(Animation *) and any
     309  existing animation on a widget can be retrieved with
     310  QWindowsVistaStylePrivate::widgetAnimation(Widget *).
     311 
     312  Once an animation has been started,
     313  QWindowsVistaStylePrivate::timerEvent(QTimerEvent *) will
     314  continuously call update() on the widget until it is stopped,
     315  meaning that drawPrimitive will be called many times until the
     316  transition has completed. During this time, the result will be
     317  retrieved by the Animation::paint(...) function and not by the style
     318  itself.
     319 
     320  To determine if a transition should occur, the style needs to know
     321  the previous state of the widget as well as the current one. This is
     322  solved by updating dynamic properties on the widget every time the
     323  function is called.
     324 
     325  Transitions interrupting existing transitions should always be
     326  smooth, so whenever a hover-transition is started on a pulsating
     327  button, it uses the current frame of the pulse-animation as the
     328  starting image for the hover transition.
     329 
    332330 */
    333331void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
    334                                     QPainter *painter, const QWidget *widget) const
     332                                       QPainter *painter, const QWidget *widget) const
    335333{
    336334    QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
     
    367365            w->setProperty("_q_stylerect", w->rect());
    368366
    369             bool doTransition = ((state & State_Sunken)     != (oldState & State_Sunken) ||
     367            bool doTransition = oldState &&
     368                                ((state & State_Sunken)     != (oldState & State_Sunken) ||
    370369                                 (state & State_On)         != (oldState & State_On)     ||
    371370                                 (state & State_MouseOver)  != (oldState & State_MouseOver));
     
    395394                QPainter startPainter(&startImage);
    396395
    397                 Animation *anim = d->widgetAnimation(widget);
    398                 Transition *t = new Transition;
     396                QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
     397                QWindowsVistaTransition *t = new QWindowsVistaTransition;
    399398                t->setWidget(w);
    400399
     
    404403
    405404                if (!anim)
    406                     drawPrimitive(element, &opt, &startPainter, 0); // Note that the widget pointer is intentionally 0
     405                    proxy()->drawPrimitive(element, &opt, &startPainter, 0); // Note that the widget pointer is intentionally 0
    407406                else                                               // this ensures that we do not recurse in the animation logic above
    408407                    anim->paint(&startPainter, &opt);
     
    418417                QStyleOption opt2 = opt;
    419418                opt2.state = option->state;
    420                 drawPrimitive(element, &opt2, &endPainter, 0); // Note that the widget pointer is intentionally 0
     419                proxy()->drawPrimitive(element, &opt2, &endPainter, 0); // Note that the widget pointer is intentionally 0
    421420                                                              // this ensures that we do not recurse in the animation logic above
    422421                t->setEndImage(endImage);
     
    488487        {
    489488            XPThemeData theme(d->treeViewHelper(), painter, QLatin1String("TREEVIEW"));
    490             static const int decoration_size = 16;
     489            static int decoration_size = 0;
     490            if (theme.isValid() && !decoration_size) {
     491                SIZE size;
     492                pGetThemePartSize(theme.handle(), 0, TVP_HOTGLYPH, GLPS_OPENED, 0, TS_TRUE, &size);
     493                decoration_size = qMax(size.cx, size.cy);
     494            }
    491495            int mid_h = option->rect.x() + option->rect.width() / 2;
    492496            int mid_v = option->rect.y() + option->rect.height() / 2;
     
    528532    case PE_IndicatorRadioButton:
    529533        {
    530             if (Animation *a = d->widgetAnimation(widget)) {
     534            if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) {
    531535                a->paint(painter, option);
    532536            } else {
    533537                QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
    534538            }
    535         }
    536         break;
    537 
    538     case PE_IndicatorToolBarHandle:
    539         {
    540             XPThemeData theme;
    541             if (option->state & State_Horizontal)
    542                 theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPER, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2));
    543             else
    544                 theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPERVERT, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2));
    545             d->drawBackground(theme);
    546539        }
    547540        break;
     
    646639            }
    647640            if (panel->lineWidth > 0)
    648                 drawPrimitive(PE_FrameLineEdit, panel, painter, widget);
     641                proxy()->drawPrimitive(PE_FrameLineEdit, panel, painter, widget);
    649642            return;
    650643        }
     
    652645
    653646    case PE_FrameLineEdit:
    654         if (Animation *anim = d->widgetAnimation(widget)) {
     647        if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) {
    655648            anim->paint(painter, option);
    656649        } else {
     
    695688        break;
    696689
     690    case PE_IndicatorToolBarHandle:
     691        {
     692            XPThemeData theme;
     693            QRect rect;
     694            if (option->state & State_Horizontal) {
     695                theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPER, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2));
     696                rect = option->rect.adjusted(0, 1, 0, -2);
     697                rect.setWidth(4);
     698            } else {
     699                theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPERVERT, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2));
     700                rect = option->rect.adjusted(1, 0, -1, 0);
     701                rect.setHeight(4);
     702            }
     703            theme.rect = rect;
     704            d->drawBackground(theme);
     705        }
     706        break;
     707
    697708    case PE_IndicatorToolBarSeparator:
    698709        {
     
    721732            const QStyleOptionViewItemV4 *vopt;
    722733            const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
    723             bool newStyle = false;
    724 
    725             if (const QListView *listview = qobject_cast<const QListView *>(widget)) {
    726                 if (listview->viewMode() == QListView::IconMode)
    727                     newStyle = true;
    728             } else if (const QTreeView* treeview = qobject_cast<const QTreeView *>(widget)) {
    729                 newStyle = true;
    730             }
     734            bool newStyle = true;
     735
     736            if (qobject_cast<const QTableView*>(widget))
     737                newStyle = false;
     738
    731739            if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) {
    732740                bool selected = vopt->state & QStyle::State_Selected;
     
    865873
    866874/*!
    867 
    868  \reimp
     875 \internal
    869876
    870877 see drawPrimitive for comments on the animation support
    871 
    872878 */
    873879void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption *option,
     
    924930                    QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
    925931                    QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
    926                     Animation *anim = d->widgetAnimation(widget);
     932                    QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
    927933
    928934                    QStyleOptionButton opt = *button;
     
    930936
    931937                    startImage.fill(0);
    932                     Transition *t = new Transition;
     938                    QWindowsVistaTransition *t = new QWindowsVistaTransition;
    933939                    t->setWidget(w);
    934940                    QPainter startPainter(&startImage);
    935941
    936942                    if (!anim) {
    937                         drawControl(element, &opt, &startPainter, 0 /* Intentional */);
     943                        proxy()->drawControl(element, &opt, &startPainter, 0 /* Intentional */);
    938944                    } else {
    939945                        anim->paint(&startPainter, &opt);
     
    946952                    endImage.fill(0);
    947953                    QPainter endPainter(&endImage);
    948                     drawControl(element, option, &endPainter, 0 /* Intentional */);
     954                    proxy()->drawControl(element, option, &endPainter, 0 /* Intentional */);
    949955                    t->setEndImage(endImage);
    950956                    int duration = 0;
     
    967973        {
    968974
    969             if (Animation *anim = d->widgetAnimation(widget)) {
     975            if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) {
    970976                anim->paint(painter, option);
    971977            } else {
     
    9941000                         (state & State_Enabled) && (state & State_Active))
    9951001                        {
    996                         Animation *anim = d->widgetAnimation(widget);
     1002                        QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
    9971003                        if (!anim && widget) {
    9981004                            QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
     
    10011007                            alternateImage.fill(0);
    10021008
    1003                             Pulse *pulse = new Pulse;
     1009                            QWindowsVistaPulse *pulse = new QWindowsVistaPulse;
    10041010                            pulse->setWidget(const_cast<QWidget*>(widget));
    10051011
     
    10481054                QStyleOptionButton newBtn = *btn;
    10491055                newBtn.rect = QStyle::visualRect(option->direction, option->rect,
    1050                                                 QRect(ir.right() - mbiw - 2, (option->rect.height()/2) - (mbih/2),
     1056                                                QRect(ir.right() - mbiw - 2,
     1057                                                      option->rect.top() + (option->rect.height()/2) - (mbih/2),
    10511058                                                      mbiw + 1, mbih + 1));
    1052                 drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
     1059                proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
    10531060            }
    10541061            return;
     
    10731080                if (((progressbar->value() > 0  && d->transitionsEnabled()) || isIndeterminate)) {
    10741081                    if (!d->widgetAnimation(progressbar) && progressbar->value() < progressbar->maximum()) {
    1075                         Animation *a = new Animation;
     1082                        QWindowsVistaAnimation *a = new QWindowsVistaAnimation;
    10761083                        a->setWidget(const_cast<QWidget*>(widget));
    10771084                        a->setStartTime(QTime::currentTime());
     
    10851092            XPThemeData theme(widget, painter, QLatin1String("PROGRESS"), vertical ? PP_FILLVERT : PP_FILL);
    10861093            theme.rect = option->rect;
    1087             bool reverse = bar->direction == Qt::LeftToRight && inverted || bar->direction == Qt::RightToLeft && !inverted;
     1094            bool reverse = (bar->direction == Qt::LeftToRight && inverted) || (bar->direction == Qt::RightToLeft && !inverted);
    10881095            QTime current = QTime::currentTime();
    10891096
    10901097            if (isIndeterminate) {
    1091                 if (Animation *a = d->widgetAnimation(widget)) {
     1098                if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) {
    10921099                    int glowSize = 120;
    10931100                    int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
     
    11591166                d->drawBackground(theme);
    11601167
    1161                 if (Animation *a = d->widgetAnimation(widget)) {
     1168                if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) {
    11621169                    int glowSize = 140;
    11631170                    int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
     
    11981205
    11991206            QPalette::ColorRole textRole = disabled ? QPalette::Text : QPalette::ButtonText;
    1200             QPixmap pix = mbi->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal);
     1207            QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal);
    12011208
    12021209            uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
    1203             if (!styleHint(SH_UnderlineShortcut, mbi, widget))
     1210            if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
    12041211                alignment |= Qt::TextHideMnemonic;
    12051212
    12061213            //The rect adjustment is a workaround for the menu not really filling its background.
    1207             XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_BARBACKGROUND, 0, option->rect.adjusted(-1, 1 , 2, 1));
     1214            XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_BARBACKGROUND, 0, option->rect.adjusted(-1, 0, 2, 1));
    12081215            d->drawBackground(theme);
    12091216
     
    12301237        if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
    12311238            // windows always has a check column, regardless whether we have an icon or not
    1232             int checkcol = qMax(menuitem->maxIconWidth, 28);
     1239            int checkcol = 28;
     1240            {
     1241                SIZE    size;
     1242                MARGINS margins;
     1243                XPThemeData theme(widget, 0, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND, MBI_HOT);
     1244                pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size);
     1245                pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0, TMT_CONTENTMARGINS, NULL, &margins);
     1246                checkcol = qMax(menuitem->maxIconWidth, int(6 + size.cx + margins.cxLeftWidth + margins.cxRightWidth));
     1247            }
    12331248            QColor darkLine = option->palette.background().color().darker(108);
    12341249            QColor lightLine = option->palette.background().color().lighter(107);
     
    12551270                QPoint p1 = QPoint(x + checkcol, yoff);
    12561271                QPoint p2 = QPoint(x + w + 6 , yoff);
    1257                 int stateId = stateId = MBI_HOT;
     1272                stateId = MBI_HOT;
    12581273                QRect subRect(p1.x(), p1.y(), p2.x() - p1.x(), 6);
    12591274                subRect  = QStyle::visualRect(option->direction, option->rect, subRect );
     
    12671282
    12681283            if (act) {
    1269                 int stateId = stateId = MBI_HOT;
     1284                stateId = MBI_HOT;
    12701285                XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_POPUPITEM, stateId, option->rect);
    12711286                d->drawBackground(theme2);
     
    12751290                XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND,
    12761291                                  menuitem->icon.isNull() ? MBI_HOT : MBI_PUSHED, vCheckRect);
     1292                SIZE    size;
     1293                MARGINS margins;
     1294                pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size);
     1295                pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0,
     1296                                TMT_CONTENTMARGINS, NULL, &margins);
     1297                QRect checkRect(0, 0, size.cx + margins.cxLeftWidth + margins.cxRightWidth ,
     1298                                size.cy + margins.cyBottomHeight + margins.cyTopHeight);
     1299                checkRect.moveCenter(vCheckRect.center());
     1300                theme.rect = checkRect;
     1301
    12771302                d->drawBackground(theme);
     1303
    12781304                if (menuitem->icon.isNull()) {
     1305                    checkRect = QRect(0, 0, size.cx, size.cy);
     1306                    checkRect.moveCenter(theme.rect.center());
     1307                    theme.rect = checkRect;
     1308
    12791309                    theme.partId = MENU_POPUPCHECK;
    12801310                    bool bullet = menuitem->checkType & QStyleOptionMenuItem::Exclusive;
     
    12931323                QPixmap pixmap;
    12941324                if (checked)
    1295                     pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On);
     1325                    pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On);
    12961326                else
    1297                     pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), mode);
     1327                    pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode);
    12981328                int pixw = pixmap.width();
    12991329                int pixh = pixmap.height();
     
    13211351                int t = s.indexOf(QLatin1Char('\t'));
    13221352                int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
    1323                 if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
     1353                if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
    13241354                    text_flags |= Qt::TextHideMnemonic;
    13251355                text_flags |= Qt::AlignLeft;
     
    13471377                newMI.rect = vSubMenuRect;
    13481378                newMI.state = dis ? State_None : State_Enabled;
    1349                 drawPrimitive(arrow, &newMI, painter, widget);
     1379                proxy()->drawPrimitive(arrow, &newMI, painter, widget);
    13501380            }
    13511381        }
     
    13721402    case CE_MenuBarEmptyArea:
    13731403        {
    1374             int stateId = MBI_NORMAL;
     1404            stateId = MBI_NORMAL;
    13751405            if (!(state & State_Enabled))
    13761406                stateId = MBI_DISABLED;
     
    14171447
    14181448            int buttonMargin = 4;
    1419             int mw = pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget);
    1420             int fw = pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget);
     1449            int mw = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget);
     1450            int fw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget);
    14211451            const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget);
    14221452            bool isFloating = dw != 0 && dw->isFloating();
     
    14371467            if (isFloating) {
    14381468                titleRect.adjust(0, -fw, 0, 0);
    1439                 if (widget != 0 && widget->windowIcon().cacheKey() != qApp->windowIcon().cacheKey())
     1469                if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey())
    14401470                    titleRect.adjust(titleRect.height() + mw, 0, 0, 0);
    14411471            } else {
     
    14641494            const QStyleOptionViewItemV4 *vopt;
    14651495            const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
    1466             bool newStyle = false;
    1467 
    1468             if (const QListView *listview = qobject_cast<const QListView *>(widget)) {
    1469                 if (listview->viewMode() == QListView::IconMode)
    1470                     newStyle = true;
    1471             } else if (const QTreeView* treeview = qobject_cast<const QTreeView *>(widget)) {
    1472                 newStyle = true;
    1473             }
     1496            bool newStyle = true;
     1497
     1498            if (qobject_cast<const QTableView*>(widget))
     1499                newStyle = false;
     1500
    14741501            if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) {
    14751502                /*
     
    15051532
    15061533/*!
    1507   \reimp
     1534  \internal
    15081535
    15091536  see drawPrimitive for comments on the animation support
     
    15571584            if (qstyleoption_cast<const QStyleOptionSlider *>(option)) {
    15581585                QRect oldSliderPos = w->property("_q_stylesliderpos").toRect();
    1559                 QRect currentPos = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
     1586                QRect currentPos = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
    15601587                w->setProperty("_q_stylesliderpos", currentPos);
    15611588                if (oldSliderPos != currentPos) {
     
    15771604                QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
    15781605                QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
    1579                 Animation *anim = d->widgetAnimation(widget);
    1580                 Transition *t = new Transition;
     1606                QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
     1607                QWindowsVistaTransition *t = new QWindowsVistaTransition;
    15811608                t->setWidget(w);
    15821609                if (!anim) {
     
    15881615                        startCombo.state = (QStyle::State)oldState;
    15891616                        startCombo.activeSubControls = (QStyle::SubControl)oldActiveControls;
    1590                         drawComplexControl(control, &startCombo, &startPainter, 0 /* Intentional */);
     1617                        proxy()->drawComplexControl(control, &startCombo, &startPainter, 0 /* Intentional */);
    15911618                        t->setStartImage(startImage);
    15921619                    } else if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option)) {
     
    15971624                        startSlider.state = (QStyle::State)oldState;
    15981625                        startSlider.activeSubControls = (QStyle::SubControl)oldActiveControls;
    1599                         drawComplexControl(control, &startSlider, &startPainter, 0 /* Intentional */);
     1626                        proxy()->drawComplexControl(control, &startSlider, &startPainter, 0 /* Intentional */);
    16001627                        t->setStartImage(startImage);
    16011628                    } else {
     
    16151642                endImage.fill(0);
    16161643                QPainter endPainter(&endImage);
    1617                 drawComplexControl(control, option, &endPainter, 0 /* Intentional */);
     1644                proxy()->drawComplexControl(control, option, &endPainter, 0 /* Intentional */);
    16181645                t->setEndImage(endImage);
    16191646                t->setStartTime(QTime::currentTime());
     
    16251652            }
    16261653
    1627             if (Animation *anim = d->widgetAnimation(widget)) {
     1654            if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) {
    16281655                anim->paint(painter, option);
    16291656                return;
     
    16541681                }
    16551682                if (sub & SC_ComboBoxArrow) {
    1656                     QRect subRect = subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget);
     1683                    QRect subRect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget);
    16571684                    XPThemeData theme(widget, painter, QLatin1String("COMBOBOX"));
    1658                     theme.rect = subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget);
     1685                    theme.rect = subRect;
    16591686                    partId = option->direction == Qt::RightToLeft ? CP_DROPDOWNBUTTONLEFT : CP_DROPDOWNBUTTONRIGHT;
    16601687
     
    16801707                    if (sub & SC_ComboBoxArrow)
    16811708                        btn.features = QStyleOptionButton::HasMenu;
    1682                     drawControl(QStyle::CE_PushButton, &btn, painter, widget);
     1709                    proxy()->drawControl(QStyle::CE_PushButton, &btn, painter, widget);
    16831710                }
    16841711            }
     
    16971724            bool isRTL  = option->direction == Qt::RightToLeft;
    16981725            if (sub & SC_ScrollBarAddLine) {
    1699                 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget);
     1726                theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget);
    17001727                partId = SBP_ARROWBTN;
    17011728                if (!(flags & State_Enabled))
     
    17141741            }
    17151742            if (sub & SC_ScrollBarSubLine) {
    1716                 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget);
     1743                theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget);
    17171744                partId = SBP_ARROWBTN;
    17181745                if (!(flags & State_Enabled))
     
    17311758            }
    17321759            if (maxedOut) {
    1733                 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
    1734                 theme.rect = theme.rect.united(subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget));
    1735                 theme.rect = theme.rect.united(subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget));
     1760                theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
     1761                theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget));
     1762                theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget));
    17361763                partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
    17371764                stateId = SCRBS_DISABLED;
     
    17411768            } else {
    17421769                if (sub & SC_ScrollBarSubPage) {
    1743                     theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget);
     1770                    theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget);
    17441771                    partId = flags & State_Horizontal ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT;
    17451772                    if (!(flags & State_Enabled))
     
    17561783                }
    17571784                if (sub & SC_ScrollBarAddPage) {
    1758                     theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget);
     1785                    theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget);
    17591786                    partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
    17601787                    if (!(flags & State_Enabled))
     
    17711798                }
    17721799                if (sub & SC_ScrollBarSlider) {
    1773                     theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
     1800                    theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
    17741801                    if (!(flags & State_Enabled))
    17751802                        stateId = SCRBS_DISABLED;
     
    17841811
    17851812                    // Draw handle
    1786                     theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
     1813                    theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
    17871814                    theme.partId = flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT;
    17881815                    theme.stateId = stateId;
     
    18521879            }
    18531880            if (sub & SC_SpinBoxUp) {
    1854                 theme.rect = subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget).adjusted(0, 0, 0, 1);
     1881                theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget).adjusted(0, 0, 0, 1);
    18551882                partId = SPNP_UP;
    18561883                if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) || !(flags & State_Enabled))
     
    18671894            }
    18681895            if (sub & SC_SpinBoxDown) {
    1869                 theme.rect = subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
     1896                theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
    18701897                partId = SPNP_DOWN;
    18711898                if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) || !(flags & State_Enabled))
     
    18911918
    18921919/*!
    1893  \reimp
     1920 \internal
    18941921 */
    18951922QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
     
    19261953    case CT_MenuItem:
    19271954        sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget);
    1928         sz.rwidth() += 28;
     1955        int minimumHeight;
     1956        {
     1957            SIZE    size;
     1958            MARGINS margins;
     1959            XPThemeData theme(widget, 0, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND, MBI_HOT);
     1960            pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size);
     1961            pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0, TMT_CONTENTMARGINS, NULL, &margins);
     1962            minimumHeight = qMax<qint32>(size.cy + margins.cyBottomHeight+ margins.cyTopHeight, sz.height());
     1963            sz.rwidth() += size.cx + margins.cxLeftWidth + margins.cxRightWidth;
     1964        }
     1965       
    19291966        if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
    1930             int minimumHeight = qMax<qint32>(22, sz.height());
    19311967            if (menuitem->menuItemType != QStyleOptionMenuItem::Separator)
    19321968                sz.setHeight(minimumHeight);
     
    19481984            //Spinbox adds frame twice
    19491985            sz = QWindowsStyle::sizeFromContents(type, option, size, widget);
    1950             int border = pixelMetric(PM_SpinBoxFrameWidth, option, widget);
     1986            int border = proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget);
    19511987            sz -= QSize(2*border, 2*border);
    19521988        }
     
    19591995
    19601996/*!
    1961  \reimp
     1997 \internal
    19621998 */
    19631999QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
     
    19742010            HTHEME theme = pOpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"Button");
    19752011            if (theme) {
    1976                 int stateId;
     2012                int stateId = PBS_NORMAL;
    19772013                if (!(option->state & State_Enabled))
    19782014                    stateId = PBS_DISABLED;
     
    19832019                else if (btn->features & QStyleOptionButton::DefaultButton)
    19842020                    stateId = PBS_DEFAULTED;
    1985                 else
    1986                     stateId = PBS_NORMAL;
    1987 
    1988                 int border = pixelMetric(PM_DefaultFrameWidth, btn, widget);
     2021
     2022                int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
    19892023                rect = option->rect.adjusted(border, border, -border, -border);
    19902024
     
    20132047            int x = option->rect.x();
    20142048            int y = option->rect.y();
    2015             int margin = pixelMetric(QStyle::PM_HeaderMargin, option, widget);
     2049            int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget);
    20162050
    20172051            XPThemeData theme(widget, 0, QLatin1String("HEADER"), HP_HEADERSORTARROW, HSAS_SORTEDDOWN, option->rect);
     
    20392073    case SE_HeaderLabel:
    20402074        {
    2041             int margin = pixelMetric(QStyle::PM_HeaderMargin, option, widget);
     2075            int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget);
    20422076            QRect r = option->rect;
    20432077            r.setRect(option->rect.x() + margin, option->rect.y() + margin,
     
    20572091        break;
    20582092    case SE_ItemViewItemDecoration:
    2059         if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))
     2093        if (qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))
    20602094            rect.adjust(-2, 0, 2, 0);
    20612095        break;
     
    21302164
    21312165
    2132 /*! \reimp */
     2166/*! \internal */
    21332167int QWindowsVistaStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
    21342168                             QStyleHintReturn *returnData) const
     
    21642198
    21652199/*!
    2166  \reimp
     2200 \internal
    21672201 */
    21682202QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
     
    21842218            int margin = cb->frame ? 3 : 0;
    21852219            int bmarg = cb->frame ? 2 : 0;
    2186             xpos += wi - bmarg - 16;
     2220            int arrowButtonWidth = bmarg + 16;
     2221            xpos += wi - arrowButtonWidth;
    21872222
    21882223            switch (subControl) {
     
    21912226                break;
    21922227            case SC_ComboBoxArrow:
    2193                 rect.setRect(cb->editable ? xpos : 0, y , wi - xpos, he);
     2228                rect.setRect(xpos, y , arrowButtonWidth, he);
    21942229                break;
    21952230            case SC_ComboBoxEditField:
     
    22152250            int buttonWidth = GetSystemMetrics(SM_CXSIZE) - 4;
    22162251
    2217             const int frameWidth = pixelMetric(PM_MdiSubWindowFrameWidth, option, widget);
     2252            const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget);
    22182253            const bool sysmenuHint  = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0;
    22192254            const bool minimizeHint = (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) != 0;
     
    22522287                    const int controlTop = 6;
    22532288                    const int controlHeight = height - controlTop - 3;
    2254                     int iconExtent = pixelMetric(PM_SmallIconSize);
     2289                    int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
    22552290                    QSize iconSize = tb->icon.actualSize(QSize(iconExtent, iconExtent));
    22562291                    if (tb->icon.isNull())
     
    22632298                }
    22642299                break;
     2300            default:
     2301                break;
    22652302            }
    22662303        }
     
    22732310
    22742311/*!
    2275  \reimp
     2312 \internal
    22762313 */
    22772314bool QWindowsVistaStyle::event(QEvent *e)
     
    22962333
    22972334/*!
    2298  \reimp
     2335 \internal
    22992336 */
    23002337QStyle::SubControl QWindowsVistaStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
     
    23082345
    23092346/*!
    2310  \reimp
     2347 \internal
    23112348 */
    23122349int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
     
    23182355
    23192356    case PM_DockWidgetTitleBarButtonMargin:
    2320         return 5;
     2357        return int(QStyleHelper::dpiScaled(5.));
    23212358    case PM_ScrollBarSliderMin:
    2322         return 18;
     2359        return int(QStyleHelper::dpiScaled(18.));
    23232360    case PM_MenuHMargin:
    23242361    case PM_MenuVMargin:
     
    23332370
    23342371/*!
    2335  \reimp
     2372 \internal
    23362373 */
    23372374QPalette QWindowsVistaStyle::standardPalette() const
     
    23412378
    23422379/*!
    2343  \reimp
     2380 \internal
    23442381 */
    23452382void QWindowsVistaStyle::polish(QApplication *app)
     
    23492386
    23502387/*!
    2351  \reimp
     2388 \internal
    23522389 */
    23532390void QWindowsVistaStyle::polish(QWidget *widget)
     
    23972434        tree->viewport()->setAttribute(Qt::WA_Hover);
    23982435    }
     2436    else if (QListView *list = qobject_cast<QListView *> (widget)) {
     2437        list->viewport()->setAttribute(Qt::WA_Hover);
     2438    }
    23992439}
    24002440
    24012441/*!
    2402  \reimp
     2442 \internal
    24032443 */
    24042444void QWindowsVistaStyle::unpolish(QWidget *widget)
     
    24332473        tree->viewport()->setAttribute(Qt::WA_Hover, false);
    24342474    } else if (qobject_cast<QCommandLinkButton*>(widget)) {
    2435         QFont font = qApp->font("QCommandLinkButton");
     2475        QFont font = QApplication::font("QCommandLinkButton");
    24362476        QFont widgetFont = widget->font();
    24372477        widgetFont.setFamily(font.family()); //Only family set by polish
     
    24422482
    24432483/*!
    2444  \reimp
     2484 \internal
    24452485 */
    24462486void QWindowsVistaStyle::unpolish(QApplication *app)
     
    24502490
    24512491/*!
    2452  \reimp
     2492 \internal
    24532493 */
    24542494void QWindowsVistaStyle::polish(QPalette &pal)
     
    24592499
    24602500/*!
    2461  \reimp
     2501 \internal
    24622502 */
    24632503QPixmap QWindowsVistaStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option,
     
    24952535            !QWindowsVistaStylePrivate::useVista())
    24962536        {
    2497             Animation *a = animations.takeAt(i);
     2537            QWindowsVistaAnimation *a = animations.takeAt(i);
    24982538            delete a;
    24992539        }
     
    25082548    for (int i = animations.size() - 1 ; i >= 0 ; --i) {
    25092549        if (animations[i]->widget() == w) {
    2510             Animation *a = animations.takeAt(i);
     2550            QWindowsVistaAnimation *a = animations.takeAt(i);
    25112551            delete a;
    25122552            break;
     
    25152555}
    25162556
    2517 void QWindowsVistaStylePrivate::startAnimation(Animation *t)
     2557void QWindowsVistaStylePrivate::startAnimation(QWindowsVistaAnimation *t)
    25182558{
    25192559    Q_Q(QWindowsVistaStyle);
     
    25282568{
    25292569    BOOL animEnabled = false;
    2530     if (QT_WA_INLINE(SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &animEnabled, 0),
    2531                      SystemParametersInfoA(SPI_GETCLIENTAREAANIMATION, 0, &animEnabled, 0)
    2532     ))
     2570    if (SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &animEnabled, 0))
    25332571    {
    25342572        if (animEnabled)
     
    25392577
    25402578
    2541 Animation * QWindowsVistaStylePrivate::widgetAnimation(const QWidget *widget) const
     2579QWindowsVistaAnimation * QWindowsVistaStylePrivate::widgetAnimation(const QWidget *widget) const
    25422580{
    25432581    if (!widget)
    25442582        return 0;
    2545     foreach (Animation *a, animations) {
     2583    foreach (QWindowsVistaAnimation *a, animations) {
    25462584        if (a->widget() == widget)
    25472585            return a;
Note: See TracChangeset for help on using the changeset viewer.