Пример #1
0
        void WhiteBoardColorChooser::paintEvent(QPaintEvent *e)
        {
            QFrame::paintEvent(e);

            QPainter tPaint;
            tPaint.begin(this);

            tPaint.drawPixmap(swapPixmapRect().topLeft(), m_swapPixmap);
            QRect bgRect = backgroundRect();
            QRect bgRectInside = QRect(bgRect.x () + 2, bgRect.y () + 2,
                                       bgRect.width () - 4, bgRect.height () - 4);
            tPaint.fillRect(bgRectInside, m_backgroundColor);
            qDrawShadePanel(&tPaint, bgRect, palette(),
                            false/*not sunken*/, 2/*lineWidth*/,
                            0/*never fill*/);

            QRect fgRect = foregroundRect();
            QRect fgRectInside = QRect(fgRect.x () + 2, fgRect.y () + 2,
                                       fgRect.width () - 4, fgRect.height () - 4);
            tPaint.fillRect(fgRectInside, m_foregroundColor);
            qDrawShadePanel(&tPaint, fgRect, palette (),
                            false/*not sunken*/, 2/*lineWidth*/,
                            0/*never fill*/);

            tPaint.end();
        }
Пример #2
0
//! Draw the thumb at a position
void QwtSlider::drawThumb(QPainter *p, const QRect &sliderRect, int pos)
{
    pos++; // shade line points one pixel below
    if (orientation() == Qt::Horizontal)
    {
        qDrawShadePanel(p, pos - d_thumbLength / 2, 
            sliderRect.y(), d_thumbLength, sliderRect.height(),
            colorGroup(), FALSE, d_borderWidth, 
            &colorGroup().brush(QColorGroup::Button));

        qDrawShadeLine(p, pos, sliderRect.y(), 
            pos, sliderRect.y() + sliderRect.height() - 2, 
            colorGroup(), TRUE, 1);
    }
    else // Vertical
    {
        qDrawShadePanel(p,sliderRect.x(), pos - d_thumbLength / 2, 
            sliderRect.width(), d_thumbLength,
            colorGroup(),FALSE, d_borderWidth, 
            &colorGroup().brush(QColorGroup::Button));

        qDrawShadeLine(p, sliderRect.x(), pos,
            sliderRect.x() + sliderRect.width() - 2, pos, 
            colorGroup(), TRUE, 1);
    }
}
Пример #3
0
//! Draw the thumb at a position
void QwtSlider::drawThumb(QPainter *p, const QRect &sliderRect, int pos)
{
    pos++; // shade line points one pixel below
    if (orientation() == Qt::Horizontal)
    {
        qDrawShadePanel(p, pos - d_data->thumbLength / 2, 
            sliderRect.y(), d_data->thumbLength, sliderRect.height(),
#if QT_VERSION < 0x040000
            colorGroup(), 
#else
            palette(), 
#endif
            false, d_data->borderWidth, 
#if QT_VERSION < 0x040000
            &colorGroup().brush(QColorGroup::Button)
#else
            &palette().brush(QPalette::Button)
#endif
        );

        qDrawShadeLine(p, pos, sliderRect.y(), 
            pos, sliderRect.y() + sliderRect.height() - 2, 
#if QT_VERSION < 0x040000
            colorGroup(), 
#else
            palette(), 
#endif
            true, 1);
    }
    else // Vertical
    {
        qDrawShadePanel(p,sliderRect.x(), pos - d_data->thumbLength / 2, 
            sliderRect.width(), d_data->thumbLength,
#if QT_VERSION < 0x040000
            colorGroup(),
#else
            palette(), 
#endif
            false, d_data->borderWidth, 
#if QT_VERSION < 0x040000
            &colorGroup().brush(QColorGroup::Button)
#else
            &palette().brush(QPalette::Button)
#endif
        );

        qDrawShadeLine(p, sliderRect.x(), pos,
            sliderRect.x() + sliderRect.width() - 2, pos, 
#if QT_VERSION < 0x040000
            colorGroup(), 
#else
            palette(), 
#endif
            true, 1);
    }
}
Пример #4
0
void KTriangleButton::paint( QPainter *painter )
{
    if ( isDown() || isOn() )
    {
        if ( style() == WindowsStyle )
            qDrawWinButton( painter, 0, 0, width(), 
                            height(), colorGroup(), TRUE );
        else
            qDrawShadePanel( painter, 0, 0, width(), 
                             height(), colorGroup(), TRUE, 2, 0L );
    }
    else if ( raised )
    {
        if ( style() == WindowsStyle )
            qDrawWinButton( painter, 0, 0, width(), height(), 
                            colorGroup(), FALSE );
        else
            qDrawShadePanel( painter, 0, 0, width(), height(), 
                             colorGroup(), FALSE, 2, 0L );
    }
    
    if (dir==Right)
    {
        int x=width()/4;
        int y=height()*2/6;
        int l=height()-y*2;
        int i=0;
        int maxi=width()-2*x;
        double m=((double)(l/2))/maxi;
        while (i<=maxi)
        {
            painter->drawLine(x,y+(int)(i*m),x,y+l-(int)(i*m));
            x++;
            i++;
        };
    }
    else if (dir==Left)
    {
        int x=width()/4;
        int y=height()*2/6;
        int l=height()-y*2;
        int i=0;
        int maxi=width()-2*x;
        x=width()-x;
        double m=((double)(l/2))/maxi;
        while (i<=maxi)
        {
            painter->drawLine(x,y+(int)(i*m),x,y+l-(int)(i*m));
            x--;
            i++;
        };
        
    };
    
}
Пример #5
0
//! Draw the slider into the specified rectangle.
void QwtSlider::drawSlider(QPainter *p, const QRect &r)
{
    QRect cr(r);

    if (d_bgStyle & BgTrough)
    {
        qDrawShadePanel(p, r.x(), r.y(),
            r.width(), r.height(),
            colorGroup(), TRUE, d_borderWidth,0);

        cr.setRect(r.x() + d_borderWidth,
            r.y() + d_borderWidth,
            r.width() - 2 * d_borderWidth,
            r.height() - 2 * d_borderWidth);

        p->fillRect(cr.x(), cr.y(), cr.width(), cr.height(), 
            colorGroup().brush(QColorGroup::Mid));
    }

    if ( d_bgStyle & BgSlot)
    {
        int ws = 4;
        int ds = d_thumbLength / 2 - 4;
        if ( ds < 1 )
            ds = 1;

        QRect rSlot;
        if (orientation() == Qt::Horizontal)
        {
            if ( cr.height() & 1 )
                ws++;
            rSlot = QRect(cr.x() + ds, 
                    cr.y() + (cr.height() - ws) / 2,
                    cr.width() - 2 * ds, ws);
        }
        else
        {
            if ( cr.width() & 1 )
                ws++;
            rSlot = QRect(cr.x() + (cr.width() - ws) / 2, 
                    cr.y() + ds,
                    ws, cr.height() - 2 * ds);
        }
        p->fillRect(rSlot.x(), rSlot.y(), rSlot.width(), rSlot.height(),
            colorGroup().brush(QColorGroup::Dark));
        qDrawShadePanel(p, rSlot.x(), rSlot.y(),
            rSlot.width(), rSlot.height(), colorGroup(), TRUE, 1 ,0);

    }

    if ( isValid() )
        drawThumb(p, cr, xyPosition(value()));
}
Пример #6
0
/*!
   Draw the slider into the specified rectangle.

   \param painter Painter
   \param sliderRect Bounding rectangle of the slider
*/
void QwtSlider::drawSlider( 
    QPainter *painter, const QRect &sliderRect ) const
{
    QRect innerRect( sliderRect );

    if ( d_data->hasTrough )
    {
        const int bw = d_data->borderWidth;
        innerRect = sliderRect.adjusted( bw, bw, -bw, -bw );

        painter->fillRect( innerRect, palette().brush( QPalette::Mid ) );
        qDrawShadePanel( painter, sliderRect, palette(), true, bw, NULL );
    }

    const QSize handleSize = qwtHandleSize( d_data->handleSize,
        d_data->orientation, d_data->hasTrough );

    if ( d_data->hasGroove )
    {
        const int slotExtent = 4;
        const int slotMargin = 4;

        QRect slotRect; 
        if ( orientation() == Qt::Horizontal )
        {
            int slotOffset = qMax( 1, handleSize.width() / 2 - slotMargin );
            int slotHeight = slotExtent + ( innerRect.height() % 2 );

            slotRect.setWidth( innerRect.width() - 2 * slotOffset );
            slotRect.setHeight( slotHeight );
        }
        else
        {
            int slotOffset = qMax( 1, handleSize.height() / 2 - slotMargin );
            int slotWidth = slotExtent + ( innerRect.width() % 2 );

            slotRect.setWidth( slotWidth );
            slotRect.setHeight( innerRect.height() - 2 * slotOffset );

        }

        slotRect.moveCenter( innerRect.center() );

        QBrush brush = palette().brush( QPalette::Dark );
        qDrawShadePanel( painter, slotRect, palette(), true, 1 , &brush );
    }

    if ( isValid() )
        drawHandle( painter, handleRect(), transform( value() ) );
}
Пример #7
0
/*!
   Draw the slider into the specified rectangle.

   \param painter Painter
   \param sliderRect Bounding rectangle of the slider
*/
void QwtSlider::drawSlider( 
    QPainter *painter, const QRect &sliderRect ) const
{
    QRect innerRect( sliderRect );

    if ( d_data->bgStyle & QwtSlider::Trough )
    {
        const int bw = d_data->borderWidth;

        qDrawShadePanel( painter, sliderRect, palette(), true, bw, NULL );

        innerRect = sliderRect.adjusted( bw, bw, -bw, -bw );
        painter->fillRect( innerRect, palette().brush( QPalette::Mid ) );
    }

    if ( d_data->bgStyle & QwtSlider::Groove )
    {
        int ws = 4;
        int ds = d_data->handleSize.width() / 2 - 4;
        if ( ds < 1 )
            ds = 1;

        QRect rSlot;
        if ( orientation() == Qt::Horizontal )
        {
            if ( innerRect.height() & 1 )
                ws++;

            rSlot = QRect( innerRect.x() + ds,
                    innerRect.y() + ( innerRect.height() - ws ) / 2,
                    innerRect.width() - 2 * ds, ws );
        }
        else
        {
            if ( innerRect.width() & 1 )
                ws++;

            rSlot = QRect( innerRect.x() + ( innerRect.width() - ws ) / 2,
                           innerRect.y() + ds,
                           ws, innerRect.height() - 2 * ds );
        }

        QBrush brush = palette().brush( QPalette::Dark );
        qDrawShadePanel( painter, rSlot, palette(), true, 1 , &brush );
    }

    if ( isValid() )
        drawHandle( painter, innerRect, transform( value() ) );
}
Пример #8
0
/*!
  Paint event handler
  \param event Paint event
*/
void QwtThermo::paintEvent( QPaintEvent *event )
{
    QPainter painter( this );
    painter.setClipRegion( event->region() );

    QStyleOption opt;
    opt.init(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);

    const QRect tRect = pipeRect();

    if ( !tRect.contains( event->rect() ) )
    {
        if ( d_data->scalePosition != QwtThermo::NoScale )
            scaleDraw()->draw( &painter, palette() );
    }

    const int bw = d_data->borderWidth;

    const QBrush brush = palette().brush( QPalette::Base );
    qDrawShadePanel( &painter, 
        tRect.adjusted( -bw, -bw, bw, bw ),
        palette(), true, bw, 
        d_data->autoFillPipe ? &brush : NULL );

    drawLiquid( &painter, tRect );
}
Пример #9
0
void QColorButton::paintEvent( QPaintEvent * event )
{
    QPainter painter( this );
    int x, y, w, h;
    QStyleOptionButton opt;
    opt.rect = event->rect();
    style()->drawControl(QStyle::CE_PushButtonBevel, &opt, &painter, this);
    QRect r = style()->subElementRect( QStyle::SE_PushButtonContents, &opt, this );
    r.getRect(&x, &y, &w, &h);

    //int margin = style()->pixelMetric( QStyle::PM_ButtonMargin, &opt, this );
    //x += margin;
    //y += margin;
    //w -= 2*margin;
    //h -= 2*margin;

    //if (isOn() || isDown()) {
    //  x += style()->pixelMetric( QStyle::PM_ButtonShiftHorizontal, &opt, this );
    //  y += style()->pixelMetric( QStyle::PM_ButtonShiftVertical, &opt, this );
    //}

    const QColor fillCol = isEnabled() ? col : palette().background().color();
    qDrawShadePanel( &painter, x, y, w, h, palette(), true, 1, NULL);
    if ( fillCol.isValid() )
        painter.fillRect( x+1, y+1, w-2, h-2, fillCol );

    //if ( hasFocus() ) {
    //  QRect focusRect = style()->subElementRect( QStyle::SE_PushButtonFocusRect, &opt, this );
    //  style()->drawPrimitive( QStyle::PE_FrameFocusRect, &opt, &painter, this );
    //}
}
Пример #10
0
/*!\reimp
  */
void QCDEStyle::drawIndicator( QPainter* p,
			       int x, int y, int w, int h, const QColorGroup &g,
			       int s, bool down, bool /* enabled */ )
{
    bool showUp = !down && s == QButton::Off;
    QBrush fill =  down ? g.brush( QColorGroup::Mid )   :
			  g.brush( QColorGroup::Button );
    qDrawShadePanel( p, x, y, w, h, g, !showUp, defaultFrameWidth(), &fill );

    if (s != QButton::Off) {
	QPointArray a( 7*2 );
	int i, xx, yy;
	xx = x+3;
	yy = y+5;
	for ( i=0; i<3; i++ ) {
	    a.setPoint( 2*i,   xx, yy );
	    a.setPoint( 2*i+1, xx, yy+2 );
	    xx++; yy++;
	}
	yy -= 2;
	for ( i=3; i<7; i++ ) {
	    a.setPoint( 2*i,   xx, yy );
	    a.setPoint( 2*i+1, xx, yy+2 );
	    xx++; yy--;
	}
	if ( s == QButton::NoChange )
	    p->setPen( g.dark() );
	else
	    p->setPen( g.foreground() );
	p->drawLineSegments( a );
    }
}
Пример #11
0
void KexiDBComboBox::paintEvent(QPaintEvent *)
{
    QPainter p(this);
    p.setPen(palette().color(QPalette::Text));
//    QColorGroup cg(palette().active());
// if ( hasFocus() )
//  cg.setColor(QColorGroup::Base, cg.highlight());
// else
    QPalette pal(palette());
    pal.setColor(QColorGroup::Base, paletteBackgroundColor()); //update base color using (reimplemented) bg color

    if (width() < 5 || height() < 5) {
        qDrawShadePanel(&p, rect(), pal, false /* !sunken */,
                        2 /*line width*/, &pal.brush(QPalette::Button)/*fill*/);
        return;
    }

#ifdef __GNUC__
#warning TODO KexiDBComboBox::paintEvent()
#else
#pragma WARNING( TODO KexiDBComboBox::paintEvent() )
#endif

    QStyleOptionComboBox option;
    option.palette = pal;
    option.initFrom(d->paintedCombo);

    if (isEnabled())
        option.state |= QStyle::State_Enabled;
    if (hasFocus())
        option.state |= QStyle::State_HasFocus;
    if (d->mouseOver)
        option.state |= QStyle::State_MouseOver;

    style()->drawComplexControl(QStyle::CC_ComboBox, &option, &p, d->paintedCombo);

#if 0 //TODO
//! @todo support reverse layout
//bool reverse = QApplication::reverseLayout();
    style()->drawComplexControl(QStyle::CC_ComboBox, &option, &p, d->paintedCombo  /*this*/
                                flags, (uint)QStyle::SC_All,
                                (d->buttonPressed ? QStyle::SC_ComboBoxArrow : QStyle::SC_None)
                               );

    if (d->isEditable) {
        //if editable, editor paints itself, nothing to do
    } else { //not editable: we need to paint the current item
        QRect editorGeometry(this->editorGeometry());
        if (hasFocus()) {
            if (0 == qstrcmp(style()->name(), "windows")) //a hack
                p.fillRect(editorGeometry, cg.brush(QColorGroup::Highlight));
            QRect r(QStyle::visualRect(style()->subRect(QStyle::SR_ComboBoxFocusRect, d->paintedCombo), this));
            r = QRect(r.left() - 1, r.top() - 1, r.width() + 2, r.height() + 2); //enlare by 1 pixel each side to avoid covering by the subwidget
            style()->drawPrimitive(QStyle::PE_FocusRect, &p,
                                   r, cg, flags | QStyle::Style_FocusAtBorder, QStyleOption(cg.highlight()));
        }
        //todo
    }
#endif
}
Пример #12
0
void qDrawShadePanel(QPainter *p, const QRect &r,
                      const QPalette &pal, bool sunken,
                      int lineWidth, const QBrush *fill)
{
    qDrawShadePanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
                     lineWidth, fill);
}
Пример #13
0
/*!
  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() );
        }
    }
}
Пример #14
0
void KviThemedLineEdit::paintEvent(QPaintEvent * event)
{
#ifdef COMPILE_PSEUDO_TRANSPARENCY
	QPainter * p = new QPainter(this);
	QPalette pal = palette();

	// In Qt5 QStyle::drawPrimitive seems to always overwrite the background, no matter what.
	qDrawShadePanel(p, 0, 0, width(), height(), palette(), true, 1, nullptr);

	QRect r(1, 1, width() - 2, height() - 2);

	if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing())
	{
		p->setCompositionMode(QPainter::CompositionMode_Source);
		QColor col = KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade);
		col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100));
		p->fillRect(r, col);
		p->restore();
	}
	else if(g_pShadedChildGlobalDesktopBackground)
	{
		QPoint pnt;
		if(m_pKviWindow)
			pnt = m_pKviWindow->isDocked() ? mapTo(g_pMainWindow, r.topLeft()) : mapTo(m_pKviWindow, r.topLeft());
		else
			pnt = mapToGlobal(event->rect().topLeft());
		p->drawTiledPixmap(r, *(g_pShadedChildGlobalDesktopBackground), pnt);
	}
	delete p;
#endif

	QLineEdit::paintEvent(event);
}
Пример #15
0
void KColorCells::paintCell( TQPainter *painter, int row, int col )
{
	TQBrush brush;
        int w = 1;

	if (shade)
        {
		qDrawShadePanel( painter, 1, 1, cellWidth()-2,
		    cellHeight()-2, colorGroup(), true, 1, &brush );
		w = 2;
        }
        TQColor color = colors[ row * numCols() + col ];
        if (!color.isValid())
	{
		if (!shade) return;
		color = backgroundColor();
	}

	painter->setPen( color );
	painter->setBrush( TQBrush( color ) );
	painter->drawRect( w, w, cellWidth()-w*2, cellHeight()-w*2 );

	if ( row * numCols() + col == selected )
		painter->drawWinFocusRect( w, w, cellWidth()-w*2, cellHeight()-w*2 );
}
Пример #16
0
void TupLuminancePicker::paintEvent(QPaintEvent *)
{
    int w = width() - 5;

    QRect r(0, foff, w, height() - 2*foff);
    int wi = r.width() - 2;
    int hi = r.height() - 2;
    if (!k->pix || k->pix->height() != hi || k->pix->width() != wi) {
        delete k->pix;
        QImage img(wi, hi, QImage::Format_RGB32);
        int y;
        for (y = 0; y < hi; y++) {
             QColor c;
             c.setHsv(k->hue, k->sat, y2val(y+coff));
             QRgb r = c.rgb();
             int x;
             for (x = 0; x < wi; x++)
                  img.setPixel(x, y, r);
        }
        k->pix = new QPixmap(QPixmap::fromImage(img));
    }

    QPainter p(this);
    p.drawPixmap(1, coff, *k->pix);
    const QPalette &g = palette();
    qDrawShadePanel(&p, r, g, true);
    p.setPen(g.foreground().color());
    p.setBrush(g.foreground());
    QPolygon a;
    int y = val2y(k->value);
    a.setPoints(3, w, y, w+5, y+5, w+5, y-5);
    p.eraseRect(w, 0, 5, height());
    p.drawPolygon(a);
}
Пример #17
0
void qDrawShadePanel( QPainter *p, const QRect &r,
		      const QColorGroup &g, bool sunken,
		      int lineWidth, const QBrush *fill )
{
    qDrawShadePanel( p, r.x(), r.y(), r.width(), r.height(), g, sunken,
		     lineWidth, fill );
}
//! Draw the whole QwtThermo.
void QwtThermo::draw(QPainter *p, const QRect& ur)
{
    if ( !d_data->thermoRect.contains(ur) )
    {
        if (d_data->scalePos != NoScale)
        {
#if QT_VERSION < 0x040000
            scaleDraw()->draw(p, colorGroup());
#else
            scaleDraw()->draw(p, palette());
#endif
        }

        qDrawShadePanel(p,
                        d_data->thermoRect.x() - d_data->borderWidth,
                        d_data->thermoRect.y() - d_data->borderWidth,
                        d_data->thermoRect.width() + 2*d_data->borderWidth,
                        d_data->thermoRect.height() + 2*d_data->borderWidth,
#if QT_VERSION < 0x040000
                        colorGroup(),
#else
                        palette(),
#endif
                        true, d_data->borderWidth,0);
    }
    drawThermo(p);
}
Пример #19
0
void QColorButton::paintEvent (QPaintEvent *p)
{
  QPushButton::paintEvent (p);
  QStyleOptionButton option;
  option.initFrom (this);

  int x, y, w, h;
  QRect r = style()->subElementRect (QStyle::SE_PushButtonContents, &option, this);
  r.getRect (&x, &y, &w, &h);

  int margin = style()->pixelMetric (QStyle::PM_ButtonMargin, &option, this);
  x += margin;
  y += margin;
  w -= 2*margin;
  h -= 2*margin;

  if (isChecked() || isDown()) {
    x += style()->pixelMetric (QStyle::PM_ButtonShiftHorizontal, &option, this );
    y += style()->pixelMetric (QStyle::PM_ButtonShiftVertical, &option, this );
  }

  QPainter painter (this);
  QColor fillCol = isEnabled() ? col : palette().brush(QPalette::Window).color();
  qDrawShadePanel (&painter, x, y, w, h, palette(), true, 1, NULL);
  if (fillCol.isValid())
    painter.fillRect (x+1, y+1, w-2, h-2, fillCol);

  if (hasFocus()) {
    style()->subElementRect (QStyle::SE_PushButtonFocusRect, &option, this);
    style()->drawPrimitive (QStyle::PE_FrameFocusRect, &option, &painter, this);
  }
}
Пример #20
0
void KColorButton::drawButtonLabel(QPainter *painter)
{
    int x, y, w, h;
    QRect r = style().subRect(QStyle::SR_PushButtonContents, this);
    r.rect(&x, &y, &w, &h);

    int margin = style().pixelMetric(QStyle::PM_ButtonMargin, this);
    x += margin;
    y += margin;
    w -= 2 * margin;
    h -= 2 * margin;

    if(isOn() || isDown())
    {
        x += style().pixelMetric(QStyle::PM_ButtonShiftHorizontal, this);
        y += style().pixelMetric(QStyle::PM_ButtonShiftVertical, this);
    }

    QColor fillCol = isEnabled() ? col : backgroundColor();
    qDrawShadePanel(painter, x, y, w, h, colorGroup(), true, 1, NULL);
    if(fillCol.isValid())
        painter->fillRect(x + 1, y + 1, w - 2, h - 2, fillCol);

    if(hasFocus())
    {
        QRect focusRect = style().subRect(QStyle::SR_PushButtonFocusRect, this);
        style().drawPrimitive(QStyle::PE_FocusRect, painter, focusRect, colorGroup());
    }
}
Пример #21
0
/*!
    \reimp
*/
void QCDEStyle::drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
                            const QWidget *widget) const
{

    switch (element) {
    case CE_MenuBarItem: {
        if (opt->state & State_Selected)  // active item
            qDrawShadePanel(p, opt->rect, opt->palette, true, 1,
                            &opt->palette.brush(QPalette::Button));
        else  // other item
            p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
        QCommonStyle::drawControl(element, opt, p, widget);
        break; }
    case CE_RubberBand: {
        p->save();
        p->setClipping(false);
        QPainterPath path;
        path.addRect(opt->rect);
        path.addRect(opt->rect.adjusted(2, 2, -2, -2));
        p->fillPath(path, opt->palette.color(QPalette::Active, QPalette::Text));
        p->restore();
        break; }
    default:
        QMotifStyle::drawControl(element, opt, p, widget);
    break;
    }
}
Пример #22
0
void KviThemedLabel::paintEvent(QPaintEvent *e)
{
#ifdef COMPILE_PSEUDO_TRANSPARENCY
	QPainter *p = new QPainter(this);

#if (QT_VERSION >= 0x050000)
	// In Qt5 QStyle::drawPrimitive seems to always overwrite the background, no matter what.
	qDrawShadePanel(p,0,0,width(),height(),palette(),true,1,NULL);

	QRect r(1,1,width()-1,height()-1);
#else
	QStyleOptionFrameV2 option;
	option.initFrom(this);

	style()->drawPrimitive(QStyle::PE_FrameLineEdit, &option, p, this);

	QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &option, this);

#endif

	if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing())
	{
		p->setCompositionMode(QPainter::CompositionMode_Source);
		QColor col=KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade);
		col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100));
		p->fillRect(r, col);
	} else if(g_pShadedChildGlobalDesktopBackground)
	{
		QPoint pnt = m_pKviWindow->isDocked() ? mapTo(g_pMainWindow, r.topLeft()) : mapTo(m_pKviWindow, r.topLeft());
		p->drawTiledPixmap(r,*(g_pShadedChildGlobalDesktopBackground), pnt);
	}
	delete p;
#endif
	QLabel::paintEvent(e);
}
Пример #23
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
}
Пример #24
0
void QProgressBar::drawContents( QPainter *p )
{
    const int unit_width  = 9;	    // includes 2 bg pixels
    const int unit_height = 12;
    const QRect bar = contentsRect();

    if ( style() == WindowsStyle ) {
	// Draw nu units out of a possible u of unit_width width, each
	// a rectangle bordered by background color, all in a sunken panel
	// with a percentage text display at the end.

	QFontMetrics fm = p->fontMetrics();
	int textw = fm.width("100%");
	int u = (bar.width() - textw - 2/*panel*/) / unit_width;
	int ox = ( bar.width() - (u*unit_width+textw) ) / 2;

	if (total_steps) { // Sanity check
	    // ### This part doesn't change as often as percentage does.
	    int nu = ( u * progress_val + total_steps/2 ) / total_steps;
	    int x = bar.x() + ox;
	    int uh = QMIN(bar.height()-4, unit_height);
	    int vm = (bar.height()-4 - uh)/2 + 2;
	    p->setPen(NoPen);
	    for (int i=0; i<nu; i++) {
		p->fillRect( x+2, bar.y()+vm,
			     unit_width-2, bar.height()-vm-vm,
			     QApplication::winStyleHighlightColor() );
		x += unit_width;
	    }
	}

	// ### This part doesn't actually change.
	const QRect r( ox + bar.x(), bar.y(), u*unit_width + 2, bar.height() );
	qDrawShadePanel( p, r, colorGroup(), TRUE, 1 );

	// ### This part changes every percentage change.
	p->setPen( colorGroup().text() );
	p->fillRect( r.x()+r.width(), bar.y(), textw, bar.height(),
	    backgroundColor() );
	p->drawText( r.x()+r.width(), bar.y(), textw, bar.height(),
	    AlignRight | AlignVCenter, progress_str );
    } else {
	if (total_steps) { // Sanity check
	    int pw = bar.width() * progress_val / total_steps;

	    p->setPen( colorGroup().base() );
	    p->setClipRect( bar.x(), bar.y(), pw, bar.height() );
	    p->fillRect( bar, QApplication::winStyleHighlightColor() );
	    p->drawText( bar, AlignCenter, progress_str );

	    p->setPen( QApplication::winStyleHighlightColor() );
	    p->setClipRect( bar.x()+pw, bar.y(), bar.width()-pw, bar.height() );
	}
	p->fillRect( bar, colorGroup().base() );
	p->setPen( colorGroup().text() );
	p->drawText( bar, AlignCenter, progress_str );
    }
}
Пример #25
0
/*!
  Draw the thumb at a position

  \param painter Painter
  \param sliderRect Bounding rectangle of the slider
  \param pos Position of the slider thumb
*/
void QwtSlider::drawHandle( QPainter *painter, 
    const QRect &sliderRect, int pos ) const
{
    const int bw = d_data->borderWidth;

    pos++; // shade line points one pixel below
    if ( orientation() == Qt::Horizontal )
    {
        QRect handleRect(
            pos - d_data->handleSize.width() / 2,
            sliderRect.y(), 
            d_data->handleSize.width(), 
            sliderRect.height()
        );

        qDrawShadePanel( painter, 
            handleRect, palette(), false, bw,
            &palette().brush( QPalette::Button ) );

        qDrawShadeLine( painter, pos, sliderRect.top() + bw,
            pos, sliderRect.bottom() - bw,
            palette(), true, 1 );
    }
    else // Vertical
    {
        QRect handleRect(
            sliderRect.left(), 
            pos - d_data->handleSize.height() / 2,
            sliderRect.width(), 
            d_data->handleSize.height()
        );

        qDrawShadePanel( painter, 
            handleRect, palette(), false, bw,
            &palette().brush( QPalette::Button ) );

        qDrawShadeLine( painter, sliderRect.left() + bw, pos,
            sliderRect.right() - bw, pos,
            palette(), true, 1 );
    }
}
void ColorButton::paintEvent(QPaintEvent *event)
{
  QToolButton::paintEvent(event);
  if (!isEnabled())
      return;

  QPainter painter(this);
  QBrush brush(_color);
  int m = (rect().height())/6;
  qDrawShadePanel(&painter, rect().x() + m, rect().y() + m, rect().width() - 2*m, rect().height() - 2*m,
                  palette(), /*sunken*/ isDown(), /*lineWidth*/ 1, /*fill*/ &brush);
}
void
QvisParallelCoordinatesWidget::redrawScene(QPainter *painter)
{
    double sceneWidth = (double)width();
    double sceneHeight = (double)height();
    double leftAxisX = sceneWidth * AXIS_LEFT_MARGIN;
    double axisSpacing = (sceneWidth*(1.0-AXIS_LEFT_MARGIN-AXIS_RIGHT_MARGIN)) /
        (double)(axisCount-1);
    double tickSpacing = (sceneHeight*(1.0-AXIS_BOTTOM_MARGIN-AXIS_TOP_MARGIN)) /
        (double)(TICKS_PER_AXIS+1);
    
    QBrush backgroundBrush(QColor(255,255,255));
    qDrawShadePanel(painter,
        0, 0, width(), height(), palette(), true, 2, &backgroundBrush);
        
    axisBottomY = (int)(sceneHeight*(1.0-AXIS_BOTTOM_MARGIN) + 0.5);
    axisTopY    = (int)(sceneHeight*AXIS_TOP_MARGIN + 0.5);
    
    axesXPos.clear();
    
    for (int axisNum = 0; axisNum < axisCount; axisNum++)
    {
        axesXPos.push_back((int)(leftAxisX + (double)axisNum*axisSpacing + 0.5));
    }
    
    ticksYPos.clear();
    
    for (int tickNum = 1; tickNum <= TICKS_PER_AXIS; tickNum++)
    {
        ticksYPos.push_back((int)(axisTopY + (double)tickNum*tickSpacing + 0.5));
    }
    
    double axisLen = (double)(axisBottomY - axisTopY);
    double dashAndGapLen = axisLen / ((double)DASHES_PER_AXIS - DASH_GAP_FRACTION);
    double dashTopYPos = (double)axisTopY;
    int dashLen = (int)(dashAndGapLen * (1.0-DASH_GAP_FRACTION));
        
    dashesTopYPos.clear(); dashesBotYPos.clear();
    
    for (int dashNum = 0; dashNum < DASHES_PER_AXIS; dashNum++)
    {
        dashesTopYPos.push_back((int)dashTopYPos);
        dashesBotYPos.push_back((int)dashTopYPos + dashLen);
        
        dashTopYPos += dashAndGapLen;
    }
    
    dashesBotYPos[DASHES_PER_AXIS-1] = axisBottomY;

    drawDataCurves(painter);
    drawAxes(painter);
    drawAxisTitles(painter);
}
Пример #28
0
/*! 
   Redraw panel and wheel
   \param painter Painter
*/
void QwtWheel::draw(QPainter *painter, const QRect&)
{
    qDrawShadePanel( painter, rect().x(), rect().y(),
        rect().width(), rect().height(),
#if QT_VERSION < 0x040000
        colorGroup(), 
#else
        palette(), 
#endif
        true, d_data->borderWidth );

    drawWheel( painter, d_data->sliderRect );

    if ( hasFocus() )
        QwtPainter::drawFocusRect(painter, this);
}
Пример #29
0
/*!
  Draw the whole QwtThermo.

  \param painter Painter
  \param rect Update rectangle
*/
void QwtThermo::draw( QPainter *painter, const QRect& rect )
{
    if ( !d_data->thermoRect.contains( rect ) )
    {
        if ( d_data->scalePos != NoScale )
            scaleDraw()->draw( painter, palette() );

        qDrawShadePanel( painter,
            d_data->thermoRect.x() - d_data->borderWidth,
            d_data->thermoRect.y() - d_data->borderWidth,
            d_data->thermoRect.width() + 2 * d_data->borderWidth,
            d_data->thermoRect.height() + 2 * d_data->borderWidth,
            palette(), true, d_data->borderWidth, 0 );
    }
    drawThermo( painter );
}
Пример #30
0
void KKeyButton::paint( QPainter *painter )
{
	QPointArray a( 4 );
	a.setPoint( 0, 0, 0) ;
	a.setPoint( 1, width(), 0 );
	a.setPoint( 2, 0, height() );
	a.setPoint( 3, 0, 0 );

	QRegion r1( a );
	painter->setClipRegion( r1 );
	painter->setBrush( backgroundColor().light() );
	painter->drawRoundRect( 0, 0, width(), height(), 20, 20);

	a.setPoint( 0, width(), height() );
	a.setPoint( 1, width(), 0 );
	a.setPoint( 2, 0, height() );
	a.setPoint( 3, width(), height() );

	QRegion r2( a );
	painter->setClipRegion( r2 );
	painter->setBrush( backgroundColor().dark() );
	painter->drawRoundRect( 0, 0, width(), height(), 20, 20 );

	painter->setClipping( FALSE );
	if( width() > 12 && height() > 8 )
	qDrawShadePanel( painter, 6, 4, width() - 12, height() - 8, 
								colorGroup(), TRUE, 1, 0L );
	if ( editing ) {
		painter->setPen( colorGroup().base() );
		painter->setBrush( colorGroup().base() );
	} else {
		painter->setPen( backgroundColor() );
		painter->setBrush( backgroundColor() );
	}
	if( width() > 14 && height() > 10 )
	painter->drawRect( 7, 5, width() - 14, height() - 10 ); 

	drawButtonLabel( painter );
	
	painter->setPen( colorGroup().text() );
	painter->setBrush( NoBrush );
	if( hasFocus() || editing ) {
		if( width() > 16 && height() > 12 )
		painter->drawRect( 8, 6, width() - 16, height() - 12 );
	}	
}