summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpainter.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2009-09-18 10:38:53 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2009-09-18 10:38:53 (GMT)
commitdd3e430897a222ee9e3c7b923d094401fdeb72dd (patch)
tree4eca99cb2586a00143352ae22be8c483ea6d4288 /src/gui/painting/qpainter.cpp
parentd3fa072c06dc3ca876ffea2b700f332d4425e56a (diff)
downloadQt-dd3e430897a222ee9e3c7b923d094401fdeb72dd.zip
Qt-dd3e430897a222ee9e3c7b923d094401fdeb72dd.tar.gz
Qt-dd3e430897a222ee9e3c7b923d094401fdeb72dd.tar.bz2
Made drawRoundedRect() implementation virtual in QPaintEngineEx
Reviewed-by: Samuel
Diffstat (limited to 'src/gui/painting/qpainter.cpp')
-rw-r--r--src/gui/painting/qpainter.cpp75
1 files changed, 2 insertions, 73 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index b3aef71..ebaa901 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -4038,7 +4038,6 @@ const QFont &QPainter::font() const
\sa drawRect(), QPen
*/
-// FALCON: Should we add a specialized method in QPaintEngineEx?
void QPainter::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode)
{
#ifdef QT_DEBUG_DRAW
@@ -4056,61 +4055,7 @@ void QPainter::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius,
}
if (d->extended) {
- QPainterPath::ElementType types[] = {
- QPainterPath::MoveToElement,
- QPainterPath::LineToElement,
- QPainterPath::CurveToElement,
- QPainterPath::CurveToDataElement,
- QPainterPath::CurveToDataElement,
- QPainterPath::LineToElement,
- QPainterPath::CurveToElement,
- QPainterPath::CurveToDataElement,
- QPainterPath::CurveToDataElement,
- QPainterPath::LineToElement,
- QPainterPath::CurveToElement,
- QPainterPath::CurveToDataElement,
- QPainterPath::CurveToDataElement,
- QPainterPath::LineToElement,
- QPainterPath::CurveToElement,
- QPainterPath::CurveToDataElement,
- QPainterPath::CurveToDataElement
- };
-
- qreal x1 = rect.left();
- qreal x2 = rect.right();
- qreal y1 = rect.top();
- qreal y2 = rect.bottom();
-
- if (mode == Qt::RelativeSize) {
- xRadius = xRadius * rect.width() / 200.;
- yRadius = yRadius * rect.height() / 200.;
- }
-
- xRadius = qMin(xRadius, rect.width() / 2);
- yRadius = qMin(yRadius, rect.height() / 2);
-
- qreal pts[] = {
- x1 + xRadius, y1, // MoveTo
- x2 - xRadius, y1, // LineTo
- x2 - (1 - KAPPA) * xRadius, y1, // CurveTo
- x2, y1 + (1 - KAPPA) * yRadius,
- x2, y1 + yRadius,
- x2, y2 - yRadius, // LineTo
- x2, y2 - (1 - KAPPA) * yRadius, // CurveTo
- x2 - (1 - KAPPA) * xRadius, y2,
- x2 - xRadius, y2,
- x1 + xRadius, y2, // LineTo
- x1 + (1 - KAPPA) * xRadius, y2, // CurveTo
- x1, y2 - (1 - KAPPA) * yRadius,
- x1, y2 - yRadius,
- x1, y1 + yRadius, // LineTo
- x1, y1 + KAPPA * yRadius, // CurveTo
- x1 + (1 - KAPPA) * xRadius, y1,
- x1 + xRadius, y1
- };
-
- QVectorPath path(pts, 17, types);
- d->extended->draw(path);
+ d->extended->drawRoundedRect(rect, xRadius, yRadius, mode);
return;
}
@@ -4152,23 +4097,7 @@ void QPainter::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius,
*/
void QPainter::drawRoundRect(const QRectF &r, int xRnd, int yRnd)
{
-#ifdef QT_DEBUG_DRAW
- if (qt_show_painter_debug_output)
- printf("QPainter::drawRoundRectangle(), [%.2f,%.2f,%.2f,%.2f]\n", r.x(), r.y(), r.width(), r.height());
-#endif
- Q_D(QPainter);
-
- if (!d->engine)
- return;
-
- if(xRnd <= 0 || yRnd <= 0) { // draw normal rectangle
- drawRect(r);
- return;
- }
-
- QPainterPath path;
- path.addRoundRect(r, xRnd, yRnd);
- drawPath(path);
+ drawRoundedRect(r, xRnd, yRnd, Qt::RelativeSize);
}