Example #1
0
void KreogistCuteStyle::drawTabItem(const QStyleOptionTab *opt,
                                    QPainter *p,
                                    const QWidget *w) const
{
    if(opt->state & QStyle::State_Selected)
    {
        QStyleOptionTab tmp=*opt;
        tmp.text=QString(opt->text.length(),QChar(' '));
        style->drawControl(CE_TabBarTab,&tmp,p,w);
        int alignment = Qt::AlignCenter | Qt::TextShowMnemonic;
        if(!proxy()->styleHint(SH_UnderlineShortcut, opt, w))
        {
            alignment |= Qt::TextHideMnemonic;
        }
        style->drawItemText(p,
                            subElementRect(SE_TabBarTabText, opt, w),
                            alignment,
                            opt->palette,
                            true,
                            opt->text,
                            QPalette::HighlightedText);
    }
    else
    {
        style->drawControl(CE_TabBarTab,opt,p,w);
    }
}
Example #2
0
void
Style::drawHeader(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
    ASSURE_OPTION(header, Header);

    if (appType == GTK)
        const_cast<QStyleOption*>(option)->palette = qApp->palette();

    // init
    //    const QRegion clipRegion = painter->clipRegion();
    //    painter->setClipRect(RECT/*, Qt::IntersectClip*/);

    // base
    drawHeaderSection(header, painter, widget);

    // label
    drawHeaderLabel(header, painter, widget);

    // sort Indicator on sorting or (inverted) on hovered headers
    if (header->sortIndicator != QStyleOptionHeader::None)
    {
        QStyleOptionHeader subopt = *header;
        subopt.rect = subElementRect(SE_HeaderArrow, option, widget);
        drawHeaderArrow(&subopt, painter, widget);
    }
       
//    painter->setClipRegion(clipRegion);
}
Example #3
0
QRect DarkBlueStyle::subElementRect(SubElement sr, const QStyleOption* opt, const QWidget* widget) const
{
    QRect r;
    switch(sr)
    {
        case SE_CheckBoxIndicator:
        case SE_RadioButtonIndicator:
        {
            int h = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget);
            r.setRect(opt->rect.x()+1, opt->rect.y() + ((opt->rect.height() - h) / 2),
                      proxy()->pixelMetric(PM_IndicatorWidth, opt, widget), h);
            break;
        }
        case SE_CheckBoxContents:
        case SE_RadioButtonContents:
        {
            QRect ir = subElementRect(SE_CheckBoxIndicator, opt, widget);
            int spacing = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt, widget);
            r.setRect(ir.right() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing, opt->rect.height());
            break;
        }
        default:
        {
            return mStyle->subElementRect(sr, opt, widget);
        }
    }
    return r;
}
Example #4
0
QRect  QCommonStyle_QtDShell::__override_subElementRect(int  r0, const QStyleOption*  opt1, const QWidget*  widget2, bool static_call) const
{
    if (static_call) {
        return QCommonStyle::subElementRect((QStyle::SubElement )r0, (const QStyleOption* )opt1, (const QWidget* )widget2);
    } else {
        return subElementRect((QStyle::SubElement )r0, (const QStyleOption* )opt1, (const QWidget* )widget2);
    }
}
Example #5
0
// draw custom slider + handle for volume widget
void MpcVolumeSlideStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
                                       QPainter *p, const QWidget *widget) const
{
    if( cc == CC_Slider )
    {
        if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
            QRect groove = subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
            QRect handle = subControlRect(CC_Slider, slider, SC_SliderHandle, widget);

            if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {

                p->setPen(slider->palette.shadow().color());
                if (slider->orientation == Qt::Horizontal) {
                    static QPoint points[3] = {
                                QPoint(groove.x() , groove.y() + slider->rect.height() ),
                                QPoint(groove.x() + groove.width() -2 , groove.y() + slider->rect.height() ),
                                QPoint(groove.x() + groove.width() -2 , groove.y()  ),
                            };
                    QPen oldPen = p->pen();
                    
                    p->setPen(slider->palette.dark().color());
                    p->drawLine(QPoint(points[0].x(), points[0].y() -2 ),QPoint(points[2].x(), points[2].y()));

                    QPoint b[3] = { QPoint(points[0].x(),points[0].y()-1), QPoint(points[1].x()-1, points[1].y()-1), QPoint(points[2].x()-1,points[2].y()) };
                    p->setPen(slider->palette.light().color());
                    p->drawPolyline(b, 3);
                    p->setPen(oldPen);
                }
            }


            if (slider->subControls & SC_SliderTickmarks) {
                QStyleOptionSlider tmpSlider = *slider;
                tmpSlider.subControls = SC_SliderTickmarks;
                QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
            }

            if (slider->subControls & SC_SliderHandle) {
                QBrush handleBrush;

                if (slider->state & State_Enabled) {
                    handleBrush = slider->palette.color(QPalette::Button);
                } else {
                    handleBrush = QBrush(slider->palette.color(QPalette::Button),
                                         Qt::Dense4Pattern);
                }


                int x = handle.x() , y = handle.y(),
                   wi = handle.width() - 2, he = slider->rect.height();

                if (slider->state & State_HasFocus) {
                    QStyleOptionFocusRect fropt;
                    fropt.QStyleOption::operator=(*slider);
                    fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
                    drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
                }

                Qt::BGMode oldMode = p->backgroundMode();
                p->setBackgroundMode(Qt::OpaqueMode);
                qDrawWinButton(p, QRect(x, y, wi, he), slider->palette, false,
                                   &handleBrush);
                p->setBackgroundMode(oldMode);

            }
        }
    }
    else
    {
        QWindowsStyle::drawComplexControl(cc,opt,p,widget);
    }
}
Example #6
0
// draw custom slider + handle for timeslide widget
void MpcTimeSlideStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
                                       QPainter *p, const QWidget *widget) const
{
    if( cc == CC_Slider )
    {
        if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
            QRect groove = subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
            QRect handle = subControlRect(CC_Slider, slider, SC_SliderHandle, widget);

            if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
                if (slider->orientation == Qt::Horizontal) {
                    int x = groove.x() + 2;
                    int y = slider->rect.height() / 2 - 4;
                    int w = groove.width() - 4;
                    int h = 7;
                    qDrawShadeRect (p,x,y,w,h, slider->palette, true,1,0,
                        &slider->palette.brush(QPalette::Light));
                }
            }


            if (slider->subControls & SC_SliderTickmarks) {
                QStyleOptionSlider tmpSlider = *slider;
                tmpSlider.subControls = SC_SliderTickmarks;
                QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
            }

            if (slider->subControls & SC_SliderHandle) {
                QBrush handleBrush;

                if (slider->state & State_Enabled) {
                    handleBrush = slider->palette.color(QPalette::Button);
                } else {
                    handleBrush = QBrush(slider->palette.color(QPalette::Button),
                                         Qt::Dense4Pattern);
                }


                int x = handle.x() , y = handle.y() + 1,
                   wi = 13, he = 14;

                if (slider->state & State_HasFocus) {
                    QStyleOptionFocusRect fropt;
                    fropt.QStyleOption::operator=(*slider);
                    fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
                    drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
                }

                Qt::BGMode oldMode = p->backgroundMode();
                p->setBackgroundMode(Qt::OpaqueMode);
                qDrawWinPanel(p, QRect(x, y, wi, he), slider->palette, false,
                               &handleBrush);
                qDrawShadeRect (p, QRect(x+2,y+3, wi-4, he-6), slider->palette, true,1,0,
                               &slider->palette.brush(QPalette::Light));
                p->setBackgroundMode(oldMode);
            }
        }
    }
    else
    {
        QWindowsStyle::drawComplexControl(cc,opt,p,widget);
    }
}
Example #7
0
void Style::drawControl
( ControlElement element, const QStyleOption * option,
  QPainter * painter, const QWidget * widget ) const
{
    if (shouldNotHandle(widget)) {
        QProxyStyle::drawControl(element, option, painter, widget);
        return;
    }

    switch(element) {
    case QStyle::CE_TabBarTab: {
        const QStyleOptionTabV3 *tabOption = static_cast<const QStyleOptionTabV3*>(option);

        painter->save();

        painter->setRenderHint( QPainter::Antialiasing, true );

        bool highlight = tabOption->state & QStyle::State_Selected
                || tabOption->state & QStyle::State_MouseOver;

        QRectF r = tabOption->rect;

        switch (tabOption->shape) {
        case QTabBar::RoundedNorth:
        case QTabBar::TriangularNorth:
            r.adjust(0.5, 0.5, -0.5, 4);
            painter->setClipRect( tabOption->rect.adjusted(0,0,0,-1) );
            break;
        case QTabBar::RoundedSouth:
        case QTabBar::TriangularSouth:
            r.adjust(0.5, -4, -0.5, -0.5);
            painter->setClipRect( tabOption->rect.adjusted(0,1,0,0) );
            break;
        default:
            qWarning("ScIDE::Style: tab shape not supported");
            break;
        }

        QColor fill = option->palette.color(QPalette::Button);
        QColor edge = option->palette.color(QPalette::Dark);
        if (highlight)
            painter->setBrush(fill);
        else
            painter->setBrush(Qt::NoBrush);
        painter->setPen(edge);
        painter->drawRoundedRect(r, 4, 4);

        painter->restore();

        if (!tabOption->icon.isNull()) {
            QPixmap pixmap = tabOption->icon.pixmap( tabOption->iconSize );
            QRect iconRect = pixmap.rect();
            iconRect.moveCenter( tabOption->rect.center() );
            int lmargin = 5;
            if (tabOption->leftButtonSize.width() > 0)
                lmargin += tabOption->leftButtonSize.width() + 4;
            iconRect.moveLeft( tabOption->rect.left() + lmargin );
            painter->drawPixmap( iconRect, pixmap );
        }

        QRect textRect = subElementRect( QStyle::SE_TabBarTabText, option, widget );

        painter->drawText( textRect,
                           Qt::AlignCenter | Qt::TextShowMnemonic,
                           tabOption->text );
        return;
    }
    case CE_Splitter:
        painter->save();
        painter->setPen(Qt::NoPen);
        painter->setBrush(option->palette.color(QPalette::Shadow));
        painter->drawRect( option->rect );
        painter->restore();
        return;
    default:
        break;
    }
    QProxyStyle::drawControl(element, option, painter, widget);
}
void CWizCategoryViewItemBase::draw(QPainter* p, const QStyleOptionViewItemV4 *vopt) const
{
#if 0
    if (!vopt->icon.isNull()) {
        QRect iconRect = subElementRect(SE_ItemViewItemDecoration, vopt, view);

        if (vopt->state.testFlag(State_Selected)) {
            vopt->icon.paint(p, iconRect, Qt::AlignCenter, QIcon::Selected);
        } else {
            vopt->icon.paint(p, iconRect, Qt::AlignCenter, QIcon::Normal);
        }
    }

    // text should not empty
    if (vopt->text.isEmpty()) {
        Q_ASSERT(0);
        return;
    }

    // draw text little far from icon than the default
    QRect textRect = subElementRect(SE_ItemViewItemText, vopt, view);
    //textRect.adjust(8, 0, 0, 0);

    // draw the text
    QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled
            ? QPalette::Normal : QPalette::Disabled;
    if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
        cg = QPalette::Inactive;

    if (vopt->state & QStyle::State_Selected) {
        p->setPen(vopt->palette.color(cg, QPalette::HighlightedText));
    } else {
        p->setPen(vopt->palette.color(cg, QPalette::Text));
    }

    if (vopt->state & QStyle::State_Editing) {
        p->setPen(vopt->palette.color(cg, QPalette::Text));
        p->drawRect(textRect.adjusted(0, 0, -1, -1));
    }

    // compute document count string length and leave enough space for drawing
    QString strCount = pItem->countString;
    int nCountWidthMax;
    int nMargin = 3;
    QFont fontCount = p->font();
    fontCount.setPointSize(10);

    if (!strCount.isEmpty()) {
        QFont fontOld = p->font();
        p->setFont(fontCount);
        nCountWidthMax = p->fontMetrics().width(strCount) + nMargin;
        textRect.adjust(0, 0, -nCountWidthMax, 0);
        p->setFont(fontOld);
    }

    QFont f = p->font();
    f.setPixelSize(12);
    p->setFont(f);

    QColor colorText = vopt->state.testFlag(State_Selected) ?
                m_colorCategoryTextSelected : m_colorCategoryTextNormal;

    CString strText = vopt->text;
    int nWidth = ::WizDrawTextSingleLine(p, textRect, strText,
                                         Qt::TextSingleLine | Qt::AlignVCenter,
                                         colorText, true);

    // only draw document count if count string is not empty
    if (!strCount.isEmpty()) {
        p->setFont(fontCount);
        textRect.adjust(nWidth + nMargin, 0, nCountWidthMax, 0);
        QColor colorCount = vopt->state.testFlag(State_Selected) ? QColor(230, 230, 230) : QColor(150, 150, 150);
        CString strCount2(strCount);
        ::WizDrawTextSingleLine(p, textRect, strCount2,  Qt::TextSingleLine | Qt::AlignVCenter, colorCount, false);
    }

    p->restore();

#endif
}
Example #9
0
void DarkBlueStyle::drawControl(ControlElement element, const QStyleOption* opt, QPainter* p, const QWidget* widget) const
{
    switch(element)
    {
        case CE_ToolBar:
        {
            // This does nothing....
            //const QStyleOptionToolBar* toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(opt);
            //proxy()->drawPrimitive(PE_PanelToolBar, opt, p, widget);
            break;
        }
        case CE_RadioButton:
        {
            const QStyleOptionButton* btn = qstyleoption_cast<const QStyleOptionButton *>(opt);
            QStyleOptionButton subopt = *btn;
            
            subopt.rect = subElementRect(SE_RadioButtonIndicator, btn, widget);
            proxy()->drawPrimitive(PE_IndicatorRadioButton, &subopt, p, widget);
            
            subopt.rect = subElementRect(SE_RadioButtonContents, btn, widget);
            proxy()->drawControl(CE_RadioButtonLabel, &subopt, p, widget);
            
            break;
        }
        case CE_CheckBox:
        {
            const QStyleOptionButton* btn = qstyleoption_cast<const QStyleOptionButton *>(opt);
            QStyleOptionButton subopt = *btn;
            
            subopt.rect = subElementRect(SE_CheckBoxIndicator, btn, widget);
            proxy()->drawPrimitive(PE_IndicatorCheckBox, &subopt, p, widget);
            
            subopt.rect = subElementRect(SE_CheckBoxContents, btn, widget);
            proxy()->drawControl(CE_CheckBoxLabel, &subopt, p, widget);
            
            break;
        }
        case CE_RadioButtonLabel:
        case CE_CheckBoxLabel:
        {
            const QStyleOptionButton* btn = qstyleoption_cast<const QStyleOptionButton *>(opt);
            if(!btn->text.isEmpty())
            {
                p->setPen(QColor(200, 200, 200));
                p->drawText(btn->rect, Qt::AlignLeft | Qt::AlignVCenter, btn->text);
            }
            break;
        }
        case CE_PushButton:
        {
            const QStyleOptionButton* btn = qstyleoption_cast<const QStyleOptionButton *>(opt);
            proxy()->drawControl(CE_PushButtonBevel, btn, p, widget);
            
            QStyleOptionButton subopt = *btn;
            subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
            proxy()->drawControl(CE_PushButtonLabel, &subopt, p, widget);
            
            break;
        }
        case CE_PushButtonBevel:
        {
            const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt);
            QRect br = btn->rect;
            
            if(btn->features & QStyleOptionButton::DefaultButton)
            {
                proxy()->drawPrimitive(PE_FrameDefaultButton, opt, p, widget);
            }

            if(!(btn->features & (QStyleOptionButton::Flat | QStyleOptionButton::CommandLinkButton))
                    || btn->state & (State_Sunken | State_On)
                    || (btn->features & QStyleOptionButton::CommandLinkButton && btn->state & State_MouseOver))
            {
                QStyleOptionButton tmpBtn = *btn;
                tmpBtn.rect = br;
                proxy()->drawPrimitive(PE_PanelButtonCommand, &tmpBtn, p, widget);
            }
            break;
        }
        default:
        {
            mStyle->drawControl(element, opt, p, widget);
            break;
        }
    }
}