/*!
  Draw the border of the canvas
  \param painter Painter
*/
void QwtPlotGLCanvas::drawBorder( QPainter *painter )
{
    const int fw = frameWidth();
    if ( fw <= 0 )
        return;

    if ( frameShadow() == QwtPlotGLCanvas::Plain )
    {
        qDrawPlainRect( painter, frameRect(), 
            palette().shadow().color(), lineWidth() );
    }
    else
    {
        if ( frameShape() == QwtPlotGLCanvas::Box )
        {
            qDrawShadeRect( painter, frameRect(), palette(),
                frameShadow() == Sunken, lineWidth(), midLineWidth() );
        }
        else
        {
            qDrawShadePanel( painter, frameRect(), palette(), 
                frameShadow() == Sunken, lineWidth() );
        }
    }
}
Esempio n. 2
0
/*!
  Virtual function that draws the mask of the frame's frame.

  If you reimplemented drawFrame(QPainter*) and your widget should
  support transparency you probably have to re-implement this function as well.

  \sa drawFrame(), updateMask(), QWidget::setAutoMask(), QPainter::setClipRect()
*/
void QFrame::drawFrameMask( QPainter* p )
{
    QPoint	p1, p2;
    QRect	r     = frameRect();
    int		type  = fstyle & MShape;
    int		style = fstyle & MShadow;
#ifdef QT_NO_DRAWUTIL
    p->setPen( color1 );
    p->drawRect( r ); //### a bit too simple
#else
    QColorGroup g(color1, color1, color1, color1, color1, color1, color1, color1, color0);

    switch ( type ) {

    case Box:
	if ( style == Plain )
	    qDrawPlainRect( p, r, g.foreground(), lwidth );
	else
	    qDrawShadeRect( p, r, g, style == Sunken, lwidth,
			    midLineWidth() );
	break;

    case Panel:
	if ( style == Plain )
	    qDrawPlainRect( p, r, g.foreground(), lwidth );
	else
	    qDrawShadePanel( p, r, g, style == Sunken, lwidth );
	break;

    case WinPanel:
	if ( style == Plain )
	    qDrawPlainRect( p, r, g.foreground(), wpwidth );
	else
	    qDrawWinPanel( p, r, g, style == Sunken );
	break;

    case HLine:
    case VLine:
	if ( type == HLine ) {
	    p1 = QPoint( r.x(), r.height()/2 );
	    p2 = QPoint( r.x()+r.width(), p1.y() );
	}
	else {
	    p1 = QPoint( r.x()+r.width()/2, 0 );
	    p2 = QPoint( p1.x(), r.height() );
	}
	if ( style == Plain ) {
	    QPen oldPen = p->pen();
	    p->setPen( QPen(g.foreground(),lwidth) );
	    p->drawLine( p1, p2 );
	    p->setPen( oldPen );
	}
	else
	    qDrawShadeLine( p, p1, p2, g, style == Sunken,
			    lwidth, midLineWidth() );
	break;
    }
#endif // QT_NO_DRAWUTIL
}
Esempio n. 3
0
void qDrawShadeRect(QPainter *p, const QRect &r,
                     const QPalette &pal, bool sunken,
                     int lineWidth, int midLineWidth,
                     const QBrush *fill)
{
    qDrawShadeRect(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
                    lineWidth, midLineWidth, fill);
}
Esempio n. 4
0
void qDrawShadeRect( QPainter *p, const QRect &r,
		     const QColorGroup &g, bool sunken,
		     int lineWidth, int midLineWidth,
		     const QBrush *fill )
{
    qDrawShadeRect( p, r.x(), r.y(), r.width(), r.height(), g, sunken,
		    lineWidth, midLineWidth, fill );
}
//! @todo add more frame types
void ClassName::drawFrame(QPainter *p)
{
    if (frameShape() == QFrame::Box) {
        if (frameShadow() == Plain)
            qDrawPlainRect(p, frameRect(), d->frameColor, lineWidth());
        else
            qDrawShadeRect(p, frameRect(), palette(), frameShadow() == QFrame::Sunken,
                           lineWidth(), midLineWidth());
    } else {
        SuperClassName::drawFrame(p);
    }
}
Esempio n. 6
0
void KWMThemeClient::drawTitle(QPainter &dest)
{
    QRect titleRect = titlebar->geometry();
    QRect r(0, 0, titleRect.width(), titleRect.height());
    QPixmap buffer;

    if(buffer.width() == r.width())
        return;

    buffer.resize(r.size());
    QPainter p;
    p.begin(&buffer);

    if(titleSunken){
        qDrawShadeRect(&p, r, options()->colorGroup(KDecorationOptions::ColorFrame, isActive()),
                       true, 1, 0);
        r.setRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
    }
    
    KPixmap *fill = isActive() ? aTitlePix : iTitlePix;
    if(fill)
        p.drawTiledPixmap(r, *fill);
    else if(titleGradient){
        fill = isActive() ? aGradient : iGradient;
        if(fill->width() != r.width()){
            fill->resize(r.width(), 20);
            KPixmapEffect::gradient(*fill,
                                    options()->color(KDecorationOptions::ColorTitleBar, isActive()),
                                    options()->color(KDecorationOptions::ColorTitleBlend, isActive()),
                                    grType);
        }
        p.drawTiledPixmap(r, *fill);
    }
    else{
        p.fillRect(r, options()->colorGroup(KDecorationOptions::ColorTitleBar, isActive()).
                   brush(QColorGroup::Button));
    }
    p.setFont(options()->font(isActive()));
    p.setPen(options()->color(KDecorationOptions::ColorFont, isActive()));
    // Add left & right margin
    r.setLeft(r.left()+5);
    r.setRight(r.right()-5);
    p.drawText(r, titleAlign, caption());
    p.end();

    dest.drawPixmap(titleRect.x(), titleRect.y(), buffer);
}
Esempio n. 7
0
/*!
  Shows the temporary message, if appropriate.
*/
void QStatusBar::paintEvent( QPaintEvent * )
{
    bool haveMessage = !d->tempItem.isEmpty();

    QPainter p( this );
    QStatusBarPrivate::SBItem* item = d->items.first();
    while ( item ) {
	if ( (!haveMessage || item->p) && item->w->isVisible() )
	    qDrawShadeRect( &p, item->w->x()-1, item->w->y()-1,
			    item->w->width()+2, item->w->height()+2,
			    colorGroup(), TRUE, 1, 0, 0 );
	item = d->items.next();
    }
    if ( haveMessage ) {
	p.setPen( colorGroup().text() );
	// ### clip and add ellipsis if necessary
	p.drawText( 6, 0, width() - 12, height(), AlignVCenter + SingleLine,
		    d->tempItem );
    }
}
Esempio n. 8
0
void Q3GroupBox::drawFrame(QPainter *p)
{
    QPoint      p1, p2;
    QStyleOptionFrame opt;
    opt.init(this);

    int frameShape  = d->frameStyle & QFrame::Shape_Mask;
    int frameShadow = d->frameStyle & QFrame::Shadow_Mask;

    int lw = 0;
    int mlw = 0;
    opt.rect = frameRect();

    switch (frameShape) {
    case QFrame::Box:
    case QFrame::HLine:
    case QFrame::VLine:
    case QFrame::StyledPanel:
        lw = d->lineWidth;
        mlw = d->midLineWidth;
        break;
    default:
        // most frame styles do not handle customized line and midline widths
        // (see updateFrameWidth()).
        lw = d->frameWidth;
        break;
    }
    opt.lineWidth = lw;
    opt.midLineWidth = mlw;
    if (frameShadow == Sunken)
        opt.state |= QStyle::State_Sunken;
    else if (frameShadow == Raised)
        opt.state |= QStyle::State_Raised;

    switch (frameShape) {
    case Box:
        if (frameShadow == Plain)
            qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw);
        else
            qDrawShadeRect(p, opt.rect, opt.palette, frameShadow == Sunken, lw, mlw);
        break;

    case StyledPanel:
        style()->drawPrimitive(QStyle::PE_Frame, &opt, p, this);
        break;

    case Panel:
        if (frameShadow == Plain)
            qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw);
        else
            qDrawShadePanel(p, opt.rect, opt.palette, frameShadow == Sunken, lw);
        break;

    case WinPanel:
        if (frameShadow == Plain)
            qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw);
        else
            qDrawWinPanel(p, opt.rect, opt.palette, frameShadow == Sunken);
        break;
    case HLine:
    case VLine:
        if (frameShape == HLine) {
            p1 = QPoint(opt.rect.x(), opt.rect.height() / 2);
            p2 = QPoint(opt.rect.x() + opt.rect.width(), p1.y());
        } else {
            p1 = QPoint(opt.rect.x()+opt.rect.width() / 2, 0);
            p2 = QPoint(p1.x(), opt.rect.height());
        }
        if (frameShadow == Plain) {
            QPen oldPen = p->pen();
            p->setPen(QPen(opt.palette.foreground().color(), lw));
            p->drawLine(p1, p2);
            p->setPen(oldPen);
        } else {
            qDrawShadeLine(p, p1, p2, opt.palette, frameShadow == Sunken, lw, mlw);
        }
        break;
    }

#ifdef QT_KEYPAD_NAVIGATION
    if (QApplication::keypadNavigationEnabled() && hasFocus()) {
        QStyleOptionFocusRect fopt;
        fopt.init(this);
        fopt.state |= QStyle::State_KeyboardFocusChange;
        fopt.rect = frameRect();
        style()->drawPrimitive(QStyle::PE_FrameFocusRect, &fopt, p, this);
    }
#endif
}
Esempio n. 9
0
void Frame::drawFrame(QPainter *p)
{
    QPoint p1, p2;
    QStyleOptionFrame opt;
    opt.init(this);
    if ( hasFocus() ) {
        opt.state |= QStyle::State_HasFocus;
    }
    int frameShape  = frameStyle() & QFrame::Shape_Mask;
    int frameShadow = frameStyle() & QFrame::Shadow_Mask;

    int lw = 0;
    int mlw = 0;
    opt.rect = frameRect();
    switch (frameShape) {
        case QFrame::Box:
        case QFrame::HLine:
        case QFrame::VLine:
        case QFrame::StyledPanel:
            lw = lineWidth();
            mlw = midLineWidth();
            break;
        default:
            // most frame styles do not handle customized line and midline widths
            // (see updateFrameWidth()).
            lw = frameWidth();
            break;
    }
    opt.lineWidth = lw;
    opt.midLineWidth = mlw;
    if (frameShadow == Sunken)
        opt.state |= QStyle::State_Sunken;
    else if (frameShadow == Raised)
        opt.state |= QStyle::State_Raised;

    switch (frameShape) {
        case Box:
            if (frameShadow == Plain)
                qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw);
            else
                qDrawShadeRect(p, opt.rect, opt.palette, frameShadow == Sunken, lw, mlw);
            break;


        case StyledPanel:
            style()->drawPrimitive(QStyle::PE_Frame, &opt, p, this);
            break;

        case Panel:
            if (frameShadow == Plain)
                qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw);
            else
                qDrawShadePanel(p, opt.rect, opt.palette, frameShadow == Sunken, lw);
            break;

        case WinPanel:
            if (frameShadow == Plain)
                qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw);
            else
                qDrawWinPanel(p, opt.rect, opt.palette, frameShadow == Sunken);
            break;
        case HLine:
        case VLine:
            if (frameShape == HLine) {
                p1 = QPoint(opt.rect.x(), opt.rect.height() / 2);
                p2 = QPoint(opt.rect.x() + opt.rect.width(), p1.y());
            } else {
                p1 = QPoint(opt.rect.x()+opt.rect.width() / 2, 0);
                p2 = QPoint(p1.x(), opt.rect.height());
            }
            if (frameShadow == Plain) {
                QPen oldPen = p->pen();
                p->setPen(QPen(opt.palette.foreground().color(), lw));
                p->drawLine(p1, p2);
                p->setPen(oldPen);
            } else {
                qDrawShadeLine(p, p1, p2, opt.palette, frameShadow == Sunken, lw, mlw);
            }
            break;
    }
}
Esempio n. 10
0
void QFrame::drawFrame(QPainter *p)
{
    QPoint      p1, p2;
    QRect       r     = frameRect();
    int         type  = fstyle & MShape;
    int         cstyle = fstyle & MShadow;
#ifdef QT_NO_DRAWUTIL
    p->setPen(black);   // ####
    p->drawRect(r);   //### a bit too simple
#else
    const QColorGroup & g = colorGroup();

#ifndef QT_NO_STYLE
    QStyleOption opt(lineWidth(), midLineWidth());

    QStyle::SFlags flags = QStyle::Style_Default;
    if (isEnabled())
        flags |= QStyle::Style_Enabled;
    if (cstyle == Sunken)
        flags |= QStyle::Style_Sunken;
    else if (cstyle == Raised)
        flags |= QStyle::Style_Raised;
    if (hasFocus())
        flags |= QStyle::Style_HasFocus;
    if (hasMouse())
        flags |= QStyle::Style_MouseOver;
#endif // QT_NO_STYLE

    switch (type) {

    case Box:
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), lwidth);
        else
            qDrawShadeRect(p, r, g, cstyle == Sunken, lwidth,
                           midLineWidth());
        break;

    case LineEditPanel:
        style().drawPrimitive(QStyle::PE_PanelLineEdit, p, r, g, flags, opt);
        break;

    case GroupBoxPanel:
        style().drawPrimitive(QStyle::PE_PanelGroupBox, p, r, g, flags, opt);
        break;

    case TabWidgetPanel:
        style().drawPrimitive(QStyle::PE_PanelTabWidget, p, r, g, flags, opt);
        break;

    case MenuBarPanel:
#ifndef QT_NO_STYLE
        style().drawPrimitive(QStyle::PE_PanelMenuBar, p, r, g, flags, opt);
        break;
#endif // fall through to Panel if QT_NO_STYLE

    case ToolBarPanel:
#ifndef QT_NO_STYLE
        style().drawPrimitive(QStyle::PE_PanelDockWindow, p, rect(), g, flags, opt);
        break;
#endif // fall through to Panel if QT_NO_STYLE

    case StyledPanel:
#ifndef QT_NO_STYLE
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), lwidth);
        else
            style().drawPrimitive(QStyle::PE_Panel, p, r, g, flags, opt);
        break;
#endif // fall through to Panel if QT_NO_STYLE

    case PopupPanel:
#ifndef QT_NO_STYLE
        {
            int vextra = style().pixelMetric(QStyle::PM_PopupMenuFrameVerticalExtra, this),
                         hextra = style().pixelMetric(QStyle::PM_PopupMenuFrameHorizontalExtra, this);
            if (vextra > 0 || hextra > 0) {
                QRect fr = frameRect();
                int   fw = frameWidth();
                if (vextra > 0) {
                    style().drawControl(QStyle::CE_PopupMenuVerticalExtra, p, this,
                                        QRect(fr.x() + fw, fr.y() + fw, fr.width() - (fw*2), vextra),
                                        g, flags, opt);
                    style().drawControl(QStyle::CE_PopupMenuVerticalExtra, p, this,
                                        QRect(fr.x() + fw, fr.bottom() - fw - vextra, fr.width() - (fw*2), vextra),
                                        g, flags, opt);
                }
                if (hextra > 0) {
                    style().drawControl(QStyle::CE_PopupMenuHorizontalExtra, p, this,
                                        QRect(fr.x() + fw, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra),
                                        g, flags, opt);
                    style().drawControl(QStyle::CE_PopupMenuHorizontalExtra, p, this,
                                        QRect(fr.right() - fw - hextra, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra),
                                        g, flags, opt);
                }
            }

            if (cstyle == Plain)
                qDrawPlainRect(p, r, g.foreground(), lwidth);
            else
                style().drawPrimitive(QStyle::PE_PanelPopup, p, r, g, flags, opt);
            break;
        }
#endif // fall through to Panel if QT_NO_STYLE

    case Panel:
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), lwidth);
        else
            qDrawShadePanel(p, r, g, cstyle == Sunken, lwidth);
        break;

    case WinPanel:
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), wpwidth);
        else
            qDrawWinPanel(p, r, g, cstyle == Sunken);
        break;
    case HLine:
    case VLine:
        if (type == HLine) {
            p1 = QPoint(r.x(), r.height() / 2);
            p2 = QPoint(r.x() + r.width(), p1.y());
        } else {
            p1 = QPoint(r.x() + r.width() / 2, 0);
            p2 = QPoint(p1.x(), r.height());
        }
        if (cstyle == Plain) {
            QPen oldPen = p->pen();
            p->setPen(QPen(g.foreground(), lwidth));
            p->drawLine(p1, p2);
            p->setPen(oldPen);
        } else
            qDrawShadeLine(p, p1, p2, g, cstyle == Sunken,
                           lwidth, midLineWidth());
        break;
    }
Esempio n. 11
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);
    }
}
Esempio n. 12
0
void QFrame::drawFrame( QPainter *p )
{
    QPoint	p1, p2;
    QRect	r     = frameRect();
    int		type  = fstyle & MShape;
    int		cstyle = fstyle & MShadow;
#ifdef QT_NO_DRAWUTIL
    p->setPen( black ); // ####
    p->drawRect( r ); //### a bit too simple
#else

    const QColorGroup & g = colorGroup();

    switch ( type ) {

    case Box:
	if ( cstyle == Plain )
	    qDrawPlainRect( p, r, g.foreground(), lwidth );
	else
	    qDrawShadeRect( p, r, g, cstyle == Sunken, lwidth,
			    midLineWidth() );
	break;

    case StyledPanel:
#ifndef QT_NO_STYLE
	if ( cstyle == Plain )
	    qDrawPlainRect( p, r, g.foreground(), lwidth );
	else
	    style().drawPanel( p, r.x(), r.y(), r.width(), r.height(), g, cstyle == Sunken, lwidth );
	break;
#endif // fall through to Panel if QT_NO_STYLE

    case PopupPanel:
#ifndef QT_NO_STYLE
	if ( cstyle == Plain )
	    qDrawPlainRect( p, r, g.foreground(), lwidth );
	else
	    style().drawPopupPanel( p, r.x(), r.y(), r.width(), r.height(), g, lwidth );
	break;
#endif // fall through to Panel if QT_NO_STYLE

    case Panel:
	if ( cstyle == Plain )
	    qDrawPlainRect( p, r, g.foreground(), lwidth );
	else
	    qDrawShadePanel( p, r, g, cstyle == Sunken, lwidth );
	break;

    case WinPanel:
	if ( cstyle == Plain )
	    qDrawPlainRect( p, r, g.foreground(), wpwidth );
	else
	    qDrawWinPanel( p, r, g, cstyle == Sunken );
	break;

    case HLine:
    case VLine:
	if ( type == HLine ) {
	    p1 = QPoint( r.x(), r.height()/2 );
	    p2 = QPoint( r.x()+r.width(), p1.y() );
	}
	else {
	    p1 = QPoint( r.x()+r.width()/2, 0 );
	    p2 = QPoint( p1.x(), r.height() );
	}
	if ( cstyle == Plain ) {
	    QPen oldPen = p->pen();
	    p->setPen( QPen(g.foreground(),lwidth) );
	    p->drawLine( p1, p2 );
	    p->setPen( oldPen );
	}
	else
	    qDrawShadeLine( p, p1, p2, g, cstyle == Sunken,
			    lwidth, midLineWidth() );
	break;
    }
#endif // QT_NO_DRAWUTIL
}