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

📄 qcommonstyle.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            //        p->drawPolygon(a);            if (opt->state & State_On) {                p->setPen(Qt::NoPen);                p->setBrush(opt->palette.text());                p->drawRect(x + 5, y + 4, 2, 4);                p->drawRect(x + 4, y + 5, 4, 2);            }#undef INTARRLEN        }        break;    case PE_Q3CheckListIndicator:        if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {            if(lv->items.isEmpty())                break;            QStyleOptionQ3ListViewItem item = lv->items.at(0);            int x = lv->rect.x(),                y = lv->rect.y(),                w = lv->rect.width(),                h = lv->rect.width(),             marg = lv->itemMargin;            if (lv->state & State_Enabled)                p->setPen(QPen(lv->palette.text().color(), 2));            else                p->setPen(QPen(lv->viewportPalette.color(QPalette::Disabled, QPalette::Text), 2));            if (opt->state & State_Selected && !lv->rootIsDecorated                && !(item.features & QStyleOptionQ3ListViewItem::ParentControl)) {                p->fillRect(0, 0, x + marg + w + 4, item.height,                            lv->palette.brush(QPalette::Highlight));                if (item.state & State_Enabled)                    p->setPen(QPen(lv->palette.highlightedText().color(), 2));            }            if (lv->state & State_NoChange)                p->setBrush(lv->palette.brush(QPalette::Button));            p->drawRect(x + marg, y + 2, w - 4, h - 4);            /////////////////////                ++x;                ++y;                if (lv->state & State_On || lv->state & State_NoChange) {                    QLineF lines[7];                    int i,                        xx = x + 1 + marg,                        yy = y + 5;                    for (i = 0; i < 3; ++i) {                        lines[i] = QLineF(xx, yy, xx, yy + 2);                        ++xx;                        ++yy;                    }                    yy -= 2;                    for (i = 3; i < 7; ++i) {                        lines[i] = QLineF(xx, yy, xx, yy + 2);                        ++xx;                        --yy;                    }                    p->drawLines(lines, 7);                }        }        break;#endif // QT3_SUPPORT    case PE_IndicatorBranch: {        int mid_h = opt->rect.x() + opt->rect.width() / 2;        int mid_v = opt->rect.y() + opt->rect.height() / 2;        int bef_h = mid_h;        int bef_v = mid_v;        int aft_h = mid_h;        int aft_v = mid_v;#ifndef QT_NO_IMAGEFORMAT_XPM        static const int decoration_size = 9;        static QPixmap open(tree_branch_open_xpm);        static QPixmap closed(tree_branch_closed_xpm);        if (opt->state & State_Children) {            int delta = decoration_size / 2;            bef_h -= delta;            bef_v -= delta;            aft_h += delta;            aft_v += delta;            p->drawPixmap(bef_h, bef_v, opt->state & State_Open ? open : closed);        }#endif // QT_NO_IMAGEFORMAT_XPM        if (opt->state & State_Item) {            if (opt->direction == Qt::RightToLeft)                p->drawLine(opt->rect.left(), mid_v, bef_h, mid_v);            else                p->drawLine(aft_h, mid_v, opt->rect.right(), mid_v);        }        if (opt->state & State_Sibling)            p->drawLine(mid_h, aft_v, mid_h, opt->rect.bottom());        if (opt->state & (State_Open | State_Children | State_Item | State_Sibling))            p->drawLine(mid_h, opt->rect.y(), mid_h, bef_v);        break; }#ifdef QT3_SUPPORT    case PE_Q3Separator:        qDrawShadeLine(p, opt->rect.left(), opt->rect.top(), opt->rect.right(), opt->rect.bottom(),                       opt->palette, opt->state & State_Sunken, 1, 0);        break;#endif // QT3_SUPPORT    case PE_FrameStatusBar:        qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, 0);        break;    case PE_IndicatorHeaderArrow:        if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {            QPen oldPen = p->pen();            if (header->sortIndicator & QStyleOptionHeader::SortUp) {                QPolygon pa(3);                p->setPen(QPen(opt->palette.light(), 0));                p->drawLine(opt->rect.x() + opt->rect.width(), opt->rect.y(),                            opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height());                p->setPen(QPen(opt->palette.dark(), 0));                pa.setPoint(0, opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height());                pa.setPoint(1, opt->rect.x(), opt->rect.y());                pa.setPoint(2, opt->rect.x() + opt->rect.width(), opt->rect.y());                p->drawPolyline(pa);            } else if (header->sortIndicator & QStyleOptionHeader::SortDown) {                QPolygon pa(3);                p->setPen(QPen(opt->palette.light(), 0));                pa.setPoint(0, opt->rect.x(), opt->rect.y() + opt->rect.height());                pa.setPoint(1, opt->rect.x() + opt->rect.width(), opt->rect.y() + opt->rect.height());                pa.setPoint(2, opt->rect.x() + opt->rect.width() / 2, opt->rect.y());                p->drawPolyline(pa);                p->setPen(QPen(opt->palette.dark(), 0));                p->drawLine(opt->rect.x(), opt->rect.y() + opt->rect.height(),                            opt->rect.x() + opt->rect.width() / 2, opt->rect.y());            }            p->setPen(oldPen);        }        break;#ifndef QT_NO_TABBAR    case PE_FrameTabBarBase:        if (const QStyleOptionTabBarBase *tbb                = qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) {            QRegion region(tbb->rect);            region -= tbb->selectedTabRect;            p->save();            p->setClipRegion(region);            switch (tbb->shape) {            case QTabBar::RoundedNorth:            case QTabBar::TriangularNorth:                p->setPen(QPen(tbb->palette.light(), 0));                p->drawLine(tbb->rect.topLeft(), tbb->rect.topRight());                break;            case QTabBar::RoundedWest:            case QTabBar::TriangularWest:                p->setPen(QPen(tbb->palette.light(), 0));                p->drawLine(tbb->rect.topLeft(), tbb->rect.bottomLeft());                break;            case QTabBar::RoundedSouth:            case QTabBar::TriangularSouth:                p->setPen(QPen(tbb->palette.shadow(), 0));                p->drawLine(tbb->rect.left(), tbb->rect.bottom(),                            tbb->rect.right(), tbb->rect.bottom());                p->setPen(QPen(tbb->palette.dark(), 0));                p->drawLine(tbb->rect.left(), tbb->rect.bottom() - 1,                            tbb->rect.right() - 1, tbb->rect.bottom() - 1);                break;            case QTabBar::RoundedEast:            case QTabBar::TriangularEast:                p->setPen(QPen(tbb->palette.dark(), 0));                p->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight());                break;            }            p->restore();        }        break;#endif // QT_NO_TABBAR    case PE_FrameTabWidget:    case PE_FrameWindow:        qDrawWinPanel(p, opt->rect, opt->palette, false, 0);        break;    case PE_FrameLineEdit:        drawPrimitive(PE_Frame, opt, p, widget);        break;#ifndef QT_NO_GROUPBOX    case PE_FrameGroupBox:        if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {            const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt);            if (frame2 && (frame2->features & QStyleOptionFrameV2::Flat)) {                QRect fr = frame->rect;                QPoint p1(fr.x(), fr.y() + 1);                QPoint p2(fr.x() + fr.width(), p1.y());                qDrawShadeLine(p, p1, p2, frame->palette, true,                               frame->lineWidth, frame->midLineWidth);            } else {                qDrawShadeRect(p, frame->rect.x(), frame->rect.y(), frame->rect.width(),                               frame->rect.height(), frame->palette, true,                               frame->lineWidth, frame->midLineWidth);            }        }        break;#endif // QT_NO_GROUPBOX#ifndef QT_NO_DOCKWIDGET    case PE_FrameDockWidget:        if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {            int lw = frame->lineWidth;            if (lw <= 0)                lw = pixelMetric(PM_DockWidgetFrameWidth);            qDrawShadePanel(p, frame->rect, frame->palette, false, lw);        }        break;#endif // QT_NO_DOCKWIDGET#ifndef QT_NO_TOOLBAR    case PE_IndicatorToolBarHandle:        p->save();        p->translate(opt->rect.x(), opt->rect.y());        if (opt->state & State_Horizontal) {            int x = opt->rect.width() / 3;            if (QApplication::layoutDirection() == Qt::RightToLeft)                x -= 2;            if (opt->rect.height() > 4) {                qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,                                opt->palette, false, 1, 0);                qDrawShadePanel(p, x+3, 2, 3, opt->rect.height() - 4,                                opt->palette, false, 1, 0);            }        } else {            if (opt->rect.width() > 4) {                int y = opt->rect.height() / 3;                qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,                                opt->palette, false, 1, 0);                qDrawShadePanel(p, 2, y+3, opt->rect.width() - 4, 3,                                opt->palette, false, 1, 0);            }        }        p->restore();        break;    case PE_Q3DockWindowSeparator:        drawPrimitive(PE_IndicatorToolBarSeparator, opt, p, widget);        break;    case PE_IndicatorToolBarSeparator:        {            QPoint p1, p2;            if (opt->state & State_Horizontal) {                p1 = QPoint(opt->rect.width()/2, 0);                p2 = QPoint(p1.x(), opt->rect.height());            } else {                p1 = QPoint(0, opt->rect.height()/2);                p2 = QPoint(opt->rect.width(), p1.y());            }            qDrawShadeLine(p, p1, p2, opt->palette, 1, 1, 0);            break;        }#endif // QT_NO_TOOLBAR#ifndef QT_NO_SPINBOX    case PE_IndicatorSpinPlus:    case PE_IndicatorSpinMinus: {        QRect r = opt->rect;        int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget);        QRect br = r.adjusted(fw, fw, -fw, -fw);        int offset = (opt->state & State_Sunken) ? 1 : 0;        int step = (br.width() + 4) / 5;        p->fillRect(br.x() + offset, br.y() + offset +br.height() / 2 - step / 2,                    br.width(), step,                    opt->palette.buttonText());        if (pe == PE_IndicatorSpinPlus)            p->fillRect(br.x() + br.width() / 2 - step / 2 + offset, br.y() + offset,                        step, br.height(),                        opt->palette.buttonText());        break; }    case PE_IndicatorSpinUp:    case PE_IndicatorSpinDown: {        QRect r = opt->rect;        int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget);        // QRect br = r.adjusted(fw, fw, -fw, -fw);        int x = r.x(), y = r.y(), w = r.width(), h = r.height();        int sw = w-4;        if (sw < 3)            break;        else if (!(sw & 1))            sw--;        sw -= (sw / 7) * 2;        // Empty border        int sh = sw/2 + 2;      // Must have empty row at foot of arrow        int sx = x + w / 2 - sw / 2;        int sy = y + h / 2 - sh / 2;        if (pe == PE_IndicatorSpinUp && fw)            --sy;        QPolygon a;        if (pe == PE_IndicatorSpinDown)            a.setPoints(3, 0, 1,  sw-1, 1,  sh-2, sh-1);        else            a.setPoints(3, 0, sh-1,  sw-1, sh-1,  sh-2, 1);        int bsx = 0;        int bsy = 0;        if (opt->state & State_Sunken) {            bsx = pixelMetric(PM_ButtonShiftHorizontal);            bsy = pixelMetric(PM_ButtonShiftVertical);        }        p->save();        p->translate(sx + bsx, sy + bsy);        p->setPen(opt->palette.buttonText().color());        p->setBrush(opt->palette.buttonText());        p->drawPolygon(a);        p->restore();        break; }#endif // QT_NO_SPINBOX    case PE_PanelTipLabel: {        QBrush oldBrush = p->brush();        QPen oldPen = p->pen();        p->setPen(opt->palette.foreground().color());

⌨️ 快捷键说明

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