Changeset 561 for trunk/src/gui/styles/qplastiquestyle.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/qplastiquestyle.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 ** … … 44 44 #if !defined(QT_NO_STYLE_PLASTIQUE) || defined(QT_PLUGIN) 45 45 46 static bool UsePixmapCache = true;47 46 static const bool AnimateBusyProgressBar = true; 48 47 static const bool AnimateProgressBar = false; … … 52 51 53 52 #include "qwindowsstyle_p.h" 53 #include <private/qstylehelper_p.h> 54 54 #include <qapplication.h> 55 55 #include <qbitmap.h> … … 99 99 static const int windowsArrowHMargin = 6; // arrow horizontal margin 100 100 static const int windowsTabSpacing = 12; // space between text and tab 101 static const int windowsCheckMarkHMargin = 2; // horiz. margins of check mark102 101 static const int windowsRightBorder = 15; // right border on windows 103 102 static const int windowsCheckMarkWidth = 12; // checkmarks width on windows … … 491 490 QPixmap pixmap; 492 491 QString name = QString::fromLatin1("qbrushtexture-alpha-%1-%2").arg(alpha).arg(texture.cacheKey()); 493 if ( UsePixmapCache &&!QPixmapCache::find(name, pixmap)) {492 if (!QPixmapCache::find(name, pixmap)) { 494 493 QImage image = texture.toImage(); 495 494 QRgb *rgb = reinterpret_cast<QRgb *>(image.bits()); … … 552 551 QPixmap pixmap; 553 552 QString name = QString::fromLatin1("qbrushtexture-light-%1-%2").arg(light).arg(texture.cacheKey()); 554 if ( UsePixmapCache &&!QPixmapCache::find(name, pixmap)) {553 if (!QPixmapCache::find(name, pixmap)) { 555 554 QImage image = texture.toImage(); 556 555 QRgb *rgb = reinterpret_cast<QRgb *>(image.bits()); … … 611 610 QPixmap pixmap; 612 611 QString name = QString::fromLatin1("qbrushtexture-dark-%1-%2").arg(dark).arg(brush.texture().cacheKey()); 613 if ( UsePixmapCache &&!QPixmapCache::find(name, pixmap)) {612 if (!QPixmapCache::find(name, pixmap)) { 614 613 QImage image = texture.toImage(); 615 614 QRgb *rgb = reinterpret_cast<QRgb *>(image.bits()); … … 731 730 } 732 731 733 static QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)734 {735 QString tmp;736 const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option);737 tmp.sprintf("%s-%d-%d-%d-%lld-%dx%d", key.toLatin1().constData(), uint(option->state),738 option->direction, complexOption ? uint(complexOption->activeSubControls) : uint(0),739 option->palette.cacheKey(), size.width(), size.height());740 return tmp;741 }742 743 732 static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart, 744 733 const QColor &gradientStop) … … 750 739 QRect r = rect; 751 740 752 bool doPixmapCache = UsePixmapCache 753 && painter->deviceTransform().isIdentity() 741 bool doPixmapCache = painter->deviceTransform().isIdentity() 754 742 && painter->worldMatrix().isIdentity(); 755 743 if (doPixmapCache && QPixmapCache::find(gradientName, cache)) { … … 1006 994 #endif 1007 995 { 1008 if (!qgetenv("QT_STYLE_NO_PIXMAPCACHE").isNull())1009 UsePixmapCache = false;1010 996 } 1011 997 … … 1071 1057 frameOpt.lineWidth = q->pixelMetric(QStyle::PM_DefaultFrameWidth); 1072 1058 frameOpt.midLineWidth = 0; 1073 frameOpt.state |= QStyle::State_Sunken; 1059 frameOpt.state = option->state | QStyle::State_Sunken; 1060 frameOpt.palette = option->palette; 1074 1061 q->drawPrimitive(QStyle::PE_PanelLineEdit, &frameOpt, painter, widget); 1075 1062 painter->restore(); … … 1108 1095 QColor gradientStartColor = option->palette.button().color().lighter(104); 1109 1096 QColor gradientStopColor = option->palette.button().color().darker(105); 1110 QColor baseGradientStartColor = option->palette.base().color().darker(101);1111 QColor baseGradientStopColor = option->palette.base().color().darker(106);1112 1097 QColor highlightedGradientStartColor = option->palette.button().color().lighter(101); 1113 1098 QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85); … … 1133 1118 switch (element) { 1134 1119 case PE_IndicatorButtonDropDown: 1135 drawPrimitive(PE_PanelButtonTool, option, painter, widget);1120 proxy()->drawPrimitive(PE_PanelButtonTool, option, painter, widget); 1136 1121 break; 1137 1122 case PE_FrameDefaultButton: { … … 1179 1164 } 1180 1165 1181 int borderThickness = p ixelMetric(PM_TabBarBaseOverlap, twf, widget);1166 int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, twf, widget); 1182 1167 bool reverse = (twf->direction == Qt::RightToLeft); 1183 1168 … … 1358 1343 } else { 1359 1344 frameV2.state &= ~(State_Sunken | State_HasFocus); 1360 drawPrimitive(PE_Frame, &frameV2, painter, widget);1345 proxy()->drawPrimitive(PE_Frame, &frameV2, painter, widget); 1361 1346 } 1362 1347 } … … 1516 1501 } 1517 1502 #endif 1518 QString pixmapName = uniqueName(QLatin1String("toolbarhandle"), option, rect.size());1519 if (! UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) {1503 QString pixmapName = QStyleHelper::uniqueName(QLatin1String("toolbarhandle"), option, rect.size()); 1504 if (!QPixmapCache::find(pixmapName, cache)) { 1520 1505 cache = QPixmap(rect.size()); 1521 1506 cache.fill(Qt::transparent); … … 1547 1532 } 1548 1533 cachePainter.end(); 1549 if (UsePixmapCache) 1550 QPixmapCache::insert(pixmapName, cache); 1534 QPixmapCache::insert(pixmapName, cache); 1551 1535 } 1552 1536 painter->drawPixmap(rect.topLeft(), cache); … … 1858 1842 button.QStyleOption::operator=(*option); 1859 1843 button.state &= ~State_MouseOver; 1860 drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget);1844 proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); 1861 1845 break; 1862 1846 } … … 1864 1848 painter->save(); 1865 1849 bool active = (option->state & State_Active); 1866 int titleBarStop = option->rect.top() + p ixelMetric(PM_TitleBarHeight, option, widget);1850 int titleBarStop = option->rect.top() + proxy()->pixelMetric(PM_TitleBarHeight, option, widget); 1867 1851 1868 1852 QPalette palette = option->palette; … … 1993 1977 adjustedRect.right() - adjustedRect.left() - 1, 1994 1978 adjustedRect.bottom() - adjustedRect.top() - 1); 1995 qt_plastique_draw_gradient(painter, gradientRect, baseGradientStartColor, baseGradientStopColor); 1979 if (option->palette.base().style() == Qt::SolidPattern) { 1980 QColor baseGradientStartColor = option->palette.base().color().darker(101); 1981 QColor baseGradientStopColor = option->palette.base().color().darker(106); 1982 qt_plastique_draw_gradient(painter, gradientRect, baseGradientStartColor, baseGradientStopColor); 1983 } else { 1984 painter->fillRect(gradientRect, option->palette.base()); 1985 } 1996 1986 // draw "+" or "-" 1997 1987 painter->setPen(alphaTextColor); … … 2074 2064 bool reverseShadow = false; 2075 2065 2076 int borderThickness = p ixelMetric(PM_TabBarBaseOverlap, tab, widget);2066 int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget); 2077 2067 int marginLeft = 0; 2078 2068 if ((atBeginning && !selected) || (selected && leftCornerWidget && ((tab->position == QStyleOptionTab::Beginning) || onlyTab))) { … … 2586 2576 } 2587 2577 2588 double vc6_workaround = ((bar->progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * rect.width()); 2589 int progressIndicatorPos = int(vc6_workaround); 2578 int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum) * rect.width(); 2590 2579 2591 2580 bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted) … … 2647 2636 if (vertical) { 2648 2637 rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height 2649 QTransform m; 2650 m.translate(rect.height()-1, 0); 2638 QTransform m = QTransform::fromTranslate(rect.height()-1, 0); 2651 2639 m.rotate(90.0); 2652 2640 painter->setTransform(m, true); … … 2783 2771 painter->setPen(QPen()); 2784 2772 2785 QString progressBarName = uniqueName(QLatin1String("progressBarContents"),2773 QString progressBarName = QStyleHelper::uniqueName(QLatin1String("progressBarContents"), 2786 2774 option, rect.size()); 2787 2775 QPixmap cache; 2788 if ( (!UsePixmapCache || !QPixmapCache::find(progressBarName, cache)) && rect.height() > 7) {2776 if (!QPixmapCache::find(progressBarName, cache) && rect.height() > 7) { 2789 2777 QSize size = rect.size(); 2790 2778 cache = QPixmap(QSize(size.width() - 6 + 30, size.height() - 6)); … … 2819 2807 } 2820 2808 2821 if (UsePixmapCache) 2822 QPixmapCache::insert(progressBarName, cache); 2809 QPixmapCache::insert(progressBarName, cache); 2823 2810 } 2824 2811 painter->setClipRect(progressBar.adjusted(1, 0, -1, -1)); … … 2844 2831 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { 2845 2832 QPixmap cache; 2846 QString pixmapName = uniqueName(QLatin1String("headersection"), option, option->rect.size());2847 pixmapName += Q Latin1String("-") + QString::number(int(header->position));2848 pixmapName += Q Latin1String("-") + QString::number(int(header->orientation));2849 2850 if (! UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) {2833 QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size()); 2834 pixmapName += QString::number(- int(header->position)); 2835 pixmapName += QString::number(- int(header->orientation)); 2836 2837 if (!QPixmapCache::find(pixmapName, cache)) { 2851 2838 cache = QPixmap(option->rect.size()); 2852 2839 cache.fill(Qt::white); … … 2892 2879 2893 2880 cachePainter.end(); 2894 if (UsePixmapCache) 2895 QPixmapCache::insert(pixmapName, cache); 2881 QPixmapCache::insert(pixmapName, cache); 2896 2882 } 2897 2883 painter->drawPixmap(option->rect.topLeft(), cache); … … 2916 2902 if (!menuItem->text.isEmpty()) { 2917 2903 painter->setFont(menuItem->font); 2918 drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,2904 proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, 2919 2905 menuItem->palette, menuItem->state & State_Enabled, menuItem->text, 2920 2906 QPalette::Text); … … 2959 2945 button.state |= State_On; 2960 2946 button.palette = menuItem->palette; 2961 drawPrimitive(PE_IndicatorRadioButton, &button, painter, widget);2947 proxy()->drawPrimitive(PE_IndicatorRadioButton, &button, painter, widget); 2962 2948 } else { 2963 2949 if (menuItem->icon.isNull()) { … … 2968 2954 button.state |= State_On; 2969 2955 button.palette = menuItem->palette; 2970 drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget);2956 proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); 2971 2957 } else if (checked) { 2972 2958 int iconSize = qMax(menuItem->maxIconWidth, 20); … … 3080 3066 else 3081 3067 newMI.palette.setColor(QPalette::ButtonText, textBrush.color()); 3082 drawPrimitive(arrow, &newMI, painter, widget);3068 proxy()->drawPrimitive(arrow, &newMI, painter, widget); 3083 3069 } 3084 3070 … … 3092 3078 if ((option->state & State_Selected)) { 3093 3079 QPixmap cache; 3094 QString pixmapName = uniqueName(QLatin1String("menubaritem"), option, option->rect.size());3095 if (! UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) {3080 QString pixmapName = QStyleHelper::uniqueName(QLatin1String("menubaritem"), option, option->rect.size()); 3081 if (!QPixmapCache::find(pixmapName, cache)) { 3096 3082 cache = QPixmap(option->rect.size()); 3097 3083 cache.fill(Qt::white); … … 3143 3129 cachePainter.drawLines(lines, 2); 3144 3130 cachePainter.end(); 3145 if (UsePixmapCache) 3146 QPixmapCache::insert(pixmapName, cache); 3131 QPixmapCache::insert(pixmapName, cache); 3147 3132 } 3148 3133 painter->drawPixmap(option->rect.topLeft(), cache); … … 3329 3314 // Draw the text centered 3330 3315 QFont font = painter->font(); 3331 font.setPointSize( font.pointSize() - 1);3316 font.setPointSize(QFontInfo(font).pointSize() - 1); 3332 3317 painter->setFont(font); 3333 3318 painter->setPen(dockWidget->palette.windowText().color()); … … 3456 3441 bool sunken = scrollBar->state & State_Sunken; 3457 3442 3458 QString addLinePixmapName = uniqueName(QLatin1String("scrollbar_addline"), option, option->rect.size());3443 QString addLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_addline"), option, option->rect.size()); 3459 3444 QPixmap cache; 3460 if (! UsePixmapCache || !QPixmapCache::find(addLinePixmapName, cache)) {3445 if (!QPixmapCache::find(addLinePixmapName, cache)) { 3461 3446 cache = QPixmap(option->rect.size()); 3462 3447 cache.fill(Qt::white); … … 3517 3502 } 3518 3503 addLinePainter.end(); 3519 if (UsePixmapCache) 3520 QPixmapCache::insert(addLinePixmapName, cache); 3504 QPixmapCache::insert(addLinePixmapName, cache); 3521 3505 } 3522 3506 painter->drawPixmap(option->rect.topLeft(), cache); … … 3529 3513 bool horizontal = scrollBar->orientation == Qt::Horizontal; 3530 3514 3531 QString groovePixmapName = uniqueName(QLatin1String("scrollbar_groove"), option, option->rect.size());3515 QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_groove"), option, option->rect.size()); 3532 3516 if (sunken) 3533 3517 groovePixmapName += QLatin1String("-sunken"); … … 3536 3520 3537 3521 QPixmap cache; 3538 if (! UsePixmapCache || !QPixmapCache::find(groovePixmapName, cache)) {3522 if (!QPixmapCache::find(groovePixmapName, cache)) { 3539 3523 cache = QPixmap(option->rect.size()); 3540 3524 cache.fill(option->palette.background().color()); … … 3562 3546 3563 3547 groovePainter.end(); 3564 if (UsePixmapCache) 3565 QPixmapCache::insert(groovePixmapName, cache); 3548 QPixmapCache::insert(groovePixmapName, cache); 3566 3549 } 3567 3550 painter->drawPixmap(option->rect.topLeft(), cache); … … 3580 3563 QRect button1; 3581 3564 QRect button2; 3582 int scrollBarExtent = p ixelMetric(PM_ScrollBarExtent, option, widget);3565 int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget); 3583 3566 if (horizontal) { 3584 3567 button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(), scrollBarExtent, scrollBarSubLine.height()); … … 3589 3572 } 3590 3573 3591 QString subLinePixmapName = uniqueName(QLatin1String("scrollbar_subline"), option, button1.size());3574 QString subLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_subline"), option, button1.size()); 3592 3575 QPixmap cache; 3593 if (! UsePixmapCache || !QPixmapCache::find(subLinePixmapName, cache)) {3576 if (!QPixmapCache::find(subLinePixmapName, cache)) { 3594 3577 cache = QPixmap(button1.size()); 3595 3578 cache.fill(Qt::white); … … 3651 3634 } 3652 3635 subLinePainter.end(); 3653 if (UsePixmapCache) 3654 QPixmapCache::insert(subLinePixmapName, cache); 3636 QPixmapCache::insert(subLinePixmapName, cache); 3655 3637 } 3656 3638 painter->drawPixmap(button1.topLeft(), cache); … … 3665 3647 // The slider 3666 3648 if (option->rect.isValid()) { 3667 QString sliderPixmapName = uniqueName(QLatin1String("scrollbar_slider"), option, option->rect.size());3649 QString sliderPixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_slider"), option, option->rect.size()); 3668 3650 if (horizontal) 3669 3651 sliderPixmapName += QLatin1String("-horizontal"); 3670 3652 3671 3653 QPixmap cache; 3672 if (! UsePixmapCache || !QPixmapCache::find(sliderPixmapName, cache)) {3654 if (!QPixmapCache::find(sliderPixmapName, cache)) { 3673 3655 cache = QPixmap(option->rect.size()); 3674 3656 cache.fill(Qt::white); … … 3721 3703 sliderPainter.drawLines(lines, 2); 3722 3704 3723 int sliderMinLength = p ixelMetric(PM_ScrollBarSliderMin, scrollBar, widget);3705 int sliderMinLength = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget); 3724 3706 if ((horizontal && scrollBar->rect.width() > sliderMinLength) 3725 3707 || (!horizontal && scrollBar->rect.height() > sliderMinLength)) { … … 3741 3723 sliderPainter.end(); 3742 3724 // insert the slider into the cache 3743 if (UsePixmapCache) 3744 QPixmapCache::insert(sliderPixmapName, cache); 3725 QPixmapCache::insert(sliderPixmapName, cache); 3745 3726 } 3746 3727 painter->drawPixmap(option->rect.topLeft(), cache); … … 3761 3742 } else if (!comboBox->currentIcon.isNull()) { 3762 3743 { 3763 QRect editRect = subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget);3744 QRect editRect = proxy()->subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget); 3764 3745 if (comboBox->direction == Qt::RightToLeft) 3765 3746 editRect.adjust(0, 2, -2, -2); … … 3774 3755 QRect iconRect(editRect); 3775 3756 iconRect.setWidth(comboBox->iconSize.width() + 5); 3776 iconRect = alignedRect( QApplication::layoutDirection(),3757 iconRect = alignedRect(comboBox->direction, 3777 3758 Qt::AlignLeft | Qt::AlignVCenter, 3778 3759 iconRect.size(), editRect); 3779 3760 painter->fillRect(iconRect, option->palette.brush(QPalette::Base)); 3780 drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);3761 proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); 3781 3762 } 3782 3763 painter->restore(); … … 3821 3802 case CC_Slider: 3822 3803 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { 3823 QRect grooveRegion = subControlRect(CC_Slider, option, SC_SliderGroove, widget);3824 QRect handle = subControlRect(CC_Slider, option, SC_SliderHandle, widget);3825 QRect ticks = subControlRect(CC_Slider, option, SC_SliderTickmarks, widget);3804 QRect grooveRegion = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); 3805 QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); 3806 QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); 3826 3807 bool horizontal = slider->orientation == Qt::Horizontal; 3827 3808 bool ticksAbove = slider->tickPosition & QSlider::TicksAbove; … … 3886 3867 3887 3868 if ((option->subControls & SC_SliderHandle) && handle.isValid()) { 3888 QString handlePixmapName = uniqueName(QLatin1String("slider_handle"), option, handle.size());3869 QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size()); 3889 3870 if (ticksAbove && !ticksBelow) 3890 3871 handlePixmapName += QLatin1String("-flipped"); … … 3892 3873 handlePixmapName += QLatin1String("-sunken"); 3893 3874 3894 if (! UsePixmapCache || !QPixmapCache::find(handlePixmapName, cache)) {3875 if (!QPixmapCache::find(handlePixmapName, cache)) { 3895 3876 cache = QPixmap(handle.size()); 3896 3877 cache.fill(Qt::white); … … 3975 3956 handlePainter.drawImage(pixmapRect, image); 3976 3957 handlePainter.end(); 3977 if (UsePixmapCache) 3978 QPixmapCache::insert(handlePixmapName, cache); 3958 QPixmapCache::insert(handlePixmapName, cache); 3979 3959 } 3980 3960 … … 3985 3965 fropt.QStyleOption::operator=(*slider); 3986 3966 fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget); 3987 drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);3967 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); 3988 3968 } 3989 3969 } … … 3992 3972 QPen oldPen = painter->pen(); 3993 3973 painter->setPen(borderColor); 3994 int tickSize = p ixelMetric(PM_SliderTickmarkOffset, option, widget);3995 int available = p ixelMetric(PM_SliderSpaceAvailable, slider, widget);3974 int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); 3975 int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); 3996 3976 int interval = slider->tickInterval; 3997 3977 if (interval <= 0) { … … 4007 3987 4008 3988 int v = slider->minimum; 4009 int len = p ixelMetric(PM_SliderLength, slider, widget);3989 int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); 4010 3990 QVarLengthArray<QLine, 32> lines; 4011 3991 while (v <= slider->maximum + 1) { … … 4062 4042 4063 4043 // Rects 4064 QRect upRect = subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);4065 QRect downRect = subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);4044 QRect upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); 4045 QRect downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); 4066 4046 QRect buttonRect = upRect | downRect; 4067 4047 … … 4084 4064 d->drawPartialFrame(painter, 4085 4065 option, 4086 subControlRect(CC_SpinBox, spinBox, SC_SpinBoxEditField, widget),4066 proxy()->subControlRect(CC_SpinBox, spinBox, SC_SpinBoxEditField, widget), 4087 4067 widget); 4088 4068 } … … 4424 4404 d->drawPartialFrame(painter, 4425 4405 option, 4426 subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget),4406 proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget), 4427 4407 widget); 4428 4408 … … 4548 4528 buttonOption.state &= ~State_Sunken; 4549 4529 } 4550 drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget);4530 proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget); 4551 4531 4552 4532 // Draw the menu button separator line … … 4581 4561 4582 4562 // Draw the focus rect 4583 if (((option->state & State_HasFocus) && (option->state & State_KeyboardFocusChange)) && !comboBox->editable) { 4563 if ((option->state & State_HasFocus) && !comboBox->editable 4564 && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) { 4584 4565 QStyleOptionFocusRect focus; 4585 focus.rect = subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget)4566 focus.rect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget) 4586 4567 .adjusted(-2, 0, 2, 0); 4587 drawPrimitive(PE_FrameFocusRect, &focus, painter, widget);4568 proxy()->drawPrimitive(PE_FrameFocusRect, &focus, painter, widget); 4588 4569 } 4589 4570 … … 4615 4596 dockwidget.QStyleOption::operator=(*option); 4616 4597 dockwidget.title = titleBar->text; 4617 drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget);4598 proxy()->drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget); 4618 4599 } else 4619 4600 #endif // QT3_SUPPORT … … 4688 4669 } 4689 4670 // draw title 4690 QRect textRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget);4671 QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget); 4691 4672 4692 4673 QFont font = painter->font(); … … 4715 4696 bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken); 4716 4697 4717 QRect minButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget);4698 QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget); 4718 4699 qt_plastique_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken); 4719 4700 … … 4759 4740 bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken); 4760 4741 4761 QRect maxButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget);4742 QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget); 4762 4743 qt_plastique_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken); 4763 4744 … … 4784 4765 bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken); 4785 4766 4786 QRect closeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget);4767 QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget); 4787 4768 qt_plastique_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken); 4788 4769 … … 4830 4811 bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken); 4831 4812 4832 QRect normalButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget);4813 QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget); 4833 4814 qt_plastique_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken); 4834 4815 int xoffset = int(normalButtonRect.width() / 3.5); … … 4876 4857 bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken); 4877 4858 4878 QRect contextHelpButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget);4859 QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget); 4879 4860 4880 4861 qt_plastique_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken); … … 4903 4884 bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken); 4904 4885 4905 QRect shadeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget);4886 QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget); 4906 4887 qt_plastique_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken); 4907 4888 … … 4927 4908 bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken); 4928 4909 4929 QRect unshadeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget);4910 QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget); 4930 4911 qt_plastique_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken); 4931 4912 … … 4952 4933 bool sunken = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_Sunken); 4953 4934 4954 QRect iconRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget);4935 QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget); 4955 4936 if (hover) 4956 4937 qt_plastique_draw_mdibutton(painter, titleBar, iconRect, hover, sunken); … … 4964 4945 tool.rect = iconRect; 4965 4946 painter->save(); 4966 drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);4947 proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm); 4967 4948 painter->restore(); 4968 4949 } … … 4971 4952 } 4972 4953 break; 4954 #ifndef QT_NO_DIAL 4955 case CC_Dial: 4956 if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option)) 4957 QStyleHelper::drawDial(dial, painter); 4958 break; 4959 #endif // QT_NO_DIAL 4973 4960 default: 4974 4961 QWindowsStyle::drawComplexControl(control, option, painter, widget); … … 4993 4980 case CT_Slider: 4994 4981 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { 4995 int tickSize = p ixelMetric(PM_SliderTickmarkOffset, option, widget);4982 int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); 4996 4983 if (slider->tickPosition & QSlider::TicksBelow) { 4997 4984 if (slider->orientation == Qt::Horizontal) … … 5012 4999 case CT_ScrollBar: 5013 5000 if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { 5014 int scrollBarExtent = p ixelMetric(PM_ScrollBarExtent, option, widget);5015 int scrollBarSliderMinimum = p ixelMetric(PM_ScrollBarSliderMin, option, widget);5001 int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget); 5002 int scrollBarSliderMinimum = proxy()->pixelMetric(PM_ScrollBarSliderMin, option, widget); 5016 5003 if (scrollBar->orientation == Qt::Horizontal) { 5017 5004 newSize = QSize(scrollBarExtent * 3 + scrollBarSliderMinimum, scrollBarExtent); … … 5045 5032 if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { 5046 5033 if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) 5047 newSize.setHeight(menuItem->text.isEmpty() ? 2 : menuItem->fontMetrics. lineSpacing());5034 newSize.setHeight(menuItem->text.isEmpty() ? 2 : menuItem->fontMetrics.height()); 5048 5035 } 5049 5036 break; … … 5094 5081 case CC_Slider: 5095 5082 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { 5096 int tickSize = p ixelMetric(PM_SliderTickmarkOffset, option, widget);5083 int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); 5097 5084 5098 5085 switch (subControl) { … … 5147 5134 case CC_ScrollBar: 5148 5135 if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { 5149 int scrollBarExtent = p ixelMetric(PM_ScrollBarExtent, scrollBar, widget);5136 int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollBar, widget); 5150 5137 int sliderMaxLength = ((scrollBar->orientation == Qt::Horizontal) ? 5151 5138 scrollBar->rect.width() : scrollBar->rect.height()) - (scrollBarExtent * 3); 5152 int sliderMinLength = p ixelMetric(PM_ScrollBarSliderMin, scrollBar, widget);5139 int sliderMinLength = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget); 5153 5140 int sliderLength; 5154 5141 … … 5272 5259 case SC_ComboBoxEditField: { 5273 5260 if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { 5274 int frameWidth = p ixelMetric(PM_DefaultFrameWidth);5261 int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth); 5275 5262 rect = visualRect(option->direction, option->rect, rect); 5276 5263 … … 5454 5441 ret = 96; // from Plastik 5455 5442 break; 5443 #ifdef Q_WS_X11 5444 case SH_DialogButtonBox_ButtonsHaveIcons: 5445 ret = true; 5446 break; 5447 #endif 5448 #ifndef Q_OS_WIN 5449 case SH_Menu_AllowActiveAndDisabled: 5450 ret = false; 5451 break; 5452 #endif 5456 5453 default: 5457 5454 ret = QWindowsStyle::styleHint(hint, option, widget, returnData); … … 5472 5469 case CC_ScrollBar: 5473 5470 if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { 5474 QRect slider = subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);5471 QRect slider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); 5475 5472 if (slider.contains(pos)) { 5476 5473 ret = SC_ScrollBarSlider; … … 5478 5475 } 5479 5476 5480 QRect scrollBarAddLine = subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);5477 QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); 5481 5478 if (scrollBarAddLine.contains(pos)) { 5482 5479 ret = SC_ScrollBarAddLine; … … 5484 5481 } 5485 5482 5486 QRect scrollBarSubPage = subControlRect(control, scrollBar, SC_ScrollBarSubPage, widget);5483 QRect scrollBarSubPage = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubPage, widget); 5487 5484 if (scrollBarSubPage.contains(pos)) { 5488 5485 ret = SC_ScrollBarSubPage; … … 5490 5487 } 5491 5488 5492 QRect scrollBarAddPage = subControlRect(control, scrollBar, SC_ScrollBarAddPage, widget);5489 QRect scrollBarAddPage = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddPage, widget); 5493 5490 if (scrollBarAddPage.contains(pos)) { 5494 5491 ret = SC_ScrollBarAddPage; … … 5496 5493 } 5497 5494 5498 QRect scrollBarSubLine = subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);5495 QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); 5499 5496 if (scrollBarSubLine.contains(pos)) { 5500 5497 ret = SC_ScrollBarSubLine; … … 5522 5519 ret = 0; 5523 5520 break; 5524 case PM_ToolBarIconSize:5525 ret = 24;5526 break;5527 5521 case PM_ButtonShiftHorizontal: 5528 5522 case PM_ButtonShiftVertical: … … 5615 5609 if (widget && widget->inherits("Q3DockWindowTitleBar")) { 5616 5610 // Q3DockWindow has smaller title bars than QDockWidget 5617 ret = qMax(widget->fontMetrics(). lineSpacing(), 20);5611 ret = qMax(widget->fontMetrics().height(), 20); 5618 5612 } else 5619 5613 #endif 5620 ret = qMax(widget ? widget->fontMetrics(). lineSpacing() :5621 (option ? option->fontMetrics. lineSpacing() : 0), 30);5614 ret = qMax(widget ? widget->fontMetrics().height() : 5615 (option ? option->fontMetrics.height() : 0), 30); 5622 5616 break; 5623 5617 case PM_MaximumDragDistance:
Note:
See TracChangeset
for help on using the changeset viewer.