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>
16#include <private/qwindowsthemecache_p.h>
32#ifndef TMT_CONTENTMARGINS
33# define TMT_CONTENTMARGINS 3602
35#ifndef TMT_SIZINGMARGINS
36# define TMT_SIZINGMARGINS 3601
41# define LISS_SELECTED 3
42# define LISS_DISABLED 4
43# define LISS_SELECTEDNOTFOCUS 5
44# define LISS_HOTSELECTED 6
47# define BP_COMMANDLINK 6
48# define BP_COMMANDLINKGLYPH 7
49# define CMDLGS_NORMAL 1
51# define CMDLGS_PRESSED 3
52# define CMDLGS_DISABLED 4
57HWND QWindowsVistaStylePrivate::m_vistaTreeViewHelper =
nullptr;
58bool QWindowsVistaStylePrivate::useVistaTheme =
false;
63 HRGN rgn = CreateRectRgn(
r.left(),
r.top(),
r.x() +
r.width(),
r.y() +
r.height());
65 HRGN dest = CreateRectRgn(0,0,0,0);
66 int result = CombineRgn(dest, winRegion, rgn, RGN_OR);
68 DeleteObject(winRegion);
77 HRGN hRegion = CreateRectRgn(0,0,0,0);
89 if (
const auto *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(
option))
109 result = nativeWindowsApp->createMessageWindow(
QStringLiteral(
"QTreeViewThemeHelperWindowClass"),
136 return r.isValid() && factor > 1
137 ?
QRectF(
r.topLeft() * factor,
r.size() * factor) :
r;
160 return useVistaTheme;
168 if (
ref.ref() && !force)
182 if (bufferDC && nullBitmap)
183 SelectObject(bufferDC, nullBitmap);
184 DeleteObject(bufferBitmap);
185 bufferBitmap =
nullptr;
192 if (
ref.deref() && !force)
197 useVistaTheme =
false;
203 BOOL animEnabled =
false;
204 if (SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &animEnabled, 0))
238 return QWindowsVistaStylePrivate::InvalidMetric;
257 return QWindowsVistaStylePrivate::InvalidMetric;
260bool QWindowsVistaStylePrivate::initVistaTreeViewTheming()
262 if (m_vistaTreeViewHelper)
266 if (!m_vistaTreeViewHelper) {
267 qWarning(
"Unable to create the treeview helper window.");
270 if (FAILED(SetWindowTheme(m_vistaTreeViewHelper, L
"explorer",
nullptr))) {
272 cleanupVistaTreeViewTheming();
278void QWindowsVistaStylePrivate::cleanupVistaTreeViewTheming()
280 if (m_vistaTreeViewHelper) {
281 DestroyWindow(m_vistaTreeViewHelper);
282 m_vistaTreeViewHelper =
nullptr;
294 QWindowsVistaStylePrivate::cleanupVistaTreeViewTheming();
299 if (theme ==
VistaTreeViewTheme && QWindowsVistaStylePrivate::initVistaTreeViewTheming())
300 hwnd = QWindowsVistaStylePrivate::m_vistaTreeViewHelper;
309 if (
QBackingStore *topLevelBackingStore = topLevel->backingStore())
310 return topLevelBackingStore;
335 if (!parent1 || parent1->isWindow())
339 && parent2->inherits(
"QAbstractItemView");
345 uint resolveMask =
option->palette.resolveMask();
350#if QT_CONFIG(spinbox)
352 resolveMask |= spinbox->palette().resolveMask();
367 if (
const HWND hwnd = QApplicationPrivate::getHWNDForWidget(
const_cast<QWidget *
>(
widget)))
375 return reinterpret_cast<HWND
>(
window->winId());
378 return GetDesktopWindow();
390 if (bufferW >=
w && bufferH >=
h)
393 if (bufferDC && nullBitmap)
394 SelectObject(bufferDC, nullBitmap);
395 DeleteObject(bufferBitmap);
396 bufferBitmap =
nullptr;
403 HDC displayDC = GetDC(
nullptr);
404 bufferDC = CreateCompatibleDC(displayDC);
405 ReleaseDC(
nullptr, displayDC);
410 memset(&bmi, 0,
sizeof(bmi));
411 bmi.bmiHeader.biSize =
sizeof(BITMAPINFOHEADER);
412 bmi.bmiHeader.biWidth =
w;
413 bmi.bmiHeader.biHeight = -
h;
414 bmi.bmiHeader.biPlanes = 1;
415 bmi.bmiHeader.biBitCount = 32;
416 bmi.bmiHeader.biCompression = BI_RGB;
419 bufferPixels =
nullptr;
420 bufferBitmap = CreateDIBSection(bufferDC, &bmi, DIB_RGB_COLORS,
reinterpret_cast<void **
>(&bufferPixels),
nullptr, 0);
422 nullBitmap =
static_cast<HBITMAP
>(SelectObject(bufferDC, bufferBitmap));
425 qErrnoWarning(
"QWindowsVistaStylePrivate::buffer(%dx%d), CreateDIBSection() failed.",
w,
h);
431 qErrnoWarning(
"QWindowsVistaStylePrivate::buffer(%dx%d), CreateDIBSection() did not allocate pixel data.",
w,
h);
439 qDebug(
"Creating new dib section (%d, %d)",
w,
h);
452 return IsThemeBackgroundPartiallyTransparent(themeData.handle(), themeData.partId,
463 const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(themeData.widget);
464 RECT
rect = themeData.toRECT(
QRect(themeData.rect.topLeft() / factor, themeData.rect.size() / factor));
465 if (!SUCCEEDED(GetThemeBackgroundRegion(themeData.handle(),
bufferHDC(), themeData.partId,
466 themeData.stateId, &
rect, &hRgn))) {
470 HRGN dest = CreateRectRgn(0, 0, 0, 0);
471 const bool success = CombineRgn(dest, hRgn,
nullptr, RGN_COPY) !=
ERROR;
476 QVarLengthArray<char>
buf(256);
477 RGNDATA *
rd =
reinterpret_cast<RGNDATA *
>(
buf.data());
478 if (GetRegionData(dest,
buf.size(),
rd) == 0) {
479 const auto numBytes = GetRegionData(dest, 0,
nullptr);
481 buf.resize(numBytes);
482 rd =
reinterpret_cast<RGNDATA *
>(
buf.data());
483 if (GetRegionData(dest, numBytes,
rd) == 0)
490 RECT *
r =
reinterpret_cast<RECT *
>(
rd->Buffer);
491 for (
uint i = 0;
i <
rd->rdh.nCount; ++
i) {
494 int((
r->right - 1) * factor), int((
r->bottom - 1) * factor));
513 const int startX =
rect.left();
514 const int startY =
rect.top();
515 const int w =
rect.width();
516 const int h =
rect.height();
519 for (
int y = startY;
y <
h/2; ++
y) {
520 auto buffer =
reinterpret_cast<const DWORD *
>(bufferPixels) + (
y * bufferW);
522 int alpha = (*buffer) >> 24;
523 if (firstAlpha == -1)
525 else if (
alpha != firstAlpha)
542 const int startX =
rect.left();
543 const int startY =
rect.top();
544 const int w =
rect.width();
545 const int h =
rect.height();
546 bool hasFixedAlphaValue =
false;
548 for (
int y = startY;
y <
h; ++
y) {
549 auto buffer =
reinterpret_cast<DWORD *
>(bufferPixels) + (
y * bufferW);
555 hasFixedAlphaValue =
true;
559 return hasFixedAlphaValue;
573 const int startX =
rect.left();
574 const int startY =
rect.top();
575 const int w =
rect.width();
576 const int h =
rect.height();
577 bool valueChange =
false;
580 for (
int y = startY;
y <
h; ++
y) {
581 auto buffer =
reinterpret_cast<DWORD *
>(bufferPixels) + (
y * bufferW);
587 unsigned int alphaValue = (*buffer) & 0xFF000000;
588 if (alphaValue == 0xFF000000) {
591 }
else if (alphaValue == 0) {
613 if (themeData.rect.isEmpty())
617 Q_ASSERT_X(
painter !=
nullptr,
"QWindowsVistaStylePrivate::drawBackground()",
"Trying to draw a theme part without a painter");
626 bool translucentToplevel =
false;
636 bool canDrawDirectly =
false;
637 if (themeData.widget &&
painter->
opacity() == 1.0 && !themeData.rotate
639 && tt !=
ComplexTransform && !themeData.mirrorVertically && !themeData.invertPixels
640 && !translucentToplevel) {
643 switch (enginePaintDevice->devType()) {
645 canDrawDirectly =
true;
650 if (bs->size().isValid() && bs->paintDevice() == enginePaintDevice)
651 canDrawDirectly =
true;
676 const QRect area =
scaleRect(
QRectF(themeData.rect), additionalDevicePixelRatio).translated(redirectionDelta).toRect();
679 if (sysRgn.isEmpty())
686 SelectClipRgn(dc, hrgn);
689 printf(
"---[ DIRECT PAINTING ]------------------> Name(%-10s) Part(%d) State(%d)\n",
690 qPrintable(themeData.name), themeData.partId, themeData.stateId);
691 showProperties(themeData);
694 RECT drawRECT = themeData.toRECT(
area);
695 DTBGOPTS drawOptions;
696 memset(&drawOptions, 0,
sizeof(drawOptions));
697 drawOptions.dwSize =
sizeof(drawOptions);
698 drawOptions.rcClip = themeData.toRECT(sysRgn.boundingRect());
699 drawOptions.dwFlags = DTBG_CLIPRECT
700 | (themeData.noBorder ? DTBG_OMITBORDER : 0)
701 | (themeData.noContent ? DTBG_OMITCONTENT : 0)
702 | (themeData.mirrorHorizontally ? DTBG_MIRRORDC : 0);
704 const HRESULT result = DrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions);
705 SelectClipRgn(dc,
nullptr);
723 qreal additionalDevicePixelRatio,
724 qreal correctionFactor)
729 if ((themeData.rotate + 90) % 180 == 0) {
736 const QRect drawRect = hasCorrectionFactor
739 int partId = themeData.partId;
740 int stateId = themeData.stateId;
741 int w =
rect.width();
742 int h =
rect.height();
746 bool stateHasData =
true;
748 bool partIsTransparent;
749 bool potentialInvalidAlpha;
752 pixmapCacheKey.append(
themeName(themeData.theme));
767 if (hasCorrectionFactor) {
776 bool haveCachedPixmap =
false;
779 partIsTransparent =
data.partIsTransparent;
781 alphaType =
data.alphaType;
782 potentialInvalidAlpha =
data.hadInvalidAlpha;
788 ::sprintf(
buf,
"+ Pixmap(%3d, %3d) ]",
w,
h);
789 printf(
"---[ CACHED %s--------> Name(%-10s) Part(%d) State(%d)\n",
790 haveCachedPixmap ?
buf :
"]-------------------",
791 qPrintable(themeData.name), themeData.partId, themeData.stateId);
795 BOOL tmt_borderonly =
false;
796 COLORREF tmt_transparentcolor = 0x0;
797 PROPERTYORIGIN proporigin = PO_NOTFOUND;
798 GetThemeBool(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERONLY, &tmt_borderonly);
799 GetThemeColor(themeData.handle(), themeData.partId, themeData.stateId, TMT_TRANSPARENTCOLOR, &tmt_transparentcolor);
800 GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_CAPTIONMARGINS, &proporigin);
804 potentialInvalidAlpha =
false;
805 GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_GLYPHTYPE, &proporigin);
806 if (proporigin == PO_PART || proporigin == PO_STATE) {
807 int tmt_glyphtype = GT_NONE;
808 GetThemeEnumValue(themeData.handle(), themeData.partId, themeData.stateId, TMT_GLYPHTYPE, &tmt_glyphtype);
809 potentialInvalidAlpha = partIsTransparent && tmt_glyphtype == GT_IMAGEGLYPH;
813 printf(
"---[ NOT CACHED ]-----------------------> Name(%-10s) Part(%d) State(%d)\n",
814 qPrintable(themeData.name), themeData.partId, themeData.stateId);
815 printf(
"-->partIsTransparen = %d\n", partIsTransparent);
816 printf(
"-->potentialInvalidAlpha = %d\n", potentialInvalidAlpha);
817 showProperties(themeData);
820 bool wasAlphaSwapped =
false;
821 bool wasAlphaFixed =
false;
827 bool addBorderContentClipping =
false;
830 if (themeData.noBorder || themeData.noContent) {
837 PROPERTYORIGIN origin = PO_NOTFOUND;
838 GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &origin);
839 GetThemeInt(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &borderSize);
840 borderSize *= additionalDevicePixelRatio;
843 if ((origin == PO_CLASS || origin == PO_PART || origin == PO_STATE) && borderSize > 0) {
844 if (themeData.noBorder) {
846 area =
area.adjusted(-borderSize, -borderSize, borderSize, borderSize);
850 if (themeData.noContent) {
851 QRegion content =
area.adjusted(borderSize, borderSize, -borderSize, -borderSize);
852 extraClip ^= content;
855 addBorderContentClipping = (themeData.noBorder | themeData.noContent);
859 if (!haveCachedPixmap) {
867 memset(bufferPixels, 0x00, bufferW * drawRect.
height() * 4);
871 int dx =
area.x() - drawRect.
x();
872 int dy =
area.y() - drawRect.
y();
877 DTBGOPTS drawOptions;
878 drawOptions.dwSize =
sizeof(drawOptions);
879 drawOptions.rcClip = themeData.toRECT(
rect);
880 drawOptions.dwFlags = DTBG_CLIPRECT
881 | (themeData.noBorder ? DTBG_OMITBORDER : 0)
882 | (themeData.noContent ? DTBG_OMITCONTENT : 0);
885 RECT wRect(themeData.toRECT(
area));
886 DrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &wRect, &drawOptions);
893 memset(
static_cast<void *
>(&
data), 0,
sizeof(
data));
894 data.dataValid =
true;
900 potentialInvalidAlpha =
true;
901#if defined(DEBUG_XP_STYLE) && 1
902 dumpNativeDIB(drawRect.
width(), drawRect.
height());
907 if (potentialInvalidAlpha)
911 if ((partIsTransparent && !wasAlphaSwapped) || (!partIsTransparent &&
hasAlpha)) {
914 }
else if (wasAlphaSwapped) {
926#if defined(DEBUG_XP_STYLE) && 1
927 printf(
"Image format is: %s\n", alphaType ==
RealAlpha ?
"Real Alpha" : alphaType ==
MaskAlpha ?
"Masked Alpha" :
"No Alpha");
930 if (themeData.invertPixels)
933 if (hasCorrectionFactor)
935 img.setDevicePixelRatio(additionalDevicePixelRatio);
939 bool useRegion = partIsTransparent && !
hasAlpha && !wasAlphaSwapped;
944 newRegion =
region(themeData);
947#if defined(DEBUG_XP_STYLE) && 0
948 printf(
"Using region:\n");
949 for (
const QRect &
r : newRegion)
950 printf(
" (%d, %d, %d, %d)\n",
r.x(),
r.y(),
r.right(),
r.bottom());
954 if (addBorderContentClipping)
957 if (!themeData.mirrorHorizontally && !themeData.mirrorVertically && !themeData.rotate) {
958 if (!haveCachedPixmap)
969 if (!haveCachedPixmap)
972 imgCopy = cachedPixmap.toImage();
974 if (themeData.rotate) {
976 rotMatrix.
rotate(themeData.rotate);
977 imgCopy = imgCopy.transformed(rotMatrix);
979 if (themeData.mirrorHorizontally || themeData.mirrorVertically)
980 imgCopy = imgCopy.mirrored(themeData.mirrorHorizontally, themeData.mirrorVertically);
984 if (useRegion || addBorderContentClipping) {
985 if (oldRegion.isEmpty())
992 if (!haveCachedPixmap &&
w &&
h) {
996 printf(
"+++Adding pixmap to cache, size(%d, %d), wasAlphaSwapped(%d), wasAlphaFixed(%d), name(%s)\n",
997 w,
h, wasAlphaSwapped, wasAlphaFixed,
qPrintable(pixmapCacheKey));
1003 memset(
static_cast<void *
>(&
data), 0,
sizeof(
data));
1004 data.dataValid =
true;
1005 data.partIsTransparent = partIsTransparent;
1006 data.alphaType = alphaType;
1008 data.wasAlphaSwapped = wasAlphaSwapped;
1009 data.hadInvalidAlpha = wasAlphaFixed;
1025 static bool animationTimeOverride =
q->dynamicPropertyNames().contains(
"_qt_animation_time");
1026 if (animationTimeOverride)
1027 return q->property(
"_qt_animation_time").toTime();
1052 result.setDevicePixelRatio(devicePixelRatio);
1062 if (
const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(
option))
1063 styleOption =
new QStyleOptionSlider(*slider);
1064 else if (
const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox*>(
option))
1065 styleOption =
new QStyleOptionSpinBox(*spinbox);
1083 if (
const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(
option))
1085 else if (
const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox*>(
option))
1100 bool isTitleBarActive,
int part,
1106 theme->
stateId = RBS_DISABLED;
1111 else if (!isTitleBarActive)
1117#if QT_CONFIG(mdiarea)
1142 const auto dpr = pd ? pd->devicePixelRatio() :
qApp->devicePixelRatio();
1145 const auto rawFactor =
qMin(requestedSize.width() / nativeSize.
width(),
1146 requestedSize.height() / nativeSize.
height());
1160 const auto flags = tb->titleBarFlags;
1161 bool retVal =
false;
1207 if (partId == BP_RADIOBUTTON || partId == BP_CHECKBOX) {
1209 stateId = RBS_UNCHECKEDDISABLED;
1211 stateId = RBS_UNCHECKEDPRESSED;
1213 stateId = RBS_UNCHECKEDHOT;
1215 stateId = RBS_UNCHECKEDNORMAL;
1218 stateId += RBS_CHECKEDNORMAL-1;
1220 }
else if (partId == BP_PUSHBUTTON) {
1222 stateId = PBS_DISABLED;
1224 stateId = PBS_PRESSED;
1228 stateId = PBS_NORMAL;
1345 bool doTransition = oldState &&
1346 ((
state & State_Sunken) != (oldState & State_Sunken) ||
1347 (
state & State_On) != (oldState & State_On) ||
1348 (
state & State_MouseOver) != (oldState & State_MouseOver));
1350 if (oldRect != newRect ||
1351 (
state & State_Enabled) != (oldState & State_Enabled) ||
1352 (
state & State_Active) != (oldState & State_Active))
1355 if (
state & State_ReadOnly && element == PE_FrameLineEdit)
1356 doTransition =
false;
1360 styleOption->
state = QStyle::State(oldState);
1368 QPainter startPainter(&startImage);
1377 proxy()->drawPrimitive(element, styleOption, &startPainter,
widget);
1379 animate->
paint(&startPainter, styleOption);
1387 proxy()->drawPrimitive(element, styleOption, &endPainter,
widget);
1398 if (element == PE_FrameLineEdit) {
1399 theme = OpenThemeData(
nullptr, L
"Edit");
1400 partId = EP_EDITBORDER_NOSCROLL;
1402 if (oldState & State_HasFocus)
1403 fromState = ETS_SELECTED;
1404 else if (oldState & State_MouseOver)
1405 fromState = ETS_HOT;
1407 fromState = ETS_NORMAL;
1409 if (
state & State_HasFocus)
1410 toState = ETS_SELECTED;
1411 else if (
state & State_MouseOver)
1414 toState = ETS_NORMAL;
1417 theme = OpenThemeData(
nullptr, L
"Button");
1418 if (element == PE_IndicatorRadioButton)
1419 partId = BP_RADIOBUTTON;
1420 else if (element == PE_IndicatorCheckBox)
1421 partId = BP_CHECKBOX;
1423 partId = BP_PUSHBUTTON;
1431 && SUCCEEDED(GetThemeTransitionDuration(theme, partId, fromState, toState,
1432 TMT_TRANSITIONDURATIONS, &duration))) {
1438 d->startAnimation(transition);
1444 int themeNumber = -1;
1447 bool hMirrored =
false;
1448 bool vMirrored =
false;
1449 bool noBorder =
false;
1450 bool noContent =
false;
1454 case PE_PanelButtonCommand:
1455 if (
const auto *
btn = qstyleoption_cast<const QStyleOptionButton *>(
option)) {
1457 if (!(
state & State_Sunken) && (
state & State_On))
1465 }
else if (
state & (State_Raised | State_On | State_Sunken)) {
1474 case PE_PanelButtonTool:
1475#if QT_CONFIG(dockwidget)
1478 if (dw->isWindow()) {
1485 if (!(
option->state & State_Enabled))
1486 stateId = TS_DISABLED;
1487 else if (
option->state & State_Sunken)
1488 stateId = TS_PRESSED;
1489 else if (
option->state & State_MouseOver)
1490 stateId =
option->state & State_On ? TS_HOTCHECKED : TS_HOT;
1491 else if (
option->state & State_On)
1492 stateId = TS_CHECKED;
1493 else if (!(
option->state & State_AutoRaise))
1496 stateId = TS_NORMAL;
1500 case PE_IndicatorHeaderArrow:
1501 if (
const auto *
header = qstyleoption_cast<const QStyleOptionHeader *>(
option)) {
1502 int stateId = HSAS_SORTEDDOWN;
1504 stateId = HSAS_SORTEDUP;
1507 HP_HEADERSORTARROW, stateId,
option->rect);
1508 d->drawBackground(theme);
1513 case PE_IndicatorCheckBox:
1520 partId = BP_CHECKBOX;
1522 if (!(
option->state & State_Enabled))
1523 stateId = CBS_UNCHECKEDDISABLED;
1524 else if (
option->state & State_Sunken)
1525 stateId = CBS_UNCHECKEDPRESSED;
1526 else if (
option->state & State_MouseOver)
1527 stateId = CBS_UNCHECKEDHOT;
1529 stateId = CBS_UNCHECKEDNORMAL;
1531 if (
option->state & State_On)
1532 stateId += CBS_CHECKEDNORMAL-1;
1533 else if (
option->state & State_NoChange)
1534 stateId += CBS_MIXEDNORMAL-1;
1538 case PE_IndicatorItemViewItemCheck: {
1540 button.QStyleOption::operator=(*option);
1541 button.state &= ~State_MouseOver;
1546 case PE_IndicatorBranch: {
1548 static int decoration_size = 0;
1549 if (!decoration_size && theme.
isValid()) {
1551 themeSize.
partId = TVP_HOTGLYPH;
1552 themeSize.
stateId = GLPS_OPENED;
1556 int mid_h =
option->rect.x() +
option->rect.width() / 2;
1557 int mid_v =
option->rect.y() +
option->rect.height() / 2;
1558 if (
option->state & State_Children) {
1559 int delta = decoration_size / 2;
1560 theme.
rect =
QRect(mid_h - delta, mid_v - delta, decoration_size, decoration_size);
1561 theme.
partId =
option->state & State_MouseOver ? TVP_HOTGLYPH : TVP_GLYPH;
1565 d->drawBackground(theme);
1570 case PE_PanelButtonBevel:
1578 partId = BP_PUSHBUTTON;
1579 if (!(
option->state & State_Enabled))
1580 stateId = PBS_DISABLED;
1581 else if ((
option->state & State_Sunken) || (
option->state & State_On))
1582 stateId = PBS_PRESSED;
1583 else if (
option->state & State_MouseOver)
1586 stateId = PBS_NORMAL;
1589 case PE_IndicatorRadioButton:
1596 partId = BP_RADIOBUTTON;
1598 if (!(
option->state & State_Enabled))
1599 stateId = RBS_UNCHECKEDDISABLED;
1600 else if (
option->state & State_Sunken)
1601 stateId = RBS_UNCHECKEDPRESSED;
1602 else if (
option->state & State_MouseOver)
1603 stateId = RBS_UNCHECKEDHOT;
1605 stateId = RBS_UNCHECKEDNORMAL;
1607 if (
option->state & State_On)
1608 stateId += RBS_CHECKEDNORMAL-1;
1613#if QT_CONFIG(accessibility)
1614 if (QStyleHelper::isInstanceOf(
option->styleObject, QAccessible::EditableText)
1615 || QStyleHelper::isInstanceOf(
option->styleObject, QAccessible::StaticText) ||
1621 int stateId = ETS_NORMAL;
1622 if (!(state & State_Enabled))
1623 stateId = ETS_DISABLED;
1624 else if (state & State_ReadOnly)
1625 stateId = ETS_READONLY;
1626 else if (state & State_HasFocus)
1627 stateId = ETS_SELECTED;
1628 QWindowsThemeData theme(widget, painter,
1629 QWindowsVistaStylePrivate::EditTheme,
1630 EP_EDITBORDER_HVSCROLL, stateId, option->rect);
1633 GetThemeInt(theme.handle(), theme.partId, theme.stateId, TMT_BORDERSIZE, &borderSize);
1634 QRegion clipRegion = option->rect;
1635 QRegion content = option->rect.adjusted(borderSize, borderSize, -borderSize, -borderSize);
1636 clipRegion ^= content;
1637 painter->setClipRegion(clipRegion);
1638 d->drawBackground(theme);
1642 if (option->state & State_Raised)
1645 themeNumber = QWindowsVistaStylePrivate::ListViewTheme;
1646 partId = LVP_LISTGROUP;
1647 QWindowsThemeData theme(widget, nullptr, themeNumber, partId);
1649 if (!(option->state & State_Enabled))
1650 stateId = ETS_DISABLED;
1652 stateId = ETS_NORMAL;
1656 if (GetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &fillType) == S_OK) {
1657 if (fillType == BT_BORDERFILL) {
1659 GetThemeColor(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &bcRef);
1660 QColor bordercolor(qRgb(GetRValue(bcRef), GetGValue(bcRef), GetBValue(bcRef)));
1661 QPen oldPen = painter->pen();
1664 painter->setPen(QPen(option->palette.base().color(), 0));
1665 const qreal dpi = QStyleHelper::dpi(option);
1666 const auto topLevelAdjustment = QStyleHelper::dpiScaled(0.5, dpi);
1667 const auto bottomRightAdjustment = QStyleHelper::dpiScaled(-1, dpi);
1668 painter->drawRect(QRectF(option->rect).adjusted(topLevelAdjustment, topLevelAdjustment,
1669 bottomRightAdjustment, bottomRightAdjustment));
1671 painter->setPen(QPen(bordercolor, 0));
1672 painter->drawRect(QRectF(option->rect).adjusted(0, 0, -topLevelAdjustment, -topLevelAdjustment));
1673 painter->setPen(oldPen);
1676 if (fillType == BT_BORDERFILL || fillType == BT_NONE)
1682 case PE_FrameMenu: {
1683 int stateId =
option->state & State_Active ? MB_ACTIVE : MB_INACTIVE;
1686 MENU_POPUPBORDERS, stateId,
option->rect);
1687 d->drawBackground(theme);
1691 case PE_PanelMenuBar:
1694#if QT_CONFIG(dockwidget)
1695 case PE_IndicatorDockWidgetResizeHandle:
1698 case PE_FrameDockWidget:
1699 if (
const auto *frm = qstyleoption_cast<const QStyleOptionFrame *>(
option)) {
1701 if (
option->state & State_Active)
1702 stateId = FS_ACTIVE;
1704 stateId = FS_INACTIVE;
1706 int fwidth =
proxy()->pixelMetric(PM_DockWidgetFrameWidth, frm,
widget);
1713 theme.
rect =
QRect(frm->rect.x(), frm->rect.y(), frm->rect.x()+fwidth, frm->rect.height()-fwidth);
1714 theme.
partId = WP_SMALLFRAMELEFT;
1715 d->drawBackground(theme);
1716 theme.
rect =
QRect(frm->rect.width()-fwidth, frm->rect.y(), fwidth, frm->rect.height()-fwidth);
1717 theme.
partId = WP_SMALLFRAMERIGHT;
1718 d->drawBackground(theme);
1719 theme.
rect =
QRect(frm->rect.x(), frm->rect.bottom()-fwidth+1, frm->rect.width(), fwidth);
1720 theme.
partId = WP_SMALLFRAMEBOTTOM;
1721 d->drawBackground(theme);
1727 case PE_FrameTabWidget:
1728 if (
const auto *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(
option)) {
1733 bool useGradient =
true;
1734 const int maxlength = 256;
1735 wchar_t themeFileName[maxlength];
1736 wchar_t themeColor[maxlength];
1738 if (GetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength,
nullptr, 0) == S_OK) {
1739 wchar_t *
offset =
nullptr;
1742 if (!lstrcmp(
offset, L
"Luna.msstyles") && !lstrcmp(
offset, L
"Metallic"))
1743 useGradient =
false;
1749 QStyleOptionTabWidgetFrame frameOpt = *tab;
1753 reg -= contentsRect;
1758 d->drawBackground(theme);
1763 switch (tab->shape) {
1786 case PE_FrameStatusBarItem:
1791 case PE_FrameWindow:
1792 if (
const auto *frm = qstyleoption_cast<const QStyleOptionFrame *>(
option)) {
1794 if (
option->state & State_Active)
1795 stateId = FS_ACTIVE;
1797 stateId = FS_INACTIVE;
1799 int fwidth = int((frm->lineWidth + frm->midLineWidth) / QWindowsStylePrivate::nativeMetricScaleFactor(
widget));
1807 theme.
partId = WP_FRAMELEFT;
1808 if (!
d->drawBackground(theme)) {
1813 theme.
partId = WP_FRAMERIGHT;
1814 if (!
d->drawBackground(theme)) {
1819 theme.
partId = WP_FRAMEBOTTOM;
1820 if (!
d->drawBackground(theme)) {
1825 theme.
partId = WP_CAPTION;
1826 if (!
d->drawBackground(theme))
1832 case PE_PanelLineEdit:
1833 if (
const auto *
panel = qstyleoption_cast<const QStyleOptionFrame *>(
option)) {
1834 bool isEnabled =
state & State_Enabled;
1838 int partId = EP_BACKGROUND;
1839 int stateId = EBS_NORMAL;
1841 stateId = EBS_DISABLED;
1842 else if (
option->state & State_ReadOnly)
1843 stateId = EBS_READONLY;
1844 else if (
option->state & State_MouseOver)
1848 partId, stateId,
rect);
1854 GetThemeEnumValue(theme.
handle(), partId, stateId, TMT_BGTYPE, &bgType);
1855 if (bgType == BT_IMAGEFILE) {
1856 d->drawBackground(theme);
1860 PROPERTYORIGIN origin = PO_NOTFOUND;
1861 GetThemePropertyOrigin(theme.
handle(), theme.
partId, theme.
stateId, TMT_FILLCOLOR, &origin);
1863 if ((origin == PO_PART || origin == PO_STATE)) {
1865 GetThemeColor(theme.
handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
1866 fillColor =
QBrush(
qRgb(GetRValue(bgRef), GetGValue(bgRef), GetBValue(bgRef)));
1872 if (
panel->lineWidth > 0)
1877 case PE_IndicatorButtonDropDown:
1879 partId = TP_SPLITBUTTONDROPDOWN;
1880 if (!(
option->state & State_Enabled))
1881 stateId = TS_DISABLED;
1882 else if (
option->state & State_Sunken)
1883 stateId = TS_PRESSED;
1884 else if (
option->state & State_MouseOver)
1885 stateId =
option->state & State_On ? TS_HOTCHECKED : TS_HOT;
1886 else if (
option->state & State_On)
1887 stateId = TS_CHECKED;
1888 else if (!(
option->state & State_AutoRaise))
1891 stateId = TS_NORMAL;
1896 case PE_FrameLineEdit:
1912 int stateId = ETS_NORMAL;
1913 if (!(
state & State_Enabled))
1914 stateId = ETS_DISABLED;
1915 else if (
state & State_ReadOnly)
1916 stateId = ETS_READONLY;
1917 else if (
state & State_HasFocus)
1918 stateId = ETS_SELECTED;
1919 else if (
state & State_MouseOver)
1923 EP_EDITBORDER_NOSCROLL, stateId,
option->rect);
1927 clipRegion -=
option->rect.adjusted(2, 2, -2, -2);
1929 d->drawBackground(theme);
1934 case PE_FrameGroupBox:
1936 partId = BP_GROUPBOX;
1937 if (!(
option->state & State_Enabled))
1938 stateId = GBS_DISABLED;
1940 stateId = GBS_NORMAL;
1941 if (
const auto *
frame = qstyleoption_cast<const QStyleOptionFrame *>(
option)) {
1953 case PE_IndicatorToolBarHandle: {
1956 if (
option->state & State_Horizontal) {
1959 RP_GRIPPER, ETS_NORMAL,
option->rect.adjusted(0, 1, -2, -2));
1964 RP_GRIPPERVERT, ETS_NORMAL,
option->rect.adjusted(0, 1, -2, -2));
1969 d->drawBackground(theme);
1973 case PE_IndicatorToolBarSeparator: {
1977 if (
option->state & State_Horizontal) {
1978 int x1 =
option->rect.center().x();
1981 int y1 =
option->rect.center().y();
1988 case PE_PanelTipLabel: {
1991 TTP_STANDARD, TTSS_NORMAL,
option->rect);
1992 d->drawBackground(theme);
1996 case PE_FrameTabBarBase:
1997 if (
const auto *tbb = qstyleoption_cast<const QStyleOptionTabBarBase *>(
option)) {
1999 switch (tbb->shape) {
2006 painter->
drawLine(tbb->rect.left(), tbb->rect.top(), tbb->rect.left(), tbb->rect.bottom());
2011 tbb->rect.right(), tbb->rect.top());
2030#if QT_CONFIG(dialogbuttonbox)
2032 if (qobject_cast<const QMessageBox *> (
widget))
2034#if QT_CONFIG(inputdialog)
2035 else if (qobject_cast<const QInputDialog *> (
widget))
2042 TDLG_PRIMARYPANEL, 0,
option->rect);
2045 theme.
rect = toprect;
2046 d->drawBackground(theme);
2051 theme.
rect = buttonRect;
2052 theme.
partId = TDLG_SECONDARYPANEL;
2053 d->drawBackground(theme);
2059 case PE_PanelItemViewItem: {
2060 const QStyleOptionViewItem *vopt;
2061 bool newStyle =
true;
2065 newStyle = !qobject_cast<const QTableView*>(
view);
2066 selectionBehavior =
view->selectionBehavior();
2067 selectionMode =
view->selectionMode();
2068#if QT_CONFIG(accessibility)
2070 newStyle = !QStyleHelper::hasAncestor(
option->styleObject, QAccessible::MenuItem) ;
2074 if (newStyle && (vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
option))) {
2079 if (vopt->features & QStyleOptionViewItem::Alternate)
2088 itemRect.
setTop(vopt->rect.top());
2089 itemRect.
setBottom(vopt->rect.bottom());
2092 if (vopt->showDecorationSelected)
2093 sectionSize = vopt->rect.size();
2096 sectionSize.
setWidth(vopt->rect.width());
2099 if (vopt->backgroundBrush.style() !=
Qt::NoBrush) {
2106 if (hover || selected) {
2107 if (sectionSize.
width() > 0 && sectionSize.
height() > 0) {
2109 .arg(sectionSize.
height()).arg(selected).arg(active).arg(hover);
2115 if (selected && hover)
2117 else if (selected && !active)
2133 d->drawBackground(theme);
2138 if (vopt->showDecorationSelected) {
2139 const int frame = 2;
2141 QRect pixmapRect = vopt->rect;
2143 bool leftSection = vopt->viewItemPosition == QStyleOptionViewItem::Beginning;
2144 bool rightSection = vopt->viewItemPosition == QStyleOptionViewItem::End;
2145 if (vopt->viewItemPosition == QStyleOptionViewItem::OnlyOne
2146 || vopt->viewItemPosition == QStyleOptionViewItem::Invalid)
2148 else if (reverse ? rightSection : leftSection){
2154 }
else if (reverse ? leftSection : rightSection) {
2161 }
else if (vopt->viewItemPosition == QStyleOptionViewItem::Middle)
2165 if (vopt->text.isEmpty() && vopt->icon.isNull())
2192 d->drawBackground(theme);
2203 case SH_EtchDisabledText:
2204 ret = (qobject_cast<const QLabel*>(
widget) != 0);
2207 case SH_SpinControls_DisableOnBounds:
2211 case SH_TitleBar_AutoRaise:
2212 case SH_TitleBar_NoBorder:
2216 case SH_GroupBox_TextLabelColor:
2220 ret =
d->groupBoxTextColorDisabled;
2223 case SH_WindowFrame_Mask: {
2225 auto *
mask = qstyleoption_cast<QStyleHintReturnMask *>(returnData);
2226 const auto *titlebar = qstyleoption_cast<const QStyleOptionTitleBar *>(
option);
2227 if (
mask && titlebar) {
2238 WP_MINCAPTION, CS_ACTIVE, titleBarRect);
2242 WP_CAPTION, CS_ACTIVE, titleBarRect);
2243 mask->region =
d->region(themeData) +
2249#if QT_CONFIG(rubberband)
2250 case SH_RubberBand_Mask:
2251 if (qstyleoption_cast<const QStyleOptionRubberBand *>(
option))
2256 case SH_MessageBox_CenterButtons:
2260 case SH_ToolTip_Mask:
2267 mask->region =
d->region(themeData);
2272 case SH_Table_GridLineColor:
2279 case SH_Header_ArrowAlignment:
2283 case SH_ItemView_DrawDelegateFrame:
2311 bool selected =
option->state & State_Selected;
2312 bool pressed =
option->state & State_Sunken;
2316 int themeNumber = -1;
2324 if (element == CE_PushButtonBevel) {
2336 bool wasDefault =
false;
2337 bool isDefault =
false;
2344 bool doTransition = ((
state & State_Sunken) != (oldState & State_Sunken) ||
2345 (
state & State_On) != (oldState & State_On) ||
2346 (
state & State_MouseOver) != (oldState & State_MouseOver));
2348 if (oldRect != newRect || (wasDefault && !isDefault)) {
2349 doTransition =
false;
2359 styleOption->
state = QStyle::State(oldState);
2362 QPainter startPainter(&startImage);
2366 proxy()->drawControl(element, styleOption, &startPainter,
widget);
2368 anim->
paint(&startPainter, styleOption);
2372 t->setStartImage(startImage);
2376 proxy()->drawControl(element, styleOption, &endPainter,
widget);
2377 t->setEndImage(endImage);
2381 const HTHEME theme = OpenThemeData(
nullptr, L
"Button");
2385 if (GetThemeTransitionDuration(theme, BP_PUSHBUTTON, fromState, toState, TMT_TRANSITIONDURATIONS, &duration) == S_OK)
2386 t->setDuration(
int(duration));
2389 t->setStartTime(
d->animationTime());
2393 d->startAnimation(
t);
2405 bool hMirrored =
false;
2406 bool vMirrored =
false;
2410 case CE_PushButtonBevel:
2413 partId = BP_PUSHBUTTON;
2418 stateId = PBS_DISABLED;
2421 else if (
flags & (State_Sunken | State_On))
2422 stateId = PBS_PRESSED;
2423 else if (
flags & State_MouseOver)
2426 stateId = PBS_DEFAULTED;
2428 stateId = PBS_NORMAL;
2433 !(
state & (State_Sunken | State_On)) && !(
state & State_MouseOver) &&
2434 (
state & State_Enabled) && (
state & State_Active))
2444 QPainter startPainter(&startImage);
2445 stateId = PBS_DEFAULTED;
2447 d->drawBackground(theme);
2449 QPainter alternatePainter(&alternateImage);
2450 theme.
stateId = PBS_DEFAULTED_ANIMATING;
2451 theme.
painter = &alternatePainter;
2452 d->drawBackground(theme);
2458 d->startAnimation(pulse);
2466 d->drawBackground(theme);
2471 d->drawBackground(theme);
2476 int mbiw = 0, mbih = 0;
2481 if (!
size.isEmpty()) {
2489 QRect(ir.right() - mbiw - 2,
2490 option->rect.top() + (
option->rect.height()/2) - (mbih/2),
2491 mbiw + 1, mbih + 1));
2499 partId = SP_GRIPPER;
2501 QSize size = (theme.
size() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget)).toSize();
2503 if (
const auto *sg = qstyleoption_cast<const QStyleOptionSizeGrip *>(
option)) {
2504 switch (sg->corner) {
2518 hMirrored = vMirrored =
true;
2529 if (
const auto *tab = qstyleoption_cast<const QStyleOptionTab *>(
option))
2530 stateId = tab->state & State_Enabled ? TIS_NORMAL : TIS_DISABLED;
2533 case CE_TabBarTabShape:
2534 if (
const auto *tab = qstyleoption_cast<const QStyleOptionTab *>(
option)) {
2536 const bool isDisabled = !(tab->state & State_Enabled);
2537 const bool hasFocus = tab->state & State_HasFocus;
2538 const bool isHot = tab->state & State_MouseOver;
2539 const bool selected = tab->state & State_Selected;
2540 bool lastTab = tab->position == QStyleOptionTab::End;
2541 bool firstTab = tab->position == QStyleOptionTab::Beginning;
2542 const bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
2545 const int borderThickness =
proxy()->pixelMetric(PM_DefaultFrameWidth,
option,
widget);
2546 const int tabOverlap =
proxy()->pixelMetric(PM_TabBarTabOverlap,
option,
widget);
2549 stateId = TIS_DISABLED;
2551 stateId = TIS_SELECTED;
2553 stateId = TIS_FOCUSED;
2557 stateId = TIS_NORMAL;
2560 if (firstTab || onlyOne) {
2562 partId = TABP_TABITEMLEFTEDGE;
2563 else if (centerAligned)
2564 partId = TABP_TABITEM;
2566 partId = TABP_TABITEMRIGHTEDGE;
2568 partId = TABP_TABITEM;
2573 bool temp = firstTab;
2578 const bool begin = firstTab || onlyOne;
2579 const bool end = lastTab || onlyOne;
2581 switch (tab->shape) {
2584 rect.adjust(
begin ? 0 : -tabOverlap, 0,
end ? 0 : tabOverlap, borderThickness);
2586 rect.adjust(
begin? tabOverlap : 0, tabOverlap,
end ? -tabOverlap : 0, 0);
2592 rect.adjust(
begin ? 0 : -tabOverlap , -borderThickness,
end ? 0 : tabOverlap, 0);
2594 rect.adjust(
begin ? tabOverlap : 0, 0,
end ? -tabOverlap : 0 , -tabOverlap);
2599 rect.adjust(-borderThickness,
begin ? 0 : -tabOverlap, 0,
end ? 0 : tabOverlap);
2601 rect.adjust(0,
begin ? tabOverlap : 0, -tabOverlap,
end ? -tabOverlap : 0);
2607 rect.adjust(0,
begin ? 0 : -tabOverlap, borderThickness,
end ? 0 : tabOverlap);
2609 rect.adjust(tabOverlap,
begin ? tabOverlap : 0, 0,
end ? -tabOverlap : 0);
2617 switch (tab->shape) {
2619 rect.adjust(0,0, 0,-1);
2622 rect.adjust(0,1, 0,0);
2625 rect.adjust( 1,0, 0,0);
2628 rect.adjust(0,0, -1,0);
2637 case CE_ProgressBarGroove: {
2639 if (
const auto *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(
option))
2649 case CE_ProgressBarContents:
2650 if (
const auto *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(
option)) {
2651 bool isIndeterminate = (bar->minimum == 0 && bar->maximum == 0);
2653 const bool inverted = bar->invertedAppearance;
2655 if (isIndeterminate || (bar->progress > 0 && (bar->progress < bar->maximum) &&
d->transitionsEnabled())) {
2664 vertical ? PP_FILLVERT : PP_FILL);
2667 QTime current =
d->animationTime();
2669 if (isIndeterminate) {
2670 if (
auto *progressAnimation = qobject_cast<QProgressStyleAnimation *>(
d->animation(
styleObject(
option)))) {
2672 int animationWidth = glowSize * 2 + (vertical ? theme.
rect.
height() : theme.
rect.
width());
2673 int animOffset = progressAnimation->startTime().
msecsTo(current) / 4;
2674 if (animOffset > animationWidth)
2675 progressAnimation->setStartTime(
d->animationTime());
2679 QSize pixmapSize(14, 14);
2682 inverted ?
rect.top() - glowSize + animOffset :
2683 rect.bottom() + glowSize - animOffset,
2684 rect.width(), glowSize);
2685 pixmapSize.
setHeight(animRect.height());
2687 animRect =
QRect(
rect.left() - glowSize + animOffset,
2688 rect.top(), glowSize,
rect.height());
2691 pixmapSize.setWidth(animRect.width());
2699 theme.
painter = &imagePainter;
2700 theme.
partId = vertical ? PP_FILLVERT : PP_FILL;
2703 vertical ?
image.height() : 0);
2709 d->drawBackground(theme);
2718 qint64 progress = qMax<qint64>(bar->progress, bar->minimum);
2721 int maxHeight =
option->rect.height();
2723 double vc6_workaround = ((progress -
qint64(bar->minimum)) /
qMax(
double(1.0), double(
qint64(bar->maximum) -
qint64(bar->minimum))) * maxHeight);
2724 int height = isIndeterminate ? maxHeight:
qMax(
int(vc6_workaround), minHeight);
2729 int maxWidth =
option->rect.width();
2731 double vc6_workaround = ((progress -
qint64(bar->minimum)) /
qMax(
double(1.0), double(
qint64(bar->maximum) -
qint64(bar->minimum))) * maxWidth);
2732 int width = isIndeterminate ? maxWidth :
qMax(
int(vc6_workaround), minWidth);
2737 d->drawBackground(theme);
2741 int animationWidth = glowSize * 2 + (vertical ? theme.
rect.
height() : theme.
rect.
width());
2742 int animOffset =
a->startTime().msecsTo(current) / 4;
2743 theme.
partId = vertical ? PP_MOVEOVERLAYVERT : PP_MOVEOVERLAY;
2744 if (animOffset > animationWidth) {
2745 if (bar->progress < bar->maximum)
2746 a->setStartTime(
d->animationTime());
2755 inverted ?
rect.top() - glowSize + animOffset :
2756 rect.bottom() + glowSize - animOffset,
2757 rect.width(), glowSize);
2762 d->drawBackground(theme);
2769 case CE_MenuBarItem:
2770 if (
const auto *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(
option)) {
2778 if (!
proxy()->styleHint(SH_UnderlineShortcut, mbi,
widget))
2785 MENU_BARBACKGROUND, 0,
option->rect.adjusted(-1, 0, 2, 1));
2786 d->drawBackground(theme);
2788 int stateId = MBI_NORMAL;
2790 stateId = MBI_DISABLED;
2792 stateId = MBI_PUSHED;
2798 MENU_BARITEM, stateId,
option->rect);
2799 d->drawBackground(theme2);
2805 drawItemText(
painter, mbi->rect,
alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole);
2810 case CE_MenuEmptyArea:
2811 if (
const auto *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(
option)) {
2812 QBrush fill = menuitem->palette.brush((menuitem->state & State_Selected) ?
2820 if (
const auto *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(
option)) {
2822 const qreal factor = QWindowsVistaStylePrivate::nativeMetricScaleFactor(
widget);
2824 const int gutterWidth =
qRound(
qreal(3) * factor);
2827 MENU_POPUPCHECKBACKGROUND, MBI_HOT);
2829 themeSize.
partId = MENU_POPUPCHECK;
2833 checkcol =
qMax(menuitem->maxIconWidth,
qRound(gutterWidth +
size.width() + margins.
left() + margins.
right()));
2839 checkcol +=
rect.
x();
2842 QRect gutterRect(
p1.x(),
p1.y(), gutterWidth,
p2.y() -
p1.y() + 1);
2844 MENU_POPUPGUTTER, stateId, gutterRect);
2845 d->drawBackground(theme2);
2848 menuitem->rect.getRect(&
x, &
y, &
w, &
h);
2849 int tab = menuitem->reservedShortcutWidth;
2850 bool dis = !(menuitem->state & State_Enabled);
2852 ? menuitem->checked :
false;
2853 bool act = menuitem->state & State_Selected;
2856 int yoff =
y-2 +
h / 2;
2857 const int separatorSize =
qRound(
qreal(6) * QWindowsStylePrivate::nativeMetricScaleFactor(
widget));
2861 QRect subRect(
p1.x() + (gutterWidth - menuitem->rect.x()),
p1.y(),
2862 p2.x() -
p1.x(), separatorSize);
2866 MENU_POPUPSEPARATOR, stateId, subRect);
2867 d->drawBackground(theme2);
2872 menuitem->rect.y(), checkcol - (gutterWidth + menuitem->rect.x()), menuitem->rect.height()));
2875 stateId = dis ? MBI_DISABLED : MBI_HOT;
2878 MENU_POPUPITEM, stateId,
option->rect);
2879 d->drawBackground(theme2);
2885 MENU_POPUPCHECKBACKGROUND,
2886 menuitem->icon.isNull() ? MBI_HOT : MBI_PUSHED, vCheckRect);
2888 themeSize.partId = MENU_POPUPCHECK;
2889 themeSize.stateId = 0;
2890 const QSizeF size = themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget);
2891 const QMarginsF margins = themeSize.margins() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget);
2894 checkRect.moveCenter(vCheckRect.center());
2895 theme.
rect = checkRect;
2897 d->drawBackground(theme);
2899 if (menuitem->icon.isNull()) {
2902 theme.
rect = checkRect;
2904 theme.
partId = MENU_POPUPCHECK;
2907 theme.
stateId = bullet ? MC_BULLETDISABLED: MC_CHECKMARKDISABLED;
2909 theme.
stateId = bullet ? MC_BULLETNORMAL: MC_CHECKMARKNORMAL;
2910 d->drawBackground(theme);
2914 if (!menuitem->icon.isNull()) {
2923 pmr.moveCenter(vCheckRect.center());
2930 const QColor textColor = menuitem->palette.text().color();
2935 int xpos = menuitem->rect.x() + xm;
2962 PrimitiveElement arrow;
2967 newMI.
rect = vSubMenuRect;
2968 newMI.state = dis ? State_None : State_Enabled;
2975 case CE_HeaderSection:
2977 partId = HP_HEADERITEM;
2978 if (
flags & State_Sunken)
2979 stateId = HIS_PRESSED;
2980 else if (
flags & State_MouseOver)
2983 stateId = HIS_NORMAL;
2990 partId, stateId,
option->rect);
2991 d->drawBackground(theme);
2995 case CE_MenuBarEmptyArea: {
2996 stateId = MBI_NORMAL;
2997 if (!(
state & State_Enabled))
2998 stateId = MBI_DISABLED;
3000 MENU_BARBACKGROUND, stateId,
option->rect);
3001 d->drawBackground(theme);
3006 if (
const auto *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(
option)) {
3009 QStyleOptionToolBar copyOpt = *toolbar;
3010 copyOpt.palette = pal;
3011 QWindowsStyle::drawControl(element, ©Opt,
painter,
widget);
3015#if QT_CONFIG(dockwidget)
3016 case CE_DockWidgetTitle:
3017 if (
const auto *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(
option)) {
3020 bool isFloating = dw && dw->isFloating();
3021 int buttonMargin = 4;
3023 int fw =
proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt,
widget);
3025 const bool verticalTitleBar = dwOpt->verticalTitleBar;
3027 if (verticalTitleBar) {
3038 if (dwOpt->closable) {
3040 titleRect.
adjust(0, 0, -sz.
width() - mw - buttonMargin, 0);
3043 if (dwOpt->floatable) {
3045 titleRect.
adjust(0, 0, -sz.
width() - mw - buttonMargin, 0);
3049 titleRect.
adjust(0, -fw, 0, 0);
3053 titleRect.
adjust(mw, 0, 0, 0);
3054 if (!dwOpt->floatable && !dwOpt->closable)
3055 titleRect.
adjust(0, 0, -mw, 0);
3058 if (!verticalTitleBar)
3059 titleRect =
visualRect(dwOpt->direction,
r, titleRect);
3062 const bool isActive = dwOpt->state & State_Active;
3065 stateId = CS_ACTIVE;
3067 stateId = CS_INACTIVE;
3069 int titleHeight =
rect.height() - 2;
3070 rect =
rect.adjusted(-fw, -fw, fw, 0);
3078 theme.
partId = WP_SMALLCAPTION;
3079 d->drawBackground(theme);
3086 QPixmap pxIco = ico.pixmap(titleHeight);
3092 if (!dwOpt->title.isEmpty()) {
3095 QFont titleFont = oldFont;
3102 GetThemeEnumValue(theme.
handle(), WP_SMALLCAPTION,
isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &
result);
3104 COLORREF textShadowRef;
3106 QColor textShadow =
qRgb(GetRValue(textShadowRef), GetGValue(textShadowRef), GetBValue(textShadowRef));
3110 dwOpt->state & State_Enabled, titleText);
3113 COLORREF captionText = GetSysColor(
isActive ? COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT);
3114 QColor textColor =
qRgb(GetRValue(captionText), GetGValue(captionText), GetBValue(captionText));
3116 drawItemText(
painter, titleRect,
3118 dwOpt->state & State_Enabled, titleText);
3127 if (!dwOpt->title.isEmpty()) {
3129 verticalTitleBar ? titleRect.
height() : titleRect.
width());
3130 const int indent = 4;
3131 drawItemText(
painter,
rect.adjusted(indent + 1, 1, -indent - 1, -1),
3134 dwOpt->state & State_Enabled, titleText,
3142#if QT_CONFIG(rubberband)
3144 if (qstyleoption_cast<const QStyleOptionRubberBand *>(
option)) {
3150 qMin(highlight.
blue()/2 + 110, 255),
3160 case CE_HeaderEmptyArea:
3161 if (
option->state & State_Horizontal) {
3163 stateId = HIS_NORMAL;
3170#if QT_CONFIG(itemviews)
3171 case CE_ItemViewItem: {
3172 const QStyleOptionViewItem *vopt;
3174 bool newStyle =
true;
3176 if (qobject_cast<const QTableView*>(
widget))
3181 if (newStyle &&
view && (vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
option))) {
3193 QStyleOptionViewItem adjustedOption = *vopt;
3194 adjustedOption.palette =
palette;
3197 && !(vopt->state & State_KeyboardFocusChange))
3198 adjustedOption.state &= ~State_HasFocus;
3200 QWindowsStyle::drawControl(element, &adjustedOption,
painter,
widget);
3213 d->drawBackground(theme);
3218#if QT_CONFIG(combobox)
3219 case CE_ComboBoxLabel:
3239 d->drawBackground(theme);
3266 flags |= State_MouseOver;
3270 if (control == CC_ScrollBar || control == CC_SpinBox || control == CC_ComboBox) {
3281 bool doTransition = ((
state & State_Sunken) != (oldState & State_Sunken)
3282 || (
state & State_On) != (oldState & State_On)
3283 || (
state & State_MouseOver) != (oldState & State_MouseOver)
3284 || oldActiveControls != int(
option->activeSubControls));
3286 if (qstyleoption_cast<const QStyleOptionSlider *>(
option)) {
3290 if (oldSliderPos != currentPos) {
3291 doTransition =
false;
3294 }
else if (control == CC_SpinBox) {
3297 doTransition = (
state & State_HasFocus) != (oldState & State_HasFocus);
3300 if (oldRect !=
option->rect) {
3301 doTransition =
false;
3307 QPainter startPainter(&startImage);
3322 styleOption->
state = QStyle::State(oldState);
3324 proxy()->drawComplexControl(control, styleOption, &startPainter,
widget);
3328 t->setStartImage(startImage);
3333 proxy()->drawComplexControl(control, styleOption, &endPainter,
widget);
3337 t->setEndImage(endImage);
3338 t->setStartTime(
d->animationTime());
3340 if (
option->state & State_MouseOver ||
option->state & State_Sunken)
3341 t->setDuration(150);
3343 t->setDuration(500);
3346 d->startAnimation(
t);
3357#if QT_CONFIG(slider)
3359 if (
const auto *slider = qstyleoption_cast<const QStyleOptionSlider *>(
option)) {
3361 QRect slrect = slider->rect;
3363 if (
sub & SC_SliderGroove) {
3367 stateId = TRS_NORMAL;
3370 partId = TKP_TRACKVERT;
3371 stateId = TRVS_NORMAL;
3376 d->drawBackground(theme);
3377 tickreg -= theme.
rect;
3379 if (
sub & SC_SliderTickmarks) {
3380 int tickOffset =
proxy()->pixelMetric(PM_SliderTickmarkOffset, slider,
widget);
3381 int ticks = slider->tickPosition;
3382 int thickness =
proxy()->pixelMetric(PM_SliderControlThickness, slider,
widget);
3384 int available =
proxy()->pixelMetric(PM_SliderSpaceAvailable, slider,
widget);
3385 int interval = slider->tickInterval;
3386 if (interval <= 0) {
3387 interval = slider->singleStep;
3392 interval = slider->pageStep;
3396 int fudge =
len / 2;
3400 QVarLengthArray<QLine, 32> lines;
3401 int v = slider->minimum;
3402 while (v <= slider->maximum + 1) {
3403 if (
v == slider->maximum + 1 && interval == 1)
3405 const int v_ =
qMin(
v, slider->maximum);
3406 int tickLength = (v_ == slider->minimum || v_ >= slider->maximum) ? 4 : 3;
3408 v_, available) + fudge;
3411 lines.append(
QLine(
pos, tickOffset - 1 - bothOffset,
3412 pos, tickOffset - 1 - bothOffset - tickLength));
3416 lines.append(
QLine(
pos, tickOffset + thickness + bothOffset,
3417 pos, tickOffset + thickness + bothOffset + tickLength));
3421 lines.append(
QLine(tickOffset - 1 - bothOffset,
pos,
3422 tickOffset - 1 - bothOffset - tickLength,
pos));
3426 lines.append(
QLine(tickOffset + thickness + bothOffset,
pos,
3427 tickOffset + thickness + bothOffset + tickLength,
pos));
3431 int nextInterval =
v + interval;
3432 if (nextInterval <
v)
3436 if (!lines.isEmpty()) {
3443 if (
sub & SC_SliderHandle) {
3447 partId = TKP_THUMBTOP;
3449 partId = TKP_THUMBBOTTOM;
3453 if (!(slider->state & State_Enabled))
3454 stateId = TUS_DISABLED;
3455 else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_Sunken))
3456 stateId = TUS_PRESSED;
3457 else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_MouseOver))
3459 else if (
flags & State_HasFocus)
3460 stateId = TUS_FOCUSED;
3462 stateId = TUS_NORMAL;
3465 partId = TKP_THUMBLEFT;
3467 partId = TKP_THUMBRIGHT;
3469 partId = TKP_THUMBVERT;
3471 if (!(slider->state & State_Enabled))
3472 stateId = TUVS_DISABLED;
3473 else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_Sunken))
3474 stateId = TUVS_PRESSED;
3475 else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_MouseOver))
3477 else if (
flags & State_HasFocus)
3478 stateId = TUVS_FOCUSED;
3480 stateId = TUVS_NORMAL;
3484 d->drawBackground(theme);
3486 if (slider->state & State_HasFocus) {
3488 fropt.QStyleOption::operator=(*slider);
3496#if QT_CONFIG(toolbutton)
3498 if (
const auto *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(
option)) {
3501 menuarea =
proxy()->subControlRect(control, toolbutton, SC_ToolButtonMenu,
widget);
3503 State bflags = toolbutton->state & ~State_Sunken;
3504 State mflags = bflags;
3505 bool autoRaise =
flags & State_AutoRaise;
3507 if (!(bflags & State_MouseOver) || !(bflags & State_Enabled))
3508 bflags &= ~State_Raised;
3511 if (toolbutton->state & State_Sunken) {
3512 if (toolbutton->activeSubControls & SC_ToolButton) {
3513 bflags |= State_Sunken;
3514 mflags |= State_MouseOver | State_Sunken;
3515 }
else if (toolbutton->activeSubControls & SC_ToolButtonMenu) {
3516 mflags |= State_Sunken;
3517 bflags |= State_MouseOver;
3522 if (toolbutton->subControls & SC_ToolButton) {
3523 if (
flags & (State_Sunken | State_On | State_Raised) || !autoRaise) {
3526 theme.
partId = TP_SPLITBUTTON;
3528 if (!(bflags & State_Enabled))
3529 stateId = TS_DISABLED;
3530 else if (bflags & State_Sunken)
3531 stateId = TS_PRESSED;
3532 else if (bflags & State_MouseOver || !(
flags & State_AutoRaise))
3533 stateId =
flags & State_On ? TS_HOTCHECKED : TS_HOT;
3534 else if (bflags & State_On)
3535 stateId = TS_CHECKED;
3537 stateId = TS_NORMAL;
3541 d->drawBackground(theme);
3544 tool.
state = bflags;
3553 if (toolbutton->state & State_HasFocus) {
3555 fr.QStyleOption::operator=(*toolbutton);
3566 label.state &= ~State_Sunken;
3570 if (toolbutton->subControls & SC_ToolButtonMenu) {
3571 tool.
rect = menuarea;
3572 tool.
state = mflags;
3576 tool.
state = mflags;
3577 menuarea.adjust(-2, 0, 0, 0);
3579 if ((bflags & State_Sunken) != (mflags & State_Sunken)){
3583 proxy()->drawPrimitive(PE_PanelButtonBevel, &tool,
painter,
nullptr);
3590 menuarea.left(), menuarea.bottom() - 3);
3593 menuarea.left() - 1, menuarea.bottom() - 3);
3600 int mbi =
proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton,
widget);
3601 QRect ir = toolbutton->rect;
3603 newBtn.
rect =
QRect(ir.right() + 4 - mbi, ir.height() - mbi + 4, mbi - 5, mbi - 5);
3611 if (
const auto *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(
option)) {
3612 const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(
widget);
3615 if (
sub & SC_TitleBarLabel) {
3619 stateId = CS_DISABLED;
3621 stateId = CS_ACTIVE;
3623 stateId = CS_INACTIVE;
3627 d->drawBackground(theme);
3629 QRect ir =
proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarLabel,
widget);
3632 GetThemeEnumValue(theme.
handle(), WP_CAPTION,
isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &
result);
3634 COLORREF textShadowRef;
3636 QColor textShadow =
qRgb(GetRValue(textShadowRef), GetGValue(textShadowRef), GetBValue(textShadowRef));
3639 int(ir.width() - 1 * factor), ir.height(),
3642 COLORREF captionText = GetSysColor(
isActive ? COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT);
3643 QColor textColor =
qRgb(GetRValue(captionText), GetGValue(captionText), GetBValue(captionText));
3646 int(ir.width() - 2 * factor), ir.height(),
3651 partId = WP_SYSBUTTON;
3653 stateId = SBS_DISABLED;
3654 else if (
option->activeSubControls == SC_TitleBarSysMenu && (
option->state & State_Sunken))
3655 stateId = SBS_PUSHED;
3656 else if (
option->activeSubControls == SC_TitleBarSysMenu && (
option->state & State_MouseOver))
3659 stateId = SBS_NORMAL;
3660 if (!tb->icon.isNull()) {
3672 d->drawBackground(theme);
3680 d->drawBackground(theme);
3685 d->drawBackground(theme);
3687 if (
sub & SC_TitleBarContextHelpButton
3690 d->drawBackground(theme);
3692 bool drawNormalButton = (
sub & SC_TitleBarNormalButton)
3697 if (drawNormalButton) {
3699 d->drawBackground(theme);
3704 d->drawBackground(theme);
3709 d->drawBackground(theme);
3713 d->drawBackground(theme);
3718#if QT_CONFIG(mdiarea)
3719 case CC_MdiControls: {
3724 if (
option->subControls.testFlag(SC_MdiCloseButton)) {
3725 populateMdiButtonTheme(
proxy(),
widget,
option, SC_MdiCloseButton, WP_MDICLOSEBUTTON, &theme);
3726 d->drawBackground(theme, mdiButtonCorrectionFactor(theme,
widget));
3728 if (
option->subControls.testFlag(SC_MdiNormalButton)) {
3729 populateMdiButtonTheme(
proxy(),
widget,
option, SC_MdiNormalButton, WP_MDIRESTOREBUTTON, &theme);
3730 d->drawBackground(theme, mdiButtonCorrectionFactor(theme,
widget));
3733 populateMdiButtonTheme(
proxy(),
widget,
option, SC_MdiMinButton, WP_MDIMINBUTTON, &theme);
3734 d->drawBackground(theme, mdiButtonCorrectionFactor(theme,
widget));
3742 if (
const auto *dial = qstyleoption_cast<const QStyleOptionSlider *>(
option))
3743 QStyleHelper::drawDial(dial,
painter);
3749 if (cmb->editable) {
3750 if (
sub & SC_ComboBoxEditField) {
3751 partId = EP_EDITBORDER_NOSCROLL;
3752 if (!(
flags & State_Enabled))
3753 stateId = ETS_DISABLED;
3754 else if (
flags & State_MouseOver)
3756 else if (
flags & State_HasFocus)
3757 stateId = ETS_FOCUSED;
3759 stateId = ETS_NORMAL;
3763 partId, stateId,
r);
3765 d->drawBackground(theme);
3767 if (
sub & SC_ComboBoxArrow) {
3770 theme.
rect = subRect;
3773 if (!(cmb->state & State_Enabled))
3774 stateId = CBXS_DISABLED;
3775 else if (cmb->state & State_Sunken || cmb->state & State_On)
3776 stateId = CBXS_PRESSED;
3777 else if (cmb->state & State_MouseOver &&
option->activeSubControls & SC_ComboBoxArrow)
3780 stateId = CBXS_NORMAL;
3784 d->drawBackground(theme);
3788 if (
sub & SC_ComboBoxFrame) {
3791 theme.
partId = CP_READONLY;
3792 if (!(cmb->state & State_Enabled))
3793 theme.
stateId = CBXS_DISABLED;
3794 else if (cmb->state & State_Sunken || cmb->state & State_On)
3796 else if (cmb->state & State_MouseOver)
3800 d->drawBackground(theme);
3802 if (
sub & SC_ComboBoxArrow) {
3806 if (!(cmb->state & State_Enabled))
3807 theme.
stateId = CBXS_DISABLED;
3810 d->drawBackground(theme);
3812 if ((
sub & SC_ComboBoxEditField) && (
flags & State_HasFocus)) {
3814 fropt.QStyleOption::operator=(*cmb);
3823 if (
const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(
option)) {
3825 bool maxedOut = (scrollbar->maximum == scrollbar->minimum);
3827 flags &= ~State_Enabled;
3829 bool isHorz =
flags & State_Horizontal;
3831 if (
sub & SC_ScrollBarAddLine) {
3833 partId = SBP_ARROWBTN;
3834 if (!(
flags & State_Enabled))
3835 stateId = (isHorz ? (isRTL ? ABS_LEFTDISABLED : ABS_RIGHTDISABLED) : ABS_DOWNDISABLED);
3836 else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_Sunken))
3837 stateId = (isHorz ? (isRTL ? ABS_LEFTPRESSED : ABS_RIGHTPRESSED) : ABS_DOWNPRESSED);
3838 else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_MouseOver))
3839 stateId = (isHorz ? (isRTL ? ABS_LEFTHOT : ABS_RIGHTHOT) : ABS_DOWNHOT);
3840 else if (scrollbar->state & State_MouseOver)
3841 stateId = (isHorz ? (isRTL ? ABS_LEFTHOVER : ABS_RIGHTHOVER) : ABS_DOWNHOVER);
3843 stateId = (isHorz ? (isRTL ? ABS_LEFTNORMAL : ABS_RIGHTNORMAL) : ABS_DOWNNORMAL);
3846 d->drawBackground(theme);
3848 if (
sub & SC_ScrollBarSubLine) {
3850 partId = SBP_ARROWBTN;
3851 if (!(
flags & State_Enabled))
3852 stateId = (isHorz ? (isRTL ? ABS_RIGHTDISABLED : ABS_LEFTDISABLED) : ABS_UPDISABLED);
3853 else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_Sunken))
3854 stateId = (isHorz ? (isRTL ? ABS_RIGHTPRESSED : ABS_LEFTPRESSED) : ABS_UPPRESSED);
3855 else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_MouseOver))
3856 stateId = (isHorz ? (isRTL ? ABS_RIGHTHOT : ABS_LEFTHOT) : ABS_UPHOT);
3857 else if (scrollbar->state & State_MouseOver)
3858 stateId = (isHorz ? (isRTL ? ABS_RIGHTHOVER : ABS_LEFTHOVER) : ABS_UPHOVER);
3860 stateId = (isHorz ? (isRTL ? ABS_RIGHTNORMAL : ABS_LEFTNORMAL) : ABS_UPNORMAL);
3863 d->drawBackground(theme);
3869 partId =
flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
3870 stateId = SCRBS_DISABLED;
3873 d->drawBackground(theme);
3875 if (
sub & SC_ScrollBarSubPage) {
3877 partId =
flags & State_Horizontal ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT;
3878 if (!(
flags & State_Enabled))
3879 stateId = SCRBS_DISABLED;
3880 else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_Sunken))
3881 stateId = SCRBS_PRESSED;
3882 else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_MouseOver))
3883 stateId = SCRBS_HOT;
3885 stateId = SCRBS_NORMAL;
3888 d->drawBackground(theme);
3890 if (
sub & SC_ScrollBarAddPage) {
3892 partId =
flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
3893 if (!(
flags & State_Enabled))
3894 stateId = SCRBS_DISABLED;
3895 else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_Sunken))
3896 stateId = SCRBS_PRESSED;
3897 else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_MouseOver))
3898 stateId = SCRBS_HOT;
3900 stateId = SCRBS_NORMAL;
3903 d->drawBackground(theme);
3905 if (
sub & SC_ScrollBarSlider) {
3907 if (!(
flags & State_Enabled))
3908 stateId = SCRBS_DISABLED;
3909 else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_Sunken))
3910 stateId = SCRBS_PRESSED;
3911 else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_MouseOver))
3912 stateId = SCRBS_HOT;
3913 else if (
option->state & State_MouseOver)
3914 stateId = SCRBS_HOVER;
3916 stateId = SCRBS_NORMAL;
3919 theme.
partId =
flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT;
3921 d->drawBackground(theme);
3927#if QT_CONFIG(spinbox)
3929 if (
const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(
option)) {
3931 if (sb->frame && (
sub & SC_SpinBoxFrame)) {
3932 partId = EP_EDITBORDER_NOSCROLL;
3933 if (!(
flags & State_Enabled))
3934 stateId = ETS_DISABLED;
3935 else if (
flags & State_MouseOver)
3937 else if (
flags & State_HasFocus)
3938 stateId = ETS_SELECTED;
3940 stateId = ETS_NORMAL;
3944 partId, stateId,
r);
3949 ftheme.noContent = (
widget !=
nullptr);
3950 d->drawBackground(ftheme);
3952 if (
sub & SC_SpinBoxUp) {
3953 theme.
rect =
proxy()->subControlRect(CC_SpinBox,
option, SC_SpinBoxUp,
widget).adjusted(0, 0, 0, 1);
3956 stateId = UPS_DISABLED;
3957 else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken))
3958 stateId = UPS_PRESSED;
3959 else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_MouseOver))
3962 stateId = UPS_NORMAL;
3965 d->drawBackground(theme);
3967 if (
sub & SC_SpinBoxDown) {
3971 stateId = DNS_DISABLED;
3972 else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken))
3973 stateId = DNS_PRESSED;
3974 else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_MouseOver))
3977 stateId = DNS_NORMAL;
3980 d->drawBackground(theme);
4007 if (buttontheme.isValid()) {
4008 const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(
widget);
4009 const QMarginsF borderSize = buttontheme.margins() * factor;
4010 if (!borderSize.isNull()) {
4012 contentSize.
rwidth() +=
qRound(borderSize.left() + borderSize.right() - margin);
4013 contentSize.
rheight() += int(borderSize.bottom() + borderSize.top() - margin
4014 +
qreal(1) / factor - 1);
4016 const int textMargins = 2*(
proxy()->pixelMetric(PM_FocusFrameHMargin,
option) + 1);
4018 + textMargins, 23), 0);
4024 contentSize +=
QSize(6, 6);
4028 contentSize +=
QSize(1, 0);
4031#if QT_CONFIG(menubar)
4032 case CT_MenuBarItem:
4042 MENU_POPUPCHECKBACKGROUND, MBI_HOT);
4044 themeSize.
partId = MENU_POPUPCHECK;
4057 case CT_MdiControls: {
4060 if (
const auto *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(
option)) {
4062 if (styleOpt->subControls & SC_MdiMinButton)
4064 if (styleOpt->subControls & SC_MdiNormalButton)
4066 if (styleOpt->subControls & SC_MdiCloseButton)
4073 case CT_ItemViewItem:
4086 case CT_HeaderSection:
4092 contentSize = QWindowsStyle::sizeFromContents(
type, hdr,
size,
widget);
4093 hdr->sortIndicator = sortInd;
4111 return QWindowsStyle::subElementRect(element,
option,
widget);
4116 case SE_PushButtonContents:
4121 int stateId = PBS_NORMAL;
4122 if (!(
option->state & State_Enabled))
4123 stateId = PBS_DISABLED;
4124 else if (
option->state & State_Sunken)
4125 stateId = PBS_PRESSED;
4126 else if (
option->state & State_MouseOver)
4129 stateId = PBS_DEFAULTED;
4134 if (SUCCEEDED(GetThemeMargins(theme,
nullptr, BP_PUSHBUTTON, stateId,
TMT_CONTENTMARGINS,
nullptr, &borderSize))) {
4135 rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
4136 -borderSize.cxRightWidth, -borderSize.cyBottomHeight);
4143 case SE_DockWidgetCloseButton:
4144 case SE_DockWidgetFloatButton:
4146 return rect.translated(0, 1);
4148 case SE_TabWidgetTabContents:
4150 if (qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(
option)) {
4152 if (
const QTabWidget *tabWidget = qobject_cast<const QTabWidget *>(
widget)) {
4153 if (tabWidget->documentMode())
4155 rect.adjust(0, 0, -2, -2);
4160 case SE_TabWidgetTabBar: {
4162 const auto *twfOption = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(
option);
4167 QStyleOptionTab otherOption;
4170 int overlap =
proxy()->pixelMetric(PM_TabBarBaseOverlap, &otherOption,
widget);
4171 int borderThickness =
proxy()->pixelMetric(PM_DefaultFrameWidth,
option,
widget);
4172 rect.adjust(-overlap + borderThickness, 0, -overlap + borderThickness, 0);
4177 case SE_HeaderArrow: {
4188 HP_HEADERSORTARROW, HSAS_SORTEDDOWN,
option->
rect);
4190 int arrowWidth = 13;
4191 int arrowHeight = 5;
4194 if (!
size.isEmpty()) {
4199 if (
option->state & State_Horizontal) {
4200 r.setRect(
x +
w/2 - arrowWidth/2,
y , arrowWidth, arrowHeight);
4202 int vert_size =
w / 2;
4203 r.setRect(
x + 5,
y +
h - margin * 2 - vert_size,
4204 w - margin * 2 - 5, vert_size);
4210 case SE_HeaderLabel: {
4215 option->rect.width() - margin * 2,
option->rect.height() - margin * 2);
4219 if (!(
option->state & State_Horizontal))
4220 r.setHeight(
r.height() - (
option->rect.width() / 2) - (margin * 2));
4227 case SE_ProgressBarContents:
4231 case SE_ItemViewItemDecoration:
4233 if (qstyleoption_cast<const QStyleOptionViewItem *>(
option))
4234 rect.adjust(-2, 0, 2, 0);
4237 case SE_ItemViewItemFocusRect:
4239 if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
option)) {
4242 if (!vopt->icon.isNull())
4265 return QWindowsStyle::subControlRect(control,
option, subControl,
widget);
4270#if QT_CONFIG(combobox)
4272 if (
const auto *
cb = qstyleoption_cast<const QStyleOptionComboBox *>(
option)) {
4273 const int x =
cb->rect.x(),
y =
cb->rect.y(), wi =
cb->rect.width(), he =
cb->rect.height();
4274 const int margin =
cb->frame ? 3 : 0;
4275 const int bmarg =
cb->frame ? 2 : 0;
4277 const int arrowButtonWidth = bmarg + arrowWidth;
4278 const int xpos =
x + wi - arrowButtonWidth;
4280 switch (subControl) {
4281 case SC_ComboBoxFrame:
4282 case SC_ComboBoxListBoxPopup:
4286 case SC_ComboBoxArrow: {
4287 rect.setRect(xpos,
y , arrowButtonWidth, he);
4291 case SC_ComboBoxEditField: {
4292 rect.setRect(
x + margin,
y + margin, wi - 2 * margin - arrowWidth, he - 2 * margin);
4307 const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(
widget);
4308 const bool isToolTitle =
false;
4309 const int height = tb->rect.height();
4310 const int width = tb->rect.width();
4313 int buttonHeight =
qRound(
qreal(GetSystemMetrics(SM_CYSIZE)) * factor)
4315 const int buttonWidth =
4318 const int frameWidth =
proxy()->pixelMetric(PM_MdiSubWindowFrameWidth,
option,
widget);
4328 const int delta = buttonWidth + 2;
4329 int controlTop =
option->rect.bottom() - buttonHeight - 2;
4331 switch (subControl) {
4332 case SC_TitleBarLabel: {
4336 rect.adjust(0, 0,
int(-buttonWidth - 3 * factor), 0);
4338 if (minimizeHint || maximizeHint)
4339 rect.adjust(0, 0,
int(-buttonWidth - 2 * factor), 0);
4346 rect.adjust(0, 0,
int(-buttonWidth - 2 * factor), 0);
4348 rect.adjust(0, 0,
int(-buttonWidth - 2 * factor), 0);
4350 rect.adjust(0, 0,
int(-buttonWidth - 2 * factor), 0);
4352 rect.adjust(0, 0,
int(-buttonWidth - 2 * factor), 0);
4354 rect.translate(0,
int(2 * factor));
4358 case SC_TitleBarContextHelpButton:
4362 case SC_TitleBarMinButton:
4365 else if (subControl == SC_TitleBarMinButton)
4368 case SC_TitleBarNormalButton:
4373 else if (subControl == SC_TitleBarNormalButton)
4376 case SC_TitleBarMaxButton:
4379 else if (subControl == SC_TitleBarMaxButton)
4382 case SC_TitleBarShadeButton:
4385 else if (subControl == SC_TitleBarShadeButton)
4388 case SC_TitleBarUnshadeButton:
4391 else if (subControl == SC_TitleBarUnshadeButton)
4394 case SC_TitleBarCloseButton:
4397 else if (subControl == SC_TitleBarCloseButton)
4401 buttonWidth, buttonHeight);
4404 case SC_TitleBarSysMenu: {
4405 const int controlTop = int(6 * factor);
4406 const int controlHeight = int(
height - controlTop - 3 * factor);
4407 int iconExtent =
proxy()->pixelMetric(PM_SmallIconSize,
option);
4409 if (tb->icon.isNull())
4411 int hPad = (controlHeight -
iconSize.height())/2;
4412 int vPad = (controlHeight -
iconSize.width())/2;
4414 rect.translate(0,
int(3 * factor));
4424#if QT_CONFIG(mdiarea)
4425 case CC_MdiControls: {
4426 int numSubControls = 0;
4427 if (
option->subControls & SC_MdiCloseButton)
4429 if (
option->subControls & SC_MdiMinButton)
4431 if (
option->subControls & SC_MdiNormalButton)
4433 if (numSubControls == 0)
4436 int buttonWidth =
option->rect.width() / numSubControls;
4439 switch (subControl) {
4440 case SC_MdiCloseButton:
4442 if (numSubControls == 1)
4446 case SC_MdiNormalButton:
4450 if (numSubControls == 1 || (numSubControls == 2 && !(
option->subControls & SC_MdiMinButton)))
4452 if (
option->subControls & SC_MdiNormalButton)
4465 return QWindowsStyle::subControlRect(control,
option, subControl,
widget);
4477 return QWindowsStyle::hitTestComplexControl(control,
option,
pos,
widget);
4486 return QWindowsStyle::pixelMetric(metric,
option,
widget);
4489 if (
ret != QWindowsStylePrivate::InvalidMetric)
4493 if (
res != QWindowsStylePrivate::InvalidMetric)
4499 case PM_MenuBarPanelWidth:
4500 case PM_ButtonDefaultIndicator:
4504 case PM_DefaultFrameWidth:
4505 res = qobject_cast<const QListView*>(
widget) ? 2 : 1;
4507 case PM_MenuPanelWidth:
4508 case PM_SpinBoxFrameWidth:
4512 case PM_TabBarTabOverlap:
4513 case PM_MenuHMargin:
4514 case PM_MenuVMargin:
4518 case PM_TabBarBaseOverlap:
4519 if (
const auto *tab = qstyleoption_cast<const QStyleOptionTab *>(
option)) {
4520 switch (tab->shape) {
4539 case PM_SplitterWidth:
4543 case PM_MdiSubWindowMinimizedWidth:
4547#if QT_CONFIG(toolbar)
4548 case PM_ToolBarHandleExtent:
4553 case PM_DockWidgetSeparatorExtent:
4554 case PM_DockWidgetTitleMargin:
4558 case PM_ButtonShiftHorizontal:
4559 case PM_ButtonShiftVertical:
4560 res = qstyleoption_cast<const QStyleOptionToolButton *>(
option) ? 1 : 0;
4575 QWindowsStyle::polish(
widget);
4581 || qobject_cast<QAbstractButton*>(
widget)
4583 || qobject_cast<QToolButton*>(
widget)
4584 || qobject_cast<QTabBar*>(
widget)
4586 || qobject_cast<QComboBox*>(
widget)
4588 || qobject_cast<QScrollBar*>(
widget)
4589 || qobject_cast<QSlider*>(
widget)
4590 || qobject_cast<QHeaderView*>(
widget)
4592 || qobject_cast<QAbstractSpinBox*>(
widget)
4593 || qobject_cast<QSpinBox*>(
widget)
4599#if QT_CONFIG(rubberband)
4600 if (qobject_cast<QRubberBand*>(
widget))
4604#if QT_CONFIG(lineedit)
4605 if (qobject_cast<QLineEdit*>(
widget))
4609 if (qobject_cast<QGroupBox*>(
widget))
4611#if QT_CONFIG(commandlinkbutton)
4612 else if (qobject_cast<QCommandLinkButton*>(
widget)) {
4629 if (theme && SUCCEEDED(GetThemeColor(theme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &bgRef))) {
4636 }
else if (qobject_cast<QMessageBox *> (
widget)) {
4638#if QT_CONFIG(dialogbuttonbox)
4644#if QT_CONFIG(inputdialog)
4645 else if (qobject_cast<QInputDialog *> (
widget)) {
4647#if QT_CONFIG(dialogbuttonbox)
4669#if QT_CONFIG(rubberband)
4670 if (qobject_cast<QRubberBand*>(
widget))
4686 d->cleanupHandleMap();
4690 || qobject_cast<QAbstractButton*>(
widget)
4692 || qobject_cast<QToolButton*>(
widget)
4693 || qobject_cast<QTabBar*>(
widget)
4695 || qobject_cast<QComboBox*>(
widget)
4697 || qobject_cast<QScrollBar*>(
widget)
4698 || qobject_cast<QSlider*>(
widget)
4699 || qobject_cast<QHeaderView*>(
widget)
4701 || qobject_cast<QAbstractSpinBox*>(
widget)
4702 || qobject_cast<QSpinBox*>(
widget)
4708 QWindowsStyle::unpolish(
widget);
4712#if QT_CONFIG(lineedit)
4713 if (qobject_cast<QLineEdit*>(
widget))
4717 if (qobject_cast<QGroupBox*>(
widget))
4719 else if (qobject_cast<QMessageBox *> (
widget)) {
4721#if QT_CONFIG(dialogbuttonbox)
4727#if QT_CONFIG(inputdialog)
4728 else if (qobject_cast<QInputDialog *> (
widget)) {
4730#if QT_CONFIG(dialogbuttonbox)
4740#if QT_CONFIG(commandlinkbutton)
4741 else if (qobject_cast<QCommandLinkButton*>(
widget)) {
4763 nativeWindowsApp->populateLightSystemPalette(pal);
4767 d->alphaCache.clear();
4768 d->hasInitColors =
false;
4770 if (!
d->hasInitColors) {
4774 GetThemeColor(theme.
handle(), BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &cref);
4775 d->groupBoxTextColor =
qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
4776 GetThemeColor(theme.
handle(), BP_GROUPBOX, GBS_DISABLED, TMT_TEXTCOLOR, &cref);
4777 d->groupBoxTextColorDisabled =
qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
4780 d->sliderTickColor =
qRgb(165, 162, 148);
4781 d->hasInitColors =
true;
4784 QWindowsStyle::polish(pal);
4795 static const char* themedWidgets[] = {
4801 "QAbstractItemView",
4812 for (
const auto& themedWidget : std::as_const(themedWidgets)) {
4815 if (widgetResolveMask != defaultResolveMask)
4820 QWindowsStyle::polish(
app);
4834 case SP_TitleBarMaxButton:
4835 case SP_TitleBarCloseButton:
4836 if (qstyleoption_cast<const QStyleOptionDockWidget *>(
option)) {
4840 const QSize size = (theme.
size() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget)).toSize();
4868 case SP_TitleBarMaxButton:
4869 if (qstyleoption_cast<const QStyleOptionDockWidget *>(
option)) {
4870 if (
d->dockFloat.isNull()) {
4872 WP_SMALLCLOSEBUTTON, CBS_NORMAL);
4874 WP_MAXBUTTON, MAXBS_NORMAL);
4876 const QSize size = (themeSize.
size() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget)).toSize();
4882 d->drawBackground(theme);
4886 d->drawBackground(theme);
4890 d->drawBackground(theme);
4894 d->drawBackground(theme);
4899 return d->dockFloat;
4903 case SP_TitleBarCloseButton:
4904 if (qstyleoption_cast<const QStyleOptionDockWidget *>(
option)) {
4905 if (
d->dockClose.isNull()) {
4907 WP_SMALLCLOSEBUTTON, CBS_NORMAL);
4909 const QSize size = (theme.
size() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget)).toSize();
4914 theme.
partId = WP_CLOSEBUTTON;
4916 d->drawBackground(theme);
4920 d->drawBackground(theme);
4924 d->drawBackground(theme);
4928 d->drawBackground(theme);
4933 return d->dockClose;
4937 case SP_TitleBarNormalButton:
4938 if (qstyleoption_cast<const QStyleOptionDockWidget *>(
option)) {
4939 if (
d->dockFloat.isNull()) {
4941 WP_SMALLCLOSEBUTTON, CBS_NORMAL);
4943 WP_RESTOREBUTTON, RBS_NORMAL);
4945 const QSize size = (themeSize.
size() * QWindowsStylePrivate::nativeMetricScaleFactor(
widget)).toSize();
4951 d->drawBackground(theme);
4955 d->drawBackground(theme);
4959 d->drawBackground(theme);
4963 d->drawBackground(theme);
4968 return d->dockFloat;
4972 case SP_CommandLink: {
4983 d->drawBackground(theme);
4988 d->drawBackground(theme);
4993 d->drawBackground(theme);
4998 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 QPlatformNativeInterface * platformNativeInterface()
static QWindowList allWindows()
Returns a list of all the windows in the application.
static QStyleHints * styleHints()
Returns the application's style hints.
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.
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 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
\inmodule QtCore\compares equality \compareswith equality QLineF \endcompareswith
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 qreal bottom() const noexcept
Returns the bottom margin.
Native interface to QGuiApplication, to be retrieved from QPlatformIntegration. \inmodule QtGui.
T findChild(QAnyStringView aName, 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...
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 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.
void setResolveMask(ResolveMask mask)
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...
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
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
\inmodule QtCore\reentrant
\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 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.
\inmodule QtCore\reentrant
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 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 void setCoords(int x1, int y1, int x2, int y2) noexcept
Sets the coordinates of the rectangle's top-left corner to (x1, y1), and the coordinates of its botto...
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 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.
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...
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
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
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.
int msecsTo(QTime t) const
Returns the number of milliseconds from this time to t.
The QTreeView class provides a default model/view implementation of a tree view.
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 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)
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,...)
QVector3D Q_QUICK3DUTILS_EXPORT rotate(const QMatrix4x4 &m, const QVector3D &v)
Q_WIDGETS_EXPORT qreal dpiScaled(qreal value, qreal dpi)
Combined button and popup list for selecting options.
Q_GUI_EXPORT void clearAllThemeCaches()
Q_GUI_EXPORT HTHEME createTheme(int theme, HWND hwnd)
Q_GUI_EXPORT QString themeName(int theme)
@ WA_TranslucentBackground
@ WindowContextHelpButtonHint
@ WindowMaximizeButtonHint
@ WindowMinimizeButtonHint
#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]
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 GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLenum GLsizei GLsizei GLsizei GLint border
GLuint GLsizei const GLchar * label
[43]
GLenum GLuint GLenum GLsizei const GLchar * buf
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 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