summaryrefslogtreecommitdiff
path: root/noncore
authorleseb <leseb>2002-03-27 17:09:29 (UTC)
committer leseb <leseb>2002-03-27 17:09:29 (UTC)
commit4372bb8e59eb4b0d2fa5fba8f6525dc14873f239 (patch) (unidiff)
tree6947938ca5d22d3a373741ba3acfc20e8dd67729 /noncore
parentfb056735d9a021787f83c6a791225a7ca70c1eb5 (diff)
downloadopie-4372bb8e59eb4b0d2fa5fba8f6525dc14873f239.zip
opie-4372bb8e59eb4b0d2fa5fba8f6525dc14873f239.tar.gz
opie-4372bb8e59eb4b0d2fa5fba8f6525dc14873f239.tar.bz2
Import/export dialogs, improved new page dialog, new tools, ...
Diffstat (limited to 'noncore') (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
@@ -22,40 +22,25 @@ ColorPanelButton::ColorPanelButton(const QColor& color, QWidget* parent, const c
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)
@@ -125,6 +110,7 @@ void 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
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
@@ -27,8 +27,6 @@ public:
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);
@@ -39,7 +37,6 @@ signals:
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
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
@@ -16,13 +16,18 @@
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>
@@ -57,14 +62,19 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
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
@@ -119,38 +129,60 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
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);
@@ -163,7 +195,9 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
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"));
@@ -172,8 +206,8 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
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);
@@ -184,7 +218,7 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
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"));
@@ -193,8 +227,8 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
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);
@@ -205,7 +239,7 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
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
@@ -229,100 +263,156 @@ DrawPad::~DrawPad()
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)
@@ -388,3 +478,26 @@ void DrawPad::updateCaption()
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
@@ -18,7 +18,7 @@
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;
@@ -34,17 +34,19 @@ public:
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);
@@ -56,10 +58,13 @@ private slots:
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
@@ -71,13 +76,17 @@ private:
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};
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
@@ -2,31 +2,39 @@ 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
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
@@ -13,12 +13,17 @@
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>
@@ -239,6 +244,60 @@ void DrawPadCanvas::save(QIODevice* ioDevice)
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();
@@ -254,34 +313,41 @@ uint DrawPadCanvas::pageCount()
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())));
@@ -296,28 +362,42 @@ void DrawPadCanvas::newPage()
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()
@@ -412,12 +492,12 @@ void DrawPadCanvas::goLastPage()
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) {
@@ -435,7 +515,7 @@ void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e)
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)
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
@@ -35,6 +35,9 @@ public:
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();
@@ -45,7 +48,7 @@ public:
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();
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
@@ -13,49 +13,90 @@
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
@@ -16,6 +16,7 @@
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
@@ -23,18 +24,22 @@ class NewPageDialog : public QDialog
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