Changeset 846 for trunk/src/gui/styles/qmacstyle_mac.mm
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/styles/qmacstyle_mac.mm
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 57 57 #include <private/qpainter_p.h> 58 58 #include <private/qprintengine_mac_p.h> 59 #include <private/qstylehelper_p.h>60 59 #include <qapplication.h> 61 60 #include <qbitmap.h> … … 98 97 #include <qlibrary.h> 99 98 #include <qdatetimeedit.h> 99 #include <qmath.h> 100 100 #include <QtGui/qgraphicsproxywidget.h> 101 101 #include <QtGui/qgraphicsview.h> 102 102 #include <private/qt_cocoa_helpers_mac_p.h> 103 #include "qmacstyle_mac_p.h" 104 #include <private/qstylehelper_p.h> 103 105 104 106 QT_BEGIN_NAMESPACE 105 106 extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp107 107 108 108 // The following constants are used for adjusting the size 109 109 // of push buttons so that they are drawn inside their bounds. 110 static const intPushButtonLeftOffset = 6;111 static const intPushButtonTopOffset = 4;112 static const intPushButtonRightOffset = 12;113 static const intPushButtonBottomOffset = 12;114 static const intMiniButtonH = 26;115 static const intSmallButtonH = 30;116 static const intBevelButtonW = 50;117 static const intBevelButtonH = 22;118 static const intPushButtonContentPadding = 6;110 const int QMacStylePrivate::PushButtonLeftOffset = 6; 111 const int QMacStylePrivate::PushButtonTopOffset = 4; 112 const int QMacStylePrivate::PushButtonRightOffset = 12; 113 const int QMacStylePrivate::PushButtonBottomOffset = 12; 114 const int QMacStylePrivate::MiniButtonH = 26; 115 const int QMacStylePrivate::SmallButtonH = 30; 116 const int QMacStylePrivate::BevelButtonW = 50; 117 const int QMacStylePrivate::BevelButtonH = 22; 118 const int QMacStylePrivate::PushButtonContentPadding = 6; 119 119 120 120 // These colors specify the titlebar gradient colors on … … 132 132 static const QColor mainWindowGradientEnd(200, 200, 200); 133 133 134 #if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5) 135 enum { 136 kThemePushButtonTextured = 31, 137 kThemePushButtonTexturedSmall = 32, 138 kThemePushButtonTexturedMini = 33 139 }; 140 141 /* Search fields */ 142 enum { 143 kHIThemeFrameTextFieldRound = 1000, 144 kHIThemeFrameTextFieldRoundSmall = 1001, 145 kHIThemeFrameTextFieldRoundMini = 1002 146 }; 147 #endif 134 static const int DisclosureOffset = 4; 148 135 149 136 // Resolve these at run-time, since the functions was moved in Leopard. 150 137 typedef HIRect * (*PtrHIShapeGetBounds)(HIShapeRef, HIRect *); 151 138 static PtrHIShapeGetBounds ptrHIShapeGetBounds = 0; 139 140 static int closeButtonSize = 12; 141 142 extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp 152 143 153 144 static bool isVerticalTabs(const QTabBar::Shape shape) { … … 157 148 || shape == QTabBar::TriangularWest); 158 149 } 159 160 static int closeButtonSize = 12;161 150 162 151 void drawTabCloseButton(QPainter *p, bool hover, bool active, bool selected) … … 238 227 // fill body 239 228 if (active) { 240 p->fillRect(rect, QColor(151, 151, 151)); 229 int d = (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) ? 16 : 0; 230 p->fillRect(rect, QColor(151 + d, 151 + d, 151 + d)); 241 231 } else { 232 int d = (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) ? 9 : 0; 242 233 QLinearGradient gradient(rect.topLeft(), rect.bottomLeft()); 243 gradient.setColorAt(0, QColor(207 , 207, 207));244 gradient.setColorAt(0.5, QColor(206 , 206, 206));245 gradient.setColorAt(1, QColor(201 , 201, 201));234 gradient.setColorAt(0, QColor(207 + d, 207 + d, 207 + d)); 235 gradient.setColorAt(0.5, QColor(206 + d, 206 + d, 206 + d)); 236 gradient.setColorAt(1, QColor(201 + d, 201 + d, 201 + d)); 246 237 p->fillRect(rect, gradient); 247 238 } … … 376 367 } 377 368 378 /*379 AHIG:380 Apple Human Interface Guidelines381 http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/382 383 Builder:384 Apple Interface Builder v. 3.1.1385 */386 387 // this works as long as we have at most 16 different control types388 #define CT1(c) CT2(c, c)389 #define CT2(c1, c2) ((uint(c1) << 16) | uint(c2))390 391 enum QAquaWidgetSize { QAquaSizeLarge = 0, QAquaSizeSmall = 1, QAquaSizeMini = 2,392 QAquaSizeUnknown = -1 };393 394 #define SIZE(large, small, mini) \395 (controlSize == QAquaSizeLarge ? (large) : controlSize == QAquaSizeSmall ? (small) : (mini))396 397 // same as return SIZE(...) but optimized398 #define return_SIZE(large, small, mini) \399 do { \400 static const int sizes[] = { (large), (small), (mini) }; \401 return sizes[controlSize]; \402 } while (0)403 404 369 static int getControlSize(const QStyleOption *option, const QWidget *widget) 405 370 { … … 433 398 QString qt_mac_removeMnemonics(const QString &original) 434 399 { 435 // copied from qt_format_text (to be bug-for-bug compatible).436 400 QString returnText(original.size(), 0); 437 401 int finalDest = 0; … … 439 403 int l = original.length(); 440 404 while (l) { 441 if (original.at(currPos) == QLatin1Char('&')) { 405 if (original.at(currPos) == QLatin1Char('&') 406 && (l == 1 || original.at(currPos + 1) != QLatin1Char('&'))) { 442 407 ++currPos; 443 408 --l; … … 479 444 } 480 445 481 class QMacStylePrivate : public QObject482 {483 Q_OBJECT484 485 public:486 QMacStylePrivate(QMacStyle *style);487 488 // Stuff from QAquaAnimate:489 bool addWidget(QWidget *);490 void removeWidget(QWidget *);491 492 enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen };493 bool animatable(Animates, const QWidget *) const;494 void stopAnimate(Animates, QWidget *);495 void startAnimate(Animates, QWidget *);496 static ThemeDrawState getDrawState(QStyle::State flags);497 QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg,498 QStyle::ContentsType ct = QStyle::CT_CustomBase,499 QSize szHint=QSize(-1, -1), QSize *insz = 0) const;500 void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider,501 HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe);502 bool doAnimate(Animates);503 inline int animateSpeed(Animates) const { return 33; }504 505 // Utility functions506 void drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi,507 QPainter *p, const QStyleOption *opt) const;508 509 QSize pushButtonSizeFromContents(const QStyleOptionButton *btn) const;510 511 HIRect pushButtonContentBounds(const QStyleOptionButton *btn,512 const HIThemeButtonDrawInfo *bdi) const;513 514 void initComboboxBdi(const QStyleOptionComboBox *combo, HIThemeButtonDrawInfo *bdi,515 const QWidget *widget, const ThemeDrawState &tds);516 517 static HIRect comboboxInnerBounds(const HIRect &outerBounds, int buttonKind);518 519 static QRect comboboxEditBounds(const QRect &outerBounds, const HIThemeButtonDrawInfo &bdi);520 521 static void drawCombobox(const HIRect &outerBounds, const HIThemeButtonDrawInfo &bdi, QPainter *p);522 static void drawTableHeader(const HIRect &outerBounds, bool drawTopBorder, bool drawLeftBorder,523 const HIThemeButtonDrawInfo &bdi, QPainter *p);524 bool contentFitsInPushButton(const QStyleOptionButton *btn, HIThemeButtonDrawInfo *bdi,525 ThemeButtonKind buttonKindToCheck) const;526 void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget,527 const ThemeDrawState tds,528 HIThemeButtonDrawInfo *bdi) const;529 QPixmap generateBackgroundPattern() const;530 protected:531 bool eventFilter(QObject *, QEvent *);532 void timerEvent(QTimerEvent *);533 534 private slots:535 void startAnimationTimer();536 537 public:538 QPointer<QPushButton> defaultButton; //default push buttons539 int timerID;540 QList<QPointer<QWidget> > progressBars; //existing progress bars that need animation541 542 struct ButtonState {543 int frame;544 enum { ButtonDark, ButtonLight } dir;545 } buttonState;546 UInt8 progressFrame;547 QPointer<QFocusFrame> focusWidget;548 CFAbsoluteTime defaultButtonStart;549 QMacStyle *q;550 bool mouseDown;551 };552 553 446 QT_BEGIN_INCLUDE_NAMESPACE 554 #include "qmacstyle_mac.moc" 447 #include "moc_qmacstyle_mac.cpp" 448 #include "moc_qmacstyle_mac_p.cpp" 555 449 QT_END_INCLUDE_NAMESPACE 556 450 … … 1053 947 // carbon not calculating the content bounds fully correct 1054 948 if (bdi->kind == kThemePushButton || bdi->kind == kThemePushButtonSmall){ 1055 outerBounds.origin.y += PushButtonTopOffset;1056 outerBounds.size.height -= PushButtonBottomOffset;949 outerBounds.origin.y += QMacStylePrivate::PushButtonTopOffset; 950 outerBounds.size.height -= QMacStylePrivate::PushButtonBottomOffset; 1057 951 } else if (bdi->kind == kThemePushButtonMini) { 1058 outerBounds.origin.y += PushButtonTopOffset;952 outerBounds.origin.y += QMacStylePrivate::PushButtonTopOffset; 1059 953 } 1060 954 … … 1072 966 QSize csz(0, 0); 1073 967 QSize iconSize = btn->icon.isNull() ? QSize(0, 0) 1074 : (btn->iconSize + QSize( PushButtonContentPadding, 0));968 : (btn->iconSize + QSize(QMacStylePrivate::PushButtonContentPadding, 0)); 1075 969 QRect textRect = btn->text.isEmpty() ? QRect(0, 0, 1, 1) 1076 970 : btn->fontMetrics.boundingRect(QRect(), Qt::AlignCenter, btn->text); … … 1147 1041 // same time displays the button contents without clipping. 1148 1042 bdi->kind = kThemeBevelButton; 1149 if (btn->rect.width() >= BevelButtonW && btn->rect.height() >=BevelButtonH){1043 if (btn->rect.width() >= QMacStylePrivate::BevelButtonW && btn->rect.height() >= QMacStylePrivate::BevelButtonH){ 1150 1044 if (widget && widget->testAttribute(Qt::WA_MacVariableSize)) { 1151 if (btn->rect.height() <= MiniButtonH){1045 if (btn->rect.height() <= QMacStylePrivate::MiniButtonH){ 1152 1046 if (contentFitsInPushButton(btn, bdi, kThemePushButtonMini)) 1153 1047 bdi->kind = kThemePushButtonMini; 1154 } else if (btn->rect.height() <= SmallButtonH){1048 } else if (btn->rect.height() <= QMacStylePrivate::SmallButtonH){ 1155 1049 if (contentFitsInPushButton(btn, bdi, kThemePushButtonSmall)) 1156 1050 bdi->kind = kThemePushButtonSmall; … … 1164 1058 } 1165 1059 } 1060 } 1061 1062 bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option) 1063 { 1064 QMacStyle *macStyle = qobject_cast<QMacStyle *>(pushButton->style()); 1065 if (!macStyle) 1066 return false; 1067 HIThemeButtonDrawInfo bdi; 1068 macStyle->d->initHIThemePushButton(option, pushButton, kThemeStateActive, &bdi); 1069 return bdi.kind == kThemeBevelButton; 1166 1070 } 1167 1071 … … 1537 1441 bool QMacStylePrivate::animatable(QMacStylePrivate::Animates as, const QWidget *w) const 1538 1442 { 1443 if (!w) 1444 return false; 1445 1539 1446 if (as == AquaPushButton) { 1540 1447 QPushButton *pb = const_cast<QPushButton *>(static_cast<const QPushButton *>(w)); … … 1915 1822 painter->setClipRegion(rgn); 1916 1823 1917 CGContextRefcg = qt_mac_cg_context(target);1824 QCFType<CGContextRef> cg = qt_mac_cg_context(target); 1918 1825 CGContextSaveGState(cg); 1919 1826 HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationInverted); … … 2141 2048 if (qstyleoption_cast<const QStyleOptionComboBox *>(opt) != 0) 2142 2049 ret = 0; 2050 // Frame of mac style line edits is two pixels on top and one on the bottom 2051 else if (qobject_cast<const QLineEdit *>(widget) != 0) 2052 ret = 2; 2143 2053 else 2144 ret = QWindowsStyle::pixelMetric(metric, opt, widget);2054 ret = 1; 2145 2055 break; 2146 2056 case PM_MaximumDragDistance: … … 3095 3005 bi.value = opt->direction == Qt::LeftToRight ? kThemeDisclosureRight : kThemeDisclosureLeft; 3096 3006 bi.adornment = kThemeAdornmentNone; 3097 HIRect hirect = qt_hirectForQRect(opt->rect );3007 HIRect hirect = qt_hirectForQRect(opt->rect.adjusted(DisclosureOffset,0,-DisclosureOffset,0)); 3098 3008 HIThemeDrawButton(&hirect, &bi, cg, kHIThemeOrientationNormal, 0); 3099 3009 break; } 3010 3100 3011 case PE_Frame: { 3101 3012 QPen oldPen = p->pen(); 3102 QPen newPen; 3103 newPen.setBrush(opt->palette.dark()); 3104 p->setPen(newPen); 3013 p->setPen(opt->palette.base().color().darker(140)); 3105 3014 p->drawRect(opt->rect.adjusted(0, 0, -1, -1)); 3015 p->setPen(opt->palette.base().color().darker(180)); 3016 p->drawLine(opt->rect.topLeft(), opt->rect.topRight()); 3106 3017 p->setPen(oldPen); 3107 3018 break; } 3019 3108 3020 case PE_FrameLineEdit: 3109 3021 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { … … 3147 3059 case PE_PanelLineEdit: 3148 3060 QWindowsStyle::drawPrimitive(pe, opt, p, w); 3061 // Draw the focus frame for widgets other than QLineEdit (e.g. for line edits in Webkit). 3062 // Focus frame is drawn outside the rectangle passed in the option-rect. 3063 if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { 3064 if ((opt->state & State_HasFocus) && !qobject_cast<const QLineEdit*>(w)) { 3065 int vmargin = pixelMetric(QStyle::PM_FocusFrameVMargin); 3066 int hmargin = pixelMetric(QStyle::PM_FocusFrameHMargin); 3067 QStyleOptionFrame focusFrame = *panel; 3068 focusFrame.rect = panel->rect.adjusted(-hmargin, -vmargin, hmargin, vmargin); 3069 drawControl(CE_FocusFrame, &focusFrame, p, w); 3070 } 3071 } 3072 3149 3073 break; 3150 3074 case PE_FrameTabWidget: … … 3170 3094 } break; 3171 3095 case PE_FrameStatusBarItem: 3172 QCommonStyle::drawPrimitive(pe, opt, p, w);3173 3096 break; 3174 3097 case PE_IndicatorTabClose: { … … 3267 3190 switch (header->position) { 3268 3191 case QStyleOptionHeader::Beginning: 3192 ir.adjust(-1, -1, 0, 0); 3269 3193 break; 3270 3194 case QStyleOptionHeader::Middle: 3195 ir.adjust(-1, -1, 0, 0); 3196 break; 3197 case QStyleOptionHeader::OnlyOneSection: 3271 3198 case QStyleOptionHeader::End: 3272 ir.adjust(-1, 0, 0, 0);3199 ir.adjust(-1, -1, 1, 0); 3273 3200 break; 3274 3201 default: … … 3410 3337 QPalette pal = tb->palette; 3411 3338 QPalette::ColorRole role = QPalette::NoRole; 3339 if (!proxy()->styleHint(SH_UnderlineShortcut, tb, w)) 3340 alignment |= Qt::TextHideMnemonic; 3412 3341 if (down) 3413 3342 cr.translate(shiftX, shiftY); … … 3427 3356 } 3428 3357 } 3429 drawItemText(p, cr, alignment, pal,3430 tb->state & State_Enabled, tb->text, role);3358 proxy()->drawItemText(p, cr, alignment, pal, 3359 tb->state & State_Enabled, tb->text, role); 3431 3360 if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5 && 3432 3361 (tb->state & State_Sunken)) { 3433 3362 // Draw a "drop shadow" in earlier versions. 3434 drawItemText(p, cr.adjusted(0, 1, 0, 1), alignment,3435 tb->palette, tb->state & State_Enabled, tb->text);3363 proxy()->drawItemText(p, cr.adjusted(0, 1, 0, 1), alignment, 3364 tb->palette, tb->state & State_Enabled, tb->text); 3436 3365 } 3437 3366 } … … 3472 3401 HIRect newRect = qt_hirectForQRect(btn->rect); 3473 3402 if (bdi.kind == kThemePushButton || bdi.kind == kThemePushButtonSmall) { 3474 newRect.origin.x += PushButtonLeftOffset;3475 newRect.origin.y += PushButtonTopOffset;3476 newRect.size.width -= PushButtonRightOffset;3477 newRect.size.height -= PushButtonBottomOffset;3403 newRect.origin.x += QMacStylePrivate::PushButtonLeftOffset; 3404 newRect.origin.y += QMacStylePrivate::PushButtonTopOffset; 3405 newRect.size.width -= QMacStylePrivate::PushButtonRightOffset; 3406 newRect.size.height -= QMacStylePrivate::PushButtonBottomOffset; 3478 3407 } else if (bdi.kind == kThemePushButtonMini) { 3479 newRect.origin.x += PushButtonLeftOffset - 2;3480 newRect.origin.y += PushButtonTopOffset;3481 newRect.size.width -= PushButtonRightOffset - 4;3408 newRect.origin.x += QMacStylePrivate::PushButtonLeftOffset - 2; 3409 newRect.origin.y += QMacStylePrivate::PushButtonTopOffset; 3410 newRect.size.width -= QMacStylePrivate::PushButtonRightOffset - 4; 3482 3411 } 3483 3412 HIThemeDrawButton(&newRect, &bdi, cg, kHIThemeOrientationNormal, 0); … … 3486 3415 int mbi = proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w); 3487 3416 QRect ir = btn->rect; 3488 HIRect arrowRect = CGRectMake(ir.right() - mbi - PushButtonRightOffset,3417 HIRect arrowRect = CGRectMake(ir.right() - mbi - QMacStylePrivate::PushButtonRightOffset, 3489 3418 ir.height() / 2 - 4, mbi, ir.height() / 2); 3490 3419 bool drawColorless = btn->palette.currentColorGroup() == QPalette::Active; … … 3580 3509 state = QIcon::On; 3581 3510 QPixmap pixmap = btn->icon.pixmap(btn->iconSize, mode, state); 3582 contentW += pixmap.width() + PushButtonContentPadding;3511 contentW += pixmap.width() + QMacStylePrivate::PushButtonContentPadding; 3583 3512 int iconLeftOffset = freeContentRect.x() + (freeContentRect.width() - contentW) / 2; 3584 3513 int iconTopOffset = freeContentRect.y() + (freeContentRect.height() - pixmap.height()) / 2; … … 3587 3516 proxy()->drawItemPixmap(p, visualIconDestRect, Qt::AlignLeft | Qt::AlignVCenter, pixmap); 3588 3517 int newOffset = iconDestRect.x() + iconDestRect.width() 3589 + PushButtonContentPadding - textRect.x();3518 + QMacStylePrivate::PushButtonContentPadding - textRect.x(); 3590 3519 textRect.adjust(newOffset, 0, newOffset, 0); 3591 3520 } … … 4330 4259 4331 4260 switch (sr) { 4261 case SE_ItemViewItemText: 4262 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { 4263 int fw = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, widget); 4264 // We add the focusframeargin between icon and text in commonstyle 4265 rect = QCommonStyle::subElementRect(sr, opt, widget); 4266 if (vopt->features & QStyleOptionViewItemV2::HasDecoration) 4267 rect.adjust(-fw, 0, 0, 0); 4268 } 4269 break; 4332 4270 case SE_ToolBoxTabContents: 4333 4271 rect = QCommonStyle::subElementRect(sr, opt, widget); … … 4347 4285 if (qstyleoption_cast<const QStyleOptionHeader *>(opt)) { 4348 4286 rect = QWindowsStyle::subElementRect(sr, opt, widget); 4349 if (widget && widget->height() <= qt_mac_aqua_get_metric(kThemeMetricListHeaderHeight)){4350 // We need to allow the text a bit more space when the header is as4351 // small as kThemeMetricListHeaderHeight, otherwise it gets clipped:4287 if (widget && widget->height() <= 22){ 4288 // We need to allow the text a bit more space when the header is 4289 // small, otherwise it gets clipped: 4352 4290 rect.setY(0); 4353 4291 rect.setHeight(widget->height()); … … 4376 4314 HIThemeGetButtonShape(&inRect, &bdi, &shape); 4377 4315 ptrHIShapeGetBounds(shape, &outRect); 4378 rect = QRect(int(outRect.origin.x), int(outRect.origin.y), 4379 int(contentRect.origin.x - outRect.origin.x), int(outRect.size.height)); 4316 rect = QRect(int(outRect.origin.x + DisclosureOffset), int(outRect.origin.y), 4317 int(contentRect.origin.x - outRect.origin.x + DisclosureOffset), 4318 int(outRect.size.height)); 4380 4319 break; 4381 4320 } … … 5419 5358 QCFString groupText = qt_mac_removeMnemonics(groupBox->text); 5420 5359 HIThemeGetTextDimensions(groupText, 0, &tti, &width, &height, 0); 5421 tw = int(width);5422 h = int(height);5360 tw = qRound(width); 5361 h = qCeil(height); 5423 5362 } else { 5424 QFontMetrics fm = groupBox->fontMetrics; 5425 if (!checkable && !fontIsSet) 5426 fm = QFontMetrics(qt_app_fonts_hash()->value("QSmallFont", QFont())); 5427 h = fm.height(); 5428 tw = fm.size(Qt::TextShowMnemonic, groupBox->text).width(); 5363 QFontMetricsF fm = QFontMetricsF(groupBox->fontMetrics); 5364 h = qCeil(fm.height()); 5365 tw = qCeil(fm.size(Qt::TextShowMnemonic, groupBox->text).width()); 5429 5366 } 5430 5367 ret.setHeight(h); … … 5473 5410 yOffset = 5; 5474 5411 if (hasNoText) 5475 yOffset = - fm.height();5476 } 5477 5478 ret = opt->rect.adjusted(0, fm.height() + yOffset, 0, 0);5412 yOffset = -qCeil(QFontMetricsF(fm).height()); 5413 } 5414 5415 ret = opt->rect.adjusted(0, qCeil(QFontMetricsF(fm).height()) + yOffset, 0, 0); 5479 5416 if (sc == SC_GroupBoxContents) 5480 5417 ret.adjust(3, 3, -3, -4); // guess … … 5675 5612 // Do this by add enough space around the contents so that rounded 5676 5613 // borders (including highlighting when active) will show. 5677 sz.rwidth() += PushButtonLeftOffset +PushButtonRightOffset + 12;5678 sz.rheight() += PushButtonTopOffset +PushButtonBottomOffset;5614 sz.rwidth() += QMacStylePrivate::PushButtonLeftOffset + QMacStylePrivate::PushButtonRightOffset + 12; 5615 sz.rheight() += QMacStylePrivate::PushButtonTopOffset + QMacStylePrivate::PushButtonBottomOffset; 5679 5616 break; 5680 5617 case QStyle::CT_MenuItem: … … 5768 5705 } 5769 5706 break; 5707 case CT_ItemViewItem: 5708 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { 5709 sz = QCommonStyle::sizeFromContents(ct, vopt, csz, widget); 5710 sz.setHeight(sz.height() + 2); 5711 } 5712 break; 5713 5770 5714 default: 5771 5715 sz = QWindowsStyle::sizeFromContents(ct, opt, csz, widget);
Note:
See TracChangeset
for help on using the changeset viewer.