author | leseb <leseb> | 2002-03-21 17:33:38 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-03-21 17:33:38 (UTC) |
commit | 29baf8dcda3d05d91d340b739de0fdd9e37f5749 (patch) (unidiff) | |
tree | 5f2958a16cc1f065cdef3e31c2c9500f8aac2e7b /noncore/graphics/drawpad/rectangledrawmode.cpp | |
parent | 60c9126183ea72c08ad5cb77b8939812627aae17 (diff) | |
download | opie-29baf8dcda3d05d91d340b739de0fdd9e37f5749.zip opie-29baf8dcda3d05d91d340b739de0fdd9e37f5749.tar.gz opie-29baf8dcda3d05d91d340b739de0fdd9e37f5749.tar.bz2 |
Enable any size pages
Diffstat (limited to 'noncore/graphics/drawpad/rectangledrawmode.cpp') (more/less context) (show 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 | { | ||
35 | m_mousePressed = true; | ||
36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | ||
37 | } | ||
38 | |||
39 | void RectangleDrawMode::mouseReleaseEvent(QMouseEvent* e) | ||
40 | { | 29 | { |
41 | Q_UNUSED(e) | 30 | p.setPen(m_pDrawPad->pen()); |
42 | 31 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); | |
43 | QPainter painter; | ||
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 | } | 32 | } |
60 | 33 | ||
61 | void RectangleDrawMode::mouseMoveEvent(QMouseEvent* e) | 34 | void RectangleDrawMode::drawTemporaryShape(QPainter& p) |
62 | { | 35 | { |
63 | if (m_mousePressed) { | 36 | p.setRasterOp(Qt::NotROP); |
64 | QPainter painter; | 37 | p.drawRect(QRect(m_polyline[2], m_polyline[1])); |
65 | painter.begin(m_pDrawPadCanvas->currentPage()); | 38 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
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 | } |