558void QWindowsStyle::drawPrimitive(PrimitiveElement pe,
const QStyleOption *opt, QPainter *p)
const
561 bool doRestore =
false;
564#if 0
&& QT_CONFIG(toolbar)
565 case PE_IndicatorToolBarSeparator:
567 QRect rect = opt->rect;
568 const int margin = 2;
569 QPen oldPen = p->pen();
570 if (opt->state & State_Horizontal){
571 const int offset = rect.width()/2;
572 p->setPen(QPen(opt->palette.dark().color()));
573 p->drawLine(rect.bottomLeft().x() + offset,
574 rect.bottomLeft().y() - margin,
575 rect.topLeft().x() + offset,
576 rect.topLeft().y() + margin);
577 p->setPen(QPen(opt->palette.light().color()));
578 p->drawLine(rect.bottomLeft().x() + offset + 1,
579 rect.bottomLeft().y() - margin,
580 rect.topLeft().x() + offset + 1,
581 rect.topLeft().y() + margin);
584 const int offset = rect.height()/2;
585 p->setPen(QPen(opt->palette.dark().color()));
586 p->drawLine(rect.topLeft().x() + margin ,
587 rect.topLeft().y() + offset,
588 rect.topRight().x() - margin,
589 rect.topRight().y() + offset);
590 p->setPen(QPen(opt->palette.light().color()));
591 p->drawLine(rect.topLeft().x() + margin ,
592 rect.topLeft().y() + offset + 1,
593 rect.topRight().x() - margin,
594 rect.topRight().y() + offset + 1);
599 case PE_IndicatorToolBarHandle:
601 p->translate(opt->rect.x(), opt->rect.y());
602 if (opt->state & State_Horizontal) {
603 int x = opt->rect.width() / 2 - 4;
604 if (opt->direction == Qt::RightToLeft)
606 if (opt->rect.height() > 4) {
607 qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
608 opt->palette,
false, 1,
nullptr);
609 qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4,
610 opt->palette,
false, 1,
nullptr);
613 if (opt->rect.width() > 4) {
614 int y = opt->rect.height() / 2 - 4;
615 qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
616 opt->palette,
false, 1,
nullptr);
617 qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3,
618 opt->palette,
false, 1,
nullptr);
625 case PE_FrameButtonTool:
626 case PE_PanelButtonTool: {
627 QPen oldPen = p->pen();
628#if 0
&& QT_CONFIG(dockwidget)
629 if (w && w->inherits(
"QDockWidgetTitleButton")) {
630 if (
const QWidget *dw = w->parentWidget())
632 qDrawWinButton(p, opt->rect.adjusted(1, 1, 0, 0), opt->palette, opt->state & (State_Sunken | State_On),
633 &opt->palette.button());
641 bool panel = (pe == PE_PanelButtonTool);
642 if ((!(opt->state & State_Sunken ))
643 && (!(opt->state & State_Enabled)
644 || !(opt->state & State_MouseOver && opt->state & State_AutoRaise))
645 && (opt->state & State_On)) {
646 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
649 fill = opt->palette.brush(QPalette::Button);
653 if (opt->state & (State_Raised | State_Sunken | State_On)) {
654 if (opt->state & State_AutoRaise) {
655 if (opt->state & (State_Enabled | State_Sunken | State_On)){
657 qDrawShadePanel(p, opt->rect, opt->palette,
658 opt->state & (State_Sunken | State_On), 1, &fill);
660 qDrawShadeRect(p, opt->rect, opt->palette,
661 opt->state & (State_Sunken | State_On), 1);
664 p->setPen(opt->palette.button().color());
665 p->drawRect(opt->rect.adjusted(1,1,-2,-2));
668 qDrawWinButton(p, opt->rect, opt->palette,
669 opt->state & (State_Sunken | State_On), panel ? &fill :
nullptr);
672 p->fillRect(opt->rect, fill);
676 case PE_PanelButtonCommand:
677 if (
const QStyleOptionButton *btn = qstyleoption_cast<
const QStyleOptionButton *>(opt)) {
679 State flags = opt->state;
680 QPalette pal = opt->palette;
682 if (! (flags & State_Sunken) && (flags & State_On))
683 fill = QBrush(pal.light().color(), Qt::Dense4Pattern);
685 fill = pal.brush(QPalette::Button);
687 if (btn->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
688 p->setPen(pal.dark().color());
690 p->drawRect(r.adjusted(0, 0, -1, -1));
691 }
else if (flags & (State_Raised | State_On | State_Sunken)) {
692 qDrawWinButton(p, r, pal, flags & (State_Sunken | State_On),
695 p->fillRect(r, fill);
699 case PE_FrameDefaultButton: {
700 QPen oldPen = p->pen();
701 p->setPen(QPen(opt->palette.shadow().color(), 0));
702 QRectF rect = opt->rect;
703 const qreal dpi = QStyleHelper::dpi(opt);
704 const qreal topLevelAdjustment = QStyleHelper::dpiScaled(0.5, dpi);
705 const qreal bottomRightAdjustment = QStyleHelper::dpiScaled(-1.5, dpi);
706 rect.adjust(topLevelAdjustment, topLevelAdjustment,
707 bottomRightAdjustment, bottomRightAdjustment);
712 case PE_IndicatorCheckBox: {
714 if (opt->state & State_NoChange)
715 fill = QBrush(opt->palette.base().color(), Qt::Dense4Pattern);
716 else if (opt->state & State_Sunken)
717 fill = opt->palette.button();
718 else if (opt->state & State_Enabled)
719 fill = opt->palette.base();
721 fill = opt->palette.window();
724 qDrawWinPanel(p, opt->rect, opt->palette,
true, &fill);
725 if (opt->state & State_NoChange)
726 p->setPen(opt->palette.dark().color());
728 p->setPen(opt->palette.text().color());
731 case PE_IndicatorItemViewItemCheck:
736#if 0
&& QT_CONFIG(itemviews)
737 if (pe == PE_IndicatorItemViewItemCheck) {
738 const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<
const QStyleOptionViewItem *>(opt);
739 p->setPen(itemViewOpt
740 && itemViewOpt->showDecorationSelected
741 && opt->state & State_Selected
742 ? opt->palette.highlightedText().color()
743 : opt->palette.text().color());
744 if (opt->state & State_NoChange)
745 p->setBrush(opt->palette.brush(QPalette::Button));
746 p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, opt->rect.width() - 2, opt->rect.height() - 2);
749 if (!(opt->state & State_Off)) {
751 qreal scaleh = opt->rect.width() / 12.0;
752 qreal scalev = opt->rect.height() / 12.0;
753 points[0] = { opt->rect.x() + 3.5 * scaleh, opt->rect.y() + 5.5 * scalev };
754 points[1] = { points[0].x(), points[0].y() + 2 * scalev };
755 points[2] = { points[1].x() + 2 * scaleh, points[1].y() + 2 * scalev };
756 points[3] = { points[2].x() + 4 * scaleh, points[2].y() - 4 * scalev };
757 points[4] = { points[3].x(), points[3].y() - 2 * scalev };
758 points[5] = { points[4].x() - 4 * scaleh, points[4].y() + 4 * scalev };
759 p->setPen(QPen(opt->palette.text().color(), 0));
760 p->setBrush(opt->palette.text());
761 p->drawPolygon(points, 6);
766 case PE_FrameFocusRect:
769 if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt))
773 p->setBackgroundMode(Qt::TransparentMode);
774 QColor bg_col = fropt->backgroundColor;
775 if (!bg_col.isValid())
776 bg_col = p->background().color();
777 bg_col = bg_col.toRgb();
779 QColor patternCol((bg_col.red() ^ 0xff) & 0xff,
780 (bg_col.green() ^ 0xff) & 0xff,
781 (bg_col.blue() ^ 0xff) & 0xff);
782 p->setBrush(QBrush(patternCol, Qt::Dense4Pattern));
783 p->setBrushOrigin(r.topLeft());
784 p->setPen(Qt::NoPen);
785 p->drawRect(r.left(), r.top(), r.width(), 1);
786 p->drawRect(r.left(), r.bottom(), r.width(), 1);
787 p->drawRect(r.left(), r.top(), 1, r.height());
788 p->drawRect(r.right(), r.top(), 1, r.height());
792 case PE_IndicatorRadioButton:
796 p->setRenderHint(QPainter::Antialiasing,
true);
798 QPointF circleCenter = r.center() + QPoint(1, 1);
799 qreal radius = (r.width() + (r.width() + 1) % 2) / 2.0 - 1;
802 path1.addEllipse(circleCenter, radius, radius);
805 path2.addEllipse(circleCenter, radius, radius);
808 path3.addEllipse(circleCenter, radius, radius);
811 path4.addEllipse(circleCenter, radius, radius);
813 QPolygon topLeftPol, bottomRightPol;
814 topLeftPol.setPoints(3, r.x(), r.y(), r.x(), r.y() + r.height(), r.x() + r.width(), r.y());
815 bottomRightPol.setPoints(3, r.x(), r.y() + r.height(), r.x() + r.width(), r.y() + r.height(), r.x() + r.width(), r.y());
817 p->setClipRegion(QRegion(topLeftPol));
818 p->setPen(opt->palette.dark().color());
819 p->setBrush(opt->palette.dark());
821 p->setPen(opt->palette.shadow().color());
822 p->setBrush(opt->palette.shadow());
825 p->setClipRegion(QRegion(bottomRightPol));
826 p->setPen(opt->palette.light().color());
827 p->setBrush(opt->palette.light());
829 p->setPen(opt->palette.midlight().color());
830 p->setBrush(opt->palette.midlight());
833 const QBrush fill = ((opt->state & State_Sunken) || !(opt->state & State_Enabled))
834 ? opt->palette.button() : opt->palette.base();
836 p->setClipping(
false);
837 p->setPen(fill.color());
841 if (opt->state & State_On) {
842 p->setPen(opt->palette.text().color());
843 p->setBrush(opt->palette.text());
852 if (
const QStyleOptionFrame *frame = qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
853 if (frame->lineWidth == 2 || pe == PE_Frame) {
854 QPalette popupPal = frame->palette;
855 if (pe == PE_FrameMenu) {
856 popupPal.setBrush(QPalette::Light, frame->palette.window());
857 popupPal.setBrush(QPalette::Midlight, frame->palette.light());
859 if (pe == PE_Frame && (frame->state & State_Raised))
860 qDrawWinButton(p, frame->rect, popupPal, frame->state & State_Sunken);
861 else if (pe == PE_Frame && (frame->state & State_Sunken))
863 popupPal.setBrush(QPalette::Midlight, frame->palette.window());
864 qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
867 qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
869 QCommonStyle::drawPrimitive(pe, opt, p);
872 QPalette popupPal = opt->palette;
873 popupPal.setBrush(QPalette::Light, opt->palette.window());
874 popupPal.setBrush(QPalette::Midlight, opt->palette.light());
875 qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
879 case PE_FrameButtonBevel:
880 case PE_PanelButtonBevel: {
882 bool panel = pe != PE_FrameButtonBevel;
883 p->setBrushOrigin(opt->rect.topLeft());
884 if (!(opt->state & State_Sunken) && (opt->state & State_On))
885 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
887 fill = opt->palette.brush(QPalette::Button);
889 if (opt->state & (State_Raised | State_On | State_Sunken)) {
890 qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On),
891 panel ? &fill :
nullptr);
894 p->fillRect(opt->rect, fill);
896 p->drawRect(opt->rect);
899 case PE_FrameWindow: {
900 QPalette popupPal = opt->palette;
901 popupPal.setBrush(QPalette::Light, opt->palette.window());
902 popupPal.setBrush(QPalette::Midlight, opt->palette.light());
903 qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
905#if 0
&& QT_CONFIG(dockwidget)
906 case PE_IndicatorDockWidgetResizeHandle:
908 case PE_FrameDockWidget:
909 if (qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
910 proxy()->drawPrimitive(QStyle::PE_FrameWindow, opt, p, w);
915 case PE_FrameStatusBarItem:
916 qDrawShadePanel(p, opt->rect, opt->palette,
true, 1,
nullptr);
919 case PE_IndicatorProgressChunk:
921 bool vertical =
false, inverted =
false;
923 vertical = !(pb->state & QStyle::State_Horizontal);
924 inverted = pb->invertedAppearance;
928 int chunksize = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt) - space;
930 if (opt->rect.width() <= chunksize)
934 p->fillRect(opt->rect.x() + space, opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
935 opt->palette.brush(QPalette::Highlight));
937 p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
938 opt->palette.brush(QPalette::Highlight));
940 if (opt->rect.height() <= chunksize)
944 p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height() - space,
945 opt->palette.brush(QPalette::Highlight));
947 p->fillRect(opt->rect.x(), opt->rect.y() + space, opt->rect.width(), opt->rect.height() - space,
948 opt->palette.brush(QPalette::Highlight));
953 case PE_FrameTabWidget: {
954 qDrawWinButton(p, opt->rect, opt->palette,
false,
nullptr);
958 QCommonStyle::drawPrimitive(pe, opt, p);
963void QWindowsStyle::drawControl(ControlElement ce,
const QStyleOption *opt, QPainter *p)
const
966#if 0
&& QT_CONFIG(rubberband)
968 if (qstyleoption_cast<
const QStyleOptionRubberBand *>(opt)) {
970 QPixmap tiledPixmap(16, 16);
971 QPainter pixmapPainter(&tiledPixmap);
972 pixmapPainter.setPen(Qt::NoPen);
973 pixmapPainter.setBrush(Qt::Dense4Pattern);
974 pixmapPainter.setBackground(Qt::white);
975 pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
976 pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
978 tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
981 QStyleHintReturnMask mask;
982 if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
983 p->setClipRegion(mask.region);
984 p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
991#if 0
&& QT_CONFIG(menu) && QT_CONFIG(mainwindow)
992 case CE_MenuBarEmptyArea:
993 if (widget && qobject_cast<
const QMainWindow *>(widget->parentWidget())) {
994 p->fillRect(opt->rect, opt->palette.button());
995 QPen oldPen = p->pen();
996 p->setPen(QPen(opt->palette.dark().color()));
997 p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight());
1002#if 0
&& QT_CONFIG(menu)
1004 if (
const QStyleOptionMenuItem *menuitem = qstyleoption_cast<
const QStyleOptionMenuItem *>(opt)) {
1006 menuitem->rect.getRect(&x, &y, &w, &h);
1007 int tab = menuitem->tabWidth;
1008 bool dis = !(menuitem->state & State_Enabled);
1009 bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
1010 ? menuitem->checked :
false;
1011 bool act = menuitem->state & State_Selected;
1014 int checkcol = qMax<
int>(menuitem->maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
1016 QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
1017 p->fillRect(menuitem->rect.adjusted(0, 0, -1, 0), fill);
1019 if (menuitem->menuItemType == QStyleOptionMenuItem::Separator){
1020 int yoff = y-1 + h / 2;
1021 p->setPen(menuitem->palette.dark().color());
1022 p->drawLine(x + 2, yoff, x + w - 4, yoff);
1023 p->setPen(menuitem->palette.light().color());
1024 p->drawLine(x + 2, yoff + 1, x + w - 4, yoff + 1);
1028 QRect vCheckRect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x(), menuitem->rect.y(), checkcol, menuitem->rect.height()));
1029 if (!menuitem->icon.isNull() && checked) {
1031 qDrawShadePanel(p, vCheckRect,
1032 menuitem->palette,
true, 1,
1033 &menuitem->palette.brush(QPalette::Button));
1035 QBrush fill(menuitem->palette.light().color(), Qt::Dense4Pattern);
1036 qDrawShadePanel(p, vCheckRect, menuitem->palette,
true, 1, &fill);
1039 p->fillRect(vCheckRect, menuitem->palette.brush(QPalette::Button));
1045 if (!menuitem->icon.isNull()) {
1046 QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
1048 mode = QIcon::Active;
1051 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
1053 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
1054 const int pixw = pixmap.width() / pixmap.devicePixelRatio();
1055 const int pixh = pixmap.height() / pixmap.devicePixelRatio();
1056 QRect pmr(0, 0, pixw, pixh);
1057 pmr.moveCenter(vCheckRect.center());
1058 p->setPen(menuitem->palette.text().color());
1059 p->drawPixmap(pmr.topLeft(), pixmap);
1060 }
else if (checked) {
1061 QStyleOptionMenuItem newMi = *menuitem;
1062 newMi.state = State_None;
1064 newMi.state |= State_Enabled;
1066 newMi.state |= State_On;
1067 newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + QWindowsStylePrivate::windowsItemFrame,
1068 menuitem->rect.y() + QWindowsStylePrivate::windowsItemFrame,
1069 checkcol - 2 * QWindowsStylePrivate::windowsItemFrame,
1070 menuitem->rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
1071 proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
1073 p->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color());
1077 discol = menuitem->palette.text().color();
1081 int xm =
int(QWindowsStylePrivate::windowsItemFrame) + checkcol +
int(QWindowsStylePrivate::windowsItemHMargin);
1082 int xpos = menuitem->rect.x() + xm;
1083 QRect textRect(xpos, y + QWindowsStylePrivate::windowsItemVMargin,
1084 w - xm - QWindowsStylePrivate::windowsRightBorder - tab + 1, h - 2 * QWindowsStylePrivate::windowsItemVMargin);
1085 QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
1086 QStringRef s(&menuitem->text);
1089 int t = s.indexOf(QLatin1Char(
'\t'));
1090 int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
1091 if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
1092 text_flags |= Qt::TextHideMnemonic;
1093 text_flags |= Qt::AlignLeft;
1095 QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
1096 QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
1097 const QString textToDraw = s.mid(t + 1).toString();
1098 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1099 p->setPen(menuitem->palette.light().color());
1100 p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, textToDraw);
1103 p->drawText(vShortcutRect, text_flags, textToDraw);
1106 QFont font = menuitem->font;
1107 if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
1110 const QString textToDraw = s.left(t).toString();
1111 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1112 p->setPen(menuitem->palette.light().color());
1113 p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, textToDraw);
1116 p->drawText(vTextRect, text_flags, textToDraw);
1119 if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {
1120 int dim = (h - 2 * QWindowsStylePrivate::windowsItemFrame) / 2;
1121 PrimitiveElement arrow;
1122 arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
1123 xpos = x + w - QWindowsStylePrivate::windowsArrowHMargin - QWindowsStylePrivate::windowsItemFrame - dim;
1124 QRect vSubMenuRect = visualRect(opt->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
1125 QStyleOptionMenuItem newMI = *menuitem;
1126 newMI.rect = vSubMenuRect;
1127 newMI.state = dis ? State_None : State_Enabled;
1129 newMI.palette.setColor(QPalette::ButtonText,
1130 newMI.palette.highlightedText().color());
1131 proxy()->drawPrimitive(arrow, &newMI, p, widget);
1137#if 0
&& QT_CONFIG(menubar)
1138 case CE_MenuBarItem:
1139 if (
const QStyleOptionMenuItem *mbi = qstyleoption_cast<
const QStyleOptionMenuItem *>(opt)) {
1140 bool active = mbi->state & State_Selected;
1141 bool hasFocus = mbi->state & State_HasFocus;
1142 bool down = mbi->state & State_Sunken;
1143 QStyleOptionMenuItem newMbi = *mbi;
1144 p->fillRect(mbi->rect, mbi->palette.brush(QPalette::Button));
1145 if (active || hasFocus) {
1146 QBrush b = mbi->palette.brush(QPalette::Button);
1148 p->setBrushOrigin(p->brushOrigin() + QPoint(1, 1));
1149 if (active && hasFocus)
1150 qDrawShadeRect(p, mbi->rect.x(), mbi->rect.y(), mbi->rect.width(),
1151 mbi->rect.height(), mbi->palette, active && down, 1, 0, &b);
1152 if (active && down) {
1153 newMbi.rect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, mbi, widget),
1154 proxy()->pixelMetric(PM_ButtonShiftVertical, mbi, widget));
1155 p->setBrushOrigin(p->brushOrigin() - QPoint(1, 1));
1158 QCommonStyle::drawControl(ce, &newMbi, p, widget);
1162#if 0
&& QT_CONFIG(tabbar)
1163 case CE_TabBarTabShape:
1164 if (
const QStyleOptionTab *tab = qstyleoption_cast<
const QStyleOptionTab *>(opt)) {
1165 bool rtlHorTabs = (tab->direction == Qt::RightToLeft
1166 && (tab->shape == QTabBar::RoundedNorth
1167 || tab->shape == QTabBar::RoundedSouth));
1168 bool selected = tab->state & State_Selected;
1169 bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
1171 && tab->position == QStyleOptionTab::Beginning));
1172 bool firstTab = ((!rtlHorTabs
1173 && tab->position == QStyleOptionTab::Beginning)
1175 && tab->position == QStyleOptionTab::End));
1176 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
1177 bool previousSelected =
1179 && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
1181 && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
1184 && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
1186 && tab->selectedPosition
1187 == QStyleOptionTab::PreviousIsSelected));
1188 int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
1189 bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
1191 && tabBarAlignment == Qt::AlignRight);
1193 bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
1195 && tabBarAlignment == Qt::AlignLeft);
1197 QColor light = tab->palette.light().color();
1198 QColor dark = tab->palette.dark().color();
1199 QColor shadow = tab->palette.shadow().color();
1200 int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
1202 borderThinkness /= 2;
1203 QRect r2(opt->rect);
1205 int x2 = r2.right();
1207 int y2 = r2.bottom();
1208 switch (tab->shape) {
1210 QCommonStyle::drawControl(ce, tab, p, widget);
1212 case QTabBar::RoundedNorth: {
1215 x1 += onlyOne || firstTab ? borderThinkness : 0;
1216 x2 -= onlyOne || lastTab ? borderThinkness : 0;
1219 p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 2), tab->palette.window());
1223 p->fillRect(QRect(x1,y2-1,x2-x1,1), tab->palette.window());
1224 p->fillRect(QRect(x1,y2,x2-x1,1), tab->palette.window());
1227 if (firstTab || selected || onlyOne || !previousSelected) {
1229 p->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
1230 p->drawPoint(x1 + 1, y1 + 1);
1234 int beg = x1 + (previousSelected ? 0 : 2);
1235 int end = x2 - (nextSelected ? 0 : 2);
1237 p->drawLine(beg, y1, end, y1);
1240 if (lastTab || selected || onlyOne || !nextSelected) {
1242 p->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1243 p->drawPoint(x2 - 1, y1 + 1);
1245 p->drawLine(x2 - 1, y1 + 2, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1248 case QTabBar::RoundedSouth: {
1251 x1 += firstTab ? borderThinkness : 0;
1252 x2 -= lastTab ? borderThinkness : 0;
1255 p->fillRect(QRect(x1 + 1, y1 + 2, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.window());
1259 p->fillRect(QRect(x1, y1 + 1, (x2 - 1)-x1, 1), tab->palette.window());
1260 p->fillRect(QRect(x1, y1, (x2 - 1)-x1, 1), tab->palette.window());
1263 if (firstTab || selected || onlyOne || !previousSelected) {
1265 p->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
1266 p->drawPoint(x1 + 1, y2 - 1);
1270 int beg = x1 + (previousSelected ? 0 : 2);
1271 int end = x2 - (nextSelected ? 0 : 2);
1273 p->drawLine(beg, y2, end, y2);
1275 p->drawLine(beg, y2 - 1, end, y2 - 1);
1278 if (lastTab || selected || onlyOne || !nextSelected) {
1280 p->drawLine(x2, y2 - 2, x2, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1281 p->drawPoint(x2 - 1, y2 - 1);
1283 p->drawLine(x2 - 1, y2 - 2, x2 - 1, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1286 case QTabBar::RoundedWest: {
1289 y1 += firstTab ? borderThinkness : 0;
1290 y2 -= lastTab ? borderThinkness : 0;
1293 p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 2, (y2 - y1) - 1), tab->palette.window());
1297 p->fillRect(QRect(x2 - 1, y1, 1, y2-y1), tab->palette.window());
1298 p->fillRect(QRect(x2, y1, 1, y2-y1), tab->palette.window());
1301 if (firstTab || selected || onlyOne || !previousSelected) {
1303 p->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
1304 p->drawPoint(x1 + 1, y1 + 1);
1308 int beg = y1 + (previousSelected ? 0 : 2);
1309 int end = y2 - (nextSelected ? 0 : 2);
1311 p->drawLine(x1, beg, x1, end);
1314 if (lastTab || selected || onlyOne || !nextSelected) {
1316 p->drawLine(x1 + 3, y2, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
1317 p->drawPoint(x1 + 2, y2 - 1);
1319 p->drawLine(x1 + 3, y2 - 1, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
1320 p->drawPoint(x1 + 1, y2 - 1);
1321 p->drawPoint(x1 + 2, y2);
1324 case QTabBar::RoundedEast: {
1327 y1 += firstTab ? borderThinkness : 0;
1328 y2 -= lastTab ? borderThinkness : 0;
1331 p->fillRect(QRect(x1 + 2, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.window());
1335 p->fillRect(QRect(x1 + 1, y1, 1, (y2 - 1)-y1),tab->palette.window());
1336 p->fillRect(QRect(x1, y1, 1, (y2-1)-y1), tab->palette.window());
1339 if (firstTab || selected || onlyOne || !previousSelected) {
1341 p->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
1342 p->drawPoint(x2 - 1, y1 + 1);
1346 int beg = y1 + (previousSelected ? 0 : 2);
1347 int end = y2 - (nextSelected ? 0 : 2);
1349 p->drawLine(x2, beg, x2, end);
1351 p->drawLine(x2 - 1, beg, x2 - 1, end);
1354 if (lastTab || selected || onlyOne || !nextSelected) {
1356 p->drawLine(x2 - 2, y2, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
1357 p->drawPoint(x2 - 1, y2 - 1);
1359 p->drawLine(x2 - 2, y2 - 1, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
1366 case CE_ToolBoxTabShape:
1367 qDrawShadePanel(p, opt->rect, opt->palette,
1368 opt->state & (State_Sunken | State_On), 1,
1369 &opt->palette.brush(QPalette::Button));
1371#if 0
&& QT_CONFIG(splitter)
1373 p->eraseRect(opt->rect);
1376#if 0
&& QT_CONFIG(scrollbar)
1377 case CE_ScrollBarSubLine:
1378 case CE_ScrollBarAddLine: {
1379 if ((opt->state & State_Sunken)) {
1380 p->setPen(opt->palette.dark().color());
1381 p->setBrush(opt->palette.brush(QPalette::Button));
1382 p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
1384 QStyleOption buttonOpt = *opt;
1385 if (!(buttonOpt.state & State_Sunken))
1386 buttonOpt.state |= State_Raised;
1387 QPalette pal(opt->palette);
1388 pal.setBrush(QPalette::Button, opt->palette.light());
1389 pal.setColor(QPalette::Light, opt->palette.button().color());
1390 qDrawWinButton(p, opt->rect, pal, opt->state & (State_Sunken | State_On),
1391 &opt->palette.brush(QPalette::Button));
1393 PrimitiveElement arrow;
1394 if (opt->state & State_Horizontal) {
1395 if (ce == CE_ScrollBarAddLine)
1396 arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft;
1398 arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
1400 if (ce == CE_ScrollBarAddLine)
1401 arrow = PE_IndicatorArrowDown;
1403 arrow = PE_IndicatorArrowUp;
1405 QStyleOption arrowOpt = *opt;
1406 arrowOpt.rect = opt->rect.adjusted(4, 4, -4, -4);
1407 proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
1409 case CE_ScrollBarAddPage:
1410 case CE_ScrollBarSubPage: {
1412 QBrush bg = p->background();
1413 Qt::BGMode bg_mode = p->backgroundMode();
1414 p->setPen(Qt::NoPen);
1415 p->setBackgroundMode(Qt::OpaqueMode);
1417 if (opt->state & State_Sunken) {
1418 br = QBrush(opt->palette.shadow().color(), Qt::Dense4Pattern);
1419 p->setBackground(opt->palette.dark().color());
1422 const QBrush paletteBrush = opt->palette.brush(QPalette::Light);
1423 if (paletteBrush.style() == Qt::TexturePattern) {
1424 if (qHasPixmapTexture(paletteBrush))
1425 br = QBrush(paletteBrush.texture());
1427 br = QBrush(paletteBrush.textureImage());
1429 br = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1430 p->setBackground(opt->palette.window().color());
1433 p->drawRect(opt->rect);
1434 p->setBackground(bg);
1435 p->setBackgroundMode(bg_mode);
1437 case CE_ScrollBarSlider:
1438 if (!(opt->state & State_Enabled)) {
1440 const QBrush paletteBrush = opt->palette.brush(QPalette::Light);
1441 if (paletteBrush.style() == Qt::TexturePattern) {
1442 if (qHasPixmapTexture(paletteBrush))
1443 br = QBrush(paletteBrush.texture());
1445 br = QBrush(paletteBrush.textureImage());
1447 br = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1448 p->setPen(Qt::NoPen);
1450 p->setBackgroundMode(Qt::OpaqueMode);
1451 p->drawRect(opt->rect);
1453 QStyleOptionButton buttonOpt;
1454 buttonOpt.QStyleOption::operator=(*opt);
1455 buttonOpt.state = State_Enabled | State_Raised;
1457 QPalette pal(opt->palette);
1458 pal.setColor(QPalette::Button, opt->palette.light().color());
1459 pal.setColor(QPalette::Light, opt->palette.button().color());
1460 qDrawWinButton(p, opt->rect, pal,
false, &opt->palette.brush(QPalette::Button));
1464 case CE_HeaderSection: {
1466 if (opt->state & State_On)
1467 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1469 fill = opt->palette.brush(QPalette::Button);
1471 if (opt->state & (State_Raised | State_Sunken)) {
1472 qDrawWinButton(p, opt->rect, opt->palette, opt->state & State_Sunken, &fill);
1474 p->fillRect(opt->rect, fill);
1477#if 0
&& QT_CONFIG(toolbar)
1479 if (
const QStyleOptionToolBar *toolbar = qstyleoption_cast<
const QStyleOptionToolBar *>(opt)) {
1481 if (!(widget && qobject_cast<
const QMainWindow*> (widget->parentWidget())))
1484 QRect rect = opt->rect;
1485 bool paintLeftBorder =
true;
1486 bool paintRightBorder =
true;
1487 bool paintBottomBorder =
true;
1489 switch (toolbar->toolBarArea){
1490 case Qt::BottomToolBarArea :
1491 switch (toolbar->positionOfLine){
1492 case QStyleOptionToolBar::Beginning:
1493 case QStyleOptionToolBar::OnlyOne:
1494 paintBottomBorder =
false;
1500 case Qt::TopToolBarArea :
1501 switch (toolbar->positionWithinLine){
1502 case QStyleOptionToolBar::Beginning:
1503 paintLeftBorder =
false;
1505 case QStyleOptionToolBar::End:
1506 paintRightBorder =
false;
1508 case QStyleOptionToolBar::OnlyOne:
1509 paintRightBorder =
false;
1510 paintLeftBorder =
false;
1515 if (opt->direction == Qt::RightToLeft){
1516 bool tmp = paintLeftBorder;
1517 paintRightBorder=paintLeftBorder;
1518 paintLeftBorder=tmp;
1521 case Qt::RightToolBarArea :
1522 switch (toolbar->positionOfLine){
1523 case QStyleOptionToolBar::Beginning:
1524 case QStyleOptionToolBar::OnlyOne:
1525 paintRightBorder =
false;
1531 case Qt::LeftToolBarArea :
1532 switch (toolbar->positionOfLine){
1533 case QStyleOptionToolBar::Beginning:
1534 case QStyleOptionToolBar::OnlyOne:
1535 paintLeftBorder =
false;
1547 p->setPen(QPen(opt->palette.light().color()));
1548 p->drawLine(rect.topLeft().x(),
1550 rect.topRight().x(),
1551 rect.topRight().y());
1553 if (paintLeftBorder){
1554 p->setPen(QPen(opt->palette.light().color()));
1555 p->drawLine(rect.topLeft().x(),
1557 rect.bottomLeft().x(),
1558 rect.bottomLeft().y());
1561 if (paintRightBorder){
1562 p->setPen(QPen(opt->palette.dark().color()));
1563 p->drawLine(rect.topRight().x(),
1564 rect.topRight().y(),
1565 rect.bottomRight().x(),
1566 rect.bottomRight().y());
1569 if (paintBottomBorder){
1570 p->setPen(QPen(opt->palette.dark().color()));
1571 p->drawLine(rect.bottomLeft().x(),
1572 rect.bottomLeft().y(),
1573 rect.bottomRight().x(),
1574 rect.bottomRight().y());
1582 case CE_ProgressBarContents:
1584 QRect rect = pb->rect;
1585 if (!rect.isValid())
1589 const bool inverted = pb->invertedAppearance;
1593 rect = QRect(rect.y(), rect.x(), rect.height(), rect.width());
1595 m.translate(0, -(rect.height() + rect.y()*2));
1597 QPalette pal2 = pb->palette;
1599 if (pal2.highlight() == pal2.window())
1600 pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
1601 QPalette::Highlight));
1602 bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
1605 int w = rect.width();
1606 Q_D(
const QWindowsStyle);
1607 if (pb->minimum == 0 && pb->maximum == 0) {
1608 const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb);
1610 Q_ASSERT(unit_width >0);
1613 pbBits.palette = pal2;
1616 int chunkCount = w / unit_width + 1;
1617#if 0
&& QT_CONFIG(animation)
1618 if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject)))
1619 step = (animation->animationStep() / 3) % chunkCount;
1621 d->startAnimation(
new QProgressStyleAnimation(d->animationFps, opt->styleObject));
1625 int chunksInRow = 5;
1626 int myY = pbBits.rect.y();
1627 int myHeight = pbBits.rect.height();
1628 int chunksToDraw = chunksInRow;
1630 if (step > chunkCount - 5)chunksToDraw = (chunkCount - step);
1632 p->setClipRect(m.mapRect(QRectF(rect)).toRect());
1634 int x0 = reverse ? rect.left() + rect.width() - unit_width*(step) - unit_width : rect.left() + unit_width * step;
1637 for (
int i = 0; i < chunksToDraw ; ++i) {
1638 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
1639 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1640 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p);
1641 x += reverse ? -unit_width : unit_width;
1644 if ( step > chunkCount-5){
1645 x0 = reverse ? rect.left() + rect.width() - unit_width : rect.left() ;
1647 int chunksToDraw = step - (chunkCount - chunksInRow);
1648 for (
int i = 0; i < chunksToDraw ; ++i) {
1649 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
1650 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1651 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p);
1652 x += reverse ? -unit_width : unit_width;
1658#if 0
&& QT_CONFIG(animation)
1659 d->stopAnimation(opt->styleObject);
1661 QCommonStyle::drawControl(ce, opt, p);
1666#if 0
&& QT_CONFIG(dockwidget)
1667 case CE_DockWidgetTitle:
1669 if (
const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<
const QStyleOptionDockWidget *>(opt)) {
1670 Q_D(
const QWindowsStyle);
1672 const bool verticalTitleBar = dwOpt->verticalTitleBar;
1674 QRect rect = dwOpt->rect;
1677 if (verticalTitleBar) {
1681 p->translate(r.left(), r.top() + r.width());
1683 p->translate(-r.left(), -r.top());
1686 bool floating =
false;
1687 bool active = dwOpt->state & State_Active;
1688 QColor inactiveCaptionTextColor = d->inactiveCaptionText;
1689 if (dwOpt->movable) {
1693 if (opt->state & QStyle::State_Window) {
1696 left = d->activeCaptionColor;
1697 right = d->activeGradientCaptionColor;
1699 left = d->inactiveCaptionColor;
1700 right = d->inactiveGradientCaptionColor;
1702 QBrush fillBrush(left);
1703 if (left != right) {
1704 QPoint p1(r.x(), r.top() + r.height()/2);
1705 QPoint p2(rect.right(), r.top() + r.height()/2);
1706 QLinearGradient lg(p1, p2);
1707 lg.setColorAt(0, left);
1708 lg.setColorAt(1, right);
1711 p->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
1714 if (!dwOpt->title.isEmpty()) {
1715 QFont oldFont = p->font();
1717 QFont font = oldFont;
1721 QPalette palette = dwOpt->palette;
1722 palette.setColor(QPalette::Window, inactiveCaptionTextColor);
1723 QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, opt, widget);
1724 if (verticalTitleBar) {
1725 titleRect = QRect(r.left() + rect.bottom()
1726 - titleRect.bottom(),
1727 r.top() + titleRect.left() - rect.left(),
1728 titleRect.height(), titleRect.width());
1730 proxy()->drawItemText(p, titleRect,
1731 Qt::AlignLeft | Qt::AlignVCenter, palette,
1732 dwOpt->state & State_Enabled, dwOpt->title,
1733 floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText);
1734 p->setFont(oldFont);
1736 if (verticalTitleBar)
1741#if 0
&& QT_CONFIG(combobox)
1742 case CE_ComboBoxLabel:
1743 if (
const QStyleOptionComboBox *cb = qstyleoption_cast<
const QStyleOptionComboBox *>(opt)) {
1744 if (cb->state & State_HasFocus) {
1745 p->setPen(cb->palette.highlightedText().color());
1746 p->setBackground(cb->palette.highlight());
1748 p->setPen(cb->palette.text().color());
1749 p->setBackground(cb->palette.window());
1752 QCommonStyle::drawControl(ce, opt, p, widget);
1756 QCommonStyle::drawControl(ce, opt, p);
1797void QWindowsStyle::drawComplexControl(ComplexControl cc,
const QStyleOptionComplex *opt,
1802#if QT_CONFIG(slider)
1804 if (
const QStyleOptionSlider *slider = qstyleoption_cast<
const QStyleOptionSlider *>(opt)) {
1805 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider);
1806 int len = proxy()->pixelMetric(PM_SliderLength, slider);
1807 int ticks = slider->tickPosition;
1808 QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove);
1809 QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle);
1811 if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
1812 int mid = thickness / 2;
1814 if (ticks & QStyleOptionSlider::TicksAbove)
1816 if (ticks & QStyleOptionSlider::TicksBelow)
1819 p->setPen(slider->palette.shadow().color());
1820 if (slider->orientation == Qt::Horizontal) {
1821 qDrawWinPanel(p, groove.x(), groove.y() + mid - 2,
1822 groove.width(), 4, slider->palette,
true);
1823 p->drawLine(groove.x() + 1, groove.y() + mid - 1,
1824 groove.x() + groove.width() - 3, groove.y() + mid - 1);
1826 qDrawWinPanel(p, groove.x() + mid - 2, groove.y(),
1827 4, groove.height(), slider->palette,
true);
1828 p->drawLine(groove.x() + mid - 1, groove.y() + 1,
1829 groove.x() + mid - 1, groove.y() + groove.height() - 3);
1833 if (slider->subControls & SC_SliderTickmarks) {
1834 QStyleOptionSlider tmpSlider = *slider;
1835 tmpSlider.subControls = SC_SliderTickmarks;
1836 QCommonStyle::drawComplexControl(cc, &tmpSlider, p);
1839 if (slider->subControls & SC_SliderHandle) {
1849 const QColor c0 = slider->palette.shadow().color();
1850 const QColor c1 = slider->palette.dark().color();
1852 const QColor c3 = slider->palette.midlight().color();
1853 const QColor c4 = slider->palette.light().color();
1856 if (slider->state & State_Enabled) {
1857 handleBrush = slider->palette.color(QPalette::Button);
1859 handleBrush = QBrush(slider->palette.color(QPalette::Button),
1864 int x = handle.x(), y = handle.y(),
1865 wi = handle.width(), he = handle.height();
1872 Qt::Orientation orient = slider->orientation;
1873 bool tickAbove = slider->tickPosition == QStyleOptionSlider::TicksAbove;
1874 bool tickBelow = slider->tickPosition == QStyleOptionSlider::TicksBelow;
1876 if (slider->state & State_HasFocus) {
1877 QStyleOptionFocusRect fropt;
1878 fropt.QStyleOption::operator=(*slider);
1879 fropt.rect = subElementRect(SE_SliderFocusRect, slider);
1880 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p);
1883 if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
1884 Qt::BGMode oldMode = p->backgroundMode();
1885 p->setBackgroundMode(Qt::OpaqueMode);
1886 qDrawWinButton(p, QRect(x, y, wi, he), slider->palette,
false,
1888 p->setBackgroundMode(oldMode);
1892 QSliderDirection dir;
1894 if (orient == Qt::Horizontal)
1911 d = (wi + 1) / 2 - 1;
1912 a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d);
1916 d = (wi + 1) / 2 - 1;
1917 a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1);
1920 d = (he + 1) / 2 - 1;
1922 a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
1925 d = (he + 1) / 2 - 1;
1927 a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1);
1931 QBrush oldBrush = p->brush();
1932 p->setPen(Qt::NoPen);
1933 p->setBrush(handleBrush);
1934 Qt::BGMode oldMode = p->backgroundMode();
1935 p->setBackgroundMode(Qt::OpaqueMode);
1936 p->drawRect(x1, y1, x2-x1+1, y2-y1+1);
1938 p->setBrush(oldBrush);
1939 p->setBackgroundMode(oldMode);
1943 p->drawLine(x1, y1, x2, y1);
1945 p->drawLine(x1, y1+1, x2, y1+1);
1947 if (dir != SlLeft) {
1949 p->drawLine(x1+1, y1+1, x1+1, y2);
1951 p->drawLine(x1, y1, x1, y2);
1953 if (dir != SlRight) {
1955 p->drawLine(x2, y1, x2, y2);
1957 p->drawLine(x2-1, y1+1, x2-1, y2-1);
1959 if (dir != SlDown) {
1961 p->drawLine(x1, y2, x2, y2);
1963 p->drawLine(x1+1, y2-1, x2-1, y2-1);
1969 p->drawLine(x1, y1, x1+d, y1-d);
1972 p->drawLine(x2, y1, x2-d, y1-d);
1975 p->drawLine(x1+1, y1, x1+1+d, y1-d);
1977 p->drawLine(x2-1, y1, x2-1-d, y1-d);
1981 p->drawLine(x1, y2, x1+d, y2+d);
1984 p->drawLine(x2, y2, x2-d, y2+d);
1987 p->drawLine(x1+1, y2, x1+1+d, y2+d);
1989 p->drawLine(x2-1, y2, x2-1-d, y2+d);
1993 p->drawLine(x1, y1, x1-d, y1+d);
1996 p->drawLine(x1, y2, x1-d, y2-d);
1999 p->drawLine(x1, y1+1, x1-d, y1+1+d);
2001 p->drawLine(x1, y2-1, x1-d, y2-1-d);
2005 p->drawLine(x2, y1, x2+d, y1+d);
2008 p->drawLine(x2, y2, x2+d, y2-d);
2011 p->drawLine(x2, y1+1, x2+d, y1+1+d);
2013 p->drawLine(x2, y2-1, x2+d, y2-1-d);
2020#if QT_CONFIG(scrollbar)
2022 if (
const QStyleOptionSlider *scrollbar = qstyleoption_cast<
const QStyleOptionSlider *>(opt)) {
2023 QStyleOptionSlider newScrollbar = *scrollbar;
2024 if (scrollbar->minimum == scrollbar->maximum)
2025 newScrollbar.state &= ~State_Enabled;
2026 QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
2030#if QT_CONFIG(combobox)
2032 if (
const QStyleOptionComboBox *cmb = qstyleoption_cast<
const QStyleOptionComboBox *>(opt)) {
2033 QBrush editBrush = cmb->palette.brush(QPalette::Button);
2034 if ((cmb->subControls & SC_ComboBoxFrame)) {
2036 QPalette shadePal = opt->palette;
2037 shadePal.setColor(QPalette::Midlight, shadePal.button().color());
2038 qDrawWinPanel(p, opt->rect, shadePal,
true, &editBrush);
2041 p->fillRect(opt->rect, editBrush);
2044 if (cmb->subControls & SC_ComboBoxArrow) {
2045 State flags = State_None;
2047 QRect ar = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
2048 bool sunkenArrow = cmb->activeSubControls == SC_ComboBoxArrow
2049 && cmb->state & State_Sunken;
2051 p->setPen(cmb->palette.dark().color());
2052 p->setBrush(cmb->palette.brush(QPalette::Button));
2053 p->drawRect(ar.adjusted(0,0,-1,-1));
2056 QPalette pal(cmb->palette);
2057 pal.setColor(QPalette::Button, cmb->palette.light().color());
2058 pal.setColor(QPalette::Light, cmb->palette.button().color());
2059 qDrawWinButton(p, ar, pal,
false,
2060 &cmb->palette.brush(QPalette::Button));
2063 ar.adjust(2, 2, -2, -2);
2064 if (opt->state & State_Enabled)
2065 flags |= State_Enabled;
2066 if (opt->state & State_HasFocus)
2067 flags |= State_HasFocus;
2070 flags |= State_Sunken;
2071 QStyleOption arrowOpt = *cmb;
2072 arrowOpt.rect = ar.adjusted(1, 1, -1, -1);
2073 arrowOpt.state = flags;
2074 proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
2077 if (cmb->subControls & SC_ComboBoxEditField) {
2078 QRect re = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
2079 if (cmb->state & State_HasFocus && !cmb->editable)
2080 p->fillRect(re.x(), re.y(), re.width(), re.height(),
2081 cmb->palette.brush(QPalette::Highlight));
2083 if (cmb->state & State_HasFocus) {
2084 p->setPen(cmb->palette.highlightedText().color());
2085 p->setBackground(cmb->palette.highlight());
2088 p->setPen(cmb->palette.text().color());
2089 p->setBackground(cmb->palette.window());
2092 if (cmb->state & State_HasFocus && !cmb->editable) {
2093 QStyleOptionFocusRect focus;
2094 focus.QStyleOption::operator=(*cmb);
2095 focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget);
2096 focus.state |= State_FocusAtBorder;
2097 focus.backgroundColor = cmb->palette.highlight().color();
2098 proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
2104#if QT_CONFIG(spinbox)
2106 if (
const QStyleOptionSpinBox *sb = qstyleoption_cast<
const QStyleOptionSpinBox *>(opt)) {
2107 QStyleOptionSpinBox copy = *sb;
2108 PrimitiveElement pe;
2109 bool enabled = opt->state & State_Enabled;
2110 if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
2111 QBrush editBrush = sb->palette.brush(QPalette::Base);
2112 QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);
2113 QPalette shadePal = sb->palette;
2114 shadePal.setColor(QPalette::Midlight, shadePal.button().color());
2115 qDrawWinPanel(p, r, shadePal,
true, &editBrush);
2118 QPalette shadePal(opt->palette);
2119 shadePal.setColor(QPalette::Button, opt->palette.light().color());
2120 shadePal.setColor(QPalette::Light, opt->palette.button().color());
2122 if (sb->subControls & SC_SpinBoxUp) {
2123 copy.subControls = SC_SpinBoxUp;
2124 QPalette pal2 = sb->palette;
2125 if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
2126 pal2.setCurrentColorGroup(QPalette::Disabled);
2127 copy.state &= ~State_Enabled;
2130 copy.palette = pal2;
2132 if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
2133 copy.state |= State_On;
2134 copy.state |= State_Sunken;
2136 copy.state |= State_Raised;
2137 copy.state &= ~State_Sunken;
2139 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
2140 : PE_IndicatorSpinUp);
2142 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);
2143 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
2144 ©.palette.brush(QPalette::Button));
2145 copy.rect.adjust(4, 1, -5, -1);
2146 if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled))
2147 && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
2149 QStyleOptionSpinBox lightCopy = copy;
2150 lightCopy.rect.adjust(1, 1, 1, 1);
2151 lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
2152 proxy()->drawPrimitive(pe, &lightCopy, p, widget);
2154 proxy()->drawPrimitive(pe, ©, p, widget);
2157 if (sb->subControls & SC_SpinBoxDown) {
2158 copy.subControls = SC_SpinBoxDown;
2159 copy.state = sb->state;
2160 QPalette pal2 = sb->palette;
2161 if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
2162 pal2.setCurrentColorGroup(QPalette::Disabled);
2163 copy.state &= ~State_Enabled;
2165 copy.palette = pal2;
2167 if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
2168 copy.state |= State_On;
2169 copy.state |= State_Sunken;
2171 copy.state |= State_Raised;
2172 copy.state &= ~State_Sunken;
2174 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
2175 : PE_IndicatorSpinDown);
2177 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
2178 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
2179 ©.palette.brush(QPalette::Button));
2180 copy.rect.adjust(4, 0, -5, -1);
2181 if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled))
2182 && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
2184 QStyleOptionSpinBox lightCopy = copy;
2185 lightCopy.rect.adjust(1, 1, 1, 1);
2186 lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
2187 proxy()->drawPrimitive(pe, &lightCopy, p, widget);
2189 proxy()->drawPrimitive(pe, ©, p, widget);
2195 QCommonStyle::drawComplexControl(cc, opt, p);
2198 QCommonStyle::drawComplexControl(cc, opt, p);