308 QColor retColor (color); |
308 QColor retColor (color); |
309 if (option && !(option->state & QStyle::State_Enabled)) { |
309 if (option && !(option->state & QStyle::State_Enabled)) { |
310 QColor hsvColor = retColor.toHsv(); |
310 QColor hsvColor = retColor.toHsv(); |
311 int colorSat = hsvColor.saturation(); |
311 int colorSat = hsvColor.saturation(); |
312 int colorVal = hsvColor.value(); |
312 int colorVal = hsvColor.value(); |
313 colorSat = (colorSat!=0) ? (colorSat>>1) : 128; |
313 colorSat = (colorSat != 0) ? (colorSat >> 1) : 128; |
314 colorVal = (colorVal!=0) ? (colorVal>>1) : 128; |
314 colorVal = (colorVal != 0) ? (colorVal >> 1) : 128; |
315 hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal); |
315 hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal); |
316 retColor = hsvColor.toRgb(); |
316 retColor = hsvColor.toRgb(); |
317 } |
317 } |
318 return retColor; |
318 return retColor; |
319 } |
319 } |
354 actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY(); |
355 actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY(); |
355 } |
356 } |
356 Q_ASSERT(actualPointSize > 0); |
357 Q_ASSERT(actualPointSize > 0); |
357 const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize); |
358 const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize); |
358 if (!m_mappedFontsCache.contains(key)) { |
359 if (!m_mappedFontsCache.contains(key)) { |
359 result = s60Font_specific(fontCategory, actualPointSize); |
360 result = s60Font_specific(fontCategory, actualPointSize, resolveFontSize); |
360 m_mappedFontsCache.insert(key, result); |
361 m_mappedFontsCache.insert(key, result); |
361 } else { |
362 } else { |
362 result = m_mappedFontsCache.value(key); |
363 result = m_mappedFontsCache.value(key); |
363 if (result.pointSize() != actualPointSize) |
364 if (result.pointSize() != actualPointSize) |
364 result.setPointSize(actualPointSize); |
365 result.setPointSize(actualPointSize); |
398 { |
398 { |
399 const bool cachedColorExists = m_colorCache.contains(frame); |
399 const bool cachedColorExists = m_colorCache.contains(frame); |
400 if (!cachedColorExists) { |
400 if (!cachedColorExists) { |
401 const int frameCornerWidth = pixelMetric(PM_Custom_FrameCornerWidth); |
401 const int frameCornerWidth = pixelMetric(PM_Custom_FrameCornerWidth); |
402 const int frameCornerHeight = pixelMetric(PM_Custom_FrameCornerHeight); |
402 const int frameCornerHeight = pixelMetric(PM_Custom_FrameCornerHeight); |
403 Q_ASSERT(2*frameCornerWidth<32); |
403 Q_ASSERT(2 * frameCornerWidth < 32); |
404 Q_ASSERT(2*frameCornerHeight<32); |
404 Q_ASSERT(2 * frameCornerHeight < 32); |
405 |
405 |
406 const QImage frameImage = QS60StylePrivate::frame(frame, QSize(32,32)).toImage(); |
406 const QImage frameImage = QS60StylePrivate::frame(frame, QSize(32, 32)).toImage(); |
407 Q_ASSERT(frameImage.bytesPerLine() > 0); |
407 Q_ASSERT(frameImage.bytesPerLine() > 0); |
408 if (frameImage.isNull()) |
408 if (frameImage.isNull()) |
409 return Qt::black; |
409 return Qt::black; |
410 |
410 |
411 const QRgb *pixelRgb = (const QRgb*)frameImage.bits(); |
411 const QRgb *pixelRgb = (const QRgb*)frameImage.bits(); |
416 int estimatedBlue = 0; |
416 int estimatedBlue = 0; |
417 |
417 |
418 int skips = 0; |
418 int skips = 0; |
419 int estimations = 0; |
419 int estimations = 0; |
420 |
420 |
421 const int topBorderLastPixel = frameCornerHeight*frameImage.width()-1; |
421 const int topBorderLastPixel = frameCornerHeight*frameImage.width() - 1; |
422 const int bottomBorderFirstPixel = frameImage.width()*frameImage.height()-frameCornerHeight*frameImage.width()-1; |
422 const int bottomBorderFirstPixel = frameImage.width() * frameImage.height() - frameCornerHeight*frameImage.width() - 1; |
423 const int rightBorderFirstPixel = frameImage.width()-frameCornerWidth; |
423 const int rightBorderFirstPixel = frameImage.width() - frameCornerWidth; |
424 const int leftBorderLastPixel = frameCornerWidth; |
424 const int leftBorderLastPixel = frameCornerWidth; |
425 |
425 |
426 while ((skips + estimations) < pixels) { |
426 while ((skips + estimations) < pixels) { |
427 if ((skips+estimations) > topBorderLastPixel && |
427 if ((skips + estimations) > topBorderLastPixel && |
428 (skips+estimations) < bottomBorderFirstPixel) { |
428 (skips + estimations) < bottomBorderFirstPixel) { |
429 for (int rowIndex = 0; rowIndex < frameImage.width(); rowIndex++) { |
429 for (int rowIndex = 0; rowIndex < frameImage.width(); rowIndex++) { |
430 if (rowIndex > leftBorderLastPixel && |
430 if (rowIndex > leftBorderLastPixel && |
431 rowIndex < rightBorderFirstPixel) { |
431 rowIndex < rightBorderFirstPixel) { |
432 estimatedRed += qRed(*pixelRgb); |
432 estimatedRed += qRed(*pixelRgb); |
433 estimatedGreen += qGreen(*pixelRgb); |
433 estimatedGreen += qGreen(*pixelRgb); |
528 if (orientation == Qt::Horizontal) { |
528 if (orientation == Qt::Horizontal) { |
529 startRect.setWidth(qMin((rect.width() >> 1) - 1, startRect.width())); |
529 startRect.setWidth(qMin((rect.width() >> 1) - 1, startRect.width())); |
530 endRect = startRect.translated(rect.width() - startRect.width(), 0); |
530 endRect = startRect.translated(rect.width() - startRect.width(), 0); |
531 middleRect.adjust(startRect.width(), 0, -startRect.width(), 0); |
531 middleRect.adjust(startRect.width(), 0, -startRect.width(), 0); |
532 if (startRect.bottomRight().x() > endRect.topLeft().x()) { |
532 if (startRect.bottomRight().x() > endRect.topLeft().x()) { |
533 const int overlap = (startRect.bottomRight().x() - endRect.topLeft().x())>>1; |
533 const int overlap = (startRect.bottomRight().x() - endRect.topLeft().x()) >> 1; |
534 startRect.setWidth(startRect.width()-overlap); |
534 startRect.setWidth(startRect.width() - overlap); |
535 endRect.adjust(overlap,0,0,0); |
535 endRect.adjust(overlap, 0, 0, 0); |
536 } |
536 } |
537 } else { |
537 } else { |
538 startRect.setHeight(qMin((rect.height() >> 1) - 1, startRect.height())); |
538 startRect.setHeight(qMin((rect.height() >> 1) - 1, startRect.height())); |
539 endRect = startRect.translated(0, rect.height() - startRect.height()); |
539 endRect = startRect.translated(0, rect.height() - startRect.height()); |
540 middleRect.adjust(0, startRect.height(), 0, -startRect.height()); |
540 middleRect.adjust(0, startRect.height(), 0, -startRect.height()); |
541 if (startRect.topRight().y() > endRect.bottomLeft().y()) { |
541 if (startRect.topRight().y() > endRect.bottomLeft().y()) { |
542 const int overlap = (startRect.topRight().y() - endRect.bottomLeft().y())>>1; |
542 const int overlap = (startRect.topRight().y() - endRect.bottomLeft().y()) >> 1; |
543 startRect.setHeight(startRect.height()-overlap); |
543 startRect.setHeight(startRect.height() - overlap); |
544 endRect.adjust(0,overlap,0,0); |
544 endRect.adjust(0, overlap, 0, 0); |
545 } |
545 } |
546 } |
546 } |
547 |
547 |
548 #if 0 |
548 #if 0 |
549 painter->save(); |
549 painter->save(); |
619 fontCategory = QS60StyleEnums::FC_Secondary; |
619 fontCategory = QS60StyleEnums::FC_Secondary; |
620 } else if (qobject_cast<QGroupBox *>(widget)){ |
620 } else if (qobject_cast<QGroupBox *>(widget)){ |
621 fontCategory = QS60StyleEnums::FC_Title; |
621 fontCategory = QS60StyleEnums::FC_Title; |
622 } |
622 } |
623 if (fontCategory != QS60StyleEnums::FC_Undefined) { |
623 if (fontCategory != QS60StyleEnums::FC_Undefined) { |
|
624 const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont) |
|
625 && (widget->font().resolve() & QFont::SizeResolved); |
624 const QFont suggestedFont = |
626 const QFont suggestedFont = |
625 s60Font(fontCategory, widget->font().pointSizeF()); |
627 s60Font(fontCategory, widget->font().pointSizeF(), resolveFontSize); |
626 widget->setFont(suggestedFont); |
628 widget->setFont(suggestedFont); |
627 } |
629 } |
628 } |
630 } |
629 |
631 |
630 void QS60StylePrivate::setThemePalette(QWidget *widget) const |
632 void QS60StylePrivate::setThemePalette(QWidget *widget) const |
807 case QS60StyleEnums::SP_QgnGrafTabPassiveR: |
809 case QS60StyleEnums::SP_QgnGrafTabPassiveR: |
808 case QS60StyleEnums::SP_QgnGrafTabPassiveL: |
810 case QS60StyleEnums::SP_QgnGrafTabPassiveL: |
809 case QS60StyleEnums::SP_QgnGrafTabActiveL: |
811 case QS60StyleEnums::SP_QgnGrafTabActiveL: |
810 //Returned QSize for tabs must not be square, but narrow rectangle with width:height |
812 //Returned QSize for tabs must not be square, but narrow rectangle with width:height |
811 //ratio of 1:2 for horizontal tab bars (and 2:1 for vertical ones). |
813 //ratio of 1:2 for horizontal tab bars (and 2:1 for vertical ones). |
812 result.setWidth(result.height()>>1); |
814 result.setWidth(result.height() >> 1); |
813 break; |
815 break; |
814 |
816 |
815 case QS60StyleEnums::SP_QgnGrafNsliderEndLeft: |
817 case QS60StyleEnums::SP_QgnGrafNsliderEndLeft: |
816 case QS60StyleEnums::SP_QgnGrafNsliderEndRight: |
818 case QS60StyleEnums::SP_QgnGrafNsliderEndRight: |
817 case QS60StyleEnums::SP_QgnGrafNsliderMiddle: |
819 case QS60StyleEnums::SP_QgnGrafNsliderMiddle: |
818 result.setWidth(result.height()>>1); |
820 result.setWidth(result.height() >> 1); |
819 break; |
821 break; |
820 |
822 |
821 case QS60StyleEnums::SP_QgnGrafNsliderMarker: |
823 case QS60StyleEnums::SP_QgnGrafNsliderMarker: |
822 case QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected: |
824 case QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected: |
823 result.scale(pixelMetric(QStyle::PM_SliderLength), |
825 result.scale(pixelMetric(QStyle::PM_SliderLength), |
990 // Button frame |
992 // Button frame |
991 QStyleOptionFrame buttonOption; |
993 QStyleOptionFrame buttonOption; |
992 buttonOption.QStyleOption::operator=(*cmb); |
994 buttonOption.QStyleOption::operator=(*cmb); |
993 const int maxHeight = cmbxFrame.height(); |
995 const int maxHeight = cmbxFrame.height(); |
994 const int maxWidth = cmbxFrame.width() - cmbxEditField.width(); |
996 const int maxWidth = cmbxFrame.width() - cmbxEditField.width(); |
995 const int topLeftPoint = direction ? cmbxEditField.right()+1 : cmbxEditField.left()+1-maxWidth; |
997 const int topLeftPoint = direction ? |
|
998 (cmbxEditField.right() + 1) : (cmbxEditField.left() + 1 - maxWidth); |
996 const QRect buttonRect(topLeftPoint, cmbxEditField.top(), maxWidth, maxHeight); |
999 const QRect buttonRect(topLeftPoint, cmbxEditField.top(), maxWidth, maxHeight); |
997 buttonOption.rect = buttonRect; |
1000 buttonOption.rect = buttonRect; |
998 buttonOption.state = cmb->state & (State_Enabled | State_MouseOver); |
1001 buttonOption.state = cmb->state; |
999 drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget); |
1002 drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget); |
1000 |
1003 |
1001 // draw label background - label itself is drawn separately |
1004 // draw label background - label itself is drawn separately |
1002 const QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_FrameLineEdit; |
1005 const QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_FrameLineEdit; |
1003 QS60StylePrivate::drawSkinElement(skinElement, painter, cmbxEditField, flags); |
1006 QS60StylePrivate::drawSkinElement(skinElement, painter, cmbxEditField, flags); |
1379 if (vopt->backgroundBrush == Qt::NoBrush) { |
1382 if (vopt->backgroundBrush == Qt::NoBrush) { |
1380 if (itemView) { |
1383 if (itemView) { |
1381 const QModelIndex index = vopt->index; |
1384 const QModelIndex index = vopt->index; |
1382 //todo: Draw cell background only once - for the first cell. |
1385 //todo: Draw cell background only once - for the first cell. |
1383 QStyleOptionViewItemV4 voptAdj2 = voptAdj; |
1386 QStyleOptionViewItemV4 voptAdj2 = voptAdj; |
1384 const QModelIndex indexFirst = itemView->model()->index(0,0); |
1387 const QModelIndex indexFirst = itemView->model()->index(0, 0); |
1385 const QModelIndex indexLast = itemView->model()->index( |
1388 const QModelIndex indexLast = itemView->model()->index( |
1386 itemView->model()->rowCount()-1,itemView->model()->columnCount()-1); |
1389 itemView->model()->rowCount() - 1, itemView->model()->columnCount() -1); |
1387 if (itemView->viewport()) |
1390 if (itemView->viewport()) |
1388 voptAdj2.rect = QRect( itemView->visualRect(indexFirst).topLeft(), |
1391 voptAdj2.rect = QRect( itemView->visualRect(indexFirst).topLeft(), |
1389 itemView->visualRect(indexLast).bottomRight()).intersect(itemView->viewport()->rect()); |
1392 itemView->visualRect(indexLast).bottomRight()).intersect(itemView->viewport()->rect()); |
1390 drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); |
1393 drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); |
1391 } |
1394 } |
1569 painter->save(); |
1572 painter->save(); |
1570 QFont f = painter->font(); |
1573 QFont f = painter->font(); |
1571 f.setPointSizeF(f.pointSizeF() * KTabFontMul); |
1574 f.setPointSizeF(f.pointSizeF() * KTabFontMul); |
1572 painter->setFont(f); |
1575 painter->setFont(f); |
1573 |
1576 |
1574 if (option->state & QStyle::State_Selected){ |
1577 const bool selected = optionTab.state & State_Selected; |
|
1578 if (selected) |
1575 optionTab.palette.setColor(QPalette::Active, QPalette::WindowText, |
1579 optionTab.palette.setColor(QPalette::Active, QPalette::WindowText, |
1576 QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 3, option)); |
1580 QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 3, option)); |
1577 } |
|
1578 |
1581 |
1579 const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast |
1582 const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast |
1580 || optionTab.shape == QTabBar::RoundedWest |
1583 || optionTab.shape == QTabBar::RoundedWest |
1581 || optionTab.shape == QTabBar::TriangularEast |
1584 || optionTab.shape == QTabBar::TriangularEast |
1582 || optionTab.shape == QTabBar::TriangularWest; |
1585 || optionTab.shape == QTabBar::TriangularWest; |
1583 const bool selected = optionTab.state & State_Selected; |
1586 |
1584 if (verticalTabs) { |
1587 if (verticalTabs) { |
1585 painter->save(); |
1588 painter->save(); |
1586 int newX, newY, newRotation; |
1589 int newX, newY, newRotation; |
1587 if (optionTab.shape == QTabBar::RoundedEast || optionTab.shape == QTabBar::TriangularEast) { |
1590 if (optionTab.shape == QTabBar::RoundedEast || optionTab.shape == QTabBar::TriangularEast) { |
1588 newX = tr.width(); |
1591 newX = tr.width(); |
1616 if (iconSize.height() > iconExtent || iconSize.width() > iconExtent) |
1619 if (iconSize.height() > iconExtent || iconSize.width() > iconExtent) |
1617 iconSize = QSize(iconExtent, iconExtent); |
1620 iconSize = QSize(iconExtent, iconExtent); |
1618 QPixmap tabIcon = optionTab.icon.pixmap(iconSize, |
1621 QPixmap tabIcon = optionTab.icon.pixmap(iconSize, |
1619 (optionTab.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); |
1622 (optionTab.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); |
1620 if (tab->text.isEmpty()) |
1623 if (tab->text.isEmpty()) |
1621 painter->drawPixmap(tr.center().x() - (tabIcon.height() >>1), |
1624 painter->drawPixmap(tr.center().x() - (tabIcon.height() >> 1), |
1622 tr.center().y() - (tabIcon.height() >>1), |
1625 tr.center().y() - (tabIcon.height() >> 1), |
1623 tabIcon); |
1626 tabIcon); |
1624 else |
1627 else |
1625 painter->drawPixmap(tr.left() + tabOverlap, |
1628 painter->drawPixmap(tr.left() + tabOverlap, |
1626 tr.center().y() - (tabIcon.height() >>1), |
1629 tr.center().y() - (tabIcon.height() >> 1), |
1627 tabIcon); |
1630 tabIcon); |
1628 tr.setLeft(tr.left() + iconSize.width() + 4); |
1631 tr.setLeft(tr.left() + iconSize.width() + 4); |
1629 } |
1632 } |
1630 |
1633 |
1631 QCommonStyle::drawItemText(painter, tr, alignment, optionTab.palette, tab->state & State_Enabled, tab->text, QPalette::WindowText); |
1634 QCommonStyle::drawItemText(painter, tr, alignment, optionTab.palette, tab->state & State_Enabled, tab->text, QPalette::WindowText); |
1650 const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? 1.0 |
1653 const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? 1.0 |
1651 : (qreal)optionProgressBar->progress / optionProgressBar->maximum; |
1654 : (qreal)optionProgressBar->progress / optionProgressBar->maximum; |
1652 if (optionProgressBar->orientation == Qt::Horizontal) { |
1655 if (optionProgressBar->orientation == Qt::Horizontal) { |
1653 progressRect.setWidth(int(progressRect.width() * progressFactor)); |
1656 progressRect.setWidth(int(progressRect.width() * progressFactor)); |
1654 if(optionProgressBar->direction == Qt::RightToLeft) |
1657 if(optionProgressBar->direction == Qt::RightToLeft) |
1655 progressRect.translate(optionProgressBar->rect.width()-progressRect.width(),0); |
1658 progressRect.translate(optionProgressBar->rect.width()-progressRect.width(), 0); |
1656 progressRect.adjust(1, 0, -1, 0); |
1659 progressRect.adjust(1, 0, -1, 0); |
1657 } else { |
1660 } else { |
1658 progressRect.adjust(0, 1, 0, -1); |
1661 progressRect.adjust(0, 1, 0, -1); |
1659 progressRect.setTop(progressRect.bottom() - int(progressRect.height() * progressFactor)); |
1662 progressRect.setTop(progressRect.bottom() - int(progressRect.height() * progressFactor)); |
1660 } |
1663 } |
1716 const int hSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); |
1719 const int hSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); |
1717 QStyleOptionMenuItem optionCheckBox; |
1720 QStyleOptionMenuItem optionCheckBox; |
1718 optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); |
1721 optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); |
1719 optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); |
1722 optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); |
1720 optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); |
1723 optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); |
1721 const int moveByX = optionCheckBox.rect.width()+vSpacing; |
1724 const int moveByX = optionCheckBox.rect.width() + vSpacing; |
1722 if (optionMenuItem.direction == Qt::LeftToRight) { |
1725 if (optionMenuItem.direction == Qt::LeftToRight) { |
1723 textRect.translate(moveByX,0); |
1726 textRect.translate(moveByX, 0); |
1724 iconRect.translate(moveByX, 0); |
1727 iconRect.translate(moveByX, 0); |
1725 iconRect.setWidth(iconRect.width()+vSpacing); |
1728 iconRect.setWidth(iconRect.width() + vSpacing); |
1726 textRect.setWidth(textRect.width()-moveByX-vSpacing); |
1729 textRect.setWidth(textRect.width() - moveByX - vSpacing); |
1727 optionCheckBox.rect.translate(vSpacing/2, hSpacing/2); |
1730 optionCheckBox.rect.translate(vSpacing >> 1, hSpacing >> 1); |
1728 } else { |
1731 } else { |
1729 textRect.setWidth(textRect.width()-moveByX); |
1732 textRect.setWidth(textRect.width() - moveByX); |
1730 iconRect.setWidth(iconRect.width()+vSpacing); |
1733 iconRect.setWidth(iconRect.width() + vSpacing); |
1731 iconRect.translate(-optionCheckBox.rect.width()-vSpacing, 0); |
1734 iconRect.translate(-optionCheckBox.rect.width() - vSpacing, 0); |
1732 optionCheckBox.rect.translate(textRect.width()+iconRect.width(),0); |
1735 optionCheckBox.rect.translate(textRect.width() + iconRect.width(), 0); |
1733 } |
1736 } |
1734 drawPrimitive(PE_IndicatorMenuCheckMark, &optionCheckBox, painter, widget); |
1737 drawPrimitive(PE_IndicatorMenuCheckMark, &optionCheckBox, painter, widget); |
1735 } |
1738 } |
1736 //draw icon and/or checkState |
1739 //draw icon and/or checkState |
1737 QPixmap pix = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize), |
1740 QPixmap pix = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize), |
1738 enabled ? QIcon::Normal : QIcon::Disabled); |
1741 enabled ? QIcon::Normal : QIcon::Disabled); |
1739 const bool itemWithIcon = !pix.isNull(); |
1742 const bool itemWithIcon = !pix.isNull(); |
1740 if (itemWithIcon) { |
1743 if (itemWithIcon) { |
1741 drawItemPixmap(painter, iconRect, text_flags, pix); |
1744 drawItemPixmap(painter, iconRect, text_flags, pix); |
1742 if (optionMenuItem.direction == Qt::LeftToRight) |
1745 if (optionMenuItem.direction == Qt::LeftToRight) |
1743 textRect.translate(vSpacing,0); |
1746 textRect.translate(vSpacing, 0); |
1744 else |
1747 else |
1745 textRect.translate(-vSpacing,0); |
1748 textRect.translate(-vSpacing, 0); |
1746 textRect.setWidth(textRect.width()-vSpacing); |
1749 textRect.setWidth(textRect.width()-vSpacing); |
1747 } |
1750 } |
1748 |
1751 |
1749 //draw indicators |
1752 //draw indicators |
1750 if (drawSubMenuIndicator) { |
1753 if (drawSubMenuIndicator) { |
1751 QStyleOptionMenuItem arrowOptions; |
1754 QStyleOptionMenuItem arrowOptions; |
1752 arrowOptions.QStyleOption::operator=(*menuItem); |
1755 arrowOptions.QStyleOption::operator=(*menuItem); |
1753 const int indicatorWidth = (pixelMetric(PM_ListViewIconSize, option, widget)>>1) + |
1756 const int indicatorWidth = (pixelMetric(PM_ListViewIconSize, option, widget) >> 1) + |
1754 pixelMetric(QStyle::PM_LayoutVerticalSpacing, option, widget); |
1757 pixelMetric(QStyle::PM_LayoutVerticalSpacing, option, widget); |
1755 if (optionMenuItem.direction == Qt::LeftToRight) |
1758 if (optionMenuItem.direction == Qt::LeftToRight) |
1756 arrowOptions.rect.setLeft(textRect.right()); |
1759 arrowOptions.rect.setLeft(textRect.right()); |
1757 arrowOptions.rect.setWidth(indicatorWidth); |
1760 arrowOptions.rect.setWidth(indicatorWidth); |
1758 //by default sub menu indicator in S60 points to east,so here icon |
1761 //by default sub menu indicator in S60 points to east,so here icon |
1793 case CE_HeaderSection: |
1796 case CE_HeaderSection: |
1794 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
1797 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
1795 painter->save(); |
1798 painter->save(); |
1796 QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); |
1799 QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); |
1797 const int penWidth = (header->orientation == Qt::Horizontal) ? |
1800 const int penWidth = (header->orientation == Qt::Horizontal) ? |
1798 linePen.width()+QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth) |
1801 linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth) |
1799 : linePen.width()+QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth); |
1802 : linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth); |
1800 linePen.setWidth(penWidth); |
1803 linePen.setWidth(penWidth); |
1801 painter->setPen(linePen); |
1804 painter->setPen(linePen); |
1802 if (header->orientation == Qt::Horizontal){ |
1805 if (header->orientation == Qt::Horizontal){ |
1803 painter->drawLine(header->rect.bottomLeft(), header->rect.bottomRight()); |
1806 painter->drawLine(header->rect.bottomLeft(), header->rect.bottomRight()); |
1804 } else { |
1807 } else { |
1813 //Draw corner button as normal pushButton. |
1816 //Draw corner button as normal pushButton. |
1814 if (qobject_cast<const QAbstractButton *>(widget)) { |
1817 if (qobject_cast<const QAbstractButton *>(widget)) { |
1815 //Make cornerButton slightly smaller so that it is not on top of table border graphic. |
1818 //Make cornerButton slightly smaller so that it is not on top of table border graphic. |
1816 QStyleOptionHeader subopt = *header; |
1819 QStyleOptionHeader subopt = *header; |
1817 const int borderTweak = |
1820 const int borderTweak = |
1818 QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth)>>1; |
1821 QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; |
1819 if (subopt.direction == Qt::LeftToRight) |
1822 if (subopt.direction == Qt::LeftToRight) |
1820 subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); |
1823 subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); |
1821 else |
1824 else |
1822 subopt.rect.adjust(0, borderTweak, -borderTweak, -borderTweak); |
1825 subopt.rect.adjust(0, borderTweak, -borderTweak, -borderTweak); |
1823 drawPrimitive(PE_PanelButtonBevel, &subopt, painter, widget); |
1826 drawPrimitive(PE_PanelButtonBevel, &subopt, painter, widget); |
1906 //todo: update to horizontal table graphic |
1909 //todo: update to horizontal table graphic |
1907 adjustableFlags = (adjustableFlags | QS60StylePrivate::SF_PointWest); |
1910 adjustableFlags = (adjustableFlags | QS60StylePrivate::SF_PointWest); |
1908 } else { |
1911 } else { |
1909 const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
1912 const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
1910 if (option->direction == Qt::LeftToRight) |
1913 if (option->direction == Qt::LeftToRight) |
1911 headerRect.adjust(-2*frameWidth, 0, 0, 0); |
1914 headerRect.adjust(-2 * frameWidth, 0, 0, 0); |
1912 else |
1915 else |
1913 headerRect.adjust(0, 0, 2*frameWidth, 0); |
1916 headerRect.adjust(0, 0, 2 * frameWidth, 0); |
1914 } |
1917 } |
1915 if (option->palette.brush(QPalette::Button).color() == Qt::transparent) |
1918 if (option->palette.brush(QPalette::Button).color() == Qt::transparent) |
1916 QS60StylePrivate::drawSkinElement( |
1919 QS60StylePrivate::drawSkinElement( |
1917 QS60StylePrivate::SE_TableHeaderItem, painter, headerRect, adjustableFlags); |
1920 QS60StylePrivate::SE_TableHeaderItem, painter, headerRect, adjustableFlags); |
1918 |
1921 |
2031 // ... or normal "tick" selection at the end. |
2034 // ... or normal "tick" selection at the end. |
2032 } else if (option->state & QStyle::State_Selected) { |
2035 } else if (option->state & QStyle::State_Selected) { |
2033 QRect tickRect = option->rect; |
2036 QRect tickRect = option->rect; |
2034 const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); |
2037 const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); |
2035 // adjust tickmark rect to exclude frame border |
2038 // adjust tickmark rect to exclude frame border |
2036 tickRect.adjust(0,-frameBorderWidth,0,-frameBorderWidth); |
2039 tickRect.adjust(0, -frameBorderWidth, 0, -frameBorderWidth); |
2037 QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd; |
2040 QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd; |
2038 QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect, |
2041 QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect, |
2039 (flags | QS60StylePrivate::SF_ColorSkinned)); |
2042 (flags | QS60StylePrivate::SF_ColorSkinned)); |
2040 } |
2043 } |
2041 } |
2044 } |
2043 #endif //QT_NO_ITEMVIEWS |
2046 #endif //QT_NO_ITEMVIEWS |
2044 break; |
2047 break; |
2045 case PE_IndicatorRadioButton: { |
2048 case PE_IndicatorRadioButton: { |
2046 QRect buttonRect = option->rect; |
2049 QRect buttonRect = option->rect; |
2047 //there is empty (a. 33%) space in svg graphics for radiobutton |
2050 //there is empty (a. 33%) space in svg graphics for radiobutton |
2048 const qreal reduceWidth = (qreal)buttonRect.width()/3.0; |
2051 const qreal reduceWidth = (qreal)buttonRect.width() / 3.0; |
2049 const qreal rectWidth = (qreal)option->rect.width() != 0 ? option->rect.width() : 1.0; |
2052 const qreal rectWidth = (qreal)option->rect.width() != 0 ? option->rect.width() : 1.0; |
2050 // Try to occupy the full area |
2053 // Try to occupy the full area |
2051 const qreal scaler = 1 + (reduceWidth/rectWidth); |
2054 const qreal scaler = 1 + (reduceWidth/rectWidth); |
2052 buttonRect.setWidth((int)((buttonRect.width()-reduceWidth) * scaler)); |
2055 buttonRect.setWidth((int)((buttonRect.width()-reduceWidth) * scaler)); |
2053 buttonRect.setHeight((int)(buttonRect.height() * scaler)); |
2056 buttonRect.setHeight((int)(buttonRect.height() * scaler)); |
2106 #endif //QT_NO_TOOLBUTTON |
2109 #endif //QT_NO_TOOLBUTTON |
2107 #ifndef QT_NO_SPINBOX |
2110 #ifndef QT_NO_SPINBOX |
2108 case PE_IndicatorSpinDown: |
2111 case PE_IndicatorSpinDown: |
2109 case PE_IndicatorSpinUp: |
2112 case PE_IndicatorSpinUp: |
2110 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2113 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2111 QStyleOptionSpinBox optionSpinBox = *spinBox; |
2114 if (QS60StylePrivate::canDrawThemeBackground(spinBox->palette.base())) { |
2112 if (QS60StylePrivate::canDrawThemeBackground(optionSpinBox.palette.base())) { |
2115 QStyleOptionSpinBox optionSpinBox = *spinBox; |
2113 const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? |
2116 const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? |
2114 QS60StyleEnums::SP_QgnGrafScrollArrowUp : |
2117 QS60StyleEnums::SP_QgnGrafScrollArrowUp : |
2115 QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2118 QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2116 const int adjustment = qMin(optionSpinBox.rect.width(), optionSpinBox.rect.height())/6; |
2119 const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; |
2117 optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); |
2120 optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2118 QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect,flags); |
2121 QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect, flags); |
2119 } else { |
2122 } else { |
2120 commonStyleDraws = true; |
2123 commonStyleDraws = true; |
2121 } |
2124 } |
2122 } |
2125 } |
|
2126 #endif //QT_NO_SPINBOX |
2123 #ifndef QT_NO_COMBOBOX |
2127 #ifndef QT_NO_COMBOBOX |
2124 else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2128 if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2125 if (QS60StylePrivate::canDrawThemeBackground( option->palette.base())) { |
2129 if (QS60StylePrivate::canDrawThemeBackground( option->palette.base())) { |
2126 // We want to draw down arrow here for comboboxes as well. |
2130 // We want to draw down arrow here for comboboxes as well. |
|
2131 QStyleOptionFrame optionsComboBox = *cmb; |
2127 const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2132 const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2128 QStyleOptionFrame comboBox = *cmb; |
2133 const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; |
2129 const int adjustment = qMin(comboBox.rect.width(), comboBox.rect.height())/6; |
2134 optionsComboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2130 comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); |
2135 QS60StylePrivate::drawSkinPart(part, painter, optionsComboBox.rect, flags); |
2131 QS60StylePrivate::drawSkinPart(part, painter, comboBox.rect,flags); |
|
2132 } else { |
2136 } else { |
2133 commonStyleDraws = true; |
2137 commonStyleDraws = true; |
2134 } |
2138 } |
2135 } |
2139 } |
2136 #endif //QT_NO_COMBOBOX |
2140 #endif //QT_NO_COMBOBOX |
2144 #ifndef QT_NO_COMBOBOX |
2148 #ifndef QT_NO_COMBOBOX |
2145 else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2149 else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2146 // We want to draw down arrow here for comboboxes as well. |
2150 // We want to draw down arrow here for comboboxes as well. |
2147 QStyleOptionFrame comboBox = *cmb; |
2151 QStyleOptionFrame comboBox = *cmb; |
2148 const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
2152 const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
2149 comboBox.rect.adjust(0,frameWidth,0,-frameWidth); |
2153 comboBox.rect.adjust(0, frameWidth, 0, -frameWidth); |
2150 QCommonStyle::drawPrimitive(element, &comboBox, painter, widget); |
2154 QCommonStyle::drawPrimitive(element, &comboBox, painter, widget); |
2151 } |
2155 } |
2152 #endif //QT_NO_COMBOBOX |
2156 #endif //QT_NO_COMBOBOX |
2153 break; |
2157 break; |
2154 #endif //QT_NO_SPINBOX |
|
2155 case PE_Widget: |
2158 case PE_Widget: |
2156 if (QS60StylePrivate::drawsOwnThemeBackground(widget) |
2159 if (QS60StylePrivate::drawsOwnThemeBackground(widget) |
2157 #ifndef QT_NO_COMBOBOX |
2160 #ifndef QT_NO_COMBOBOX |
2158 || qobject_cast<const QComboBoxListView *>(widget) |
2161 || qobject_cast<const QComboBoxListView *>(widget) |
2159 #endif //QT_NO_COMBOBOX |
2162 #endif //QT_NO_COMBOBOX |
2160 #ifndef QT_NO_MENU |
2163 #ifndef QT_NO_MENU |
2161 || qobject_cast<const QMenu *> (widget) |
2164 || qobject_cast<const QMenu *> (widget) |
2162 #endif //QT_NO_MENU |
2165 #endif //QT_NO_MENU |
2163 ) { |
2166 ) { |
2164 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) |
2167 //Need extra check since dialogs have their own theme background |
|
2168 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base()) && |
|
2169 option->palette.window().texture().cacheKey() == |
|
2170 QS60StylePrivate::m_themePalette->window().texture().cacheKey()) |
2165 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_OptionsMenu, painter, option->rect, flags); |
2171 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_OptionsMenu, painter, option->rect, flags); |
2166 else |
2172 else |
2167 commonStyleDraws = true; |
2173 commonStyleDraws = true; |
2168 } |
2174 } |
2169 break; |
2175 break; |
2336 QSize sz(csz); |
2342 QSize sz(csz); |
2337 switch (ct) { |
2343 switch (ct) { |
2338 case CT_ToolButton: |
2344 case CT_ToolButton: |
2339 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2345 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2340 //FIXME properly - style should calculate the location of border frame-part |
2346 //FIXME properly - style should calculate the location of border frame-part |
2341 sz += QSize(2*pixelMetric(PM_ButtonMargin), 2*pixelMetric(PM_ButtonMargin)); |
2347 sz += QSize(2 * pixelMetric(PM_ButtonMargin), 2 * pixelMetric(PM_ButtonMargin)); |
2342 if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) |
2348 if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) |
2343 if (toolBtn->subControls & SC_ToolButtonMenu) |
2349 if (toolBtn->subControls & SC_ToolButtonMenu) |
2344 sz += QSize(pixelMetric(PM_MenuButtonIndicator),0); |
2350 sz += QSize(pixelMetric(PM_MenuButtonIndicator), 0); |
2345 break; |
2351 break; |
2346 case CT_PushButton: |
2352 case CT_PushButton: |
2347 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2353 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2348 //FIXME properly - style should calculate the location of border frame-part |
2354 //FIXME properly - style should calculate the location of border frame-part |
2349 sz += QSize(2*pixelMetric(PM_ButtonMargin), 2*pixelMetric(PM_ButtonMargin)); |
2355 sz += QSize(2 * pixelMetric(PM_ButtonMargin), 2 * pixelMetric(PM_ButtonMargin)); |
2350 if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) |
2356 if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) |
2351 if (buttonWidget->isCheckable()) |
2357 if (buttonWidget->isCheckable()) |
2352 sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); |
2358 sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); |
2353 break; |
2359 break; |
2354 case CT_LineEdit: |
2360 case CT_LineEdit: |
2355 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) |
2361 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) |
2356 sz += QSize(2*f->lineWidth, 4*f->lineWidth); |
2362 sz += QSize(2 * f->lineWidth, 4 * f->lineWidth); |
2357 break; |
2363 break; |
2358 case CT_TabBarTab: |
2364 case CT_TabBarTab: |
2359 { |
2365 { |
2360 const QSize naviPaneSize = QS60StylePrivate::naviPaneSize(); |
2366 const QSize naviPaneSize = QS60StylePrivate::naviPaneSize(); |
2361 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); |
2367 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); |
2366 case CT_ItemViewItem: |
2372 case CT_ItemViewItem: |
2367 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2373 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2368 if (QS60StylePrivate::isTouchSupported()) |
2374 if (QS60StylePrivate::isTouchSupported()) |
2369 //Make itemview easier to use in touch devices |
2375 //Make itemview easier to use in touch devices |
2370 //QCommonStyle does not adjust height with horizontal margin, it only adjusts width |
2376 //QCommonStyle does not adjust height with horizontal margin, it only adjusts width |
2371 sz.setHeight(sz.height() + 2*pixelMetric(QStyle::PM_FocusFrameVMargin)); |
2377 sz.setHeight(sz.height() + 2 * pixelMetric(QStyle::PM_FocusFrameVMargin)); |
2372 break; |
2378 break; |
2373 default: |
2379 default: |
2374 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2380 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2375 break; |
2381 break; |
2376 } |
2382 } |
2518 #endif // QT_NO_SCROLLBAR |
2524 #endif // QT_NO_SCROLLBAR |
2519 case CC_SpinBox: |
2525 case CC_SpinBox: |
2520 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2526 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2521 const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; |
2527 const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; |
2522 const int buttonMargin = spinbox->frame ? 2 : 0; |
2528 const int buttonMargin = spinbox->frame ? 2 : 0; |
2523 const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize) + 2*buttonMargin; |
2529 const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize) + 2 * buttonMargin; |
2524 QSize buttonSize; |
2530 QSize buttonSize; |
2525 buttonSize.setHeight(qMax(8, spinbox->rect.height() - frameThickness)); |
2531 buttonSize.setHeight(qMax(8, spinbox->rect.height() - frameThickness)); |
2526 buttonSize.setWidth(buttonWidth); |
2532 //width should at least be equal to height |
|
2533 buttonSize.setWidth(qMax(buttonSize.height(), buttonWidth)); |
2527 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2534 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2528 |
2535 |
2529 const int y = frameThickness + spinbox->rect.y(); |
2536 const int y = frameThickness + spinbox->rect.y(); |
2530 const int x = spinbox->rect.x() + spinbox->rect.width() - frameThickness - 2*buttonSize.width(); |
2537 const int x = spinbox->rect.x() + spinbox->rect.width() - frameThickness - 2 * buttonSize.width(); |
2531 |
2538 |
2532 switch (scontrol) { |
2539 switch (scontrol) { |
2533 case SC_SpinBoxUp: |
2540 case SC_SpinBoxUp: |
2534 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2541 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2535 return QRect(); |
2542 return QRect(); |
2536 ret = QRect(x, y, buttonWidth, buttonSize.height()); |
2543 ret = QRect(x, y, buttonSize.width(), buttonSize.height()); |
2537 break; |
2544 break; |
2538 case SC_SpinBoxDown: |
2545 case SC_SpinBoxDown: |
2539 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2546 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2540 return QRect(); |
2547 return QRect(); |
2541 ret = QRect(x+buttonSize.width(), y, buttonWidth, buttonSize.height()); |
2548 ret = QRect(x + buttonSize.width(), y, buttonSize.width(), buttonSize.height()); |
2542 break; |
2549 break; |
2543 case SC_SpinBoxEditField: |
2550 case SC_SpinBoxEditField: |
2544 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2551 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2545 ret = QRect( |
2552 ret = QRect( |
2546 frameThickness, |
2553 frameThickness, |
2547 frameThickness, |
2554 frameThickness, |
2548 spinbox->rect.width() - 2*frameThickness, |
2555 spinbox->rect.width() - 2 * frameThickness, |
2549 spinbox->rect.height() - 2*frameThickness); |
2556 spinbox->rect.height() - 2 * frameThickness); |
2550 else |
2557 else |
2551 ret = QRect( |
2558 ret = QRect( |
2552 frameThickness, |
2559 frameThickness, |
2553 frameThickness, |
2560 frameThickness, |
2554 x - frameThickness, |
2561 x - frameThickness, |
2555 spinbox->rect.height() - 2*frameThickness); |
2562 spinbox->rect.height() - 2 * frameThickness); |
2556 break; |
2563 break; |
2557 case SC_SpinBoxFrame: |
2564 case SC_SpinBoxFrame: |
2558 ret = spinbox->rect; |
2565 ret = spinbox->rect; |
2559 break; |
2566 break; |
2560 default: |
2567 default: |
2566 case CC_ComboBox: |
2573 case CC_ComboBox: |
2567 if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
2574 if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
2568 ret = cmb->rect; |
2575 ret = cmb->rect; |
2569 const int width = cmb->rect.width(); |
2576 const int width = cmb->rect.width(); |
2570 const int height = cmb->rect.height(); |
2577 const int height = cmb->rect.height(); |
|
2578 const int buttonIconSize = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize); |
2571 const int buttonMargin = cmb->frame ? 2 : 0; |
2579 const int buttonMargin = cmb->frame ? 2 : 0; |
2572 // lets use spinbox frame here as well, as no combobox specific value available. |
2580 // lets use spinbox frame here as well, as no combobox specific value available. |
2573 const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; |
2581 const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; |
2574 const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize); |
2582 const int buttonWidth = qMax(cmb->rect.height(), buttonIconSize); |
|
2583 const int xposMod = (cmb->rect.x()) + width - buttonMargin - buttonWidth; |
|
2584 const int ypos = cmb->rect.y(); |
2575 |
2585 |
2576 QSize buttonSize; |
2586 QSize buttonSize; |
2577 buttonSize.setHeight(qMax(8, (cmb->rect.height()>>1) - frameThickness)); //minimum of 8 pixels |
2587 buttonSize.setWidth(buttonWidth + 2 * buttonMargin); |
2578 buttonSize.setWidth(buttonWidth+2*buttonMargin); |
2588 buttonSize.setHeight(qMax(8, (cmb->rect.height() >> 1) - frameThickness)); //buttons should be squares |
2579 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2589 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2580 switch (scontrol) { |
2590 switch (scontrol) { |
2581 case SC_ComboBoxArrow: |
2591 case SC_ComboBoxArrow: |
2582 ret.setRect( |
2592 ret.setRect(xposMod, ypos + buttonMargin, buttonWidth, height - 2 * buttonMargin); |
2583 ret.x() + ret.width() - buttonMargin - buttonWidth, |
|
2584 ret.y() + buttonMargin, |
|
2585 buttonWidth, |
|
2586 height - 2*buttonMargin); |
|
2587 break; |
2593 break; |
2588 case SC_ComboBoxEditField: { |
2594 case SC_ComboBoxEditField: { |
2589 ret.setRect( |
2595 const int withFrameX = cmb->rect.x() + cmb->rect.width() - frameThickness - buttonSize.width(); |
2590 ret.x() + frameThickness, |
2596 ret = QRect( |
2591 ret.y() + frameThickness, |
2597 frameThickness, |
2592 ret.width() - 2*frameThickness - buttonSize.width(), |
2598 frameThickness, |
2593 ret.height() - 2*frameThickness); |
2599 withFrameX - frameThickness, |
|
2600 cmb->rect.height() - 2 * frameThickness); |
2594 } |
2601 } |
2595 break; |
2602 break; |
2596 default: |
2603 default: |
2597 break; |
2604 break; |
2598 } |
2605 } |
2605 case SC_GroupBoxCheckBox: //fallthrough |
2612 case SC_GroupBoxCheckBox: //fallthrough |
2606 case SC_GroupBoxLabel: { |
2613 case SC_GroupBoxLabel: { |
2607 //slightly indent text and boxes, so that dialog border does not mess with them. |
2614 //slightly indent text and boxes, so that dialog border does not mess with them. |
2608 const int horizontalSpacing = |
2615 const int horizontalSpacing = |
2609 QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); |
2616 QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); |
2610 ret.adjust(2,horizontalSpacing-3,0,0); |
2617 ret.adjust(2, horizontalSpacing - 3, 0, 0); |
2611 } |
2618 } |
2612 break; |
2619 break; |
2613 case SC_GroupBoxFrame: { |
2620 case SC_GroupBoxFrame: { |
2614 const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget); |
2621 const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget); |
2615 const int tbHeight = textBox.height(); |
2622 const int tbHeight = textBox.height(); |
2616 ret.translate(0, -ret.y()); |
2623 ret.translate(0, -ret.y()); |
2617 // include title to within the groupBox frame |
2624 // include title to within the groupBox frame |
2618 ret.setHeight(ret.height()+tbHeight); |
2625 ret.setHeight(ret.height() + tbHeight); |
2619 if (widget && ret.bottom() > widget->rect().bottom()) |
2626 if (widget && ret.bottom() > widget->rect().bottom()) |
2620 ret.setBottom(widget->rect().bottom()); |
2627 ret.setBottom(widget->rect().bottom()); |
2621 } |
2628 } |
2622 break; |
2629 break; |
2623 default: |
2630 default: |
2663 switch (element) { |
2670 switch (element) { |
2664 case SE_LineEditContents: { |
2671 case SE_LineEditContents: { |
2665 // in S60 the input text box doesn't start from line Edit's TL, but |
2672 // in S60 the input text box doesn't start from line Edit's TL, but |
2666 // a bit indented. |
2673 // a bit indented. |
2667 QRect lineEditRect = opt->rect; |
2674 QRect lineEditRect = opt->rect; |
2668 const int adjustment = opt->rect.height()>>2; |
2675 const int adjustment = opt->rect.height() >> 2; |
2669 lineEditRect.adjust(adjustment,0,0,0); |
2676 lineEditRect.adjust(adjustment, 0, 0, 0); |
2670 ret = lineEditRect; |
2677 ret = lineEditRect; |
2671 } |
2678 } |
2672 break; |
2679 break; |
2673 case SE_TabBarTearIndicator: |
2680 case SE_TabBarTearIndicator: |
2674 ret = QRect(0,0,0,0); |
2681 ret = QRect(0, 0, 0, 0); |
2675 break; |
2682 break; |
2676 case SE_TabWidgetTabBar: |
2683 case SE_TabWidgetTabBar: |
2677 if (const QStyleOptionTabWidgetFrame *optionTab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
2684 if (const QStyleOptionTabWidgetFrame *optionTab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
2678 ret = QCommonStyle::subElementRect(element, opt, widget); |
2685 ret = QCommonStyle::subElementRect(element, opt, widget); |
2679 |
2686 |
2691 case QTabBar::TriangularSouth: { |
2698 case QTabBar::TriangularSouth: { |
2692 if (widget) { |
2699 if (widget) { |
2693 // make sure that gain does not set the rect outside of widget boundaries |
2700 // make sure that gain does not set the rect outside of widget boundaries |
2694 if (twf->direction == Qt::RightToLeft) { |
2701 if (twf->direction == Qt::RightToLeft) { |
2695 if ((ret.left() - gain) < widget->rect().left()) |
2702 if ((ret.left() - gain) < widget->rect().left()) |
2696 gain = widget->rect().left()-ret.left(); |
2703 gain = widget->rect().left() - ret.left(); |
2697 ret.adjust(-gain,0,0,0); |
2704 ret.adjust(-gain, 0, 0, 0); |
2698 } else { |
2705 } else { |
2699 if ((ret.right() + gain) > widget->rect().right()) |
2706 if ((ret.right() + gain) > widget->rect().right()) |
2700 gain = widget->rect().right()-ret.right(); |
2707 gain = widget->rect().right() - ret.right(); |
2701 ret.adjust(0,0,gain,0); |
2708 ret.adjust(0, 0, gain, 0); |
2702 } |
2709 } |
2703 } |
2710 } |
2704 break; |
2711 break; |
2705 } |
2712 } |
2706 default: { |
2713 default: { |
2707 if (widget) { |
2714 if (widget) { |
2708 if ((ret.bottom() + gain) > widget->rect().bottom()) |
2715 if ((ret.bottom() + gain) > widget->rect().bottom()) |
2709 gain = widget->rect().bottom()-ret.bottom(); |
2716 gain = widget->rect().bottom() - ret.bottom(); |
2710 ret.adjust(0,0,0,gain); |
2717 ret.adjust(0, 0, 0, gain); |
2711 } |
2718 } |
2712 break; |
2719 break; |
2713 } |
2720 } |
2714 } |
2721 } |
2715 } |
2722 } |
2731 (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator)) { |
2738 (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator)) { |
2732 const int verticalSpacing = |
2739 const int verticalSpacing = |
2733 QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing); |
2740 QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing); |
2734 //const int horizontalSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); |
2741 //const int horizontalSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); |
2735 const int checkBoxRectWidth = subElementRect(SE_ItemViewItemCheckIndicator, opt, widget).width(); |
2742 const int checkBoxRectWidth = subElementRect(SE_ItemViewItemCheckIndicator, opt, widget).width(); |
2736 ret.adjust(-checkBoxRectWidth-verticalSpacing,0,-checkBoxRectWidth-verticalSpacing,0); |
2743 ret.adjust(-checkBoxRectWidth - verticalSpacing, 0, -checkBoxRectWidth - verticalSpacing, 0); |
2737 } |
2744 } |
2738 } else if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { |
2745 } else if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { |
2739 const bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; |
2746 const bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; |
2740 const int indicatorWidth = checkable ? |
2747 const int indicatorWidth = checkable ? |
2741 pixelMetric(PM_ListViewIconSize, opt, widget) : |
2748 pixelMetric(PM_ListViewIconSize, opt, widget) : |
2756 |
2763 |
2757 // Make room for submenu indicator |
2764 // Make room for submenu indicator |
2758 if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu){ |
2765 if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu){ |
2759 // submenu indicator is very small, so lets halve the rect |
2766 // submenu indicator is very small, so lets halve the rect |
2760 if (menuItem->direction == Qt::LeftToRight) |
2767 if (menuItem->direction == Qt::LeftToRight) |
2761 ret.adjust(0,0,-(indicatorWidth >> 1),0); |
2768 ret.adjust(0, 0, -(indicatorWidth >> 1), 0); |
2762 else |
2769 else |
2763 ret.adjust((indicatorWidth >> 1),0,0,0); |
2770 ret.adjust((indicatorWidth >> 1), 0, 0, 0); |
2764 } |
2771 } |
2765 } |
2772 } |
2766 } |
2773 } |
2767 break; |
2774 break; |
2768 case SE_ItemViewItemCheckIndicator: |
2775 case SE_ItemViewItemCheckIndicator: |
2782 const int spacing = QS60StylePrivate::pixelMetric(QStyle::PM_CheckBoxLabelSpacing); |
2789 const int spacing = QS60StylePrivate::pixelMetric(QStyle::PM_CheckBoxLabelSpacing); |
2783 |
2790 |
2784 const int itemHeight = opt->rect.height(); |
2791 const int itemHeight = opt->rect.height(); |
2785 int heightOffset = 0; |
2792 int heightOffset = 0; |
2786 if (indicatorHeight < itemHeight) |
2793 if (indicatorHeight < itemHeight) |
2787 heightOffset = ((itemHeight - indicatorHeight)>>1); |
2794 heightOffset = ((itemHeight - indicatorHeight) >> 1); |
2788 if (checkBoxOnly) { |
2795 if (checkBoxOnly) { |
2789 // Move rect and make it slightly smaller, so that |
2796 // Move rect and make it slightly smaller, so that |
2790 // a) highlight border does not cross the rect |
2797 // a) highlight border does not cross the rect |
2791 // b) in s60 list checkbox is smaller than normal checkbox |
2798 // b) in s60 list checkbox is smaller than normal checkbox |
2792 //todo; magic three |
2799 //todo; magic three |
2793 ret.setRect(opt->rect.left()+3, opt->rect.top() + heightOffset, |
2800 ret.setRect(opt->rect.left() + 3, opt->rect.top() + heightOffset, |
2794 indicatorWidth-3, indicatorHeight-3); |
2801 indicatorWidth - 3, indicatorHeight - 3); |
2795 } else { |
2802 } else { |
2796 ret.setRect(opt->rect.right() - indicatorWidth - spacing, opt->rect.top() + heightOffset, |
2803 ret.setRect(opt->rect.right() - indicatorWidth - spacing, opt->rect.top() + heightOffset, |
2797 indicatorWidth, indicatorHeight); |
2804 indicatorWidth, indicatorHeight); |
2798 } |
2805 } |
2799 } else { |
2806 } else { |
2953 */ |
2960 */ |
2954 QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, |
2961 QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, |
2955 const QStyleOption *option, const QWidget *widget) const |
2962 const QStyleOption *option, const QWidget *widget) const |
2956 { |
2963 { |
2957 const int iconDimension = QS60StylePrivate::pixelMetric(QStyle::PM_ToolBarIconSize); |
2964 const int iconDimension = QS60StylePrivate::pixelMetric(QStyle::PM_ToolBarIconSize); |
2958 const QRect iconSize = (!option) ? QRect(0,0,iconDimension,iconDimension) : option->rect; |
2965 const QRect iconSize = (!option) ? QRect(0, 0, iconDimension, iconDimension) : option->rect; |
2959 QS60StyleEnums::SkinParts part; |
2966 QS60StyleEnums::SkinParts part; |
2960 QS60StylePrivate::SkinElementFlags adjustedFlags; |
2967 QS60StylePrivate::SkinElementFlags adjustedFlags; |
2961 if (option) |
2968 if (option) |
2962 adjustedFlags = (option->state & State_Enabled || option->state == 0) ? |
2969 adjustedFlags = (option->state & State_Enabled || option->state == 0) ? |
2963 QS60StylePrivate::SF_StateEnabled : |
2970 QS60StylePrivate::SF_StateEnabled : |