summaryrefslogtreecommitdiff
path: root/noncore/graphics/drawpad/pointdrawmode.cpp
authorleseb <leseb>2002-03-16 22:19:40 (UTC)
committer leseb <leseb>2002-03-16 22:19:40 (UTC)
commit8111d4bf6281420b7f44ae70c26d2531cfe34401 (patch) (unidiff)
tree4c106c80125ec35faa57df9d7af492c4b481db58 /noncore/graphics/drawpad/pointdrawmode.cpp
parent54f8d1b709b198dbdedf17dc2b4a8dd4625c5751 (diff)
downloadopie-8111d4bf6281420b7f44ae70c26d2531cfe34401.zip
opie-8111d4bf6281420b7f44ae70c26d2531cfe34401.tar.gz
opie-8111d4bf6281420b7f44ae70c26d2531cfe34401.tar.bz2
Initial commit
Diffstat (limited to 'noncore/graphics/drawpad/pointdrawmode.cpp') (more/less context) (ignore 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}