557void QWindowsStyle::drawPrimitive(PrimitiveElement pe,
const QStyleOption *opt, QPainter *p)
const
560 bool doRestore =
false;
563#if 0
&& QT_CONFIG(toolbar)
564 case PE_IndicatorToolBarSeparator:
566 QRect rect = opt->rect;
567 const int margin = 2;
568 QPen oldPen = p->pen();
569 if (opt->state & State_Horizontal){
570 const int offset = rect.width()/2;
571 p->setPen(QPen(opt->palette.dark().color()));
572 p->drawLine(rect.bottomLeft().x() + offset,
573 rect.bottomLeft().y() - margin,
574 rect.topLeft().x() + offset,
575 rect.topLeft().y() + margin);
576 p->setPen(QPen(opt->palette.light().color()));
577 p->drawLine(rect.bottomLeft().x() + offset + 1,
578 rect.bottomLeft().y() - margin,
579 rect.topLeft().x() + offset + 1,
580 rect.topLeft().y() + margin);
583 const int offset = rect.height()/2;
584 p->setPen(QPen(opt->palette.dark().color()));
585 p->drawLine(rect.topLeft().x() + margin ,
586 rect.topLeft().y() + offset,
587 rect.topRight().x() - margin,
588 rect.topRight().y() + offset);
589 p->setPen(QPen(opt->palette.light().color()));
590 p->drawLine(rect.topLeft().x() + margin ,
591 rect.topLeft().y() + offset + 1,
592 rect.topRight().x() - margin,
593 rect.topRight().y() + offset + 1);
598 case PE_IndicatorToolBarHandle:
600 p->translate(opt->rect.x(), opt->rect.y());
601 if (opt->state & State_Horizontal) {
602 int x = opt->rect.width() / 2 - 4;
603 if (opt->direction == Qt::RightToLeft)
605 if (opt->rect.height() > 4) {
606 qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
607 opt->palette,
false, 1,
nullptr);
608 qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4,
609 opt->palette,
false, 1,
nullptr);
612 if (opt->rect.width() > 4) {
613 int y = opt->rect.height() / 2 - 4;
614 qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
615 opt->palette,
false, 1,
nullptr);
616 qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3,
617 opt->palette,
false, 1,
nullptr);
624 case PE_FrameButtonTool:
625 case PE_PanelButtonTool: {
626 QPen oldPen = p->pen();
627#if 0
&& QT_CONFIG(dockwidget)
628 if (w && w->inherits(
"QDockWidgetTitleButton")) {
629 if (
const QWidget *dw = w->parentWidget())
631 qDrawWinButton(p, opt->rect.adjusted(1, 1, 0, 0), opt->palette, opt->state & (State_Sunken | State_On),
632 &opt->palette.button());
640 bool panel = (pe == PE_PanelButtonTool);
641 if ((!(opt->state & State_Sunken ))
642 && (!(opt->state & State_Enabled)
643 || !(opt->state & State_MouseOver && opt->state & State_AutoRaise))
644 && (opt->state & State_On)) {
645 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
648 fill = opt->palette.brush(QPalette::Button);
652 if (opt->state & (State_Raised | State_Sunken | State_On)) {
653 if (opt->state & State_AutoRaise) {
654 if (opt->state & (State_Enabled | State_Sunken | State_On)){
656 qDrawShadePanel(p, opt->rect, opt->palette,
657 opt->state & (State_Sunken | State_On), 1, &fill);
659 qDrawShadeRect(p, opt->rect, opt->palette,
660 opt->state & (State_Sunken | State_On), 1);
663 p->setPen(opt->palette.button().color());
664 p->drawRect(opt->rect.adjusted(1,1,-2,-2));
667 qDrawWinButton(p, opt->rect, opt->palette,
668 opt->state & (State_Sunken | State_On), panel ? &fill :
nullptr);
671 p->fillRect(opt->rect, fill);
675 case PE_PanelButtonCommand:
676 if (
const QStyleOptionButton *btn = qstyleoption_cast<
const QStyleOptionButton *>(opt)) {
678 State flags = opt->state;
679 QPalette pal = opt->palette;
681 if (! (flags & State_Sunken) && (flags & State_On))
682 fill = QBrush(pal.light().color(), Qt::Dense4Pattern);
684 fill = pal.brush(QPalette::Button);
686 if (btn->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
687 p->setPen(pal.dark().color());
689 p->drawRect(r.adjusted(0, 0, -1, -1));
690 }
else if (flags & (State_Raised | State_On | State_Sunken)) {
691 qDrawWinButton(p, r, pal, flags & (State_Sunken | State_On),
694 p->fillRect(r, fill);
698 case PE_FrameDefaultButton: {
699 QPen oldPen = p->pen();
700 p->setPen(QPen(opt->palette.shadow().color(), 0));
701 QRectF rect = opt->rect;
702 const qreal dpi = QStyleHelper::dpi(opt);
703 const qreal topLevelAdjustment = QStyleHelper::dpiScaled(0.5, dpi);
704 const qreal bottomRightAdjustment = QStyleHelper::dpiScaled(-1.5, dpi);
705 rect.adjust(topLevelAdjustment, topLevelAdjustment,
706 bottomRightAdjustment, bottomRightAdjustment);
711 case PE_IndicatorCheckBox: {
713 if (opt->state & State_NoChange)
714 fill = QBrush(opt->palette.base().color(), Qt::Dense4Pattern);
715 else if (opt->state & State_Sunken)
716 fill = opt->palette.button();
717 else if (opt->state & State_Enabled)
718 fill = opt->palette.base();
720 fill = opt->palette.window();
723 qDrawWinPanel(p, opt->rect, opt->palette,
true, &fill);
724 if (opt->state & State_NoChange)
725 p->setPen(opt->palette.dark().color());
727 p->setPen(opt->palette.text().color());
730 case PE_IndicatorItemViewItemCheck:
735#if 0
&& QT_CONFIG(itemviews)
736 if (pe == PE_IndicatorItemViewItemCheck) {
737 const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<
const QStyleOptionViewItem *>(opt);
738 p->setPen(itemViewOpt
739 && itemViewOpt->showDecorationSelected
740 && opt->state & State_Selected
741 ? opt->palette.highlightedText().color()
742 : opt->palette.text().color());
743 if (opt->state & State_NoChange)
744 p->setBrush(opt->palette.brush(QPalette::Button));
745 p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, opt->rect.width() - 2, opt->rect.height() - 2);
748 if (!(opt->state & State_Off)) {
750 qreal scaleh = opt->rect.width() / 12.0;
751 qreal scalev = opt->rect.height() / 12.0;
752 points[0] = { opt->rect.x() + 3.5 * scaleh, opt->rect.y() + 5.5 * scalev };
753 points[1] = { points[0].x(), points[0].y() + 2 * scalev };
754 points[2] = { points[1].x() + 2 * scaleh, points[1].y() + 2 * scalev };
755 points[3] = { points[2].x() + 4 * scaleh, points[2].y() - 4 * scalev };
756 points[4] = { points[3].x(), points[3].y() - 2 * scalev };
757 points[5] = { points[4].x() - 4 * scaleh, points[4].y() + 4 * scalev };
758 p->setPen(QPen(opt->palette.text().color(), 0));
759 p->setBrush(opt->palette.text());
760 p->drawPolygon(points, 6);
765 case PE_FrameFocusRect:
768 if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt))
772 p->setBackgroundMode(Qt::TransparentMode);
773 QColor bg_col = fropt->backgroundColor;
774 if (!bg_col.isValid())
775 bg_col = p->background().color();
776 bg_col = bg_col.toRgb();
778 QColor patternCol((bg_col.red() ^ 0xff) & 0xff,
779 (bg_col.green() ^ 0xff) & 0xff,
780 (bg_col.blue() ^ 0xff) & 0xff);
781 p->setBrush(QBrush(patternCol, Qt::Dense4Pattern));
782 p->setBrushOrigin(r.topLeft());
783 p->setPen(Qt::NoPen);
784 p->drawRect(r.left(), r.top(), r.width(), 1);
785 p->drawRect(r.left(), r.bottom(), r.width(), 1);
786 p->drawRect(r.left(), r.top(), 1, r.height());
787 p->drawRect(r.right(), r.top(), 1, r.height());
791 case PE_IndicatorRadioButton:
795 p->setRenderHint(QPainter::Antialiasing,
true);
797 QPointF circleCenter = r.center() + QPoint(1, 1);
798 qreal radius = (r.width() + (r.width() + 1) % 2) / 2.0 - 1;
801 path1.addEllipse(circleCenter, radius, radius);
804 path2.addEllipse(circleCenter, radius, radius);
807 path3.addEllipse(circleCenter, radius, radius);
810 path4.addEllipse(circleCenter, radius, radius);
812 QPolygon topLeftPol, bottomRightPol;
813 topLeftPol.setPoints(3, r.x(), r.y(), r.x(), r.y() + r.height(), r.x() + r.width(), r.y());
814 bottomRightPol.setPoints(3, r.x(), r.y() + r.height(), r.x() + r.width(), r.y() + r.height(), r.x() + r.width(), r.y());
816 p->setClipRegion(QRegion(topLeftPol));
817 p->setPen(opt->palette.dark().color());
818 p->setBrush(opt->palette.dark());
820 p->setPen(opt->palette.shadow().color());
821 p->setBrush(opt->palette.shadow());
824 p->setClipRegion(QRegion(bottomRightPol));
825 p->setPen(opt->palette.light().color());
826 p->setBrush(opt->palette.light());
828 p->setPen(opt->palette.midlight().color());
829 p->setBrush(opt->palette.midlight());
832 const QBrush fill = ((opt->state & State_Sunken) || !(opt->state & State_Enabled))
833 ? opt->palette.button() : opt->palette.base();
835 p->setClipping(
false);
836 p->setPen(fill.color());
840 if (opt->state & State_On) {
841 p->setPen(opt->palette.text().color());
842 p->setBrush(opt->palette.text());
851 if (
const QStyleOptionFrame *frame = qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
852 if (frame->lineWidth == 2 || pe == PE_Frame) {
853 QPalette popupPal = frame->palette;
854 if (pe == PE_FrameMenu) {
855 popupPal.setBrush(QPalette::Light, frame->palette.window());
856 popupPal.setBrush(QPalette::Midlight, frame->palette.light());
858 if (pe == PE_Frame && (frame->state & State_Raised))
859 qDrawWinButton(p, frame->rect, popupPal, frame->state & State_Sunken);
860 else if (pe == PE_Frame && (frame->state & State_Sunken))
862 popupPal.setBrush(QPalette::Midlight, frame->palette.window());
863 qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
866 qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
868 QCommonStyle::drawPrimitive(pe, opt, p);
871 QPalette popupPal = opt->palette;
872 popupPal.setBrush(QPalette::Light, opt->palette.window());
873 popupPal.setBrush(QPalette::Midlight, opt->palette.light());
874 qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
878 case PE_FrameButtonBevel:
879 case PE_PanelButtonBevel: {
881 bool panel = pe != PE_FrameButtonBevel;
882 p->setBrushOrigin(opt->rect.topLeft());
883 if (!(opt->state & State_Sunken) && (opt->state & State_On))
884 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
886 fill = opt->palette.brush(QPalette::Button);
888 if (opt->state & (State_Raised | State_On | State_Sunken)) {
889 qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On),
890 panel ? &fill :
nullptr);
893 p->fillRect(opt->rect, fill);
895 p->drawRect(opt->rect);
898 case PE_FrameWindow: {
899 QPalette popupPal = opt->palette;
900 popupPal.setBrush(QPalette::Light, opt->palette.window());
901 popupPal.setBrush(QPalette::Midlight, opt->palette.light());
902 qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
904#if 0
&& QT_CONFIG(dockwidget)
905 case PE_IndicatorDockWidgetResizeHandle:
907 case PE_FrameDockWidget:
908 if (qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
909 proxy()->drawPrimitive(QStyle::PE_FrameWindow, opt, p, w);
914 case PE_FrameStatusBarItem:
915 qDrawShadePanel(p, opt->rect, opt->palette,
true, 1,
nullptr);
918 case PE_IndicatorProgressChunk:
920 bool vertical =
false, inverted =
false;
922 vertical = !(pb->state & QStyle::State_Horizontal);
923 inverted = pb->invertedAppearance;
927 int chunksize = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt) - space;
929 if (opt->rect.width() <= chunksize)
933 p->fillRect(opt->rect.x() + space, opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
934 opt->palette.brush(QPalette::Highlight));
936 p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
937 opt->palette.brush(QPalette::Highlight));
939 if (opt->rect.height() <= chunksize)
943 p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height() - space,
944 opt->palette.brush(QPalette::Highlight));
946 p->fillRect(opt->rect.x(), opt->rect.y() + space, opt->rect.width(), opt->rect.height() - space,
947 opt->palette.brush(QPalette::Highlight));
952 case PE_FrameTabWidget: {
953 qDrawWinButton(p, opt->rect, opt->palette,
false,
nullptr);
957 QCommonStyle::drawPrimitive(pe, opt, p);
962void QWindowsStyle::drawControl(ControlElement ce,
const QStyleOption *opt, QPainter *p)
const
965#if 0
&& QT_CONFIG(rubberband)
967 if (qstyleoption_cast<
const QStyleOptionRubberBand *>(opt)) {
969 QPixmap tiledPixmap(16, 16);
970 QPainter pixmapPainter(&tiledPixmap);
971 pixmapPainter.setPen(Qt::NoPen);
972 pixmapPainter.setBrush(Qt::Dense4Pattern);
973 pixmapPainter.setBackground(Qt::white);
974 pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
975 pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
977 tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
980 QStyleHintReturnMask mask;
981 if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
982 p->setClipRegion(mask.region);
983 p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
990#if 0
&& QT_CONFIG(menu) && QT_CONFIG(mainwindow)
991 case CE_MenuBarEmptyArea:
992 if (widget && qobject_cast<
const QMainWindow *>(widget->parentWidget())) {
993 p->fillRect(opt->rect, opt->palette.button());
994 QPen oldPen = p->pen();
995 p->setPen(QPen(opt->palette.dark().color()));
996 p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight());
1001#if 0
&& QT_CONFIG(menu)
1003 if (
const QStyleOptionMenuItem *menuitem = qstyleoption_cast<
const QStyleOptionMenuItem *>(opt)) {
1005 menuitem->rect.getRect(&x, &y, &w, &h);
1006 int tab = menuitem->tabWidth;
1007 bool dis = !(menuitem->state & State_Enabled);
1008 bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
1009 ? menuitem->checked :
false;
1010 bool act = menuitem->state & State_Selected;
1013 int checkcol = qMax<
int>(menuitem->maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
1015 QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
1016 p->fillRect(menuitem->rect.adjusted(0, 0, -1, 0), fill);
1018 if (menuitem->menuItemType == QStyleOptionMenuItem::Separator){
1019 int yoff = y-1 + h / 2;
1020 p->setPen(menuitem->palette.dark().color());
1021 p->drawLine(x + 2, yoff, x + w - 4, yoff);
1022 p->setPen(menuitem->palette.light().color());
1023 p->drawLine(x + 2, yoff + 1, x + w - 4, yoff + 1);
1027 QRect vCheckRect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x(), menuitem->rect.y(), checkcol, menuitem->rect.height()));
1028 if (!menuitem->icon.isNull() && checked) {
1030 qDrawShadePanel(p, vCheckRect,
1031 menuitem->palette,
true, 1,
1032 &menuitem->palette.brush(QPalette::Button));
1034 QBrush fill(menuitem->palette.light().color(), Qt::Dense4Pattern);
1035 qDrawShadePanel(p, vCheckRect, menuitem->palette,
true, 1, &fill);
1038 p->fillRect(vCheckRect, menuitem->palette.brush(QPalette::Button));
1044 if (!menuitem->icon.isNull()) {
1045 QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
1047 mode = QIcon::Active;
1050 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
1052 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
1053 const int pixw = pixmap.width() / pixmap.devicePixelRatio();
1054 const int pixh = pixmap.height() / pixmap.devicePixelRatio();
1055 QRect pmr(0, 0, pixw, pixh);
1056 pmr.moveCenter(vCheckRect.center());
1057 p->setPen(menuitem->palette.text().color());
1058 p->drawPixmap(pmr.topLeft(), pixmap);
1059 }
else if (checked) {
1060 QStyleOptionMenuItem newMi = *menuitem;
1061 newMi.state = State_None;
1063 newMi.state |= State_Enabled;
1065 newMi.state |= State_On;
1066 newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + QWindowsStylePrivate::windowsItemFrame,
1067 menuitem->rect.y() + QWindowsStylePrivate::windowsItemFrame,
1068 checkcol - 2 * QWindowsStylePrivate::windowsItemFrame,
1069 menuitem->rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
1070 proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
1072 p->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color());
1076 discol = menuitem->palette.text().color();
1080 int xm =
int(QWindowsStylePrivate::windowsItemFrame) + checkcol +
int(QWindowsStylePrivate::windowsItemHMargin);
1081 int xpos = menuitem->rect.x() + xm;
1082 QRect textRect(xpos, y + QWindowsStylePrivate::windowsItemVMargin,
1083 w - xm - QWindowsStylePrivate::windowsRightBorder - tab + 1, h - 2 * QWindowsStylePrivate::windowsItemVMargin);
1084 QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
1085 QStringRef s(&menuitem->text);
1088 int t = s.indexOf(QLatin1Char(
'\t'));
1089 int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
1090 if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
1091 text_flags |= Qt::TextHideMnemonic;
1092 text_flags |= Qt::AlignLeft;
1094 QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
1095 QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
1096 const QString textToDraw = s.mid(t + 1).toString();
1097 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1098 p->setPen(menuitem->palette.light().color());
1099 p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, textToDraw);
1102 p->drawText(vShortcutRect, text_flags, textToDraw);
1105 QFont font = menuitem->font;
1106 if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
1109 const QString textToDraw = s.left(t).toString();
1110 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1111 p->setPen(menuitem->palette.light().color());
1112 p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, textToDraw);
1115 p->drawText(vTextRect, text_flags, textToDraw);
1118 if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {
1119 int dim = (h - 2 * QWindowsStylePrivate::windowsItemFrame) / 2;
1120 PrimitiveElement arrow;
1121 arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
1122 xpos = x + w - QWindowsStylePrivate::windowsArrowHMargin - QWindowsStylePrivate::windowsItemFrame - dim;
1123 QRect vSubMenuRect = visualRect(opt->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
1124 QStyleOptionMenuItem newMI = *menuitem;
1125 newMI.rect = vSubMenuRect;
1126 newMI.state = dis ? State_None : State_Enabled;
1128 newMI.palette.setColor(QPalette::ButtonText,
1129 newMI.palette.highlightedText().color());
1130 proxy()->drawPrimitive(arrow, &newMI, p, widget);
1136#if 0
&& QT_CONFIG(menubar)
1137 case CE_MenuBarItem:
1138 if (
const QStyleOptionMenuItem *mbi = qstyleoption_cast<
const QStyleOptionMenuItem *>(opt)) {
1139 bool active = mbi->state & State_Selected;
1140 bool hasFocus = mbi->state & State_HasFocus;
1141 bool down = mbi->state & State_Sunken;
1142 QStyleOptionMenuItem newMbi = *mbi;
1143 p->fillRect(mbi->rect, mbi->palette.brush(QPalette::Button));
1144 if (active || hasFocus) {
1145 QBrush b = mbi->palette.brush(QPalette::Button);
1147 p->setBrushOrigin(p->brushOrigin() + QPoint(1, 1));
1148 if (active && hasFocus)
1149 qDrawShadeRect(p, mbi->rect.x(), mbi->rect.y(), mbi->rect.width(),
1150 mbi->rect.height(), mbi->palette, active && down, 1, 0, &b);
1151 if (active && down) {
1152 newMbi.rect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, mbi, widget),
1153 proxy()->pixelMetric(PM_ButtonShiftVertical, mbi, widget));
1154 p->setBrushOrigin(p->brushOrigin() - QPoint(1, 1));
1157 QCommonStyle::drawControl(ce, &newMbi, p, widget);
1161#if 0
&& QT_CONFIG(tabbar)
1162 case CE_TabBarTabShape:
1163 if (
const QStyleOptionTab *tab = qstyleoption_cast<
const QStyleOptionTab *>(opt)) {
1164 bool rtlHorTabs = (tab->direction == Qt::RightToLeft
1165 && (tab->shape == QTabBar::RoundedNorth
1166 || tab->shape == QTabBar::RoundedSouth));
1167 bool selected = tab->state & State_Selected;
1168 bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
1170 && tab->position == QStyleOptionTab::Beginning));
1171 bool firstTab = ((!rtlHorTabs
1172 && tab->position == QStyleOptionTab::Beginning)
1174 && tab->position == QStyleOptionTab::End));
1175 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
1176 bool previousSelected =
1178 && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
1180 && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
1183 && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
1185 && tab->selectedPosition
1186 == QStyleOptionTab::PreviousIsSelected));
1187 int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
1188 bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
1190 && tabBarAlignment == Qt::AlignRight);
1192 bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
1194 && tabBarAlignment == Qt::AlignLeft);
1196 QColor light = tab->palette.light().color();
1197 QColor dark = tab->palette.dark().color();
1198 QColor shadow = tab->palette.shadow().color();
1199 int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
1201 borderThinkness /= 2;
1202 QRect r2(opt->rect);
1204 int x2 = r2.right();
1206 int y2 = r2.bottom();
1207 switch (tab->shape) {
1209 QCommonStyle::drawControl(ce, tab, p, widget);
1211 case QTabBar::RoundedNorth: {
1214 x1 += onlyOne || firstTab ? borderThinkness : 0;
1215 x2 -= onlyOne || lastTab ? borderThinkness : 0;
1218 p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 2), tab->palette.window());
1222 p->fillRect(QRect(x1,y2-1,x2-x1,1), tab->palette.window());
1223 p->fillRect(QRect(x1,y2,x2-x1,1), tab->palette.window());
1226 if (firstTab || selected || onlyOne || !previousSelected) {
1228 p->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
1229 p->drawPoint(x1 + 1, y1 + 1);
1233 int beg = x1 + (previousSelected ? 0 : 2);
1234 int end = x2 - (nextSelected ? 0 : 2);
1236 p->drawLine(beg, y1, end, y1);
1239 if (lastTab || selected || onlyOne || !nextSelected) {
1241 p->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1242 p->drawPoint(x2 - 1, y1 + 1);
1244 p->drawLine(x2 - 1, y1 + 2, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1247 case QTabBar::RoundedSouth: {
1250 x1 += firstTab ? borderThinkness : 0;
1251 x2 -= lastTab ? borderThinkness : 0;
1254 p->fillRect(QRect(x1 + 1, y1 + 2, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.window());
1258 p->fillRect(QRect(x1, y1 + 1, (x2 - 1)-x1, 1), tab->palette.window());
1259 p->fillRect(QRect(x1, y1, (x2 - 1)-x1, 1), tab->palette.window());
1262 if (firstTab || selected || onlyOne || !previousSelected) {
1264 p->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
1265 p->drawPoint(x1 + 1, y2 - 1);
1269 int beg = x1 + (previousSelected ? 0 : 2);
1270 int end = x2 - (nextSelected ? 0 : 2);
1272 p->drawLine(beg, y2, end, y2);
1274 p->drawLine(beg, y2 - 1, end, y2 - 1);
1277 if (lastTab || selected || onlyOne || !nextSelected) {
1279 p->drawLine(x2, y2 - 2, x2, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1280 p->drawPoint(x2 - 1, y2 - 1);
1282 p->drawLine(x2 - 1, y2 - 2, x2 - 1, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1285 case QTabBar::RoundedWest: {
1288 y1 += firstTab ? borderThinkness : 0;
1289 y2 -= lastTab ? borderThinkness : 0;
1292 p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 2, (y2 - y1) - 1), tab->palette.window());
1296 p->fillRect(QRect(x2 - 1, y1, 1, y2-y1), tab->palette.window());
1297 p->fillRect(QRect(x2, y1, 1, y2-y1), tab->palette.window());
1300 if (firstTab || selected || onlyOne || !previousSelected) {
1302 p->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
1303 p->drawPoint(x1 + 1, y1 + 1);
1307 int beg = y1 + (previousSelected ? 0 : 2);
1308 int end = y2 - (nextSelected ? 0 : 2);
1310 p->drawLine(x1, beg, x1, end);
1313 if (lastTab || selected || onlyOne || !nextSelected) {
1315 p->drawLine(x1 + 3, y2, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
1316 p->drawPoint(x1 + 2, y2 - 1);
1318 p->drawLine(x1 + 3, y2 - 1, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
1319 p->drawPoint(x1 + 1, y2 - 1);
1320 p->drawPoint(x1 + 2, y2);
1323 case QTabBar::RoundedEast: {
1326 y1 += firstTab ? borderThinkness : 0;
1327 y2 -= lastTab ? borderThinkness : 0;
1330 p->fillRect(QRect(x1 + 2, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.window());
1334 p->fillRect(QRect(x1 + 1, y1, 1, (y2 - 1)-y1),tab->palette.window());
1335 p->fillRect(QRect(x1, y1, 1, (y2-1)-y1), tab->palette.window());
1338 if (firstTab || selected || onlyOne || !previousSelected) {
1340 p->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
1341 p->drawPoint(x2 - 1, y1 + 1);
1345 int beg = y1 + (previousSelected ? 0 : 2);
1346 int end = y2 - (nextSelected ? 0 : 2);
1348 p->drawLine(x2, beg, x2, end);
1350 p->drawLine(x2 - 1, beg, x2 - 1, end);
1353 if (lastTab || selected || onlyOne || !nextSelected) {
1355 p->drawLine(x2 - 2, y2, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
1356 p->drawPoint(x2 - 1, y2 - 1);
1358 p->drawLine(x2 - 2, y2 - 1, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
1365 case CE_ToolBoxTabShape:
1366 qDrawShadePanel(p, opt->rect, opt->palette,
1367 opt->state & (State_Sunken | State_On), 1,
1368 &opt->palette.brush(QPalette::Button));
1370#if 0
&& QT_CONFIG(splitter)
1372 p->eraseRect(opt->rect);
1375#if 0
&& QT_CONFIG(scrollbar)
1376 case CE_ScrollBarSubLine:
1377 case CE_ScrollBarAddLine: {
1378 if ((opt->state & State_Sunken)) {
1379 p->setPen(opt->palette.dark().color());
1380 p->setBrush(opt->palette.brush(QPalette::Button));
1381 p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
1383 QStyleOption buttonOpt = *opt;
1384 if (!(buttonOpt.state & State_Sunken))
1385 buttonOpt.state |= State_Raised;
1386 QPalette pal(opt->palette);
1387 pal.setBrush(QPalette::Button, opt->palette.light());
1388 pal.setColor(QPalette::Light, opt->palette.button().color());
1389 qDrawWinButton(p, opt->rect, pal, opt->state & (State_Sunken | State_On),
1390 &opt->palette.brush(QPalette::Button));
1392 PrimitiveElement arrow;
1393 if (opt->state & State_Horizontal) {
1394 if (ce == CE_ScrollBarAddLine)
1395 arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft;
1397 arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
1399 if (ce == CE_ScrollBarAddLine)
1400 arrow = PE_IndicatorArrowDown;
1402 arrow = PE_IndicatorArrowUp;
1404 QStyleOption arrowOpt = *opt;
1405 arrowOpt.rect = opt->rect.adjusted(4, 4, -4, -4);
1406 proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
1408 case CE_ScrollBarAddPage:
1409 case CE_ScrollBarSubPage: {
1411 QBrush bg = p->background();
1412 Qt::BGMode bg_mode = p->backgroundMode();
1413 p->setPen(Qt::NoPen);
1414 p->setBackgroundMode(Qt::OpaqueMode);
1416 if (opt->state & State_Sunken) {
1417 br = QBrush(opt->palette.shadow().color(), Qt::Dense4Pattern);
1418 p->setBackground(opt->palette.dark().color());
1421 const QBrush paletteBrush = opt->palette.brush(QPalette::Light);
1422 if (paletteBrush.style() == Qt::TexturePattern) {
1423 if (qHasPixmapTexture(paletteBrush))
1424 br = QBrush(paletteBrush.texture());
1426 br = QBrush(paletteBrush.textureImage());
1428 br = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1429 p->setBackground(opt->palette.window().color());
1432 p->drawRect(opt->rect);
1433 p->setBackground(bg);
1434 p->setBackgroundMode(bg_mode);
1436 case CE_ScrollBarSlider:
1437 if (!(opt->state & State_Enabled)) {
1439 const QBrush paletteBrush = opt->palette.brush(QPalette::Light);
1440 if (paletteBrush.style() == Qt::TexturePattern) {
1441 if (qHasPixmapTexture(paletteBrush))
1442 br = QBrush(paletteBrush.texture());
1444 br = QBrush(paletteBrush.textureImage());
1446 br = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1447 p->setPen(Qt::NoPen);
1449 p->setBackgroundMode(Qt::OpaqueMode);
1450 p->drawRect(opt->rect);
1452 QStyleOptionButton buttonOpt;
1453 buttonOpt.QStyleOption::operator=(*opt);
1454 buttonOpt.state = State_Enabled | State_Raised;
1456 QPalette pal(opt->palette);
1457 pal.setColor(QPalette::Button, opt->palette.light().color());
1458 pal.setColor(QPalette::Light, opt->palette.button().color());
1459 qDrawWinButton(p, opt->rect, pal,
false, &opt->palette.brush(QPalette::Button));
1463 case CE_HeaderSection: {
1465 if (opt->state & State_On)
1466 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1468 fill = opt->palette.brush(QPalette::Button);
1470 if (opt->state & (State_Raised | State_Sunken)) {
1471 qDrawWinButton(p, opt->rect, opt->palette, opt->state & State_Sunken, &fill);
1473 p->fillRect(opt->rect, fill);
1476#if 0
&& QT_CONFIG(toolbar)
1478 if (
const QStyleOptionToolBar *toolbar = qstyleoption_cast<
const QStyleOptionToolBar *>(opt)) {
1480 if (!(widget && qobject_cast<
const QMainWindow*> (widget->parentWidget())))
1483 QRect rect = opt->rect;
1484 bool paintLeftBorder =
true;
1485 bool paintRightBorder =
true;
1486 bool paintBottomBorder =
true;
1488 switch (toolbar->toolBarArea){
1489 case Qt::BottomToolBarArea :
1490 switch (toolbar->positionOfLine){
1491 case QStyleOptionToolBar::Beginning:
1492 case QStyleOptionToolBar::OnlyOne:
1493 paintBottomBorder =
false;
1499 case Qt::TopToolBarArea :
1500 switch (toolbar->positionWithinLine){
1501 case QStyleOptionToolBar::Beginning:
1502 paintLeftBorder =
false;
1504 case QStyleOptionToolBar::End:
1505 paintRightBorder =
false;
1507 case QStyleOptionToolBar::OnlyOne:
1508 paintRightBorder =
false;
1509 paintLeftBorder =
false;
1514 if (opt->direction == Qt::RightToLeft){
1515 bool tmp = paintLeftBorder;
1516 paintRightBorder=paintLeftBorder;
1517 paintLeftBorder=tmp;
1520 case Qt::RightToolBarArea :
1521 switch (toolbar->positionOfLine){
1522 case QStyleOptionToolBar::Beginning:
1523 case QStyleOptionToolBar::OnlyOne:
1524 paintRightBorder =
false;
1530 case Qt::LeftToolBarArea :
1531 switch (toolbar->positionOfLine){
1532 case QStyleOptionToolBar::Beginning:
1533 case QStyleOptionToolBar::OnlyOne:
1534 paintLeftBorder =
false;
1546 p->setPen(QPen(opt->palette.light().color()));
1547 p->drawLine(rect.topLeft().x(),
1549 rect.topRight().x(),
1550 rect.topRight().y());
1552 if (paintLeftBorder){
1553 p->setPen(QPen(opt->palette.light().color()));
1554 p->drawLine(rect.topLeft().x(),
1556 rect.bottomLeft().x(),
1557 rect.bottomLeft().y());
1560 if (paintRightBorder){
1561 p->setPen(QPen(opt->palette.dark().color()));
1562 p->drawLine(rect.topRight().x(),
1563 rect.topRight().y(),
1564 rect.bottomRight().x(),
1565 rect.bottomRight().y());
1568 if (paintBottomBorder){
1569 p->setPen(QPen(opt->palette.dark().color()));
1570 p->drawLine(rect.bottomLeft().x(),
1571 rect.bottomLeft().y(),
1572 rect.bottomRight().x(),
1573 rect.bottomRight().y());
1581 case CE_ProgressBarContents:
1583 QRect rect = pb->rect;
1584 if (!rect.isValid())
1588 const bool inverted = pb->invertedAppearance;
1592 rect = QRect(rect.y(), rect.x(), rect.height(), rect.width());
1594 m.translate(0, -(rect.height() + rect.y()*2));
1596 QPalette pal2 = pb->palette;
1598 if (pal2.highlight() == pal2.window())
1599 pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
1600 QPalette::Highlight));
1601 bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
1604 int w = rect.width();
1605 Q_D(
const QWindowsStyle);
1606 if (pb->minimum == 0 && pb->maximum == 0) {
1607 const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb);
1609 Q_ASSERT(unit_width >0);
1612 pbBits.palette = pal2;
1615 int chunkCount = w / unit_width + 1;
1616#if 0
&& QT_CONFIG(animation)
1617 if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject)))
1618 step = (animation->animationStep() / 3) % chunkCount;
1620 d->startAnimation(
new QProgressStyleAnimation(d->animationFps, opt->styleObject));
1624 int chunksInRow = 5;
1625 int myY = pbBits.rect.y();
1626 int myHeight = pbBits.rect.height();
1627 int chunksToDraw = chunksInRow;
1629 if (step > chunkCount - 5)chunksToDraw = (chunkCount - step);
1631 p->setClipRect(m.mapRect(QRectF(rect)).toRect());
1633 int x0 = reverse ? rect.left() + rect.width() - unit_width*(step) - unit_width : rect.left() + unit_width * step;
1636 for (
int i = 0; i < chunksToDraw ; ++i) {
1637 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
1638 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1639 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p);
1640 x += reverse ? -unit_width : unit_width;
1643 if ( step > chunkCount-5){
1644 x0 = reverse ? rect.left() + rect.width() - unit_width : rect.left() ;
1646 int chunksToDraw = step - (chunkCount - chunksInRow);
1647 for (
int i = 0; i < chunksToDraw ; ++i) {
1648 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
1649 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1650 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p);
1651 x += reverse ? -unit_width : unit_width;
1657#if 0
&& QT_CONFIG(animation)
1658 d->stopAnimation(opt->styleObject);
1660 QCommonStyle::drawControl(ce, opt, p);
1665#if 0
&& QT_CONFIG(dockwidget)
1666 case CE_DockWidgetTitle:
1668 if (
const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<
const QStyleOptionDockWidget *>(opt)) {
1669 Q_D(
const QWindowsStyle);
1671 const bool verticalTitleBar = dwOpt->verticalTitleBar;
1673 QRect rect = dwOpt->rect;
1676 if (verticalTitleBar) {
1680 p->translate(r.left(), r.top() + r.width());
1682 p->translate(-r.left(), -r.top());
1685 bool floating =
false;
1686 bool active = dwOpt->state & State_Active;
1687 QColor inactiveCaptionTextColor = d->inactiveCaptionText;
1688 if (dwOpt->movable) {
1692 if (opt->state & QStyle::State_Window) {
1695 left = d->activeCaptionColor;
1696 right = d->activeGradientCaptionColor;
1698 left = d->inactiveCaptionColor;
1699 right = d->inactiveGradientCaptionColor;
1701 QBrush fillBrush(left);
1702 if (left != right) {
1703 QPoint p1(r.x(), r.top() + r.height()/2);
1704 QPoint p2(rect.right(), r.top() + r.height()/2);
1705 QLinearGradient lg(p1, p2);
1706 lg.setColorAt(0, left);
1707 lg.setColorAt(1, right);
1710 p->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
1713 if (!dwOpt->title.isEmpty()) {
1714 QFont oldFont = p->font();
1716 QFont font = oldFont;
1720 QPalette palette = dwOpt->palette;
1721 palette.setColor(QPalette::Window, inactiveCaptionTextColor);
1722 QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, opt, widget);
1723 if (verticalTitleBar) {
1724 titleRect = QRect(r.left() + rect.bottom()
1725 - titleRect.bottom(),
1726 r.top() + titleRect.left() - rect.left(),
1727 titleRect.height(), titleRect.width());
1729 proxy()->drawItemText(p, titleRect,
1730 Qt::AlignLeft | Qt::AlignVCenter, palette,
1731 dwOpt->state & State_Enabled, dwOpt->title,
1732 floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText);
1733 p->setFont(oldFont);
1735 if (verticalTitleBar)
1740#if 0
&& QT_CONFIG(combobox)
1741 case CE_ComboBoxLabel:
1742 if (
const QStyleOptionComboBox *cb = qstyleoption_cast<
const QStyleOptionComboBox *>(opt)) {
1743 if (cb->state & State_HasFocus) {
1744 p->setPen(cb->palette.highlightedText().color());
1745 p->setBackground(cb->palette.highlight());
1747 p->setPen(cb->palette.text().color());
1748 p->setBackground(cb->palette.window());
1751 QCommonStyle::drawControl(ce, opt, p, widget);
1755 QCommonStyle::drawControl(ce, opt, p);
1796void QWindowsStyle::drawComplexControl(ComplexControl cc,
const QStyleOptionComplex *opt,
1801#if QT_CONFIG(slider)
1803 if (
const QStyleOptionSlider *slider = qstyleoption_cast<
const QStyleOptionSlider *>(opt)) {
1804 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider);
1805 int len = proxy()->pixelMetric(PM_SliderLength, slider);
1806 int ticks = slider->tickPosition;
1807 QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove);
1808 QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle);
1810 if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
1811 int mid = thickness / 2;
1813 if (ticks & QStyleOptionSlider::TicksAbove)
1815 if (ticks & QStyleOptionSlider::TicksBelow)
1818 p->setPen(slider->palette.shadow().color());
1819 if (slider->orientation == Qt::Horizontal) {
1820 qDrawWinPanel(p, groove.x(), groove.y() + mid - 2,
1821 groove.width(), 4, slider->palette,
true);
1822 p->drawLine(groove.x() + 1, groove.y() + mid - 1,
1823 groove.x() + groove.width() - 3, groove.y() + mid - 1);
1825 qDrawWinPanel(p, groove.x() + mid - 2, groove.y(),
1826 4, groove.height(), slider->palette,
true);
1827 p->drawLine(groove.x() + mid - 1, groove.y() + 1,
1828 groove.x() + mid - 1, groove.y() + groove.height() - 3);
1832 if (slider->subControls & SC_SliderTickmarks) {
1833 QStyleOptionSlider tmpSlider = *slider;
1834 tmpSlider.subControls = SC_SliderTickmarks;
1835 QCommonStyle::drawComplexControl(cc, &tmpSlider, p);
1838 if (slider->subControls & SC_SliderHandle) {
1848 const QColor c0 = slider->palette.shadow().color();
1849 const QColor c1 = slider->palette.dark().color();
1851 const QColor c3 = slider->palette.midlight().color();
1852 const QColor c4 = slider->palette.light().color();
1855 if (slider->state & State_Enabled) {
1856 handleBrush = slider->palette.color(QPalette::Button);
1858 handleBrush = QBrush(slider->palette.color(QPalette::Button),
1863 int x = handle.x(), y = handle.y(),
1864 wi = handle.width(), he = handle.height();
1871 Qt::Orientation orient = slider->orientation;
1872 bool tickAbove = slider->tickPosition == QStyleOptionSlider::TicksAbove;
1873 bool tickBelow = slider->tickPosition == QStyleOptionSlider::TicksBelow;
1875 if (slider->state & State_HasFocus) {
1876 QStyleOptionFocusRect fropt;
1877 fropt.QStyleOption::operator=(*slider);
1878 fropt.rect = subElementRect(SE_SliderFocusRect, slider);
1879 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p);
1882 if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
1883 Qt::BGMode oldMode = p->backgroundMode();
1884 p->setBackgroundMode(Qt::OpaqueMode);
1885 qDrawWinButton(p, QRect(x, y, wi, he), slider->palette,
false,
1887 p->setBackgroundMode(oldMode);
1891 QSliderDirection dir;
1893 if (orient == Qt::Horizontal)
1910 d = (wi + 1) / 2 - 1;
1911 a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d);
1915 d = (wi + 1) / 2 - 1;
1916 a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1);
1919 d = (he + 1) / 2 - 1;
1921 a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
1924 d = (he + 1) / 2 - 1;
1926 a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1);
1930 QBrush oldBrush = p->brush();
1931 p->setPen(Qt::NoPen);
1932 p->setBrush(handleBrush);
1933 Qt::BGMode oldMode = p->backgroundMode();
1934 p->setBackgroundMode(Qt::OpaqueMode);
1935 p->drawRect(x1, y1, x2-x1+1, y2-y1+1);
1937 p->setBrush(oldBrush);
1938 p->setBackgroundMode(oldMode);
1942 p->drawLine(x1, y1, x2, y1);
1944 p->drawLine(x1, y1+1, x2, y1+1);
1946 if (dir != SlLeft) {
1948 p->drawLine(x1+1, y1+1, x1+1, y2);
1950 p->drawLine(x1, y1, x1, y2);
1952 if (dir != SlRight) {
1954 p->drawLine(x2, y1, x2, y2);
1956 p->drawLine(x2-1, y1+1, x2-1, y2-1);
1958 if (dir != SlDown) {
1960 p->drawLine(x1, y2, x2, y2);
1962 p->drawLine(x1+1, y2-1, x2-1, y2-1);
1968 p->drawLine(x1, y1, x1+d, y1-d);
1971 p->drawLine(x2, y1, x2-d, y1-d);
1974 p->drawLine(x1+1, y1, x1+1+d, y1-d);
1976 p->drawLine(x2-1, y1, x2-1-d, y1-d);
1980 p->drawLine(x1, y2, x1+d, y2+d);
1983 p->drawLine(x2, y2, x2-d, y2+d);
1986 p->drawLine(x1+1, y2, x1+1+d, y2+d);
1988 p->drawLine(x2-1, y2, x2-1-d, y2+d);
1992 p->drawLine(x1, y1, x1-d, y1+d);
1995 p->drawLine(x1, y2, x1-d, y2-d);
1998 p->drawLine(x1, y1+1, x1-d, y1+1+d);
2000 p->drawLine(x1, y2-1, x1-d, y2-1-d);
2004 p->drawLine(x2, y1, x2+d, y1+d);
2007 p->drawLine(x2, y2, x2+d, y2-d);
2010 p->drawLine(x2, y1+1, x2+d, y1+1+d);
2012 p->drawLine(x2, y2-1, x2+d, y2-1-d);
2019#if QT_CONFIG(scrollbar)
2021 if (
const QStyleOptionSlider *scrollbar = qstyleoption_cast<
const QStyleOptionSlider *>(opt)) {
2022 QStyleOptionSlider newScrollbar = *scrollbar;
2023 if (scrollbar->minimum == scrollbar->maximum)
2024 newScrollbar.state &= ~State_Enabled;
2025 QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
2029#if QT_CONFIG(combobox)
2031 if (
const QStyleOptionComboBox *cmb = qstyleoption_cast<
const QStyleOptionComboBox *>(opt)) {
2032 QBrush editBrush = cmb->palette.brush(QPalette::Button);
2033 if ((cmb->subControls & SC_ComboBoxFrame)) {
2035 QPalette shadePal = opt->palette;
2036 shadePal.setColor(QPalette::Midlight, shadePal.button().color());
2037 qDrawWinPanel(p, opt->rect, shadePal,
true, &editBrush);
2040 p->fillRect(opt->rect, editBrush);
2043 if (cmb->subControls & SC_ComboBoxArrow) {
2044 State flags = State_None;
2046 QRect ar = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
2047 bool sunkenArrow = cmb->activeSubControls == SC_ComboBoxArrow
2048 && cmb->state & State_Sunken;
2050 p->setPen(cmb->palette.dark().color());
2051 p->setBrush(cmb->palette.brush(QPalette::Button));
2052 p->drawRect(ar.adjusted(0,0,-1,-1));
2055 QPalette pal(cmb->palette);
2056 pal.setColor(QPalette::Button, cmb->palette.light().color());
2057 pal.setColor(QPalette::Light, cmb->palette.button().color());
2058 qDrawWinButton(p, ar, pal,
false,
2059 &cmb->palette.brush(QPalette::Button));
2062 ar.adjust(2, 2, -2, -2);
2063 if (opt->state & State_Enabled)
2064 flags |= State_Enabled;
2065 if (opt->state & State_HasFocus)
2066 flags |= State_HasFocus;
2069 flags |= State_Sunken;
2070 QStyleOption arrowOpt = *cmb;
2071 arrowOpt.rect = ar.adjusted(1, 1, -1, -1);
2072 arrowOpt.state = flags;
2073 proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
2076 if (cmb->subControls & SC_ComboBoxEditField) {
2077 QRect re = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
2078 if (cmb->state & State_HasFocus && !cmb->editable)
2079 p->fillRect(re.x(), re.y(), re.width(), re.height(),
2080 cmb->palette.brush(QPalette::Highlight));
2082 if (cmb->state & State_HasFocus) {
2083 p->setPen(cmb->palette.highlightedText().color());
2084 p->setBackground(cmb->palette.highlight());
2087 p->setPen(cmb->palette.text().color());
2088 p->setBackground(cmb->palette.window());
2091 if (cmb->state & State_HasFocus && !cmb->editable) {
2092 QStyleOptionFocusRect focus;
2093 focus.QStyleOption::operator=(*cmb);
2094 focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget);
2095 focus.state |= State_FocusAtBorder;
2096 focus.backgroundColor = cmb->palette.highlight().color();
2097 proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
2103#if QT_CONFIG(spinbox)
2105 if (
const QStyleOptionSpinBox *sb = qstyleoption_cast<
const QStyleOptionSpinBox *>(opt)) {
2106 QStyleOptionSpinBox copy = *sb;
2107 PrimitiveElement pe;
2108 bool enabled = opt->state & State_Enabled;
2109 if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
2110 QBrush editBrush = sb->palette.brush(QPalette::Base);
2111 QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);
2112 QPalette shadePal = sb->palette;
2113 shadePal.setColor(QPalette::Midlight, shadePal.button().color());
2114 qDrawWinPanel(p, r, shadePal,
true, &editBrush);
2117 QPalette shadePal(opt->palette);
2118 shadePal.setColor(QPalette::Button, opt->palette.light().color());
2119 shadePal.setColor(QPalette::Light, opt->palette.button().color());
2121 if (sb->subControls & SC_SpinBoxUp) {
2122 copy.subControls = SC_SpinBoxUp;
2123 QPalette pal2 = sb->palette;
2124 if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
2125 pal2.setCurrentColorGroup(QPalette::Disabled);
2126 copy.state &= ~State_Enabled;
2129 copy.palette = pal2;
2131 if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
2132 copy.state |= State_On;
2133 copy.state |= State_Sunken;
2135 copy.state |= State_Raised;
2136 copy.state &= ~State_Sunken;
2138 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
2139 : PE_IndicatorSpinUp);
2141 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);
2142 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
2143 ©.palette.brush(QPalette::Button));
2144 copy.rect.adjust(4, 1, -5, -1);
2145 if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled))
2146 && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
2148 QStyleOptionSpinBox lightCopy = copy;
2149 lightCopy.rect.adjust(1, 1, 1, 1);
2150 lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
2151 proxy()->drawPrimitive(pe, &lightCopy, p, widget);
2153 proxy()->drawPrimitive(pe, ©, p, widget);
2156 if (sb->subControls & SC_SpinBoxDown) {
2157 copy.subControls = SC_SpinBoxDown;
2158 copy.state = sb->state;
2159 QPalette pal2 = sb->palette;
2160 if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
2161 pal2.setCurrentColorGroup(QPalette::Disabled);
2162 copy.state &= ~State_Enabled;
2164 copy.palette = pal2;
2166 if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
2167 copy.state |= State_On;
2168 copy.state |= State_Sunken;
2170 copy.state |= State_Raised;
2171 copy.state &= ~State_Sunken;
2173 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
2174 : PE_IndicatorSpinDown);
2176 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
2177 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
2178 ©.palette.brush(QPalette::Button));
2179 copy.rect.adjust(4, 0, -5, -1);
2180 if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled))
2181 && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
2183 QStyleOptionSpinBox lightCopy = copy;
2184 lightCopy.rect.adjust(1, 1, 1, 1);
2185 lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
2186 proxy()->drawPrimitive(pe, &lightCopy, p, widget);
2188 proxy()->drawPrimitive(pe, ©, p, widget);
2194 QCommonStyle::drawComplexControl(cc, opt, p);
2197 QCommonStyle::drawComplexControl(cc, opt, p);