Diffstat (limited to 'noncore/graphics/drawpad/rectangledrawmode.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/rectangledrawmode.cpp | 60 |
1 files changed, 8 insertions, 52 deletions
diff --git a/noncore/graphics/drawpad/rectangledrawmode.cpp b/noncore/graphics/drawpad/rectangledrawmode.cpp index 60d7cea..0226544 100644 --- a/noncore/graphics/drawpad/rectangledrawmode.cpp +++ b/noncore/graphics/drawpad/rectangledrawmode.cpp @@ -1,83 +1,39 @@ /*************************************************************************** * * * DrawPad - a drawing program for Opie Environment * * * * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "rectangledrawmode.h" #include "drawpad.h" #include "drawpadcanvas.h" -#include <qpainter.h> -#include <qpixmap.h> - RectangleDrawMode::RectangleDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) - : DrawMode(drawPad, drawPadCanvas) + : ShapeDrawMode(drawPad, drawPadCanvas) { - m_mousePressed = false; - m_polyline.resize(3); } RectangleDrawMode::~RectangleDrawMode() { } -void RectangleDrawMode::mousePressEvent(QMouseEvent* e) +void RectangleDrawMode::drawFinalShape(QPainter& p) { - m_mousePressed = true; - m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); + p.setPen(m_pDrawPad->pen()); + p.drawRect(QRect(m_polyline[2], m_polyline[0])); } -void RectangleDrawMode::mouseReleaseEvent(QMouseEvent* e) +void RectangleDrawMode::drawTemporaryShape(QPainter& p) { - Q_UNUSED(e) - - QPainter painter; - painter.begin(m_pDrawPadCanvas->currentPage()); - painter.setPen(m_pDrawPad->pen()); - painter.drawRect(QRect(m_polyline[2], m_polyline[0])); - painter.end(); - - QRect r = m_polyline.boundingRect(); - r = r.normalize(); - r.setLeft(r.left() - m_pDrawPad->pen().width()); - r.setTop(r.top() - m_pDrawPad->pen().width()); - r.setRight(r.right() + m_pDrawPad->pen().width()); - r.setBottom(r.bottom() + m_pDrawPad->pen().width()); - - bitBlt(m_pDrawPadCanvas, r.x(), r.y(), m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); - - m_mousePressed = false; -} - -void RectangleDrawMode::mouseMoveEvent(QMouseEvent* e) -{ - if (m_mousePressed) { - QPainter painter; - painter.begin(m_pDrawPadCanvas->currentPage()); - painter.setRasterOp(Qt::NotROP); - m_polyline[0] = e->pos(); - painter.drawRect(QRect(m_polyline[2], m_polyline[1])); - painter.drawRect(QRect(m_polyline[2], m_polyline[0])); - painter.end(); - - QRect r = m_polyline.boundingRect(); - r = r.normalize(); - r.setLeft(r.left() - m_pDrawPad->pen().width()); - r.setTop(r.top() - m_pDrawPad->pen().width()); - r.setRight(r.right() + m_pDrawPad->pen().width()); - r.setBottom(r.bottom() + m_pDrawPad->pen().width()); - - bitBlt(m_pDrawPadCanvas, r.x(), r.y(), m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); - - m_polyline[1] = m_polyline[0]; - } + p.setRasterOp(Qt::NotROP); + p.drawRect(QRect(m_polyline[2], m_polyline[1])); + p.drawRect(QRect(m_polyline[2], m_polyline[0])); } |