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 | |||
@@ -16,68 +16,24 @@ | |||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | 18 | ||
19 | #include <qpainter.h> | ||
20 | #include <qpixmap.h> | ||
21 | |||
22 | RectangleDrawMode::RectangleDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 19 | RectangleDrawMode::RectangleDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : DrawMode(drawPad, drawPadCanvas) | 20 | : ShapeDrawMode(drawPad, drawPadCanvas) |
24 | { | 21 | { |
25 | m_mousePressed = false; | ||
26 | m_polyline.resize(3); | ||
27 | } | 22 | } |
28 | 23 | ||
29 | RectangleDrawMode::~RectangleDrawMode() | 24 | RectangleDrawMode::~RectangleDrawMode() |
30 | { | 25 | { |
31 | } | 26 | } |
32 | 27 | ||
33 | void RectangleDrawMode::mousePressEvent(QMouseEvent* e) | 28 | void RectangleDrawMode::drawFinalShape(QPainter& p) |
34 | { | 29 | { |
35 | m_mousePressed = true; | 30 | p.setPen(m_pDrawPad->pen()); |
36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | 31 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
37 | } | 32 | } |
38 | 33 | ||
39 | void RectangleDrawMode::mouseReleaseEvent(QMouseEvent* e) | 34 | void RectangleDrawMode::drawTemporaryShape(QPainter& p) |
40 | { | 35 | { |
41 | Q_UNUSED(e) | 36 | p.setRasterOp(Qt::NotROP); |
42 | 37 | p.drawRect(QRect(m_polyline[2], m_polyline[1])); | |
43 | QPainter painter; | 38 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
44 | painter.begin(m_pDrawPadCanvas->currentPage()); | ||
45 | painter.setPen(m_pDrawPad->pen()); | ||
46 | painter.drawRect(QRect(m_polyline[2], m_polyline[0])); | ||
47 | painter.end(); | ||
48 | |||
49 | QRect r = m_polyline.boundingRect(); | ||
50 | r = r.normalize(); | ||
51 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | ||
52 | r.setTop(r.top() - m_pDrawPad->pen().width()); | ||
53 | r.setRight(r.right() + m_pDrawPad->pen().width()); | ||
54 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | ||
55 | |||
56 | bitBlt(m_pDrawPadCanvas, r.x(), r.y(), m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | ||
57 | |||
58 | m_mousePressed = false; | ||
59 | } | ||
60 | |||
61 | void RectangleDrawMode::mouseMoveEvent(QMouseEvent* e) | ||
62 | { | ||
63 | if (m_mousePressed) { | ||
64 | QPainter painter; | ||
65 | painter.begin(m_pDrawPadCanvas->currentPage()); | ||
66 | painter.setRasterOp(Qt::NotROP); | ||
67 | m_polyline[0] = e->pos(); | ||
68 | painter.drawRect(QRect(m_polyline[2], m_polyline[1])); | ||
69 | painter.drawRect(QRect(m_polyline[2], m_polyline[0])); | ||
70 | painter.end(); | ||
71 | |||
72 | QRect r = m_polyline.boundingRect(); | ||
73 | r = r.normalize(); | ||
74 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | ||
75 | r.setTop(r.top() - m_pDrawPad->pen().width()); | ||
76 | r.setRight(r.right() + m_pDrawPad->pen().width()); | ||
77 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | ||
78 | |||
79 | bitBlt(m_pDrawPadCanvas, r.x(), r.y(), m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | ||
80 | |||
81 | m_polyline[1] = m_polyline[0]; | ||
82 | } | ||
83 | } | 39 | } |