11#include <private/qstyleanimation_p.h>
12#include <private/qstylehelper_p.h>
13#include <qpa/qplatformnativeinterface.h>
14#include <private/qapplication_p.h>
15#include <private/qsystemlibrary_p.h>
31#ifndef TMT_CONTENTMARGINS
32# define TMT_CONTENTMARGINS 3602
34#ifndef TMT_SIZINGMARGINS
35# define TMT_SIZINGMARGINS 3601
40# define LISS_SELECTED 3
41# define LISS_DISABLED 4
42# define LISS_SELECTEDNOTFOCUS 5
43# define LISS_HOTSELECTED 6
46# define BP_COMMANDLINK 6
47# define BP_COMMANDLINKGLYPH 7
48# define CMDLGS_NORMAL 1
50# define CMDLGS_PRESSED 3
51# define CMDLGS_DISABLED 4
61 L
"BUTTON", L
"COMBOBOX", L
"EDIT", L
"HEADER", L
"LISTVIEW",
62 L
"MENU", L
"PROGRESS", L
"REBAR", L
"SCROLLBAR", L
"SPIN",
63 L
"TAB", L
"TASKDIALOG", L
"TOOLBAR", L
"TOOLTIP", L
"TRACKBAR",
64 L
"WINDOW", L
"STATUS", L
"TREEVIEW"
69HWND QWindowsVistaStylePrivate::m_vistaTreeViewHelper =
nullptr;
70HTHEME QWindowsVistaStylePrivate::m_themes[NThemes];
71bool QWindowsVistaStylePrivate::useVistaTheme =
false;
76 HRGN rgn = CreateRectRgn(
r.left(),
r.top(),
r.x() +
r.width(),
r.y() +
r.height());
78 HRGN dest = CreateRectRgn(0,0,0,0);
79 int result = CombineRgn(dest, winRegion, rgn, RGN_OR);
81 DeleteObject(winRegion);
90 HRGN hRegion = CreateRectRgn(0,0,0,0);
102 if (
const auto *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(
option))
122 result = nativeWindowsApp->createMessageWindow(
QStringLiteral(
"QTreeViewThemeHelperWindowClass"),
150 ?
QRectF(
r.topLeft() * factor,
r.size() * factor) :
r;
173 return useVistaTheme;
181 if (
ref.ref() && !force)
187 std::fill(m_themes, m_themes +
NThemes,
nullptr);
196 if (bufferDC && nullBitmap)
197 SelectObject(bufferDC, nullBitmap);
198 DeleteObject(bufferBitmap);
199 bufferBitmap =
nullptr;
206 if (
ref.deref() && !force)
211 useVistaTheme =
false;
217 BOOL animEnabled =
false;
218 if (SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &animEnabled, 0))
231 static const auto pOpenThemeDataForDpi =
232 reinterpret_cast<decltype(&::OpenThemeDataForDpi)
>(
233 QSystemLibrary::resolve(u
"uxtheme"_s,
"OpenThemeDataForDpi"));
238 return pOpenThemeDataForDpi(hwnd,
name, dpi);
242 return OpenThemeData(hwnd,
name);
264 ? GetSystemMetrics(SM_CYSMCAPTION) + GetSystemMetrics(SM_CXSIZEFRAME)
265 : GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CXSIZEFRAME);
274 return QWindowsVistaStylePrivate::InvalidMetric;
293 return QWindowsVistaStylePrivate::InvalidMetric;
296bool QWindowsVistaStylePrivate::initVistaTreeViewTheming()
298 if (m_vistaTreeViewHelper)
302 if (!m_vistaTreeViewHelper) {
303 qWarning(
"Unable to create the treeview helper window.");
306 if (FAILED(SetWindowTheme(m_vistaTreeViewHelper, L
"explorer",
nullptr))) {
308 cleanupVistaTreeViewTheming();
314void QWindowsVistaStylePrivate::cleanupVistaTreeViewTheming()
316 if (m_vistaTreeViewHelper) {
317 DestroyWindow(m_vistaTreeViewHelper);
318 m_vistaTreeViewHelper =
nullptr;
329 for (
auto &theme : m_themes) {
331 CloseThemeData(theme);
335 QWindowsVistaStylePrivate::cleanupVistaTreeViewTheming();
341 qWarning(
"Invalid parameters #%d, %p", theme, hwnd);
344 if (!m_themes[theme]) {
346 if (theme ==
VistaTreeViewTheme && QWindowsVistaStylePrivate::initVistaTreeViewTheming())
347 hwnd = QWindowsVistaStylePrivate::m_vistaTreeViewHelper;
354 return m_themes[theme];
362 if (
QBackingStore *topLevelBackingStore = topLevel->backingStore())
363 return topLevelBackingStore;
379 return theme >= 0 && theme <
NThemes
389 if (!parent1 || parent1->
isWindow())
393 && parent2->
inherits(
"QAbstractItemView");
399 uint resolveMask =
option->palette.resolveMask();
404#if QT_CONFIG(spinbox)
406 resolveMask |= spinbox->palette().resolveMask();
421 if (
const HWND hwnd = QApplicationPrivate::getHWNDForWidget(
const_cast<QWidget *
>(
widget)))
429 return reinterpret_cast<HWND
>(
window->winId());
432 return GetDesktopWindow();
444 if (bufferW >=
w && bufferH >=
h)
447 if (bufferDC && nullBitmap)
448 SelectObject(bufferDC, nullBitmap);
449 DeleteObject(bufferBitmap);
450 bufferBitmap =
nullptr;
457 HDC displayDC = GetDC(
nullptr);
458 bufferDC = CreateCompatibleDC(displayDC);
459 ReleaseDC(
nullptr, displayDC);
464 memset(&bmi, 0,
sizeof(bmi));
465 bmi.bmiHeader.biSize =
sizeof(BITMAPINFOHEADER);
466 bmi.bmiHeader.biWidth =
w;
467 bmi.bmiHeader.biHeight = -
h;
468 bmi.bmiHeader.biPlanes = 1;
469 bmi.bmiHeader.biBitCount = 32;
470 bmi.bmiHeader.biCompression = BI_RGB;
473 bufferPixels =
nullptr;
474 bufferBitmap = CreateDIBSection(bufferDC, &bmi, DIB_RGB_COLORS,
reinterpret_cast<void **
>(&bufferPixels),
nullptr, 0);
476 nullBitmap =
static_cast<HBITMAP
>(SelectObject(bufferDC, bufferBitmap));
479 qErrnoWarning(
"QWindowsVistaStylePrivate::buffer(%dx%d), CreateDIBSection() failed.",
w,
h);
485 qErrnoWarning(
"QWindowsVistaStylePrivate::buffer(%dx%d), CreateDIBSection() did not allocate pixel data.",
w,
h);
493 qDebug(
"Creating new dib section (%d, %d)",
w,
h);
506 return IsThemeBackgroundPartiallyTransparent(themeData.
handle(), themeData.
partId,
517 const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(themeData.
widget);
524 HRGN dest = CreateRectRgn(0, 0, 0, 0);
525 const bool success = CombineRgn(dest, hRgn,
nullptr, RGN_COPY) !=
ERROR;
531 RGNDATA *
rd =
reinterpret_cast<RGNDATA *
>(
buf.data());
532 if (GetRegionData(dest,
buf.size(),
rd) == 0) {
533 const auto numBytes = GetRegionData(dest, 0,
nullptr);
535 buf.resize(numBytes);
536 rd =
reinterpret_cast<RGNDATA *
>(
buf.data());
537 if (GetRegionData(dest, numBytes,
rd) == 0)
544 RECT *
r =
reinterpret_cast<RECT *
>(
rd->Buffer);
545 for (
uint i = 0;
i <
rd->rdh.nCount; ++
i) {
547 rect.setCoords(
int(
r->left * factor), int(
r->top * factor),
548 int((
r->right - 1) * factor), int((
r->bottom - 1) * factor));
567 const int startX =
rect.left();
568 const int startY =
rect.top();
569 const int w =
rect.width();
570 const int h =
rect.height();
573 for (
int y = startY;
y <
h/2; ++
y) {
574 auto buffer =
reinterpret_cast<const DWORD *
>(bufferPixels) + (
y * bufferW);
576 int alpha = (*buffer) >> 24;
577 if (firstAlpha == -1)
579 else if (
alpha != firstAlpha)
596 const int startX =
rect.left();
597 const int startY =
rect.top();
598 const int w =
rect.width();
599 const int h =
rect.height();
600 bool hasFixedAlphaValue =
false;
602 for (
int y = startY;
y <
h; ++
y) {
603 auto buffer =
reinterpret_cast<DWORD *
>(bufferPixels) + (
y * bufferW);
609 hasFixedAlphaValue =
true;
613 return hasFixedAlphaValue;
627 const int startX =
rect.left();
628 const int startY =
rect.top();
629 const int w =
rect.width();
630 const int h =
rect.height();
631 bool valueChange =
false;
634 for (
int y = startY;
y <
h; ++
y) {
635 auto buffer =
reinterpret_cast<DWORD *
>(bufferPixels) + (
y * bufferW);
641 unsigned int alphaValue = (*buffer) & 0xFF000000;
642 if (alphaValue == 0xFF000000) {
645 }
else if (alphaValue == 0) {
671 Q_ASSERT_X(
painter !=
nullptr,
"QWindowsVistaStylePrivate::drawBackground()",
"Trying to draw a theme part without a painter");
680 bool translucentToplevel =
false;
690 bool canDrawDirectly =
false;
694 && !translucentToplevel) {
697 switch (enginePaintDevice->
devType()) {
699 canDrawDirectly =
true;
704 if (bs->size().isValid() && bs->paintDevice() == enginePaintDevice)
705 canDrawDirectly =
true;
740 SelectClipRgn(dc, hrgn);
743 printf(
"---[ DIRECT PAINTING ]------------------> Name(%-10s) Part(%d) State(%d)\n",
745 showProperties(themeData);
749 DTBGOPTS drawOptions;
750 memset(&drawOptions, 0,
sizeof(drawOptions));
751 drawOptions.dwSize =
sizeof(drawOptions);
753 drawOptions.dwFlags = DTBG_CLIPRECT
754 | (themeData.
noBorder ? DTBG_OMITBORDER : 0)
755 | (themeData.
noContent ? DTBG_OMITCONTENT : 0)
759 SelectClipRgn(dc,
nullptr);
777 qreal additionalDevicePixelRatio,
778 qreal correctionFactor)
783 if ((themeData.
rotate + 90) % 180 == 0) {
790 const QRect drawRect = hasCorrectionFactor
793 int partId = themeData.
partId;
794 int stateId = themeData.
stateId;
795 int w =
rect.width();
796 int h =
rect.height();
800 bool stateHasData =
true;
802 bool partIsTransparent;
803 bool potentialInvalidAlpha;
821 if (hasCorrectionFactor) {
830 bool haveCachedPixmap =
false;
833 partIsTransparent =
data.partIsTransparent;
835 alphaType =
data.alphaType;
836 potentialInvalidAlpha =
data.hadInvalidAlpha;
842 ::sprintf(
buf,
"+ Pixmap(%3d, %3d) ]",
w,
h);
843 printf(
"---[ CACHED %s--------> Name(%-10s) Part(%d) State(%d)\n",
844 haveCachedPixmap ?
buf :
"]-------------------",
849 BOOL tmt_borderonly =
false;
850 COLORREF tmt_transparentcolor = 0x0;
851 PROPERTYORIGIN proporigin = PO_NOTFOUND;
852 GetThemeBool(themeData.
handle(), themeData.
partId, themeData.
stateId, TMT_BORDERONLY, &tmt_borderonly);
853 GetThemeColor(themeData.
handle(), themeData.
partId, themeData.
stateId, TMT_TRANSPARENTCOLOR, &tmt_transparentcolor);
854 GetThemePropertyOrigin(themeData.
handle(), themeData.
partId, themeData.
stateId, TMT_CAPTIONMARGINS, &proporigin);
858 potentialInvalidAlpha =
false;
859 GetThemePropertyOrigin(themeData.
handle(), themeData.
partId, themeData.
stateId, TMT_GLYPHTYPE, &proporigin);
860 if (proporigin == PO_PART || proporigin == PO_STATE) {
861 int tmt_glyphtype = GT_NONE;
862 GetThemeEnumValue(themeData.
handle(), themeData.
partId, themeData.
stateId, TMT_GLYPHTYPE, &tmt_glyphtype);
863 potentialInvalidAlpha = partIsTransparent && tmt_glyphtype == GT_IMAGEGLYPH;
867 printf(
"---[ NOT CACHED ]-----------------------> Name(%-10s) Part(%d) State(%d)\n",
869 printf(
"-->partIsTransparen = %d\n", partIsTransparent);
870 printf(
"-->potentialInvalidAlpha = %d\n", potentialInvalidAlpha);
871 showProperties(themeData);
874 bool wasAlphaSwapped =
false;
875 bool wasAlphaFixed =
false;
881 bool addBorderContentClipping =
false;
891 PROPERTYORIGIN origin = PO_NOTFOUND;
892 GetThemePropertyOrigin(themeData.
handle(), themeData.
partId, themeData.
stateId, TMT_BORDERSIZE, &origin);
893 GetThemeInt(themeData.
handle(), themeData.
partId, themeData.
stateId, TMT_BORDERSIZE, &borderSize);
894 borderSize *= additionalDevicePixelRatio;
897 if ((origin == PO_CLASS || origin == PO_PART || origin == PO_STATE) && borderSize > 0) {
900 area =
area.adjusted(-borderSize, -borderSize, borderSize, borderSize);
905 QRegion content =
area.adjusted(borderSize, borderSize, -borderSize, -borderSize);
906 extraClip ^= content;
913 if (!haveCachedPixmap) {
921 memset(bufferPixels, 0x00, bufferW * drawRect.
height() * 4);
925 int dx =
area.x() - drawRect.
x();
926 int dy =
area.y() - drawRect.
y();
931 DTBGOPTS drawOptions;
932 drawOptions.dwSize =
sizeof(drawOptions);
934 drawOptions.dwFlags = DTBG_CLIPRECT
935 | (themeData.
noBorder ? DTBG_OMITBORDER : 0)
936 | (themeData.
noContent ? DTBG_OMITCONTENT : 0);
940 DrawThemeBackgroundEx(themeData.
handle(), dc, themeData.
partId, themeData.
stateId, &wRect, &drawOptions);
947 memset(
static_cast<void *
>(&
data), 0,
sizeof(
data));
948 data.dataValid =
true;
954 potentialInvalidAlpha =
true;
955#if defined(DEBUG_XP_STYLE) && 1
956 dumpNativeDIB(drawRect.
width(), drawRect.
height());
961 if (potentialInvalidAlpha)
965 if ((partIsTransparent && !wasAlphaSwapped) || (!partIsTransparent &&
hasAlpha)) {
968 }
else if (wasAlphaSwapped) {
980#if defined(DEBUG_XP_STYLE) && 1
981 printf(
"Image format is: %s\n", alphaType ==
RealAlpha ?
"Real Alpha" : alphaType ==
MaskAlpha ?
"Masked Alpha" :
"No Alpha");
987 if (hasCorrectionFactor)
989 img.setDevicePixelRatio(additionalDevicePixelRatio);
993 bool useRegion = partIsTransparent && !
hasAlpha && !wasAlphaSwapped;
998 newRegion =
region(themeData);
1001#if defined(DEBUG_XP_STYLE) && 0
1002 printf(
"Using region:\n");
1003 for (
const QRect &
r : newRegion)
1004 printf(
" (%d, %d, %d, %d)\n",
r.x(),
r.y(),
r.right(),
r.bottom());
1008 if (addBorderContentClipping)
1012 if (!haveCachedPixmap)
1023 if (!haveCachedPixmap)
1026 imgCopy = cachedPixmap.
toImage();
1038 if (useRegion || addBorderContentClipping) {
1046 if (!haveCachedPixmap &&
w &&
h) {
1049#ifdef DEBUG_XP_STYLE
1050 printf(
"+++Adding pixmap to cache, size(%d, %d), wasAlphaSwapped(%d), wasAlphaFixed(%d), name(%s)\n",
1051 w,
h, wasAlphaSwapped, wasAlphaFixed,
qPrintable(pixmapCacheKey));
1057 memset(
static_cast<void *
>(&
data), 0,
sizeof(
data));
1058 data.dataValid =
true;
1059 data.partIsTransparent = partIsTransparent;
1060 data.alphaType = alphaType;
1062 data.wasAlphaSwapped = wasAlphaSwapped;
1063 data.hadInvalidAlpha = wasAlphaFixed;
1079 static bool animationTimeOverride =
q->dynamicPropertyNames().contains(
"_qt_animation_time");
1080 if (animationTimeOverride)
1081 return q->property(
"_qt_animation_time").toTime();
1098 && !
option->styleObject->property(
"_q_no_animation").toBool();
1106 result.setDevicePixelRatio(devicePixelRatio);
1116 if (
const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(
option))
1117 styleOption =
new QStyleOptionSlider(*slider);
1118 else if (
const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox*>(
option))
1119 styleOption =
new QStyleOptionSpinBox(*spinbox);
1137 if (
const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(
option))
1139 else if (
const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox*>(
option))
1154 bool isTitleBarActive,
int part,
1160 theme->
stateId = RBS_DISABLED;
1165 else if (!isTitleBarActive)
1171#if QT_CONFIG(mdiarea)
1196 const auto dpr = pd ? pd->devicePixelRatio() :
qApp->devicePixelRatio();
1199 const auto rawFactor =
qMin(requestedSize.width() / nativeSize.
width(),
1200 requestedSize.height() / nativeSize.
height());
1215 bool retVal =
false;
1261 if (partId == BP_RADIOBUTTON || partId == BP_CHECKBOX) {
1263 stateId = RBS_UNCHECKEDDISABLED;
1265 stateId = RBS_UNCHECKEDPRESSED;
1267 stateId = RBS_UNCHECKEDHOT;
1269 stateId = RBS_UNCHECKEDNORMAL;
1272 stateId += RBS_CHECKEDNORMAL-1;
1274 }
else if (partId == BP_PUSHBUTTON) {
1276 stateId = PBS_DISABLED;
1278 stateId = PBS_PRESSED;
1282 stateId = PBS_NORMAL;
1391 bool doTransition = oldState &&
1392 ((
state & State_Sunken) != (oldState & State_Sunken) ||
1393 (
state & State_On) != (oldState & State_On) ||
1394 (
state & State_MouseOver) != (oldState & State_MouseOver));
1396 if (oldRect != newRect ||
1397 (
state & State_Enabled) != (oldState & State_Enabled) ||
1398 (
state & State_Active) != (oldState & State_Active))
1401 if (
state & State_ReadOnly && element == PE_FrameLineEdit)
1402 doTransition =
false;
1406 styleOption->
state = QStyle::State(oldState);
1414 QPainter startPainter(&startImage);
1423 proxy()->drawPrimitive(element, styleOption, &startPainter,
widget);
1425 animate->
paint(&startPainter, styleOption);
1433 proxy()->drawPrimitive(element, styleOption, &endPainter,
widget);
1444 if (element == PE_FrameLineEdit) {
1445 theme = OpenThemeData(
nullptr, L
"Edit");
1446 partId = EP_EDITBORDER_NOSCROLL;
1448 if (oldState & State_MouseOver)
1449 fromState = ETS_HOT;
1450 else if (oldState & State_HasFocus)
1451 fromState = ETS_FOCUSED;
1453 fromState = ETS_NORMAL;
1455 if (
state & State_MouseOver)
1457 else if (
state & State_HasFocus)
1458 toState = ETS_FOCUSED;
1460 toState = ETS_NORMAL;
1463 theme = OpenThemeData(
nullptr, L
"Button");
1464 if (element == PE_IndicatorRadioButton)
1465 partId = BP_RADIOBUTTON;
1466 else if (element == PE_IndicatorCheckBox)
1467 partId = BP_CHECKBOX;
1469 partId = BP_PUSHBUTTON;
1477 && SUCCEEDED(GetThemeTransitionDuration(theme, partId, fromState, toState,
1478 TMT_TRANSITIONDURATIONS, &duration))) {
1484 d->startAnimation(transition);
1490 int themeNumber = -1;
1493 bool hMirrored =
false;
1494 bool vMirrored =
false;
1495 bool noBorder =
false;
1496 bool noContent =
false;
1500 case PE_PanelButtonCommand:
1501 if (
const auto *
btn = qstyleoption_cast<const QStyleOptionButton *>(
option)) {
1503 if (!(
state & State_Sunken) && (
state & State_On))
1511 }
else if (
state & (State_Raised | State_On | State_Sunken)) {
1520 case PE_PanelButtonTool:
1521#if QT_CONFIG(dockwidget)
1524 if (dw->isWindow()) {
1531 if (!(
option->state & State_Enabled))
1532 stateId = TS_DISABLED;
1533 else if (
option->state & State_Sunken)
1534 stateId = TS_PRESSED;
1535 else if (
option->state & State_MouseOver)
1536 stateId =
option->state & State_On ? TS_HOTCHECKED : TS_HOT;
1537 else if (
option->state & State_On)
1538 stateId = TS_CHECKED;
1539 else if (!(
option->state & State_AutoRaise))
1542 stateId = TS_NORMAL;
1546 case PE_IndicatorHeaderArrow:
1547 if (
const auto *
header = qstyleoption_cast<const QStyleOptionHeader *>(
option)) {
1548 int stateId = HSAS_SORTEDDOWN;
1550 stateId = HSAS_SORTEDUP;
1553 HP_HEADERSORTARROW, stateId,
option->rect);
1554 d->drawBackground(theme);
1559 case PE_IndicatorCheckBox:
1566 partId = BP_CHECKBOX;
1568 if (!(
option->state & State_Enabled))
1569 stateId = CBS_UNCHECKEDDISABLED;
1570 else if (
option->state & State_Sunken)
1571 stateId = CBS_UNCHECKEDPRESSED;
1572 else if (
option->state & State_MouseOver)
1573 stateId = CBS_UNCHECKEDHOT;
1575 stateId = CBS_UNCHECKEDNORMAL;
1577 if (
option->state & State_On)
1578 stateId += CBS_CHECKEDNORMAL-1;
1579 else if (
option->state & State_NoChange)
1580 stateId += CBS_MIXEDNORMAL-1;
1584 case PE_IndicatorItemViewItemCheck: {
1586 button.QStyleOption::operator=(*option);
1587 button.state &= ~State_MouseOver;
1592 case PE_IndicatorBranch: {
1594 static int decoration_size = 0;
1595 if (!decoration_size && theme.
isValid()) {
1597 themeSize.
partId = TVP_HOTGLYPH;
1598 themeSize.
stateId = GLPS_OPENED;
1602 int mid_h =
option->rect.x() +
option->rect.width() / 2;
1603 int mid_v =
option->rect.y() +
option->rect.height() / 2;
1604 if (
option->state & State_Children) {
1605 int delta = decoration_size / 2;
1606 theme.
rect =
QRect(mid_h - delta, mid_v - delta, decoration_size, decoration_size);
1607 theme.
partId =
option->state & State_MouseOver ? TVP_HOTGLYPH : TVP_GLYPH;
1611 d->drawBackground(theme);
1616 case PE_PanelButtonBevel:
1624 partId = BP_PUSHBUTTON;
1625 if (!(
option->state & State_Enabled))
1626 stateId = PBS_DISABLED;
1627 else if ((
option->state & State_Sunken) || (
option->state & State_On))
1628 stateId = PBS_PRESSED;
1629 else if (
option->state & State_MouseOver)
1632 stateId = PBS_NORMAL;
1635 case PE_IndicatorRadioButton:
1642 partId = BP_RADIOBUTTON;
1644 if (!(
option->state & State_Enabled))
1645 stateId = RBS_UNCHECKEDDISABLED;
1646 else if (
option->state & State_Sunken)
1647 stateId = RBS_UNCHECKEDPRESSED;
1648 else if (
option->state & State_MouseOver)
1649 stateId = RBS_UNCHECKEDHOT;
1651 stateId = RBS_UNCHECKEDNORMAL;
1653 if (
option->state & State_On)
1654 stateId += RBS_CHECKEDNORMAL-1;
1659#if QT_CONFIG(accessibility)
1660 if (QStyleHelper::isInstanceOf(
option->styleObject, QAccessible::EditableText)
1661 || QStyleHelper::isInstanceOf(
option->styleObject, QAccessible::StaticText) ||
1667 int stateId = ETS_NORMAL;
1668 if (!(state & State_Enabled))
1669 stateId = ETS_DISABLED;
1670 else if (state & State_ReadOnly)
1671 stateId = ETS_READONLY;
1672 else if (state & State_HasFocus)
1673 stateId = ETS_SELECTED;
1674 QWindowsThemeData theme(widget, painter,
1675 QWindowsVistaStylePrivate::EditTheme,
1676 EP_EDITBORDER_HVSCROLL, stateId, option->rect);
1679 GetThemeInt(theme.handle(), theme.partId, theme.stateId, TMT_BORDERSIZE, &borderSize);
1680 QRegion clipRegion = option->rect;
1681 QRegion content = option->rect.adjusted(borderSize, borderSize, -borderSize, -borderSize);
1682 clipRegion ^= content;
1683 painter->setClipRegion(clipRegion);
1684 d->drawBackground(theme);
1688 if (option->state & State_Raised)
1691 themeNumber = QWindowsVistaStylePrivate::ListViewTheme;
1692 partId = LVP_LISTGROUP;
1693 QWindowsThemeData theme(widget, nullptr, themeNumber, partId);
1695 if (!(option->state & State_Enabled))
1696 stateId = ETS_DISABLED;
1698 stateId = ETS_NORMAL;
1702 if (GetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &fillType) == S_OK) {
1703 if (fillType == BT_BORDERFILL) {
1705 GetThemeColor(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &bcRef);
1706 QColor bordercolor(qRgb(GetRValue(bcRef), GetGValue(bcRef), GetBValue(bcRef)));
1707 QPen oldPen = painter->pen();
1710 painter->setPen(QPen(option->palette.base().color(), 0));
1711 const qreal dpi = QStyleHelper::dpi(option);
1712 const auto topLevelAdjustment = QStyleHelper::dpiScaled(0.5, dpi);
1713 const auto bottomRightAdjustment = QStyleHelper::dpiScaled(-1, dpi);
1714 painter->drawRect(QRectF(option->rect).adjusted(topLevelAdjustment, topLevelAdjustment,
1715 bottomRightAdjustment, bottomRightAdjustment));
1717 painter->setPen(QPen(bordercolor, 0));
1718 painter->drawRect(QRectF(option->rect).adjusted(0, 0, -topLevelAdjustment, -topLevelAdjustment));
1719 painter->setPen(oldPen);
1722 if (fillType == BT_BORDERFILL || fillType == BT_NONE)
1728 case PE_FrameMenu: {
1729 int stateId =
option->state & State_Active ? MB_ACTIVE : MB_INACTIVE;
1732 MENU_POPUPBORDERS, stateId,
option->rect);
1733 d->drawBackground(theme);
1737 case PE_PanelMenuBar:
1740#if QT_CONFIG(dockwidget)
1741 case PE_IndicatorDockWidgetResizeHandle:
1744 case PE_FrameDockWidget:
1745 if (
const auto *frm = qstyleoption_cast<const QStyleOptionFrame *>(
option)) {
1747 if (
option->state & State_Active)
1748 stateId = FS_ACTIVE;
1750 stateId = FS_INACTIVE;
1752 int fwidth =
proxy()->pixelMetric(PM_DockWidgetFrameWidth, frm,
widget);
1759 theme.
rect =
QRect(frm->rect.x(), frm->rect.y(), frm->rect.x()+fwidth, frm->rect.height()-fwidth);
1760 theme.
partId = WP_SMALLFRAMELEFT;
1761 d->drawBackground(theme);
1762 theme.
rect =
QRect(frm->rect.width()-fwidth, frm->rect.y(), fwidth, frm->rect.height()-fwidth);
1763 theme.
partId = WP_SMALLFRAMERIGHT;
1764 d->drawBackground(theme);
1765 theme.
rect =
QRect(frm->rect.x(), frm->rect.bottom()-fwidth+1, frm->rect.width(), fwidth);
1766 theme.
partId = WP_SMALLFRAMEBOTTOM;
1767 d->drawBackground(theme);
1773 case PE_FrameTabWidget:
1774 if (
const auto *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(
option)) {
1779 bool useGradient =
true;
1780 const int maxlength = 256;
1781 wchar_t themeFileName[maxlength];
1782 wchar_t themeColor[maxlength];
1784 if (GetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength,
nullptr, 0) == S_OK) {
1785 wchar_t *
offset =
nullptr;
1788 if (!lstrcmp(
offset, L
"Luna.msstyles") && !lstrcmp(
offset, L
"Metallic"))
1789 useGradient =
false;
1795 QStyleOptionTabWidgetFrame frameOpt = *tab;
1799 reg -= contentsRect;
1804 d->drawBackground(theme);
1809 switch (tab->shape) {
1832 case PE_FrameStatusBarItem:
1837 case PE_FrameWindow:
1838 if (
const auto *frm = qstyleoption_cast<const QStyleOptionFrame *>(
option)) {
1840 if (
option->state & State_Active)
1841 stateId = FS_ACTIVE;
1843 stateId = FS_INACTIVE;
1845 int fwidth = int((frm->lineWidth + frm->midLineWidth) / QWindowsStylePrivate::nativeMetricScaleFactor(
widget));
1853 theme.
partId = WP_FRAMELEFT;
1854 if (!
d->drawBackground(theme)) {
1859 theme.
partId = WP_FRAMERIGHT;
1860 if (!
d->drawBackground(theme)) {
1865 theme.
partId = WP_FRAMEBOTTOM;
1866 if (!
d->drawBackground(theme)) {
1871 theme.
partId = WP_CAPTION;
1872 if (!
d->drawBackground(theme))
1878 case PE_PanelLineEdit:
1879 if (
const auto *
panel = qstyleoption_cast<const QStyleOptionFrame *>(
option)) {
1880 bool isEnabled =
state & State_Enabled;
1884 int partId = EP_BACKGROUND;
1885 int stateId = EBS_NORMAL;
1887 stateId = EBS_DISABLED;
1888 else if (
option->state & State_ReadOnly)
1889 stateId = EBS_READONLY;
1890 else if (
option->state & State_MouseOver)
1894 partId, stateId,
rect);
1900 GetThemeEnumValue(theme.
handle(), partId, stateId, TMT_BGTYPE, &bgType);
1901 if (bgType == BT_IMAGEFILE) {
1902 d->drawBackground(theme);
1906 PROPERTYORIGIN origin = PO_NOTFOUND;
1907 GetThemePropertyOrigin(theme.
handle(), theme.
partId, theme.
stateId, TMT_FILLCOLOR, &origin);
1909 if ((origin == PO_PART || origin == PO_STATE)) {
1911 GetThemeColor(theme.
handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
1912 fillColor =
QBrush(
qRgb(GetRValue(bgRef), GetGValue(bgRef), GetBValue(bgRef)));
1918 if (
panel->lineWidth > 0)
1923 case PE_IndicatorButtonDropDown:
1925 partId = TP_SPLITBUTTONDROPDOWN;
1926 if (!(
option->state & State_Enabled))
1927 stateId = TS_DISABLED;
1928 else if (
option->state & State_Sunken)
1929 stateId = TS_PRESSED;
1930 else if (
option->state & State_MouseOver)
1931 stateId =
option->state & State_On ? TS_HOTCHECKED : TS_HOT;
1932 else if (
option->state & State_On)
1933 stateId = TS_CHECKED;
1934 else if (!(
option->state & State_AutoRaise))
1937 stateId = TS_NORMAL;
1942 case PE_FrameLineEdit:
1958 int stateId = ETS_NORMAL;
1959 if (!(
state & State_Enabled))
1960 stateId = ETS_DISABLED;
1961 else if (
state & State_ReadOnly)
1962 stateId = ETS_READONLY;
1963 else if (
state & State_MouseOver)
1965 else if (
state & State_HasFocus)
1966 stateId = ETS_SELECTED;
1969 EP_EDITBORDER_NOSCROLL, stateId,
option->rect);
1973 clipRegion -=
option->rect.adjusted(2, 2, -2, -2);
1975 d->drawBackground(theme);
1980 case PE_FrameGroupBox:
1982 partId = BP_GROUPBOX;
1983 if (!(
option->state & State_Enabled))
1984 stateId = GBS_DISABLED;
1986 stateId = GBS_NORMAL;
1987 if (
const auto *
frame = qstyleoption_cast<const QStyleOptionFrame *>(
option)) {
1999 case PE_IndicatorToolBarHandle: {
2002 if (
option->state & State_Horizontal) {
2005 RP_GRIPPER, ETS_NORMAL,
option->rect.adjusted(0, 1, -2, -2));
2010 RP_GRIPPERVERT, ETS_NORMAL,
option->rect.adjusted(0, 1, -2, -2));
2015 d->drawBackground(theme);
2019 case PE_IndicatorToolBarSeparator: {
2023 if (
option->state & State_Horizontal) {
2024 int x1 =
option->rect.center().x();
2027 int y1 =
option->rect.center().y();
2034 case PE_PanelTipLabel: {
2037 TTP_STANDARD, TTSS_NORMAL,
option->rect);
2038 d->drawBackground(theme);
2042 case PE_FrameTabBarBase:
2043 if (
const auto *tbb = qstyleoption_cast<const QStyleOptionTabBarBase *>(
option)) {
2045 switch (tbb->shape) {
2052 painter->
drawLine(tbb->rect.left(), tbb->rect.top(), tbb->rect.left(), tbb->rect.bottom());
2057 tbb->rect.right(), tbb->rect.top());
2076#if QT_CONFIG(dialogbuttonbox)
2078 if (qobject_cast<const QMessageBox *> (
widget))
2080#if QT_CONFIG(inputdialog)
2081 else if (qobject_cast<const QInputDialog *> (
widget))
2088 TDLG_PRIMARYPANEL, 0,
option->rect);
2091 theme.
rect = toprect;
2092 d->drawBackground(theme);
2097 theme.
rect = buttonRect;
2098 theme.
partId = TDLG_SECONDARYPANEL;
2099 d->drawBackground(theme);
2105 case PE_PanelItemViewItem: {
2106 const QStyleOptionViewItem *vopt;
2107 bool newStyle =
true;
2111 newStyle = !qobject_cast<const QTableView*>(
view);
2112 selectionBehavior =
view->selectionBehavior();
2113 selectionMode =
view->selectionMode();
2114#if QT_CONFIG(accessibility)
2116 newStyle = !QStyleHelper::hasAncestor(
option->styleObject, QAccessible::MenuItem) ;
2120 if (newStyle && (vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
option))) {
2125 if (vopt->features & QStyleOptionViewItem::Alternate)
2134 itemRect.
setTop(vopt->rect.top());
2135 itemRect.
setBottom(vopt->rect.bottom());
2138 if (vopt->showDecorationSelected)
2139 sectionSize = vopt->rect.size();
2142 sectionSize.
setWidth(vopt->rect.width());
2145 if (vopt->backgroundBrush.style() !=
Qt::NoBrush) {
2152 if (hover || selected) {
2153 if (sectionSize.
width() > 0 && sectionSize.
height() > 0) {
2161 if (selected && hover)
2163 else if (selected && !active)
2179 d->drawBackground(theme);
2184 if (vopt->showDecorationSelected) {
2185 const int frame = 2;
2187 QRect pixmapRect = vopt->rect;
2189 bool leftSection = vopt->viewItemPosition == QStyleOptionViewItem::Beginning;
2190 bool rightSection = vopt->viewItemPosition == QStyleOptionViewItem::End;
2191 if (vopt->viewItemPosition == QStyleOptionViewItem::OnlyOne
2192 || vopt->viewItemPosition == QStyleOptionViewItem::Invalid)
2194 else if (reverse ? rightSection : leftSection){
2200 }
else if (reverse ? leftSection : rightSection) {
2207 }
else if (vopt->viewItemPosition == QStyleOptionViewItem::Middle)
2211 if (vopt->text.isEmpty() && vopt->icon.isNull())
2238 d->drawBackground(theme);
2249 case SH_EtchDisabledText:
2250 ret = (qobject_cast<const QLabel*>(
widget) != 0);
2253 case SH_SpinControls_DisableOnBounds:
2257 case SH_TitleBar_AutoRaise:
2258 case SH_TitleBar_NoBorder:
2262 case SH_GroupBox_TextLabelColor:
2264 ret =
d->groupBoxTextColor;
2266 ret =
d->groupBoxTextColorDisabled;
2269 case SH_WindowFrame_Mask: {
2271 auto *
mask = qstyleoption_cast<QStyleHintReturnMask *>(returnData);
2272 const auto *titlebar = qstyleoption_cast<const QStyleOptionTitleBar *>(
option);
2273 if (
mask && titlebar) {
2284 WP_MINCAPTION, CS_ACTIVE, titleBarRect);
2288 WP_CAPTION, CS_ACTIVE, titleBarRect);
2289 mask->region =
d->region(themeData) +
2295#if QT_CONFIG(rubberband)
2296 case SH_RubberBand_Mask:
2297 if (qstyleoption_cast<const QStyleOptionRubberBand *>(
option))
2302 case SH_MessageBox_CenterButtons:
2306 case SH_ToolTip_Mask:
2312 TTP_STANDARD, TTSS_NORMAL,
option->rect);
2313 mask->region =
d->region(themeData);
2318 case SH_Table_GridLineColor:
2325 case SH_Header_ArrowAlignment:
2329 case SH_ItemView_DrawDelegateFrame:
2357 bool selected =
option->state & State_Selected;
2358 bool pressed =
option->state & State_Sunken;
2362 int themeNumber = -1;
2370 if (element == CE_PushButtonBevel) {
2382 bool wasDefault =
false;
2383 bool isDefault =
false;
2390 bool doTransition = ((
state & State_Sunken) != (oldState & State_Sunken) ||
2391 (
state & State_On) != (oldState & State_On) ||
2392 (
state & State_MouseOver) != (oldState & State_MouseOver));
2394 if (oldRect != newRect || (wasDefault && !isDefault)) {
2395 doTransition =
false;
2405 styleOption->
state = QStyle::State(oldState);
2408 QPainter startPainter(&startImage);
2412 proxy()->drawControl(element, styleOption, &startPainter,
widget);
2414 anim->
paint(&startPainter, styleOption);
2418 t->setStartImage(startImage);
2422 proxy()->drawControl(element, styleOption, &endPainter,
widget);
2423 t->setEndImage(endImage);
2427 const HTHEME theme = OpenThemeData(
nullptr, L
"Button");
2431 if (GetThemeTransitionDuration(theme, BP_PUSHBUTTON, fromState, toState, TMT_TRANSITIONDURATIONS, &duration) == S_OK)
2432 t->setDuration(
int(duration));
2435 t->setStartTime(
d->animationTime());
2439 d->startAnimation(
t);
2451 bool hMirrored =
false;
2452 bool vMirrored =
false;
2456 case CE_PushButtonBevel:
2459 partId = BP_PUSHBUTTON;
2464 stateId = PBS_DISABLED;
2467 else if (
flags & (State_Sunken | State_On))
2468 stateId = PBS_PRESSED;
2469 else if (
flags & State_MouseOver)
2472 stateId = PBS_DEFAULTED;
2474 stateId = PBS_NORMAL;
2479 !(
state & (State_Sunken | State_On)) && !(
state & State_MouseOver) &&
2480 (
state & State_Enabled) && (
state & State_Active))
2490 QPainter startPainter(&startImage);
2491 stateId = PBS_DEFAULTED;
2493 d->drawBackground(theme);
2495 QPainter alternatePainter(&alternateImage);
2496 theme.
stateId = PBS_DEFAULTED_ANIMATING;
2497 theme.
painter = &alternatePainter;
2498 d->drawBackground(theme);
2504 d->startAnimation(pulse);
2512 d->drawBackground(theme);
2517 d->drawBackground(theme);
2522 int mbiw = 0, mbih = 0;
2527 if (!
size.isEmpty()) {
2536 option->rect.top() + (
option->rect.height()/2) - (mbih/2),
2537 mbiw + 1, mbih + 1));
2545 partId = SP_GRIPPER;
2547 QSize size = (theme.
size() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget)).toSize();
2549 if (
const auto *sg = qstyleoption_cast<const QStyleOptionSizeGrip *>(
option)) {
2550 switch (sg->corner) {
2564 hMirrored = vMirrored =
true;
2575 if (
const auto *tab = qstyleoption_cast<const QStyleOptionTab *>(
option))
2576 stateId = tab->state & State_Enabled ? TIS_NORMAL : TIS_DISABLED;
2579 case CE_TabBarTabShape:
2580 if (
const auto *tab = qstyleoption_cast<const QStyleOptionTab *>(
option)) {
2582 const bool isDisabled = !(tab->state & State_Enabled);
2583 const bool hasFocus = tab->state & State_HasFocus;
2584 const bool isHot = tab->state & State_MouseOver;
2585 const bool selected = tab->state & State_Selected;
2586 bool lastTab = tab->position == QStyleOptionTab::End;
2587 bool firstTab = tab->position == QStyleOptionTab::Beginning;
2588 const bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
2591 const int borderThickness =
proxy()->pixelMetric(PM_DefaultFrameWidth,
option,
widget);
2592 const int tabOverlap =
proxy()->pixelMetric(PM_TabBarTabOverlap,
option,
widget);
2595 stateId = TIS_DISABLED;
2597 stateId = TIS_SELECTED;
2599 stateId = TIS_FOCUSED;
2603 stateId = TIS_NORMAL;
2606 if (firstTab || onlyOne) {
2608 partId = TABP_TABITEMLEFTEDGE;
2609 else if (centerAligned)
2610 partId = TABP_TABITEM;
2612 partId = TABP_TABITEMRIGHTEDGE;
2614 partId = TABP_TABITEM;
2619 bool temp = firstTab;
2624 const bool begin = firstTab || onlyOne;
2625 const bool end = lastTab || onlyOne;
2627 switch (tab->shape) {
2630 rect.adjust(
begin ? 0 : -tabOverlap, 0,
end ? 0 : tabOverlap, borderThickness);
2632 rect.adjust(
begin? tabOverlap : 0, tabOverlap,
end ? -tabOverlap : 0, 0);
2638 rect.adjust(
begin ? 0 : -tabOverlap , -borderThickness,
end ? 0 : tabOverlap, 0);
2640 rect.adjust(
begin ? tabOverlap : 0, 0,
end ? -tabOverlap : 0 , -tabOverlap);
2645 rect.adjust(-borderThickness,
begin ? 0 : -tabOverlap, 0,
end ? 0 : tabOverlap);
2647 rect.adjust(0,
begin ? tabOverlap : 0, -tabOverlap,
end ? -tabOverlap : 0);
2653 rect.adjust(0,
begin ? 0 : -tabOverlap, borderThickness,
end ? 0 : tabOverlap);
2655 rect.adjust(tabOverlap,
begin ? tabOverlap : 0, 0,
end ? -tabOverlap : 0);
2663 switch (tab->shape) {
2665 rect.adjust(0,0, 0,-1);
2668 rect.adjust(0,1, 0,0);
2671 rect.adjust( 1,0, 0,0);
2674 rect.adjust(0,0, -1,0);
2683 case CE_ProgressBarGroove: {
2685 if (
const auto *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(
option))
2695 case CE_ProgressBarContents:
2696 if (
const auto *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(
option)) {
2697 bool isIndeterminate = (bar->minimum == 0 && bar->maximum == 0);
2699 const bool inverted = bar->invertedAppearance;
2701 if (isIndeterminate || (bar->progress > 0 && (bar->progress < bar->maximum) &&
d->transitionsEnabled())) {
2710 vertical ? PP_FILLVERT : PP_FILL);
2713 QTime current =
d->animationTime();
2715 if (isIndeterminate) {
2716 if (
auto *progressAnimation = qobject_cast<QProgressStyleAnimation *>(
d->animation(
styleObject(
option)))) {
2718 int animationWidth = glowSize * 2 + (vertical ? theme.
rect.
height() : theme.
rect.
width());
2719 int animOffset = progressAnimation->startTime().msecsTo(current) / 4;
2720 if (animOffset > animationWidth)
2721 progressAnimation->setStartTime(
d->animationTime());
2725 QSize pixmapSize(14, 14);
2728 inverted ?
rect.top() - glowSize + animOffset :
2729 rect.bottom() + glowSize - animOffset,
2730 rect.width(), glowSize);
2733 animRect =
QRect(
rect.left() - glowSize + animOffset,
2734 rect.top(), glowSize,
rect.height());
2745 theme.
painter = &imagePainter;
2746 theme.
partId = vertical ? PP_FILLVERT : PP_FILL;
2749 vertical ?
image.height() : 0);
2755 d->drawBackground(theme);
2764 qint64 progress = qMax<qint64>(bar->progress, bar->minimum);
2767 int maxHeight =
option->rect.height();
2769 double vc6_workaround = ((progress -
qint64(bar->minimum)) /
qMax(
double(1.0), double(
qint64(bar->maximum) -
qint64(bar->minimum))) * maxHeight);
2770 int height = isIndeterminate ? maxHeight:
qMax(
int(vc6_workaround), minHeight);
2775 int maxWidth =
option->rect.width();
2777 double vc6_workaround = ((progress -
qint64(bar->minimum)) /
qMax(
double(1.0), double(
qint64(bar->maximum) -
qint64(bar->minimum))) * maxWidth);
2778 int width = isIndeterminate ? maxWidth :
qMax(
int(vc6_workaround), minWidth);
2783 d->drawBackground(theme);
2787 int animationWidth = glowSize * 2 + (vertical ? theme.
rect.
height() : theme.
rect.
width());
2788 int animOffset =
a->startTime().msecsTo(current) / 4;
2789 theme.
partId = vertical ? PP_MOVEOVERLAYVERT : PP_MOVEOVERLAY;
2790 if (animOffset > animationWidth) {
2791 if (bar->progress < bar->maximum)
2792 a->setStartTime(
d->animationTime());
2801 inverted ?
rect.top() - glowSize + animOffset :
2802 rect.bottom() + glowSize - animOffset,
2803 rect.width(), glowSize);
2808 d->drawBackground(theme);
2815 case CE_MenuBarItem:
2816 if (
const auto *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(
option)) {
2824 if (!
proxy()->styleHint(SH_UnderlineShortcut, mbi,
widget))
2831 MENU_BARBACKGROUND, 0,
option->rect.adjusted(-1, 0, 2, 1));
2832 d->drawBackground(theme);
2834 int stateId = MBI_NORMAL;
2836 stateId = MBI_DISABLED;
2838 stateId = MBI_PUSHED;
2844 MENU_BARITEM, stateId,
option->rect);
2845 d->drawBackground(theme2);
2851 drawItemText(
painter, mbi->rect,
alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole);
2856 case CE_MenuEmptyArea:
2857 if (
const auto *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(
option)) {
2858 QBrush fill = menuitem->palette.brush((menuitem->state & State_Selected) ?
2866 if (
const auto *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(
option)) {
2868 const qreal factor = QWindowsVistaStylePrivate::nativeMetricScaleFactor(
widget);
2870 const int gutterWidth =
qRound(
qreal(3) * factor);
2873 MENU_POPUPCHECKBACKGROUND, MBI_HOT);
2875 themeSize.
partId = MENU_POPUPCHECK;
2879 checkcol =
qMax(menuitem->maxIconWidth,
qRound(gutterWidth +
size.width() + margins.
left() + margins.
right()));
2885 checkcol +=
rect.x();
2888 QRect gutterRect(
p1.x(),
p1.y(), gutterWidth,
p2.y() -
p1.y() + 1);
2890 MENU_POPUPGUTTER, stateId, gutterRect);
2891 d->drawBackground(theme2);
2894 menuitem->rect.getRect(&
x, &
y, &
w, &
h);
2895 int tab = menuitem->reservedShortcutWidth;
2896 bool dis = !(menuitem->state & State_Enabled);
2898 ? menuitem->checked :
false;
2899 bool act = menuitem->state & State_Selected;
2902 int yoff =
y-2 +
h / 2;
2903 const int separatorSize =
qRound(
qreal(6) * QWindowsStylePrivate::nativeMetricScaleFactor(
widget));
2907 QRect subRect(
p1.x() + (gutterWidth - menuitem->rect.x()),
p1.y(),
2908 p2.x() -
p1.x(), separatorSize);
2912 MENU_POPUPSEPARATOR, stateId, subRect);
2913 d->drawBackground(theme2);
2918 menuitem->rect.y(), checkcol - (gutterWidth + menuitem->rect.x()), menuitem->rect.height()));
2921 stateId = dis ? MBI_DISABLED : MBI_HOT;
2924 MENU_POPUPITEM, stateId,
option->rect);
2925 d->drawBackground(theme2);
2931 MENU_POPUPCHECKBACKGROUND,
2932 menuitem->icon.isNull() ? MBI_HOT : MBI_PUSHED, vCheckRect);
2934 themeSize.
partId = MENU_POPUPCHECK;
2935 themeSize.stateId = 0;
2936 const QSizeF size = themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget);
2937 const QMarginsF margins = themeSize.margins() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget);
2941 theme.
rect = checkRect;
2943 d->drawBackground(theme);
2945 if (menuitem->icon.isNull()) {
2948 theme.
rect = checkRect;
2950 theme.
partId = MENU_POPUPCHECK;
2953 theme.
stateId = bullet ? MC_BULLETDISABLED: MC_CHECKMARKDISABLED;
2955 theme.
stateId = bullet ? MC_BULLETNORMAL: MC_CHECKMARKNORMAL;
2956 d->drawBackground(theme);
2959 painter->
fillRect(checkRect, menuitem->palette.highlight().color().lighter(200));
2963 if (!menuitem->icon.isNull()) {
2979 const QColor textColor = menuitem->palette.text().color();
2984 int xpos = menuitem->rect.x() + xm;
3011 PrimitiveElement arrow;
3016 newMI.
rect = vSubMenuRect;
3017 newMI.
state = dis ? State_None : State_Enabled;
3024 case CE_HeaderSection:
3026 partId = HP_HEADERITEM;
3027 if (
flags & State_Sunken)
3028 stateId = HIS_PRESSED;
3029 else if (
flags & State_MouseOver)
3032 stateId = HIS_NORMAL;
3039 partId, stateId,
option->rect);
3040 d->drawBackground(theme);
3044 case CE_MenuBarEmptyArea: {
3045 stateId = MBI_NORMAL;
3046 if (!(
state & State_Enabled))
3047 stateId = MBI_DISABLED;
3049 MENU_BARBACKGROUND, stateId,
option->rect);
3050 d->drawBackground(theme);
3055 if (
const auto *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(
option)) {
3058 QStyleOptionToolBar copyOpt = *toolbar;
3059 copyOpt.palette = pal;
3060 QWindowsStyle::drawControl(element, ©Opt,
painter,
widget);
3064#if QT_CONFIG(dockwidget)
3065 case CE_DockWidgetTitle:
3066 if (
const auto *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(
option)) {
3070 int buttonMargin = 4;
3072 int fw =
proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt,
widget);
3074 const bool verticalTitleBar = dwOpt->verticalTitleBar;
3076 if (verticalTitleBar) {
3087 if (dwOpt->closable) {
3089 titleRect.
adjust(0, 0, -sz.
width() - mw - buttonMargin, 0);
3092 if (dwOpt->floatable) {
3094 titleRect.
adjust(0, 0, -sz.
width() - mw - buttonMargin, 0);
3098 titleRect.
adjust(0, -fw, 0, 0);
3102 titleRect.
adjust(mw, 0, 0, 0);
3103 if (!dwOpt->floatable && !dwOpt->closable)
3104 titleRect.
adjust(0, 0, -mw, 0);
3107 if (!verticalTitleBar)
3108 titleRect =
visualRect(dwOpt->direction,
r, titleRect);
3111 const bool isActive = dwOpt->state & State_Active;
3114 stateId = CS_ACTIVE;
3116 stateId = CS_INACTIVE;
3118 int titleHeight =
rect.height() - 2;
3119 rect =
rect.adjusted(-fw, -fw, fw, 0);
3127 theme.
partId = WP_SMALLCAPTION;
3128 d->drawBackground(theme);
3141 if (!dwOpt->title.isEmpty()) {
3144 QFont titleFont = oldFont;
3151 GetThemeEnumValue(theme.
handle(), WP_SMALLCAPTION,
isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &
result);
3153 COLORREF textShadowRef;
3155 QColor textShadow =
qRgb(GetRValue(textShadowRef), GetGValue(textShadowRef), GetBValue(textShadowRef));
3159 dwOpt->state & State_Enabled, titleText);
3162 COLORREF captionText = GetSysColor(
isActive ? COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT);
3163 QColor textColor =
qRgb(GetRValue(captionText), GetGValue(captionText), GetBValue(captionText));
3165 drawItemText(
painter, titleRect,
3167 dwOpt->state & State_Enabled, titleText);
3176 if (!dwOpt->title.isEmpty()) {
3178 verticalTitleBar ? titleRect.
height() : titleRect.
width());
3179 const int indent = 4;
3180 drawItemText(
painter,
rect.adjusted(indent + 1, 1, -indent - 1, -1),
3183 dwOpt->state & State_Enabled, titleText,
3191#if QT_CONFIG(rubberband)
3193 if (qstyleoption_cast<const QStyleOptionRubberBand *>(
option)) {
3199 qMin(highlight.
blue()/2 + 110, 255),
3209 case CE_HeaderEmptyArea:
3210 if (
option->state & State_Horizontal) {
3212 stateId = HIS_NORMAL;
3219#if QT_CONFIG(itemviews)
3220 case CE_ItemViewItem: {
3221 const QStyleOptionViewItem *vopt;
3223 bool newStyle =
true;
3225 if (qobject_cast<const QTableView*>(
widget))
3230 if (newStyle &&
view && (vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
option))) {
3242 QStyleOptionViewItem adjustedOption = *vopt;
3243 adjustedOption.palette =
palette;
3246 && !(vopt->state & State_KeyboardFocusChange))
3247 adjustedOption.state &= ~State_HasFocus;
3249 QWindowsStyle::drawControl(element, &adjustedOption,
painter,
widget);
3262 d->drawBackground(theme);
3267#if QT_CONFIG(combobox)
3268 case CE_ComboBoxLabel:
3288 d->drawBackground(theme);
3315 flags |= State_MouseOver;
3319 if (control == CC_ScrollBar || control == CC_SpinBox || control == CC_ComboBox) {
3330 bool doTransition = ((
state & State_Sunken) != (oldState & State_Sunken)
3331 || (
state & State_On) != (oldState & State_On)
3332 || (
state & State_MouseOver) != (oldState & State_MouseOver)
3333 || oldActiveControls != int(
option->activeSubControls));
3335 if (qstyleoption_cast<const QStyleOptionSlider *>(
option)) {
3339 if (oldSliderPos != currentPos) {
3340 doTransition =
false;
3343 }
else if (control == CC_SpinBox) {
3346 doTransition = (
state & State_HasFocus) != (oldState & State_HasFocus);
3349 if (oldRect !=
option->rect) {
3350 doTransition =
false;
3356 QPainter startPainter(&startImage);
3371 styleOption->
state = QStyle::State(oldState);
3373 proxy()->drawComplexControl(control, styleOption, &startPainter,
widget);
3377 t->setStartImage(startImage);
3382 proxy()->drawComplexControl(control, styleOption, &endPainter,
widget);
3386 t->setEndImage(endImage);
3387 t->setStartTime(
d->animationTime());
3389 if (
option->state & State_MouseOver ||
option->state & State_Sunken)
3390 t->setDuration(150);
3392 t->setDuration(500);
3395 d->startAnimation(
t);
3406#if QT_CONFIG(slider)
3408 if (
const auto *slider = qstyleoption_cast<const QStyleOptionSlider *>(
option)) {
3410 QRect slrect = slider->rect;
3412 if (
sub & SC_SliderGroove) {
3416 stateId = TRS_NORMAL;
3419 partId = TKP_TRACKVERT;
3420 stateId = TRVS_NORMAL;
3425 d->drawBackground(theme);
3426 tickreg -= theme.
rect;
3428 if (
sub & SC_SliderTickmarks) {
3429 int tickOffset =
proxy()->pixelMetric(PM_SliderTickmarkOffset, slider,
widget);
3430 int ticks = slider->tickPosition;
3431 int thickness =
proxy()->pixelMetric(PM_SliderControlThickness, slider,
widget);
3433 int available =
proxy()->pixelMetric(PM_SliderSpaceAvailable, slider,
widget);
3434 int interval = slider->tickInterval;
3435 if (interval <= 0) {
3436 interval = slider->singleStep;
3441 interval = slider->pageStep;
3445 int fudge =
len / 2;
3450 int v = slider->minimum;
3451 while (v <= slider->maximum + 1) {
3452 if (
v == slider->maximum + 1 && interval == 1)
3454 const int v_ =
qMin(
v, slider->maximum);
3455 int tickLength = (v_ == slider->minimum || v_ >= slider->maximum) ? 4 : 3;
3457 v_, available) + fudge;
3461 pos, tickOffset - 1 - bothOffset - tickLength));
3466 pos, tickOffset + thickness + bothOffset + tickLength));
3471 tickOffset - 1 - bothOffset - tickLength,
pos));
3476 tickOffset + thickness + bothOffset + tickLength,
pos));
3480 int nextInterval =
v + interval;
3481 if (nextInterval <
v)
3492 if (
sub & SC_SliderHandle) {
3496 partId = TKP_THUMBTOP;
3498 partId = TKP_THUMBBOTTOM;
3502 if (!(slider->state & State_Enabled))
3503 stateId = TUS_DISABLED;
3504 else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_Sunken))
3505 stateId = TUS_PRESSED;
3506 else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_MouseOver))
3508 else if (
flags & State_HasFocus)
3509 stateId = TUS_FOCUSED;
3511 stateId = TUS_NORMAL;
3514 partId = TKP_THUMBLEFT;
3516 partId = TKP_THUMBRIGHT;
3518 partId = TKP_THUMBVERT;
3520 if (!(slider->state & State_Enabled))
3521 stateId = TUVS_DISABLED;
3522 else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_Sunken))
3523 stateId = TUVS_PRESSED;
3524 else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_MouseOver))
3526 else if (
flags & State_HasFocus)
3527 stateId = TUVS_FOCUSED;
3529 stateId = TUVS_NORMAL;
3533 d->drawBackground(theme);
3535 if (slider->state & State_HasFocus) {
3537 fropt.QStyleOption::operator=(*slider);
3545#if QT_CONFIG(toolbutton)
3547 if (
const auto *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(
option)) {
3550 menuarea =
proxy()->subControlRect(control, toolbutton, SC_ToolButtonMenu,
widget);
3552 State bflags = toolbutton->state & ~State_Sunken;
3553 State mflags = bflags;
3554 bool autoRaise =
flags & State_AutoRaise;
3556 if (!(bflags & State_MouseOver) || !(bflags & State_Enabled))
3557 bflags &= ~State_Raised;
3560 if (toolbutton->state & State_Sunken) {
3561 if (toolbutton->activeSubControls & SC_ToolButton) {
3562 bflags |= State_Sunken;
3563 mflags |= State_MouseOver | State_Sunken;
3564 }
else if (toolbutton->activeSubControls & SC_ToolButtonMenu) {
3565 mflags |= State_Sunken;
3566 bflags |= State_MouseOver;
3571 if (toolbutton->subControls & SC_ToolButton) {
3572 if (
flags & (State_Sunken | State_On | State_Raised) || !autoRaise) {
3575 theme.
partId = TP_SPLITBUTTON;
3577 if (!(bflags & State_Enabled))
3578 stateId = TS_DISABLED;
3579 else if (bflags & State_Sunken)
3580 stateId = TS_PRESSED;
3581 else if (bflags & State_MouseOver || !(
flags & State_AutoRaise))
3582 stateId =
flags & State_On ? TS_HOTCHECKED : TS_HOT;
3583 else if (bflags & State_On)
3584 stateId = TS_CHECKED;
3586 stateId = TS_NORMAL;
3590 d->drawBackground(theme);
3593 tool.
state = bflags;
3602 if (toolbutton->state & State_HasFocus) {
3604 fr.QStyleOption::operator=(*toolbutton);
3615 label.state &= ~State_Sunken;
3619 if (toolbutton->subControls & SC_ToolButtonMenu) {
3620 tool.
rect = menuarea;
3621 tool.
state = mflags;
3625 tool.
state = mflags;
3626 menuarea.
adjust(-2, 0, 0, 0);
3628 if ((bflags & State_Sunken) != (mflags & State_Sunken)){
3632 proxy()->drawPrimitive(PE_PanelButtonBevel, &tool,
painter,
nullptr);
3649 int mbi =
proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton,
widget);
3650 QRect ir = toolbutton->rect;
3660 if (
const auto *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(
option)) {
3661 const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(
widget);
3664 if (
sub & SC_TitleBarLabel) {
3668 stateId = CS_DISABLED;
3670 stateId = CS_ACTIVE;
3672 stateId = CS_INACTIVE;
3676 d->drawBackground(theme);
3678 QRect ir =
proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarLabel,
widget);
3681 GetThemeEnumValue(theme.
handle(), WP_CAPTION,
isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &
result);
3683 COLORREF textShadowRef;
3685 QColor textShadow =
qRgb(GetRValue(textShadowRef), GetGValue(textShadowRef), GetBValue(textShadowRef));
3691 COLORREF captionText = GetSysColor(
isActive ? COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT);
3692 QColor textColor =
qRgb(GetRValue(captionText), GetGValue(captionText), GetBValue(captionText));
3700 partId = WP_SYSBUTTON;
3702 stateId = SBS_DISABLED;
3703 else if (
option->activeSubControls == SC_TitleBarSysMenu && (
option->state & State_Sunken))
3704 stateId = SBS_PUSHED;
3705 else if (
option->activeSubControls == SC_TitleBarSysMenu && (
option->state & State_MouseOver))
3708 stateId = SBS_NORMAL;
3709 if (!tb->icon.isNull()) {
3721 d->drawBackground(theme);
3729 d->drawBackground(theme);
3734 d->drawBackground(theme);
3736 if (
sub & SC_TitleBarContextHelpButton
3739 d->drawBackground(theme);
3741 bool drawNormalButton = (
sub & SC_TitleBarNormalButton)
3746 if (drawNormalButton) {
3748 d->drawBackground(theme);
3753 d->drawBackground(theme);
3758 d->drawBackground(theme);
3762 d->drawBackground(theme);
3767#if QT_CONFIG(mdiarea)
3768 case CC_MdiControls: {
3773 if (
option->subControls.testFlag(SC_MdiCloseButton)) {
3774 populateMdiButtonTheme(
proxy(),
widget,
option, SC_MdiCloseButton, WP_MDICLOSEBUTTON, &theme);
3775 d->drawBackground(theme, mdiButtonCorrectionFactor(theme,
widget));
3777 if (
option->subControls.testFlag(SC_MdiNormalButton)) {
3778 populateMdiButtonTheme(
proxy(),
widget,
option, SC_MdiNormalButton, WP_MDIRESTOREBUTTON, &theme);
3779 d->drawBackground(theme, mdiButtonCorrectionFactor(theme,
widget));
3782 populateMdiButtonTheme(
proxy(),
widget,
option, SC_MdiMinButton, WP_MDIMINBUTTON, &theme);
3783 d->drawBackground(theme, mdiButtonCorrectionFactor(theme,
widget));
3791 if (
const auto *dial = qstyleoption_cast<const QStyleOptionSlider *>(
option))
3792 QStyleHelper::drawDial(dial,
painter);
3798 if (cmb->editable) {
3799 if (
sub & SC_ComboBoxEditField) {
3800 partId = EP_EDITBORDER_NOSCROLL;
3801 if (!(
flags & State_Enabled))
3802 stateId = ETS_DISABLED;
3803 else if (
flags & State_MouseOver)
3805 else if (
flags & State_HasFocus)
3806 stateId = ETS_FOCUSED;
3808 stateId = ETS_NORMAL;
3812 partId, stateId,
r);
3814 d->drawBackground(theme);
3816 if (
sub & SC_ComboBoxArrow) {
3819 theme.
rect = subRect;
3822 if (!(cmb->state & State_Enabled))
3823 stateId = CBXS_DISABLED;
3824 else if (cmb->state & State_Sunken || cmb->state & State_On)
3825 stateId = CBXS_PRESSED;
3826 else if (cmb->state & State_MouseOver &&
option->activeSubControls & SC_ComboBoxArrow)
3829 stateId = CBXS_NORMAL;
3833 d->drawBackground(theme);
3837 if (
sub & SC_ComboBoxFrame) {
3840 theme.
partId = CP_READONLY;
3841 if (!(cmb->state & State_Enabled))
3842 theme.
stateId = CBXS_DISABLED;
3843 else if (cmb->state & State_Sunken || cmb->state & State_On)
3845 else if (cmb->state & State_MouseOver)
3849 d->drawBackground(theme);
3851 if (
sub & SC_ComboBoxArrow) {
3855 if (!(cmb->state & State_Enabled))
3856 theme.
stateId = CBXS_DISABLED;
3859 d->drawBackground(theme);
3861 if ((
sub & SC_ComboBoxEditField) && (
flags & State_HasFocus)) {
3863 fropt.QStyleOption::operator=(*cmb);
3872 if (
const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(
option)) {
3874 bool maxedOut = (scrollbar->maximum == scrollbar->minimum);
3876 flags &= ~State_Enabled;
3878 bool isHorz =
flags & State_Horizontal;
3880 if (
sub & SC_ScrollBarAddLine) {
3882 partId = SBP_ARROWBTN;
3883 if (!(
flags & State_Enabled))
3884 stateId = (isHorz ? (isRTL ? ABS_LEFTDISABLED : ABS_RIGHTDISABLED) : ABS_DOWNDISABLED);
3885 else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_Sunken))
3886 stateId = (isHorz ? (isRTL ? ABS_LEFTPRESSED : ABS_RIGHTPRESSED) : ABS_DOWNPRESSED);
3887 else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_MouseOver))
3888 stateId = (isHorz ? (isRTL ? ABS_LEFTHOT : ABS_RIGHTHOT) : ABS_DOWNHOT);
3889 else if (scrollbar->state & State_MouseOver)
3890 stateId = (isHorz ? (isRTL ? ABS_LEFTHOVER : ABS_RIGHTHOVER) : ABS_DOWNHOVER);
3892 stateId = (isHorz ? (isRTL ? ABS_LEFTNORMAL : ABS_RIGHTNORMAL) : ABS_DOWNNORMAL);
3895 d->drawBackground(theme);
3897 if (
sub & SC_ScrollBarSubLine) {
3899 partId = SBP_ARROWBTN;
3900 if (!(
flags & State_Enabled))
3901 stateId = (isHorz ? (isRTL ? ABS_RIGHTDISABLED : ABS_LEFTDISABLED) : ABS_UPDISABLED);
3902 else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_Sunken))
3903 stateId = (isHorz ? (isRTL ? ABS_RIGHTPRESSED : ABS_LEFTPRESSED) : ABS_UPPRESSED);
3904 else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_MouseOver))
3905 stateId = (isHorz ? (isRTL ? ABS_RIGHTHOT : ABS_LEFTHOT) : ABS_UPHOT);
3906 else if (scrollbar->state & State_MouseOver)
3907 stateId = (isHorz ? (isRTL ? ABS_RIGHTHOVER : ABS_LEFTHOVER) : ABS_UPHOVER);
3909 stateId = (isHorz ? (isRTL ? ABS_RIGHTNORMAL : ABS_LEFTNORMAL) : ABS_UPNORMAL);
3912 d->drawBackground(theme);
3918 partId =
flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
3919 stateId = SCRBS_DISABLED;
3922 d->drawBackground(theme);
3924 if (
sub & SC_ScrollBarSubPage) {
3926 partId =
flags & State_Horizontal ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT;
3927 if (!(
flags & State_Enabled))
3928 stateId = SCRBS_DISABLED;
3929 else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_Sunken))
3930 stateId = SCRBS_PRESSED;
3931 else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_MouseOver))
3932 stateId = SCRBS_HOT;
3934 stateId = SCRBS_NORMAL;
3937 d->drawBackground(theme);
3939 if (
sub & SC_ScrollBarAddPage) {
3941 partId =
flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
3942 if (!(
flags & State_Enabled))
3943 stateId = SCRBS_DISABLED;
3944 else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_Sunken))
3945 stateId = SCRBS_PRESSED;
3946 else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_MouseOver))
3947 stateId = SCRBS_HOT;
3949 stateId = SCRBS_NORMAL;
3952 d->drawBackground(theme);
3954 if (
sub & SC_ScrollBarSlider) {
3956 if (!(
flags & State_Enabled))
3957 stateId = SCRBS_DISABLED;
3958 else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_Sunken))
3959 stateId = SCRBS_PRESSED;
3960 else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_MouseOver))
3961 stateId = SCRBS_HOT;
3962 else if (
option->state & State_MouseOver)
3963 stateId = SCRBS_HOVER;
3965 stateId = SCRBS_NORMAL;
3968 theme.
partId =
flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT;
3970 d->drawBackground(theme);
3976#if QT_CONFIG(spinbox)
3978 if (
const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(
option)) {
3980 if (sb->frame && (
sub & SC_SpinBoxFrame)) {
3981 partId = EP_EDITBORDER_NOSCROLL;
3982 if (!(
flags & State_Enabled))
3983 stateId = ETS_DISABLED;
3984 else if (
flags & State_MouseOver)
3986 else if (
flags & State_HasFocus)
3987 stateId = ETS_SELECTED;
3989 stateId = ETS_NORMAL;
3993 partId, stateId,
r);
3999 d->drawBackground(ftheme);
4001 if (
sub & SC_SpinBoxUp) {
4002 theme.
rect =
proxy()->subControlRect(CC_SpinBox,
option, SC_SpinBoxUp,
widget).adjusted(0, 0, 0, 1);
4005 stateId = UPS_DISABLED;
4006 else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken))
4007 stateId = UPS_PRESSED;
4008 else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_MouseOver))
4011 stateId = UPS_NORMAL;
4014 d->drawBackground(theme);
4016 if (
sub & SC_SpinBoxDown) {
4020 stateId = DNS_DISABLED;
4021 else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken))
4022 stateId = DNS_PRESSED;
4023 else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_MouseOver))
4026 stateId = DNS_NORMAL;
4029 d->drawBackground(theme);
4057 const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(
widget);
4059 if (!borderSize.
isNull()) {
4062 contentSize.
rheight() += int(borderSize.
bottom() + borderSize.
top() - margin
4063 +
qreal(1) / factor - 1);
4065 const int textMargins = 2*(
proxy()->pixelMetric(PM_FocusFrameHMargin,
option) + 1);
4067 + textMargins, 23), 0);
4073 contentSize +=
QSize(6, 6);
4077 contentSize +=
QSize(1, 0);
4080#if QT_CONFIG(menubar)
4081 case CT_MenuBarItem:
4091 MENU_POPUPCHECKBACKGROUND, MBI_HOT);
4093 themeSize.
partId = MENU_POPUPCHECK;
4106 case CT_MdiControls: {
4109 if (
const auto *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(
option)) {
4111 if (styleOpt->subControls & SC_MdiMinButton)
4113 if (styleOpt->subControls & SC_MdiNormalButton)
4115 if (styleOpt->subControls & SC_MdiCloseButton)
4122 case CT_ItemViewItem:
4135 case CT_HeaderSection:
4141 contentSize = QWindowsStyle::sizeFromContents(
type, hdr,
size,
widget);
4142 hdr->sortIndicator = sortInd;
4160 return QWindowsStyle::subElementRect(element,
option,
widget);
4165 case SE_PushButtonContents:
4170 int stateId = PBS_NORMAL;
4171 if (!(
option->state & State_Enabled))
4172 stateId = PBS_DISABLED;
4173 else if (
option->state & State_Sunken)
4174 stateId = PBS_PRESSED;
4175 else if (
option->state & State_MouseOver)
4178 stateId = PBS_DEFAULTED;
4183 if (SUCCEEDED(GetThemeMargins(theme,
nullptr, BP_PUSHBUTTON, stateId,
TMT_CONTENTMARGINS,
nullptr, &borderSize))) {
4184 rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
4185 -borderSize.cxRightWidth, -borderSize.cyBottomHeight);
4192 case SE_DockWidgetCloseButton:
4193 case SE_DockWidgetFloatButton:
4195 return rect.translated(0, 1);
4197 case SE_TabWidgetTabContents:
4199 if (qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(
option)) {
4201 if (
const QTabWidget *tabWidget = qobject_cast<const QTabWidget *>(
widget)) {
4202 if (tabWidget->documentMode())
4204 rect.adjust(0, 0, -2, -2);
4209 case SE_TabWidgetTabBar: {
4211 const auto *twfOption = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(
option);
4216 QStyleOptionTab otherOption;
4219 int overlap =
proxy()->pixelMetric(PM_TabBarBaseOverlap, &otherOption,
widget);
4220 int borderThickness =
proxy()->pixelMetric(PM_DefaultFrameWidth,
option,
widget);
4221 rect.adjust(-overlap + borderThickness, 0, -overlap + borderThickness, 0);
4226 case SE_HeaderArrow: {
4229 int h =
option->rect.height();
4237 HP_HEADERSORTARROW, HSAS_SORTEDDOWN,
option->rect);
4239 int arrowWidth = 13;
4240 int arrowHeight = 5;
4243 if (!
size.isEmpty()) {
4248 if (
option->state & State_Horizontal) {
4249 r.setRect(
x +
w/2 - arrowWidth/2,
y , arrowWidth, arrowHeight);
4251 int vert_size =
w / 2;
4252 r.setRect(
x + 5,
y +
h - margin * 2 - vert_size,
4253 w - margin * 2 - 5, vert_size);
4259 case SE_HeaderLabel: {
4264 option->rect.width() - margin * 2,
option->rect.height() - margin * 2);
4268 if (!(
option->state & State_Horizontal))
4269 r.setHeight(
r.height() - (
option->rect.width() / 2) - (margin * 2));
4276 case SE_ProgressBarContents:
4280 case SE_ItemViewItemDecoration:
4282 if (qstyleoption_cast<const QStyleOptionViewItem *>(
option))
4283 rect.adjust(-2, 0, 2, 0);
4286 case SE_ItemViewItemFocusRect:
4288 if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
option)) {
4291 if (!vopt->icon.isNull())
4314 return QWindowsStyle::subControlRect(control,
option, subControl,
widget);
4319#if QT_CONFIG(combobox)
4321 if (
const auto *
cb = qstyleoption_cast<const QStyleOptionComboBox *>(
option)) {
4322 const int x =
cb->rect.x(),
y =
cb->rect.y(), wi =
cb->rect.width(), he =
cb->rect.height();
4323 const int margin =
cb->frame ? 3 : 0;
4324 const int bmarg =
cb->frame ? 2 : 0;
4326 const int arrowButtonWidth = bmarg + arrowWidth;
4327 const int xpos =
x + wi - arrowButtonWidth;
4329 switch (subControl) {
4330 case SC_ComboBoxFrame:
4331 case SC_ComboBoxListBoxPopup:
4335 case SC_ComboBoxArrow: {
4336 rect.setRect(xpos,
y , arrowButtonWidth, he);
4340 case SC_ComboBoxEditField: {
4341 rect.setRect(
x + margin,
y + margin, wi - 2 * margin - arrowWidth, he - 2 * margin);
4356 const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(
widget);
4357 const bool isToolTitle =
false;
4358 const int height = tb->rect.height();
4359 const int width = tb->rect.width();
4362 int buttonHeight =
qRound(
qreal(GetSystemMetrics(SM_CYSIZE)) * factor)
4364 const int buttonWidth =
4367 const int frameWidth =
proxy()->pixelMetric(PM_MdiSubWindowFrameWidth,
option,
widget);
4377 const int delta = buttonWidth + 2;
4378 int controlTop =
option->rect.bottom() - buttonHeight - 2;
4380 switch (subControl) {
4381 case SC_TitleBarLabel: {
4385 rect.adjust(0, 0,
int(-buttonWidth - 3 * factor), 0);
4387 if (minimizeHint || maximizeHint)
4388 rect.adjust(0, 0,
int(-buttonWidth - 2 * factor), 0);
4395 rect.adjust(0, 0,
int(-buttonWidth - 2 * factor), 0);
4397 rect.adjust(0, 0,
int(-buttonWidth - 2 * factor), 0);
4399 rect.adjust(0, 0,
int(-buttonWidth - 2 * factor), 0);
4401 rect.adjust(0, 0,
int(-buttonWidth - 2 * factor), 0);
4403 rect.translate(0,
int(2 * factor));
4407 case SC_TitleBarContextHelpButton:
4411 case SC_TitleBarMinButton:
4414 else if (subControl == SC_TitleBarMinButton)
4417 case SC_TitleBarNormalButton:
4422 else if (subControl == SC_TitleBarNormalButton)
4425 case SC_TitleBarMaxButton:
4428 else if (subControl == SC_TitleBarMaxButton)
4431 case SC_TitleBarShadeButton:
4434 else if (subControl == SC_TitleBarShadeButton)
4437 case SC_TitleBarUnshadeButton:
4440 else if (subControl == SC_TitleBarUnshadeButton)
4443 case SC_TitleBarCloseButton:
4446 else if (subControl == SC_TitleBarCloseButton)
4450 buttonWidth, buttonHeight);
4453 case SC_TitleBarSysMenu: {
4454 const int controlTop = int(6 * factor);
4455 const int controlHeight = int(
height - controlTop - 3 * factor);
4456 int iconExtent =
proxy()->pixelMetric(PM_SmallIconSize,
option);
4458 if (tb->icon.isNull())
4460 int hPad = (controlHeight -
iconSize.height())/2;
4461 int vPad = (controlHeight -
iconSize.width())/2;
4463 rect.translate(0,
int(3 * factor));
4473#if QT_CONFIG(mdiarea)
4474 case CC_MdiControls: {
4475 int numSubControls = 0;
4476 if (
option->subControls & SC_MdiCloseButton)
4478 if (
option->subControls & SC_MdiMinButton)
4480 if (
option->subControls & SC_MdiNormalButton)
4482 if (numSubControls == 0)
4485 int buttonWidth =
option->rect.width() / numSubControls;
4488 switch (subControl) {
4489 case SC_MdiCloseButton:
4491 if (numSubControls == 1)
4495 case SC_MdiNormalButton:
4499 if (numSubControls == 1 || (numSubControls == 2 && !(
option->subControls & SC_MdiMinButton)))
4501 if (
option->subControls & SC_MdiNormalButton)
4515 QWindowsStyle::subControlRect(control,
option, subControl,
widget));
4527 return QWindowsStyle::hitTestComplexControl(control,
option,
pos,
widget);
4536 return QWindowsStyle::pixelMetric(metric,
option,
widget);
4539 if (
ret != QWindowsStylePrivate::InvalidMetric)
4543 if (
res != QWindowsStylePrivate::InvalidMetric)
4549 case PM_MenuBarPanelWidth:
4550 case PM_ButtonDefaultIndicator:
4554 case PM_DefaultFrameWidth:
4555 res = qobject_cast<const QListView*>(
widget) ? 2 : 1;
4557 case PM_MenuPanelWidth:
4558 case PM_SpinBoxFrameWidth:
4562 case PM_TabBarTabOverlap:
4563 case PM_MenuHMargin:
4564 case PM_MenuVMargin:
4568 case PM_TabBarBaseOverlap:
4569 if (
const auto *tab = qstyleoption_cast<const QStyleOptionTab *>(
option)) {
4570 switch (tab->shape) {
4589 case PM_SplitterWidth:
4593 case PM_MdiSubWindowMinimizedWidth:
4597#if QT_CONFIG(toolbar)
4598 case PM_ToolBarHandleExtent:
4603 case PM_DockWidgetSeparatorExtent:
4604 case PM_DockWidgetTitleMargin:
4608 case PM_ButtonShiftHorizontal:
4609 case PM_ButtonShiftVertical:
4610 res = qstyleoption_cast<const QStyleOptionToolButton *>(
option) ? 1 : 0;
4625 QWindowsStyle::polish(
widget);
4631 || qobject_cast<QAbstractButton*>(
widget)
4633 || qobject_cast<QToolButton*>(
widget)
4634 || qobject_cast<QTabBar*>(
widget)
4636 || qobject_cast<QComboBox*>(
widget)
4638 || qobject_cast<QScrollBar*>(
widget)
4639 || qobject_cast<QSlider*>(
widget)
4640 || qobject_cast<QHeaderView*>(
widget)
4642 || qobject_cast<QAbstractSpinBox*>(
widget)
4643 || qobject_cast<QSpinBox*>(
widget)
4649#if QT_CONFIG(rubberband)
4650 if (qobject_cast<QRubberBand*>(
widget))
4654#if QT_CONFIG(lineedit)
4655 if (qobject_cast<QLineEdit*>(
widget))
4659 if (qobject_cast<QGroupBox*>(
widget))
4661#if QT_CONFIG(commandlinkbutton)
4662 else if (qobject_cast<QCommandLinkButton*>(
widget)) {
4679 if (theme && SUCCEEDED(GetThemeColor(theme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &bgRef))) {
4685 }
else if (qobject_cast<QMessageBox *> (
widget)) {
4687#if QT_CONFIG(dialogbuttonbox)
4693#if QT_CONFIG(inputdialog)
4694 else if (qobject_cast<QInputDialog *> (
widget)) {
4696#if QT_CONFIG(dialogbuttonbox)
4718#if QT_CONFIG(rubberband)
4719 if (qobject_cast<QRubberBand*>(
widget))
4735 d->cleanupHandleMap();
4739 || qobject_cast<QAbstractButton*>(
widget)
4741 || qobject_cast<QToolButton*>(
widget)
4742 || qobject_cast<QTabBar*>(
widget)
4744 || qobject_cast<QComboBox*>(
widget)
4746 || qobject_cast<QScrollBar*>(
widget)
4747 || qobject_cast<QSlider*>(
widget)
4748 || qobject_cast<QHeaderView*>(
widget)
4750 || qobject_cast<QAbstractSpinBox*>(
widget)
4751 || qobject_cast<QSpinBox*>(
widget)
4757 QWindowsStyle::unpolish(
widget);
4761#if QT_CONFIG(lineedit)
4762 if (qobject_cast<QLineEdit*>(
widget))
4766 if (qobject_cast<QGroupBox*>(
widget))
4768 else if (qobject_cast<QMessageBox *> (
widget)) {
4770#if QT_CONFIG(dialogbuttonbox)
4776#if QT_CONFIG(inputdialog)
4777 else if (qobject_cast<QInputDialog *> (
widget)) {
4779#if QT_CONFIG(dialogbuttonbox)
4789#if QT_CONFIG(commandlinkbutton)
4790 else if (qobject_cast<QCommandLinkButton*>(
widget)) {
4812 nativeWindowsApp->populateLightSystemPalette(pal);
4816 d->alphaCache.clear();
4817 d->hasInitColors =
false;
4819 if (!
d->hasInitColors) {
4823 GetThemeColor(theme.
handle(), BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &cref);
4824 d->groupBoxTextColor =
qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
4825 GetThemeColor(theme.
handle(), BP_GROUPBOX, GBS_DISABLED, TMT_TEXTCOLOR, &cref);
4826 d->groupBoxTextColorDisabled =
qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
4829 d->sliderTickColor =
qRgb(165, 162, 148);
4830 d->hasInitColors =
true;
4833 QWindowsStyle::polish(pal);
4844 static const char* themedWidgets[] = {
4850 "QAbstractItemView",
4861 for (
const auto& themedWidget : std::as_const(themedWidgets)) {
4864 if (widgetResolveMask != defaultResolveMask)
4869 QWindowsStyle::polish(
app);
4883 case SP_TitleBarMaxButton:
4884 case SP_TitleBarCloseButton:
4885 if (qstyleoption_cast<const QStyleOptionDockWidget *>(
option)) {
4889 const QSize size = (theme.
size() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget)).toSize();
4917 case SP_TitleBarMaxButton:
4918 if (qstyleoption_cast<const QStyleOptionDockWidget *>(
option)) {
4919 if (
d->dockFloat.isNull()) {
4921 WP_SMALLCLOSEBUTTON, CBS_NORMAL);
4923 WP_MAXBUTTON, MAXBS_NORMAL);
4925 const QSize size = (themeSize.
size() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget)).toSize();
4931 d->drawBackground(theme);
4935 d->drawBackground(theme);
4939 d->drawBackground(theme);
4943 d->drawBackground(theme);
4948 return d->dockFloat;
4952 case SP_TitleBarCloseButton:
4953 if (qstyleoption_cast<const QStyleOptionDockWidget *>(
option)) {
4954 if (
d->dockClose.isNull()) {
4956 WP_SMALLCLOSEBUTTON, CBS_NORMAL);
4958 const QSize size = (theme.
size() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget)).toSize();
4963 theme.
partId = WP_CLOSEBUTTON;
4965 d->drawBackground(theme);
4969 d->drawBackground(theme);
4973 d->drawBackground(theme);
4977 d->drawBackground(theme);
4982 return d->dockClose;
4986 case SP_TitleBarNormalButton:
4987 if (qstyleoption_cast<const QStyleOptionDockWidget *>(
option)) {
4988 if (
d->dockFloat.isNull()) {
4990 WP_SMALLCLOSEBUTTON, CBS_NORMAL);
4992 WP_RESTOREBUTTON, RBS_NORMAL);
4994 const QSize size = (themeSize.
size() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget)).toSize();
5000 d->drawBackground(theme);
5004 d->drawBackground(theme);
5008 d->drawBackground(theme);
5012 d->drawBackground(theme);
5017 return d->dockFloat;
5021 case SP_CommandLink: {
5032 d->drawBackground(theme);
5037 d->drawBackground(theme);
5042 d->drawBackground(theme);
5047 d->drawBackground(theme);
The QAbstractItemView class provides the basic functionality for item view classes.
SelectionMode
This enum indicates how the view responds to user selections:
SelectionBehavior
\value SelectItems Selecting single items.
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
The QApplication class manages the GUI application's control flow and main settings.
static void setPalette(const QPalette &, const char *className=nullptr)
Changes the application palette to palette.
static QPalette palette()
Returns the current application palette.
static QFont font()
Returns the default application font.
The QBackingStore class provides a drawing area for QWindow.
void setEndImage(const QImage &image)
void setStartImage(const QImage &image)
const QColor & color() const
Returns the brush color.
The QColor class provides colors based on RGB, HSV or CMYK values.
QColor darker(int f=200) const noexcept
static QColor fromRgb(QRgb rgb) noexcept
Static convenience function that returns a QColor constructed from the given QRgb value rgb.
int red() const noexcept
Returns the red color component of this color.
int blue() const noexcept
Returns the blue color component of this color.
int green() const noexcept
Returns the green color component of this color.
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=nullptr) const override
\reimp
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
\reimp
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags=0) const
void setFamilies(const QStringList &)
QStringList families() const
void setBold(bool)
If enable is true sets the font's weight to \l{Weight}{QFont::Bold}; otherwise sets the weight to \l{...
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
static QPlatformIntegration * platformIntegration()
static Qt::ColorScheme colorScheme()
QGuiApplicationPrivate::colorScheme.
static QPlatformNativeInterface * platformNativeInterface()
static QWindowList allWindows()
Returns a list of all the windows in the application.
QScreen * primaryScreen
the primary (or default) screen of the application.
QIcon windowIcon
the default window icon
T value(const Key &key) const noexcept
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
The QIcon class provides scalable icons in different modes and states.
void addPixmap(const QPixmap &pixmap, Mode mode=Normal, State state=Off)
Adds pixmap to the icon, as a specialization for mode and state.
Mode
This enum type describes the mode for which a pixmap is intended to be used.
qint64 cacheKey() const
Returns a number that identifies the contents of this QIcon object.
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
QImage transformed(const QTransform &matrix, Qt::TransformationMode mode=Qt::FastTransformation) const
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
Format
The following image formats are available in Qt.
@ Format_ARGB32_Premultiplied
QImage mirrored(bool horizontally=false, bool vertically=true) const &
The QListView class provides a list or icon view onto a model.
constexpr qreal right() const noexcept
Returns the right margin.
constexpr qreal left() const noexcept
Returns the left margin.
constexpr qreal top() const noexcept
Returns the top margin.
constexpr bool isNull() const noexcept
Returns true if all margins are very close to 0; otherwise returns false.
constexpr qreal bottom() const noexcept
Returns the bottom margin.
Native interface to QGuiApplication, to be retrieved from QPlatformIntegration. \inmodule QtGui.
T findChild(const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Returns the child of this object that can be cast into type T and that is called name,...
QVariant property(const char *name) const
Returns the value of the object's name property.
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
static QOperatingSystemVersion current()
[0]
static constexpr QOperatingSystemVersionBase Windows11
\variable QOperatingSystemVersion::Windows11
qreal devicePixelRatio() const
virtual int devType() const
qreal devicePixelRatioF() const
QRegion systemClip() const
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns \nullptr...
The QPainter class performs low-level painting on widgets and other paint devices.
const QPen & pen() const
Returns the painter's current pen.
void setClipping(bool enable)
Enables clipping if enable is true, or disables clipping if enable is false.
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or \nullptr if the painter is n...
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation.
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawLine(const QLineF &line)
Draws a line defined by line.
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
void setBrushOrigin(int x, int y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const QFont & font() const
Returns the currently set font used for drawing text.
void restore()
Restores the current painter state (pops a saved state off the stack).
void rotate(qreal a)
Rotates the coordinate system clockwise.
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
void save()
Saves the current painter state (pushes the state onto a stack).
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Draws the rectangular portion source of the given image into the target rectangle in the paint device...
void setFont(const QFont &f)
Sets the painter's font to the given font.
QRegion clipRegion() const
Returns the currently set clip region.
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position.
const QTransform & deviceTransform() const
Returns the matrix that transforms from logical coordinates to device coordinates of the platform dep...
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
void eraseRect(const QRectF &)
Erases the area inside the given rectangle.
QPoint brushOrigin() const
Returns the currently set brush origin.
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
@ CompositionMode_SourceIn
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
bool hasClipping() const
Returns true if clipping has been set; otherwise returns false.
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
The QPalette class contains color groups for each widget state.
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette.
ResolveMask resolveMask() const
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
const QBrush & base() const
Returns the base brush of the current color group.
static bool find(const QString &key, QPixmap *pixmap)
Looks for a cached pixmap associated with the given key in the cache.
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
static void clear()
Removes all pixmaps from the cache.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
QImage toImage() const
Converts the pixmap to a QImage.
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
int width() const
Returns the width of the pixmap.
QPixmap copy(int x, int y, int width, int height) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
\inmodule QtCore\reentrant
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr void moveTo(qreal x, qreal y) noexcept
Moves the rectangle, leaving the top-left corner at the given position (x, y).
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QSizeF size() const noexcept
Returns the size of the rectangle.
constexpr QRect toRect() const noexcept
Returns a QRect based on the values of this rectangle.
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
constexpr void moveCenter(const QPoint &p) noexcept
Moves the rectangle, leaving the center point at the given position.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr QPoint topRight() const noexcept
Returns the position of the rectangle's top-right corner.
constexpr void setBottom(int pos) noexcept
Sets the bottom edge of the rectangle to the given y coordinate.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr void setRect(int x, int y, int w, int h) noexcept
Sets the coordinates of the rectangle's top-left corner to ({x}, {y}), and its size to the given widt...
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr void setWidth(int w) noexcept
Sets the width of the rectangle to the given width.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr int width() const noexcept
Returns the width of the rectangle.
QRect united(const QRect &other) const noexcept
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr void setHeight(int h) noexcept
Sets the height of the rectangle to the given height.
constexpr void moveTop(int pos) noexcept
Moves the rectangle vertically, leaving the rectangle's top edge at the given y coordinate.
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
constexpr void setTop(int pos) noexcept
Sets the top edge of the rectangle to the given y coordinate.
The QRegion class specifies a clip region for a painter.
QRect boundingRect() const noexcept
Returns the bounding rectangle of this region.
int rectCount() const noexcept
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
QRegion translated(int dx, int dy) const
constexpr QSize toSize() const noexcept
Returns an integer based copy of this size.
constexpr qreal width() const noexcept
Returns the width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
constexpr qreal height() const noexcept
Returns the height.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr int & rheight() noexcept
Returns a reference to the height.
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
constexpr int & rwidth() noexcept
Returns a reference to the width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
static QString fromWCharArray(const wchar_t *string, qsizetype size=-1)
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & append(QChar c)
void setDuration(int duration)
void setStartTime(QTime time)
The QStyleHintReturnMask class provides style hints that return a QRegion.
\variable QStyleOptionGraphicsItem::exposedRect
\variable QStyleOptionToolButton::features
\variable QStyleOptionMenuItem::menuItemType
QStyle::SubControls activeSubControls
\variable QStyleOption::palette
\variable QStyleOptionFrame::features
\variable QStyleOptionToolBox::selectedPosition
Qt::WindowFlags titleBarFlags
The QStyleOption class stores the parameters used by QStyle functions.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
static int sliderPositionFromValue(int min, int max, int val, int space, bool upsideDown=false)
Converts the given logicalValue to a pixel position.
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction.
PixelMetric
This enum describes the various available pixel metrics.
@ PM_DockWidgetFrameWidth
@ PM_DockWidgetTitleMargin
@ PM_ExclusiveIndicatorHeight
@ PM_MdiSubWindowFrameWidth
@ PM_DockWidgetTitleBarButtonMargin
@ PM_ProgressBarChunkWidth
@ PM_ExclusiveIndicatorWidth
PrimitiveElement
This enum describes the various primitive elements.
@ PE_IndicatorRadioButton
@ SE_ItemViewItemDecoration
@ SE_ItemViewItemFocusRect
SubControl
This enum describes the available sub controls.
@ SC_TitleBarUnshadeButton
@ SC_TitleBarNormalButton
@ SC_TitleBarContextHelpButton
static QPoint visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
Returns the given logicalPosition converted to screen coordinates based on the specified direction.
\inmodule QtCore \reentrant
static QTime currentTime()
Returns the current time as reported by the system clock.
The QTreeView class provides a default model/view implementation of a tree view.
constexpr size_type size() const noexcept
const T * constData() const
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
QRect toRect() const
Returns the variant as a QRect if the variant has userType() \l QMetaType::QRect; otherwise returns a...
QMarginsF margins(const QRect &rect, int propId=TMT_CONTENTMARGINS)
static RECT toRECT(const QRect &qr)
static QSizeF themeSize(const QWidget *w=nullptr, QPainter *p=nullptr, int themeIn=-1, int part=0, int state=0)
void paint(QPainter *painter, const QStyleOption *option)
HBITMAP buffer(int w=0, int h=0)
static int fixedPixelMetric(QStyle::PixelMetric pm)
static HDC hdcForWidgetBackingStore(const QWidget *widget)
static QBackingStore * backingStoreForWidget(const QWidget *widget)
bool swapAlphaChannel(const QRect &rect, bool allPixels=false)
bool drawBackgroundThruNativeBuffer(QWindowsThemeData &QWindowsThemeData, qreal aditionalDevicePixelRatio, qreal correctionFactor)
static HWND winId(const QWidget *widget)
static HTHEME openThemeForPrimaryScreenDpi(HWND hwnd, const wchar_t *name)
void init(bool force=false)
static bool isLineEditBaseColorSet(const QStyleOption *option, const QWidget *widget)
bool transitionsEnabled() const
bool drawBackgroundDirectly(HDC dc, QWindowsThemeData &QWindowsThemeData, qreal aditionalDevicePixelRatio)
static bool isItemViewDelegateLineEdit(const QWidget *widget)
static bool useVista(bool update=false)
static HTHEME createTheme(int theme, HWND hwnd)
bool fixAlphaChannel(const QRect &rect)
void cleanup(bool force=false)
bool isTransparent(QWindowsThemeData &QWindowsThemeData)
bool hasAlphaChannel(const QRect &rect)
QRegion region(QWindowsThemeData &QWindowsThemeData)
QTime animationTime() const
bool drawBackground(QWindowsThemeData &QWindowsThemeData, qreal correctionFactor=1)
static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option=nullptr, const QWidget *widget=nullptr)
static QString themeName(int theme)
The QWindowsVistaStyle class provides a look and feel suitable for applications on Microsoft Windows ...
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override
int styleHint(StyleHint hint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const override
SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget=nullptr) const override
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override
void polish(QWidget *widget) override
int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=nullptr) const override
QWindowsVistaStyle()
Constructs a QWindowsVistaStyle object.
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
\reimp
~QWindowsVistaStyle() override
Destructor.
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const override
void unpolish(QWidget *widget) override
const QStyleOptionButton * btn
[3]
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
void qErrnoWarning(const char *msg,...)
Q_WIDGETS_EXPORT qreal dpiScaled(qreal value, qreal dpi)
Combined button and popup list for selecting options.
@ WA_TranslucentBackground
@ WindowContextHelpButtonHint
@ WindowMaximizeButtonHint
@ WindowMinimizeButtonHint
QVector3D Q_QUICK3DUTILS_EXPORT rotate(const QMatrix4x4 &m, const QVector3D &v)
#define Q_BASIC_ATOMIC_INITIALIZER(a)
#define QByteArrayLiteral(str)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter * sub
static QString header(const QString &name)
void qDrawWinButton(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
int qRound(qfloat16 d) noexcept
static void visualRect(QRectF *geom, Qt::LayoutDirection dir, const QRectF &contentsRect)
static int area(const QSize &s)
static const double leftOffset
static const QStyle::SubControl SubControls[]
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
static QString themeName()
GLsizei const GLfloat * v
[13]
GLuint64 GLenum void * handle
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLfloat GLfloat GLfloat x1
GLint GLenum GLsizei GLsizei GLsizei GLint border
GLuint GLsizei const GLchar * label
[43]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLuint GLenum transformType
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLuint GLenum GLenum transform
GLdouble GLdouble GLdouble GLdouble q
GLfloat GLfloat GLfloat alpha
static const QRectF scaleRect(const QRectF &r, qreal sx, qreal sy)
static bool hasAlpha(const QImage &image)
#define ERROR(description)
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)
#define Q_ASSERT_X(cond, x, msg)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
constexpr QRgb qRgb(int r, int g, int b)
constexpr int qRed(QRgb rgb)
constexpr int qGreen(QRgb rgb)
constexpr int qBlue(QRgb rgb)
constexpr int qAlpha(QRgb rgb)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define qPrintable(string)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define QT_CONFIG(feature)
#define TMT_TEXTSHADOWCOLOR
static bool isFullyOpaque(const QWindowsThemeData &themeData)
static QRectF scaleRect(const QRectF &r, qreal factor)
static const int windowsItemFrame
#define TMT_CONTENTMARGINS
static bool buttonVisible(const QStyle::SubControl sc, const QStyleOptionTitleBar *tb)
#define LISS_SELECTEDNOTFOCUS
static const int windowsItemHMargin
bool canAnimate(const QStyleOption *option)
QStyleOption * clonedAnimationStyleOption(const QStyleOption *option)
static void qt_add_rect(HRGN &winRegion, QRect r)
static int buttonStateId(int flags, int partId)
static const int windowsArrowHMargin
static QRegion scaleRegion(const QRegion ®ion, qreal factor)
static const int windowsItemVMargin
static void populateTitleBarButtonTheme(const QStyle *proxy, const QWidget *widget, const QStyleOptionComplex *option, QStyle::SubControl subControl, bool isTitleBarActive, int part, QWindowsThemeData *theme)
QObject * styleObject(const QStyleOption *option)
#define BP_COMMANDLINKGLYPH
static Qt::Orientation progressBarOrientation(const QStyleOption *option=nullptr)
static HRGN qt_hrgn_from_qregion(const QRegion ®ion)
void deleteClonedAnimationStyleOption(const QStyleOption *option)
@ HighDpiScalingTransform
static QImage createAnimationBuffer(const QStyleOption *option, const QWidget *widget)
static HWND createTreeViewHelperWindow()
static const wchar_t * themeNames[QWindowsVistaStylePrivate::NThemes]
static bool supportsStateTransition(QStyle::PrimitiveElement element, const QStyleOption *option, const QWidget *widget)
static const int windowsRightBorder
if(qFloatDistance(a, b)<(1<< 7))
[0]
QRandomGenerator64 rd
[10]
QLinearGradient alphaGradient(rect.topLeft(), rect.bottomLeft())
[1]
rect deviceTransform(view->viewportTransform()).map(QPointF(0
QApplication app(argc, argv)
[0]
\inmodule QtCore \reentrant