1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
1123 } |
1123 } |
1124 } |
1124 } |
1125 |
1125 |
1126 void QRenderRule::drawBorderImage(QPainter *p, const QRect& rect) |
1126 void QRenderRule::drawBorderImage(QPainter *p, const QRect& rect) |
1127 { |
1127 { |
|
1128 setClip(p, rect); |
1128 static const Qt::TileRule tileMode2TileRule[] = { |
1129 static const Qt::TileRule tileMode2TileRule[] = { |
1129 Qt::StretchTile, Qt::RoundTile, Qt::StretchTile, Qt::RepeatTile, Qt::StretchTile }; |
1130 Qt::StretchTile, Qt::RoundTile, Qt::StretchTile, Qt::RepeatTile, Qt::StretchTile }; |
1130 |
1131 |
1131 const QStyleSheetBorderImageData *borderImageData = border()->borderImage(); |
1132 const QStyleSheetBorderImageData *borderImageData = border()->borderImage(); |
1132 const int *targetBorders = border()->borders; |
1133 const int *targetBorders = border()->borders; |
1140 p->setRenderHint(QPainter::SmoothPixmapTransform); |
1141 p->setRenderHint(QPainter::SmoothPixmapTransform); |
1141 qDrawBorderPixmap(p, rect, targetMargins, borderImageData->pixmap, |
1142 qDrawBorderPixmap(p, rect, targetMargins, borderImageData->pixmap, |
1142 QRect(QPoint(), borderImageData->pixmap.size()), sourceMargins, |
1143 QRect(QPoint(), borderImageData->pixmap.size()), sourceMargins, |
1143 QTileRules(tileMode2TileRule[borderImageData->horizStretch], tileMode2TileRule[borderImageData->vertStretch])); |
1144 QTileRules(tileMode2TileRule[borderImageData->horizStretch], tileMode2TileRule[borderImageData->vertStretch])); |
1144 p->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothPixmapTransform); |
1145 p->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothPixmapTransform); |
|
1146 unsetClip(p); |
1145 } |
1147 } |
1146 |
1148 |
1147 QRect QRenderRule::originRect(const QRect &rect, Origin origin) const |
1149 QRect QRenderRule::originRect(const QRect &rect, Origin origin) const |
1148 { |
1150 { |
1149 switch (origin) { |
1151 switch (origin) { |
5609 case SE_ItemViewItemText: |
5611 case SE_ItemViewItemText: |
5610 case SE_ItemViewItemDecoration: |
5612 case SE_ItemViewItemDecoration: |
5611 case SE_ItemViewItemFocusRect: |
5613 case SE_ItemViewItemFocusRect: |
5612 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { |
5614 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { |
5613 QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem); |
5615 QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem); |
5614 QStyleOptionViewItemV4 optCopy(*vopt); |
|
5615 optCopy.rect = subRule.contentsRect(vopt->rect); |
|
5616 QRect rect = ParentStyle::subElementRect(se, &optCopy, w); |
|
5617 PseudoElement pe = PseudoElement_None; |
5616 PseudoElement pe = PseudoElement_None; |
5618 if (se == SE_ItemViewItemText || se == SE_ItemViewItemFocusRect) |
5617 if (se == SE_ItemViewItemText || se == SE_ItemViewItemFocusRect) |
5619 pe = PseudoElement_ViewItemText; |
5618 pe = PseudoElement_ViewItemText; |
5620 else if (se == SE_ItemViewItemDecoration && vopt->features & QStyleOptionViewItemV2::HasDecoration) |
5619 else if (se == SE_ItemViewItemDecoration && vopt->features & QStyleOptionViewItemV2::HasDecoration) |
5621 pe = PseudoElement_ViewItemIcon; |
5620 pe = PseudoElement_ViewItemIcon; |
5622 else if (se == SE_ItemViewItemCheckIndicator && vopt->features & QStyleOptionViewItemV2::HasCheckIndicator) |
5621 else if (se == SE_ItemViewItemCheckIndicator && vopt->features & QStyleOptionViewItemV2::HasCheckIndicator) |
5623 pe = PseudoElement_ViewItemIndicator; |
5622 pe = PseudoElement_ViewItemIndicator; |
5624 else |
5623 else |
5625 break; |
5624 break; |
5626 QRenderRule subRule2 = renderRule(w, opt, pe); |
5625 if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || hasStyleRule(w, pe)) { |
5627 return positionRect(w, subRule2, pe, rect, opt->direction); |
5626 QRenderRule subRule2 = renderRule(w, opt, pe); |
|
5627 QStyleOptionViewItemV4 optCopy(*vopt); |
|
5628 optCopy.rect = subRule.contentsRect(vopt->rect); |
|
5629 QRect rect = ParentStyle::subElementRect(se, &optCopy, w); |
|
5630 return positionRect(w, subRule2, pe, rect, opt->direction); |
|
5631 } |
5628 } |
5632 } |
5629 break; |
5633 break; |
5630 #endif // QT_NO_ITEMVIEWS |
5634 #endif // QT_NO_ITEMVIEWS |
5631 |
5635 |
5632 case SE_HeaderArrow: { |
5636 case SE_HeaderArrow: { |
5737 break; |
5741 break; |
5738 QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetTitle); |
5742 QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetTitle); |
5739 return positionRect(w, subRule, subRule2, pe, opt->rect, opt->direction); |
5743 return positionRect(w, subRule, subRule2, pe, opt->rect, opt->direction); |
5740 } |
5744 } |
5741 |
5745 |
|
5746 #ifndef QT_NO_TOOLBAR |
|
5747 case SE_ToolBarHandle: |
|
5748 if (hasStyleRule(w, PseudoElement_ToolBarHandle)) |
|
5749 return ParentStyle::subElementRect(se, opt, w); |
|
5750 break; |
|
5751 #endif //QT_NO_TOOLBAR |
|
5752 |
5742 default: |
5753 default: |
5743 break; |
5754 break; |
5744 } |
5755 } |
5745 |
5756 |
5746 return baseStyle()->subElementRect(se, opt, w); |
5757 return baseStyle()->subElementRect(se, opt, w); |