Changeset 561 for trunk/src/gui/styles/qwindowsvistastyle.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/styles/qwindowsvistastyle.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 42 42 #include "qwindowsvistastyle.h" 43 43 #include "qwindowsvistastyle_p.h" 44 #include <private/qstylehelper_p.h> 44 45 45 46 #if !defined(QT_NO_STYLE_WINDOWSVISTA) || defined(QT_PLUGIN) … … 159 160 160 161 //convert Qt state flags to uxtheme button states 161 int buttonStateId(int flags, int partId)162 static int buttonStateId(int flags, int partId) 162 163 { 163 164 int stateId = 0; … … 190 191 } 191 192 192 void Animation::paint(QPainter *painter, const QStyleOption *option)193 void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option) 193 194 { 194 195 Q_UNUSED(option); … … 196 197 } 197 198 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 207 207 */ 208 209 void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) { 208 void QWindowsVistaAnimation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) { 210 209 if (_secondaryImage.isNull() || _primaryImage.isNull()) 211 210 return; … … 248 247 } 249 248 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. 256 253 */ 257 258 void Transition::paint(QPainter *painter, const QStyleOption *option) 254 void QWindowsVistaTransition::paint(QPainter *painter, const QStyleOption *option) 259 255 { 260 256 float alpha = 1.0; … … 278 274 } 279 275 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. 286 280 */ 287 288 289 void Pulse::paint(QPainter *painter, const QStyleOption *option) 281 void QWindowsVistaPulse::paint(QPainter *painter, const QStyleOption *option) 290 282 { 291 283 float alpha = 1.0; … … 308 300 309 301 /*! 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 332 330 */ 333 331 void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, 334 QPainter *painter, const QWidget *widget) const332 QPainter *painter, const QWidget *widget) const 335 333 { 336 334 QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func()); … … 367 365 w->setProperty("_q_stylerect", w->rect()); 368 366 369 bool doTransition = ((state & State_Sunken) != (oldState & State_Sunken) || 367 bool doTransition = oldState && 368 ((state & State_Sunken) != (oldState & State_Sunken) || 370 369 (state & State_On) != (oldState & State_On) || 371 370 (state & State_MouseOver) != (oldState & State_MouseOver)); … … 395 394 QPainter startPainter(&startImage); 396 395 397 Animation *anim = d->widgetAnimation(widget);398 Transition *t = newTransition;396 QWindowsVistaAnimation *anim = d->widgetAnimation(widget); 397 QWindowsVistaTransition *t = new QWindowsVistaTransition; 399 398 t->setWidget(w); 400 399 … … 404 403 405 404 if (!anim) 406 drawPrimitive(element, &opt, &startPainter, 0); // Note that the widget pointer is intentionally 0405 proxy()->drawPrimitive(element, &opt, &startPainter, 0); // Note that the widget pointer is intentionally 0 407 406 else // this ensures that we do not recurse in the animation logic above 408 407 anim->paint(&startPainter, &opt); … … 418 417 QStyleOption opt2 = opt; 419 418 opt2.state = option->state; 420 drawPrimitive(element, &opt2, &endPainter, 0); // Note that the widget pointer is intentionally 0419 proxy()->drawPrimitive(element, &opt2, &endPainter, 0); // Note that the widget pointer is intentionally 0 421 420 // this ensures that we do not recurse in the animation logic above 422 421 t->setEndImage(endImage); … … 488 487 { 489 488 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 } 491 495 int mid_h = option->rect.x() + option->rect.width() / 2; 492 496 int mid_v = option->rect.y() + option->rect.height() / 2; … … 528 532 case PE_IndicatorRadioButton: 529 533 { 530 if ( Animation *a = d->widgetAnimation(widget)) {534 if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) { 531 535 a->paint(painter, option); 532 536 } else { 533 537 QWindowsXPStyle::drawPrimitive(element, option, painter, widget); 534 538 } 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 else544 theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPERVERT, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2));545 d->drawBackground(theme);546 539 } 547 540 break; … … 646 639 } 647 640 if (panel->lineWidth > 0) 648 drawPrimitive(PE_FrameLineEdit, panel, painter, widget);641 proxy()->drawPrimitive(PE_FrameLineEdit, panel, painter, widget); 649 642 return; 650 643 } … … 652 645 653 646 case PE_FrameLineEdit: 654 if ( Animation *anim = d->widgetAnimation(widget)) {647 if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) { 655 648 anim->paint(painter, option); 656 649 } else { … … 695 688 break; 696 689 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 697 708 case PE_IndicatorToolBarSeparator: 698 709 { … … 721 732 const QStyleOptionViewItemV4 *vopt; 722 733 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 731 739 if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) { 732 740 bool selected = vopt->state & QStyle::State_Selected; … … 865 873 866 874 /*! 867 868 \reimp 875 \internal 869 876 870 877 see drawPrimitive for comments on the animation support 871 872 878 */ 873 879 void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption *option, … … 924 930 QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); 925 931 QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); 926 Animation *anim = d->widgetAnimation(widget);932 QWindowsVistaAnimation *anim = d->widgetAnimation(widget); 927 933 928 934 QStyleOptionButton opt = *button; … … 930 936 931 937 startImage.fill(0); 932 Transition *t = newTransition;938 QWindowsVistaTransition *t = new QWindowsVistaTransition; 933 939 t->setWidget(w); 934 940 QPainter startPainter(&startImage); 935 941 936 942 if (!anim) { 937 drawControl(element, &opt, &startPainter, 0 /* Intentional */);943 proxy()->drawControl(element, &opt, &startPainter, 0 /* Intentional */); 938 944 } else { 939 945 anim->paint(&startPainter, &opt); … … 946 952 endImage.fill(0); 947 953 QPainter endPainter(&endImage); 948 drawControl(element, option, &endPainter, 0 /* Intentional */);954 proxy()->drawControl(element, option, &endPainter, 0 /* Intentional */); 949 955 t->setEndImage(endImage); 950 956 int duration = 0; … … 967 973 { 968 974 969 if ( Animation *anim = d->widgetAnimation(widget)) {975 if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) { 970 976 anim->paint(painter, option); 971 977 } else { … … 994 1000 (state & State_Enabled) && (state & State_Active)) 995 1001 { 996 Animation *anim = d->widgetAnimation(widget);1002 QWindowsVistaAnimation *anim = d->widgetAnimation(widget); 997 1003 if (!anim && widget) { 998 1004 QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); … … 1001 1007 alternateImage.fill(0); 1002 1008 1003 Pulse *pulse = newPulse;1009 QWindowsVistaPulse *pulse = new QWindowsVistaPulse; 1004 1010 pulse->setWidget(const_cast<QWidget*>(widget)); 1005 1011 … … 1048 1054 QStyleOptionButton newBtn = *btn; 1049 1055 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), 1051 1058 mbiw + 1, mbih + 1)); 1052 drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);1059 proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget); 1053 1060 } 1054 1061 return; … … 1073 1080 if (((progressbar->value() > 0 && d->transitionsEnabled()) || isIndeterminate)) { 1074 1081 if (!d->widgetAnimation(progressbar) && progressbar->value() < progressbar->maximum()) { 1075 Animation *a = newAnimation;1082 QWindowsVistaAnimation *a = new QWindowsVistaAnimation; 1076 1083 a->setWidget(const_cast<QWidget*>(widget)); 1077 1084 a->setStartTime(QTime::currentTime()); … … 1085 1092 XPThemeData theme(widget, painter, QLatin1String("PROGRESS"), vertical ? PP_FILLVERT : PP_FILL); 1086 1093 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); 1088 1095 QTime current = QTime::currentTime(); 1089 1096 1090 1097 if (isIndeterminate) { 1091 if ( Animation *a = d->widgetAnimation(widget)) {1098 if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) { 1092 1099 int glowSize = 120; 1093 1100 int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width()); … … 1159 1166 d->drawBackground(theme); 1160 1167 1161 if ( Animation *a = d->widgetAnimation(widget)) {1168 if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) { 1162 1169 int glowSize = 140; 1163 1170 int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width()); … … 1198 1205 1199 1206 QPalette::ColorRole textRole = disabled ? QPalette::Text : QPalette::ButtonText; 1200 QPixmap pix = mbi->icon.pixmap(p ixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal);1207 QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal); 1201 1208 1202 1209 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)) 1204 1211 alignment |= Qt::TextHideMnemonic; 1205 1212 1206 1213 //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)); 1208 1215 d->drawBackground(theme); 1209 1216 … … 1230 1237 if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { 1231 1238 // 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 } 1233 1248 QColor darkLine = option->palette.background().color().darker(108); 1234 1249 QColor lightLine = option->palette.background().color().lighter(107); … … 1255 1270 QPoint p1 = QPoint(x + checkcol, yoff); 1256 1271 QPoint p2 = QPoint(x + w + 6 , yoff); 1257 int stateId =stateId = MBI_HOT;1272 stateId = MBI_HOT; 1258 1273 QRect subRect(p1.x(), p1.y(), p2.x() - p1.x(), 6); 1259 1274 subRect = QStyle::visualRect(option->direction, option->rect, subRect ); … … 1267 1282 1268 1283 if (act) { 1269 int stateId =stateId = MBI_HOT;1284 stateId = MBI_HOT; 1270 1285 XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_POPUPITEM, stateId, option->rect); 1271 1286 d->drawBackground(theme2); … … 1275 1290 XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND, 1276 1291 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 1277 1302 d->drawBackground(theme); 1303 1278 1304 if (menuitem->icon.isNull()) { 1305 checkRect = QRect(0, 0, size.cx, size.cy); 1306 checkRect.moveCenter(theme.rect.center()); 1307 theme.rect = checkRect; 1308 1279 1309 theme.partId = MENU_POPUPCHECK; 1280 1310 bool bullet = menuitem->checkType & QStyleOptionMenuItem::Exclusive; … … 1293 1323 QPixmap pixmap; 1294 1324 if (checked) 1295 pixmap = menuitem->icon.pixmap(p ixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On);1325 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On); 1296 1326 else 1297 pixmap = menuitem->icon.pixmap(p ixelMetric(PM_SmallIconSize, option, widget), mode);1327 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode); 1298 1328 int pixw = pixmap.width(); 1299 1329 int pixh = pixmap.height(); … … 1321 1351 int t = s.indexOf(QLatin1Char('\t')); 1322 1352 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)) 1324 1354 text_flags |= Qt::TextHideMnemonic; 1325 1355 text_flags |= Qt::AlignLeft; … … 1347 1377 newMI.rect = vSubMenuRect; 1348 1378 newMI.state = dis ? State_None : State_Enabled; 1349 drawPrimitive(arrow, &newMI, painter, widget);1379 proxy()->drawPrimitive(arrow, &newMI, painter, widget); 1350 1380 } 1351 1381 } … … 1372 1402 case CE_MenuBarEmptyArea: 1373 1403 { 1374 intstateId = MBI_NORMAL;1404 stateId = MBI_NORMAL; 1375 1405 if (!(state & State_Enabled)) 1376 1406 stateId = MBI_DISABLED; … … 1417 1447 1418 1448 int buttonMargin = 4; 1419 int mw = p ixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget);1420 int fw = p ixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget);1449 int mw = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget); 1450 int fw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget); 1421 1451 const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget); 1422 1452 bool isFloating = dw != 0 && dw->isFloating(); … … 1437 1467 if (isFloating) { 1438 1468 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()) 1440 1470 titleRect.adjust(titleRect.height() + mw, 0, 0, 0); 1441 1471 } else { … … 1464 1494 const QStyleOptionViewItemV4 *vopt; 1465 1495 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 1474 1501 if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) { 1475 1502 /* … … 1505 1532 1506 1533 /*! 1507 \ reimp1534 \internal 1508 1535 1509 1536 see drawPrimitive for comments on the animation support … … 1557 1584 if (qstyleoption_cast<const QStyleOptionSlider *>(option)) { 1558 1585 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); 1560 1587 w->setProperty("_q_stylesliderpos", currentPos); 1561 1588 if (oldSliderPos != currentPos) { … … 1577 1604 QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); 1578 1605 QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); 1579 Animation *anim = d->widgetAnimation(widget);1580 Transition *t = newTransition;1606 QWindowsVistaAnimation *anim = d->widgetAnimation(widget); 1607 QWindowsVistaTransition *t = new QWindowsVistaTransition; 1581 1608 t->setWidget(w); 1582 1609 if (!anim) { … … 1588 1615 startCombo.state = (QStyle::State)oldState; 1589 1616 startCombo.activeSubControls = (QStyle::SubControl)oldActiveControls; 1590 drawComplexControl(control, &startCombo, &startPainter, 0 /* Intentional */);1617 proxy()->drawComplexControl(control, &startCombo, &startPainter, 0 /* Intentional */); 1591 1618 t->setStartImage(startImage); 1592 1619 } else if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option)) { … … 1597 1624 startSlider.state = (QStyle::State)oldState; 1598 1625 startSlider.activeSubControls = (QStyle::SubControl)oldActiveControls; 1599 drawComplexControl(control, &startSlider, &startPainter, 0 /* Intentional */);1626 proxy()->drawComplexControl(control, &startSlider, &startPainter, 0 /* Intentional */); 1600 1627 t->setStartImage(startImage); 1601 1628 } else { … … 1615 1642 endImage.fill(0); 1616 1643 QPainter endPainter(&endImage); 1617 drawComplexControl(control, option, &endPainter, 0 /* Intentional */);1644 proxy()->drawComplexControl(control, option, &endPainter, 0 /* Intentional */); 1618 1645 t->setEndImage(endImage); 1619 1646 t->setStartTime(QTime::currentTime()); … … 1625 1652 } 1626 1653 1627 if ( Animation *anim = d->widgetAnimation(widget)) {1654 if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) { 1628 1655 anim->paint(painter, option); 1629 1656 return; … … 1654 1681 } 1655 1682 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); 1657 1684 XPThemeData theme(widget, painter, QLatin1String("COMBOBOX")); 1658 theme.rect = sub ControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget);1685 theme.rect = subRect; 1659 1686 partId = option->direction == Qt::RightToLeft ? CP_DROPDOWNBUTTONLEFT : CP_DROPDOWNBUTTONRIGHT; 1660 1687 … … 1680 1707 if (sub & SC_ComboBoxArrow) 1681 1708 btn.features = QStyleOptionButton::HasMenu; 1682 drawControl(QStyle::CE_PushButton, &btn, painter, widget);1709 proxy()->drawControl(QStyle::CE_PushButton, &btn, painter, widget); 1683 1710 } 1684 1711 } … … 1697 1724 bool isRTL = option->direction == Qt::RightToLeft; 1698 1725 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); 1700 1727 partId = SBP_ARROWBTN; 1701 1728 if (!(flags & State_Enabled)) … … 1714 1741 } 1715 1742 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); 1717 1744 partId = SBP_ARROWBTN; 1718 1745 if (!(flags & State_Enabled)) … … 1731 1758 } 1732 1759 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)); 1736 1763 partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT; 1737 1764 stateId = SCRBS_DISABLED; … … 1741 1768 } else { 1742 1769 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); 1744 1771 partId = flags & State_Horizontal ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT; 1745 1772 if (!(flags & State_Enabled)) … … 1756 1783 } 1757 1784 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); 1759 1786 partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT; 1760 1787 if (!(flags & State_Enabled)) … … 1771 1798 } 1772 1799 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); 1774 1801 if (!(flags & State_Enabled)) 1775 1802 stateId = SCRBS_DISABLED; … … 1784 1811 1785 1812 // Draw handle 1786 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);1813 theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); 1787 1814 theme.partId = flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT; 1788 1815 theme.stateId = stateId; … … 1852 1879 } 1853 1880 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); 1855 1882 partId = SPNP_UP; 1856 1883 if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) || !(flags & State_Enabled)) … … 1867 1894 } 1868 1895 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); 1870 1897 partId = SPNP_DOWN; 1871 1898 if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) || !(flags & State_Enabled)) … … 1891 1918 1892 1919 /*! 1893 \ reimp1920 \internal 1894 1921 */ 1895 1922 QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption *option, … … 1926 1953 case CT_MenuItem: 1927 1954 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 1929 1966 if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { 1930 int minimumHeight = qMax<qint32>(22, sz.height());1931 1967 if (menuitem->menuItemType != QStyleOptionMenuItem::Separator) 1932 1968 sz.setHeight(minimumHeight); … … 1948 1984 //Spinbox adds frame twice 1949 1985 sz = QWindowsStyle::sizeFromContents(type, option, size, widget); 1950 int border = p ixelMetric(PM_SpinBoxFrameWidth, option, widget);1986 int border = proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget); 1951 1987 sz -= QSize(2*border, 2*border); 1952 1988 } … … 1959 1995 1960 1996 /*! 1961 \ reimp1997 \internal 1962 1998 */ 1963 1999 QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const … … 1974 2010 HTHEME theme = pOpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"Button"); 1975 2011 if (theme) { 1976 int stateId ;2012 int stateId = PBS_NORMAL; 1977 2013 if (!(option->state & State_Enabled)) 1978 2014 stateId = PBS_DISABLED; … … 1983 2019 else if (btn->features & QStyleOptionButton::DefaultButton) 1984 2020 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); 1989 2023 rect = option->rect.adjusted(border, border, -border, -border); 1990 2024 … … 2013 2047 int x = option->rect.x(); 2014 2048 int y = option->rect.y(); 2015 int margin = p ixelMetric(QStyle::PM_HeaderMargin, option, widget);2049 int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget); 2016 2050 2017 2051 XPThemeData theme(widget, 0, QLatin1String("HEADER"), HP_HEADERSORTARROW, HSAS_SORTEDDOWN, option->rect); … … 2039 2073 case SE_HeaderLabel: 2040 2074 { 2041 int margin = p ixelMetric(QStyle::PM_HeaderMargin, option, widget);2075 int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget); 2042 2076 QRect r = option->rect; 2043 2077 r.setRect(option->rect.x() + margin, option->rect.y() + margin, … … 2057 2091 break; 2058 2092 case SE_ItemViewItemDecoration: 2059 if ( const QStyleOptionViewItemV4 *vopt =qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))2093 if (qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) 2060 2094 rect.adjust(-2, 0, 2, 0); 2061 2095 break; … … 2130 2164 2131 2165 2132 /*! \ reimp*/2166 /*! \internal */ 2133 2167 int QWindowsVistaStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, 2134 2168 QStyleHintReturn *returnData) const … … 2164 2198 2165 2199 /*! 2166 \ reimp2200 \internal 2167 2201 */ 2168 2202 QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option, … … 2184 2218 int margin = cb->frame ? 3 : 0; 2185 2219 int bmarg = cb->frame ? 2 : 0; 2186 xpos += wi - bmarg - 16; 2220 int arrowButtonWidth = bmarg + 16; 2221 xpos += wi - arrowButtonWidth; 2187 2222 2188 2223 switch (subControl) { … … 2191 2226 break; 2192 2227 case SC_ComboBoxArrow: 2193 rect.setRect( cb->editable ? xpos : 0, y , wi - xpos, he);2228 rect.setRect(xpos, y , arrowButtonWidth, he); 2194 2229 break; 2195 2230 case SC_ComboBoxEditField: … … 2215 2250 int buttonWidth = GetSystemMetrics(SM_CXSIZE) - 4; 2216 2251 2217 const int frameWidth = p ixelMetric(PM_MdiSubWindowFrameWidth, option, widget);2252 const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget); 2218 2253 const bool sysmenuHint = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0; 2219 2254 const bool minimizeHint = (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) != 0; … … 2252 2287 const int controlTop = 6; 2253 2288 const int controlHeight = height - controlTop - 3; 2254 int iconExtent = p ixelMetric(PM_SmallIconSize);2289 int iconExtent = proxy()->pixelMetric(PM_SmallIconSize); 2255 2290 QSize iconSize = tb->icon.actualSize(QSize(iconExtent, iconExtent)); 2256 2291 if (tb->icon.isNull()) … … 2263 2298 } 2264 2299 break; 2300 default: 2301 break; 2265 2302 } 2266 2303 } … … 2273 2310 2274 2311 /*! 2275 \ reimp2312 \internal 2276 2313 */ 2277 2314 bool QWindowsVistaStyle::event(QEvent *e) … … 2296 2333 2297 2334 /*! 2298 \ reimp2335 \internal 2299 2336 */ 2300 2337 QStyle::SubControl QWindowsVistaStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, … … 2308 2345 2309 2346 /*! 2310 \ reimp2347 \internal 2311 2348 */ 2312 2349 int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const … … 2318 2355 2319 2356 case PM_DockWidgetTitleBarButtonMargin: 2320 return 5;2357 return int(QStyleHelper::dpiScaled(5.)); 2321 2358 case PM_ScrollBarSliderMin: 2322 return 18;2359 return int(QStyleHelper::dpiScaled(18.)); 2323 2360 case PM_MenuHMargin: 2324 2361 case PM_MenuVMargin: … … 2333 2370 2334 2371 /*! 2335 \ reimp2372 \internal 2336 2373 */ 2337 2374 QPalette QWindowsVistaStyle::standardPalette() const … … 2341 2378 2342 2379 /*! 2343 \ reimp2380 \internal 2344 2381 */ 2345 2382 void QWindowsVistaStyle::polish(QApplication *app) … … 2349 2386 2350 2387 /*! 2351 \ reimp2388 \internal 2352 2389 */ 2353 2390 void QWindowsVistaStyle::polish(QWidget *widget) … … 2397 2434 tree->viewport()->setAttribute(Qt::WA_Hover); 2398 2435 } 2436 else if (QListView *list = qobject_cast<QListView *> (widget)) { 2437 list->viewport()->setAttribute(Qt::WA_Hover); 2438 } 2399 2439 } 2400 2440 2401 2441 /*! 2402 \ reimp2442 \internal 2403 2443 */ 2404 2444 void QWindowsVistaStyle::unpolish(QWidget *widget) … … 2433 2473 tree->viewport()->setAttribute(Qt::WA_Hover, false); 2434 2474 } else if (qobject_cast<QCommandLinkButton*>(widget)) { 2435 QFont font = qApp->font("QCommandLinkButton");2475 QFont font = QApplication::font("QCommandLinkButton"); 2436 2476 QFont widgetFont = widget->font(); 2437 2477 widgetFont.setFamily(font.family()); //Only family set by polish … … 2442 2482 2443 2483 /*! 2444 \ reimp2484 \internal 2445 2485 */ 2446 2486 void QWindowsVistaStyle::unpolish(QApplication *app) … … 2450 2490 2451 2491 /*! 2452 \ reimp2492 \internal 2453 2493 */ 2454 2494 void QWindowsVistaStyle::polish(QPalette &pal) … … 2459 2499 2460 2500 /*! 2461 \ reimp2501 \internal 2462 2502 */ 2463 2503 QPixmap QWindowsVistaStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option, … … 2495 2535 !QWindowsVistaStylePrivate::useVista()) 2496 2536 { 2497 Animation *a = animations.takeAt(i);2537 QWindowsVistaAnimation *a = animations.takeAt(i); 2498 2538 delete a; 2499 2539 } … … 2508 2548 for (int i = animations.size() - 1 ; i >= 0 ; --i) { 2509 2549 if (animations[i]->widget() == w) { 2510 Animation *a = animations.takeAt(i);2550 QWindowsVistaAnimation *a = animations.takeAt(i); 2511 2551 delete a; 2512 2552 break; … … 2515 2555 } 2516 2556 2517 void QWindowsVistaStylePrivate::startAnimation( Animation *t)2557 void QWindowsVistaStylePrivate::startAnimation(QWindowsVistaAnimation *t) 2518 2558 { 2519 2559 Q_Q(QWindowsVistaStyle); … … 2528 2568 { 2529 2569 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)) 2533 2571 { 2534 2572 if (animEnabled) … … 2539 2577 2540 2578 2541 Animation * QWindowsVistaStylePrivate::widgetAnimation(const QWidget *widget) const2579 QWindowsVistaAnimation * QWindowsVistaStylePrivate::widgetAnimation(const QWidget *widget) const 2542 2580 { 2543 2581 if (!widget) 2544 2582 return 0; 2545 foreach ( Animation *a, animations) {2583 foreach (QWindowsVistaAnimation *a, animations) { 2546 2584 if (a->widget() == widget) 2547 2585 return a;
Note:
See TracChangeset
for help on using the changeset viewer.