639 bool doRestore =
false;
642#if 0
&& QT_CONFIG(toolbar)
643 case PE_IndicatorToolBarSeparator:
645 QRect rect = opt->rect;
646 const int margin = 2;
647 QPen oldPen = p->pen();
648 if (opt->state & State_Horizontal){
649 const int offset = rect.width()/2;
650 p->setPen(QPen(opt->palette.dark().color()));
651 p->drawLine(rect.bottomLeft().x() + offset,
652 rect.bottomLeft().y() - margin,
653 rect.topLeft().x() + offset,
654 rect.topLeft().y() + margin);
655 p->setPen(QPen(opt->palette.light().color()));
656 p->drawLine(rect.bottomLeft().x() + offset + 1,
657 rect.bottomLeft().y() - margin,
658 rect.topLeft().x() + offset + 1,
659 rect.topLeft().y() + margin);
662 const int offset = rect.height()/2;
663 p->setPen(QPen(opt->palette.dark().color()));
664 p->drawLine(rect.topLeft().x() + margin ,
665 rect.topLeft().y() + offset,
666 rect.topRight().x() - margin,
667 rect.topRight().y() + offset);
668 p->setPen(QPen(opt->palette.light().color()));
669 p->drawLine(rect.topLeft().x() + margin ,
670 rect.topLeft().y() + offset + 1,
671 rect.topRight().x() - margin,
672 rect.topRight().y() + offset + 1);
677 case PE_IndicatorToolBarHandle:
679 p->translate(opt->rect.x(), opt->rect.y());
680 if (opt->state & State_Horizontal) {
681 int x = opt->rect.width() / 2 - 4;
682 if (opt->direction == Qt::RightToLeft)
684 if (opt->rect.height() > 4) {
685 qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
686 opt->palette,
false, 1,
nullptr);
687 qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4,
688 opt->palette,
false, 1,
nullptr);
691 if (opt->rect.width() > 4) {
692 int y = opt->rect.height() / 2 - 4;
693 qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
694 opt->palette,
false, 1,
nullptr);
695 qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3,
696 opt->palette,
false, 1,
nullptr);
703 case PE_FrameButtonTool:
704 case PE_PanelButtonTool: {
705 QPen oldPen = p->pen();
706#if 0
&& QT_CONFIG(dockwidget)
707 if (w && w->inherits(
"QDockWidgetTitleButton")) {
708 if (
const QWidget *dw = w->parentWidget())
710 qDrawWinButton(p, opt->rect.adjusted(1, 1, 0, 0), opt->palette, opt->state & (State_Sunken | State_On),
711 &opt->palette.button());
719 bool panel = (pe == PE_PanelButtonTool);
720 if ((!(opt->state & State_Sunken ))
721 && (!(opt->state & State_Enabled)
722 || !(opt->state & State_MouseOver && opt->state & State_AutoRaise))
723 && (opt->state & State_On)) {
724 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
727 fill = opt->palette.brush(QPalette::Button);
731 if (opt->state & (State_Raised | State_Sunken | State_On)) {
732 if (opt->state & State_AutoRaise) {
733 if (opt->state & (State_Enabled | State_Sunken | State_On)){
735 qDrawShadePanel(p, opt->rect, opt->palette,
736 opt->state & (State_Sunken | State_On), 1, &fill);
738 qDrawShadeRect(p, opt->rect, opt->palette,
739 opt->state & (State_Sunken | State_On), 1);
742 p->setPen(opt->palette.button().color());
743 p->drawRect(opt->rect.adjusted(1,1,-2,-2));
746 qDrawWinButton(p, opt->rect, opt->palette,
747 opt->state & (State_Sunken | State_On), panel ? &fill :
nullptr);
750 p->fillRect(opt->rect, fill);
754 case PE_PanelButtonCommand:
757 State flags = opt->state;
758 QPalette pal = opt->palette;
760 if (! (flags & State_Sunken) && (flags & State_On))
761 fill = QBrush(pal.light().color(), Qt::Dense4Pattern);
763 fill = pal.brush(QPalette::Button);
765 if (btn->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
766 p->setPen(pal.dark().color());
768 p->drawRect(r.adjusted(0, 0, -1, -1));
769 }
else if (flags & (State_Raised | State_On | State_Sunken)) {
770 qDrawWinButton(p, r, pal, flags & (State_Sunken | State_On),
773 p->fillRect(r, fill);
777 case PE_FrameDefaultButton: {
778 QPen oldPen = p->pen();
779 p->setPen(QPen(opt->palette.shadow().color(), 0));
780 QRectF rect = opt->rect;
781 const qreal dpi = QStyleHelper::dpi(opt);
782 const qreal topLevelAdjustment = QStyleHelper::dpiScaled(0.5, dpi);
783 const qreal bottomRightAdjustment = QStyleHelper::dpiScaled(-1.5, dpi);
784 rect.adjust(topLevelAdjustment, topLevelAdjustment,
785 bottomRightAdjustment, bottomRightAdjustment);
790 case PE_IndicatorCheckBox: {
792 if (opt->state & State_NoChange)
793 fill = QBrush(opt->palette.base().color(), Qt::Dense4Pattern);
794 else if (opt->state & State_Sunken)
795 fill = opt->palette.button();
796 else if (opt->state & State_Enabled)
797 fill = opt->palette.base();
799 fill = opt->palette.window();
802 qDrawWinPanel(p, opt->rect, opt->palette,
true, &fill);
803 if (opt->state & State_NoChange)
804 p->setPen(opt->palette.dark().color());
806 p->setPen(opt->palette.text().color());
809 case PE_IndicatorItemViewItemCheck:
814#if 0
&& QT_CONFIG(itemviews)
815 if (pe == PE_IndicatorItemViewItemCheck) {
816 const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<
const QStyleOptionViewItem *>(opt);
817 p->setPen(itemViewOpt
818 && itemViewOpt->showDecorationSelected
819 && opt->state & State_Selected
820 ? opt->palette.highlightedText().color()
821 : opt->palette.text().color());
822 if (opt->state & State_NoChange)
823 p->setBrush(opt->palette.brush(QPalette::Button));
824 p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, opt->rect.width() - 2, opt->rect.height() - 2);
827 if (!(opt->state & State_Off)) {
829 qreal scaleh = opt->rect.width() / 12.0;
830 qreal scalev = opt->rect.height() / 12.0;
831 points[0] = { opt->rect.x() + 3.5 * scaleh, opt->rect.y() + 5.5 * scalev };
832 points[1] = { points[0].x(), points[0].y() + 2 * scalev };
833 points[2] = { points[1].x() + 2 * scaleh, points[1].y() + 2 * scalev };
834 points[3] = { points[2].x() + 4 * scaleh, points[2].y() - 4 * scalev };
835 points[4] = { points[3].x(), points[3].y() - 2 * scalev };
836 points[5] = { points[4].x() - 4 * scaleh, points[4].y() + 4 * scalev };
837 p->setPen(QPen(opt->palette.text().color(), 0));
838 p->setBrush(opt->palette.text());
839 p->drawPolygon(points, 6);
844 case PE_FrameFocusRect:
845 if (
const QStyleOptionFocusRect *fropt = qstyleoption_cast<
const QStyleOptionFocusRect *>(opt)) {
847 if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt))
851 p->setBackgroundMode(Qt::TransparentMode);
852 QColor bg_col = fropt->backgroundColor;
853 if (!bg_col.isValid())
854 bg_col = p->background().color();
855 bg_col = bg_col.toRgb();
857 QColor patternCol((bg_col.red() ^ 0xff) & 0xff,
858 (bg_col.green() ^ 0xff) & 0xff,
859 (bg_col.blue() ^ 0xff) & 0xff);
860 p->setBrush(QBrush(patternCol, Qt::Dense4Pattern));
861 p->setBrushOrigin(r.topLeft());
862 p->setPen(Qt::NoPen);
863 p->drawRect(r.left(), r.top(), r.width(), 1);
864 p->drawRect(r.left(), r.bottom(), r.width(), 1);
865 p->drawRect(r.left(), r.top(), 1, r.height());
866 p->drawRect(r.right(), r.top(), 1, r.height());
870 case PE_IndicatorRadioButton:
874 p->setRenderHint(QPainter::Antialiasing,
true);
876 QPointF circleCenter = r.center() + QPoint(1, 1);
877 qreal radius = (r.width() + (r.width() + 1) % 2) / 2.0 - 1;
880 path1.addEllipse(circleCenter, radius, radius);
883 path2.addEllipse(circleCenter, radius, radius);
886 path3.addEllipse(circleCenter, radius, radius);
889 path4.addEllipse(circleCenter, radius, radius);
891 QPolygon topLeftPol, bottomRightPol;
892 topLeftPol.setPoints(3, r.x(), r.y(), r.x(), r.y() + r.height(), r.x() + r.width(), r.y());
893 bottomRightPol.setPoints(3, r.x(), r.y() + r.height(), r.x() + r.width(), r.y() + r.height(), r.x() + r.width(), r.y());
895 p->setClipRegion(QRegion(topLeftPol));
896 p->setPen(opt->palette.dark().color());
897 p->setBrush(opt->palette.dark());
899 p->setPen(opt->palette.shadow().color());
900 p->setBrush(opt->palette.shadow());
903 p->setClipRegion(QRegion(bottomRightPol));
904 p->setPen(opt->palette.light().color());
905 p->setBrush(opt->palette.light());
907 p->setPen(opt->palette.midlight().color());
908 p->setBrush(opt->palette.midlight());
911 const QBrush fill = ((opt->state & State_Sunken) || !(opt->state & State_Enabled))
912 ? opt->palette.button() : opt->palette.base();
914 p->setClipping(
false);
915 p->setPen(fill.color());
919 if (opt->state & State_On) {
920 p->setPen(opt->palette.text().color());
921 p->setBrush(opt->palette.text());
930 if (
const QStyleOptionFrame *frame = qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
931 if (frame->lineWidth == 2 || pe == PE_Frame) {
932 QPalette popupPal = frame->palette;
933 if (pe == PE_FrameMenu) {
934 popupPal.setBrush(QPalette::Light, frame->palette.window());
935 popupPal.setBrush(QPalette::Midlight, frame->palette.light());
937 if (pe == PE_Frame && (frame->state & State_Raised))
938 qDrawWinButton(p, frame->rect, popupPal, frame->state & State_Sunken);
939 else if (pe == PE_Frame && (frame->state & State_Sunken))
941 popupPal.setBrush(QPalette::Midlight, frame->palette.window());
942 qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
945 qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
947 QCommonStyle::drawPrimitive(pe, opt, p);
950 QPalette popupPal = opt->palette;
951 popupPal.setBrush(QPalette::Light, opt->palette.window());
952 popupPal.setBrush(QPalette::Midlight, opt->palette.light());
953 qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
957 case PE_FrameButtonBevel:
958 case PE_PanelButtonBevel: {
960 bool panel = pe != PE_FrameButtonBevel;
961 p->setBrushOrigin(opt->rect.topLeft());
962 if (!(opt->state & State_Sunken) && (opt->state & State_On))
963 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
965 fill = opt->palette.brush(QPalette::Button);
967 if (opt->state & (State_Raised | State_On | State_Sunken)) {
968 qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On),
969 panel ? &fill :
nullptr);
972 p->fillRect(opt->rect, fill);
974 p->drawRect(opt->rect);
977 case PE_FrameWindow: {
978 QPalette popupPal = opt->palette;
979 popupPal.setBrush(QPalette::Light, opt->palette.window());
980 popupPal.setBrush(QPalette::Midlight, opt->palette.light());
981 qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
983#if 0
&& QT_CONFIG(dockwidget)
984 case PE_IndicatorDockWidgetResizeHandle:
986 case PE_FrameDockWidget:
987 if (qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
988 proxy()->drawPrimitive(QStyle::PE_FrameWindow, opt, p, w);
993 case PE_FrameStatusBarItem:
994 qDrawShadePanel(p, opt->rect, opt->palette,
true, 1,
nullptr);
997 case PE_IndicatorProgressChunk:
999 bool vertical =
false, inverted =
false;
1000 if (
const QStyleOptionProgressBar *pb = qstyleoption_cast<
const QStyleOptionProgressBar *>(opt)) {
1001 vertical = !(pb->state & QStyle::State_Horizontal);
1002 inverted = pb->invertedAppearance;
1006 int chunksize = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt) - space;
1008 if (opt->rect.width() <= chunksize)
1012 p->fillRect(opt->rect.x() + space, opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
1013 opt->palette.brush(QPalette::Highlight));
1015 p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
1016 opt->palette.brush(QPalette::Highlight));
1018 if (opt->rect.height() <= chunksize)
1022 p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height() - space,
1023 opt->palette.brush(QPalette::Highlight));
1025 p->fillRect(opt->rect.x(), opt->rect.y() + space, opt->rect.width(), opt->rect.height() - space,
1026 opt->palette.brush(QPalette::Highlight));
1031 case PE_FrameTabWidget: {
1032 qDrawWinButton(p, opt->rect, opt->palette,
false,
nullptr);
1036 QCommonStyle::drawPrimitive(pe, opt, p);
1047#if 0
&& QT_CONFIG(rubberband)
1049 if (qstyleoption_cast<
const QStyleOptionRubberBand *>(opt)) {
1051 QPixmap tiledPixmap(16, 16);
1052 QPainter pixmapPainter(&tiledPixmap);
1053 pixmapPainter.setPen(Qt::NoPen);
1054 pixmapPainter.setBrush(Qt::Dense4Pattern);
1055 pixmapPainter.setBackground(Qt::white);
1056 pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
1057 pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
1058 pixmapPainter.end();
1059 tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
1061 QRect r = opt->rect;
1062 QStyleHintReturnMask mask;
1063 if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
1064 p->setClipRegion(mask.region);
1065 p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
1072#if 0
&& QT_CONFIG(menu) && QT_CONFIG(mainwindow)
1073 case CE_MenuBarEmptyArea:
1074 if (widget && qobject_cast<
const QMainWindow *>(widget->parentWidget())) {
1075 p->fillRect(opt->rect, opt->palette.button());
1076 QPen oldPen = p->pen();
1077 p->setPen(QPen(opt->palette.dark().color()));
1078 p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight());
1083#if 0
&& QT_CONFIG(menu)
1085 if (
const QStyleOptionMenuItem *menuitem = qstyleoption_cast<
const QStyleOptionMenuItem *>(opt)) {
1087 menuitem->rect.getRect(&x, &y, &w, &h);
1088 int tab = menuitem->tabWidth;
1089 bool dis = !(menuitem->state & State_Enabled);
1090 bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
1091 ? menuitem->checked :
false;
1092 bool act = menuitem->state & State_Selected;
1095 int checkcol = qMax<
int>(menuitem->maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
1097 QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
1098 p->fillRect(menuitem->rect.adjusted(0, 0, -1, 0), fill);
1100 if (menuitem->menuItemType == QStyleOptionMenuItem::Separator){
1101 int yoff = y-1 + h / 2;
1102 p->setPen(menuitem->palette.dark().color());
1103 p->drawLine(x + 2, yoff, x + w - 4, yoff);
1104 p->setPen(menuitem->palette.light().color());
1105 p->drawLine(x + 2, yoff + 1, x + w - 4, yoff + 1);
1109 QRect vCheckRect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x(), menuitem->rect.y(), checkcol, menuitem->rect.height()));
1110 if (!menuitem->icon.isNull() && checked) {
1112 qDrawShadePanel(p, vCheckRect,
1113 menuitem->palette,
true, 1,
1114 &menuitem->palette.brush(QPalette::Button));
1116 QBrush fill(menuitem->palette.light().color(), Qt::Dense4Pattern);
1117 qDrawShadePanel(p, vCheckRect, menuitem->palette,
true, 1, &fill);
1120 p->fillRect(vCheckRect, menuitem->palette.brush(QPalette::Button));
1126 if (!menuitem->icon.isNull()) {
1127 QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
1129 mode = QIcon::Active;
1132 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
1134 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
1135 const int pixw = pixmap.width() / pixmap.devicePixelRatio();
1136 const int pixh = pixmap.height() / pixmap.devicePixelRatio();
1137 QRect pmr(0, 0, pixw, pixh);
1138 pmr.moveCenter(vCheckRect.center());
1139 p->setPen(menuitem->palette.text().color());
1140 p->drawPixmap(pmr.topLeft(), pixmap);
1141 }
else if (checked) {
1142 QStyleOptionMenuItem newMi = *menuitem;
1143 newMi.state = State_None;
1145 newMi.state |= State_Enabled;
1147 newMi.state |= State_On;
1148 newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + QWindowsStylePrivate::windowsItemFrame,
1149 menuitem->rect.y() + QWindowsStylePrivate::windowsItemFrame,
1150 checkcol - 2 * QWindowsStylePrivate::windowsItemFrame,
1151 menuitem->rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
1152 proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
1154 p->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color());
1158 discol = menuitem->palette.text().color();
1162 int xm =
int(QWindowsStylePrivate::windowsItemFrame) + checkcol +
int(QWindowsStylePrivate::windowsItemHMargin);
1163 int xpos = menuitem->rect.x() + xm;
1164 QRect textRect(xpos, y + QWindowsStylePrivate::windowsItemVMargin,
1165 w - xm - QWindowsStylePrivate::windowsRightBorder - tab + 1, h - 2 * QWindowsStylePrivate::windowsItemVMargin);
1166 QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
1167 QStringRef s(&menuitem->text);
1170 int t = s.indexOf(QLatin1Char(
'\t'));
1171 int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
1172 if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
1173 text_flags |= Qt::TextHideMnemonic;
1174 text_flags |= Qt::AlignLeft;
1176 QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
1177 QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
1178 const QString textToDraw = s.mid(t + 1).toString();
1179 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1180 p->setPen(menuitem->palette.light().color());
1181 p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, textToDraw);
1184 p->drawText(vShortcutRect, text_flags, textToDraw);
1187 QFont font = menuitem->font;
1188 if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
1191 const QString textToDraw = s.left(t).toString();
1192 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1193 p->setPen(menuitem->palette.light().color());
1194 p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, textToDraw);
1197 p->drawText(vTextRect, text_flags, textToDraw);
1200 if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {
1201 int dim = (h - 2 * QWindowsStylePrivate::windowsItemFrame) / 2;
1202 PrimitiveElement arrow;
1203 arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
1204 xpos = x + w - QWindowsStylePrivate::windowsArrowHMargin - QWindowsStylePrivate::windowsItemFrame - dim;
1205 QRect vSubMenuRect = visualRect(opt->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
1206 QStyleOptionMenuItem newMI = *menuitem;
1207 newMI.rect = vSubMenuRect;
1208 newMI.state = dis ? State_None : State_Enabled;
1210 newMI.palette.setColor(QPalette::ButtonText,
1211 newMI.palette.highlightedText().color());
1212 proxy()->drawPrimitive(arrow, &newMI, p, widget);
1218#if 0
&& QT_CONFIG(menubar)
1219 case CE_MenuBarItem:
1220 if (
const QStyleOptionMenuItem *mbi = qstyleoption_cast<
const QStyleOptionMenuItem *>(opt)) {
1221 bool active = mbi->state & State_Selected;
1222 bool hasFocus = mbi->state & State_HasFocus;
1223 bool down = mbi->state & State_Sunken;
1224 QStyleOptionMenuItem newMbi = *mbi;
1225 p->fillRect(mbi->rect, mbi->palette.brush(QPalette::Button));
1226 if (active || hasFocus) {
1227 QBrush b = mbi->palette.brush(QPalette::Button);
1229 p->setBrushOrigin(p->brushOrigin() + QPoint(1, 1));
1230 if (active && hasFocus)
1231 qDrawShadeRect(p, mbi->rect.x(), mbi->rect.y(), mbi->rect.width(),
1232 mbi->rect.height(), mbi->palette, active && down, 1, 0, &b);
1233 if (active && down) {
1234 newMbi.rect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, mbi, widget),
1235 proxy()->pixelMetric(PM_ButtonShiftVertical, mbi, widget));
1236 p->setBrushOrigin(p->brushOrigin() - QPoint(1, 1));
1239 QCommonStyle::drawControl(ce, &newMbi, p, widget);
1243#if 0
&& QT_CONFIG(tabbar)
1244 case CE_TabBarTabShape:
1245 if (
const QStyleOptionTab *tab = qstyleoption_cast<
const QStyleOptionTab *>(opt)) {
1246 bool rtlHorTabs = (tab->direction == Qt::RightToLeft
1247 && (tab->shape == QTabBar::RoundedNorth
1248 || tab->shape == QTabBar::RoundedSouth));
1249 bool selected = tab->state & State_Selected;
1250 bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
1252 && tab->position == QStyleOptionTab::Beginning));
1253 bool firstTab = ((!rtlHorTabs
1254 && tab->position == QStyleOptionTab::Beginning)
1256 && tab->position == QStyleOptionTab::End));
1257 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
1258 bool previousSelected =
1260 && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
1262 && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
1265 && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
1267 && tab->selectedPosition
1268 == QStyleOptionTab::PreviousIsSelected));
1269 int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
1270 bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
1272 && tabBarAlignment == Qt::AlignRight);
1274 bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
1276 && tabBarAlignment == Qt::AlignLeft);
1278 QColor light = tab->palette.light().color();
1279 QColor dark = tab->palette.dark().color();
1280 QColor shadow = tab->palette.shadow().color();
1281 int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
1283 borderThinkness /= 2;
1284 QRect r2(opt->rect);
1286 int x2 = r2.right();
1288 int y2 = r2.bottom();
1289 switch (tab->shape) {
1291 QCommonStyle::drawControl(ce, tab, p, widget);
1293 case QTabBar::RoundedNorth: {
1296 x1 += onlyOne || firstTab ? borderThinkness : 0;
1297 x2 -= onlyOne || lastTab ? borderThinkness : 0;
1300 p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 2), tab->palette.window());
1304 p->fillRect(QRect(x1,y2-1,x2-x1,1), tab->palette.window());
1305 p->fillRect(QRect(x1,y2,x2-x1,1), tab->palette.window());
1308 if (firstTab || selected || onlyOne || !previousSelected) {
1310 p->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
1311 p->drawPoint(x1 + 1, y1 + 1);
1315 int beg = x1 + (previousSelected ? 0 : 2);
1316 int end = x2 - (nextSelected ? 0 : 2);
1318 p->drawLine(beg, y1, end, y1);
1321 if (lastTab || selected || onlyOne || !nextSelected) {
1323 p->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1324 p->drawPoint(x2 - 1, y1 + 1);
1326 p->drawLine(x2 - 1, y1 + 2, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1329 case QTabBar::RoundedSouth: {
1332 x1 += firstTab ? borderThinkness : 0;
1333 x2 -= lastTab ? borderThinkness : 0;
1336 p->fillRect(QRect(x1 + 1, y1 + 2, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.window());
1340 p->fillRect(QRect(x1, y1 + 1, (x2 - 1)-x1, 1), tab->palette.window());
1341 p->fillRect(QRect(x1, y1, (x2 - 1)-x1, 1), tab->palette.window());
1344 if (firstTab || selected || onlyOne || !previousSelected) {
1346 p->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
1347 p->drawPoint(x1 + 1, y2 - 1);
1351 int beg = x1 + (previousSelected ? 0 : 2);
1352 int end = x2 - (nextSelected ? 0 : 2);
1354 p->drawLine(beg, y2, end, y2);
1356 p->drawLine(beg, y2 - 1, end, y2 - 1);
1359 if (lastTab || selected || onlyOne || !nextSelected) {
1361 p->drawLine(x2, y2 - 2, x2, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1362 p->drawPoint(x2 - 1, y2 - 1);
1364 p->drawLine(x2 - 1, y2 - 2, x2 - 1, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1367 case QTabBar::RoundedWest: {
1370 y1 += firstTab ? borderThinkness : 0;
1371 y2 -= lastTab ? borderThinkness : 0;
1374 p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 2, (y2 - y1) - 1), tab->palette.window());
1378 p->fillRect(QRect(x2 - 1, y1, 1, y2-y1), tab->palette.window());
1379 p->fillRect(QRect(x2, y1, 1, y2-y1), tab->palette.window());
1382 if (firstTab || selected || onlyOne || !previousSelected) {
1384 p->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
1385 p->drawPoint(x1 + 1, y1 + 1);
1389 int beg = y1 + (previousSelected ? 0 : 2);
1390 int end = y2 - (nextSelected ? 0 : 2);
1392 p->drawLine(x1, beg, x1, end);
1395 if (lastTab || selected || onlyOne || !nextSelected) {
1397 p->drawLine(x1 + 3, y2, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
1398 p->drawPoint(x1 + 2, y2 - 1);
1400 p->drawLine(x1 + 3, y2 - 1, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
1401 p->drawPoint(x1 + 1, y2 - 1);
1402 p->drawPoint(x1 + 2, y2);
1405 case QTabBar::RoundedEast: {
1408 y1 += firstTab ? borderThinkness : 0;
1409 y2 -= lastTab ? borderThinkness : 0;
1412 p->fillRect(QRect(x1 + 2, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.window());
1416 p->fillRect(QRect(x1 + 1, y1, 1, (y2 - 1)-y1),tab->palette.window());
1417 p->fillRect(QRect(x1, y1, 1, (y2-1)-y1), tab->palette.window());
1420 if (firstTab || selected || onlyOne || !previousSelected) {
1422 p->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
1423 p->drawPoint(x2 - 1, y1 + 1);
1427 int beg = y1 + (previousSelected ? 0 : 2);
1428 int end = y2 - (nextSelected ? 0 : 2);
1430 p->drawLine(x2, beg, x2, end);
1432 p->drawLine(x2 - 1, beg, x2 - 1, end);
1435 if (lastTab || selected || onlyOne || !nextSelected) {
1437 p->drawLine(x2 - 2, y2, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
1438 p->drawPoint(x2 - 1, y2 - 1);
1440 p->drawLine(x2 - 2, y2 - 1, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
1447 case CE_ToolBoxTabShape:
1448 qDrawShadePanel(p, opt->rect, opt->palette,
1449 opt->state & (State_Sunken | State_On), 1,
1450 &opt->palette.brush(QPalette::Button));
1452#if 0
&& QT_CONFIG(splitter)
1454 p->eraseRect(opt->rect);
1457#if 0
&& QT_CONFIG(scrollbar)
1458 case CE_ScrollBarSubLine:
1459 case CE_ScrollBarAddLine: {
1460 if ((opt->state & State_Sunken)) {
1461 p->setPen(opt->palette.dark().color());
1462 p->setBrush(opt->palette.brush(QPalette::Button));
1463 p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
1465 QStyleOption buttonOpt = *opt;
1466 if (!(buttonOpt.state & State_Sunken))
1467 buttonOpt.state |= State_Raised;
1468 QPalette pal(opt->palette);
1469 pal.setBrush(QPalette::Button, opt->palette.light());
1470 pal.setColor(QPalette::Light, opt->palette.button().color());
1471 qDrawWinButton(p, opt->rect, pal, opt->state & (State_Sunken | State_On),
1472 &opt->palette.brush(QPalette::Button));
1474 PrimitiveElement arrow;
1475 if (opt->state & State_Horizontal) {
1476 if (ce == CE_ScrollBarAddLine)
1477 arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft;
1479 arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
1481 if (ce == CE_ScrollBarAddLine)
1482 arrow = PE_IndicatorArrowDown;
1484 arrow = PE_IndicatorArrowUp;
1486 QStyleOption arrowOpt = *opt;
1487 arrowOpt.rect = opt->rect.adjusted(4, 4, -4, -4);
1488 proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
1490 case CE_ScrollBarAddPage:
1491 case CE_ScrollBarSubPage: {
1493 QBrush bg = p->background();
1494 Qt::BGMode bg_mode = p->backgroundMode();
1495 p->setPen(Qt::NoPen);
1496 p->setBackgroundMode(Qt::OpaqueMode);
1498 if (opt->state & State_Sunken) {
1499 br = QBrush(opt->palette.shadow().color(), Qt::Dense4Pattern);
1500 p->setBackground(opt->palette.dark().color());
1503 const QBrush paletteBrush = opt->palette.brush(QPalette::Light);
1504 if (paletteBrush.style() == Qt::TexturePattern) {
1505 if (qHasPixmapTexture(paletteBrush))
1506 br = QBrush(paletteBrush.texture());
1508 br = QBrush(paletteBrush.textureImage());
1510 br = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1511 p->setBackground(opt->palette.window().color());
1514 p->drawRect(opt->rect);
1515 p->setBackground(bg);
1516 p->setBackgroundMode(bg_mode);
1518 case CE_ScrollBarSlider:
1519 if (!(opt->state & State_Enabled)) {
1521 const QBrush paletteBrush = opt->palette.brush(QPalette::Light);
1522 if (paletteBrush.style() == Qt::TexturePattern) {
1523 if (qHasPixmapTexture(paletteBrush))
1524 br = QBrush(paletteBrush.texture());
1526 br = QBrush(paletteBrush.textureImage());
1528 br = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1529 p->setPen(Qt::NoPen);
1531 p->setBackgroundMode(Qt::OpaqueMode);
1532 p->drawRect(opt->rect);
1534 QStyleOptionButton buttonOpt;
1535 buttonOpt.QStyleOption::operator=(*opt);
1536 buttonOpt.state = State_Enabled | State_Raised;
1538 QPalette pal(opt->palette);
1539 pal.setColor(QPalette::Button, opt->palette.light().color());
1540 pal.setColor(QPalette::Light, opt->palette.button().color());
1541 qDrawWinButton(p, opt->rect, pal,
false, &opt->palette.brush(QPalette::Button));
1545 case CE_HeaderSection: {
1547 if (opt->state & State_On)
1548 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1550 fill = opt->palette.brush(QPalette::Button);
1552 if (opt->state & (State_Raised | State_Sunken)) {
1553 qDrawWinButton(p, opt->rect, opt->palette, opt->state & State_Sunken, &fill);
1555 p->fillRect(opt->rect, fill);
1558#if 0
&& QT_CONFIG(toolbar)
1560 if (
const QStyleOptionToolBar *toolbar = qstyleoption_cast<
const QStyleOptionToolBar *>(opt)) {
1562 if (!(widget && qobject_cast<
const QMainWindow*> (widget->parentWidget())))
1565 QRect rect = opt->rect;
1566 bool paintLeftBorder =
true;
1567 bool paintRightBorder =
true;
1568 bool paintBottomBorder =
true;
1570 switch (toolbar->toolBarArea){
1571 case Qt::BottomToolBarArea :
1572 switch (toolbar->positionOfLine){
1573 case QStyleOptionToolBar::Beginning:
1574 case QStyleOptionToolBar::OnlyOne:
1575 paintBottomBorder =
false;
1581 case Qt::TopToolBarArea :
1582 switch (toolbar->positionWithinLine){
1583 case QStyleOptionToolBar::Beginning:
1584 paintLeftBorder =
false;
1586 case QStyleOptionToolBar::End:
1587 paintRightBorder =
false;
1589 case QStyleOptionToolBar::OnlyOne:
1590 paintRightBorder =
false;
1591 paintLeftBorder =
false;
1596 if (opt->direction == Qt::RightToLeft){
1597 bool tmp = paintLeftBorder;
1598 paintRightBorder=paintLeftBorder;
1599 paintLeftBorder=tmp;
1602 case Qt::RightToolBarArea :
1603 switch (toolbar->positionOfLine){
1604 case QStyleOptionToolBar::Beginning:
1605 case QStyleOptionToolBar::OnlyOne:
1606 paintRightBorder =
false;
1612 case Qt::LeftToolBarArea :
1613 switch (toolbar->positionOfLine){
1614 case QStyleOptionToolBar::Beginning:
1615 case QStyleOptionToolBar::OnlyOne:
1616 paintLeftBorder =
false;
1628 p->setPen(QPen(opt->palette.light().color()));
1629 p->drawLine(rect.topLeft().x(),
1631 rect.topRight().x(),
1632 rect.topRight().y());
1634 if (paintLeftBorder){
1635 p->setPen(QPen(opt->palette.light().color()));
1636 p->drawLine(rect.topLeft().x(),
1638 rect.bottomLeft().x(),
1639 rect.bottomLeft().y());
1642 if (paintRightBorder){
1643 p->setPen(QPen(opt->palette.dark().color()));
1644 p->drawLine(rect.topRight().x(),
1645 rect.topRight().y(),
1646 rect.bottomRight().x(),
1647 rect.bottomRight().y());
1650 if (paintBottomBorder){
1651 p->setPen(QPen(opt->palette.dark().color()));
1652 p->drawLine(rect.bottomLeft().x(),
1653 rect.bottomLeft().y(),
1654 rect.bottomRight().x(),
1655 rect.bottomRight().y());
1663 case CE_ProgressBarContents:
1664 if (
const QStyleOptionProgressBar *pb = qstyleoption_cast<
const QStyleOptionProgressBar *>(opt)) {
1665 QRect rect = pb->rect;
1666 if (!rect.isValid())
1669 const bool vertical = !(pb->state & QStyle::State_Horizontal);
1670 const bool inverted = pb->invertedAppearance;
1674 rect = QRect(rect.y(), rect.x(), rect.height(), rect.width());
1676 m.translate(0, -(rect.height() + rect.y()*2));
1678 QPalette pal2 = pb->palette;
1680 if (pal2.highlight() == pal2.window())
1681 pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
1682 QPalette::Highlight));
1683 bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
1686 int w = rect.width();
1687 if (pb->minimum == 0 && pb->maximum == 0) {
1688 const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb);
1689 QStyleOptionProgressBar pbBits = *pb;
1690 Q_ASSERT(unit_width >0);
1693 pbBits.palette = pal2;
1696 int chunkCount = w / unit_width + 1;
1697#if QT_CONFIG(animation)
1698 if (QQuickItem *control = opt->control) {
1699 auto *anim = control->findChild<QQuickWindowsProgressBarAnimation *>(Qt::FindDirectChildrenOnly);
1701 anim =
new QQuickWindowsProgressBarAnimation(control);
1702 if (!anim->isActive())
1704 step = (anim->step() / 3) % chunkCount;
1707 int chunksInRow = 5;
1708 int myY = pbBits.rect.y();
1709 int myHeight = pbBits.rect.height();
1710 int chunksToDraw = chunksInRow;
1712 if (step > chunkCount - 5)chunksToDraw = (chunkCount - step);
1714 p->setClipRect(m.mapRect(QRectF(rect)).toRect());
1716 int x0 = reverse ? rect.left() + rect.width() - unit_width*(step) - unit_width : rect.left() + unit_width * step;
1719 for (
int i = 0; i < chunksToDraw ; ++i) {
1720 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
1721 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1722 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p);
1723 x += reverse ? -unit_width : unit_width;
1726 if ( step > chunkCount-5){
1727 x0 = reverse ? rect.left() + rect.width() - unit_width : rect.left() ;
1729 int chunksToDraw = step - (chunkCount - chunksInRow);
1730 for (
int i = 0; i < chunksToDraw ; ++i) {
1731 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
1732 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1733 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p);
1734 x += reverse ? -unit_width : unit_width;
1740 QCommonStyle::drawControl(ce, opt, p);
1745#if 0
&& QT_CONFIG(dockwidget)
1746 case CE_DockWidgetTitle:
1748 if (
const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<
const QStyleOptionDockWidget *>(opt)) {
1749 Q_D(
const QWindowsStyle);
1751 const bool verticalTitleBar = dwOpt->verticalTitleBar;
1753 QRect rect = dwOpt->rect;
1756 if (verticalTitleBar) {
1760 p->translate(r.left(), r.top() + r.width());
1762 p->translate(-r.left(), -r.top());
1765 bool floating =
false;
1766 bool active = dwOpt->state & State_Active;
1767 QColor inactiveCaptionTextColor = d->inactiveCaptionText;
1768 if (dwOpt->movable) {
1772 if (opt->state & QStyle::State_Window) {
1775 left = d->activeCaptionColor;
1776 right = d->activeGradientCaptionColor;
1778 left = d->inactiveCaptionColor;
1779 right = d->inactiveGradientCaptionColor;
1781 QBrush fillBrush(left);
1782 if (left != right) {
1783 QPoint p1(r.x(), r.top() + r.height()/2);
1784 QPoint p2(rect.right(), r.top() + r.height()/2);
1785 QLinearGradient lg(p1, p2);
1786 lg.setColorAt(0, left);
1787 lg.setColorAt(1, right);
1790 p->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
1793 if (!dwOpt->title.isEmpty()) {
1794 QFont oldFont = p->font();
1796 QFont font = oldFont;
1800 QPalette palette = dwOpt->palette;
1801 palette.setColor(QPalette::Window, inactiveCaptionTextColor);
1802 QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, opt, widget);
1803 if (verticalTitleBar) {
1804 titleRect = QRect(r.left() + rect.bottom()
1805 - titleRect.bottom(),
1806 r.top() + titleRect.left() - rect.left(),
1807 titleRect.height(), titleRect.width());
1809 proxy()->drawItemText(p, titleRect,
1810 Qt::AlignLeft | Qt::AlignVCenter, palette,
1811 dwOpt->state & State_Enabled, dwOpt->title,
1812 floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText);
1813 p->setFont(oldFont);
1815 if (verticalTitleBar)
1820#if 0
&& QT_CONFIG(combobox)
1821 case CE_ComboBoxLabel:
1822 if (
const QStyleOptionComboBox *cb = qstyleoption_cast<
const QStyleOptionComboBox *>(opt)) {
1823 if (cb->state & State_HasFocus) {
1824 p->setPen(cb->palette.highlightedText().color());
1825 p->setBackground(cb->palette.highlight());
1827 p->setPen(cb->palette.text().color());
1828 p->setBackground(cb->palette.window());
1831 QCommonStyle::drawControl(ce, opt, p, widget);
1835 QCommonStyle::drawControl(ce, opt, p);
1887#if QT_CONFIG(slider)
1889 if (
const QStyleOptionSlider *slider = qstyleoption_cast<
const QStyleOptionSlider *>(opt)) {
1890 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider);
1891 int len = proxy()->pixelMetric(PM_SliderLength, slider);
1892 int ticks = slider->tickPosition;
1893 QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove);
1894 QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle);
1896 if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
1897 int mid = thickness / 2;
1899 if (ticks & QStyleOptionSlider::TicksAbove)
1901 if (ticks & QStyleOptionSlider::TicksBelow)
1904 p->setPen(slider->palette.shadow().color());
1905 if (slider->orientation == Qt::Horizontal) {
1906 qDrawWinPanel(p, groove.x(), groove.y() + mid - 2,
1907 groove.width(), 4, slider->palette,
true);
1908 p->drawLine(groove.x() + 1, groove.y() + mid - 1,
1909 groove.x() + groove.width() - 3, groove.y() + mid - 1);
1911 qDrawWinPanel(p, groove.x() + mid - 2, groove.y(),
1912 4, groove.height(), slider->palette,
true);
1913 p->drawLine(groove.x() + mid - 1, groove.y() + 1,
1914 groove.x() + mid - 1, groove.y() + groove.height() - 3);
1918 if (slider->subControls & SC_SliderTickmarks) {
1919 QStyleOptionSlider tmpSlider = *slider;
1920 tmpSlider.subControls = SC_SliderTickmarks;
1921 QCommonStyle::drawComplexControl(cc, &tmpSlider, p);
1924 if (slider->subControls & SC_SliderHandle) {
1934 const QColor c0 = slider->palette.shadow().color();
1935 const QColor c1 = slider->palette.dark().color();
1937 const QColor c3 = slider->palette.midlight().color();
1938 const QColor c4 = slider->palette.light().color();
1941 if (slider->state & State_Enabled) {
1942 handleBrush = slider->palette.color(QPalette::Button);
1944 handleBrush = QBrush(slider->palette.color(QPalette::Button),
1949 int x = handle.x(), y = handle.y(),
1950 wi = handle.width(), he = handle.height();
1957 Qt::Orientation orient = slider->orientation;
1958 bool tickAbove = slider->tickPosition == QStyleOptionSlider::TicksAbove;
1959 bool tickBelow = slider->tickPosition == QStyleOptionSlider::TicksBelow;
1961 if (slider->state & State_HasFocus) {
1962 QStyleOptionFocusRect fropt;
1963 fropt.QStyleOption::operator=(*slider);
1964 fropt.rect = subElementRect(SE_SliderFocusRect, slider);
1965 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p);
1968 if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
1969 Qt::BGMode oldMode = p->backgroundMode();
1970 p->setBackgroundMode(Qt::OpaqueMode);
1971 qDrawWinButton(p, QRect(x, y, wi, he), slider->palette,
false,
1973 p->setBackgroundMode(oldMode);
1977 QSliderDirection dir;
1979 if (orient == Qt::Horizontal)
1996 d = (wi + 1) / 2 - 1;
1997 a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d);
2001 d = (wi + 1) / 2 - 1;
2002 a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1);
2005 d = (he + 1) / 2 - 1;
2007 a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
2010 d = (he + 1) / 2 - 1;
2012 a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1);
2016 QBrush oldBrush = p->brush();
2017 p->setPen(Qt::NoPen);
2018 p->setBrush(handleBrush);
2019 Qt::BGMode oldMode = p->backgroundMode();
2020 p->setBackgroundMode(Qt::OpaqueMode);
2021 p->drawRect(x1, y1, x2-x1+1, y2-y1+1);
2023 p->setBrush(oldBrush);
2024 p->setBackgroundMode(oldMode);
2028 p->drawLine(x1, y1, x2, y1);
2030 p->drawLine(x1, y1+1, x2, y1+1);
2032 if (dir != SlLeft) {
2034 p->drawLine(x1+1, y1+1, x1+1, y2);
2036 p->drawLine(x1, y1, x1, y2);
2038 if (dir != SlRight) {
2040 p->drawLine(x2, y1, x2, y2);
2042 p->drawLine(x2-1, y1+1, x2-1, y2-1);
2044 if (dir != SlDown) {
2046 p->drawLine(x1, y2, x2, y2);
2048 p->drawLine(x1+1, y2-1, x2-1, y2-1);
2054 p->drawLine(x1, y1, x1+d, y1-d);
2057 p->drawLine(x2, y1, x2-d, y1-d);
2060 p->drawLine(x1+1, y1, x1+1+d, y1-d);
2062 p->drawLine(x2-1, y1, x2-1-d, y1-d);
2066 p->drawLine(x1, y2, x1+d, y2+d);
2069 p->drawLine(x2, y2, x2-d, y2+d);
2072 p->drawLine(x1+1, y2, x1+1+d, y2+d);
2074 p->drawLine(x2-1, y2, x2-1-d, y2+d);
2078 p->drawLine(x1, y1, x1-d, y1+d);
2081 p->drawLine(x1, y2, x1-d, y2-d);
2084 p->drawLine(x1, y1+1, x1-d, y1+1+d);
2086 p->drawLine(x1, y2-1, x1-d, y2-1-d);
2090 p->drawLine(x2, y1, x2+d, y1+d);
2093 p->drawLine(x2, y2, x2+d, y2-d);
2096 p->drawLine(x2, y1+1, x2+d, y1+1+d);
2098 p->drawLine(x2, y2-1, x2+d, y2-1-d);
2105#if QT_CONFIG(scrollbar)
2107 if (
const QStyleOptionSlider *scrollbar = qstyleoption_cast<
const QStyleOptionSlider *>(opt)) {
2108 QStyleOptionSlider newScrollbar = *scrollbar;
2109 if (scrollbar->minimum == scrollbar->maximum)
2110 newScrollbar.state &= ~State_Enabled;
2111 QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
2115#if QT_CONFIG(combobox)
2117 if (
const QStyleOptionComboBox *cmb = qstyleoption_cast<
const QStyleOptionComboBox *>(opt)) {
2118 QBrush editBrush = cmb->palette.brush(QPalette::Button);
2119 if ((cmb->subControls & SC_ComboBoxFrame)) {
2121 QPalette shadePal = opt->palette;
2122 shadePal.setColor(QPalette::Midlight, shadePal.button().color());
2123 qDrawWinPanel(p, opt->rect, shadePal,
true, &editBrush);
2126 p->fillRect(opt->rect, editBrush);
2129 if (cmb->subControls & SC_ComboBoxArrow) {
2130 State flags = State_None;
2132 QRect ar = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
2133 bool sunkenArrow = cmb->activeSubControls == SC_ComboBoxArrow
2134 && cmb->state & State_Sunken;
2136 p->setPen(cmb->palette.dark().color());
2137 p->setBrush(cmb->palette.brush(QPalette::Button));
2138 p->drawRect(ar.adjusted(0,0,-1,-1));
2141 QPalette pal(cmb->palette);
2142 pal.setColor(QPalette::Button, cmb->palette.light().color());
2143 pal.setColor(QPalette::Light, cmb->palette.button().color());
2144 qDrawWinButton(p, ar, pal,
false,
2145 &cmb->palette.brush(QPalette::Button));
2148 ar.adjust(2, 2, -2, -2);
2149 if (opt->state & State_Enabled)
2150 flags |= State_Enabled;
2151 if (opt->state & State_HasFocus)
2152 flags |= State_HasFocus;
2155 flags |= State_Sunken;
2156 QStyleOption arrowOpt = *cmb;
2157 arrowOpt.rect = ar.adjusted(1, 1, -1, -1);
2158 arrowOpt.state = flags;
2159 proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
2162 if (cmb->subControls & SC_ComboBoxEditField) {
2163 QRect re = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
2164 if (cmb->state & State_HasFocus && !cmb->editable)
2165 p->fillRect(re.x(), re.y(), re.width(), re.height(),
2166 cmb->palette.brush(QPalette::Highlight));
2168 if (cmb->state & State_HasFocus) {
2169 p->setPen(cmb->palette.highlightedText().color());
2170 p->setBackground(cmb->palette.highlight());
2173 p->setPen(cmb->palette.text().color());
2174 p->setBackground(cmb->palette.window());
2177 if (cmb->state & State_HasFocus && !cmb->editable) {
2178 QStyleOptionFocusRect focus;
2179 focus.QStyleOption::operator=(*cmb);
2180 focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget);
2181 focus.state |= State_FocusAtBorder;
2182 focus.backgroundColor = cmb->palette.highlight().color();
2183 proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
2189#if QT_CONFIG(spinbox)
2191 if (
const QStyleOptionSpinBox *sb = qstyleoption_cast<
const QStyleOptionSpinBox *>(opt)) {
2192 QStyleOptionSpinBox copy = *sb;
2193 PrimitiveElement pe;
2194 bool enabled = opt->state & State_Enabled;
2195 if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
2196 QBrush editBrush = sb->palette.brush(QPalette::Base);
2197 QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);
2198 QPalette shadePal = sb->palette;
2199 shadePal.setColor(QPalette::Midlight, shadePal.button().color());
2200 qDrawWinPanel(p, r, shadePal,
true, &editBrush);
2203 QPalette shadePal(opt->palette);
2204 shadePal.setColor(QPalette::Button, opt->palette.light().color());
2205 shadePal.setColor(QPalette::Light, opt->palette.button().color());
2207 if (sb->subControls & SC_SpinBoxUp) {
2208 copy.subControls = SC_SpinBoxUp;
2209 QPalette pal2 = sb->palette;
2210 if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
2211 pal2.setCurrentColorGroup(QPalette::Disabled);
2212 copy.state &= ~State_Enabled;
2215 copy.palette = pal2;
2217 if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
2218 copy.state |= State_On;
2219 copy.state |= State_Sunken;
2221 copy.state |= State_Raised;
2222 copy.state &= ~State_Sunken;
2224 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
2225 : PE_IndicatorSpinUp);
2227 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);
2228 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
2229 ©.palette.brush(QPalette::Button));
2230 copy.rect.adjust(4, 1, -5, -1);
2231 if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled))
2232 && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
2234 QStyleOptionSpinBox lightCopy = copy;
2235 lightCopy.rect.adjust(1, 1, 1, 1);
2236 lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
2237 proxy()->drawPrimitive(pe, &lightCopy, p, widget);
2239 proxy()->drawPrimitive(pe, ©, p, widget);
2242 if (sb->subControls & SC_SpinBoxDown) {
2243 copy.subControls = SC_SpinBoxDown;
2244 copy.state = sb->state;
2245 QPalette pal2 = sb->palette;
2246 if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
2247 pal2.setCurrentColorGroup(QPalette::Disabled);
2248 copy.state &= ~State_Enabled;
2250 copy.palette = pal2;
2252 if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
2253 copy.state |= State_On;
2254 copy.state |= State_Sunken;
2256 copy.state |= State_Raised;
2257 copy.state &= ~State_Sunken;
2259 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
2260 : PE_IndicatorSpinDown);
2262 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
2263 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
2264 ©.palette.brush(QPalette::Button));
2265 copy.rect.adjust(4, 0, -5, -1);
2266 if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled))
2267 && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
2269 QStyleOptionSpinBox lightCopy = copy;
2270 lightCopy.rect.adjust(1, 1, 1, 1);
2271 lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
2272 proxy()->drawPrimitive(pe, &lightCopy, p, widget);
2274 proxy()->drawPrimitive(pe, ©, p, widget);
2280 QCommonStyle::drawComplexControl(cc, opt, p);
2283 QCommonStyle::drawComplexControl(cc, opt, p);