summaryrefslogtreecommitdiff
path: root/noncore/graphics/drawpad/pointdrawmode.cpp
Unidiff
Diffstat (limited to 'noncore/graphics/drawpad/pointdrawmode.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/drawpad/pointdrawmode.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/noncore/graphics/drawpad/pointdrawmode.cpp b/noncore/graphics/drawpad/pointdrawmode.cpp
new file mode 100644
index 0000000..11722c8
--- a/dev/null
+++ b/noncore/graphics/drawpad/pointdrawmode.cpp
@@ -0,0 +1,67 @@
1/***************************************************************************
2 * *
3 * DrawPad - a drawing program for Opie Environment *
4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 ***************************************************************************/
13
14#include "pointdrawmode.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19#include <qpainter.h>
20#include <qpixmap.h>
21
22PointDrawMode::PointDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : DrawMode(drawPad, drawPadCanvas)
24{
25 m_mousePressed = false;
26 m_polyline.resize(3);
27}
28
29PointDrawMode::~PointDrawMode()
30{
31}
32
33void PointDrawMode::mousePressEvent(QMouseEvent* e)
34{
35 m_mousePressed = true;
36 m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
37}
38
39void PointDrawMode::mouseReleaseEvent(QMouseEvent* e)
40{
41 Q_UNUSED(e);
42
43 m_mousePressed = false;
44}
45
46void PointDrawMode::mouseMoveEvent(QMouseEvent* e)
47{
48 if (m_mousePressed) {
49 QPainter painter;
50 painter.begin(m_pDrawPadCanvas->currentPage());
51 painter.setPen(m_pDrawPad->pen());
52 m_polyline[2] = m_polyline[1];
53 m_polyline[1] = m_polyline[0];
54 m_polyline[0] = e->pos();
55 painter.drawPolyline(m_polyline);
56 painter.end();
57
58 QRect r = m_polyline.boundingRect();
59 r = r.normalize();
60 r.setLeft(r.left() - m_pDrawPad->pen().width());
61 r.setTop(r.top() - m_pDrawPad->pen().width());
62 r.setRight(r.right() + m_pDrawPad->pen().width());
63 r.setBottom(r.bottom() + m_pDrawPad->pen().width());
64
65 bitBlt(m_pDrawPadCanvas, r.x(), r.y(), m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height());
66 }
67}