static void test_surface(SkCanvas* canvas, SkSurface* surf) { drawContents(surf, SK_ColorRED); SkImage* imgR = surf->newImageSnapshot(); if (true) { SkImage* imgR2 = surf->newImageSnapshot(); SkASSERT(imgR == imgR2); imgR2->unref(); } drawContents(surf, SK_ColorGREEN); SkImage* imgG = surf->newImageSnapshot(); // since we've drawn after we snapped imgR, imgG will be a different obj SkASSERT(imgR != imgG); drawContents(surf, SK_ColorBLUE); SkPaint paint; // paint.setFilterBitmap(true); // paint.setAlpha(0x80); imgR->draw(canvas, 0, 0, &paint); imgG->draw(canvas, 0, 80, &paint); surf->draw(canvas, 0, 160, &paint); imgG->unref(); imgR->unref(); }
void KexiToolTip::paintEvent(QPaintEvent *pev) { QWidget::paintEvent(pev); QPainter p(this); drawFrame(p); drawContents(p); }
void KSelector::paintEvent( QPaintEvent * ) { QPainter painter; int w = style()->pixelMetric( QStyle::PM_DefaultFrameWidth ); int iw = (w < ARROWSIZE) ? ARROWSIZE : w; painter.begin( this ); drawContents( &painter ); QBrush brush; QPoint pos = calcArrowPos( value() ); drawArrow( &painter, pos ); if ( indent() ) { QStyleOptionFrame opt; opt.initFrom( this ); opt.state = QStyle::State_Sunken; if ( orientation() == Qt::Vertical ) opt.rect.adjust( 0, iw - w, -5, w - iw ); else opt.rect.adjust(iw - w, 0, w - iw, -5); style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, this ); } painter.end(); }
void PrettyPopupMenu::paintEvent( QPaintEvent* e ) { generateSidePixmap(); QPainter p( this ); QRect r = sideImageRect(); r.setTop( r.bottom() - s_sidePixmap.height() ); if ( r.intersects( e->rect() ) ) { QRect drawRect = r.intersect( e->rect() ).intersect( sideImageRect() ); QRect pixRect = drawRect; pixRect.moveBy( -r.left(), -r.top() ); p.drawImage( drawRect.topLeft(), s_sidePixmap, pixRect ); } p.setClipRegion( e->region() ); //NOTE The order is important here. drawContents() must be called before drawPrimitive(), // otherwise we get rendering glitches. drawContents( &p ); style().drawPrimitive( QStyle::PE_PanelPopup, &p, QRect( 0, 0, width(), height() ), colorGroup(), QStyle::Style_Default, QStyleOption( frameWidth(), 0 ) ); }
void CelSplashScreen::drawContents() { QPixmap textPix = pixmap; QPainter painter( &textPix, this ); drawContents( &painter ); setErasePixmap( textPix ); }
void PanelKMenu::paintEvent(QPaintEvent * e) { if (sidePixmap.isNull()) { PanelServiceMenu::paintEvent(e); return; } QPainter p(this); p.setClipRegion(e->region()); style().drawPrimitive( QStyle::PE_PanelPopup, &p, QRect( 0, 0, width(), height() ), colorGroup(), QStyle::Style_Default, QStyleOption( frameWidth(), 0 ) ); QRect r = sideImageRect(); r.setBottom( r.bottom() - sidePixmap.height() ); if ( r.intersects( e->rect() ) ) { p.drawTiledPixmap( r, sideTilePixmap ); } r = sideImageRect(); r.setTop( r.bottom() - sidePixmap.height() ); if ( r.intersects( e->rect() ) ) { QRect drawRect = r.intersect( e->rect() ); QRect pixRect = drawRect; pixRect.moveBy( -r.left(), -r.top() ); p.drawPixmap( drawRect.topLeft(), sidePixmap, pixRect ); } drawContents( &p ); }
void DataGrapher::paintEvent(QPaintEvent *event) { QFrame::paintEvent(event); QPainter painter(this); painter.setClipRect(contentsRect()); drawContents(&painter); }
static void test_surface(SkCanvas* canvas, SkSurface* surf, bool usePaint) { drawContents(surf, SK_ColorRED); SkImage* imgR = surf->newImageSnapshot(); if (true) { SkImage* imgR2 = surf->newImageSnapshot(); SkASSERT(imgR == imgR2); imgR2->unref(); } drawContents(surf, SK_ColorGREEN); SkImage* imgG = surf->newImageSnapshot(); // since we've drawn after we snapped imgR, imgG will be a different obj SkASSERT(imgR != imgG); drawContents(surf, SK_ColorBLUE); SkPaint paint; // paint.setFilterBitmap(true); // paint.setAlpha(0x80); canvas->drawImage(imgR, 0, 0, usePaint ? &paint : NULL); canvas->drawImage(imgG, 0, 80, usePaint ? &paint : NULL); surf->draw(canvas, 0, 160, usePaint ? &paint : NULL); SkRect src1, src2, src3; src1.iset(0, 0, surf->width(), surf->height()); src2.iset(-surf->width() / 2, -surf->height() / 2, surf->width(), surf->height()); src3.iset(0, 0, surf->width() / 2, surf->height() / 2); SkRect dst1, dst2, dst3, dst4; dst1.set(0, 240, 65, 305); dst2.set(0, 320, 65, 385); dst3.set(0, 400, 65, 465); dst4.set(0, 480, 65, 545); canvas->drawImageRect(imgR, &src1, dst1, usePaint ? &paint : NULL); canvas->drawImageRect(imgG, &src2, dst2, usePaint ? &paint : NULL); canvas->drawImageRect(imgR, &src3, dst3, usePaint ? &paint : NULL); canvas->drawImageRect(imgG, NULL, dst4, usePaint ? &paint : NULL); imgG->unref(); imgR->unref(); }
void arnMulVectorPlot::paintEvent(QPaintEvent *event) { QFrame::paintEvent(event); QPainter painter(this); painter.setClipRect(contentsRect()); drawContents(&painter); }
void Screen::drawAll() { glClearColor(mBackground[0],mBackground[1],mBackground[2],1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); drawContents(); drawWidgets(); glfwSwapBuffers(mGLFWWindow); }
/*! \reimp */ bool QSplashScreen::event(QEvent *e) { if (e->type() == QEvent::Paint) { Q_D(QSplashScreen); QPainter painter(this); if (!d->pixmap.isNull()) painter.drawPixmap(QPoint(), d->pixmap); drawContents(&painter); } return QWidget::event(e); }
void QScope::refresh(timeref_t t) { if (t) { qss.endtime = t; nspikes = 0; } QPainter qp(this); erase(contentsRect()); drawContents(&qp); //drawContents_box(&qp); forall(&QScope::refresh,t); // for satellites i think }
void QGroupBox::paintEvent( QPaintEvent *event ) { QPainter paint( this ); if ( lenvisible && !isCheckable() ) { // draw title QFontMetrics fm = paint.fontMetrics(); int h = fm.height(); int tw = fm.width( str, lenvisible ) + fm.width(QChar(' ')); int x; int marg = bFlat ? 0 : 8; if ( align & AlignHCenter ) // center alignment x = frameRect().width()/2 - tw/2; else if ( align & AlignRight ) // right alignment x = frameRect().width() - tw - marg; else if ( align & AlignLeft ) // left alignment x = marg; else { // auto align if( QApplication::reverseLayout() ) x = frameRect().width() - tw - marg; else x = marg; } QRect r( x, 0, tw, h ); int va = style().styleHint(QStyle::SH_GroupBox_TextLabelVerticalAlignment, this); if(va & AlignTop) r.moveBy(0, fm.descent()); QColor pen( (QRgb) style().styleHint(QStyle::SH_GroupBox_TextLabelColor, this ) ); if (!style().styleHint(QStyle::SH_UnderlineAccelerator, this)) va |= NoAccel; style().drawItem( &paint, r, ShowPrefix | AlignHCenter | va, colorGroup(), isEnabled(), 0, str, -1, ownPalette() ? 0 : &pen ); paint.setClipRegion( event->region().subtract( r ) ); // clip everything but title #ifndef QT_NO_CHECKBOX } else if ( d->checkbox ) { QRect cbClip = d->checkbox->geometry(); QFontMetrics fm = paint.fontMetrics(); cbClip.setX( cbClip.x() - fm.width(QChar(' ')) ); cbClip.setWidth( cbClip.width() + fm.width(QChar(' ')) ); paint.setClipRegion( event->region().subtract( cbClip ) ); #endif } if ( bFlat ) { QRect fr = frameRect(); QPoint p1( fr.x(), fr.y() + 1 ); QPoint p2( fr.x() + fr.width(), p1.y() ); // ### This should probably be a style primitive. qDrawShadeLine( &paint, p1, p2, colorGroup(), TRUE, lineWidth(), midLineWidth() ); } else { drawFrame(&paint); } drawContents( &paint ); // draw the contents }
/*! Paints the frame (or part of the frame) that's necessary, depending on the \a event. */ void Q3Frame::paintEvent(QPaintEvent * event) { QPainter paint(this); if (!contentsRect().contains(event->rect())) { paint.save(); paint.setClipRegion(event->region().intersected(frameRect())); drawFrame(&paint); paint.restore(); } if (event->rect().intersects(contentsRect())) { paint.setClipRegion(event->region().intersected(contentsRect())); drawContents(&paint); } }
void KColorPatch::setColor( const TQColor &col ) { if ( colContext ) TQColor::destroyAllocContext( colContext ); colContext = TQColor::enterAllocContext(); color.setRgb( col.rgb() ); color.alloc(); TQColor::leaveAllocContext(); TQPainter painter; painter.begin( this ); drawContents( &painter ); painter.end(); }
void KXYSelector::paintEvent( QPaintEvent * /* ev */ ) { QStyleOptionFrame opt; opt.initFrom(this); QPainter painter; painter.begin( this ); drawContents( &painter ); drawMarker( &painter, d->px, d->py ); style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, this ); painter.end(); }
/*! Qt paint event \param event Paint event */ void QwtTextLabel::paintEvent( QPaintEvent *event ) { QPainter painter( this ); if ( !contentsRect().contains( event->rect() ) ) { painter.save(); painter.setClipRegion( event->region() & frameRect() ); drawFrame( &painter ); painter.restore(); } painter.setClipRegion( event->region() & contentsRect() ); drawContents( &painter ); }
void KURLLabel::paintEvent(QPaintEvent*) { // Mirko Sucker, 1998/11/16: QPen pen; QPainter paint(this); // ----- if(m_transparent && parentWidget()!=0) { QPixmap bg(width(), height()); // ----- bg.fill(parentWidget(), mapToParent(QPoint(0, 0))); paint.drawPixmap(0, 0, bg); } drawFrame(&paint); drawContents(&paint); paint.end(); }
void QFrame::paintEvent( QPaintEvent *event ) { QPainter paint( this ); if ( !contentsRect().contains( event->rect() ) ) { paint.save(); paint.setClipRegion( event->region().intersect(frameRect()) ); drawFrame( &paint ); paint.restore(); } if ( event->rect().intersects( contentsRect() ) && (fstyle & MShape) != HLine && (fstyle & MShape) != VLine ) { paint.setClipRegion( event->region().intersect( contentsRect() ) ); drawContents( &paint ); } }
//! Repaint the dial void QwtDial::paintEvent(QPaintEvent *e) { const QRect &ur = e->rect(); if ( ur.isValid() ) { QwtPaintBuffer paintBuffer(this, ur); QPainter *painter = paintBuffer.painter(); drawContents(painter); drawFrame(painter); if ( hasFocus() ) drawFocusIndicator(painter); } }
void GL3DShaderWidget::paintGL() { // If it's not yet visible don't try and draw (you can upset OpenGL on some systems if you do) if(!isVisible()) return; CG_GL_ERROR_CHECK // Make sure this OpenGL context is current #ifdef GLCONTEXT_DEBUG fprintf(stderr, "Making current (%s:%d)\n", __FILE__, __LINE__); fflush(stderr); #endif makeGLContextCurrent(); CG_GL_ERROR_CHECK // Clear the buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); CG_GL_ERROR_CHECK // Allow special processing before drawContents() (implement in child) // Note: buffer clears before but not after, shader is not bound if(mShader != NULL) mShader->release(); CG_GL_ERROR_CHECK prePaint(); CG_GL_ERROR_CHECK // Bind the shader and draw the maincontents if(mShader != NULL) mShader->bind(); else glColor4f(0.0, 0.0, 0.0, 1.0); drawContents(); CG_GL_ERROR_CHECK // Allow special procesing after drawContents() but before buffer swap (implement in child) // Note: shader is not bound if(mShader != NULL) mShader->release(); postPaintPreSwap(); CG_GL_ERROR_CHECK // Swap back and front buffers // NO! Qt does this automatically and doing it manually will cause a // double swap on some OSs and seisure inducing flashing. // swapBuffers(); }
void Window::draw(Renderer2D &out) const { out.setViewPos(-m_clipped_rect.min); out.setScissorRect(m_clipped_rect); if(m_background_color.a > 0.0f && !(m_background && m_background->size() == m_rect.size())) out.addFilledRect(IRect(m_clipped_rect.size()), m_background_color); if(m_background) out.addFilledRect(IRect(m_background->size()), m_background); drawContents(out); out.setViewPos(-m_clipped_rect.min); if(m_has_inner_rect) { int2 rsize = m_rect.size(); int2 isize = m_inner_rect.size(); auto col1 = WindowStyle::gui_dark; auto col2 = WindowStyle::gui_light; col1 = FColor(col1.rgb() * 0.8f, 0.5f); col2 = FColor(col2.rgb() * 1.333f, 0.5f); // TODO: minimum size of progress bar, coz sometimes its almost invisible if(isize.x > rsize.x) { float divisor = 1.0f / float(isize.x); float spos = float(0 - m_inner_rect.min.x) * divisor; float epos = float(rsize.x - m_inner_rect.min.x) * divisor; out.addFilledRect(IRect(0, rsize.y - 5, rsize.x, rsize.y), col1); out.addFilledRect(IRect(spos * rsize.x, rsize.y - 5, (spos + epos) * rsize.x, rsize.y), col2); } if(isize.y > rsize.y) { float divisor = 1.0f / float(isize.y); float spos = float(0 - m_inner_rect.min.y) * divisor; float epos = float(rsize.y - m_inner_rect.min.y) * divisor; out.addFilledRect(IRect(rsize.x - 5, 0, rsize.x, rsize.y), col1); out.addFilledRect(IRect(rsize.x - 5, spos * rsize.y, rsize.x, epos * rsize.y), col2); } } for(int n = 0; n < (int)m_children.size(); n++) if(m_children[n]->isVisible()) m_children[n]->draw(out); if(!m_parent) out.setScissorRect(none); }
/*! Paint event \param event Paint event */ void QwtPlotCanvas::paintEvent( QPaintEvent *event ) { QPainter painter( this ); if ( !contentsRect().contains( event->rect() ) ) { painter.save(); painter.setClipRegion( event->region() & frameRect() ); drawFrame( &painter ); painter.restore(); } painter.setClipRegion( event->region() & contentsRect() ); drawContents( &painter ); if ( d_data->paintAttributes & PaintPacked ) setSystemBackground( false ); }
//! Paint event void QwtPolarCanvas::paintEvent( QPaintEvent *event ) { #if QT_VERSION >= 0x040000 QPainter painter( this ); if ( !contentsRect().contains( event->rect() ) ) { painter.save(); painter.setClipRegion( event->region() & frameRect() ); drawFrame( &painter ); painter.restore(); } painter.setClipRegion( event->region() & contentsRect() ); drawContents( &painter ); #else // QT_VERSION < 0x040000 QFrame::paintEvent( event ); #endif }
void TabPanel::drawInternal(Graphics* const TheGraphics, Real32 Opacity) const { //Draw Inactive tabs for (UInt32 i = 0; i < getMFTabs()->size(); ++i) { if(i != getSelectedIndex()) { drawTab(i,TheGraphics, Opacity); } } //Draw Active Content drawContents(TheGraphics, Opacity); //Draw Active Tab if(getSelectedIndex() != -1) { setupClipping(TheGraphics); drawTab(getSelectedIndex(),TheGraphics, Opacity); } }
//! Paint event void QwtLegendLabel::paintEvent( QPaintEvent *e ) { const QRect cr = contentsRect(); QPainter painter( this ); painter.setClipRegion( e->region() ); if ( d_data->isDown ) { qDrawWinButton( &painter, 0, 0, width(), height(), palette(), true ); } painter.save(); if ( d_data->isDown ) { const QSize shiftSize = buttonShift( this ); painter.translate( shiftSize.width(), shiftSize.height() ); } painter.setClipRect( cr ); drawContents( &painter ); if ( !d_data->icon.isNull() ) { QRect iconRect = cr; iconRect.setX( iconRect.x() + margin() ); if ( d_data->itemMode != QwtLegendData::ReadOnly ) iconRect.setX( iconRect.x() + ButtonFrame ); iconRect.setSize( d_data->icon.size() ); iconRect.moveCenter( QPoint( iconRect.center().x(), cr.center().y() ) ); painter.drawPixmap( iconRect, d_data->icon ); } painter.restore(); }
void TupGradientSelector::paintEvent(QPaintEvent *) { QPainter painter; QBrush brush; painter.begin(this); drawContents(&painter); for (int i = 0; i < m_arrows.count(); i++) { painter.setBrush(m_arrows[i]->color()); if (i == m_currentArrowIndex) painter.setPen(QPen(palette().highlight(), 1)); else painter.setPen(Qt::gray); painter.drawPath(m_arrows[i]->form()); } painter.end(); }
/*! Paint the dial \param event Paint event */ void QwtDial::paintEvent( QPaintEvent *event ) { QPainter painter( this ); painter.setClipRegion( event->region() ); QStyleOption opt; opt.init(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); painter.setRenderHint( QPainter::Antialiasing, true ); painter.save(); drawContents( &painter ); painter.restore(); painter.save(); drawFrame( &painter ); painter.restore(); if ( hasFocus() ) drawFocusIndicator( &painter ); }
void QFrame::paintEvent( QPaintEvent *event ) { const int m = margin(); if ( m && testWFlags( WNoAutoErase ) ) { QRect r = contentsRect(); r.addCoords( -m, -m, m, m ); erase( event->region().intersect( QRegion( r ) - contentsRect() ) ); } QPainter paint( this ); if ( !contentsRect().contains( event->rect() ) ) { paint.save(); paint.setClipRegion( event->region().intersect(frameRect()) ); drawFrame( &paint ); paint.restore(); } if ( event->rect().intersects( contentsRect() ) && (fstyle & MShape) != HLine && (fstyle & MShape) != VLine ) { paint.setClipRegion( event->region().intersect( contentsRect() ) ); drawContents( &paint ); } }
void KdmItem::paint(QPainter *p, const QRect &rect, bool background, bool primaryScreen) { if (!isVisible()) return; if (background && (p->device()->width() < m_minScrWidth || p->device()->height() < m_minScrHeight)) return; if (myWidget) return; QRect contentsRect = area.intersected(rect); if (!contentsRect.isEmpty() && (!background || isBackground) && (paintOnScreen == ScrAll || ((paintOnScreen == ScrGreeter) == primaryScreen))) { drawContents(p, contentsRect); if (debugLevel & DEBUG_THEMING) { // Draw bounding rect for this item QPen pen(Qt::white); pen.setCapStyle(Qt::FlatCap); pen.setDashPattern(QVector<qreal>() << 5 << 6); p->setPen(pen); p->setBackgroundMode(Qt::OpaqueMode); p->setBackground(Qt::black); p->drawRect(area.x(), area.y(), area.width() - 1, area.height() - 1); p->setBackgroundMode(Qt::TransparentMode); } } // Dispatch paint events to children forEachChild (itm) itm->paint(p, rect, background, primaryScreen); }