author | leseb <leseb> | 2002-03-16 22:19:40 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-03-16 22:19:40 (UTC) |
commit | 8111d4bf6281420b7f44ae70c26d2531cfe34401 (patch) (unidiff) | |
tree | 4c106c80125ec35faa57df9d7af492c4b481db58 /noncore/graphics/drawpad/ellipsedrawmode.cpp | |
parent | 54f8d1b709b198dbdedf17dc2b4a8dd4625c5751 (diff) | |
download | opie-8111d4bf6281420b7f44ae70c26d2531cfe34401.zip opie-8111d4bf6281420b7f44ae70c26d2531cfe34401.tar.gz opie-8111d4bf6281420b7f44ae70c26d2531cfe34401.tar.bz2 |
Initial commit
Diffstat (limited to 'noncore/graphics/drawpad/ellipsedrawmode.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/ellipsedrawmode.cpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/noncore/graphics/drawpad/ellipsedrawmode.cpp b/noncore/graphics/drawpad/ellipsedrawmode.cpp new file mode 100644 index 0000000..1051335 --- a/dev/null +++ b/noncore/graphics/drawpad/ellipsedrawmode.cpp | |||
@@ -0,0 +1,86 @@ | |||
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 "ellipsedrawmode.h" | ||
15 | |||
16 | #include "drawpad.h" | ||
17 | #include "drawpadcanvas.h" | ||
18 | |||
19 | #include <qpainter.h> | ||
20 | #include <qpixmap.h> | ||
21 | |||
22 | EllipseDrawMode::EllipseDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | ||
23 | : DrawMode(drawPad, drawPadCanvas) | ||
24 | { | ||
25 | m_mousePressed = false; | ||
26 | m_polyline.resize(3); | ||
27 | } | ||
28 | |||
29 | EllipseDrawMode::~EllipseDrawMode() | ||
30 | { | ||
31 | } | ||
32 | |||
33 | void EllipseDrawMode::mousePressEvent(QMouseEvent* e) | ||
34 | { | ||
35 | m_mousePressed = true; | ||
36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | ||
37 | } | ||
38 | |||
39 | void EllipseDrawMode::mouseReleaseEvent(QMouseEvent* e) | ||
40 | { | ||
41 | Q_UNUSED(e); | ||
42 | |||
43 | QPainter painter; | ||
44 | painter.begin(m_pDrawPadCanvas->currentPage()); | ||
45 | painter.setRasterOp(Qt::NotROP); | ||
46 | painter.drawRect(QRect(m_polyline[2], m_polyline[0])); | ||
47 | painter.setPen(m_pDrawPad->pen()); | ||
48 | painter.setRasterOp(Qt::CopyROP); | ||
49 | painter.drawEllipse(QRect(m_polyline[2], m_polyline[0])); | ||
50 | painter.end(); | ||
51 | |||
52 | QRect r = m_polyline.boundingRect(); | ||
53 | r = r.normalize(); | ||
54 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | ||
55 | r.setTop(r.top() - m_pDrawPad->pen().width()); | ||
56 | r.setRight(r.right() + m_pDrawPad->pen().width()); | ||
57 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | ||
58 | |||
59 | bitBlt(m_pDrawPadCanvas, r.x(), r.y(), m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | ||
60 | |||
61 | m_mousePressed = false; | ||
62 | } | ||
63 | |||
64 | void EllipseDrawMode::mouseMoveEvent(QMouseEvent* e) | ||
65 | { | ||
66 | if (m_mousePressed) { | ||
67 | QPainter painter; | ||
68 | painter.begin(m_pDrawPadCanvas->currentPage()); | ||
69 | painter.setRasterOp(Qt::NotROP); | ||
70 | m_polyline[0] = e->pos(); | ||
71 | painter.drawRect(QRect(m_polyline[2], m_polyline[1])); | ||
72 | painter.drawRect(QRect(m_polyline[2], m_polyline[0])); | ||
73 | painter.end(); | ||
74 | |||
75 | QRect r = m_polyline.boundingRect(); | ||
76 | r = r.normalize(); | ||
77 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | ||
78 | r.setTop(r.top() - m_pDrawPad->pen().width()); | ||
79 | r.setRight(r.right() + m_pDrawPad->pen().width()); | ||
80 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | ||
81 | |||
82 | bitBlt(m_pDrawPadCanvas, r.x(), r.y(), m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | ||
83 | |||
84 | m_polyline[1] = m_polyline[0]; | ||
85 | } | ||
86 | } | ||