summaryrefslogtreecommitdiff
authorleseb <leseb>2002-03-27 17:17:06 (UTC)
committer leseb <leseb>2002-03-27 17:17:06 (UTC)
commit7578abbb11ce2dbae3c54ab7051ad2b39d31360b (patch) (unidiff)
treed87912e163039608f6c1c2dfcdab2f99010df118
parent4372bb8e59eb4b0d2fa5fba8f6525dc14873f239 (diff)
downloadopie-7578abbb11ce2dbae3c54ab7051ad2b39d31360b.zip
opie-7578abbb11ce2dbae3c54ab7051ad2b39d31360b.tar.gz
opie-7578abbb11ce2dbae3c54ab7051ad2b39d31360b.tar.bz2
Rename drawmode -> tool
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawmode.cpp28
-rw-r--r--noncore/graphics/drawpad/drawmode.h39
-rw-r--r--noncore/graphics/drawpad/ellipsedrawmode.cpp45
-rw-r--r--noncore/graphics/drawpad/ellipsedrawmode.h30
-rw-r--r--noncore/graphics/drawpad/erasedrawmode.cpp74
-rw-r--r--noncore/graphics/drawpad/erasedrawmode.h36
-rw-r--r--noncore/graphics/drawpad/filldrawmode.cpp88
-rw-r--r--noncore/graphics/drawpad/filldrawmode.h39
-rw-r--r--noncore/graphics/drawpad/linedrawmode.cpp39
-rw-r--r--noncore/graphics/drawpad/linedrawmode.h30
-rw-r--r--noncore/graphics/drawpad/pointdrawmode.cpp73
-rw-r--r--noncore/graphics/drawpad/pointdrawmode.h36
-rw-r--r--noncore/graphics/drawpad/rectangledrawmode.cpp39
-rw-r--r--noncore/graphics/drawpad/rectangledrawmode.h30
-rw-r--r--noncore/graphics/drawpad/shapedrawmode.cpp92
-rw-r--r--noncore/graphics/drawpad/shapedrawmode.h41
16 files changed, 0 insertions, 759 deletions
diff --git a/noncore/graphics/drawpad/drawmode.cpp b/noncore/graphics/drawpad/drawmode.cpp
deleted file mode 100644
index 57fd14b..0000000
--- a/noncore/graphics/drawpad/drawmode.cpp
+++ b/dev/null
@@ -1,28 +0,0 @@
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 "drawmode.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19DrawMode::DrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
20 : QObject()
21{
22 m_pDrawPad = drawPad;
23 m_pDrawPadCanvas = drawPadCanvas;
24}
25
26DrawMode::~DrawMode()
27{
28}
diff --git a/noncore/graphics/drawpad/drawmode.h b/noncore/graphics/drawpad/drawmode.h
deleted file mode 100644
index 01e42cc..0000000
--- a/noncore/graphics/drawpad/drawmode.h
+++ b/dev/null
@@ -1,39 +0,0 @@
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#ifndef DRAWMODE_H
15#define DRAWMODE_H
16
17#include <qobject.h>
18
19class DrawPad;
20class DrawPadCanvas;
21
22class DrawMode : public QObject
23{
24protected:
25 DrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
26
27public:
28 virtual ~DrawMode();
29
30 virtual void mousePressEvent(QMouseEvent* e) = 0;
31 virtual void mouseReleaseEvent(QMouseEvent* e) = 0;
32 virtual void mouseMoveEvent(QMouseEvent* e) = 0;
33
34protected:
35 DrawPad* m_pDrawPad;
36 DrawPadCanvas* m_pDrawPadCanvas;
37};
38
39#endif // DRAWMODE_H
diff --git a/noncore/graphics/drawpad/ellipsedrawmode.cpp b/noncore/graphics/drawpad/ellipsedrawmode.cpp
deleted file mode 100644
index f9cfa73..0000000
--- a/noncore/graphics/drawpad/ellipsedrawmode.cpp
+++ b/dev/null
@@ -1,45 +0,0 @@
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
22EllipseDrawMode::EllipseDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : ShapeDrawMode(drawPad, drawPadCanvas)
24{
25}
26
27EllipseDrawMode::~EllipseDrawMode()
28{
29}
30
31void EllipseDrawMode::drawFinalShape(QPainter& p)
32{
33 p.setRasterOp(Qt::NotROP);
34 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
35 p.setPen(m_pDrawPad->pen());
36 p.setRasterOp(Qt::CopyROP);
37 p.drawEllipse(QRect(m_polyline[2], m_polyline[0]));
38}
39
40void EllipseDrawMode::drawTemporaryShape(QPainter& p)
41{
42 p.setRasterOp(Qt::NotROP);
43 p.drawRect(QRect(m_polyline[2], m_polyline[1]));
44 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
45}
diff --git a/noncore/graphics/drawpad/ellipsedrawmode.h b/noncore/graphics/drawpad/ellipsedrawmode.h
deleted file mode 100644
index 0246caa..0000000
--- a/noncore/graphics/drawpad/ellipsedrawmode.h
+++ b/dev/null
@@ -1,30 +0,0 @@
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#ifndef ELLIPSEDRAWMODE_H
15#define ELLIPSEDRAWMODE_H
16
17#include "shapedrawmode.h"
18
19class EllipseDrawMode : public ShapeDrawMode
20{
21public:
22 EllipseDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
23 ~EllipseDrawMode();
24
25protected:
26 void drawFinalShape(QPainter& p);
27 void drawTemporaryShape(QPainter& p);
28};
29
30#endif // ELLIPSEDRAWMODE_H
diff --git a/noncore/graphics/drawpad/erasedrawmode.cpp b/noncore/graphics/drawpad/erasedrawmode.cpp
deleted file mode 100644
index 0e585cc..0000000
--- a/noncore/graphics/drawpad/erasedrawmode.cpp
+++ b/dev/null
@@ -1,74 +0,0 @@
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 "erasedrawmode.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19#include <qpainter.h>
20#include <qpixmap.h>
21
22EraseDrawMode::EraseDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : DrawMode(drawPad, drawPadCanvas)
24{
25 m_mousePressed = false;
26 m_polyline.resize(3);
27}
28
29EraseDrawMode::~EraseDrawMode()
30{
31}
32
33void EraseDrawMode::mousePressEvent(QMouseEvent* e)
34{
35 m_mousePressed = true;
36 m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
37}
38
39void EraseDrawMode::mouseReleaseEvent(QMouseEvent* e)
40{
41 Q_UNUSED(e)
42
43 m_mousePressed = false;
44}
45
46void EraseDrawMode::mouseMoveEvent(QMouseEvent* e)
47{
48 if (m_mousePressed) {
49 QPainter painter;
50 QPen pen(Qt::white, m_pDrawPad->pen().width());
51 painter.begin(m_pDrawPadCanvas->currentPage());
52 painter.setPen(pen);
53 m_polyline[2] = m_polyline[1];
54 m_polyline[1] = m_polyline[0];
55 m_polyline[0] = e->pos();
56 painter.drawPolyline(m_polyline);
57 painter.end();
58
59 QRect r = m_polyline.boundingRect();
60 r = r.normalize();
61 r.setLeft(r.left() - m_pDrawPad->pen().width());
62 r.setTop(r.top() - m_pDrawPad->pen().width());
63 r.setRight(r.right() + m_pDrawPad->pen().width());
64 r.setBottom(r.bottom() + m_pDrawPad->pen().width());
65
66 QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()),
67 m_pDrawPadCanvas->contentsToViewport(r.bottomRight()));
68
69 bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(),
70 m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height());
71
72 m_pDrawPadCanvas->viewport()->update(viewportRect);
73 }
74}
diff --git a/noncore/graphics/drawpad/erasedrawmode.h b/noncore/graphics/drawpad/erasedrawmode.h
deleted file mode 100644
index c64b010..0000000
--- a/noncore/graphics/drawpad/erasedrawmode.h
+++ b/dev/null
@@ -1,36 +0,0 @@
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#ifndef ERASEDRAWMODE_H
15#define ERASEPOINTDRAWMODE_H
16
17#include "drawmode.h"
18
19#include <qpointarray.h>
20
21class EraseDrawMode : public DrawMode
22{
23public:
24 EraseDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
25 ~EraseDrawMode();
26
27 void mousePressEvent(QMouseEvent* e);
28 void mouseReleaseEvent(QMouseEvent* e);
29 void mouseMoveEvent(QMouseEvent* e);
30
31private:
32 bool m_mousePressed;
33 QPointArray m_polyline;
34};
35
36#endif // ERASEDRAWMODE_H
diff --git a/noncore/graphics/drawpad/filldrawmode.cpp b/noncore/graphics/drawpad/filldrawmode.cpp
deleted file mode 100644
index 6ae0e58..0000000
--- a/noncore/graphics/drawpad/filldrawmode.cpp
+++ b/dev/null
@@ -1,88 +0,0 @@
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 "filldrawmode.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19#include <qimage.h>
20#include <qpixmap.h>
21
22FillDrawMode::FillDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : DrawMode(drawPad, drawPadCanvas)
24{
25}
26
27FillDrawMode::~FillDrawMode()
28{
29}
30
31void FillDrawMode::mousePressEvent(QMouseEvent* e)
32{
33 int x = e->x();
34 int y = e->y();
35
36 m_image = m_pDrawPadCanvas->currentPage()->convertToImage();
37 m_fillRgb = m_pDrawPad->brush().color().rgb();
38 m_oldRgb = m_image.pixel(x, y);
39
40 if (m_oldRgb != m_fillRgb) {
41 fillLine(x, y);
42
43 m_pDrawPadCanvas->currentPage()->convertFromImage(m_image);
44 m_pDrawPadCanvas->viewport()->update();
45 }
46}
47
48void FillDrawMode::mouseReleaseEvent(QMouseEvent* e)
49{
50 Q_UNUSED(e)
51}
52
53void FillDrawMode::mouseMoveEvent(QMouseEvent* e)
54{
55 Q_UNUSED(e)
56}
57
58void FillDrawMode::fillLine(int x, int y)
59{
60 if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) {
61 if (m_image.pixel(x, y) == m_oldRgb) {
62 int x1, x2;
63
64 x1 = x - 1;
65 x2 = x + 1;
66
67 while ((x1 >= 0) && (m_image.pixel(x1, y) == m_oldRgb)) {
68 x1--;
69 }
70
71 while ((x2 < m_image.width()) && (m_image.pixel(x2, y) == m_oldRgb)) {
72 x2++;
73 }
74
75 for (int i = x1 + 1; i < x2; i++) {
76 m_image.setPixel(i, y, m_fillRgb);
77 }
78
79 for (int i = x1 + 1; i < x2; i++) {
80 fillLine(i, y - 1);
81 }
82
83 for (int i = x1 + 1; i < x2; i++) {
84 fillLine(i, y + 1);
85 }
86 }
87 }
88}
diff --git a/noncore/graphics/drawpad/filldrawmode.h b/noncore/graphics/drawpad/filldrawmode.h
deleted file mode 100644
index 604f9c7..0000000
--- a/noncore/graphics/drawpad/filldrawmode.h
+++ b/dev/null
@@ -1,39 +0,0 @@
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#ifndef FILLDRAWMODE_H
15#define FILLDRAWMODE_H
16
17#include "drawmode.h"
18
19#include <qimage.h>
20
21class FillDrawMode : public DrawMode
22{
23public:
24 FillDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
25 ~FillDrawMode();
26
27 void mousePressEvent(QMouseEvent* e);
28 void mouseReleaseEvent(QMouseEvent* e);
29 void mouseMoveEvent(QMouseEvent* e);
30
31private:
32 void fillLine(int x, int y);
33
34 QImage m_image;
35 QRgb m_fillRgb;
36 QRgb m_oldRgb;
37};
38
39#endif // FILLDRAWMODE_H
diff --git a/noncore/graphics/drawpad/linedrawmode.cpp b/noncore/graphics/drawpad/linedrawmode.cpp
deleted file mode 100644
index d432fad..0000000
--- a/noncore/graphics/drawpad/linedrawmode.cpp
+++ b/dev/null
@@ -1,39 +0,0 @@
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 "linedrawmode.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19LineDrawMode::LineDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
20 : ShapeDrawMode(drawPad, drawPadCanvas)
21{
22}
23
24LineDrawMode::~LineDrawMode()
25{
26}
27
28void LineDrawMode::drawFinalShape(QPainter& p)
29{
30 p.setPen(m_pDrawPad->pen());
31 p.drawLine(m_polyline[2], m_polyline[0]);
32}
33
34void LineDrawMode::drawTemporaryShape(QPainter& p)
35{
36 p.setRasterOp(Qt::NotROP);
37 p.drawLine(m_polyline[2], m_polyline[1]);
38 p.drawLine(m_polyline[2], m_polyline[0]);
39}
diff --git a/noncore/graphics/drawpad/linedrawmode.h b/noncore/graphics/drawpad/linedrawmode.h
deleted file mode 100644
index 0ddd0ad..0000000
--- a/noncore/graphics/drawpad/linedrawmode.h
+++ b/dev/null
@@ -1,30 +0,0 @@
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#ifndef LINEDRAWMODE_H
15#define LINEDRAWMODE_H
16
17#include "shapedrawmode.h"
18
19class LineDrawMode : public ShapeDrawMode
20{
21public:
22 LineDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
23 ~LineDrawMode();
24
25protected:
26 void drawFinalShape(QPainter& p);
27 void drawTemporaryShape(QPainter& p);
28};
29
30#endif // LINEDRAWMODE_H
diff --git a/noncore/graphics/drawpad/pointdrawmode.cpp b/noncore/graphics/drawpad/pointdrawmode.cpp
deleted file mode 100644
index e251f1b..0000000
--- a/noncore/graphics/drawpad/pointdrawmode.cpp
+++ b/dev/null
@@ -1,73 +0,0 @@
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 QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()),
66 m_pDrawPadCanvas->contentsToViewport(r.bottomRight()));
67
68 bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(),
69 m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height());
70
71 m_pDrawPadCanvas->viewport()->update(viewportRect);
72 }
73}
diff --git a/noncore/graphics/drawpad/pointdrawmode.h b/noncore/graphics/drawpad/pointdrawmode.h
deleted file mode 100644
index 78da31f..0000000
--- a/noncore/graphics/drawpad/pointdrawmode.h
+++ b/dev/null
@@ -1,36 +0,0 @@
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#ifndef POINTDRAWMODE_H
15#define POINTDRAWMODE_H
16
17#include "drawmode.h"
18
19#include <qpointarray.h>
20
21class PointDrawMode : public DrawMode
22{
23public:
24 PointDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
25 ~PointDrawMode();
26
27 void mousePressEvent(QMouseEvent* e);
28 void mouseReleaseEvent(QMouseEvent* e);
29 void mouseMoveEvent(QMouseEvent* e);
30
31private:
32 bool m_mousePressed;
33 QPointArray m_polyline;
34};
35
36#endif // POINTDRAWMODE_H
diff --git a/noncore/graphics/drawpad/rectangledrawmode.cpp b/noncore/graphics/drawpad/rectangledrawmode.cpp
deleted file mode 100644
index 0226544..0000000
--- a/noncore/graphics/drawpad/rectangledrawmode.cpp
+++ b/dev/null
@@ -1,39 +0,0 @@
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 "rectangledrawmode.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19RectangleDrawMode::RectangleDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
20 : ShapeDrawMode(drawPad, drawPadCanvas)
21{
22}
23
24RectangleDrawMode::~RectangleDrawMode()
25{
26}
27
28void RectangleDrawMode::drawFinalShape(QPainter& p)
29{
30 p.setPen(m_pDrawPad->pen());
31 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
32}
33
34void RectangleDrawMode::drawTemporaryShape(QPainter& p)
35{
36 p.setRasterOp(Qt::NotROP);
37 p.drawRect(QRect(m_polyline[2], m_polyline[1]));
38 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
39}
diff --git a/noncore/graphics/drawpad/rectangledrawmode.h b/noncore/graphics/drawpad/rectangledrawmode.h
deleted file mode 100644
index 186533d..0000000
--- a/noncore/graphics/drawpad/rectangledrawmode.h
+++ b/dev/null
@@ -1,30 +0,0 @@
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#ifndef RECTANGLEDRAWMODE_H
15#define RECTANGLEDRAWMODE_H
16
17#include "shapedrawmode.h"
18
19class RectangleDrawMode : public ShapeDrawMode
20{
21public:
22 RectangleDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
23 ~RectangleDrawMode();
24
25protected:
26 void drawFinalShape(QPainter& p);
27 void drawTemporaryShape(QPainter& p);
28};
29
30#endif // RECTANGLEDRAWMODE_H
diff --git a/noncore/graphics/drawpad/shapedrawmode.cpp b/noncore/graphics/drawpad/shapedrawmode.cpp
deleted file mode 100644
index 8b9877d..0000000
--- a/noncore/graphics/drawpad/shapedrawmode.cpp
+++ b/dev/null
@@ -1,92 +0,0 @@
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 "shapedrawmode.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19#include <qpainter.h>
20#include <qpixmap.h>
21
22ShapeDrawMode::ShapeDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : DrawMode(drawPad, drawPadCanvas)
24{
25 m_mousePressed = false;
26 m_polyline.resize(3);
27}
28
29ShapeDrawMode::~ShapeDrawMode()
30{
31}
32
33void ShapeDrawMode::mousePressEvent(QMouseEvent* e)
34{
35 m_mousePressed = true;
36 m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
37}
38
39void ShapeDrawMode::mouseReleaseEvent(QMouseEvent* e)
40{
41 Q_UNUSED(e)
42
43 QPainter painter;
44 painter.begin(m_pDrawPadCanvas->currentPage());
45 drawFinalShape(painter);
46 painter.end();
47
48 QRect r = m_polyline.boundingRect();
49 r = r.normalize();
50 r.setLeft(r.left() - m_pDrawPad->pen().width());
51 r.setTop(r.top() - m_pDrawPad->pen().width());
52 r.setRight(r.right() + m_pDrawPad->pen().width());
53 r.setBottom(r.bottom() + m_pDrawPad->pen().width());
54
55 QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()),
56 m_pDrawPadCanvas->contentsToViewport(r.bottomRight()));
57
58 bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(),
59 m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height());
60
61 m_pDrawPadCanvas->viewport()->update(viewportRect);
62
63 m_mousePressed = false;
64}
65
66void ShapeDrawMode::mouseMoveEvent(QMouseEvent* e)
67{
68 if (m_mousePressed) {
69 m_polyline[0] = e->pos();
70 QPainter painter;
71 painter.begin(m_pDrawPadCanvas->currentPage());
72 drawTemporaryShape(painter);
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 QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()),
83 m_pDrawPadCanvas->contentsToViewport(r.bottomRight()));
84
85 bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(),
86 m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height());
87
88 m_pDrawPadCanvas->viewport()->update(viewportRect);
89
90 m_polyline[1] = m_polyline[0];
91 }
92}
diff --git a/noncore/graphics/drawpad/shapedrawmode.h b/noncore/graphics/drawpad/shapedrawmode.h
deleted file mode 100644
index 292478f..0000000
--- a/noncore/graphics/drawpad/shapedrawmode.h
+++ b/dev/null
@@ -1,41 +0,0 @@
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#ifndef SHAPEDRAWMODE_H
15#define SHAPEDRAWMODE_H
16
17#include "drawmode.h"
18
19#include <qpointarray.h>
20
21class ShapeDrawMode : public DrawMode
22{
23public:
24 ShapeDrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
25 ~ShapeDrawMode();
26
27 void mousePressEvent(QMouseEvent* e);
28 void mouseReleaseEvent(QMouseEvent* e);
29 void mouseMoveEvent(QMouseEvent* e);
30
31protected:
32 virtual void drawFinalShape(QPainter& p) = 0;
33 virtual void drawTemporaryShape(QPainter& p) = 0;
34
35 QPointArray m_polyline;
36
37private:
38 bool m_mousePressed;
39};
40
41#endif // SHAPEDRAWMODE_H