574 bool doRestore =
false;
577#if 0
&& QT_CONFIG(toolbar)
578 case PE_IndicatorToolBarSeparator:
580 QRect rect = opt->rect;
581 const int margin = 2;
582 QPen oldPen = p->pen();
583 if (opt->state & State_Horizontal){
584 const int offset = rect.width()/2;
585 p->setPen(QPen(opt->palette.dark().color()));
586 p->drawLine(rect.bottomLeft().x() + offset,
587 rect.bottomLeft().y() - margin,
588 rect.topLeft().x() + offset,
589 rect.topLeft().y() + margin);
590 p->setPen(QPen(opt->palette.light().color()));
591 p->drawLine(rect.bottomLeft().x() + offset + 1,
592 rect.bottomLeft().y() - margin,
593 rect.topLeft().x() + offset + 1,
594 rect.topLeft().y() + margin);
597 const int offset = rect.height()/2;
598 p->setPen(QPen(opt->palette.dark().color()));
599 p->drawLine(rect.topLeft().x() + margin ,
600 rect.topLeft().y() + offset,
601 rect.topRight().x() - margin,
602 rect.topRight().y() + offset);
603 p->setPen(QPen(opt->palette.light().color()));
604 p->drawLine(rect.topLeft().x() + margin ,
605 rect.topLeft().y() + offset + 1,
606 rect.topRight().x() - margin,
607 rect.topRight().y() + offset + 1);
612 case PE_IndicatorToolBarHandle:
614 p->translate(opt->rect.x(), opt->rect.y());
615 if (opt->state & State_Horizontal) {
616 int x = opt->rect.width() / 2 - 4;
617 if (opt->direction == Qt::RightToLeft)
619 if (opt->rect.height() > 4) {
620 qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
621 opt->palette,
false, 1,
nullptr);
622 qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4,
623 opt->palette,
false, 1,
nullptr);
626 if (opt->rect.width() > 4) {
627 int y = opt->rect.height() / 2 - 4;
628 qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
629 opt->palette,
false, 1,
nullptr);
630 qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3,
631 opt->palette,
false, 1,
nullptr);
638 case PE_FrameButtonTool:
639 case PE_PanelButtonTool: {
640 QPen oldPen = p->pen();
641#if 0
&& QT_CONFIG(dockwidget)
642 if (w && w->inherits(
"QDockWidgetTitleButton")) {
643 if (
const QWidget *dw = w->parentWidget())
645 qDrawWinButton(p, opt->rect.adjusted(1, 1, 0, 0), opt->palette, opt->state & (State_Sunken | State_On),
646 &opt->palette.button());
654 bool panel = (pe == PE_PanelButtonTool);
655 if ((!(opt->state & State_Sunken ))
656 && (!(opt->state & State_Enabled)
657 || !(opt->state & State_MouseOver && opt->state & State_AutoRaise))
658 && (opt->state & State_On)) {
659 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
662 fill = opt->palette.brush(QPalette::Button);
666 if (opt->state & (State_Raised | State_Sunken | State_On)) {
667 if (opt->state & State_AutoRaise) {
668 if (opt->state & (State_Enabled | State_Sunken | State_On)){
670 qDrawShadePanel(p, opt->rect, opt->palette,
671 opt->state & (State_Sunken | State_On), 1, &fill);
673 qDrawShadeRect(p, opt->rect, opt->palette,
674 opt->state & (State_Sunken | State_On), 1);
677 p->setPen(opt->palette.button().color());
678 p->drawRect(opt->rect.adjusted(1,1,-2,-2));
681 qDrawWinButton(p, opt->rect, opt->palette,
682 opt->state & (State_Sunken | State_On), panel ? &fill :
nullptr);
685 p->fillRect(opt->rect, fill);
689 case PE_PanelButtonCommand:
692 State flags = opt->state;
693 QPalette pal = opt->palette;
695 if (! (flags & State_Sunken) && (flags & State_On))
696 fill = QBrush(pal.light().color(), Qt::Dense4Pattern);
698 fill = pal.brush(QPalette::Button);
700 if (btn->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
701 p->setPen(pal.dark().color());
703 p->drawRect(r.adjusted(0, 0, -1, -1));
704 }
else if (flags & (State_Raised | State_On | State_Sunken)) {
705 qDrawWinButton(p, r, pal, flags & (State_Sunken | State_On),
708 p->fillRect(r, fill);
712 case PE_FrameDefaultButton: {
713 QPen oldPen = p->pen();
714 p->setPen(QPen(opt->palette.shadow().color(), 0));
715 QRectF rect = opt->rect;
716 const qreal dpi = QStyleHelper::dpi(opt);
717 const qreal topLevelAdjustment = QStyleHelper::dpiScaled(0.5, dpi);
718 const qreal bottomRightAdjustment = QStyleHelper::dpiScaled(-1.5, dpi);
719 rect.adjust(topLevelAdjustment, topLevelAdjustment,
720 bottomRightAdjustment, bottomRightAdjustment);
725 case PE_IndicatorCheckBox: {
727 if (opt->state & State_NoChange)
728 fill = QBrush(opt->palette.base().color(), Qt::Dense4Pattern);
729 else if (opt->state & State_Sunken)
730 fill = opt->palette.button();
731 else if (opt->state & State_Enabled)
732 fill = opt->palette.base();
734 fill = opt->palette.window();
737 qDrawWinPanel(p, opt->rect, opt->palette,
true, &fill);
738 if (opt->state & State_NoChange)
739 p->setPen(opt->palette.dark().color());
741 p->setPen(opt->palette.text().color());
744 case PE_IndicatorItemViewItemCheck:
749#if 0
&& QT_CONFIG(itemviews)
750 if (pe == PE_IndicatorItemViewItemCheck) {
751 const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<
const QStyleOptionViewItem *>(opt);
752 p->setPen(itemViewOpt
753 && itemViewOpt->showDecorationSelected
754 && opt->state & State_Selected
755 ? opt->palette.highlightedText().color()
756 : opt->palette.text().color());
757 if (opt->state & State_NoChange)
758 p->setBrush(opt->palette.brush(QPalette::Button));
759 p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, opt->rect.width() - 2, opt->rect.height() - 2);
762 if (!(opt->state & State_Off)) {
764 qreal scaleh = opt->rect.width() / 12.0;
765 qreal scalev = opt->rect.height() / 12.0;
766 points[0] = { opt->rect.x() + 3.5 * scaleh, opt->rect.y() + 5.5 * scalev };
767 points[1] = { points[0].x(), points[0].y() + 2 * scalev };
768 points[2] = { points[1].x() + 2 * scaleh, points[1].y() + 2 * scalev };
769 points[3] = { points[2].x() + 4 * scaleh, points[2].y() - 4 * scalev };
770 points[4] = { points[3].x(), points[3].y() - 2 * scalev };
771 points[5] = { points[4].x() - 4 * scaleh, points[4].y() + 4 * scalev };
772 p->setPen(QPen(opt->palette.text().color(), 0));
773 p->setBrush(opt->palette.text());
774 p->drawPolygon(points, 6);
779 case PE_FrameFocusRect:
780 if (
const QStyleOptionFocusRect *fropt = qstyleoption_cast<
const QStyleOptionFocusRect *>(opt)) {
782 if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt))
786 p->setBackgroundMode(Qt::TransparentMode);
787 QColor bg_col = fropt->backgroundColor;
788 if (!bg_col.isValid())
789 bg_col = p->background().color();
790 bg_col = bg_col.toRgb();
792 QColor patternCol((bg_col.red() ^ 0xff) & 0xff,
793 (bg_col.green() ^ 0xff) & 0xff,
794 (bg_col.blue() ^ 0xff) & 0xff);
795 p->setBrush(QBrush(patternCol, Qt::Dense4Pattern));
796 p->setBrushOrigin(r.topLeft());
797 p->setPen(Qt::NoPen);
798 p->drawRect(r.left(), r.top(), r.width(), 1);
799 p->drawRect(r.left(), r.bottom(), r.width(), 1);
800 p->drawRect(r.left(), r.top(), 1, r.height());
801 p->drawRect(r.right(), r.top(), 1, r.height());
805 case PE_IndicatorRadioButton:
809 p->setRenderHint(QPainter::Antialiasing,
true);
811 QPointF circleCenter = r.center() + QPoint(1, 1);
812 qreal radius = (r.width() + (r.width() + 1) % 2) / 2.0 - 1;
815 path1.addEllipse(circleCenter, radius, radius);
818 path2.addEllipse(circleCenter, radius, radius);
821 path3.addEllipse(circleCenter, radius, radius);
824 path4.addEllipse(circleCenter, radius, radius);
826 QPolygon topLeftPol, bottomRightPol;
827 topLeftPol.setPoints(3, r.x(), r.y(), r.x(), r.y() + r.height(), r.x() + r.width(), r.y());
828 bottomRightPol.setPoints(3, r.x(), r.y() + r.height(), r.x() + r.width(), r.y() + r.height(), r.x() + r.width(), r.y());
830 p->setClipRegion(QRegion(topLeftPol));
831 p->setPen(opt->palette.dark().color());
832 p->setBrush(opt->palette.dark());
834 p->setPen(opt->palette.shadow().color());
835 p->setBrush(opt->palette.shadow());
838 p->setClipRegion(QRegion(bottomRightPol));
839 p->setPen(opt->palette.light().color());
840 p->setBrush(opt->palette.light());
842 p->setPen(opt->palette.midlight().color());
843 p->setBrush(opt->palette.midlight());
846 const QBrush fill = ((opt->state & State_Sunken) || !(opt->state & State_Enabled))
847 ? opt->palette.button() : opt->palette.base();
849 p->setClipping(
false);
850 p->setPen(fill.color());
854 if (opt->state & State_On) {
855 p->setPen(opt->palette.text().color());
856 p->setBrush(opt->palette.text());
865 if (
const QStyleOptionFrame *frame = qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
866 if (frame->lineWidth == 2 || pe == PE_Frame) {
867 QPalette popupPal = frame->palette;
868 if (pe == PE_FrameMenu) {
869 popupPal.setBrush(QPalette::Light, frame->palette.window());
870 popupPal.setBrush(QPalette::Midlight, frame->palette.light());
872 if (pe == PE_Frame && (frame->state & State_Raised))
873 qDrawWinButton(p, frame->rect, popupPal, frame->state & State_Sunken);
874 else if (pe == PE_Frame && (frame->state & State_Sunken))
876 popupPal.setBrush(QPalette::Midlight, frame->palette.window());
877 qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
880 qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
882 QCommonStyle::drawPrimitive(pe, opt, p);
885 QPalette popupPal = opt->palette;
886 popupPal.setBrush(QPalette::Light, opt->palette.window());
887 popupPal.setBrush(QPalette::Midlight, opt->palette.light());
888 qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
892 case PE_FrameButtonBevel:
893 case PE_PanelButtonBevel: {
895 bool panel = pe != PE_FrameButtonBevel;
896 p->setBrushOrigin(opt->rect.topLeft());
897 if (!(opt->state & State_Sunken) && (opt->state & State_On))
898 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
900 fill = opt->palette.brush(QPalette::Button);
902 if (opt->state & (State_Raised | State_On | State_Sunken)) {
903 qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On),
904 panel ? &fill :
nullptr);
907 p->fillRect(opt->rect, fill);
909 p->drawRect(opt->rect);
912 case PE_FrameWindow: {
913 QPalette popupPal = opt->palette;
914 popupPal.setBrush(QPalette::Light, opt->palette.window());
915 popupPal.setBrush(QPalette::Midlight, opt->palette.light());
916 qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
918#if 0
&& QT_CONFIG(dockwidget)
919 case PE_IndicatorDockWidgetResizeHandle:
921 case PE_FrameDockWidget:
922 if (qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
923 proxy()->drawPrimitive(QStyle::PE_FrameWindow, opt, p, w);
928 case PE_FrameStatusBarItem:
929 qDrawShadePanel(p, opt->rect, opt->palette,
true, 1,
nullptr);
932 case PE_IndicatorProgressChunk:
934 bool vertical =
false, inverted =
false;
935 if (
const QStyleOptionProgressBar *pb = qstyleoption_cast<
const QStyleOptionProgressBar *>(opt)) {
936 vertical = !(pb->state & QStyle::State_Horizontal);
937 inverted = pb->invertedAppearance;
941 int chunksize = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt) - space;
943 if (opt->rect.width() <= chunksize)
947 p->fillRect(opt->rect.x() + space, opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
948 opt->palette.brush(QPalette::Highlight));
950 p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
951 opt->palette.brush(QPalette::Highlight));
953 if (opt->rect.height() <= chunksize)
957 p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height() - space,
958 opt->palette.brush(QPalette::Highlight));
960 p->fillRect(opt->rect.x(), opt->rect.y() + space, opt->rect.width(), opt->rect.height() - space,
961 opt->palette.brush(QPalette::Highlight));
966 case PE_FrameTabWidget: {
967 qDrawWinButton(p, opt->rect, opt->palette,
false,
nullptr);
971 QCommonStyle::drawPrimitive(pe, opt, p);
982#if 0
&& QT_CONFIG(rubberband)
984 if (qstyleoption_cast<
const QStyleOptionRubberBand *>(opt)) {
986 QPixmap tiledPixmap(16, 16);
987 QPainter pixmapPainter(&tiledPixmap);
988 pixmapPainter.setPen(Qt::NoPen);
989 pixmapPainter.setBrush(Qt::Dense4Pattern);
990 pixmapPainter.setBackground(Qt::white);
991 pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
992 pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
994 tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
997 QStyleHintReturnMask mask;
998 if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
999 p->setClipRegion(mask.region);
1000 p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
1007#if 0
&& QT_CONFIG(menu) && QT_CONFIG(mainwindow)
1008 case CE_MenuBarEmptyArea:
1009 if (widget && qobject_cast<
const QMainWindow *>(widget->parentWidget())) {
1010 p->fillRect(opt->rect, opt->palette.button());
1011 QPen oldPen = p->pen();
1012 p->setPen(QPen(opt->palette.dark().color()));
1013 p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight());
1018#if 0
&& QT_CONFIG(menu)
1020 if (
const QStyleOptionMenuItem *menuitem = qstyleoption_cast<
const QStyleOptionMenuItem *>(opt)) {
1022 menuitem->rect.getRect(&x, &y, &w, &h);
1023 int tab = menuitem->tabWidth;
1024 bool dis = !(menuitem->state & State_Enabled);
1025 bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
1026 ? menuitem->checked :
false;
1027 bool act = menuitem->state & State_Selected;
1030 int checkcol = qMax<
int>(menuitem->maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
1032 QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
1033 p->fillRect(menuitem->rect.adjusted(0, 0, -1, 0), fill);
1035 if (menuitem->menuItemType == QStyleOptionMenuItem::Separator){
1036 int yoff = y-1 + h / 2;
1037 p->setPen(menuitem->palette.dark().color());
1038 p->drawLine(x + 2, yoff, x + w - 4, yoff);
1039 p->setPen(menuitem->palette.light().color());
1040 p->drawLine(x + 2, yoff + 1, x + w - 4, yoff + 1);
1044 QRect vCheckRect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x(), menuitem->rect.y(), checkcol, menuitem->rect.height()));
1045 if (!menuitem->icon.isNull() && checked) {
1047 qDrawShadePanel(p, vCheckRect,
1048 menuitem->palette,
true, 1,
1049 &menuitem->palette.brush(QPalette::Button));
1051 QBrush fill(menuitem->palette.light().color(), Qt::Dense4Pattern);
1052 qDrawShadePanel(p, vCheckRect, menuitem->palette,
true, 1, &fill);
1055 p->fillRect(vCheckRect, menuitem->palette.brush(QPalette::Button));
1061 if (!menuitem->icon.isNull()) {
1062 QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
1064 mode = QIcon::Active;
1067 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
1069 pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
1070 const int pixw = pixmap.width() / pixmap.devicePixelRatio();
1071 const int pixh = pixmap.height() / pixmap.devicePixelRatio();
1072 QRect pmr(0, 0, pixw, pixh);
1073 pmr.moveCenter(vCheckRect.center());
1074 p->setPen(menuitem->palette.text().color());
1075 p->drawPixmap(pmr.topLeft(), pixmap);
1076 }
else if (checked) {
1077 QStyleOptionMenuItem newMi = *menuitem;
1078 newMi.state = State_None;
1080 newMi.state |= State_Enabled;
1082 newMi.state |= State_On;
1083 newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + QWindowsStylePrivate::windowsItemFrame,
1084 menuitem->rect.y() + QWindowsStylePrivate::windowsItemFrame,
1085 checkcol - 2 * QWindowsStylePrivate::windowsItemFrame,
1086 menuitem->rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
1087 proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
1089 p->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color());
1093 discol = menuitem->palette.text().color();
1097 int xm =
int(QWindowsStylePrivate::windowsItemFrame) + checkcol +
int(QWindowsStylePrivate::windowsItemHMargin);
1098 int xpos = menuitem->rect.x() + xm;
1099 QRect textRect(xpos, y + QWindowsStylePrivate::windowsItemVMargin,
1100 w - xm - QWindowsStylePrivate::windowsRightBorder - tab + 1, h - 2 * QWindowsStylePrivate::windowsItemVMargin);
1101 QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
1102 QStringRef s(&menuitem->text);
1105 int t = s.indexOf(QLatin1Char(
'\t'));
1106 int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
1107 if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
1108 text_flags |= Qt::TextHideMnemonic;
1109 text_flags |= Qt::AlignLeft;
1111 QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
1112 QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
1113 const QString textToDraw = s.mid(t + 1).toString();
1114 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1115 p->setPen(menuitem->palette.light().color());
1116 p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, textToDraw);
1119 p->drawText(vShortcutRect, text_flags, textToDraw);
1122 QFont font = menuitem->font;
1123 if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
1126 const QString textToDraw = s.left(t).toString();
1127 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1128 p->setPen(menuitem->palette.light().color());
1129 p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, textToDraw);
1132 p->drawText(vTextRect, text_flags, textToDraw);
1135 if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {
1136 int dim = (h - 2 * QWindowsStylePrivate::windowsItemFrame) / 2;
1137 PrimitiveElement arrow;
1138 arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
1139 xpos = x + w - QWindowsStylePrivate::windowsArrowHMargin - QWindowsStylePrivate::windowsItemFrame - dim;
1140 QRect vSubMenuRect = visualRect(opt->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
1141 QStyleOptionMenuItem newMI = *menuitem;
1142 newMI.rect = vSubMenuRect;
1143 newMI.state = dis ? State_None : State_Enabled;
1145 newMI.palette.setColor(QPalette::ButtonText,
1146 newMI.palette.highlightedText().color());
1147 proxy()->drawPrimitive(arrow, &newMI, p, widget);
1153#if 0
&& QT_CONFIG(menubar)
1154 case CE_MenuBarItem:
1155 if (
const QStyleOptionMenuItem *mbi = qstyleoption_cast<
const QStyleOptionMenuItem *>(opt)) {
1156 bool active = mbi->state & State_Selected;
1157 bool hasFocus = mbi->state & State_HasFocus;
1158 bool down = mbi->state & State_Sunken;
1159 QStyleOptionMenuItem newMbi = *mbi;
1160 p->fillRect(mbi->rect, mbi->palette.brush(QPalette::Button));
1161 if (active || hasFocus) {
1162 QBrush b = mbi->palette.brush(QPalette::Button);
1164 p->setBrushOrigin(p->brushOrigin() + QPoint(1, 1));
1165 if (active && hasFocus)
1166 qDrawShadeRect(p, mbi->rect.x(), mbi->rect.y(), mbi->rect.width(),
1167 mbi->rect.height(), mbi->palette, active && down, 1, 0, &b);
1168 if (active && down) {
1169 newMbi.rect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, mbi, widget),
1170 proxy()->pixelMetric(PM_ButtonShiftVertical, mbi, widget));
1171 p->setBrushOrigin(p->brushOrigin() - QPoint(1, 1));
1174 QCommonStyle::drawControl(ce, &newMbi, p, widget);
1178#if 0
&& QT_CONFIG(tabbar)
1179 case CE_TabBarTabShape:
1180 if (
const QStyleOptionTab *tab = qstyleoption_cast<
const QStyleOptionTab *>(opt)) {
1181 bool rtlHorTabs = (tab->direction == Qt::RightToLeft
1182 && (tab->shape == QTabBar::RoundedNorth
1183 || tab->shape == QTabBar::RoundedSouth));
1184 bool selected = tab->state & State_Selected;
1185 bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
1187 && tab->position == QStyleOptionTab::Beginning));
1188 bool firstTab = ((!rtlHorTabs
1189 && tab->position == QStyleOptionTab::Beginning)
1191 && tab->position == QStyleOptionTab::End));
1192 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
1193 bool previousSelected =
1195 && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
1197 && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
1200 && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
1202 && tab->selectedPosition
1203 == QStyleOptionTab::PreviousIsSelected));
1204 int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
1205 bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
1207 && tabBarAlignment == Qt::AlignRight);
1209 bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
1211 && tabBarAlignment == Qt::AlignLeft);
1213 QColor light = tab->palette.light().color();
1214 QColor dark = tab->palette.dark().color();
1215 QColor shadow = tab->palette.shadow().color();
1216 int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
1218 borderThinkness /= 2;
1219 QRect r2(opt->rect);
1221 int x2 = r2.right();
1223 int y2 = r2.bottom();
1224 switch (tab->shape) {
1226 QCommonStyle::drawControl(ce, tab, p, widget);
1228 case QTabBar::RoundedNorth: {
1231 x1 += onlyOne || firstTab ? borderThinkness : 0;
1232 x2 -= onlyOne || lastTab ? borderThinkness : 0;
1235 p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 2), tab->palette.window());
1239 p->fillRect(QRect(x1,y2-1,x2-x1,1), tab->palette.window());
1240 p->fillRect(QRect(x1,y2,x2-x1,1), tab->palette.window());
1243 if (firstTab || selected || onlyOne || !previousSelected) {
1245 p->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
1246 p->drawPoint(x1 + 1, y1 + 1);
1250 int beg = x1 + (previousSelected ? 0 : 2);
1251 int end = x2 - (nextSelected ? 0 : 2);
1253 p->drawLine(beg, y1, end, y1);
1256 if (lastTab || selected || onlyOne || !nextSelected) {
1258 p->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1259 p->drawPoint(x2 - 1, y1 + 1);
1261 p->drawLine(x2 - 1, y1 + 2, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1264 case QTabBar::RoundedSouth: {
1267 x1 += firstTab ? borderThinkness : 0;
1268 x2 -= lastTab ? borderThinkness : 0;
1271 p->fillRect(QRect(x1 + 1, y1 + 2, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.window());
1275 p->fillRect(QRect(x1, y1 + 1, (x2 - 1)-x1, 1), tab->palette.window());
1276 p->fillRect(QRect(x1, y1, (x2 - 1)-x1, 1), tab->palette.window());
1279 if (firstTab || selected || onlyOne || !previousSelected) {
1281 p->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
1282 p->drawPoint(x1 + 1, y2 - 1);
1286 int beg = x1 + (previousSelected ? 0 : 2);
1287 int end = x2 - (nextSelected ? 0 : 2);
1289 p->drawLine(beg, y2, end, y2);
1291 p->drawLine(beg, y2 - 1, end, y2 - 1);
1294 if (lastTab || selected || onlyOne || !nextSelected) {
1296 p->drawLine(x2, y2 - 2, x2, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1297 p->drawPoint(x2 - 1, y2 - 1);
1299 p->drawLine(x2 - 1, y2 - 2, x2 - 1, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
1302 case QTabBar::RoundedWest: {
1305 y1 += firstTab ? borderThinkness : 0;
1306 y2 -= lastTab ? borderThinkness : 0;
1309 p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 2, (y2 - y1) - 1), tab->palette.window());
1313 p->fillRect(QRect(x2 - 1, y1, 1, y2-y1), tab->palette.window());
1314 p->fillRect(QRect(x2, y1, 1, y2-y1), tab->palette.window());
1317 if (firstTab || selected || onlyOne || !previousSelected) {
1319 p->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
1320 p->drawPoint(x1 + 1, y1 + 1);
1324 int beg = y1 + (previousSelected ? 0 : 2);
1325 int end = y2 - (nextSelected ? 0 : 2);
1327 p->drawLine(x1, beg, x1, end);
1330 if (lastTab || selected || onlyOne || !nextSelected) {
1332 p->drawLine(x1 + 3, y2, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
1333 p->drawPoint(x1 + 2, y2 - 1);
1335 p->drawLine(x1 + 3, y2 - 1, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
1336 p->drawPoint(x1 + 1, y2 - 1);
1337 p->drawPoint(x1 + 2, y2);
1340 case QTabBar::RoundedEast: {
1343 y1 += firstTab ? borderThinkness : 0;
1344 y2 -= lastTab ? borderThinkness : 0;
1347 p->fillRect(QRect(x1 + 2, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.window());
1351 p->fillRect(QRect(x1 + 1, y1, 1, (y2 - 1)-y1),tab->palette.window());
1352 p->fillRect(QRect(x1, y1, 1, (y2-1)-y1), tab->palette.window());
1355 if (firstTab || selected || onlyOne || !previousSelected) {
1357 p->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
1358 p->drawPoint(x2 - 1, y1 + 1);
1362 int beg = y1 + (previousSelected ? 0 : 2);
1363 int end = y2 - (nextSelected ? 0 : 2);
1365 p->drawLine(x2, beg, x2, end);
1367 p->drawLine(x2 - 1, beg, x2 - 1, end);
1370 if (lastTab || selected || onlyOne || !nextSelected) {
1372 p->drawLine(x2 - 2, y2, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
1373 p->drawPoint(x2 - 1, y2 - 1);
1375 p->drawLine(x2 - 2, y2 - 1, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
1382 case CE_ToolBoxTabShape:
1383 qDrawShadePanel(p, opt->rect, opt->palette,
1384 opt->state & (State_Sunken | State_On), 1,
1385 &opt->palette.brush(QPalette::Button));
1387#if 0
&& QT_CONFIG(splitter)
1389 p->eraseRect(opt->rect);
1392#if 0
&& QT_CONFIG(scrollbar)
1393 case CE_ScrollBarSubLine:
1394 case CE_ScrollBarAddLine: {
1395 if ((opt->state & State_Sunken)) {
1396 p->setPen(opt->palette.dark().color());
1397 p->setBrush(opt->palette.brush(QPalette::Button));
1398 p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
1400 QStyleOption buttonOpt = *opt;
1401 if (!(buttonOpt.state & State_Sunken))
1402 buttonOpt.state |= State_Raised;
1403 QPalette pal(opt->palette);
1404 pal.setBrush(QPalette::Button, opt->palette.light());
1405 pal.setColor(QPalette::Light, opt->palette.button().color());
1406 qDrawWinButton(p, opt->rect, pal, opt->state & (State_Sunken | State_On),
1407 &opt->palette.brush(QPalette::Button));
1409 PrimitiveElement arrow;
1410 if (opt->state & State_Horizontal) {
1411 if (ce == CE_ScrollBarAddLine)
1412 arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft;
1414 arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
1416 if (ce == CE_ScrollBarAddLine)
1417 arrow = PE_IndicatorArrowDown;
1419 arrow = PE_IndicatorArrowUp;
1421 QStyleOption arrowOpt = *opt;
1422 arrowOpt.rect = opt->rect.adjusted(4, 4, -4, -4);
1423 proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
1425 case CE_ScrollBarAddPage:
1426 case CE_ScrollBarSubPage: {
1428 QBrush bg = p->background();
1429 Qt::BGMode bg_mode = p->backgroundMode();
1430 p->setPen(Qt::NoPen);
1431 p->setBackgroundMode(Qt::OpaqueMode);
1433 if (opt->state & State_Sunken) {
1434 br = QBrush(opt->palette.shadow().color(), Qt::Dense4Pattern);
1435 p->setBackground(opt->palette.dark().color());
1438 const QBrush paletteBrush = opt->palette.brush(QPalette::Light);
1439 if (paletteBrush.style() == Qt::TexturePattern) {
1440 if (qHasPixmapTexture(paletteBrush))
1441 br = QBrush(paletteBrush.texture());
1443 br = QBrush(paletteBrush.textureImage());
1445 br = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1446 p->setBackground(opt->palette.window().color());
1449 p->drawRect(opt->rect);
1450 p->setBackground(bg);
1451 p->setBackgroundMode(bg_mode);
1453 case CE_ScrollBarSlider:
1454 if (!(opt->state & State_Enabled)) {
1456 const QBrush paletteBrush = opt->palette.brush(QPalette::Light);
1457 if (paletteBrush.style() == Qt::TexturePattern) {
1458 if (qHasPixmapTexture(paletteBrush))
1459 br = QBrush(paletteBrush.texture());
1461 br = QBrush(paletteBrush.textureImage());
1463 br = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1464 p->setPen(Qt::NoPen);
1466 p->setBackgroundMode(Qt::OpaqueMode);
1467 p->drawRect(opt->rect);
1469 QStyleOptionButton buttonOpt;
1470 buttonOpt.QStyleOption::operator=(*opt);
1471 buttonOpt.state = State_Enabled | State_Raised;
1473 QPalette pal(opt->palette);
1474 pal.setColor(QPalette::Button, opt->palette.light().color());
1475 pal.setColor(QPalette::Light, opt->palette.button().color());
1476 qDrawWinButton(p, opt->rect, pal,
false, &opt->palette.brush(QPalette::Button));
1480 case CE_HeaderSection: {
1482 if (opt->state & State_On)
1483 fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1485 fill = opt->palette.brush(QPalette::Button);
1487 if (opt->state & (State_Raised | State_Sunken)) {
1488 qDrawWinButton(p, opt->rect, opt->palette, opt->state & State_Sunken, &fill);
1490 p->fillRect(opt->rect, fill);
1493#if 0
&& QT_CONFIG(toolbar)
1495 if (
const QStyleOptionToolBar *toolbar = qstyleoption_cast<
const QStyleOptionToolBar *>(opt)) {
1497 if (!(widget && qobject_cast<
const QMainWindow*> (widget->parentWidget())))
1500 QRect rect = opt->rect;
1501 bool paintLeftBorder =
true;
1502 bool paintRightBorder =
true;
1503 bool paintBottomBorder =
true;
1505 switch (toolbar->toolBarArea){
1506 case Qt::BottomToolBarArea :
1507 switch (toolbar->positionOfLine){
1508 case QStyleOptionToolBar::Beginning:
1509 case QStyleOptionToolBar::OnlyOne:
1510 paintBottomBorder =
false;
1516 case Qt::TopToolBarArea :
1517 switch (toolbar->positionWithinLine){
1518 case QStyleOptionToolBar::Beginning:
1519 paintLeftBorder =
false;
1521 case QStyleOptionToolBar::End:
1522 paintRightBorder =
false;
1524 case QStyleOptionToolBar::OnlyOne:
1525 paintRightBorder =
false;
1526 paintLeftBorder =
false;
1531 if (opt->direction == Qt::RightToLeft){
1532 bool tmp = paintLeftBorder;
1533 paintRightBorder=paintLeftBorder;
1534 paintLeftBorder=tmp;
1537 case Qt::RightToolBarArea :
1538 switch (toolbar->positionOfLine){
1539 case QStyleOptionToolBar::Beginning:
1540 case QStyleOptionToolBar::OnlyOne:
1541 paintRightBorder =
false;
1547 case Qt::LeftToolBarArea :
1548 switch (toolbar->positionOfLine){
1549 case QStyleOptionToolBar::Beginning:
1550 case QStyleOptionToolBar::OnlyOne:
1551 paintLeftBorder =
false;
1563 p->setPen(QPen(opt->palette.light().color()));
1564 p->drawLine(rect.topLeft().x(),
1566 rect.topRight().x(),
1567 rect.topRight().y());
1569 if (paintLeftBorder){
1570 p->setPen(QPen(opt->palette.light().color()));
1571 p->drawLine(rect.topLeft().x(),
1573 rect.bottomLeft().x(),
1574 rect.bottomLeft().y());
1577 if (paintRightBorder){
1578 p->setPen(QPen(opt->palette.dark().color()));
1579 p->drawLine(rect.topRight().x(),
1580 rect.topRight().y(),
1581 rect.bottomRight().x(),
1582 rect.bottomRight().y());
1585 if (paintBottomBorder){
1586 p->setPen(QPen(opt->palette.dark().color()));
1587 p->drawLine(rect.bottomLeft().x(),
1588 rect.bottomLeft().y(),
1589 rect.bottomRight().x(),
1590 rect.bottomRight().y());
1598 case CE_ProgressBarContents:
1599 if (
const QStyleOptionProgressBar *pb = qstyleoption_cast<
const QStyleOptionProgressBar *>(opt)) {
1600 QRect rect = pb->rect;
1601 if (!rect.isValid())
1604 const bool vertical = !(pb->state & QStyle::State_Horizontal);
1605 const bool inverted = pb->invertedAppearance;
1609 rect = QRect(rect.y(), rect.x(), rect.height(), rect.width());
1611 m.translate(0, -(rect.height() + rect.y()*2));
1613 QPalette pal2 = pb->palette;
1615 if (pal2.highlight() == pal2.window())
1616 pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
1617 QPalette::Highlight));
1618 bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
1621 int w = rect.width();
1622 Q_D(
const QWindowsStyle);
1623 if (pb->minimum == 0 && pb->maximum == 0) {
1624 const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb);
1625 QStyleOptionProgressBar pbBits = *pb;
1626 Q_ASSERT(unit_width >0);
1629 pbBits.palette = pal2;
1632 int chunkCount = w / unit_width + 1;
1633#if 0
&& QT_CONFIG(animation)
1634 if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject)))
1635 step = (animation->animationStep() / 3) % chunkCount;
1637 d->startAnimation(
new QProgressStyleAnimation(d->animationFps, opt->styleObject));
1641 int chunksInRow = 5;
1642 int myY = pbBits.rect.y();
1643 int myHeight = pbBits.rect.height();
1644 int chunksToDraw = chunksInRow;
1646 if (step > chunkCount - 5)chunksToDraw = (chunkCount - step);
1648 p->setClipRect(m.mapRect(QRectF(rect)).toRect());
1650 int x0 = reverse ? rect.left() + rect.width() - unit_width*(step) - unit_width : rect.left() + unit_width * step;
1653 for (
int i = 0; i < chunksToDraw ; ++i) {
1654 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
1655 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1656 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p);
1657 x += reverse ? -unit_width : unit_width;
1660 if ( step > chunkCount-5){
1661 x0 = reverse ? rect.left() + rect.width() - unit_width : rect.left() ;
1663 int chunksToDraw = step - (chunkCount - chunksInRow);
1664 for (
int i = 0; i < chunksToDraw ; ++i) {
1665 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
1666 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1667 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p);
1668 x += reverse ? -unit_width : unit_width;
1674#if 0
&& QT_CONFIG(animation)
1675 d->stopAnimation(opt->styleObject);
1677 QCommonStyle::drawControl(ce, opt, p);
1682#if 0
&& QT_CONFIG(dockwidget)
1683 case CE_DockWidgetTitle:
1685 if (
const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<
const QStyleOptionDockWidget *>(opt)) {
1686 Q_D(
const QWindowsStyle);
1688 const bool verticalTitleBar = dwOpt->verticalTitleBar;
1690 QRect rect = dwOpt->rect;
1693 if (verticalTitleBar) {
1697 p->translate(r.left(), r.top() + r.width());
1699 p->translate(-r.left(), -r.top());
1702 bool floating =
false;
1703 bool active = dwOpt->state & State_Active;
1704 QColor inactiveCaptionTextColor = d->inactiveCaptionText;
1705 if (dwOpt->movable) {
1709 if (opt->state & QStyle::State_Window) {
1712 left = d->activeCaptionColor;
1713 right = d->activeGradientCaptionColor;
1715 left = d->inactiveCaptionColor;
1716 right = d->inactiveGradientCaptionColor;
1718 QBrush fillBrush(left);
1719 if (left != right) {
1720 QPoint p1(r.x(), r.top() + r.height()/2);
1721 QPoint p2(rect.right(), r.top() + r.height()/2);
1722 QLinearGradient lg(p1, p2);
1723 lg.setColorAt(0, left);
1724 lg.setColorAt(1, right);
1727 p->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
1730 if (!dwOpt->title.isEmpty()) {
1731 QFont oldFont = p->font();
1733 QFont font = oldFont;
1737 QPalette palette = dwOpt->palette;
1738 palette.setColor(QPalette::Window, inactiveCaptionTextColor);
1739 QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, opt, widget);
1740 if (verticalTitleBar) {
1741 titleRect = QRect(r.left() + rect.bottom()
1742 - titleRect.bottom(),
1743 r.top() + titleRect.left() - rect.left(),
1744 titleRect.height(), titleRect.width());
1746 proxy()->drawItemText(p, titleRect,
1747 Qt::AlignLeft | Qt::AlignVCenter, palette,
1748 dwOpt->state & State_Enabled, dwOpt->title,
1749 floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText);
1750 p->setFont(oldFont);
1752 if (verticalTitleBar)
1757#if 0
&& QT_CONFIG(combobox)
1758 case CE_ComboBoxLabel:
1759 if (
const QStyleOptionComboBox *cb = qstyleoption_cast<
const QStyleOptionComboBox *>(opt)) {
1760 if (cb->state & State_HasFocus) {
1761 p->setPen(cb->palette.highlightedText().color());
1762 p->setBackground(cb->palette.highlight());
1764 p->setPen(cb->palette.text().color());
1765 p->setBackground(cb->palette.window());
1768 QCommonStyle::drawControl(ce, opt, p, widget);
1772 QCommonStyle::drawControl(ce, opt, p);
1824#if QT_CONFIG(slider)
1826 if (
const QStyleOptionSlider *slider = qstyleoption_cast<
const QStyleOptionSlider *>(opt)) {
1827 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider);
1828 int len = proxy()->pixelMetric(PM_SliderLength, slider);
1829 int ticks = slider->tickPosition;
1830 QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove);
1831 QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle);
1833 if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
1834 int mid = thickness / 2;
1836 if (ticks & QStyleOptionSlider::TicksAbove)
1838 if (ticks & QStyleOptionSlider::TicksBelow)
1841 p->setPen(slider->palette.shadow().color());
1842 if (slider->orientation == Qt::Horizontal) {
1843 qDrawWinPanel(p, groove.x(), groove.y() + mid - 2,
1844 groove.width(), 4, slider->palette,
true);
1845 p->drawLine(groove.x() + 1, groove.y() + mid - 1,
1846 groove.x() + groove.width() - 3, groove.y() + mid - 1);
1848 qDrawWinPanel(p, groove.x() + mid - 2, groove.y(),
1849 4, groove.height(), slider->palette,
true);
1850 p->drawLine(groove.x() + mid - 1, groove.y() + 1,
1851 groove.x() + mid - 1, groove.y() + groove.height() - 3);
1855 if (slider->subControls & SC_SliderTickmarks) {
1856 QStyleOptionSlider tmpSlider = *slider;
1857 tmpSlider.subControls = SC_SliderTickmarks;
1858 QCommonStyle::drawComplexControl(cc, &tmpSlider, p);
1861 if (slider->subControls & SC_SliderHandle) {
1871 const QColor c0 = slider->palette.shadow().color();
1872 const QColor c1 = slider->palette.dark().color();
1874 const QColor c3 = slider->palette.midlight().color();
1875 const QColor c4 = slider->palette.light().color();
1878 if (slider->state & State_Enabled) {
1879 handleBrush = slider->palette.color(QPalette::Button);
1881 handleBrush = QBrush(slider->palette.color(QPalette::Button),
1886 int x = handle.x(), y = handle.y(),
1887 wi = handle.width(), he = handle.height();
1894 Qt::Orientation orient = slider->orientation;
1895 bool tickAbove = slider->tickPosition == QStyleOptionSlider::TicksAbove;
1896 bool tickBelow = slider->tickPosition == QStyleOptionSlider::TicksBelow;
1898 if (slider->state & State_HasFocus) {
1899 QStyleOptionFocusRect fropt;
1900 fropt.QStyleOption::operator=(*slider);
1901 fropt.rect = subElementRect(SE_SliderFocusRect, slider);
1902 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p);
1905 if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
1906 Qt::BGMode oldMode = p->backgroundMode();
1907 p->setBackgroundMode(Qt::OpaqueMode);
1908 qDrawWinButton(p, QRect(x, y, wi, he), slider->palette,
false,
1910 p->setBackgroundMode(oldMode);
1914 QSliderDirection dir;
1916 if (orient == Qt::Horizontal)
1933 d = (wi + 1) / 2 - 1;
1934 a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d);
1938 d = (wi + 1) / 2 - 1;
1939 a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1);
1942 d = (he + 1) / 2 - 1;
1944 a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
1947 d = (he + 1) / 2 - 1;
1949 a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1);
1953 QBrush oldBrush = p->brush();
1954 p->setPen(Qt::NoPen);
1955 p->setBrush(handleBrush);
1956 Qt::BGMode oldMode = p->backgroundMode();
1957 p->setBackgroundMode(Qt::OpaqueMode);
1958 p->drawRect(x1, y1, x2-x1+1, y2-y1+1);
1960 p->setBrush(oldBrush);
1961 p->setBackgroundMode(oldMode);
1965 p->drawLine(x1, y1, x2, y1);
1967 p->drawLine(x1, y1+1, x2, y1+1);
1969 if (dir != SlLeft) {
1971 p->drawLine(x1+1, y1+1, x1+1, y2);
1973 p->drawLine(x1, y1, x1, y2);
1975 if (dir != SlRight) {
1977 p->drawLine(x2, y1, x2, y2);
1979 p->drawLine(x2-1, y1+1, x2-1, y2-1);
1981 if (dir != SlDown) {
1983 p->drawLine(x1, y2, x2, y2);
1985 p->drawLine(x1+1, y2-1, x2-1, y2-1);
1991 p->drawLine(x1, y1, x1+d, y1-d);
1994 p->drawLine(x2, y1, x2-d, y1-d);
1997 p->drawLine(x1+1, y1, x1+1+d, y1-d);
1999 p->drawLine(x2-1, y1, x2-1-d, y1-d);
2003 p->drawLine(x1, y2, x1+d, y2+d);
2006 p->drawLine(x2, y2, x2-d, y2+d);
2009 p->drawLine(x1+1, y2, x1+1+d, y2+d);
2011 p->drawLine(x2-1, y2, x2-1-d, y2+d);
2015 p->drawLine(x1, y1, x1-d, y1+d);
2018 p->drawLine(x1, y2, x1-d, y2-d);
2021 p->drawLine(x1, y1+1, x1-d, y1+1+d);
2023 p->drawLine(x1, y2-1, x1-d, y2-1-d);
2027 p->drawLine(x2, y1, x2+d, y1+d);
2030 p->drawLine(x2, y2, x2+d, y2-d);
2033 p->drawLine(x2, y1+1, x2+d, y1+1+d);
2035 p->drawLine(x2, y2-1, x2+d, y2-1-d);
2042#if QT_CONFIG(scrollbar)
2044 if (
const QStyleOptionSlider *scrollbar = qstyleoption_cast<
const QStyleOptionSlider *>(opt)) {
2045 QStyleOptionSlider newScrollbar = *scrollbar;
2046 if (scrollbar->minimum == scrollbar->maximum)
2047 newScrollbar.state &= ~State_Enabled;
2048 QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
2052#if QT_CONFIG(combobox)
2054 if (
const QStyleOptionComboBox *cmb = qstyleoption_cast<
const QStyleOptionComboBox *>(opt)) {
2055 QBrush editBrush = cmb->palette.brush(QPalette::Button);
2056 if ((cmb->subControls & SC_ComboBoxFrame)) {
2058 QPalette shadePal = opt->palette;
2059 shadePal.setColor(QPalette::Midlight, shadePal.button().color());
2060 qDrawWinPanel(p, opt->rect, shadePal,
true, &editBrush);
2063 p->fillRect(opt->rect, editBrush);
2066 if (cmb->subControls & SC_ComboBoxArrow) {
2067 State flags = State_None;
2069 QRect ar = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
2070 bool sunkenArrow = cmb->activeSubControls == SC_ComboBoxArrow
2071 && cmb->state & State_Sunken;
2073 p->setPen(cmb->palette.dark().color());
2074 p->setBrush(cmb->palette.brush(QPalette::Button));
2075 p->drawRect(ar.adjusted(0,0,-1,-1));
2078 QPalette pal(cmb->palette);
2079 pal.setColor(QPalette::Button, cmb->palette.light().color());
2080 pal.setColor(QPalette::Light, cmb->palette.button().color());
2081 qDrawWinButton(p, ar, pal,
false,
2082 &cmb->palette.brush(QPalette::Button));
2085 ar.adjust(2, 2, -2, -2);
2086 if (opt->state & State_Enabled)
2087 flags |= State_Enabled;
2088 if (opt->state & State_HasFocus)
2089 flags |= State_HasFocus;
2092 flags |= State_Sunken;
2093 QStyleOption arrowOpt = *cmb;
2094 arrowOpt.rect = ar.adjusted(1, 1, -1, -1);
2095 arrowOpt.state = flags;
2096 proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
2099 if (cmb->subControls & SC_ComboBoxEditField) {
2100 QRect re = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
2101 if (cmb->state & State_HasFocus && !cmb->editable)
2102 p->fillRect(re.x(), re.y(), re.width(), re.height(),
2103 cmb->palette.brush(QPalette::Highlight));
2105 if (cmb->state & State_HasFocus) {
2106 p->setPen(cmb->palette.highlightedText().color());
2107 p->setBackground(cmb->palette.highlight());
2110 p->setPen(cmb->palette.text().color());
2111 p->setBackground(cmb->palette.window());
2114 if (cmb->state & State_HasFocus && !cmb->editable) {
2115 QStyleOptionFocusRect focus;
2116 focus.QStyleOption::operator=(*cmb);
2117 focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget);
2118 focus.state |= State_FocusAtBorder;
2119 focus.backgroundColor = cmb->palette.highlight().color();
2120 proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
2126#if QT_CONFIG(spinbox)
2128 if (
const QStyleOptionSpinBox *sb = qstyleoption_cast<
const QStyleOptionSpinBox *>(opt)) {
2129 QStyleOptionSpinBox copy = *sb;
2130 PrimitiveElement pe;
2131 bool enabled = opt->state & State_Enabled;
2132 if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
2133 QBrush editBrush = sb->palette.brush(QPalette::Base);
2134 QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);
2135 QPalette shadePal = sb->palette;
2136 shadePal.setColor(QPalette::Midlight, shadePal.button().color());
2137 qDrawWinPanel(p, r, shadePal,
true, &editBrush);
2140 QPalette shadePal(opt->palette);
2141 shadePal.setColor(QPalette::Button, opt->palette.light().color());
2142 shadePal.setColor(QPalette::Light, opt->palette.button().color());
2144 if (sb->subControls & SC_SpinBoxUp) {
2145 copy.subControls = SC_SpinBoxUp;
2146 QPalette pal2 = sb->palette;
2147 if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
2148 pal2.setCurrentColorGroup(QPalette::Disabled);
2149 copy.state &= ~State_Enabled;
2152 copy.palette = pal2;
2154 if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
2155 copy.state |= State_On;
2156 copy.state |= State_Sunken;
2158 copy.state |= State_Raised;
2159 copy.state &= ~State_Sunken;
2161 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
2162 : PE_IndicatorSpinUp);
2164 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);
2165 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
2166 ©.palette.brush(QPalette::Button));
2167 copy.rect.adjust(4, 1, -5, -1);
2168 if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled))
2169 && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
2171 QStyleOptionSpinBox lightCopy = copy;
2172 lightCopy.rect.adjust(1, 1, 1, 1);
2173 lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
2174 proxy()->drawPrimitive(pe, &lightCopy, p, widget);
2176 proxy()->drawPrimitive(pe, ©, p, widget);
2179 if (sb->subControls & SC_SpinBoxDown) {
2180 copy.subControls = SC_SpinBoxDown;
2181 copy.state = sb->state;
2182 QPalette pal2 = sb->palette;
2183 if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
2184 pal2.setCurrentColorGroup(QPalette::Disabled);
2185 copy.state &= ~State_Enabled;
2187 copy.palette = pal2;
2189 if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
2190 copy.state |= State_On;
2191 copy.state |= State_Sunken;
2193 copy.state |= State_Raised;
2194 copy.state &= ~State_Sunken;
2196 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
2197 : PE_IndicatorSpinDown);
2199 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
2200 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
2201 ©.palette.brush(QPalette::Button));
2202 copy.rect.adjust(4, 0, -5, -1);
2203 if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled))
2204 && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
2206 QStyleOptionSpinBox lightCopy = copy;
2207 lightCopy.rect.adjust(1, 1, 1, 1);
2208 lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
2209 proxy()->drawPrimitive(pe, &lightCopy, p, widget);
2211 proxy()->drawPrimitive(pe, ©, p, widget);
2217 QCommonStyle::drawComplexControl(cc, opt, p);
2220 QCommonStyle::drawComplexControl(cc, opt, p);