📄 qwindowsxpstyle.cpp
字号:
stateId = TS_NORMAL; break; case PE_IndicatorArrowDown: name = QLatin1String("TOOLBAR"); partId = TP_SPLITBUTTONDROPDOWN; if (!(flags & State_Enabled)) stateId = TS_DISABLED; else stateId = TS_NORMAL; break; case PE_IndicatorCheckBox: name = QLatin1String("BUTTON"); partId = BP_CHECKBOX; if (!(flags & State_Enabled)) stateId = CBS_UNCHECKEDDISABLED; else if (flags & State_Sunken) stateId = CBS_UNCHECKEDPRESSED; else if (flags & State_MouseOver) stateId = CBS_UNCHECKEDHOT; else stateId = CBS_UNCHECKEDNORMAL; if (flags & State_On) stateId += CBS_CHECKEDNORMAL-1; else if (flags & State_NoChange) stateId += CBS_MIXEDNORMAL-1; break; case PE_IndicatorRadioButton: name = QLatin1String("BUTTON"); partId = BP_RADIOBUTTON; if (!(flags & State_Enabled)) stateId = RBS_UNCHECKEDDISABLED; else if (flags & State_Sunken) stateId = RBS_UNCHECKEDPRESSED; else if (flags & State_MouseOver) stateId = RBS_UNCHECKEDHOT; else stateId = RBS_UNCHECKEDNORMAL; if (flags & State_On) stateId += RBS_CHECKEDNORMAL-1; break; case PE_IndicatorDockWidgetResizeHandle: return;case PE_Frame: { if (flags & State_Raised) return; name = QLatin1String("LISTVIEW"); partId = LVP_LISTGROUP; XPThemeData theme(0, 0, name, partId, 0); if (!(flags & State_Enabled)) stateId = ETS_DISABLED; else stateId = ETS_NORMAL; int fillType; if (pGetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &fillType) == S_OK) { if (fillType == BT_BORDERFILL) { int borderSize = 1; COLORREF bcRef; pGetThemeColor(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &bcRef); QColor bordercolor(qRgb(GetRValue(bcRef), GetGValue(bcRef), GetBValue(bcRef))); pGetThemeInt(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &borderSize); QPen oldPen = p->pen(); p->setPen(QPen(bordercolor, 1)); p->drawRect(option->rect.adjusted(0, 0, -1, -1)); p->setPen(oldPen); return; } else if (fillType == BT_NONE) { return; } else { break; } } } case PE_FrameLineEdit: if (qstyleoption_cast<const QStyleOptionFrame *>(option)) { name = QLatin1String("EDIT"); partId = EP_EDITTEXT; noContent = true; if (!(flags & State_Enabled)) stateId = ETS_DISABLED; else stateId = ETS_NORMAL; } break; case PE_PanelLineEdit: if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) { name = QLatin1String("EDIT"); partId = EP_EDITTEXT; noBorder = true; QBrush bg; bool usePalette = false; bool isEnabled = flags & State_Enabled; uint resolve_mask = panel->palette.resolve(); if (resolve_mask & (1 << QPalette::Base)) { // Base color is set for this widget, so use it bg = panel->palette.brush(QPalette::Base); usePalette = true; } stateId = isEnabled ? ETS_NORMAL : ETS_DISABLED; if (usePalette) { p->fillRect(panel->rect, bg); } else { XPThemeData theme(0, p, name, partId, stateId, rect); if (!theme.isValid()) { QWindowsStyle::drawPrimitive(pe, option, p, widget); return; } int bgType; pGetThemeEnumValue( theme.handle(), partId, stateId, TMT_BGTYPE, &bgType); if( bgType == BT_IMAGEFILE ) { theme.mirrorHorizontally = hMirrored; theme.mirrorVertically = vMirrored; theme.noBorder = noBorder; theme.noContent = noContent; theme.rotate = rotate; d->drawBackground(theme); } else { QBrush fillColor = option->palette.brush(QPalette::Base); if (!isEnabled) { PROPERTYORIGIN origin = PO_NOTFOUND; pGetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin); // Use only if the fill property comes from our part if ((origin == PO_PART || origin == PO_STATE)) { COLORREF bgRef; pGetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef); fillColor = QBrush(qRgb(GetRValue(bgRef), GetGValue(bgRef), GetBValue(bgRef))); } } p->fillRect(option->rect, fillColor); } } if (panel->lineWidth > 0) drawPrimitive(PE_FrameLineEdit, panel, p, widget); return; } break; case PE_FrameTabWidget: if (const QStyleOptionTabWidgetFrame *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) { name = QLatin1String("TAB"); partId = TABP_PANE; if (widget) { bool useGradient = true; const int maxlength = 256; WCHAR themeFileName[maxlength]; WCHAR themeColor[maxlength]; // Due to a a scaling issue with the XP Silver theme, tab gradients are not used with it if (pGetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength, NULL, 0) == S_OK) { WCHAR* offset; if ((offset = wcsrchr(themeFileName, QChar(QLatin1Char('\\')).unicode())) != NULL) { offset++; if (!lstrcmp(offset, L"Luna.msstyles") && !lstrcmp(offset, L"Metallic")) { useGradient = false; } } } // This should work, but currently there's an error in the ::drawBackgroundDirectly() // code, when using the HDC directly.. if (useGradient) { QStyleOptionTabWidgetFrame frameOpt = *tab; frameOpt.rect = widget->rect(); QRect contentsRect = subElementRect(SE_TabWidgetTabContents, &frameOpt, widget); QRegion reg = option->rect; reg -= contentsRect; p->setClipRegion(reg); XPThemeData theme(widget, p, name, partId, stateId, rect); theme.mirrorHorizontally = hMirrored; theme.mirrorVertically = vMirrored; d->drawBackground(theme); p->setClipRect(contentsRect); partId = TABP_BODY; } } switch (tab->shape) { case QTabBar::RoundedNorth: case QTabBar::TriangularNorth: break; case QTabBar::RoundedSouth: case QTabBar::TriangularSouth: vMirrored = true; break; case QTabBar::RoundedEast: case QTabBar::TriangularEast: rotate = 90; break; case QTabBar::RoundedWest: case QTabBar::TriangularWest: rotate = 90; hMirrored = true; break; default: break; } } break; case PE_FrameMenu: p->save(); p->setPen(option->palette.dark().color()); p->drawRect(rect.adjusted(0, 0, -1, -1)); p->restore(); return; case PE_PanelMenuBar: break; case PE_FrameDockWidget: if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(option)) { name = QLatin1String("WINDOW"); if (flags & State_Active) stateId = FS_ACTIVE; else stateId = FS_INACTIVE; int fwidth = pixelMetric(PM_DockWidgetFrameWidth, frm, widget); XPThemeData theme(widget, p, name, 0, stateId); if (!theme.isValid()) break; theme.rect = QRect(frm->rect.x(), frm->rect.y(), frm->rect.x()+fwidth, frm->rect.height()-fwidth); theme.partId = WP_SMALLFRAMELEFT; d->drawBackground(theme); theme.rect = QRect(frm->rect.width()-fwidth, frm->rect.y(), fwidth, frm->rect.height()-fwidth); theme.partId = WP_SMALLFRAMERIGHT; d->drawBackground(theme); theme.rect = QRect(frm->rect.x(), frm->rect.bottom()-fwidth+1, frm->rect.width(), fwidth); theme.partId = WP_SMALLFRAMEBOTTOM; d->drawBackground(theme); return; } break; case PE_IndicatorHeaderArrow: {#if 0 // XP theme engine doesn't know about this :( name = QLatin1String("HEADER"); partId = HP_HEADERSORTARROW; if (flags & State_Down) stateId = HSAS_SORTEDDOWN; else stateId = HSAS_SORTEDUP;#else if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { p->save(); p->setPen(option->palette.dark().color()); p->translate(0, option->rect.height()/2 - 4); if (header->sortIndicator & QStyleOptionHeader::SortUp) { // invert logic to follow Windows style guide p->drawLine(option->rect.x(), option->rect.y(), option->rect.x()+8, option->rect.y()); p->drawLine(option->rect.x()+1, option->rect.y()+1, option->rect.x()+7, option->rect.y()+1); p->drawLine(option->rect.x()+2, option->rect.y()+2, option->rect.x()+6, option->rect.y()+2); p->drawLine(option->rect.x()+3, option->rect.y()+3, option->rect.x()+5, option->rect.y()+3); p->drawPoint(option->rect.x()+4, option->rect.y()+4); } else if(header->sortIndicator & QStyleOptionHeader::SortDown) { p->drawLine(option->rect.x(), option->rect.y()+4, option->rect.x()+8, option->rect.y()+4); p->drawLine(option->rect.x()+1, option->rect.y()+3, option->rect.x()+7, option->rect.y()+3); p->drawLine(option->rect.x()+2, option->rect.y()+2, option->rect.x()+6, option->rect.y()+2); p->drawLine(option->rect.x()+3, option->rect.y()+1, option->rect.x()+5, option->rect.y()+1); p->drawPoint(option->rect.x()+4, option->rect.y()); } p->restore(); return; }#endif } break; case PE_FrameStatusBar: name = QLatin1String("STATUS"); partId = SP_PANE; break; case PE_FrameGroupBox: name = QLatin1String("BUTTON"); partId = BP_GROUPBOX; if (!(flags & State_Enabled)) stateId = GBS_DISABLED; else stateId = GBS_NORMAL; if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) { const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(option); if (frame2->features & QStyleOptionFrameV2::Flat) { // Windows XP does not have a theme part for a flat GroupBox, paint it with the windows style QRect fr = frame->rect; QPoint p1(fr.x(), fr.y() + 1); QPoint p2(fr.x() + fr.width(), p1.y() + 1); rect = QRect(p1, p2); name = QLatin1String(""); } } break; case PE_IndicatorProgressChunk: { Qt::Orientation orient = Qt::Horizontal; bool inverted = false; if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { orient = pb2->orientation; if (pb2->invertedAppearance) inverted = true; } if (orient == Qt::Horizontal) { partId = PP_CHUNK; rect = QRect(option->rect.x(), option->rect.y(), option->rect.width(), option->rect.height() ); if (inverted && option->direction == Qt::LeftToRight) hMirrored = true; } else { partId = PP_CHUNKVERT; rect = QRect(option->rect.x(), option->rect.y(), option->rect.width(), option->rect.height()); } name = QLatin1String(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -