diff options
Diffstat (limited to 'tdegtk')
-rw-r--r-- | tdegtk/tqtcairopainter.cpp | 92 |
1 files changed, 76 insertions, 16 deletions
diff --git a/tdegtk/tqtcairopainter.cpp b/tdegtk/tqtcairopainter.cpp index 6bf5b9f..ae440b7 100644 --- a/tdegtk/tqtcairopainter.cpp +++ b/tdegtk/tqtcairopainter.cpp @@ -384,6 +384,8 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) double x; double y; + double x2; + double y2; double width; double height; @@ -393,13 +395,16 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) // Convert data types if (p) { -// if ((c == PdcDrawPoint) || (c == PdcMoveTo) || (c == PdcLineTo) || (c == PdcSetBrushOrigin)) { -// qt4point1 = QPoint(p[0].point->x(), p[0].point->y()); -// } -// if (c == PdcDrawLine) { -// qt4point1 = QPoint(p[0].point->x(), p[0].point->y()); -// qt4point2 = QPoint(p[1].point->x(), p[1].point->y()); -// } + if ((c == PdcDrawPoint) || (c == PdcMoveTo) || (c == PdcLineTo) || (c == PdcSetBrushOrigin)) { + x = p[0].point->x(); + y = p[0].point->y(); + } + if (c == PdcDrawLine) { + x = p[0].point->x(); + y = p[0].point->y(); + x2 = p[1].point->x(); + y2 = p[1].point->y(); + } // if ((c == PdcDrawPolyline) || (c == PdcDrawPolygon) || (c == PdcDrawLineSegments) || (c == PdcDrawCubicBezier)) { // TQPointArray qt3parray = *p[0].ptarr; // qt4polygon.resize(qt3parray.count()); @@ -420,24 +425,52 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) switch ( c ) { // exec cmd case PdcNOP: break; -#if 0 case PdcDrawPoint: - m_qt4painter->drawPoint( qt4point1 ); + if (m_painter) { + cairo_save(m_painter); + if (m_pen.style() != TQPen::NoPen) { + cairo_move_to(m_painter, x+CAIRO_PIXEL_OFFSET, y+CAIRO_PIXEL_OFFSET); + cairo_line_to(m_painter, x+CAIRO_PIXEL_OFFSET, y+CAIRO_PIXEL_OFFSET); + updatePen(FALSE); + cairo_set_line_cap(m_painter, CAIRO_LINE_CAP_ROUND); + cairo_stroke(m_painter); + } + cairo_restore(m_painter); + } break; case PdcMoveTo: - curPt = qt4point1; + if (m_painter) { + cairo_save(m_painter); + if (m_pen.style() != TQPen::NoPen) { + cairo_move_to(m_painter, x+CAIRO_PIXEL_OFFSET, y+CAIRO_PIXEL_OFFSET); + } + cairo_restore(m_painter); + } break; case PdcLineTo: - prevPt = curPt; - curPt = qt4point1; - m_qt4painter->drawLine( prevPt, curPt ); + if (m_painter) { + cairo_save(m_painter); + if (m_pen.style() != TQPen::NoPen) { + cairo_line_to(m_painter, x2+CAIRO_PIXEL_OFFSET, y2+CAIRO_PIXEL_OFFSET); + dualStrokePen(); + } + cairo_restore(m_painter); + } break; case PdcDrawLine: - m_qt4painter->drawLine( qt4point1, qt4point2 ); + if (m_painter) { + cairo_save(m_painter); + if (m_pen.style() != TQPen::NoPen) { + cairo_move_to(m_painter, x+CAIRO_PIXEL_OFFSET, y+CAIRO_PIXEL_OFFSET); + cairo_line_to(m_painter, x2+CAIRO_PIXEL_OFFSET, y2+CAIRO_PIXEL_OFFSET); + dualStrokePen(); + } + cairo_restore(m_painter); + } break; -#endif case PdcDrawRect: if (m_painter) { + cairo_save(m_painter); if (m_pen.style() != TQPen::NoPen) { cairo_rectangle(m_painter, x+CAIRO_PIXEL_OFFSET, y+CAIRO_PIXEL_OFFSET, width, height); dualStrokePen(); @@ -447,6 +480,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) cairo_rectangle(m_painter, x+line_width+CAIRO_PIXEL_OFFSET, y+line_width+CAIRO_PIXEL_OFFSET, width-(line_width*2), height-(line_width*2)); dualStrokeBrush(); } + cairo_restore(m_painter); } else { #if defined(QT_CHECK_RANGE) @@ -476,9 +510,35 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) lineCount = (count == -1) ? (qt4polygon.size() - index) / 2 : count; m_qt4painter->drawLines(qt4polygon.constData() + index * 2, lineCount); break; +#endif case PdcDrawPolyline: - m_qt4painter->drawPolyline( qt4polygon ); + if (m_painter) { + cairo_save(m_painter); + if (p) { + const TQPointArray* pointarray = p[0].ptarr; + if (pointarray) { + int x; + int y; + bool first=true; + for (i=0;i<pointarray->count();i++) { + pointarray->point(i, &x, &y ); + if (first) { + cairo_move_to(m_painter, x+CAIRO_PIXEL_OFFSET, y+CAIRO_PIXEL_OFFSET); + first = false; + } + else { + cairo_line_to(m_painter, x+CAIRO_PIXEL_OFFSET, y+CAIRO_PIXEL_OFFSET); + } + } + if (m_pen.style() != TQPen::NoPen) { + dualStrokePen(); + } + } + } + cairo_restore(m_painter); + } break; +#if 0 case PdcDrawPolygon: m_qt4painter->drawPolygon( qt4polygon, (p[1].ival == 0)?Qt::OddEvenFill:Qt::WindingFill ); break; |