summaryrefslogtreecommitdiff
authorleseb <leseb>2002-03-27 17:09:29 (UTC)
committer leseb <leseb>2002-03-27 17:09:29 (UTC)
commit4372bb8e59eb4b0d2fa5fba8f6525dc14873f239 (patch) (unidiff)
tree6947938ca5d22d3a373741ba3acfc20e8dd67729
parentfb056735d9a021787f83c6a791225a7ca70c1eb5 (diff)
downloadopie-4372bb8e59eb4b0d2fa5fba8f6525dc14873f239.zip
opie-4372bb8e59eb4b0d2fa5fba8f6525dc14873f239.tar.gz
opie-4372bb8e59eb4b0d2fa5fba8f6525dc14873f239.tar.bz2
Import/export dialogs, improved new page dialog, new tools, ...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/colorpanel.cpp22
-rw-r--r--noncore/graphics/drawpad/colorpanel.h3
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp317
-rw-r--r--noncore/graphics/drawpad/drawpad.h41
-rw-r--r--noncore/graphics/drawpad/drawpad.pro40
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp144
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h5
-rw-r--r--noncore/graphics/drawpad/ellipsetool.cpp45
-rw-r--r--noncore/graphics/drawpad/ellipsetool.h30
-rw-r--r--noncore/graphics/drawpad/erasetool.cpp74
-rw-r--r--noncore/graphics/drawpad/erasetool.h36
-rw-r--r--noncore/graphics/drawpad/exportdialog.cpp173
-rw-r--r--noncore/graphics/drawpad/exportdialog.h58
-rw-r--r--noncore/graphics/drawpad/filledellipsetool.cpp46
-rw-r--r--noncore/graphics/drawpad/filledellipsetool.h30
-rw-r--r--noncore/graphics/drawpad/filledrectangletool.cpp43
-rw-r--r--noncore/graphics/drawpad/filledrectangletool.h30
-rw-r--r--noncore/graphics/drawpad/filltool.cpp88
-rw-r--r--noncore/graphics/drawpad/filltool.h39
-rw-r--r--noncore/graphics/drawpad/importdialog.cpp41
-rw-r--r--noncore/graphics/drawpad/importdialog.h36
-rw-r--r--noncore/graphics/drawpad/linetool.cpp42
-rw-r--r--noncore/graphics/drawpad/linetool.h30
-rw-r--r--noncore/graphics/drawpad/newpagedialog.cpp83
-rw-r--r--noncore/graphics/drawpad/newpagedialog.h17
-rw-r--r--noncore/graphics/drawpad/pointtool.cpp73
-rw-r--r--noncore/graphics/drawpad/pointtool.h36
-rw-r--r--noncore/graphics/drawpad/rectangletool.cpp42
-rw-r--r--noncore/graphics/drawpad/rectangletool.h30
-rw-r--r--noncore/graphics/drawpad/shapetool.cpp92
-rw-r--r--noncore/graphics/drawpad/shapetool.h41
-rw-r--r--noncore/graphics/drawpad/tool.cpp28
-rw-r--r--noncore/graphics/drawpad/tool.h39
33 files changed, 1679 insertions, 215 deletions
diff --git a/noncore/graphics/drawpad/colorpanel.cpp b/noncore/graphics/drawpad/colorpanel.cpp
index 1db0d7b..9327012 100644
--- a/noncore/graphics/drawpad/colorpanel.cpp
+++ b/noncore/graphics/drawpad/colorpanel.cpp
@@ -1,134 +1,120 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "colorpanel.h" 14#include "colorpanel.h"
15 15
16#include <qlayout.h> 16#include <qlayout.h>
17#include <qpainter.h> 17#include <qpainter.h>
18 18
19ColorPanelButton::ColorPanelButton(const QColor& color, QWidget* parent, const char* name) 19ColorPanelButton::ColorPanelButton(const QColor& color, QWidget* parent, const char* name)
20 : QFrame(parent, name) 20 : QFrame(parent, name)
21{ 21{
22 m_color = color; 22 m_color = color;
23 23
24 setFixedSize(16, 16); 24 setFixedSize(16, 16);
25 setActive(false); 25 setFrameStyle(NoFrame);
26} 26}
27 27
28ColorPanelButton::~ColorPanelButton() 28ColorPanelButton::~ColorPanelButton()
29{ 29{
30} 30}
31 31
32void ColorPanelButton::setActive(bool active)
33{
34 m_active = active;
35
36 if (m_active) {
37 setFrameStyle(Panel | Sunken);
38 } else {
39 setFrameStyle(NoFrame);
40 }
41}
42
43void ColorPanelButton::enterEvent(QEvent* e) 32void ColorPanelButton::enterEvent(QEvent* e)
44{ 33{
45 Q_UNUSED(e) 34 Q_UNUSED(e)
46 35
47 if (!m_active) { 36 setFrameStyle(Panel | Sunken);
48 setFrameStyle(Panel | Sunken);
49 }
50} 37}
51 38
52void ColorPanelButton::leaveEvent(QEvent* e) 39void ColorPanelButton::leaveEvent(QEvent* e)
53{ 40{
54 Q_UNUSED(e) 41 Q_UNUSED(e)
55 42
56 if (!m_active) { 43 setFrameStyle(NoFrame);
57 setFrameStyle(NoFrame);
58 }
59} 44}
60 45
61void ColorPanelButton::paintEvent(QPaintEvent* e) 46void ColorPanelButton::paintEvent(QPaintEvent* e)
62{ 47{
63 QFrame::paintEvent(e); 48 QFrame::paintEvent(e);
64 49
65 QPainter painter; 50 QPainter painter;
66 painter.begin(this); 51 painter.begin(this);
67 painter.fillRect(2, 2, 12, 12, m_color); 52 painter.fillRect(2, 2, 12, 12, m_color);
68 painter.setPen(Qt::black); 53 painter.setPen(Qt::black);
69 painter.drawRect(2, 2, 12, 12); 54 painter.drawRect(2, 2, 12, 12);
70 painter.end(); 55 painter.end();
71} 56}
72 57
73void ColorPanelButton::mouseReleaseEvent(QMouseEvent* e) 58void ColorPanelButton::mouseReleaseEvent(QMouseEvent* e)
74{ 59{
75 Q_UNUSED(e) 60 Q_UNUSED(e)
76 61
77 emit selected(m_color); 62 emit selected(m_color);
78} 63}
79 64
80ColorPanel::ColorPanel(QWidget* parent, const char* name) 65ColorPanel::ColorPanel(QWidget* parent, const char* name)
81 : QWidget(parent, name) 66 : QWidget(parent, name)
82{ 67{
83 m_pGridLayout = new QGridLayout(this, 5, 6); 68 m_pGridLayout = new QGridLayout(this, 5, 6);
84 69
85 addColor(QColor(255, 255, 255), 0, 1); 70 addColor(QColor(255, 255, 255), 0, 1);
86 addColor(QColor(192, 192, 192), 0, 2); 71 addColor(QColor(192, 192, 192), 0, 2);
87 addColor(QColor(128, 128, 128), 0, 3); 72 addColor(QColor(128, 128, 128), 0, 3);
88 addColor(QColor(64, 64, 64), 0, 4); 73 addColor(QColor(64, 64, 64), 0, 4);
89 addColor(QColor(0, 0, 0), 0, 5); 74 addColor(QColor(0, 0, 0), 0, 5);
90 75
91 addColor(QColor(255, 0, 0), 1, 0); 76 addColor(QColor(255, 0, 0), 1, 0);
92 addColor(QColor(255, 128, 0), 1, 1); 77 addColor(QColor(255, 128, 0), 1, 1);
93 addColor(QColor(255, 255, 0), 1, 2); 78 addColor(QColor(255, 255, 0), 1, 2);
94 addColor(QColor(128, 255, 0), 1, 3); 79 addColor(QColor(128, 255, 0), 1, 3);
95 addColor(QColor(0, 255, 0), 1, 4); 80 addColor(QColor(0, 255, 0), 1, 4);
96 addColor(QColor(0, 255, 128), 1, 5); 81 addColor(QColor(0, 255, 128), 1, 5);
97 82
98 addColor(QColor(128, 0, 0), 2, 0); 83 addColor(QColor(128, 0, 0), 2, 0);
99 addColor(QColor(128, 64, 0), 2, 1); 84 addColor(QColor(128, 64, 0), 2, 1);
100 addColor(QColor(128, 128, 0), 2, 2); 85 addColor(QColor(128, 128, 0), 2, 2);
101 addColor(QColor(64, 128, 0), 2, 3); 86 addColor(QColor(64, 128, 0), 2, 3);
102 addColor(QColor(0, 128, 0), 2, 4); 87 addColor(QColor(0, 128, 0), 2, 4);
103 addColor(QColor(0, 128, 64), 2, 5); 88 addColor(QColor(0, 128, 64), 2, 5);
104 89
105 addColor(QColor(0, 255, 255), 3, 0); 90 addColor(QColor(0, 255, 255), 3, 0);
106 addColor(QColor(0, 128, 255), 3, 1); 91 addColor(QColor(0, 128, 255), 3, 1);
107 addColor(QColor(0, 0, 255), 3, 2); 92 addColor(QColor(0, 0, 255), 3, 2);
108 addColor(QColor(128, 0, 255), 3, 3); 93 addColor(QColor(128, 0, 255), 3, 3);
109 addColor(QColor(255, 0, 255), 3, 4); 94 addColor(QColor(255, 0, 255), 3, 4);
110 addColor(QColor(255, 0, 128), 3, 5); 95 addColor(QColor(255, 0, 128), 3, 5);
111 96
112 addColor(QColor(0, 128, 128), 4, 0); 97 addColor(QColor(0, 128, 128), 4, 0);
113 addColor(QColor(0, 64, 128), 4, 1); 98 addColor(QColor(0, 64, 128), 4, 1);
114 addColor(QColor(0, 0, 128), 4, 2); 99 addColor(QColor(0, 0, 128), 4, 2);
115 addColor(QColor(64, 0, 128), 4, 3); 100 addColor(QColor(64, 0, 128), 4, 3);
116 addColor(QColor(128, 0, 128), 4, 4); 101 addColor(QColor(128, 0, 128), 4, 4);
117 addColor(QColor(128, 0, 64), 4, 5); 102 addColor(QColor(128, 0, 64), 4, 5);
118} 103}
119 104
120ColorPanel::~ColorPanel() 105ColorPanel::~ColorPanel()
121{ 106{
122} 107}
123 108
124void ColorPanel::addColor(const QColor& color, int row, int col) 109void ColorPanel::addColor(const QColor& color, int row, int col)
125{ 110{
126 ColorPanelButton* panelButton = new ColorPanelButton(color, this); 111 ColorPanelButton* panelButton = new ColorPanelButton(color, this);
127 connect(panelButton, SIGNAL(selected(const QColor&)), this, SLOT(buttonSelected(const QColor&))); 112 connect(panelButton, SIGNAL(selected(const QColor&)), this, SLOT(buttonSelected(const QColor&)));
113
128 m_pGridLayout->addWidget(panelButton, row, col); 114 m_pGridLayout->addWidget(panelButton, row, col);
129} 115}
130 116
131void ColorPanel::buttonSelected(const QColor& color) 117void ColorPanel::buttonSelected(const QColor& color)
132{ 118{
133 emit colorSelected(color); 119 emit colorSelected(color);
134} 120}
diff --git a/noncore/graphics/drawpad/colorpanel.h b/noncore/graphics/drawpad/colorpanel.h
index 05364c1..4664879 100644
--- a/noncore/graphics/drawpad/colorpanel.h
+++ b/noncore/graphics/drawpad/colorpanel.h
@@ -1,65 +1,62 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#ifndef COLORPANEL_H 14#ifndef COLORPANEL_H
15#define COLORPANEL_H 15#define COLORPANEL_H
16 16
17#include <qframe.h> 17#include <qframe.h>
18#include <qwidget.h> 18#include <qwidget.h>
19 19
20class QGridLayout; 20class QGridLayout;
21 21
22class ColorPanelButton : public QFrame 22class ColorPanelButton : public QFrame
23{ 23{
24 Q_OBJECT 24 Q_OBJECT
25 25
26public: 26public:
27 ColorPanelButton(const QColor& color, QWidget* parent = 0, const char* name = 0); 27 ColorPanelButton(const QColor& color, QWidget* parent = 0, const char* name = 0);
28 ~ColorPanelButton(); 28 ~ColorPanelButton();
29 29
30 void setActive(bool active);
31
32 void enterEvent(QEvent* e); 30 void enterEvent(QEvent* e);
33 void leaveEvent(QEvent* e); 31 void leaveEvent(QEvent* e);
34 void paintEvent(QPaintEvent* e); 32 void paintEvent(QPaintEvent* e);
35 void mouseReleaseEvent(QMouseEvent* e); 33 void mouseReleaseEvent(QMouseEvent* e);
36 34
37signals: 35signals:
38 void selected(const QColor&); 36 void selected(const QColor&);
39 37
40private: 38private:
41 QColor m_color; 39 QColor m_color;
42 bool m_active;
43}; 40};
44 41
45class ColorPanel : public QWidget 42class ColorPanel : public QWidget
46{ 43{
47 Q_OBJECT 44 Q_OBJECT
48 45
49public: 46public:
50 ColorPanel(QWidget* parent = 0, const char* name = 0); 47 ColorPanel(QWidget* parent = 0, const char* name = 0);
51 ~ColorPanel(); 48 ~ColorPanel();
52 49
53 void addColor(const QColor& color, int row, int col); 50 void addColor(const QColor& color, int row, int col);
54 51
55public slots: 52public slots:
56 void buttonSelected(const QColor& color); 53 void buttonSelected(const QColor& color);
57 54
58signals: 55signals:
59 void colorSelected(const QColor&); 56 void colorSelected(const QColor&);
60 57
61private: 58private:
62 QGridLayout* m_pGridLayout; 59 QGridLayout* m_pGridLayout;
63}; 60};
64 61
65#endif // COLORPANEL_H 62#endif // COLORPANEL_H
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index e94187f..5c7e541 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -1,390 +1,503 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "drawpad.h" 14#include "drawpad.h"
15 15
16#include "colordialog.h" 16#include "colordialog.h"
17#include "colorpanel.h" 17#include "colorpanel.h"
18#include "drawpadcanvas.h" 18#include "drawpadcanvas.h"
19#include "ellipsedrawmode.h" 19#include "ellipsetool.h"
20#include "erasedrawmode.h" 20#include "erasetool.h"
21#include "filldrawmode.h" 21#include "exportdialog.h"
22#include "linedrawmode.h" 22#include "filledellipsetool.h"
23#include "pointdrawmode.h" 23#include "filledrectangletool.h"
24#include "rectangledrawmode.h" 24#include "filltool.h"
25 25#include "importdialog.h"
26#include "linetool.h"
27#include "pointtool.h"
28#include "rectangletool.h"
29
30#include <qpe/applnk.h>
26#include <qpe/global.h> 31#include <qpe/global.h>
27#include <qpe/qpemenubar.h> 32#include <qpe/qpemenubar.h>
28#include <qpe/qpetoolbar.h> 33#include <qpe/qpetoolbar.h>
29#include <qpe/resource.h> 34#include <qpe/resource.h>
30 35
31#include <qaction.h> 36#include <qaction.h>
32#include <qfile.h> 37#include <qfile.h>
33#include <qpainter.h> 38#include <qpainter.h>
34#include <qspinbox.h> 39#include <qspinbox.h>
35#include <qtoolbutton.h> 40#include <qtoolbutton.h>
36#include <qtooltip.h> 41#include <qtooltip.h>
37 42
38DrawPad::DrawPad(QWidget* parent, const char* name) 43DrawPad::DrawPad(QWidget* parent, const char* name)
39 : QMainWindow(parent, name) 44 : QMainWindow(parent, name)
40{ 45{
41 // init members 46 // init members
42 47
43 m_pDrawPadCanvas = new DrawPadCanvas(this, this); 48 m_pDrawPadCanvas = new DrawPadCanvas(this, this);
44 49
45 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); 50 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons()));
46 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); 51 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption()));
47 connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); 52 connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons()));
48 53
49 setCentralWidget(m_pDrawPadCanvas); 54 setCentralWidget(m_pDrawPadCanvas);
50 55
51 // init menu 56 // init menu
52 57
53 setToolBarsMovable(false); 58 setToolBarsMovable(false);
54 59
55 QPEToolBar* menuToolBar = new QPEToolBar(this); 60 QPEToolBar* menuToolBar = new QPEToolBar(this);
56 QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); 61 QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar);
57 62
58 QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar); 63 QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar);
59 64
60 QAction* clearAllAction = new QAction(tr("Clear All"), QString::null, 0, this); 65 QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
61 connect(clearAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearAll())); 66 connect(deleteAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deleteAll()));
62 clearAllAction->addTo(toolsPopupMenu); 67 deleteAllAction->addTo(toolsPopupMenu);
63 68
64 toolsPopupMenu->insertSeparator(); 69 toolsPopupMenu->insertSeparator();
65 70
66 QAction* setOptionsAction = new QAction(tr("Options"), tr("Options..."), 0, this); 71 QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this);
67 setOptionsAction->addTo(toolsPopupMenu); 72 connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage()));
73 importPageAction->addTo(toolsPopupMenu);
74
75 QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this);
76 connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage()));
77 exportPageAction->addTo(toolsPopupMenu);
68 78
69 menuBar->insertItem(tr("Tools"), toolsPopupMenu); 79 menuBar->insertItem(tr("Tools"), toolsPopupMenu);
70 80
71 // init page toolbar 81 // init page toolbar
72 82
73 QPEToolBar* pageToolBar = new QPEToolBar(this); 83 QPEToolBar* pageToolBar = new QPEToolBar(this);
74 84
75 QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); 85 QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this);
76 connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage())); 86 connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage()));
77 newPageAction->addTo(pageToolBar); 87 newPageAction->addTo(pageToolBar);
78 88
79 QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); 89 QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this);
80 connect(clearPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearPage())); 90 connect(clearPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearPage()));
81 clearPageAction->addTo(pageToolBar); 91 clearPageAction->addTo(pageToolBar);
82 92
83 QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); 93 QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this);
84 connect(deletePageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deletePage())); 94 connect(deletePageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deletePage()));
85 deletePageAction->addTo(pageToolBar); 95 deletePageAction->addTo(pageToolBar);
86 96
87 QPEToolBar* emptyToolBar = new QPEToolBar(this); 97 QPEToolBar* emptyToolBar = new QPEToolBar(this);
88 emptyToolBar->setHorizontalStretchable(true); 98 emptyToolBar->setHorizontalStretchable(true);
89 99
90 // init navigation toolbar 100 // init navigation toolbar
91 101
92 QPEToolBar* navigationToolBar = new QPEToolBar(this); 102 QPEToolBar* navigationToolBar = new QPEToolBar(this);
93 103
94 m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); 104 m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this);
95 connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); 105 connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo()));
96 m_pUndoAction->addTo(navigationToolBar); 106 m_pUndoAction->addTo(navigationToolBar);
97 107
98 m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); 108 m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this);
99 connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); 109 connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo()));
100 m_pRedoAction->addTo(navigationToolBar); 110 m_pRedoAction->addTo(navigationToolBar);
101 111
102 m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); 112 m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this);
103 connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); 113 connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage()));
104 m_pFirstPageAction->addTo(navigationToolBar); 114 m_pFirstPageAction->addTo(navigationToolBar);
105 115
106 m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); 116 m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this);
107 connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); 117 connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage()));
108 m_pPreviousPageAction->addTo(navigationToolBar); 118 m_pPreviousPageAction->addTo(navigationToolBar);
109 119
110 m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); 120 m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this);
111 connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); 121 connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage()));
112 m_pNextPageAction->addTo(navigationToolBar); 122 m_pNextPageAction->addTo(navigationToolBar);
113 123
114 m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); 124 m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this);
115 connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); 125 connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage()));
116 m_pLastPageAction->addTo(navigationToolBar); 126 m_pLastPageAction->addTo(navigationToolBar);
117 127
118 // init draw mode toolbar 128 // init draw mode toolbar
119 129
120 QPEToolBar* drawModeToolBar = new QPEToolBar(this); 130 QPEToolBar* drawModeToolBar = new QPEToolBar(this);
121 131
122 m_pPointDrawModeAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), QString::null, 0, this); 132 m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), QString::null, 0, this);
123 m_pPointDrawModeAction->setToggleAction(true); 133 m_pPointToolAction->setToggleAction(true);
124 connect(m_pPointDrawModeAction, SIGNAL(activated()), this, SLOT(setPointDrawMode())); 134 connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool()));
125 m_pPointDrawModeAction->addTo(drawModeToolBar); 135 m_pPointToolAction->addTo(drawModeToolBar);
136
137 m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), QString::null, 0, this);
138 m_pLineToolAction->setToggleAction(true);
139 connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool()));
140 m_pLineToolAction->addTo(drawModeToolBar);
141
142 m_pRectangleToolButton = new QToolButton(drawModeToolBar);
143 m_pRectangleToolButton->setToggleButton(true);
144
145 QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton);
146
147 m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this);
148 connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool()));
149 m_pRectangleToolAction->addTo(rectanglePopupMenu);
126 150
127 m_pLineDrawModeAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), QString::null, 0, this); 151 m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this);
128 m_pLineDrawModeAction->setToggleAction(true); 152 connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool()));
129 connect(m_pLineDrawModeAction, SIGNAL(activated()), this, SLOT(setLineDrawMode())); 153 m_pFilledRectangleToolAction->addTo(rectanglePopupMenu);
130 m_pLineDrawModeAction->addTo(drawModeToolBar);
131 154
132 m_pRectangleDrawModeAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), QString::null, 0, this); 155 m_pRectangleToolButton->setPopup(rectanglePopupMenu);
133 m_pRectangleDrawModeAction->setToggleAction(true);
134 connect(m_pRectangleDrawModeAction, SIGNAL(activated()), this, SLOT(setRectangleDrawMode()));
135 m_pRectangleDrawModeAction->addTo(drawModeToolBar);
136 156
137 m_pEllipseDrawModeAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), QString::null, 0, this); 157 m_pEllipseToolButton = new QToolButton(drawModeToolBar);
138 m_pEllipseDrawModeAction->setToggleAction(true); 158 m_pEllipseToolButton->setToggleButton(true);
139 connect(m_pEllipseDrawModeAction, SIGNAL(activated()), this, SLOT(setEllipseDrawMode()));
140 m_pEllipseDrawModeAction->addTo(drawModeToolBar);
141 159
142 m_pFillDrawModeAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); 160 QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton);
143 m_pFillDrawModeAction->setToggleAction(true);
144 connect(m_pFillDrawModeAction, SIGNAL(activated()), this, SLOT(setFillDrawMode()));
145 m_pFillDrawModeAction->addTo(drawModeToolBar);
146 161
147 m_pEraseDrawModeAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); 162 m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this);
148 m_pEraseDrawModeAction->setToggleAction(true); 163 connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool()));
149 connect(m_pEraseDrawModeAction, SIGNAL(activated()), this, SLOT(setEraseDrawMode())); 164 m_pEllipseToolAction->addTo(ellipsePopupMenu);
150 m_pEraseDrawModeAction->addTo(drawModeToolBar);
151 165
152 m_pDrawMode = 0; 166 m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this);
153 setPointDrawMode(); 167 connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool()));
168 m_pFilledEllipseToolAction->addTo(ellipsePopupMenu);
169
170 m_pEllipseToolButton->setPopup(ellipsePopupMenu);
171
172 m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this);
173 m_pFillToolAction->setToggleAction(true);
174 connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool()));
175 m_pFillToolAction->addTo(drawModeToolBar);
176
177 m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this);
178 m_pEraseToolAction->setToggleAction(true);
179 connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool()));
180 m_pEraseToolAction->addTo(drawModeToolBar);
181
182 m_pTool = 0;
183 setRectangleTool();
184 setEllipseTool();
185 setPointTool();
154 186
155 emptyToolBar = new QPEToolBar(this); 187 emptyToolBar = new QPEToolBar(this);
156 emptyToolBar->setHorizontalStretchable(true); 188 emptyToolBar->setHorizontalStretchable(true);
157 emptyToolBar->addSeparator(); 189 emptyToolBar->addSeparator();
158 190
159 // init draw parameters toolbar 191 // init draw parameters toolbar
160 192
161 QPEToolBar* drawParametersToolBar = new QPEToolBar(this); 193 QPEToolBar* drawParametersToolBar = new QPEToolBar(this);
162 194
163 QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); 195 QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar);
164 connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); 196 connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int)));
165 197
198 QToolTip::add(penWidthSpinBox, tr("Pen Width"));
166 penWidthSpinBox->setValue(1); 199 penWidthSpinBox->setValue(1);
200 penWidthSpinBox->setFocusPolicy(QWidget::NoFocus);
167 201
168 m_pPenColorToolButton = new QToolButton(drawParametersToolBar); 202 m_pPenColorToolButton = new QToolButton(drawParametersToolBar);
169 m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); 203 m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png"));
170 204
171 QPopupMenu* penColorPopupMenu = new QPopupMenu(m_pPenColorToolButton); 205 QPopupMenu* penColorPopupMenu = new QPopupMenu(m_pPenColorToolButton);
172 206
173 ColorPanel* penColorPanel = new ColorPanel(penColorPopupMenu); 207 ColorPanel* penColorPanel = new ColorPanel(penColorPopupMenu);
174 connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); 208 connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&)));
175 penColorPopupMenu->insertItem(penColorPanel);
176 209
210 penColorPopupMenu->insertItem(penColorPanel);
177 penColorPopupMenu->insertSeparator(); 211 penColorPopupMenu->insertSeparator();
178 212
179 QAction* choosePenColorAction = new QAction(tr("More"), tr("More..."), 0, this); 213 QAction* choosePenColorAction = new QAction(tr("More"), tr("More..."), 0, this);
180 connect(choosePenColorAction, SIGNAL(activated()), this, SLOT(choosePenColor())); 214 connect(choosePenColorAction, SIGNAL(activated()), this, SLOT(choosePenColor()));
181 choosePenColorAction->addTo(penColorPopupMenu); 215 choosePenColorAction->addTo(penColorPopupMenu);
182 216
183 QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); 217 QToolTip::add(m_pPenColorToolButton, tr("Pen Color"));
184 m_pPenColorToolButton->setPopup(penColorPopupMenu); 218 m_pPenColorToolButton->setPopup(penColorPopupMenu);
185 m_pPenColorToolButton->setPopupDelay(0); 219 m_pPenColorToolButton->setPopupDelay(0);
186 220
187 penColorPopupMenu->activateItemAt(0); 221 penColorPanel->buttonSelected(Qt::black);
188 222
189 m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); 223 m_pBrushColorToolButton = new QToolButton(drawParametersToolBar);
190 m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png")); 224 m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png"));
191 225
192 QPopupMenu* brushColorPopupMenu = new QPopupMenu(m_pBrushColorToolButton); 226 QPopupMenu* brushColorPopupMenu = new QPopupMenu(m_pBrushColorToolButton);
193 227
194 ColorPanel* brushColorPanel = new ColorPanel(brushColorPopupMenu); 228 ColorPanel* brushColorPanel = new ColorPanel(brushColorPopupMenu);
195 connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); 229 connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&)));
196 brushColorPopupMenu->insertItem(brushColorPanel);
197 230
231 brushColorPopupMenu->insertItem(brushColorPanel);
198 brushColorPopupMenu->insertSeparator(); 232 brushColorPopupMenu->insertSeparator();
199 233
200 QAction* chooseBrushColorAction = new QAction(tr("More"), tr("More..."), 0, this); 234 QAction* chooseBrushColorAction = new QAction(tr("More"), tr("More..."), 0, this);
201 connect(chooseBrushColorAction, SIGNAL(activated()), this, SLOT(chooseBrushColor())); 235 connect(chooseBrushColorAction, SIGNAL(activated()), this, SLOT(chooseBrushColor()));
202 chooseBrushColorAction->addTo(brushColorPopupMenu); 236 chooseBrushColorAction->addTo(brushColorPopupMenu);
203 237
204 QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); 238 QToolTip::add(m_pBrushColorToolButton, tr("Fill Color"));
205 m_pBrushColorToolButton->setPopup(brushColorPopupMenu); 239 m_pBrushColorToolButton->setPopup(brushColorPopupMenu);
206 m_pBrushColorToolButton->setPopupDelay(0); 240 m_pBrushColorToolButton->setPopupDelay(0);
207 241
208 brushColorPopupMenu->activateItemAt(1); 242 brushColorPanel->buttonSelected(Qt::white);
209 243
210 // init pages 244 // init pages
211 245
212 QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); 246 QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
213 247
214 if (file.open(IO_ReadOnly)) { 248 if (file.open(IO_ReadOnly)) {
215 m_pDrawPadCanvas->load(&file); 249 m_pDrawPadCanvas->load(&file);
216 file.close(); 250 file.close();
217 } else { 251 } else {
218 m_pDrawPadCanvas->initialPage(); 252 m_pDrawPadCanvas->initialPage();
219 } 253 }
220} 254}
221 255
222DrawPad::~DrawPad() 256DrawPad::~DrawPad()
223{ 257{
224 QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); 258 QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
225 259
226 if (file.open(IO_WriteOnly)) { 260 if (file.open(IO_WriteOnly)) {
227 m_pDrawPadCanvas->save(&file); 261 m_pDrawPadCanvas->save(&file);
228 file.close(); 262 file.close();
229 } 263 }
230} 264}
231 265
232void DrawPad::setPointDrawMode() 266void DrawPad::setPointTool()
267{
268 if (m_pTool) {
269 delete m_pTool;
270 }
271
272 m_pTool = new PointTool(this, m_pDrawPadCanvas);
273
274 m_pPointToolAction->setOn(true);
275 m_pLineToolAction->setOn(false);
276 m_pRectangleToolButton->setOn(false);
277 m_pEllipseToolButton->setOn(false);
278 m_pFillToolAction->setOn(false);
279 m_pEraseToolAction->setOn(false);
280}
281
282void DrawPad::setLineTool()
283{
284 if (m_pTool) {
285 delete m_pTool;
286 }
287
288 m_pTool = new LineTool(this, m_pDrawPadCanvas);
289
290 m_pPointToolAction->setOn(false);
291 m_pLineToolAction->setOn(true);
292 m_pRectangleToolButton->setOn(false);
293 m_pEllipseToolButton->setOn(false);
294 m_pFillToolAction->setOn(false);
295 m_pEraseToolAction->setOn(false);
296}
297
298void DrawPad::setRectangleTool()
233{ 299{
234 if (m_pDrawMode) { 300 if (m_pTool) {
235 delete m_pDrawMode; 301 delete m_pTool;
236 } 302 }
237 303
238 m_pDrawMode = new PointDrawMode(this, m_pDrawPadCanvas); 304 m_pTool = new RectangleTool(this, m_pDrawPadCanvas);
239 305
240 m_pPointDrawModeAction->setOn(true); 306 m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet());
241 m_pLineDrawModeAction->setOn(false); 307 QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text());
242 m_pRectangleDrawModeAction->setOn(false); 308
243 m_pEllipseDrawModeAction->setOn(false); 309 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0);
244 m_pFillDrawModeAction->setOn(false); 310 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated()));
245 m_pEraseDrawModeAction->setOn(false); 311
312 m_pPointToolAction->setOn(false);
313 m_pLineToolAction->setOn(false);
314 m_pRectangleToolButton->setOn(true);
315 m_pEllipseToolButton->setOn(false);
316 m_pFillToolAction->setOn(false);
317 m_pEraseToolAction->setOn(false);
246} 318}
247 319
248void DrawPad::setLineDrawMode() 320void DrawPad::setFilledRectangleTool()
249{ 321{
250 if (m_pDrawMode) { 322 if (m_pTool) {
251 delete m_pDrawMode; 323 delete m_pTool;
252 } 324 }
253 325
254 m_pDrawMode = new LineDrawMode(this, m_pDrawPadCanvas); 326 m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas);
327
328 m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet());
329 QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text());
255 330
256 m_pPointDrawModeAction->setOn(false); 331 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0);
257 m_pLineDrawModeAction->setOn(true); 332 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated()));
258 m_pRectangleDrawModeAction->setOn(false); 333
259 m_pEllipseDrawModeAction->setOn(false); 334 m_pPointToolAction->setOn(false);
260 m_pFillDrawModeAction->setOn(false); 335 m_pLineToolAction->setOn(false);
261 m_pEraseDrawModeAction->setOn(false); 336 m_pRectangleToolButton->setOn(true);
337 m_pEllipseToolButton->setOn(false);
338 m_pFillToolAction->setOn(false);
339 m_pEraseToolAction->setOn(false);
262} 340}
263 341
264void DrawPad::setRectangleDrawMode() 342void DrawPad::setEllipseTool()
265{ 343{
266 if (m_pDrawMode) { 344 if (m_pTool) {
267 delete m_pDrawMode; 345 delete m_pTool;
268 } 346 }
269 347
270 m_pDrawMode = new RectangleDrawMode(this, m_pDrawPadCanvas); 348 m_pTool = new EllipseTool(this, m_pDrawPadCanvas);
349
350 m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet());
351 QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text());
352
353 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0);
354 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated()));
271 355
272 m_pPointDrawModeAction->setOn(false); 356 m_pPointToolAction->setOn(false);
273 m_pLineDrawModeAction->setOn(false); 357 m_pLineToolAction->setOn(false);
274 m_pRectangleDrawModeAction->setOn(true); 358 m_pRectangleToolButton->setOn(false);
275 m_pEllipseDrawModeAction->setOn(false); 359 m_pEllipseToolButton->setOn(true);
276 m_pFillDrawModeAction->setOn(false); 360 m_pFillToolAction->setOn(false);
277 m_pEraseDrawModeAction->setOn(false); 361 m_pEraseToolAction->setOn(false);
278} 362}
279 363
280void DrawPad::setEllipseDrawMode() 364void DrawPad::setFilledEllipseTool()
281{ 365{
282 if (m_pDrawMode) { 366 if (m_pTool) {
283 delete m_pDrawMode; 367 delete m_pTool;
284 } 368 }
285 369
286 m_pDrawMode = new EllipseDrawMode(this, m_pDrawPadCanvas); 370 m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas);
287 371
288 m_pPointDrawModeAction->setOn(false); 372 m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet());
289 m_pLineDrawModeAction->setOn(false); 373 QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text());
290 m_pRectangleDrawModeAction->setOn(false); 374
291 m_pEllipseDrawModeAction->setOn(true); 375 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0);
292 m_pFillDrawModeAction->setOn(false); 376 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated()));
293 m_pEraseDrawModeAction->setOn(false); 377
378 m_pPointToolAction->setOn(false);
379 m_pLineToolAction->setOn(false);
380 m_pRectangleToolButton->setOn(false);
381 m_pEllipseToolButton->setOn(true);
382 m_pFillToolAction->setOn(false);
383 m_pEraseToolAction->setOn(false);
294} 384}
295 385
296void DrawPad::setFillDrawMode() 386void DrawPad::setFillTool()
297{ 387{
298 if (m_pDrawMode) { 388 if (m_pTool) {
299 delete m_pDrawMode; 389 delete m_pTool;
300 } 390 }
301 391
302 m_pDrawMode = new FillDrawMode(this, m_pDrawPadCanvas); 392 m_pTool = new FillTool(this, m_pDrawPadCanvas);
303 393
304 m_pPointDrawModeAction->setOn(false); 394 m_pPointToolAction->setOn(false);
305 m_pLineDrawModeAction->setOn(false); 395 m_pLineToolAction->setOn(false);
306 m_pRectangleDrawModeAction->setOn(false); 396 m_pRectangleToolButton->setOn(false);
307 m_pEllipseDrawModeAction->setOn(false); 397 m_pEllipseToolButton->setOn(false);
308 m_pFillDrawModeAction->setOn(true); 398 m_pFillToolAction->setOn(true);
309 m_pEraseDrawModeAction->setOn(false); 399 m_pEraseToolAction->setOn(false);
310} 400}
311 401
312void DrawPad::setEraseDrawMode() 402void DrawPad::setEraseTool()
313{ 403{
314 if (m_pDrawMode) { 404 if (m_pTool) {
315 delete m_pDrawMode; 405 delete m_pTool;
316 } 406 }
317 407
318 m_pDrawMode = new EraseDrawMode(this, m_pDrawPadCanvas); 408 m_pTool = new EraseTool(this, m_pDrawPadCanvas);
319 409
320 m_pPointDrawModeAction->setOn(false); 410 m_pPointToolAction->setOn(false);
321 m_pLineDrawModeAction->setOn(false); 411 m_pLineToolAction->setOn(false);
322 m_pRectangleDrawModeAction->setOn(false); 412 m_pRectangleToolButton->setOn(false);
323 m_pEllipseDrawModeAction->setOn(false); 413 m_pEllipseToolButton->setOn(false);
324 m_pFillDrawModeAction->setOn(false); 414 m_pFillToolAction->setOn(false);
325 m_pEraseDrawModeAction->setOn(true); 415 m_pEraseToolAction->setOn(true);
326} 416}
327 417
328void DrawPad::changePenWidth(int value) 418void DrawPad::changePenWidth(int value)
329{ 419{
330 m_pen.setWidth(value); 420 m_pen.setWidth(value);
331} 421}
332 422
333void DrawPad::changePenColor(const QColor& color) 423void DrawPad::changePenColor(const QColor& color)
334{ 424{
335 m_pen.setColor(color); 425 m_pen.setColor(color);
336 426
337 QPainter painter; 427 QPainter painter;
338 painter.begin(m_pPenColorToolButton->pixmap()); 428 painter.begin(m_pPenColorToolButton->pixmap());
339 painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); 429 painter.fillRect(QRect(0, 12, 14, 2), m_pen.color());
340 painter.end(); 430 painter.end();
341 431
342 m_pPenColorToolButton->popup()->hide(); 432 m_pPenColorToolButton->popup()->hide();
343} 433}
344 434
345void DrawPad::changeBrushColor(const QColor& color) 435void DrawPad::changeBrushColor(const QColor& color)
346{ 436{
347 m_brush = QBrush(color); 437 m_brush = QBrush(color);
348 438
349 QPainter painter; 439 QPainter painter;
350 painter.begin(m_pBrushColorToolButton->pixmap()); 440 painter.begin(m_pBrushColorToolButton->pixmap());
351 painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); 441 painter.fillRect(QRect(0, 12, 14, 2), m_brush.color());
352 painter.end(); 442 painter.end();
353 443
354 m_pBrushColorToolButton->popup()->hide(); 444 m_pBrushColorToolButton->popup()->hide();
355} 445}
356 446
357void DrawPad::choosePenColor() 447void DrawPad::choosePenColor()
358{ 448{
359 QColor newPenColor = QColorDialog::getColor(m_pen.color()); 449 QColor newPenColor = QColorDialog::getColor(m_pen.color());
360 changePenColor(newPenColor); 450 changePenColor(newPenColor);
361} 451}
362 452
363void DrawPad::chooseBrushColor() 453void DrawPad::chooseBrushColor()
364{ 454{
365 QColor newBrushColor = QColorDialog::getColor(m_brush.color()); 455 QColor newBrushColor = QColorDialog::getColor(m_brush.color());
366 changeBrushColor(newBrushColor); 456 changeBrushColor(newBrushColor);
367} 457}
368 458
369void DrawPad::updateUndoRedoToolButtons() 459void DrawPad::updateUndoRedoToolButtons()
370{ 460{
371 m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled()); 461 m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled());
372 m_pRedoAction->setEnabled(m_pDrawPadCanvas->redoEnabled()); 462 m_pRedoAction->setEnabled(m_pDrawPadCanvas->redoEnabled());
373} 463}
374 464
375void DrawPad::updateNavigationToolButtons() 465void DrawPad::updateNavigationToolButtons()
376{ 466{
377 m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); 467 m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
378 m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); 468 m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
379 m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); 469 m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
380 m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); 470 m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
381} 471}
382 472
383void DrawPad::updateCaption() 473void DrawPad::updateCaption()
384{ 474{
385 uint pagePosition = m_pDrawPadCanvas->pagePosition(); 475 uint pagePosition = m_pDrawPadCanvas->pagePosition();
386 uint pageCount = m_pDrawPadCanvas->pageCount(); 476 uint pageCount = m_pDrawPadCanvas->pageCount();
387 477
388 setCaption(tr("DrawPad") + " - " + tr("Page") + " " 478 setCaption(tr("DrawPad") + " - " + tr("Page") + " "
389 + QString::number(pagePosition) + "/" + QString::number(pageCount)); 479 + QString::number(pagePosition) + "/" + QString::number(pageCount));
390} 480}
481
482void DrawPad::importPage()
483{
484 ImportDialog importDialog(this);
485
486 importDialog.showMaximized();
487
488 if (importDialog.exec() == QDialog::Accepted) {
489 m_pDrawPadCanvas->importPage(importDialog.selected()->file());
490 }
491}
492
493void DrawPad::exportPage()
494{
495 ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this);
496
497 exportDialog.showMaximized();
498
499 if (exportDialog.exec() == QDialog::Accepted) {
500 m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(),
501 exportDialog.selectedName(), exportDialog.selectedFormat());
502 }
503}
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h
index c49a559..fbe67b8 100644
--- a/noncore/graphics/drawpad/drawpad.h
+++ b/noncore/graphics/drawpad/drawpad.h
@@ -1,85 +1,94 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#ifndef DRAWPAD_H 14#ifndef DRAWPAD_H
15#define DRAWPAD_H 15#define DRAWPAD_H
16 16
17#include <qmainwindow.h> 17#include <qmainwindow.h>
18 18
19#include <qpen.h> 19#include <qpen.h>
20 20
21class DrawMode; 21class Tool;
22class DrawPadCanvas; 22class DrawPadCanvas;
23 23
24class QAction; 24class QAction;
25class QColor; 25class QColor;
26class QToolButton; 26class QToolButton;
27class QWidgetStack; 27class QWidgetStack;
28 28
29class DrawPad : public QMainWindow 29class DrawPad : public QMainWindow
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32 32
33public: 33public:
34 DrawPad(QWidget* parent = 0, const char* name = 0); 34 DrawPad(QWidget* parent = 0, const char* name = 0);
35 ~DrawPad(); 35 ~DrawPad();
36 36
37 DrawMode* drawMode() { return m_pDrawMode; } 37 Tool* tool() { return m_pTool; }
38 QPen pen() { return m_pen; } 38 QPen pen() { return m_pen; }
39 QBrush brush() { return m_brush; } 39 QBrush brush() { return m_brush; }
40 40
41private slots: 41private slots:
42 void setPointDrawMode(); 42 void setPointTool();
43 void setLineDrawMode(); 43 void setLineTool();
44 void setRectangleDrawMode(); 44 void setRectangleTool();
45 void setEllipseDrawMode(); 45 void setFilledRectangleTool();
46 void setFillDrawMode(); 46 void setEllipseTool();
47 void setEraseDrawMode(); 47 void setFilledEllipseTool();
48 void setFillTool();
49 void setEraseTool();
48 50
49 void changePenWidth(int value); 51 void changePenWidth(int value);
50 void changePenColor(const QColor& color); 52 void changePenColor(const QColor& color);
51 void changeBrushColor(const QColor& color); 53 void changeBrushColor(const QColor& color);
52 void choosePenColor(); 54 void choosePenColor();
53 void chooseBrushColor(); 55 void chooseBrushColor();
54 56
55 void updateUndoRedoToolButtons(); 57 void updateUndoRedoToolButtons();
56 void updateNavigationToolButtons(); 58 void updateNavigationToolButtons();
57 void updateCaption(); 59 void updateCaption();
58 60
61 void importPage();
62 void exportPage();
63
59private: 64private:
60 DrawPadCanvas* m_pDrawPadCanvas; 65 DrawPadCanvas* m_pDrawPadCanvas;
61 66
62 DrawMode* m_pDrawMode; 67 Tool* m_pTool;
63 QPen m_pen; 68 QPen m_pen;
64 QBrush m_brush; 69 QBrush m_brush;
65 70
66 QAction* m_pUndoAction; 71 QAction* m_pUndoAction;
67 QAction* m_pRedoAction; 72 QAction* m_pRedoAction;
68 73
69 QAction* m_pFirstPageAction; 74 QAction* m_pFirstPageAction;
70 QAction* m_pPreviousPageAction; 75 QAction* m_pPreviousPageAction;
71 QAction* m_pNextPageAction; 76 QAction* m_pNextPageAction;
72 QAction* m_pLastPageAction; 77 QAction* m_pLastPageAction;
73 78
74 QAction* m_pPointDrawModeAction; 79 QAction* m_pPointToolAction;
75 QAction* m_pLineDrawModeAction; 80 QAction* m_pLineToolAction;
76 QAction* m_pRectangleDrawModeAction; 81 QAction* m_pRectangleToolAction;
77 QAction* m_pEllipseDrawModeAction; 82 QAction* m_pFilledRectangleToolAction;
78 QAction* m_pFillDrawModeAction; 83 QAction* m_pEllipseToolAction;
79 QAction* m_pEraseDrawModeAction; 84 QAction* m_pFilledEllipseToolAction;
80 85 QAction* m_pFillToolAction;
86 QAction* m_pEraseToolAction;
87
88 QToolButton* m_pRectangleToolButton;
89 QToolButton* m_pEllipseToolButton;
81 QToolButton* m_pPenColorToolButton; 90 QToolButton* m_pPenColorToolButton;
82 QToolButton* m_pBrushColorToolButton; 91 QToolButton* m_pBrushColorToolButton;
83}; 92};
84 93
85#endif // DRAWPAD_H 94#endif // DRAWPAD_H
diff --git a/noncore/graphics/drawpad/drawpad.pro b/noncore/graphics/drawpad/drawpad.pro
index b0eb009..5f14515 100644
--- a/noncore/graphics/drawpad/drawpad.pro
+++ b/noncore/graphics/drawpad/drawpad.pro
@@ -1,35 +1,43 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release
3 HEADERS = colordialog.h \ 3 HEADERS = colordialog.h \
4 colorpanel.h \ 4 colorpanel.h \
5 drawmode.h \
6 drawpad.h \ 5 drawpad.h \
7 drawpadcanvas.h \ 6 drawpadcanvas.h \
8 ellipsedrawmode.h \ 7 ellipsetool.h \
9 erasedrawmode.h \ 8 erasetool.h \
10 filldrawmode.h \ 9 exportdialog.h \
11 linedrawmode.h \ 10 filltool.h \
11 filledellipsetool.h \
12 filledrectangletool.h \
13 importdialog.h \
14 linetool.h \
12 newpagedialog.h \ 15 newpagedialog.h \
13 pointdrawmode.h \ 16 pointtool.h \
14 rectangledrawmode.h \ 17 rectangletool.h \
15 shapedrawmode.h 18 shapetool.h \
19 tool.h
16 SOURCES = colordialog.cpp \ 20 SOURCES = colordialog.cpp \
17 colorpanel.cpp \ 21 colorpanel.cpp \
18 drawmode.cpp \
19 drawpad.cpp \ 22 drawpad.cpp \
20 drawpadcanvas.cpp \ 23 drawpadcanvas.cpp \
21 ellipsedrawmode.cpp \ 24 ellipsetool.cpp \
22 erasedrawmode.cpp \ 25 erasetool.cpp \
23 filldrawmode.cpp \ 26 exportdialog.cpp \
24 linedrawmode.cpp \ 27 filltool.cpp \
28 filledellipsetool.cpp \
29 filledrectangletool.cpp \
30 importdialog.cpp \
31 linetool.cpp \
25 main.cpp \ 32 main.cpp \
26 newpagedialog.cpp \ 33 newpagedialog.cpp \
27 pointdrawmode.cpp \ 34 pointtool.cpp \
28 rectangledrawmode.cpp \ 35 rectangletool.cpp \
29 shapedrawmode.cpp 36 shapetool.cpp \
37 tool.cpp
30 INCLUDEPATH+= $(OPIEDIR)/include \ 38 INCLUDEPATH+= $(OPIEDIR)/include \
31 $(QTDIR)/src/3rdparty/zlib 39 $(QTDIR)/src/3rdparty/zlib
32 DEPENDPATH+= $(OPIEDIR)/include 40 DEPENDPATH+= $(OPIEDIR)/include
33 LIBS += -lqpe 41 LIBS += -lqpe
34 DESTDIR = $(OPIEDIR)/bin 42 DESTDIR = $(OPIEDIR)/bin
35 TARGET = drawpad 43 TARGET = drawpad
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 40c27b5..8818c03 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -1,69 +1,74 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "drawpadcanvas.h" 14#include "drawpadcanvas.h"
15 15
16#include "drawmode.h"
17#include "drawpad.h" 16#include "drawpad.h"
18#include "newpagedialog.h" 17#include "newpagedialog.h"
18#include "tool.h"
19
20#include <qpe/applnk.h>
21#include <qpe/filemanager.h>
22#include <qpe/mimetype.h>
19 23
20#include <qbuffer.h> 24#include <qbuffer.h>
21#include <qimage.h> 25#include <qimage.h>
26#include <qmessagebox.h>
22#include <qpainter.h> 27#include <qpainter.h>
23#include <qpixmap.h> 28#include <qpixmap.h>
24#include <qtextcodec.h> 29#include <qtextcodec.h>
25#include <qtextstream.h> 30#include <qtextstream.h>
26#include <qxml.h> 31#include <qxml.h>
27 32
28#include <zlib.h> 33#include <zlib.h>
29 34
30class DrawPadCanvasXmlHandler: public QXmlDefaultHandler 35class DrawPadCanvasXmlHandler: public QXmlDefaultHandler
31{ 36{
32public: 37public:
33 DrawPadCanvasXmlHandler(); 38 DrawPadCanvasXmlHandler();
34 ~DrawPadCanvasXmlHandler(); 39 ~DrawPadCanvasXmlHandler();
35 40
36 QList<QPixmap> pixmaps(); 41 QList<QPixmap> pixmaps();
37 42
38 bool startElement(const QString& namespaceURI, const QString& localName, 43 bool startElement(const QString& namespaceURI, const QString& localName,
39 const QString& qName, const QXmlAttributes& atts); 44 const QString& qName, const QXmlAttributes& atts);
40 bool endElement(const QString& namespaceURI, const QString& localName, 45 bool endElement(const QString& namespaceURI, const QString& localName,
41 const QString& qName); 46 const QString& qName);
42 bool characters(const QString& ch); 47 bool characters(const QString& ch);
43 48
44private: 49private:
45 enum State { 50 enum State {
46 Unknown, 51 Unknown,
47 InData 52 InData
48 }; 53 };
49 54
50 State m_state; 55 State m_state;
51 ulong m_dataLenght; 56 ulong m_dataLenght;
52 QList<QPixmap> m_pixmaps; 57 QList<QPixmap> m_pixmaps;
53}; 58};
54 59
55DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() 60DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler()
56{ 61{
57 m_state = Unknown; 62 m_state = Unknown;
58} 63}
59 64
60DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() 65DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler()
61{ 66{
62} 67}
63 68
64QList<QPixmap> DrawPadCanvasXmlHandler::pixmaps() 69QList<QPixmap> DrawPadCanvasXmlHandler::pixmaps()
65{ 70{
66 return m_pixmaps; 71 return m_pixmaps;
67} 72}
68 73
69bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, 74bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName,
@@ -194,253 +199,328 @@ void DrawPadCanvas::initialPage()
194 emit pageBackupsChanged(); 199 emit pageBackupsChanged();
195} 200}
196 201
197void DrawPadCanvas::save(QIODevice* ioDevice) 202void DrawPadCanvas::save(QIODevice* ioDevice)
198{ 203{
199 QTextStream textStream(ioDevice); 204 QTextStream textStream(ioDevice);
200 textStream.setCodec(QTextCodec::codecForName("UTF-8")); 205 textStream.setCodec(QTextCodec::codecForName("UTF-8"));
201 206
202 textStream << "<drawpad>" << endl; 207 textStream << "<drawpad>" << endl;
203 textStream << " <images>" << endl; 208 textStream << " <images>" << endl;
204 209
205 QListIterator<QPixmap> bufferIterator(m_pages); 210 QListIterator<QPixmap> bufferIterator(m_pages);
206 211
207 for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { 212 for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) {
208 textStream << " <image>" << endl; 213 textStream << " <image>" << endl;
209 214
210 QImage image = bufferIterator.current()->convertToImage(); 215 QImage image = bufferIterator.current()->convertToImage();
211 QByteArray byteArray; 216 QByteArray byteArray;
212 QBuffer buffer(byteArray); 217 QBuffer buffer(byteArray);
213 QImageIO imageIO(&buffer, "XPM"); 218 QImageIO imageIO(&buffer, "XPM");
214 219
215 buffer.open(IO_WriteOnly); 220 buffer.open(IO_WriteOnly);
216 imageIO.setImage(image); 221 imageIO.setImage(image);
217 imageIO.write(); 222 imageIO.write();
218 buffer.close(); 223 buffer.close();
219 224
220 ulong size = byteArray.size() * 2; 225 ulong size = byteArray.size() * 2;
221 QByteArray byteArrayZipped(size); 226 QByteArray byteArrayZipped(size);
222 ::compress((uchar*)byteArrayZipped.data(), &size, (uchar*)byteArray.data(), byteArray.size()); 227 ::compress((uchar*)byteArrayZipped.data(), &size, (uchar*)byteArray.data(), byteArray.size());
223 228
224 textStream << " <data length=\"" << byteArray.size() << "\">"; 229 textStream << " <data length=\"" << byteArray.size() << "\">";
225 230
226 static const char hexchars[] = "0123456789abcdef"; 231 static const char hexchars[] = "0123456789abcdef";
227 232
228 for (int i = 0; i < (int)size; i++ ) { 233 for (int i = 0; i < (int)size; i++ ) {
229 uchar s = (uchar)byteArrayZipped[i]; 234 uchar s = (uchar)byteArrayZipped[i];
230 textStream << hexchars[s >> 4]; 235 textStream << hexchars[s >> 4];
231 textStream << hexchars[s & 0x0f]; 236 textStream << hexchars[s & 0x0f];
232 } 237 }
233 238
234 textStream << "</data>" << endl; 239 textStream << "</data>" << endl;
235 textStream << " </image>" << endl; 240 textStream << " </image>" << endl;
236 } 241 }
237 242
238 textStream << " </images>" << endl; 243 textStream << " </images>" << endl;
239 textStream << "</drawpad>"; 244 textStream << "</drawpad>";
240} 245}
241 246
247void DrawPadCanvas::importPage(const QString& fileName)
248{
249 QPixmap* importedPixmap = new QPixmap();
250
251 importedPixmap->load(fileName);
252 m_pages.insert(m_pages.at() + 1, importedPixmap);
253
254 m_pageBackups.clear();
255 m_pageBackups.append(new QPixmap(*(m_pages.current())));
256
257 resizeContents(m_pages.current()->width(), m_pages.current()->height());
258 viewport()->update();
259
260 emit pagesChanged();
261 emit pageBackupsChanged();
262}
263
264void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format)
265{
266 if (fromPage == toPage) {
267 DocLnk docLnk;
268 MimeType mimeType(format);
269
270 docLnk.setName(name);
271 docLnk.setType(mimeType.id());
272
273 FileManager fileManager;
274 QIODevice* ioDevice = fileManager.saveFile(docLnk);
275 QImageIO imageIO(ioDevice, format);
276
277 QImage image = m_pages.current()->convertToImage();
278 imageIO.setImage(image);
279 imageIO.write();
280 delete ioDevice;
281 } else {
282 for (uint i = fromPage; i <= toPage; i++) {
283 DocLnk docLnk;
284 MimeType mimeType(format);
285
286 docLnk.setName(name + QString::number(i));
287 docLnk.setType(mimeType.id());
288
289 FileManager fileManager;
290 QIODevice* ioDevice = fileManager.saveFile(docLnk);
291 QImageIO imageIO(ioDevice, format);
292
293 QImage image = m_pages.at(i - 1)->convertToImage();
294 imageIO.setImage(image);
295 imageIO.write();
296 delete ioDevice;
297 }
298 }
299}
300
242QPixmap* DrawPadCanvas::currentPage() 301QPixmap* DrawPadCanvas::currentPage()
243{ 302{
244 return m_pages.current(); 303 return m_pages.current();
245} 304}
246 305
247uint DrawPadCanvas::pagePosition() 306uint DrawPadCanvas::pagePosition()
248{ 307{
249 return (m_pages.at() + 1); 308 return (m_pages.at() + 1);
250} 309}
251 310
252uint DrawPadCanvas::pageCount() 311uint DrawPadCanvas::pageCount()
253{ 312{
254 return m_pages.count(); 313 return m_pages.count();
255} 314}
256 315
257void DrawPadCanvas::clearAll() 316void DrawPadCanvas::deleteAll()
258{ 317{
259 m_pages.clear(); 318 QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"),
319 QMessageBox::Information, QMessageBox::Yes,
320 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
321 QMessageBox::NoButton, this);
260 322
261 m_pages.append(new QPixmap(contentsRect().size())); 323 if (messageBox.exec() == QMessageBox::Yes) {
262 m_pages.current()->fill(Qt::white); 324 m_pages.clear();
263 325
264 m_pageBackups.clear(); 326 m_pages.append(new QPixmap(contentsRect().size()));
265 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 327 m_pages.current()->fill(Qt::white);
266 328
267 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 329 m_pageBackups.clear();
268 viewport()->update(); 330 m_pageBackups.append(new QPixmap(*(m_pages.current())));
269 331
270 emit pagesChanged(); 332 resizeContents(m_pages.current()->width(), m_pages.current()->height());
271 emit pageBackupsChanged(); 333 viewport()->update();
334
335 emit pagesChanged();
336 emit pageBackupsChanged();
337 }
272} 338}
273 339
274void DrawPadCanvas::newPage() 340void DrawPadCanvas::newPage()
275{ 341{
276 QRect rect = contentsRect(); 342 QRect rect = contentsRect();
277 343
278 NewPageDialog newPageDialog(this); 344 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(),
279 newPageDialog.setWidth(rect.width()); 345 m_pDrawPad->brush().color(), this);
280 newPageDialog.setHeight(rect.height());
281 346
282 if (newPageDialog.exec() == QDialog::Accepted) { 347 if (newPageDialog.exec() == QDialog::Accepted) {
283 m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.width(), newPageDialog.height())); 348 m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.selectedWidth(),
284 m_pages.current()->fill(Qt::white); 349 newPageDialog.selectedHeight()));
350 m_pages.current()->fill(newPageDialog.selectedColor());
285 351
286 m_pageBackups.clear(); 352 m_pageBackups.clear();
287 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 353 m_pageBackups.append(new QPixmap(*(m_pages.current())));
288 354
289 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 355 resizeContents(m_pages.current()->width(), m_pages.current()->height());
290 viewport()->update(); 356 viewport()->update();
291 357
292 emit pagesChanged(); 358 emit pagesChanged();
293 emit pageBackupsChanged(); 359 emit pageBackupsChanged();
294 } 360 }
295} 361}
296 362
297void DrawPadCanvas::clearPage() 363void DrawPadCanvas::clearPage()
298{ 364{
299 m_pages.current()->fill(Qt::white); 365 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"),
366 QMessageBox::Information, QMessageBox::Yes,
367 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
368 QMessageBox::NoButton, this);
300 369
301 viewport()->update(); 370 if (messageBox.exec() == QMessageBox::Yes) {
371 m_pages.current()->fill(Qt::white);
372
373 viewport()->update();
374 }
302} 375}
303 376
304void DrawPadCanvas::deletePage() 377void DrawPadCanvas::deletePage()
305{ 378{
306 m_pages.remove(m_pages.current()); 379 QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"),
380 QMessageBox::Information, QMessageBox::Yes,
381 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
382 QMessageBox::NoButton, this);
307 383
308 if (m_pages.isEmpty()) { 384 if (messageBox.exec() == QMessageBox::Yes) {
309 m_pages.append(new QPixmap(contentsRect().size())); 385 m_pages.remove(m_pages.current());
310 m_pages.current()->fill(Qt::white);
311 }
312 386
313 m_pageBackups.clear(); 387 if (m_pages.isEmpty()) {
314 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 388 m_pages.append(new QPixmap(contentsRect().size()));
389 m_pages.current()->fill(Qt::white);
390 }
315 391
316 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 392 m_pageBackups.clear();
317 viewport()->update(); 393 m_pageBackups.append(new QPixmap(*(m_pages.current())));
318 394
319 emit pagesChanged(); 395 resizeContents(m_pages.current()->width(), m_pages.current()->height());
320 emit pageBackupsChanged(); 396 viewport()->update();
397
398 emit pagesChanged();
399 emit pageBackupsChanged();
400 }
321} 401}
322 402
323bool DrawPadCanvas::undoEnabled() 403bool DrawPadCanvas::undoEnabled()
324{ 404{
325 return (m_pageBackups.current() != m_pageBackups.getFirst()); 405 return (m_pageBackups.current() != m_pageBackups.getFirst());
326} 406}
327 407
328bool DrawPadCanvas::redoEnabled() 408bool DrawPadCanvas::redoEnabled()
329{ 409{
330 return (m_pageBackups.current() != m_pageBackups.getLast()); 410 return (m_pageBackups.current() != m_pageBackups.getLast());
331} 411}
332 412
333bool DrawPadCanvas::goPreviousPageEnabled() 413bool DrawPadCanvas::goPreviousPageEnabled()
334{ 414{
335 return (m_pages.current() != m_pages.getFirst()); 415 return (m_pages.current() != m_pages.getFirst());
336} 416}
337 417
338bool DrawPadCanvas::goNextPageEnabled() 418bool DrawPadCanvas::goNextPageEnabled()
339{ 419{
340 return (m_pages.current() != m_pages.getLast()); 420 return (m_pages.current() != m_pages.getLast());
341} 421}
342 422
343void DrawPadCanvas::undo() 423void DrawPadCanvas::undo()
344{ 424{
345 *(m_pages.current()) = *(m_pageBackups.prev()); 425 *(m_pages.current()) = *(m_pageBackups.prev());
346 426
347 viewport()->update(); 427 viewport()->update();
348 428
349 emit pageBackupsChanged(); 429 emit pageBackupsChanged();
350} 430}
351 431
352void DrawPadCanvas::redo() 432void DrawPadCanvas::redo()
353{ 433{
354 *(m_pages.current()) = *(m_pageBackups.next()); 434 *(m_pages.current()) = *(m_pageBackups.next());
355 435
356 viewport()->update(); 436 viewport()->update();
357 437
358 emit pageBackupsChanged(); 438 emit pageBackupsChanged();
359} 439}
360 440
361void DrawPadCanvas::goFirstPage() 441void DrawPadCanvas::goFirstPage()
362{ 442{
363 m_pages.first(); 443 m_pages.first();
364 m_pageBackups.clear(); 444 m_pageBackups.clear();
365 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 445 m_pageBackups.append(new QPixmap(*(m_pages.current())));
366 446
367 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 447 resizeContents(m_pages.current()->width(), m_pages.current()->height());
368 viewport()->update(); 448 viewport()->update();
369 449
370 emit pagesChanged(); 450 emit pagesChanged();
371 emit pageBackupsChanged(); 451 emit pageBackupsChanged();
372} 452}
373 453
374void DrawPadCanvas::goPreviousPage() 454void DrawPadCanvas::goPreviousPage()
375{ 455{
376 m_pages.prev(); 456 m_pages.prev();
377 m_pageBackups.clear(); 457 m_pageBackups.clear();
378 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 458 m_pageBackups.append(new QPixmap(*(m_pages.current())));
379 459
380 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 460 resizeContents(m_pages.current()->width(), m_pages.current()->height());
381 viewport()->update(); 461 viewport()->update();
382 462
383 emit pagesChanged(); 463 emit pagesChanged();
384 emit pageBackupsChanged(); 464 emit pageBackupsChanged();
385} 465}
386 466
387void DrawPadCanvas::goNextPage() 467void DrawPadCanvas::goNextPage()
388{ 468{
389 m_pages.next(); 469 m_pages.next();
390 m_pageBackups.clear(); 470 m_pageBackups.clear();
391 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 471 m_pageBackups.append(new QPixmap(*(m_pages.current())));
392 472
393 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 473 resizeContents(m_pages.current()->width(), m_pages.current()->height());
394 viewport()->update(); 474 viewport()->update();
395 475
396 emit pagesChanged(); 476 emit pagesChanged();
397 emit pageBackupsChanged(); 477 emit pageBackupsChanged();
398} 478}
399 479
400void DrawPadCanvas::goLastPage() 480void DrawPadCanvas::goLastPage()
401{ 481{
402 m_pages.last(); 482 m_pages.last();
403 m_pageBackups.clear(); 483 m_pageBackups.clear();
404 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 484 m_pageBackups.append(new QPixmap(*(m_pages.current())));
405 485
406 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 486 resizeContents(m_pages.current()->width(), m_pages.current()->height());
407 viewport()->update(); 487 viewport()->update();
408 488
409 emit pagesChanged(); 489 emit pagesChanged();
410 emit pageBackupsChanged(); 490 emit pageBackupsChanged();
411} 491}
412 492
413void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) 493void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e)
414{ 494{
415 m_pDrawPad->drawMode()->mousePressEvent(e); 495 m_pDrawPad->tool()->mousePressEvent(e);
416} 496}
417 497
418void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) 498void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e)
419{ 499{
420 m_pDrawPad->drawMode()->mouseReleaseEvent(e); 500 m_pDrawPad->tool()->mouseReleaseEvent(e);
421 501
422 QPixmap* currentBackup = m_pageBackups.current(); 502 QPixmap* currentBackup = m_pageBackups.current();
423 while (m_pageBackups.last() != currentBackup) { 503 while (m_pageBackups.last() != currentBackup) {
424 m_pageBackups.removeLast(); 504 m_pageBackups.removeLast();
425 } 505 }
426 506
427 while (m_pageBackups.count() >= (5 + 1)) { 507 while (m_pageBackups.count() >= (5 + 1)) {
428 m_pageBackups.removeFirst(); 508 m_pageBackups.removeFirst();
429 } 509 }
430 510
431 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 511 m_pageBackups.append(new QPixmap(*(m_pages.current())));
432 512
433 emit pageBackupsChanged(); 513 emit pageBackupsChanged();
434} 514}
435 515
436void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) 516void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e)
437{ 517{
438 m_pDrawPad->drawMode()->mouseMoveEvent(e); 518 m_pDrawPad->tool()->mouseMoveEvent(e);
439} 519}
440 520
441void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 521void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
442{ 522{
443 QRect clipRect(cx, cy, cw, ch); 523 QRect clipRect(cx, cy, cw, ch);
444 524
445 p->drawPixmap(clipRect.topLeft(), *(m_pages.current()), clipRect); 525 p->drawPixmap(clipRect.topLeft(), *(m_pages.current()), clipRect);
446} 526}
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h
index 4836a3f..90dd951 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.h
+++ b/noncore/graphics/drawpad/drawpadcanvas.h
@@ -1,77 +1,80 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#ifndef DRAWPADCANVAS_H 14#ifndef DRAWPADCANVAS_H
15#define DRAWPADCANVAS_H 15#define DRAWPADCANVAS_H
16 16
17#include <qscrollview.h> 17#include <qscrollview.h>
18 18
19#include <qlist.h> 19#include <qlist.h>
20#include <qpointarray.h> 20#include <qpointarray.h>
21 21
22class DrawPad; 22class DrawPad;
23 23
24class QPixmap; 24class QPixmap;
25 25
26class DrawPadCanvas : public QScrollView 26class DrawPadCanvas : public QScrollView
27{ 27{
28 Q_OBJECT 28 Q_OBJECT
29 29
30public: 30public:
31 DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0); 31 DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0);
32 ~DrawPadCanvas(); 32 ~DrawPadCanvas();
33 33
34 void load(QIODevice* ioDevice); 34 void load(QIODevice* ioDevice);
35 void initialPage(); 35 void initialPage();
36 void save(QIODevice* ioDevice); 36 void save(QIODevice* ioDevice);
37 37
38 void importPage(const QString& fileName);
39 void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format);
40
38 bool undoEnabled(); 41 bool undoEnabled();
39 bool redoEnabled(); 42 bool redoEnabled();
40 bool goPreviousPageEnabled(); 43 bool goPreviousPageEnabled();
41 bool goNextPageEnabled(); 44 bool goNextPageEnabled();
42 45
43 QPixmap* currentPage(); 46 QPixmap* currentPage();
44 uint pagePosition(); 47 uint pagePosition();
45 uint pageCount(); 48 uint pageCount();
46 49
47public slots: 50public slots:
48 void clearAll(); 51 void deleteAll();
49 void newPage(); 52 void newPage();
50 void clearPage(); 53 void clearPage();
51 void deletePage(); 54 void deletePage();
52 55
53 void undo(); 56 void undo();
54 void redo(); 57 void redo();
55 58
56 void goFirstPage(); 59 void goFirstPage();
57 void goPreviousPage(); 60 void goPreviousPage();
58 void goNextPage(); 61 void goNextPage();
59 void goLastPage(); 62 void goLastPage();
60 63
61signals: 64signals:
62 void pagesChanged(); 65 void pagesChanged();
63 void pageBackupsChanged(); 66 void pageBackupsChanged();
64 67
65protected: 68protected:
66 void contentsMousePressEvent(QMouseEvent* e); 69 void contentsMousePressEvent(QMouseEvent* e);
67 void contentsMouseReleaseEvent(QMouseEvent* e); 70 void contentsMouseReleaseEvent(QMouseEvent* e);
68 void contentsMouseMoveEvent(QMouseEvent* e); 71 void contentsMouseMoveEvent(QMouseEvent* e);
69 void drawContents(QPainter* p, int cx, int cy, int cw, int ch); 72 void drawContents(QPainter* p, int cx, int cy, int cw, int ch);
70 73
71private: 74private:
72 DrawPad* m_pDrawPad; 75 DrawPad* m_pDrawPad;
73 QList<QPixmap> m_pages; 76 QList<QPixmap> m_pages;
74 QList<QPixmap> m_pageBackups; 77 QList<QPixmap> m_pageBackups;
75}; 78};
76 79
77#endif // DRAWPADCANVAS_H 80#endif // DRAWPADCANVAS_H
diff --git a/noncore/graphics/drawpad/ellipsetool.cpp b/noncore/graphics/drawpad/ellipsetool.cpp
new file mode 100644
index 0000000..c3badc3
--- a/dev/null
+++ b/noncore/graphics/drawpad/ellipsetool.cpp
@@ -0,0 +1,45 @@
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 "ellipsetool.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19#include <qpainter.h>
20#include <qpixmap.h>
21
22EllipseTool::EllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : ShapeTool(drawPad, drawPadCanvas)
24{
25}
26
27EllipseTool::~EllipseTool()
28{
29}
30
31void EllipseTool::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 EllipseTool::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/ellipsetool.h b/noncore/graphics/drawpad/ellipsetool.h
new file mode 100644
index 0000000..1f48b39
--- a/dev/null
+++ b/noncore/graphics/drawpad/ellipsetool.h
@@ -0,0 +1,30 @@
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 ELLIPSETOOL_H
15#define ELLIPSETOOL_H
16
17#include "shapetool.h"
18
19class EllipseTool : public ShapeTool
20{
21public:
22 EllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
23 ~EllipseTool();
24
25protected:
26 void drawFinalShape(QPainter& p);
27 void drawTemporaryShape(QPainter& p);
28};
29
30#endif // ELLIPSETOOL_H
diff --git a/noncore/graphics/drawpad/erasetool.cpp b/noncore/graphics/drawpad/erasetool.cpp
new file mode 100644
index 0000000..d37c901
--- a/dev/null
+++ b/noncore/graphics/drawpad/erasetool.cpp
@@ -0,0 +1,74 @@
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 "erasetool.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19#include <qpainter.h>
20#include <qpixmap.h>
21
22EraseTool::EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : Tool(drawPad, drawPadCanvas)
24{
25 m_mousePressed = false;
26 m_polyline.resize(3);
27}
28
29EraseTool::~EraseTool()
30{
31}
32
33void EraseTool::mousePressEvent(QMouseEvent* e)
34{
35 m_mousePressed = true;
36 m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
37}
38
39void EraseTool::mouseReleaseEvent(QMouseEvent* e)
40{
41 Q_UNUSED(e)
42
43 m_mousePressed = false;
44}
45
46void EraseTool::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/erasetool.h b/noncore/graphics/drawpad/erasetool.h
new file mode 100644
index 0000000..3871404
--- a/dev/null
+++ b/noncore/graphics/drawpad/erasetool.h
@@ -0,0 +1,36 @@
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 ERASETOOL_H
15#define ERASEPOINTTOOL_H
16
17#include "tool.h"
18
19#include <qpointarray.h>
20
21class EraseTool : public Tool
22{
23public:
24 EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
25 ~EraseTool();
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 // ERASETOOL_H
diff --git a/noncore/graphics/drawpad/exportdialog.cpp b/noncore/graphics/drawpad/exportdialog.cpp
new file mode 100644
index 0000000..0a980fc
--- a/dev/null
+++ b/noncore/graphics/drawpad/exportdialog.cpp
@@ -0,0 +1,173 @@
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 "exportdialog.h"
15
16#include <qpe/fileselector.h>
17
18#include <qbuttongroup.h>
19#include <qcombobox.h>
20#include <qgroupbox.h>
21#include <qimage.h>
22#include <qlabel.h>
23#include <qlayout.h>
24#include <qlineedit.h>
25#include <qradiobutton.h>
26#include <qspinbox.h>
27
28#include <stdlib.h>
29
30ExportDialog::ExportDialog(uint pageAt, uint pageCount, QWidget* parent, const char* name)
31 : QDialog(parent, name, true)
32{
33 setCaption(tr("Export"));
34
35 m_pageAt = pageAt;
36 m_pageCount = pageCount;
37
38 QButtonGroup* selectionButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Page Selection"), this);
39 connect(selectionButtonGroup, SIGNAL(pressed(int)), this, SLOT(selectionChanged(int)));
40
41 QRadioButton* selectAllRadioButton = new QRadioButton(tr("All"), selectionButtonGroup);
42 QRadioButton* selectCurrentRadioButton = new QRadioButton(tr("Current"), selectionButtonGroup);
43 QRadioButton* selectRangeRadioButton = new QRadioButton(tr("Range"), selectionButtonGroup);
44
45 QLabel* toLabel = new QLabel(tr("To:"), selectionButtonGroup);
46
47 m_pFromPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
48 connect(m_pFromPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fromPageChanged(int)));
49
50 m_pToPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
51 connect(m_pToPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(toPageChanged(int)));
52
53 selectionButtonGroup->setButton(1);
54 selectionChanged(1);
55
56 m_pFromPageSpinBox->setValue(pageAt);
57 m_pToPageSpinBox->setValue(pageAt);
58
59 QGroupBox* exportGroupBox = new QGroupBox(0, Qt::Vertical, tr("Export As"), this);
60
61 QLabel* nameLabel = new QLabel(tr("Name:"), exportGroupBox);
62 QLabel* formatLabel = new QLabel(tr("Format:"), exportGroupBox);
63
64 m_pNameLineEdit = new QLineEdit(exportGroupBox);
65
66 m_pFormatComboBox = new QComboBox(exportGroupBox);
67 m_pFormatComboBox->insertStrList(QImageIO::outputFormats());
68
69 FileSelector* fileSelector = new FileSelector("image/*", this, "fileselector");
70 fileSelector->setNewVisible(false);
71 fileSelector->setCloseVisible(false);
72
73 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
74 selectionButtonGroup->layout()->setSpacing(4);
75 exportGroupBox->layout()->setSpacing(4);
76 QGridLayout* selectionLayout = new QGridLayout(selectionButtonGroup->layout(), 2, 2);
77 QHBoxLayout* rangeLayout = new QHBoxLayout();
78 QGridLayout* exportLayout = new QGridLayout(exportGroupBox->layout(), 2, 2);
79
80 selectionLayout->addWidget(selectAllRadioButton, 0, 0);
81 selectionLayout->addWidget(selectCurrentRadioButton, 1, 0);
82 selectionLayout->addWidget(selectRangeRadioButton, 0, 1);
83 selectionLayout->addLayout(rangeLayout, 1, 1);
84
85 rangeLayout->addWidget(m_pFromPageSpinBox);
86 rangeLayout->addWidget(toLabel);
87 rangeLayout->addWidget(m_pToPageSpinBox);
88
89 exportLayout->addWidget(nameLabel, 0, 0);
90 exportLayout->addWidget(formatLabel, 1, 0);
91
92 exportLayout->addWidget(m_pNameLineEdit, 0, 1);
93 exportLayout->addWidget(m_pFormatComboBox, 1, 1);
94
95 exportLayout->setColStretch(1, 1);
96
97 mainLayout->addWidget(selectionButtonGroup);
98 mainLayout->addWidget(exportGroupBox);
99 mainLayout->addWidget(fileSelector);
100
101 m_pNameLineEdit->setFocus();
102}
103
104ExportDialog::~ExportDialog()
105{
106}
107
108uint ExportDialog::selectedFromPage()
109{
110 return (m_pFromPageSpinBox->value());
111}
112
113uint ExportDialog::selectedToPage()
114{
115 return (m_pToPageSpinBox->value());
116}
117
118QString ExportDialog::selectedName()
119{
120 return (m_pNameLineEdit->text());
121}
122
123QString ExportDialog::selectedFormat()
124{
125 return (m_pFormatComboBox->currentText());
126}
127
128void ExportDialog::accept()
129{
130 if (!(m_pNameLineEdit->text().isEmpty())) {
131 QDialog::accept();
132 }
133}
134
135void ExportDialog::selectionChanged(int id)
136{
137 switch (id) {
138 case 0:
139 m_pFromPageSpinBox->setValue(1);
140 m_pToPageSpinBox->setValue(m_pageCount);
141
142 m_pFromPageSpinBox->setEnabled(false);
143 m_pToPageSpinBox->setEnabled(false);
144 break;
145 case 1:
146 m_pFromPageSpinBox->setValue(m_pageAt);
147 m_pToPageSpinBox->setValue(m_pageAt);
148
149 m_pFromPageSpinBox->setEnabled(false);
150 m_pToPageSpinBox->setEnabled(false);
151 break;
152 case 2:
153 m_pFromPageSpinBox->setEnabled(true);
154 m_pToPageSpinBox->setEnabled(true);
155 break;
156 default:
157 break;
158 }
159}
160
161void ExportDialog::fromPageChanged(int value)
162{
163 if (m_pToPageSpinBox->value() < value) {
164 m_pToPageSpinBox->setValue(value);
165 }
166}
167
168void ExportDialog::toPageChanged(int value)
169{
170 if (m_pFromPageSpinBox->value() > value) {
171 m_pFromPageSpinBox->setValue(value);
172 }
173}
diff --git a/noncore/graphics/drawpad/exportdialog.h b/noncore/graphics/drawpad/exportdialog.h
new file mode 100644
index 0000000..7379f6d
--- a/dev/null
+++ b/noncore/graphics/drawpad/exportdialog.h
@@ -0,0 +1,58 @@
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 EXPORTDIALOG_H
15#define EXPORTDIALOG_H
16
17#include <qdialog.h>
18
19#include <qstrlist.h>
20
21class QComboBox;
22class QLineEdit;
23class QSpinBox;
24
25class ExportDialog : public QDialog
26{
27 Q_OBJECT
28
29public:
30 ExportDialog(uint pageAt, uint pageCount, QWidget* parent = 0, const char* name = 0);
31 ~ExportDialog();
32
33 uint selectedFromPage();
34 uint selectedToPage();
35
36 QString selectedName();
37 QString selectedFormat();
38
39public slots:
40 void accept();
41
42private slots:
43 void selectionChanged(int id);
44 void fromPageChanged(int value);
45 void toPageChanged(int value);
46
47private:
48 uint m_pageAt;
49 uint m_pageCount;
50
51 QSpinBox* m_pFromPageSpinBox;
52 QSpinBox* m_pToPageSpinBox;
53
54 QLineEdit* m_pNameLineEdit;
55 QComboBox* m_pFormatComboBox;
56};
57
58#endif // EXPORTDIALOG_H
diff --git a/noncore/graphics/drawpad/filledellipsetool.cpp b/noncore/graphics/drawpad/filledellipsetool.cpp
new file mode 100644
index 0000000..b446000
--- a/dev/null
+++ b/noncore/graphics/drawpad/filledellipsetool.cpp
@@ -0,0 +1,46 @@
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 "filledellipsetool.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19#include <qpainter.h>
20#include <qpixmap.h>
21
22FilledEllipseTool::FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : ShapeTool(drawPad, drawPadCanvas)
24{
25}
26
27FilledEllipseTool::~FilledEllipseTool()
28{
29}
30
31void FilledEllipseTool::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.setBrush(m_pDrawPad->brush());
37 p.setRasterOp(Qt::CopyROP);
38 p.drawEllipse(QRect(m_polyline[2], m_polyline[0]));
39}
40
41void FilledEllipseTool::drawTemporaryShape(QPainter& p)
42{
43 p.setRasterOp(Qt::NotROP);
44 p.drawRect(QRect(m_polyline[2], m_polyline[1]));
45 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
46}
diff --git a/noncore/graphics/drawpad/filledellipsetool.h b/noncore/graphics/drawpad/filledellipsetool.h
new file mode 100644
index 0000000..b29be20
--- a/dev/null
+++ b/noncore/graphics/drawpad/filledellipsetool.h
@@ -0,0 +1,30 @@
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 FILLEDELLIPSETOOL_H
15#define FILLEDELLIPSETOOL_H
16
17#include "shapetool.h"
18
19class FilledEllipseTool : public ShapeTool
20{
21public:
22 FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
23 ~FilledEllipseTool();
24
25protected:
26 void drawFinalShape(QPainter& p);
27 void drawTemporaryShape(QPainter& p);
28};
29
30#endif // FILLEDELLIPSETOOL_H
diff --git a/noncore/graphics/drawpad/filledrectangletool.cpp b/noncore/graphics/drawpad/filledrectangletool.cpp
new file mode 100644
index 0000000..388acbd
--- a/dev/null
+++ b/noncore/graphics/drawpad/filledrectangletool.cpp
@@ -0,0 +1,43 @@
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 "filledrectangletool.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19FilledRectangleTool::FilledRectangleTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
20 : ShapeTool(drawPad, drawPadCanvas)
21{
22}
23
24FilledRectangleTool::~FilledRectangleTool()
25{
26}
27
28void FilledRectangleTool::drawFinalShape(QPainter& p)
29{
30 p.setRasterOp(Qt::NotROP);
31 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
32 p.setRasterOp(Qt::CopyROP);
33 p.fillRect(QRect(m_polyline[2], m_polyline[0]), m_pDrawPad->brush());
34 p.setPen(m_pDrawPad->pen());
35 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
36}
37
38void FilledRectangleTool::drawTemporaryShape(QPainter& p)
39{
40 p.setRasterOp(Qt::NotROP);
41 p.drawRect(QRect(m_polyline[2], m_polyline[1]));
42 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
43}
diff --git a/noncore/graphics/drawpad/filledrectangletool.h b/noncore/graphics/drawpad/filledrectangletool.h
new file mode 100644
index 0000000..7364911
--- a/dev/null
+++ b/noncore/graphics/drawpad/filledrectangletool.h
@@ -0,0 +1,30 @@
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 FILLEDRECTANGLETOOL_H
15#define FILLEDRECTANGLETOOL_H
16
17#include "shapetool.h"
18
19class FilledRectangleTool : public ShapeTool
20{
21public:
22 FilledRectangleTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
23 ~FilledRectangleTool();
24
25protected:
26 void drawFinalShape(QPainter& p);
27 void drawTemporaryShape(QPainter& p);
28};
29
30#endif // FILLEDRECTANGLETOOL_H
diff --git a/noncore/graphics/drawpad/filltool.cpp b/noncore/graphics/drawpad/filltool.cpp
new file mode 100644
index 0000000..3297d21
--- a/dev/null
+++ b/noncore/graphics/drawpad/filltool.cpp
@@ -0,0 +1,88 @@
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 "filltool.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19#include <qimage.h>
20#include <qpixmap.h>
21
22FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : Tool(drawPad, drawPadCanvas)
24{
25}
26
27FillTool::~FillTool()
28{
29}
30
31void FillTool::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 FillTool::mouseReleaseEvent(QMouseEvent* e)
49{
50 Q_UNUSED(e)
51}
52
53void FillTool::mouseMoveEvent(QMouseEvent* e)
54{
55 Q_UNUSED(e)
56}
57
58void FillTool::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/filltool.h b/noncore/graphics/drawpad/filltool.h
new file mode 100644
index 0000000..eaf9a27
--- a/dev/null
+++ b/noncore/graphics/drawpad/filltool.h
@@ -0,0 +1,39 @@
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 FILLTOOL_H
15#define FILLTOOL_H
16
17#include "tool.h"
18
19#include <qimage.h>
20
21class FillTool : public Tool
22{
23public:
24 FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
25 ~FillTool();
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 // FILLTOOL_H
diff --git a/noncore/graphics/drawpad/importdialog.cpp b/noncore/graphics/drawpad/importdialog.cpp
new file mode 100644
index 0000000..7722417
--- a/dev/null
+++ b/noncore/graphics/drawpad/importdialog.cpp
@@ -0,0 +1,41 @@
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 "importdialog.h"
15
16#include <qpe/applnk.h>
17#include <qpe/fileselector.h>
18
19#include <qlayout.h>
20
21ImportDialog::ImportDialog(QWidget* parent, const char* name)
22 : QDialog(parent, name, true)
23{
24 setCaption(tr("Import"));
25
26 m_pFileSelector = new FileSelector("image/*", this, "fileselector");
27 m_pFileSelector->setNewVisible(false);
28 m_pFileSelector->setCloseVisible(false);
29
30 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
31 mainLayout->addWidget(m_pFileSelector);
32}
33
34ImportDialog::~ImportDialog()
35{
36}
37
38const DocLnk* ImportDialog::selected()
39{
40 return m_pFileSelector->selected();
41}
diff --git a/noncore/graphics/drawpad/importdialog.h b/noncore/graphics/drawpad/importdialog.h
new file mode 100644
index 0000000..1c67145
--- a/dev/null
+++ b/noncore/graphics/drawpad/importdialog.h
@@ -0,0 +1,36 @@
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 IMPORTDIALOG_H
15#define IMPORTDIALOG_H
16
17#include <qdialog.h>
18
19class DocLnk;
20class FileSelector;
21
22class ImportDialog : public QDialog
23{
24 Q_OBJECT
25
26public:
27 ImportDialog(QWidget* parent = 0, const char* name = 0);
28 ~ImportDialog();
29
30 const DocLnk* selected();
31
32private:
33 FileSelector* m_pFileSelector;
34};
35
36#endif // IMPORTDIALOG_H
diff --git a/noncore/graphics/drawpad/linetool.cpp b/noncore/graphics/drawpad/linetool.cpp
new file mode 100644
index 0000000..94ca165
--- a/dev/null
+++ b/noncore/graphics/drawpad/linetool.cpp
@@ -0,0 +1,42 @@
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 "linetool.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19LineTool::LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
20 : ShapeTool(drawPad, drawPadCanvas)
21{
22}
23
24LineTool::~LineTool()
25{
26}
27
28void LineTool::drawFinalShape(QPainter& p)
29{
30 p.setRasterOp(Qt::NotROP);
31 p.drawLine(m_polyline[2], m_polyline[0]);
32 p.setPen(m_pDrawPad->pen());
33 p.setRasterOp(Qt::CopyROP);
34 p.drawLine(m_polyline[2], m_polyline[0]);
35}
36
37void LineTool::drawTemporaryShape(QPainter& p)
38{
39 p.setRasterOp(Qt::NotROP);
40 p.drawLine(m_polyline[2], m_polyline[1]);
41 p.drawLine(m_polyline[2], m_polyline[0]);
42}
diff --git a/noncore/graphics/drawpad/linetool.h b/noncore/graphics/drawpad/linetool.h
new file mode 100644
index 0000000..6108b5a
--- a/dev/null
+++ b/noncore/graphics/drawpad/linetool.h
@@ -0,0 +1,30 @@
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 LINETOOL_H
15#define LINETOOL_H
16
17#include "shapetool.h"
18
19class LineTool : public ShapeTool
20{
21public:
22 LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
23 ~LineTool();
24
25protected:
26 void drawFinalShape(QPainter& p);
27 void drawTemporaryShape(QPainter& p);
28};
29
30#endif // LINETOOL_H
diff --git a/noncore/graphics/drawpad/newpagedialog.cpp b/noncore/graphics/drawpad/newpagedialog.cpp
index c11d977..b1b26ef 100644
--- a/noncore/graphics/drawpad/newpagedialog.cpp
+++ b/noncore/graphics/drawpad/newpagedialog.cpp
@@ -1,61 +1,102 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "newpagedialog.h" 14#include "newpagedialog.h"
15 15
16#include <qbuttongroup.h>
17#include <qgroupbox.h>
16#include <qlabel.h> 18#include <qlabel.h>
17#include <qlayout.h> 19#include <qlayout.h>
20#include <qradiobutton.h>
18#include <qspinbox.h> 21#include <qspinbox.h>
19 22
20NewPageDialog::NewPageDialog(QWidget* parent, const char* name) 23NewPageDialog::NewPageDialog(uint width, uint height, const QColor& foregroundColor,
24 const QColor& backgroundColor, QWidget* parent, const char* name)
21 : QDialog(parent, name, true) 25 : QDialog(parent, name, true)
22{ 26{
23 setCaption(tr("New Page")); 27 setCaption(tr("New Page"));
24 28
25 QLabel* widthLabel = new QLabel(tr("Width :"), this); 29 m_foregroundColor = foregroundColor;
26 QLabel* heightLabel = new QLabel(tr("Height :"), this); 30 m_backgroundColor = backgroundColor;
27 31
28 m_pWidthSpinBox = new QSpinBox(1, 1024, 1, this); 32 QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Page Size"), this);
29 m_pHeightSpinBox = new QSpinBox(1, 1024, 1, this);
30 33
31 QGridLayout* gridLayout = new QGridLayout(this, 2, 2, 2, 2); 34 QLabel* widthLabel = new QLabel(tr("Width :"), sizeGroupBox);
35 QLabel* heightLabel = new QLabel(tr("Height :"), sizeGroupBox);
32 36
33 gridLayout->addWidget(widthLabel, 0, 0); 37 m_pWidthSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox);
34 gridLayout->addWidget(heightLabel, 1, 0); 38 m_pHeightSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox);
35 gridLayout->addWidget(m_pWidthSpinBox, 0, 1);
36 gridLayout->addWidget(m_pHeightSpinBox, 1, 1);
37}
38 39
39NewPageDialog::~NewPageDialog() 40 m_pWidthSpinBox->setValue(width);
40{ 41 m_pHeightSpinBox->setValue(height);
42
43 m_pContentButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Contents"), this);
44
45 QRadioButton* whiteColorRadioButton = new QRadioButton(tr("White"), m_pContentButtonGroup);
46 QRadioButton* foregroundColorRadioButton = new QRadioButton(tr("Foreground Color"), m_pContentButtonGroup);
47 QRadioButton* backgroundColorRadioButton = new QRadioButton(tr("Background Color"), m_pContentButtonGroup);
48
49 m_pContentButtonGroup->setButton(0);
50
51 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
52 sizeGroupBox->layout()->setSpacing(4);
53 m_pContentButtonGroup->layout()->setSpacing(4);
54 QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2);
55 QVBoxLayout* contentLayout = new QVBoxLayout(m_pContentButtonGroup->layout());
56
57 sizeLayout->addWidget(widthLabel, 0, 0);
58 sizeLayout->addWidget(heightLabel, 1, 0);
59 sizeLayout->addWidget(m_pWidthSpinBox, 0, 1);
60 sizeLayout->addWidget(m_pHeightSpinBox, 1, 1);
61
62 sizeLayout->setColStretch(1, 1);
63
64 contentLayout->addWidget(whiteColorRadioButton);
65 contentLayout->addWidget(foregroundColorRadioButton);
66 contentLayout->addWidget(backgroundColorRadioButton);
67
68 mainLayout->addWidget(sizeGroupBox);
69 mainLayout->addWidget(m_pContentButtonGroup);
41} 70}
42 71
43void NewPageDialog::setWidth(int width) 72NewPageDialog::~NewPageDialog()
44{ 73{
45 m_pWidthSpinBox->setValue(width);
46} 74}
47 75
48void NewPageDialog::setHeight(int height) 76uint NewPageDialog::selectedWidth()
49{ 77{
50 m_pHeightSpinBox->setValue(height); 78 return (m_pWidthSpinBox->value());
51} 79}
52 80
53int NewPageDialog::width() 81uint NewPageDialog::selectedHeight()
54{ 82{
55 return m_pWidthSpinBox->value(); 83 return (m_pHeightSpinBox->value());
56} 84}
57 85
58int NewPageDialog::height() 86const QColor& NewPageDialog::selectedColor()
59{ 87{
60 return m_pHeightSpinBox->value(); 88 switch (m_pContentButtonGroup->id(m_pContentButtonGroup->selected())) {
89 case 0:
90 return (Qt::white);
91 break;
92 case 1:
93 return (m_foregroundColor);
94 break;
95 case 2:
96 return (m_backgroundColor);
97 break;
98 default:
99 return (Qt::white);
100 break;
101 }
61} 102}
diff --git a/noncore/graphics/drawpad/newpagedialog.h b/noncore/graphics/drawpad/newpagedialog.h
index a2b6b87..f418340 100644
--- a/noncore/graphics/drawpad/newpagedialog.h
+++ b/noncore/graphics/drawpad/newpagedialog.h
@@ -1,40 +1,45 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#ifndef NEWPAGEDIALOG_H 14#ifndef NEWPAGEDIALOG_H
15#define NEWPAGEDIALOG_H 15#define NEWPAGEDIALOG_H
16 16
17#include <qdialog.h> 17#include <qdialog.h>
18 18
19class QButtonGroup;
19class QSpinBox; 20class QSpinBox;
20 21
21class NewPageDialog : public QDialog 22class NewPageDialog : public QDialog
22{ 23{
23 Q_OBJECT 24 Q_OBJECT
24 25
25public: 26public:
26 NewPageDialog(QWidget* parent = 0, const char* name = 0); 27 NewPageDialog(uint width, uint height, const QColor& foregroundColor,
28 const QColor& backgroundColor, QWidget* parent = 0, const char* name = 0);
27 ~NewPageDialog(); 29 ~NewPageDialog();
28 30
29 void setWidth(int width); 31 uint selectedWidth();
30 void setHeight(int height); 32 uint selectedHeight();
31 33 const QColor& selectedColor();
32 int width();
33 int height();
34 34
35private: 35private:
36 QSpinBox* m_pWidthSpinBox; 36 QSpinBox* m_pWidthSpinBox;
37 QSpinBox* m_pHeightSpinBox; 37 QSpinBox* m_pHeightSpinBox;
38
39 QColor m_foregroundColor;
40 QColor m_backgroundColor;
41
42 QButtonGroup* m_pContentButtonGroup;
38}; 43};
39 44
40#endif // NEWPAGEDIALOG_H 45#endif // NEWPAGEDIALOG_H
diff --git a/noncore/graphics/drawpad/pointtool.cpp b/noncore/graphics/drawpad/pointtool.cpp
new file mode 100644
index 0000000..5661b03
--- a/dev/null
+++ b/noncore/graphics/drawpad/pointtool.cpp
@@ -0,0 +1,73 @@
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 "pointtool.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19#include <qpainter.h>
20#include <qpixmap.h>
21
22PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : Tool(drawPad, drawPadCanvas)
24{
25 m_mousePressed = false;
26 m_polyline.resize(3);
27}
28
29PointTool::~PointTool()
30{
31}
32
33void PointTool::mousePressEvent(QMouseEvent* e)
34{
35 m_mousePressed = true;
36 m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
37}
38
39void PointTool::mouseReleaseEvent(QMouseEvent* e)
40{
41 Q_UNUSED(e)
42
43 m_mousePressed = false;
44}
45
46void PointTool::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/pointtool.h b/noncore/graphics/drawpad/pointtool.h
new file mode 100644
index 0000000..4bbbac2
--- a/dev/null
+++ b/noncore/graphics/drawpad/pointtool.h
@@ -0,0 +1,36 @@
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 POINTTOOL_H
15#define POINTTOOL_H
16
17#include "tool.h"
18
19#include <qpointarray.h>
20
21class PointTool : public Tool
22{
23public:
24 PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
25 ~PointTool();
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 // POINTTOOL_H
diff --git a/noncore/graphics/drawpad/rectangletool.cpp b/noncore/graphics/drawpad/rectangletool.cpp
new file mode 100644
index 0000000..a2f6026
--- a/dev/null
+++ b/noncore/graphics/drawpad/rectangletool.cpp
@@ -0,0 +1,42 @@
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 "rectangletool.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19RectangleTool::RectangleTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
20 : ShapeTool(drawPad, drawPadCanvas)
21{
22}
23
24RectangleTool::~RectangleTool()
25{
26}
27
28void RectangleTool::drawFinalShape(QPainter& p)
29{
30 p.setRasterOp(Qt::NotROP);
31 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
32 p.setPen(m_pDrawPad->pen());
33 p.setRasterOp(Qt::CopyROP);
34 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
35}
36
37void RectangleTool::drawTemporaryShape(QPainter& p)
38{
39 p.setRasterOp(Qt::NotROP);
40 p.drawRect(QRect(m_polyline[2], m_polyline[1]));
41 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
42}
diff --git a/noncore/graphics/drawpad/rectangletool.h b/noncore/graphics/drawpad/rectangletool.h
new file mode 100644
index 0000000..b5164dc
--- a/dev/null
+++ b/noncore/graphics/drawpad/rectangletool.h
@@ -0,0 +1,30 @@
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 RECTANGLETOOL_H
15#define RECTANGLETOOL_H
16
17#include "shapetool.h"
18
19class RectangleTool : public ShapeTool
20{
21public:
22 RectangleTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
23 ~RectangleTool();
24
25protected:
26 void drawFinalShape(QPainter& p);
27 void drawTemporaryShape(QPainter& p);
28};
29
30#endif // RECTANGLETOOL_H
diff --git a/noncore/graphics/drawpad/shapetool.cpp b/noncore/graphics/drawpad/shapetool.cpp
new file mode 100644
index 0000000..3c99370
--- a/dev/null
+++ b/noncore/graphics/drawpad/shapetool.cpp
@@ -0,0 +1,92 @@
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 "shapetool.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19#include <qpainter.h>
20#include <qpixmap.h>
21
22ShapeTool::ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : Tool(drawPad, drawPadCanvas)
24{
25 m_mousePressed = false;
26 m_polyline.resize(3);
27}
28
29ShapeTool::~ShapeTool()
30{
31}
32
33void ShapeTool::mousePressEvent(QMouseEvent* e)
34{
35 m_mousePressed = true;
36 m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
37}
38
39void ShapeTool::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 ShapeTool::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/shapetool.h b/noncore/graphics/drawpad/shapetool.h
new file mode 100644
index 0000000..3f2f7a9
--- a/dev/null
+++ b/noncore/graphics/drawpad/shapetool.h
@@ -0,0 +1,41 @@
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 SHAPETOOL_H
15#define SHAPETOOL_H
16
17#include "tool.h"
18
19#include <qpointarray.h>
20
21class ShapeTool : public Tool
22{
23public:
24 ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
25 ~ShapeTool();
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 // SHAPETOOL_H
diff --git a/noncore/graphics/drawpad/tool.cpp b/noncore/graphics/drawpad/tool.cpp
new file mode 100644
index 0000000..0d36912
--- a/dev/null
+++ b/noncore/graphics/drawpad/tool.cpp
@@ -0,0 +1,28 @@
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 "tool.h"
15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18
19Tool::Tool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
20 : QObject()
21{
22 m_pDrawPad = drawPad;
23 m_pDrawPadCanvas = drawPadCanvas;
24}
25
26Tool::~Tool()
27{
28}
diff --git a/noncore/graphics/drawpad/tool.h b/noncore/graphics/drawpad/tool.h
new file mode 100644
index 0000000..5848215
--- a/dev/null
+++ b/noncore/graphics/drawpad/tool.h
@@ -0,0 +1,39 @@
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 TOOL_H
15#define TOOL_H
16
17#include <qobject.h>
18
19class DrawPad;
20class DrawPadCanvas;
21
22class Tool : public QObject
23{
24protected:
25 Tool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
26
27public:
28 virtual ~Tool();
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 // TOOL_H