KGridView::KGridView(QImage *image, QWidget *parent, const char *name) : QFrame(parent, name) { pprops = 0L; _corner = 0L; _hruler = _vruler = 0L; _grid = 0L; acceptdrop = false; pprops = props(this); viewport = new QScrollView(this); CHECK_PTR(viewport); _grid = new KIconEditGrid(image, viewport->viewport()); CHECK_PTR(_grid); viewport->addChild(_grid); if(pprops->backgroundmode == FixedPixmap) { QPixmap pix(pprops->backgroundpixmap.data()); if(pix.isNull()) { QPixmap pmlogo((const char**)logo); pix = pmlogo; } viewport->viewport()->setBackgroundPixmap(pix); _grid->setBackgroundPixmap(pix); } else { viewport->viewport()->setBackgroundColor(pprops->backgroundcolor); } _corner = new QFrame(this); _corner->setFrameStyle(QFrame::WinPanel | QFrame::Raised); _hruler = new KRuler(KRuler::horizontal, this); _hruler->setEndLabel(i18n("width")); _hruler->setOffset( 0 ); _hruler->setRange(0, 1000); _vruler = new KRuler(KRuler::vertical, this); _vruler->setEndLabel(i18n("height")); _vruler->setOffset( 0 ); _vruler->setRange(0, 1000); connect(_grid, SIGNAL(scalingchanged(int, bool)), SLOT(scalingChange(int, bool))); connect(_grid, SIGNAL(sizechanged(int, int)), SLOT(sizeChange(int, int))); connect(_grid, SIGNAL(needPainting()), SLOT(paintGrid())); connect( _grid, SIGNAL(xposchanged(int)), _hruler, SLOT(slotNewValue(int)) ); connect( _grid, SIGNAL(yposchanged(int)), _vruler, SLOT(slotNewValue(int)) ); connect(viewport, SIGNAL(contentsMoving(int, int)), SLOT(moving(int, int))); setSizes(); QResizeEvent e(size(), size()); resizeEvent(&e); }
void MaskStriple::paintEvent(QPaintEvent *pe) { QPainter painter; painter.begin(this); painter.fillRect(workplace, Qt::white); painter.end(); if(_paintGrid) paintGrid(); paintMask(); pe->accept(); }
void paint (Graphics& g) { Rectangle <int> const r = getLocalBounds (); g.setColour (Colours::white); g.fillRect (r); g.setColour (Colours::black); g.drawRect (r); paintGrid (g); paintControlPoints (g); }
void KWCanvasBase::paint(QPainter &painter, const QRectF &paintRect) { painter.translate(-m_documentOffset); static int iteration = 0; iteration++; if (m_viewMode->hasPages()) { int pageContentArea = 0; if (!m_cacheEnabled || !m_pageCacheManager) { // no caching, simple case QList<KWViewMode::ViewMap> map = m_viewMode->mapExposedRects(paintRect.translated(m_documentOffset), viewConverter()); foreach (KWViewMode::ViewMap vm, map) { painter.save(); // Set up the painter to clip the part of the canvas that contains the rect. painter.translate(vm.distance.x(), vm.distance.y()); vm.clipRect = vm.clipRect.adjusted(-1, -1, 1, 1); painter.setClipRect(vm.clipRect); // Paint the background of the page. QColor color = Qt::white; #ifdef DEBUG_REPAINT color = QColor(random() % 255, random() % 255, random() % 255); #endif painter.fillRect(vm.clipRect, QBrush(color)); // Paint the contents of the page. painter.setRenderHint(QPainter::Antialiasing); m_shapeManager->paint(painter, *(viewConverter()), false); // Paint all shapes paintBorder(painter, vm); // Paint the page decorations: shadow, etc. paintPageDecorations(painter, vm); // Paint the grid paintGrid(painter, vm); // paint whatever the tool wants to paint m_toolProxy->paint(painter, *(viewConverter())); painter.restore(); int contentArea = vm.clipRect.width() * vm.clipRect.height(); if (contentArea > pageContentArea) { pageContentArea = contentArea; } }
void XYChartCore::paint(QPainter* painter) { painter->setRenderHint(QPainter::Antialiasing, true); painter->setFont(m_labelFont); QPen pen(m_textColor); pen.setWidthF(m_lineWidth); painter->setPen(pen); if (m_gridLines) paintGrid(painter); paintAxis(painter); paintTicks(painter); paintAxisLabels(painter); paintDimensionLabels(painter); }
void CanvasRenderer::paint( Object* object, int layer, int frame, QRect rect ) { Q_ASSERT( object ); mObject = object; mLayerIndex = layer; mFrameNumber = frame; QPainter painter( mCanvas ); painter.setWorldTransform( mViewTransform ); painter.setRenderHint( QPainter::SmoothPixmapTransform, mOptions.bAntiAlias ); painter.setRenderHint( QPainter::Antialiasing, true ); // Don't set clip rect, paint whole canvas. //painter.setClipRect( rect ); //painter.setClipping( true ); painter.setWorldMatrixEnabled( true ); paintBackground( painter ); paintOnionSkin( painter ); paintCurrentFrame( painter ); paintCameraBorder( painter ); // post effects if ( mOptions.bAxis ) { paintAxis( painter ); } if ( mOptions.bGrid ) { paintGrid( painter ); } }
void VisItSimStripChart::paintEvent( QPaintEvent * ) { int i =0; float h = height(); float w = width(); QPen penLimits; QPainter paint( this ); gridFont->setPointSize(pointSize); paint.scale(1.0,zoom); if ( center ) { paint.translate( 0,points.back().y()); center = false; } // start drawing the data n times step away from the right // hand edge of the window. timeShift = int(w - ( (delta/2.0) * points.size())); // do we have data to draw and are we enabled? if ( points.empty()) return; if ( !enabled ) return; // display the grid paintGrid( &paint); VisItPointD startOffset(points.front().x(),0); Points::iterator it; // connect all points together to make the graph for( it = points.begin(); it != points.end(); ) { // Set the pen width and color penLimits.setWidth(2); // set pen color to normal penLimits.setColor(Qt::darkGreen); VisItPointD startPoint(0,0); startPoint.setX( (*it).x() - startOffset.x()); startPoint.setY( (*it).y() - startOffset.y()); it++; if ( it == points.end()) break; VisItPointD endPoint(0,0); endPoint.setX((*it).x() - startOffset.x());; endPoint.setY((*it).y() - startOffset.y());; // check to see if it is out of limit if ( outOfBandLimitsEnabled ) { if ( startPoint.y() > maxYLimit || startPoint.y() < minYLimit || endPoint.y() > maxYLimit || endPoint.y() < minYLimit ) { // set pen color to out of limits penLimits.setColor(Qt::red); } } paint.setPen( penLimits ); QPoint startPoint_int; QPoint endPoint_int; // convert to screen space startPoint_int.setX ( int(startPoint.x()*delta +timeShift)); startPoint_int.setY ( int ((h-((startPoint.y()-minPoint)*vdelta)))); endPoint_int.setX ( int(endPoint.x()*delta + timeShift)); endPoint_int.setY ( int((h-((endPoint.y()-minPoint)*vdelta)) )); currentScaledY = ((h-((endPoint.y()-minPoint)*vdelta)) ); paint.drawLine( startPoint_int, endPoint_int ); // draw line i++; if ( i%10 == 0 ) { paint.drawText( startPoint_int.x(),int(h-10), QString::number((*it).x())); paint.drawText( startPoint_int.x(),int(middle*vdelta), QString::number((*it).x())); paint.drawText( startPoint_int.x(),int(10), QString::number((*it).x())); } // draw limit extents if ( outOfBandLimitsEnabled ) { penLimits.setColor(Qt::red); penLimits.setWidth(3); paint.setPen( penLimits ); paint.drawLine( QPoint(int(0),int(h-((maxYLimit)-minPoint)*vdelta)), QPoint(int(w),int(h-((maxYLimit-minPoint)*vdelta)))); // draw line paint.drawLine( QPoint(int(0),int(h-((minYLimit)-minPoint)*vdelta)), QPoint(int(w),int(h-((minYLimit)-minPoint)*vdelta))); // draw line } } }
void GOLWidget::paintEvent(QPaintEvent *) { QPainter p(this); paintGrid(p); paintCells(p); }
void gameW::paintEvent(QPaintEvent *) { QPainter painter(this); paintGrid(painter); paintGeneration(painter); }
void lifeWidget::paintEvent(QPaintEvent *) { QPainter p(this); paintGrid(p); paintUniverse(p); }
void QSlide::paintEvent(QPaintEvent *) { paintBorder(); paintText(); paintGrid(); }
void EnvelopeEditorControl::paint(PPGraphicsAbstract* g) { if (!isVisible()) return; pp_int32 xOffset = 2; pp_int32 yOffset = 2; g->setRect(location.x, location.y, location.x + size.width, location.y + size.height); g->setColor(backgroundColor); g->fill(); if (border) { drawBorder(g, *borderColor); } g->setRect(location.x+1, location.y+1, location.x+1 + size.width-2, location.y+1 + size.height-2); g->setColor(255, 255, 255); if (envelope == NULL) { PPFont* font = PPFont::getFont(PPFont::FONT_SYSTEM); g->setFont(font); PPString s("None selected"); g->drawString(s, location.x + size.width / 2 - font->getStrWidth(s) / 2, location.y + size.height / 2 - font->getCharHeight() / 2); return; } float scaley = calcYScale(); float scalex = calcXScale(); pp_int32 i; paintGrid(g, xOffset, yOffset); g->setColor(255, 255, 255); // vertical for (i = 0; i <= yMax; i++) { if (!(i & 15)) { pp_int32 y1 = (pp_int32)(i*scaley); y1 = location.y + yOffset + visibleHeight - y1; g->setPixel(location.x + xOffset, y1); if (!(i&31)) { g->setPixel(location.x + xOffset-1, y1); } } } /*// horizontal for (i = 0; i <= visibleWidth; i++) { pp_int32 i2 = i + startPos; pp_int32 x1 = i; pp_int32 x = x1 + location.x + xOffset; pp_int32 y1 = location.y + yOffset + visibleHeight - (pp_int32)(128*scaley); if (!(i2 & 3)) { g->setPixel(x, location.y + yOffset + visibleHeight); if (!(i2&31)) { g->setPixel(x, location.y + yOffset + visibleHeight + 1); } } }*/ // centered line for (i = 0; i <= visibleWidth; i++) { pp_int32 x1 = i; pp_int32 x = x1 + location.x + xOffset; pp_int32 y1 = location.y + yOffset + visibleHeight - (pp_int32)(128*scaley); if (showVCenter) { if (!(i&7)) g->setColor(128, 128, 128); else g->setColor(64, 64, 64); g->setPixel(x, y1); } } g->setColor(255, 255, 128); if (!envelope->num) { PPFont* font = PPFont::getFont(PPFont::FONT_SYSTEM); g->setFont(font); PPString s("No envelope"); g->drawString(s, location.x + size.width / 2 - font->getStrWidth(s) / 2, location.y + size.height / 2 - font->getCharHeight()); } for (i = 0; i < envelope->num - 1; i++) { pp_int32 x1 = (pp_int32)(envelope->env[i][0]*scalex); pp_int32 y1 = (pp_int32)(envelope->env[i][1]*scaley); pp_int32 x2 = (pp_int32)(envelope->env[i+1][0]*scalex); pp_int32 y2 = (pp_int32)(envelope->env[i+1][1]*scaley); x1+=location.x + xOffset - startPos; x2+=location.x + xOffset - startPos; y1 = location.y + yOffset + visibleHeight - y1; y2 = location.y + yOffset + visibleHeight - y2; g->drawAntialiasedLine(x1,y1,x2,y2); //g->drawLine(x1,y1,x2,y2); //g->setPixel(location.x + xOffset + x, location.y + yOffset + size.height - 4 - y); } // Showmarks g->setColor(255, 0, 255); for (pp_int32 sm = 0; sm < TrackerConfig::maximumPlayerChannels; sm++) { pp_int32 showMark = showMarks[sm].pos; if (!showMarks[sm].intensity || showMark == -1) continue; pp_int32 x = (pp_int32)(showMark*scalex) - startPos; g->drawVLine(location.y + yOffset, location.y + yOffset + visibleHeight + 2, location.x + xOffset + x); } for (i = 0; i < envelope->num; i++) { pp_int32 x1 = (pp_int32)(envelope->env[i][0]*scalex); pp_int32 y1 = (pp_int32)(envelope->env[i][1]*scaley); x1+=location.x + xOffset - startPos; y1 = location.y + yOffset + visibleHeight - y1; if ((envelope->type & 4) && (i == envelope->loops || i == envelope->loope)) { g->setColor(TrackerConfig::colorHighLight_1); for (pp_int32 j = 0; j < visibleHeight; j+=2) g->setPixel(x1, j + location.y + yOffset); if (i == envelope->loops) { g->setPixel(x1, location.y + yOffset); g->setPixel(x1, location.y + yOffset + 1); g->setPixel(x1+1, location.y + yOffset + 1); g->setPixel(x1-1, location.y + yOffset + 1); g->setPixel(x1, location.y + yOffset + 2); g->setPixel(x1+1, location.y + yOffset + 2); g->setPixel(x1-1, location.y + yOffset + 2); g->setPixel(x1+2, location.y + yOffset + 2); g->setPixel(x1-2, location.y + yOffset + 2); } if (i == envelope->loope) { g->setPixel(x1, location.y + visibleHeight + yOffset); g->setPixel(x1, location.y + visibleHeight + yOffset - 1); g->setPixel(x1+1, location.y + visibleHeight + yOffset - 1); g->setPixel(x1-1, location.y + visibleHeight + yOffset - 1); g->setPixel(x1, location.y + visibleHeight + yOffset - 2); g->setPixel(x1+1, location.y + visibleHeight + yOffset - 2); g->setPixel(x1-1, location.y + visibleHeight + yOffset - 2); g->setPixel(x1+2, location.y + visibleHeight + yOffset - 2); g->setPixel(x1-2, location.y + visibleHeight + yOffset - 2); } } if ((envelope->type & 2) && (i == envelope->sustain)) { g->setColor(255, 255, 255); for (pp_int32 j = 0; j < visibleHeight; j+=2) g->setPixel(x1, j + location.y + yOffset + 1); } /*pp_int32 extent = 1; if (i == selectionIndex) { g->setColor(255, 0, 0); extent = 2; } else*/ if (i != envelopeEditor->getSelectionIndex()) { const pp_int32 extent = 1; g->setColor(255, 255, 255); for (pp_int32 y = -extent; y <= extent; y++) for (pp_int32 x = -extent; x <= extent; x++) g->setPixel(x1+x, y1+y); } } // draw selected point always above the other points if (envelopeEditor->getSelectionIndex() != -1) { i = envelopeEditor->getSelectionIndex(); pp_int32 x1 = (pp_int32)(envelope->env[i][0]*scalex); pp_int32 y1 = (pp_int32)(envelope->env[i][1]*scaley); x1+=location.x + xOffset - startPos; y1 = location.y + yOffset + visibleHeight - y1; const pp_int32 extent = 2; g->setColor(255, 0, 0); for (pp_int32 y = -extent; y <= extent; y++) for (pp_int32 x = -extent; x <= extent; x++) g->setPixel(x1+x, y1+y); } if (currentPosition.x >= 0 && currentPosition.y >= 0) { PPFont* font = PPFont::getFont(PPFont::FONT_TINY); g->setFont(font); // loop markers above range text char buffer[32]; PPTools::convertToHex(buffer, (unsigned)currentPosition.x, 4); g->setColor(0, 0, 0); g->drawString(buffer, location.x + 3 + visibleWidth - font->getStrWidth(buffer), location.y + 4); g->setColor(255, 0, 255); g->drawString(buffer, location.x + 2 + visibleWidth - font->getStrWidth(buffer), location.y + 3); PPTools::convertToHex(buffer, (unsigned)currentPosition.y, 2); g->setColor(0, 0, 0); g->drawString(buffer, location.x + 3 + visibleWidth - font->getStrWidth(buffer), location.y + 4 + font->getCharHeight()+2); g->setColor(0, 255, 0); g->drawString(buffer, location.x + 2 + visibleWidth - font->getStrWidth(buffer), location.y + 3 + font->getCharHeight()+2); } hScrollbar->paint(g); }