//-------------------------------------------------------------------------- // return a thumbnail that respects the orientation flag // only if it seems sane //-------------------------------------------------------------------------- QImage ExifData::getThumbnail() { if (!isThumbnailSane()) return NULL; if (!Orientation || Orientation == 1) return Thumbnail; // now fix orientation QWMatrix M; QWMatrix flip= QWMatrix(-1,0,0,1,0,0); switch (Orientation) { // notice intentional fallthroughs case 2: M = flip; break; case 4: M = flip; case 3: M.rotate(180); break; case 5: M = flip; case 6: M.rotate(90); break; case 7: M = flip; case 8: M.rotate(270); break; default: break; // should never happen } return Thumbnail.xForm(M); }
void KoChild::updateMatrix() { QWMatrix r; r.rotate( - d->m_rotation ); QPoint p = r.map( QPoint( d->m_rotationPoint.x(), d->m_rotationPoint.y() ) ); QWMatrix m; m.rotate( d->m_rotation ); m.translate( -d->m_rotationPoint.x() + d->m_geometry.x(), -d->m_rotationPoint.y() + d->m_geometry.y() ); m.translate( p.x(), p.y() ); m.shear( d->m_shearX, d->m_shearY ); d->m_matrix = m; }
void rotate() { int i; const int w = 64; const int h = 64; QImage image( w, h, 8, 128 ); // create image for ( i=0; i<128; i++ ) // build color table image.setColor( i, qRgb(i,0,0) ); for ( int y=0; y<h; y++ ) { // set image pixels uchar *p = image.scanLine(y); for ( int x=0; x<w; x++ ) *p++ = (x+y)%128; } QPixmap pm; pm = image; // convert image to pixmap pm.optimize( TRUE ); // rotation will be faster QWidget *d = QApplication::desktop(); // w = desktop widget for ( i=0; i<=360; i += 2 ) { QWMatrix m; m.rotate( i ); // rotate coordinate system QPixmap rpm = pm.xForm( m ); // rpm = rotated pixmap d->setBackgroundPixmap( rpm ); // set desktop pixmap d->update(); // repaint desktop } }
void ImageLabel::applyTransformations(bool useSmoothScale) { pixmap = realpixmap; if (doRotate) { // KDE and QT seem to miss a high quality image rotation QWMatrix rotMat; rotMat.rotate(rot_angle); pixmap = pixmap.xForm(rotMat); } if (doScale) { if (m_karamba -> useSmoothTransforms() || useSmoothScale) { pixmap.convertFromImage( pixmap.convertToImage().smoothScale(scale_w, scale_h)); } else { double widthFactor = ((double)scale_w) / ((double)pixmap.width()); double heightFactor = ((double)scale_h) / ((double)pixmap.height()); QWMatrix scaleMat; scaleMat.scale(widthFactor, heightFactor); pixmap = pixmap.xForm(scaleMat); } } if (imageEffect != 0) { pixmap = imageEffect -> apply(pixmap); } setWidth(pixmap.width()); setHeight(pixmap.height()); }
void drawColorWheel( QPainter *p ) { QFont f( "times", 18, QFont::Bold ); p->setFont( f ); p->setPen( Qt::black ); p->setWindow( 0, 0, 500, 500 ); // defines coordinate system for ( int i=0; i<36; i++ ) { // draws 36 rotated rectangles QWMatrix matrix; matrix.translate( 250.0F, 250.0F ); // move to center matrix.shear( 0.0F, 0.3F ); // twist it matrix.rotate( (float)i*10 ); // rotate 0,10,20,.. degrees p->setWorldMatrix( matrix ); // use this world matrix QColor c; c.setHsv( i*10, 255, 255 ); // rainbow effect p->setBrush( c ); // solid fill with color c p->drawRect( 70, -10, 80, 10 ); // draw the rectangle QString n; n.sprintf( "H=%d", i*10 ); p->drawText( 80+70+5, 0, n ); // draw the hue number } }
void MechanicsItemOverlay::slotUpdateResizeHandles() { const PositionInfo absPos = p_mechanicsItem->absolutePosition(); const QRect sizeRect = p_mechanicsItem->sizeRect(); QPointArray pa(9); pa[0] = sizeRect.topLeft(); pa[2] = sizeRect.topRight(); pa[1] = (pa[0]+pa[2])/2; pa[4] = sizeRect.bottomRight(); pa[3] = (pa[2]+pa[4])/2; pa[6] = sizeRect.bottomLeft(); pa[5] = (pa[4]+pa[6])/2; pa[7] = (pa[6]+pa[0])/2; pa[8] = QPoint(0,0); QWMatrix m; m.rotate(absPos.angle() * DPR); pa = m.map(pa); m_tl->move( absPos.x()+pa[0].x(), absPos.y()+pa[0].y() ); m_tm->move( absPos.x()+pa[1].x(), absPos.y()+pa[1].y() ); m_tr->move( absPos.x()+pa[2].x(), absPos.y()+pa[2].y() ); m_mr->move( absPos.x()+pa[3].x(), absPos.y()+pa[3].y() ); m_br->move( absPos.x()+pa[4].x(), absPos.y()+pa[4].y() ); m_bm->move( absPos.x()+pa[5].x(), absPos.y()+pa[5].y() ); m_bl->move( absPos.x()+pa[6].x(), absPos.y()+pa[6].y() ); m_ml->move( absPos.x()+pa[7].x(), absPos.y()+pa[7].y() ); m_mm->move( absPos.x()+pa[8].x(), absPos.y()+pa[8].y() ); }
void ArrowLine::drawShape(QPainter &p) { p.setPen(darkGray); QCanvasLine::drawShape(p); double angle = computeAngle(startPoint().x(), startPoint().y(), endPoint().x(), endPoint().y()); QPointArray pts(3); QWMatrix m; int x, y; m.rotate(angle); m.map(-5, -2, &x, &y); pts.setPoint(0, x, y); m.map(-5, 2, &x, &y); pts.setPoint(1, x, y); m.map(0, 0, &x, &y); pts.setPoint(2, x, y); pts.translate(endPoint().x(), endPoint().y()); p.setBrush(QColor(darkGray)); p.drawPolygon(pts); }
void Node::initPoints() { // Bounding rectangle, facing right QPointArray pa(QRect(0, -8, m_length, 16)); QWMatrix m; m.rotate(m_dir); pa = m.map(pa); setPoints(pa); }
void KivioStencil::rotatePainter(KivioIntraStencilData *pData) { if(m_rotation != 0) { QWMatrix m; m.translate(pData->zoomHandler->zoomItX(m_pinPoint.x()), pData->zoomHandler->zoomItY(m_pinPoint.y())); m.rotate(m_rotation); m.translate(pData->zoomHandler->zoomItX(-m_pinPoint.x()), pData->zoomHandler->zoomItY(-m_pinPoint.y())); pData->painter->setWorldMatrix(m, true); } }
void PinNode::initPoints() { int l = - m_length; // Bounding rectangle, facing right Q3PointArray pa( QRect( 0, -8, l, 16 ) ); QWMatrix m; m.rotate( m_dir ); pa = m.map(pa); setPoints(pa); }
void KMultiTabBarTab::setIcon(const QPixmap& icon) { if ((m_position==KMultiTabBar::Left) || (m_position==KMultiTabBar::Right)) { QWMatrix rotateMatrix; if (m_position==KMultiTabBar::Left) rotateMatrix.rotate(90); else rotateMatrix.rotate(-90); QPixmap pic=icon.xForm(rotateMatrix); #if 0 if(m_position==KMultiTabBar::Left) { QWMatrix flipMatrix; flipMatrix.setMatrix(1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F); pic=pic.xForm(flipMatrix); } #endif d->pix=pic; setIconSet(pic); } else setIconSet(icon); }
void KMultiTabBarTab::setTabsPosition(KMultiTabBar::KMultiTabBarPosition pos) { if ((pos!=m_position) && ((pos==KMultiTabBar::Left) || (pos==KMultiTabBar::Right))) { if (!d->pix.isNull()) { QWMatrix temp;// (1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F); temp.rotate(180); d->pix=d->pix.xForm(temp); setIconSet(d->pix); } } setPosition(pos); // repaint(); }
void AnalogClock::paintEvent( QPaintEvent * ) // paint clock { if ( !isVisible() ) // is is invisible return; time = QTime::currentTime(); // save current time QPointArray pts; QPainter paint( this ); paint.setBrush( foregroundColor() ); // fill with foreground color QPoint cp = rect().center(); // widget center point int d = QMIN(width(),height()); // we want a circular clock QWMatrix matrix; // setup transformation matrix matrix.translate( cp.x(), cp.y() ); // origin at widget center matrix.scale( d/1000.0F, d/1000.0F ); // scale coordinate system float h_angle = 30*(time.hour()%12-3) + time.minute()/2; matrix.rotate( h_angle ); // rotate to draw hour hand paint.setWorldMatrix( matrix ); pts.setPoints( 4, -20,0, 0,-20, 300,0, 0,20 ); paint.drawPolygon( pts ); // draw hour hand matrix.rotate( -h_angle ); // rotate back to zero float m_angle = (time.minute()-15)*6; matrix.rotate( m_angle ); // rotate to draw minute hand paint.setWorldMatrix( matrix ); pts.setPoints( 4, -10,0, 0,-10, 400,0, 0,10 ); paint.drawPolygon( pts ); // draw minute hand matrix.rotate( -m_angle ); // rotate back to zero for ( int i=0; i<12; i++ ) { // draw hour lines paint.setWorldMatrix( matrix ); paint.drawLine( 450,0, 500,0 ); matrix.rotate( 30 ); } }
QRect GuiPart::drawRect() { QRect dr = rect(); if ( m_angleDegrees%180 != 0 ) { QWMatrix m; m.translate( int(x()+(width()/2)), int(y()+(height()/2)) ); if ( (m_angleDegrees%180) != 0 ) m.rotate(-m_angleDegrees); m.translate( -int(x()+(width()/2)), -int(y()+(height()/2)) ); dr = m.mapRect(dr); } return dr; }
void FLCodBar::readPixmapStdout() { if ( writingStdout ) { qApp->processEvents(); return ; } p.loadFromData( proc->readStdout(), "PNG" ); if ( !p.isNull() ) { QWMatrix m; m.rotate(( double ) barcode.rotation ); p.xForm( m ); barcode.valid = true; } readingStdout = false; }
void drawPathText( QPainter *p ) { QPointArray a( 4 ); a.setPoint( 0, 100,200 ); a.setPoint( 1, 150,75 ); a.setPoint( 2, 250,75 ); a.setPoint( 3, 300,200 ); a = a.quadBezier(); // calculate Bezier curve p->setPen( lightGray ); // set light gray pen p->drawPolyline( a ); // draw Bezier point array p->setFont( QFont("Times",24) ); // set fast font p->setPen( black ); // set black pen const char *text = "Troll Tech AS"; int len = strlen(text); if ( len == 0 ) return; int ipos = a.size()/len; int cpos = ipos; for ( int i=0; i<len; i++ ) { // for each char in text... QPoint p1 = a.point( cpos-1 ); QPoint p2 = a.point( cpos+1 ); QPoint pt = a.point(cpos); float dx = (float)(p2.x() - p1.x()); float dy = (float)(p2.y() - p1.y()); float angle = (float)atan(dy/dx); // way too simple angle *= 180.0F/3.14F; QWMatrix m; // setup world matrix m.translate( (float)pt.x(), (float)pt.y() ); m.rotate( angle ); p->setWorldMatrix( m ); p->drawText( 0,0, &text[i], 1 ); cpos += ipos; } }
void PictButton::paintEvent(QPaintEvent *e) { if (icon) CToolButton::paintEvent(e); QPainter p(this); QRect rc(4, 4, width() - 4, height() - 4); if (icon){ const QPixmap &pict = Pict(icon); QToolBar *bar = static_cast<QToolBar*>(parent()); if (bar->orientation() == Vertical){ p.drawPixmap((width() - pict.width()) / 2, 4, pict); QWMatrix m; m.rotate(90); p.setWorldMatrix(m); rc = QRect(8 + pict.height(), -4, height() - 4, 4 - width()); }else{ p.drawPixmap(4, (height() - pict.height()) / 2, pict); rc = QRect(8 + pict.width(), 4, width() - 4, height() - 4); } } p.drawText(rc, AlignLeft | AlignVCenter, text); }
void ZLQtViewWidget::ZLQtViewWidgetInternal::paintEvent(QPaintEvent*) { const int w = width(); const int h = height() + myHolder.myApplicationWindow.verticalAdjustment(); switch (myHolder.rotation()) { default: ((ZLQtPaintContext&)myHolder.view()->context()).setSize(w, h); break; case DEGREES90: case DEGREES270: ((ZLQtPaintContext&)myHolder.view()->context()).setSize(h, w); break; } myHolder.view()->paint(); int angle = 0; switch (myHolder.rotation()) { default: break; case DEGREES90: angle = 270; break; case DEGREES180: angle = 180; break; case DEGREES270: angle = 90; break; } const QPixmap &pixmap = ((ZLQtPaintContext&)myHolder.view()->context()).pixmap(); QPainter painter(this); if (angle == 0) { painter.drawPixmap(0, 0, pixmap); } else { QWMatrix matrix; matrix.rotate(angle); painter.drawPixmap(0, 0, pixmap.xForm(matrix)); } }
void TaskBarExtension::setBackgroundTheme() { if (KickerSettings::transparent()) { if (!m_rootPixmap) { m_rootPixmap = new KRootPixmap(this); m_rootPixmap->setCustomPainting(true); connect(m_rootPixmap, SIGNAL(backgroundUpdated(const QPixmap&)), SLOT(updateBackground(const QPixmap&))); } else { m_rootPixmap->repaint(true); } double tint = double(KickerSettings::tintValue()) / 100; m_rootPixmap->setFadeEffect(tint, KickerSettings::tintColor()); m_rootPixmap->start(); return; } else if (m_rootPixmap) { delete m_rootPixmap; m_rootPixmap = 0; } unsetPalette(); m_container->unsetPalette(); if (KickerSettings::useBackgroundTheme()) { QString bgFilename = locate("appdata", KickerSettings::backgroundTheme()); if (m_bgFilename != bgFilename) { m_bgFilename = bgFilename; m_bgImage.load(m_bgFilename); } if (!m_bgImage.isNull()) { QImage bgImage = m_bgImage; if (orientation() == Vertical) { if (KickerSettings::rotateBackground()) { QWMatrix matrix; matrix.rotate(position() == KPanelExtension::Left ? 90: 270); bgImage = bgImage.xForm(matrix); } bgImage = bgImage.scaleWidth(size().width()); } else { if (position() == KPanelExtension::Top && KickerSettings::rotateBackground()) { QWMatrix matrix; matrix.rotate(180); bgImage = bgImage.xForm(matrix); } bgImage = bgImage.scaleHeight(size().height()); } if (KickerSettings::colorizeBackground()) { KickerLib::colorize(bgImage); } setPaletteBackgroundPixmap(bgImage); m_container->setPaletteBackgroundPixmap(bgImage); } } }
void KdmClock::paintEvent( QPaintEvent * ) { if (!isVisible()) return; QPainter p( this ); drawFrame( &p ); QPixmap pm( contentsRect().size() ); QPainter paint; paint.begin( &pm ); paint.fillRect( contentsRect(), mBackgroundBrush ); // get current time QTime time = QTime::currentTime(); /* if (mDigital) { QString buf; if (mSecond) buf.sprintf( "%02d:%02d:%02d", time.hour(), time.minute(), time.second() ); else buf.sprintf( "%02d:%02d", time.hour(), time.minute() ); mFont.setPointSize( QMIN( (int)(width()/buf.length()*1.5),height() ) ); paint.setFont( mFont ); paint.setPen( backgroundColor() ); paint.drawText( contentsRect(),AlignHCenter|AlignVCenter, buf,-1,0,0 ); } else { */ QPointArray pts; QPoint cp = contentsRect().center() - QPoint( 2,2 ); int d = QMIN( contentsRect().width()-15,contentsRect().height()-15 ); paint.setPen( foregroundColor() ); paint.setBrush( foregroundColor() ); QWMatrix matrix; matrix.translate( cp.x(), cp.y() ); matrix.scale( d/1000.0F, d/1000.0F ); // Hour float h_angle = 30*(time.hour()%12-3) + time.minute()/2; matrix.rotate( h_angle ); paint.setWorldMatrix( matrix ); pts.setPoints( 4, -20,0, 0,-20, 300,0, 0,20 ); paint.drawPolygon( pts ); matrix.rotate( -h_angle ); // Minute float m_angle = (time.minute()-15)*6; matrix.rotate( m_angle ); paint.setWorldMatrix( matrix ); pts.setPoints( 4, -10,0, 0,-10, 400,0, 0,10 ); paint.drawPolygon( pts ); matrix.rotate( -m_angle ); // Second float s_angle = (time.second()-15)*6; matrix.rotate( s_angle ); paint.setWorldMatrix( matrix ); pts.setPoints( 4,0,0,0,0,400,0,0,0 ); if (mSecond) paint.drawPolygon( pts ); matrix.rotate( -s_angle ); // quadrante for (int i=0 ; i < 60 ; i++) { paint.setWorldMatrix( matrix ); if ((i % 5) == 0) paint.drawLine( 450,0, 500,0 ); // draw hour lines else paint.drawPoint( 480,0 ); // draw second lines matrix.rotate( 6 ); } // } // if (mDigital) paint.end(); // flicker free code by Remi Guyomarch <*****@*****.**> bitBlt( this, contentsRect().topLeft(), &pm ); }
// motif arrows look the same whether they are used or not // is this correct? static void qDrawMotifArrow( QPainter *p, Qt::ArrowType type, bool down, int x, int y, int w, int h, const QColorGroup &g, bool ) { QPointArray bFill; // fill polygon QPointArray bTop; // top shadow. QPointArray bBot; // bottom shadow. QPointArray bLeft; // left shadow. #ifndef QT_NO_TRANSFORMATIONS QWMatrix matrix; // xform matrix #endif bool vertical = type == Qt::UpArrow || type == Qt::DownArrow; bool horizontal = !vertical; int dim = w < h ? w : h; int colspec = 0x0000; // color specification array if ( dim < 2 ) // too small arrow return; if ( dim > 3 ) { if ( dim > 6 ) bFill.resize( dim & 1 ? 3 : 4 ); bTop.resize( (dim/2)*2 ); bBot.resize( dim & 1 ? dim + 1 : dim ); bLeft.resize( dim > 4 ? 4 : 2 ); bLeft.putPoints( 0, 2, 0,0, 0,dim-1 ); if ( dim > 4 ) bLeft.putPoints( 2, 2, 1,2, 1,dim-3 ); bTop.putPoints( 0, 4, 1,0, 1,1, 2,1, 3,1 ); bBot.putPoints( 0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2 ); for( int i=0; i<dim/2-2 ; i++ ) { bTop.putPoints( i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i ); bBot.putPoints( i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i ); } if ( dim & 1 ) // odd number size: extra line bBot.putPoints( dim-1, 2, dim-3,dim/2, dim-1,dim/2 ); if ( dim > 6 ) { // dim>6: must fill interior bFill.putPoints( 0, 2, 1,dim-3, 1,2 ); if ( dim & 1 ) // if size is an odd number bFill.setPoint( 2, dim - 3, dim / 2 ); else bFill.putPoints( 2, 2, dim-4,dim/2-1, dim-4,dim/2 ); } } else { if ( dim == 3 ) { // 3x3 arrow pattern bLeft.setPoints( 4, 0,0, 0,2, 1,1, 1,1 ); bTop .setPoints( 2, 1,0, 1,0 ); bBot .setPoints( 2, 1,2, 2,1 ); } else { // 2x2 arrow pattern bLeft.setPoints( 2, 0,0, 0,1 ); bTop .setPoints( 2, 1,0, 1,0 ); bBot .setPoints( 2, 1,1, 1,1 ); } } if ( type == Qt::UpArrow || type == Qt::LeftArrow ) { #ifndef QT_NO_TRANSFORMATIONS // #### fix me! matrix.translate( x, y ); if ( vertical ) { matrix.translate( 0, h - 1 ); matrix.rotate( -90 ); } else { matrix.translate( w - 1, h - 1 ); matrix.rotate( 180 ); } #endif if ( down ) colspec = horizontal ? 0x2334 : 0x2343; else colspec = horizontal ? 0x1443 : 0x1434; } else if ( type == Qt::DownArrow || type == Qt::RightArrow ) { #ifndef QT_NO_TRANSFORMATIONS // #### fix me! matrix.translate( x, y ); if ( vertical ) { matrix.translate( w-1, 0 ); matrix.rotate( 90 ); } #endif if ( down ) colspec = horizontal ? 0x2443 : 0x2434; else colspec = horizontal ? 0x1334 : 0x1343; } QColor *cols[5]; cols[0] = 0; cols[1] = (QColor *)&g.button(); cols[2] = (QColor *)&g.mid(); cols[3] = (QColor *)&g.light(); cols[4] = (QColor *)&g.dark(); #define CMID *cols[ (colspec>>12) & 0xf ] #define CLEFT *cols[ (colspec>>8) & 0xf ] #define CTOP *cols[ (colspec>>4) & 0xf ] #define CBOT *cols[ colspec & 0xf ] QPen savePen = p->pen(); // save current pen QBrush saveBrush = p->brush(); // save current brush #ifndef QT_NO_TRANSFORMATIONS QWMatrix wxm = p->worldMatrix(); #endif QPen pen( Qt::NoPen ); const QBrush &brush = g.brush( QColorGroup::Button ); p->setPen( pen ); p->setBrush( brush ); #ifndef QT_NO_TRANSFORMATIONS p->setWorldMatrix( matrix, TRUE ); // set transformation matrix #endif p->drawPolygon( bFill ); // fill arrow p->setBrush( Qt::NoBrush ); // don't fill p->setPen( CLEFT ); p->drawLineSegments( bLeft ); p->setPen( CTOP ); p->drawLineSegments( bTop ); p->setPen( CBOT ); p->drawLineSegments( bBot ); #ifndef QT_NO_TRANSFORMATIONS p->setWorldMatrix( wxm ); #endif p->setBrush( saveBrush ); // restore brush p->setPen( savePen ); // restore pen #undef CMID #undef CLEFT #undef CTOP #undef CBOT }
void KSPlanetBase::scaleRotateImage( int scale, double imAngle ) { ImageAngle = imAngle; QWMatrix m; m.rotate( ImageAngle ); Image = Image0.xForm( m ).smoothScale( scale, scale ); }
void KSPlanetBase::rotateImage( double imAngle ) { ImageAngle = imAngle; QWMatrix m; m.rotate( ImageAngle ); Image = Image0.xForm( m ); }
/** * Tests if a point is over a stencils */ int SelectTool::isOverResizeHandle( KivioStencil *pStencil, const double x, const double y ) { double three_pixels = 4.0; int available; QWMatrix m; double w = pStencil->w(); double h = pStencil->h(); double w2 = pStencil->w() / 2.0; double h2 = pStencil->h() / 2.0; m.translate(pStencil->x(), pStencil->y()); m.translate(w2, h2); m.rotate(pStencil->rotation()); m.translate(-w2, -h2); // FIXME: this needs to be optimized!!!! KoPoint tl(0 * m.m11() + 0 * m.m21() + m.dx(), 0 * m.m12() + 0 * m.m22() + m.dy()); KoPoint t(w2 * m.m11() + 0 * m.m21() + m.dx(), w2 * m.m12() + 0 * m.m22() + m.dy()); KoPoint tr(w * m.m11() + 0 * m.m21() + m.dx(), w * m.m12() + 0 * m.m22() + m.dy()); KoPoint r(w * m.m11() + h2 * m.m21() + m.dx(), w * m.m12() + h2 * m.m22() + m.dy()); KoPoint br(w * m.m11() + h * m.m21() + m.dx(), w * m.m12() + h * m.m22() + m.dy()); KoPoint b(w2 * m.m11() + h * m.m21() + m.dx(), w2 * m.m12() + h * m.m22() + m.dy()); KoPoint bl(0 * m.m11() + h * m.m21() + m.dx(), 0 * m.m12() + h * m.m22() + m.dy()); KoPoint l(0 * m.m11() + h2 * m.m21() + m.dx(), 0 * m.m12() + h2 * m.m22() + m.dy()); available = pStencil->resizeHandlePositions(); // Quick reject if( !available ) return 0; // Top left if( available & krhpNW && RESIZE_BOX_TEST( x, y, tl.x(), tl.y() ) ) return 1; // Top if( available & krhpN && RESIZE_BOX_TEST( x, y, t.x(), t.y() ) ) return 2; // Top right if( available & krhpNE && RESIZE_BOX_TEST( x, y, tr.x(), tr.y() ) ) return 3; // Right if( available & krhpE && RESIZE_BOX_TEST( x, y, r.x(), r.y() ) ) return 4; // Bottom right if( available & krhpSE && RESIZE_BOX_TEST( x, y, br.x(), br.y() ) ) return 5; // Bottom if( available & krhpS && RESIZE_BOX_TEST( x, y, b.x(), b.y() ) ) return 6; // Bottom left if( available & krhpSW && RESIZE_BOX_TEST( x, y, bl.x(), bl.y() ) ) return 7; // Left if( available & krhpW && RESIZE_BOX_TEST( x, y, l.x(), l.y() ) ) return 8; // Nothing found return 0; }
void Main::rotateCounterClockwise() { QWMatrix m = editor->worldMatrix(); m.rotate( -22.5 ); editor->setWorldMatrix( m ); }
void QCDEStyle::drawArrow( QPainter *p, ArrowType type, bool down, int x, int y, int w, int h, const QColorGroup &g, bool enabled, const QBrush * /* fill */ ) { QPointArray bFill; // fill polygon QPointArray bTop; // top shadow. QPointArray bBot; // bottom shadow. QPointArray bLeft; // left shadow. QWMatrix matrix; // xform matrix bool vertical = type == UpArrow || type == DownArrow; bool horizontal = !vertical; int dim = w < h ? w : h; int colspec = 0x0000; // color specification array if ( dim < 2 ) // too small arrow return; // adjust size and center (to fix rotation below) if ( w > dim ) { x += (w-dim)/2; w = dim; } if ( h > dim ) { y += (h-dim)/2; h = dim; } if ( dim > 3 ) { bFill.resize( dim & 1 ? 3 : 4 ); bTop.resize( 2 ); bBot.resize( 2 ); bLeft.resize( 2 ); bLeft.putPoints( 0, 2, 0,0, 0,dim-1 ); bTop.putPoints( 0, 2, 1,0, dim-1, dim/2); bBot.putPoints( 0, 2, 1,dim-1, dim-1, dim/2); if ( dim > 6 ) { // dim>6: must fill interior bFill.putPoints( 0, 2, 1,dim-1, 1,1 ); if ( dim & 1 ) // if size is an odd number bFill.setPoint( 2, dim - 2, dim / 2 ); else bFill.putPoints( 2, 2, dim-2,dim/2-1, dim-2,dim/2 ); } } else { if ( dim == 3 ) { // 3x3 arrow pattern bLeft.setPoints( 4, 0,0, 0,2, 1,1, 1,1 ); bTop .setPoints( 2, 1,0, 1,0 ); bBot .setPoints( 2, 1,2, 2,1 ); } else { // 2x2 arrow pattern bLeft.setPoints( 2, 0,0, 0,1 ); bTop .setPoints( 2, 1,0, 1,0 ); bBot .setPoints( 2, 1,1, 1,1 ); } } if ( type == UpArrow || type == LeftArrow ) { matrix.translate( x, y ); if ( vertical ) { matrix.translate( 0, h - 1 ); matrix.rotate( -90 ); } else { matrix.translate( w - 1, h - 1 ); matrix.rotate( 180 ); } if ( down ) colspec = horizontal ? 0x2334 : 0x2343; else colspec = horizontal ? 0x1443 : 0x1434; } else if ( type == DownArrow || type == RightArrow ) { matrix.translate( x, y ); if ( vertical ) { matrix.translate( w-1, 0 ); matrix.rotate( 90 ); } if ( down ) colspec = horizontal ? 0x2443 : 0x2434; else colspec = horizontal ? 0x1334 : 0x1343; } QColor *cols[5]; if ( enabled ) { cols[0] = 0; cols[1] = (QColor *)&g.button(); cols[2] = (QColor *)&g.mid(); cols[3] = (QColor *)&g.light(); cols[4] = (QColor *)&g.dark(); } else { cols[0] = 0; cols[1] = (QColor *)&g.button(); cols[2] = (QColor *)&g.button(); cols[3] = (QColor *)&g.button(); cols[4] = (QColor *)&g.button(); } #define CMID *cols[ (colspec>>12) & 0xf ] #define CLEFT *cols[ (colspec>>8) & 0xf ] #define CTOP *cols[ (colspec>>4) & 0xf ] #define CBOT *cols[ colspec & 0xf ] QPen savePen = p->pen(); // save current pen QBrush saveBrush = p->brush(); // save current brush QWMatrix wxm = p->worldMatrix(); QPen pen( NoPen ); QBrush brush = g.brush( enabled?QColorGroup::Button:QColorGroup::Mid ); p->setPen( pen ); p->setBrush( brush ); p->setWorldMatrix( matrix, TRUE ); // set transformation matrix p->drawPolygon( bFill ); // fill arrow p->setBrush( NoBrush ); // don't fill p->setPen( CLEFT ); p->drawLineSegments( bLeft ); p->setPen( CBOT ); p->drawLineSegments( bBot ); p->setPen( CTOP ); p->drawLineSegments( bTop ); p->setWorldMatrix( wxm ); p->setBrush( saveBrush ); // restore brush p->setPen( savePen ); // restore pen #undef CMID #undef CLEFT #undef CTOP #undef CBOT }