1178 if (background()->attachment == Attachment_Fixed) |
1178 if (background()->attachment == Attachment_Fixed) |
1179 off = QPoint(0, 0); |
1179 off = QPoint(0, 0); |
1180 |
1180 |
1181 QRect r = originRect(rect, background()->origin); |
1181 QRect r = originRect(rect, background()->origin); |
1182 QRect aligned = QStyle::alignedRect(Qt::LeftToRight, background()->position, bgp.size(), r); |
1182 QRect aligned = QStyle::alignedRect(Qt::LeftToRight, background()->position, bgp.size(), r); |
1183 QRect inter = aligned.intersected(r); |
1183 QRect inter = aligned.translated(-off).intersected(r); |
1184 |
1184 |
1185 switch (background()->repeat) { |
1185 switch (background()->repeat) { |
1186 case Repeat_Y: |
1186 case Repeat_Y: |
1187 p->drawTiledPixmap(inter.x(), r.y(), inter.width(), r.height(), bgp, |
1187 p->drawTiledPixmap(inter.x(), r.y(), inter.width(), r.height(), bgp, |
1188 inter.x() - aligned.x() + off.x(), |
1188 inter.x() - aligned.x() + off.x(), |
3323 return; |
3323 return; |
3324 } |
3324 } |
3325 break; |
3325 break; |
3326 |
3326 |
3327 case CE_PushButton: |
3327 case CE_PushButton: |
3328 ParentStyle::drawControl(ce, opt, p, w); |
3328 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
3329 return; |
3329 if (rule.hasDrawable() || rule.hasBox() || rule.hasPosition() || rule.hasPalette() || |
3330 |
3330 ((btn->features & QStyleOptionButton::HasMenu) && hasStyleRule(w, PseudoElement_PushButtonMenuIndicator))) { |
|
3331 ParentStyle::drawControl(ce, opt, p, w); |
|
3332 return; |
|
3333 } |
|
3334 } |
|
3335 break; |
3331 case CE_PushButtonBevel: |
3336 case CE_PushButtonBevel: |
3332 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
3337 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
3333 QStyleOptionButton btnOpt(*btn); |
3338 QStyleOptionButton btnOpt(*btn); |
3334 btnOpt.rect = rule.borderRect(opt->rect); |
3339 btnOpt.rect = rule.borderRect(opt->rect); |
3335 if (rule.hasNativeBorder()) { |
3340 if (rule.hasNativeBorder()) { |
3368 QStyleOptionButton butOpt(*button); |
3373 QStyleOptionButton butOpt(*button); |
3369 rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button); |
3374 rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button); |
3370 if (rule.hasPosition() && rule.position()->textAlignment != 0) { |
3375 if (rule.hasPosition() && rule.position()->textAlignment != 0) { |
3371 Qt::Alignment textAlignment = rule.position()->textAlignment; |
3376 Qt::Alignment textAlignment = rule.position()->textAlignment; |
3372 QRect textRect = button->rect; |
3377 QRect textRect = button->rect; |
3373 uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic; |
3378 uint tf = Qt::TextShowMnemonic; |
|
3379 const uint verticalAlignMask = Qt::AlignVCenter | Qt::AlignTop | Qt::AlignLeft; |
|
3380 tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter; |
3374 if (!styleHint(SH_UnderlineShortcut, button, w)) |
3381 if (!styleHint(SH_UnderlineShortcut, button, w)) |
3375 tf |= Qt::TextHideMnemonic; |
3382 tf |= Qt::TextHideMnemonic; |
3376 if (!button->icon.isNull()) { |
3383 if (!button->icon.isNull()) { |
3377 //Group both icon and text |
3384 //Group both icon and text |
3378 QRect iconRect; |
3385 QRect iconRect; |
3597 mi.rect = positionRect(w, subRule, subRule2, PseudoElement_MenuRightArrow, opt->rect, mi.direction); |
3604 mi.rect = positionRect(w, subRule, subRule2, PseudoElement_MenuRightArrow, opt->rect, mi.direction); |
3598 drawPrimitive(arrow, &mi, p, w); |
3605 drawPrimitive(arrow, &mi, p, w); |
3599 } |
3606 } |
3600 } else if (hasStyleRule(w, PseudoElement_MenuCheckMark) || hasStyleRule(w, PseudoElement_MenuRightArrow)) { |
3607 } else if (hasStyleRule(w, PseudoElement_MenuCheckMark) || hasStyleRule(w, PseudoElement_MenuRightArrow)) { |
3601 QWindowsStyle::drawControl(ce, &mi, p, w); |
3608 QWindowsStyle::drawControl(ce, &mi, p, w); |
|
3609 if (mi.checkType != QStyleOptionMenuItem::NotCheckable && !mi.checked) { |
|
3610 // We have a style defined, but QWindowsStyle won't draw anything if not checked. |
|
3611 // So we mimick what QWindowsStyle would do. |
|
3612 int checkcol = qMax<int>(mi.maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth); |
|
3613 QRect vCheckRect = visualRect(opt->direction, mi.rect, QRect(mi.rect.x(), mi.rect.y(), checkcol, mi.rect.height())); |
|
3614 if (mi.state.testFlag(State_Enabled) && mi.state.testFlag(State_Selected)) { |
|
3615 qDrawShadePanel(p, vCheckRect, mi.palette, true, 1, &mi.palette.brush(QPalette::Button)); |
|
3616 } else { |
|
3617 QBrush fill(mi.palette.light().color(), Qt::Dense4Pattern); |
|
3618 qDrawShadePanel(p, vCheckRect, mi.palette, true, 1, &fill); |
|
3619 } |
|
3620 QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark); |
|
3621 if (subSubRule.hasDrawable()) { |
|
3622 QStyleOptionMenuItem newMi(mi); |
|
3623 newMi.rect = visualRect(opt->direction, mi.rect, QRect(mi.rect.x() + QWindowsStylePrivate::windowsItemFrame, |
|
3624 mi.rect.y() + QWindowsStylePrivate::windowsItemFrame, |
|
3625 checkcol - 2 * QWindowsStylePrivate::windowsItemFrame, |
|
3626 mi.rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame)); |
|
3627 drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, w); |
|
3628 } |
|
3629 } |
3602 } else { |
3630 } else { |
3603 if (rule.hasDrawable() && !subRule.hasDrawable() && !(opt->state & QStyle::State_Selected)) { |
3631 if (rule.hasDrawable() && !subRule.hasDrawable() && !(opt->state & QStyle::State_Selected)) { |
3604 mi.palette.setColor(QPalette::Window, Qt::transparent); |
3632 mi.palette.setColor(QPalette::Window, Qt::transparent); |
3605 mi.palette.setColor(QPalette::Button, Qt::transparent); |
3633 mi.palette.setColor(QPalette::Button, Qt::transparent); |
3606 } |
3634 } |
3666 else |
3694 else |
3667 editRect.translate(cb->iconSize.width() + spacing, 0); |
3695 editRect.translate(cb->iconSize.width() + spacing, 0); |
3668 } |
3696 } |
3669 if (!cb->currentText.isEmpty() && !cb->editable) { |
3697 if (!cb->currentText.isEmpty() && !cb->editable) { |
3670 drawItemText(p, editRect.adjusted(0, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, cb->palette, |
3698 drawItemText(p, editRect.adjusted(0, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, cb->palette, |
3671 cb->state & State_Enabled, cb->currentText); |
3699 cb->state & State_Enabled, cb->currentText, QPalette::Text); |
3672 } |
3700 } |
3673 p->restore(); |
3701 p->restore(); |
3674 return; |
3702 return; |
3675 } |
3703 } |
3676 break; |
3704 break; |
4273 p->fillRect(v2->rect, v2->palette.highlight()); |
4301 p->fillRect(v2->rect, v2->palette.highlight()); |
4274 else if (v2->features & QStyleOptionViewItemV2::Alternate) |
4302 else if (v2->features & QStyleOptionViewItemV2::Alternate) |
4275 p->fillRect(v2->rect, v2->palette.alternateBase()); |
4303 p->fillRect(v2->rect, v2->palette.alternateBase()); |
4276 subRule.drawRule(p, opt->rect); |
4304 subRule.drawRule(p, opt->rect); |
4277 } else { |
4305 } else { |
4278 QStyleOptionViewItemV2 v2Copy(*v2); |
4306 baseStyle()->drawPrimitive(pe, v2, p, w); |
4279 if (v2->showDecorationSelected) { |
|
4280 QRenderRule subRule2 = renderRule(w, opt, PseudoElement_ViewItem); |
|
4281 if (v2->state & QStyle::State_Selected) { |
|
4282 subRule2.configurePalette(&v2Copy.palette, QPalette::NoRole, QPalette::Highlight); |
|
4283 } else if (v2->features & QStyleOptionViewItemV2::Alternate) { |
|
4284 subRule2.configurePalette(&v2Copy.palette, QPalette::NoRole, QPalette::AlternateBase); |
|
4285 } else if (subRule2.hasBackground()) { |
|
4286 p->fillRect(v2->rect, subRule2.background()->brush); |
|
4287 } |
|
4288 } else if (v2->features & QStyleOptionViewItemV2::Alternate) { |
|
4289 quint64 pc = v2->state & QStyle::State_Enabled ? PseudoClass_Enabled : PseudoClass_Disabled; |
|
4290 pc |= PseudoClass_Alternate; |
|
4291 QRenderRule subRule2 = renderRule(w, PseudoElement_ViewItem, pc); |
|
4292 subRule2.configurePalette(&v2Copy.palette, QPalette::NoRole, QPalette::AlternateBase); |
|
4293 } |
|
4294 baseStyle()->drawPrimitive(pe, &v2Copy, p, w); |
|
4295 } |
4307 } |
4296 } |
4308 } |
4297 return; |
4309 return; |
4298 |
4310 |
4299 case PE_PanelTipLabel: |
4311 case PE_PanelTipLabel: |
4323 case PE_FrameTabWidget: |
4335 case PE_FrameTabWidget: |
4324 if (const QStyleOptionTabWidgetFrame *frm = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
4336 if (const QStyleOptionTabWidgetFrame *frm = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
4325 QRenderRule subRule = renderRule(w, opt, PseudoElement_TabWidgetPane); |
4337 QRenderRule subRule = renderRule(w, opt, PseudoElement_TabWidgetPane); |
4326 if (subRule.hasNativeBorder()) { |
4338 if (subRule.hasNativeBorder()) { |
4327 subRule.drawBackground(p, opt->rect); |
4339 subRule.drawBackground(p, opt->rect); |
4328 QStyleOptionTabWidgetFrame frmCopy(*frm); |
4340 QStyleOptionTabWidgetFrameV2 frmCopy(*frm); |
4329 subRule.configurePalette(&frmCopy.palette, QPalette::WindowText, QPalette::Window); |
4341 subRule.configurePalette(&frmCopy.palette, QPalette::WindowText, QPalette::Window); |
4330 baseStyle()->drawPrimitive(pe, &frmCopy, p, w); |
4342 baseStyle()->drawPrimitive(pe, &frmCopy, p, w); |
4331 } else { |
4343 } else { |
4332 subRule.drawRule(p, opt->rect); |
4344 subRule.drawRule(p, opt->rect); |
4333 } |
4345 } |
4354 case PE_IndicatorDockWidgetResizeHandle: |
4366 case PE_IndicatorDockWidgetResizeHandle: |
4355 pseudoElement = PseudoElement_DockWidgetSeparator; |
4367 pseudoElement = PseudoElement_DockWidgetSeparator; |
4356 break; |
4368 break; |
4357 |
4369 |
4358 case PE_PanelItemViewItem: |
4370 case PE_PanelItemViewItem: |
4359 if (!styleHint(SH_ItemView_ShowDecorationSelected, opt, w)) { |
|
4360 rect = subElementRect(QStyle::SE_ItemViewItemText, opt, w) |
|
4361 | subElementRect(QStyle::SE_ItemViewItemDecoration, opt, w) |
|
4362 | subElementRect(QStyle::SE_ItemViewItemCheckIndicator, opt, w); |
|
4363 } |
|
4364 pseudoElement = PseudoElement_ViewItem; |
|
4365 break; |
|
4366 |
|
4367 case PE_PanelItemViewRow: |
|
4368 ParentStyle::drawPrimitive(pe, opt, p, w); |
|
4369 if (!styleHint(SH_ItemView_ShowDecorationSelected, opt, w)) |
|
4370 return; |
|
4371 pseudoElement = PseudoElement_ViewItem; |
4371 pseudoElement = PseudoElement_ViewItem; |
4372 break; |
4372 break; |
4373 |
4373 |
4374 case PE_PanelScrollAreaCorner: |
4374 case PE_PanelScrollAreaCorner: |
4375 pseudoElement = PseudoElement_ScrollAreaCorner; |
4375 pseudoElement = PseudoElement_ScrollAreaCorner; |
4635 return (opt->state & QStyle::State_Horizontal) |
4635 return (opt->state & QStyle::State_Horizontal) |
4636 ? sz.width() : sz.height(); |
4636 ? sz.width() : sz.height(); |
4637 } |
4637 } |
4638 break; |
4638 break; |
4639 |
4639 |
|
4640 #ifndef QT_NO_TABWIDGET |
4640 case PM_TabBarTabHSpace: |
4641 case PM_TabBarTabHSpace: |
4641 case PM_TabBarTabVSpace: |
4642 case PM_TabBarTabVSpace: |
4642 subRule = renderRule(w, opt, PseudoElement_TabBarTab); |
4643 subRule = renderRule(w, opt, PseudoElement_TabBarTab); |
4643 if (subRule.hasBox() || subRule.hasBorder()) |
4644 if (subRule.hasBox() || subRule.hasBorder()) |
4644 return 0; |
4645 return 0; |
4658 subRule = renderRule(w, opt, PseudoElement_TabBarTab); |
4659 subRule = renderRule(w, opt, PseudoElement_TabBarTab); |
4659 if (subRule.hasBox()) |
4660 if (subRule.hasBox()) |
4660 return 0; |
4661 return 0; |
4661 break; |
4662 break; |
4662 |
4663 |
4663 case PM_TabBarBaseOverlap: |
4664 case PM_TabBarBaseOverlap: { |
4664 if (hasStyleRule(w->parentWidget(), PseudoElement_TabWidgetPane)) { |
4665 const QWidget *tabWidget = qobject_cast<const QTabWidget *>(w) ? w : w->parentWidget(); |
|
4666 if (hasStyleRule(tabWidget, PseudoElement_TabWidgetPane)) { |
4665 return 0; |
4667 return 0; |
4666 } |
4668 } |
4667 break; |
4669 break; |
|
4670 } |
|
4671 #endif // QT_NO_TABWIDGET |
4668 |
4672 |
4669 case PM_SliderThickness: // horizontal slider's height (sizeHint) |
4673 case PM_SliderThickness: // horizontal slider's height (sizeHint) |
4670 case PM_SliderLength: // minimum length of slider |
4674 case PM_SliderLength: // minimum length of slider |
4671 if (rule.hasContentsSize()) { |
4675 if (rule.hasContentsSize()) { |
4672 bool horizontal = opt->state & QStyle::State_Horizontal; |
4676 bool horizontal = opt->state & QStyle::State_Horizontal; |
4720 QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar); |
4724 QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar); |
4721 if (subRule.hasContentsSize()) |
4725 if (subRule.hasContentsSize()) |
4722 return subRule.size().height(); |
4726 return subRule.size().height(); |
4723 else if (subRule.hasBox() || subRule.hasBorder()) { |
4727 else if (subRule.hasBox() || subRule.hasBorder()) { |
4724 QFontMetrics fm = opt ? opt->fontMetrics : w->fontMetrics(); |
4728 QFontMetrics fm = opt ? opt->fontMetrics : w->fontMetrics(); |
4725 return subRule.size(QSize(0, fm.lineSpacing())).height(); |
4729 return subRule.size(QSize(0, fm.height())).height(); |
4726 } |
4730 } |
4727 break; |
4731 break; |
4728 } |
4732 } |
4729 |
4733 |
4730 case PM_MdiSubWindowFrameWidth: |
4734 case PM_MdiSubWindowFrameWidth: |