⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qwindowsvistastyle.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                int stateId = EBS_NORMAL;                if (!isEnabled)                    stateId = EBS_DISABLED;                else if (state & State_ReadOnly)                    stateId = EBS_READONLY;                else if (state & State_MouseOver)                    stateId = EBS_HOT;                XPThemeData theme(0, painter, QLatin1String("EDIT"), partId, stateId, rect);                if (!theme.isValid()) {                    QWindowsStyle::drawPrimitive(element, option, painter, widget);                    return;                }                int bgType;                pGetThemeEnumValue( theme.handle(),                                    partId,                                    stateId,                                    TMT_BGTYPE,                                    &bgType);                if( bgType == BT_IMAGEFILE ) {                    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)));                        }                    }                    painter->fillRect(option->rect, fillColor);                }            }            if (panel->lineWidth > 0)                drawPrimitive(PE_FrameLineEdit, panel, painter, widget);            return;        }        break;    case PE_FrameLineEdit:        if (Animation *anim = d->widgetAnimation(widget)) {            anim->paint(painter, option);        } else {            int stateId = ETS_NORMAL;            if (!(state & State_Enabled))                stateId = ETS_DISABLED;            else if (state & State_ReadOnly)                stateId = ETS_READONLY;            else if (state & State_MouseOver)                stateId = ETS_HOT;            else if (state & State_HasFocus)                stateId = ETS_SELECTED;            XPThemeData theme(widget, painter, QLatin1String("EDIT"), EP_EDITBORDER_NOSCROLL, stateId, option->rect);            painter->save();            QRegion clipRegion = option->rect;            clipRegion -= option->rect.adjusted(2, 2, -2, -2);            painter->setClipRegion(clipRegion);            d->drawBackground(theme);            painter->restore();        }        break;    case PE_IndicatorToolBarSeparator:        {            QPen pen = painter->pen();            int x1 = option->rect.center().x();            int margin = 3;            painter->setPen(option->palette.background().color().darker(114));            painter->drawLine(QPoint(x1, option->rect.top() + margin), QPoint(x1, option->rect.bottom() - margin));            painter->setPen(pen);        }        break;    case PE_PanelTipLabel: {        XPThemeData theme(widget, painter, QLatin1String("TOOLTIP"), TTP_STANDARD, TTSS_NORMAL, option->rect);        d->drawBackground(theme);        break;    }    case PE_Widget:         {            const QDialogButtonBox *buttonBox = 0;            if (qobject_cast<const QMessageBox *> (widget))                buttonBox = qFindChild<const QDialogButtonBox *>(widget,QLatin1String("qt_msgbox_buttonbox"));            else if (qobject_cast<const QInputDialog *> (widget))                buttonBox = qFindChild<const QDialogButtonBox *>(widget,QLatin1String("qt_inputdlg_buttonbox"));            if (buttonBox) {                //draw white panel part                XPThemeData theme(widget, painter, QLatin1String("TASKDIALOG"), TDLG_PRIMARYPANEL, 0, option->rect);                QRect toprect = option->rect;                toprect.setBottom(buttonBox->geometry().top());                theme.rect = toprect;                d->drawBackground(theme);                //draw bottom panel part                QRect buttonRect = option->rect;                buttonRect.setTop(buttonBox->geometry().top());                theme.rect = buttonRect;                theme.partId = TDLG_SECONDARYPANEL;                d->drawBackground(theme);            }        }    default:        QWindowsXPStyle::drawPrimitive(element, option, painter, widget);        break;    }}/*! \reimp see drawPrimitive for comments on the animation support */void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption *option,                                  QPainter *painter, const QWidget *widget) const{    QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());    if (!QWindowsVistaStylePrivate::useVista()) {        QWindowsStyle::drawControl(element, option, painter, widget);        return;    }    bool selected = option->state & State_Selected;    bool pressed = option->state & State_Sunken;    bool disabled = !(option->state & State_Enabled);    int state = option->state;    QString name;    QRect rect(option->rect);    State flags = option->state;    int partId = 0;    int stateId = 0;    QRect oldRect;    QRect newRect;    if (d->transitionsEnabled() && widget) {        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {            if ((qobject_cast<const QPushButton*>(widget) && element == CE_PushButtonBevel))            {                QWidget *w = const_cast<QWidget *> (widget);                int oldState = w->property("_q_stylestate").toInt();                oldRect = w->property("_q_stylerect").toRect();                newRect = w->rect();                w->setProperty("_q_stylestate", (int)option->state);                w->setProperty("_q_stylerect", w->rect());                bool wasDefault = w->property("_q_isdefault").toBool();                bool isDefault = button->features & QStyleOptionButton::DefaultButton;                w->setProperty("_q_isdefault", isDefault);                bool doTransition = ((state & State_Sunken)     != (oldState & State_Sunken) ||                                     (state & State_On)         != (oldState & State_On)     ||                                     (state & State_MouseOver)  != (oldState & State_MouseOver));                if (oldRect != newRect || (wasDefault && !isDefault))                {                    doTransition = false;                    d->stopAnimation(widget);                }                if (doTransition) {                    QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);                    QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);                    Animation *anim = d->widgetAnimation(widget);                    QStyleOptionButton opt = *button;                    opt.state = (QStyle::State)oldState;                    startImage.fill(0);                    Transition *t = new Transition;                    t->setWidget(w);                    QPainter startPainter(&startImage);                    if (!anim) {                        drawControl(element, &opt, &startPainter, 0 /* Intentional */);                    } else {                        anim->paint(&startPainter, &opt);                        d->stopAnimation(widget);                    }                    t->setStartImage(startImage);                    d->startAnimation(t);                    endImage.fill(0);                    QPainter endPainter(&endImage);                    drawControl(element, option, &endPainter, 0 /* Intentional */);                    t->setEndImage(endImage);                    int duration = 0;                    HTHEME theme = pOpenThemeData(0, L"Button");                    int fromState = buttonStateId(oldState, BP_PUSHBUTTON);                    int toState = buttonStateId(option->state, BP_PUSHBUTTON);                    if (pGetThemeTransitionDuration(theme, BP_PUSHBUTTON, fromState, toState, TMT_TRANSITIONDURATIONS, &duration) == S_OK)                        t->setDuration(duration);                    else                        t->setDuration(0);                    t->setStartTime(QTime::currentTime());                }            }        }    }    switch (element) {    case CE_PushButtonBevel:        if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option))        {            if (Animation *anim = d->widgetAnimation(widget)) {                anim->paint(painter, option);            } else {                name = QLatin1String("BUTTON");                partId = BP_PUSHBUTTON;                if (btn->features & QStyleOptionButton::CommandLinkButton)                    partId = BP_COMMANDLINK;                bool justFlat = (btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken));                if (!(flags & State_Enabled) && !(btn->features & QStyleOptionButton::Flat))                    stateId = PBS_DISABLED;                else if (justFlat)                    ;                else if (flags & (State_Sunken | State_On))                    stateId = PBS_PRESSED;                else if (flags & State_MouseOver)                    stateId = PBS_HOT;                else if (btn->features & QStyleOptionButton::DefaultButton && (state & State_Active))                    stateId = PBS_DEFAULTED;                else                    stateId = PBS_NORMAL;                if (!justFlat) {                    if (widget && (btn->features & QStyleOptionButton::DefaultButton)      &&                        !(state & (State_Sunken | State_On)) && !(state & State_MouseOver) &&                         (state & State_Enabled) && (state & State_Active))                        {                        Animation *anim = d->widgetAnimation(widget);                        if (!anim && widget) {                            QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);                            startImage.fill(0);                            QImage alternateImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);                            alternateImage.fill(0);                            Pulse *pulse = new Pulse;                            pulse->setWidget(const_cast<QWidget*>(widget));                            QPainter startPainter(&startImage);                            stateId = PBS_DEFAULTED;                            XPThemeData theme(widget, &startPainter, name, partId, stateId, rect);                            d->drawBackground(theme);                            QPainter alternatePainter(&alternateImage);                            theme.stateId = PBS_DEFAULTED_ANIMATING;                            theme.painter = &alternatePainter;                            d->drawBackground(theme);                            pulse->setPrimaryImage(startImage);                            pulse->setAlternateImage(alternateImage);                            pulse->setStartTime(QTime::currentTime());                            pulse->setDuration(2000);                            d->startAnimation(pulse);                            anim = pulse;                        }                        if (anim)                            anim->paint(painter, option);                        else {                            XPThemeData theme(widget, painter, name, partId, stateId, rect);                            d->drawBackground(theme);                        }                    }                    else {                        d->stopAnimation(widget);                        XPThemeData theme(widget, painter, name, partId, stateId, rect);                        d->drawBackground(theme);                    }                }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -