author | leseb <leseb> | 2002-03-27 17:09:29 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-03-27 17:09:29 (UTC) |
commit | 4372bb8e59eb4b0d2fa5fba8f6525dc14873f239 (patch) (unidiff) | |
tree | 6947938ca5d22d3a373741ba3acfc20e8dd67729 /noncore/graphics/drawpad | |
parent | fb056735d9a021787f83c6a791225a7ca70c1eb5 (diff) | |
download | opie-4372bb8e59eb4b0d2fa5fba8f6525dc14873f239.zip opie-4372bb8e59eb4b0d2fa5fba8f6525dc14873f239.tar.gz opie-4372bb8e59eb4b0d2fa5fba8f6525dc14873f239.tar.bz2 |
Import/export dialogs, improved new page dialog, new tools, ...
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 | |||
@@ -24,3 +24,3 @@ ColorPanelButton::ColorPanelButton(const QColor& color, QWidget* parent, const c | |||
24 | setFixedSize(16, 16); | 24 | setFixedSize(16, 16); |
25 | setActive(false); | 25 | setFrameStyle(NoFrame); |
26 | } | 26 | } |
@@ -31,13 +31,2 @@ ColorPanelButton::~ColorPanelButton() | |||
31 | 31 | ||
32 | void 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 | |||
43 | void ColorPanelButton::enterEvent(QEvent* e) | 32 | void ColorPanelButton::enterEvent(QEvent* e) |
@@ -46,5 +35,3 @@ void ColorPanelButton::enterEvent(QEvent* e) | |||
46 | 35 | ||
47 | if (!m_active) { | 36 | setFrameStyle(Panel | Sunken); |
48 | setFrameStyle(Panel | Sunken); | ||
49 | } | ||
50 | } | 37 | } |
@@ -55,5 +42,3 @@ void ColorPanelButton::leaveEvent(QEvent* e) | |||
55 | 42 | ||
56 | if (!m_active) { | 43 | setFrameStyle(NoFrame); |
57 | setFrameStyle(NoFrame); | ||
58 | } | ||
59 | } | 44 | } |
@@ -127,2 +112,3 @@ void ColorPanel::addColor(const QColor& color, int row, int col) | |||
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); |
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 | |||
@@ -29,4 +29,2 @@ public: | |||
29 | 29 | ||
30 | void setActive(bool active); | ||
31 | |||
32 | void enterEvent(QEvent* e); | 30 | void enterEvent(QEvent* e); |
@@ -41,3 +39,2 @@ private: | |||
41 | QColor m_color; | 39 | QColor m_color; |
42 | bool m_active; | ||
43 | }; | 40 | }; |
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 | |||
@@ -18,9 +18,14 @@ | |||
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> |
@@ -59,5 +64,5 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
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 | ||
@@ -65,4 +70,9 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
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 | ||
@@ -121,34 +131,56 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
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 | ||
@@ -165,3 +197,5 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
165 | 197 | ||
198 | QToolTip::add(penWidthSpinBox, tr("Pen Width")); | ||
166 | penWidthSpinBox->setValue(1); | 199 | penWidthSpinBox->setValue(1); |
200 | penWidthSpinBox->setFocusPolicy(QWidget::NoFocus); | ||
167 | 201 | ||
@@ -174,4 +208,4 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
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(); |
@@ -186,3 +220,3 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
186 | 220 | ||
187 | penColorPopupMenu->activateItemAt(0); | 221 | penColorPanel->buttonSelected(Qt::black); |
188 | 222 | ||
@@ -195,4 +229,4 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
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(); |
@@ -207,3 +241,3 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
207 | 241 | ||
208 | brushColorPopupMenu->activateItemAt(1); | 242 | brushColorPanel->buttonSelected(Qt::white); |
209 | 243 | ||
@@ -231,96 +265,152 @@ DrawPad::~DrawPad() | |||
231 | 265 | ||
232 | void DrawPad::setPointDrawMode() | 266 | void 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 | |||
282 | void 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 | |||
298 | void 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 | ||
248 | void DrawPad::setLineDrawMode() | 320 | void 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 | ||
264 | void DrawPad::setRectangleDrawMode() | 342 | void 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 | ||
280 | void DrawPad::setEllipseDrawMode() | 364 | void 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 | ||
296 | void DrawPad::setFillDrawMode() | 386 | void 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 | ||
312 | void DrawPad::setEraseDrawMode() | 402 | void 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 | } |
@@ -390 +480,24 @@ void DrawPad::updateCaption() | |||
390 | } | 480 | } |
481 | |||
482 | void 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 | |||
493 | void 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 | |||
@@ -20,3 +20,3 @@ | |||
20 | 20 | ||
21 | class DrawMode; | 21 | class Tool; |
22 | class DrawPadCanvas; | 22 | class DrawPadCanvas; |
@@ -36,3 +36,3 @@ public: | |||
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; } |
@@ -41,8 +41,10 @@ public: | |||
41 | private slots: | 41 | private 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 | ||
@@ -58,2 +60,5 @@ private slots: | |||
58 | 60 | ||
61 | void importPage(); | ||
62 | void exportPage(); | ||
63 | |||
59 | private: | 64 | private: |
@@ -61,3 +66,3 @@ private: | |||
61 | 66 | ||
62 | DrawMode* m_pDrawMode; | 67 | Tool* m_pTool; |
63 | QPen m_pen; | 68 | QPen m_pen; |
@@ -73,9 +78,13 @@ private: | |||
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; |
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 | |||
@@ -4,27 +4,35 @@ 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 \ |
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 | |||
@@ -15,5 +15,9 @@ | |||
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 | ||
@@ -21,2 +25,3 @@ | |||
21 | #include <qimage.h> | 25 | #include <qimage.h> |
26 | #include <qmessagebox.h> | ||
22 | #include <qpainter.h> | 27 | #include <qpainter.h> |
@@ -241,2 +246,56 @@ void DrawPadCanvas::save(QIODevice* ioDevice) | |||
241 | 246 | ||
247 | void 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 | |||
264 | void 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 | |||
242 | QPixmap* DrawPadCanvas::currentPage() | 301 | QPixmap* DrawPadCanvas::currentPage() |
@@ -256,17 +315,24 @@ uint DrawPadCanvas::pageCount() | |||
256 | 315 | ||
257 | void DrawPadCanvas::clearAll() | 316 | void 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 | } |
@@ -277,9 +343,9 @@ void DrawPadCanvas::newPage() | |||
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 | ||
@@ -298,5 +364,12 @@ void 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 | } |
@@ -305,17 +378,24 @@ void 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 | } |
@@ -414,3 +494,3 @@ void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) | |||
414 | { | 494 | { |
415 | m_pDrawPad->drawMode()->mousePressEvent(e); | 495 | m_pDrawPad->tool()->mousePressEvent(e); |
416 | } | 496 | } |
@@ -419,3 +499,3 @@ void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) | |||
419 | { | 499 | { |
420 | m_pDrawPad->drawMode()->mouseReleaseEvent(e); | 500 | m_pDrawPad->tool()->mouseReleaseEvent(e); |
421 | 501 | ||
@@ -437,3 +517,3 @@ void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) | |||
437 | { | 517 | { |
438 | m_pDrawPad->drawMode()->mouseMoveEvent(e); | 518 | m_pDrawPad->tool()->mouseMoveEvent(e); |
439 | } | 519 | } |
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 | |||
@@ -37,2 +37,5 @@ public: | |||
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(); |
@@ -47,3 +50,3 @@ public: | |||
47 | public slots: | 50 | public slots: |
48 | void clearAll(); | 51 | void deleteAll(); |
49 | void newPage(); | 52 | void newPage(); |
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 | |||
22 | EllipseTool::EllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | ||
23 | : ShapeTool(drawPad, drawPadCanvas) | ||
24 | { | ||
25 | } | ||
26 | |||
27 | EllipseTool::~EllipseTool() | ||
28 | { | ||
29 | } | ||
30 | |||
31 | void 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 | |||
40 | void 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 | |||
19 | class EllipseTool : public ShapeTool | ||
20 | { | ||
21 | public: | ||
22 | EllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas); | ||
23 | ~EllipseTool(); | ||
24 | |||
25 | protected: | ||
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 | |||
22 | EraseTool::EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | ||
23 | : Tool(drawPad, drawPadCanvas) | ||
24 | { | ||
25 | m_mousePressed = false; | ||
26 | m_polyline.resize(3); | ||
27 | } | ||
28 | |||
29 | EraseTool::~EraseTool() | ||
30 | { | ||
31 | } | ||
32 | |||
33 | void EraseTool::mousePressEvent(QMouseEvent* e) | ||
34 | { | ||
35 | m_mousePressed = true; | ||
36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | ||
37 | } | ||
38 | |||
39 | void EraseTool::mouseReleaseEvent(QMouseEvent* e) | ||
40 | { | ||
41 | Q_UNUSED(e) | ||
42 | |||
43 | m_mousePressed = false; | ||
44 | } | ||
45 | |||
46 | void 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 | |||
21 | class EraseTool : public Tool | ||
22 | { | ||
23 | public: | ||
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 | |||
31 | private: | ||
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 | |||
30 | ExportDialog::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 | |||
104 | ExportDialog::~ExportDialog() | ||
105 | { | ||
106 | } | ||
107 | |||
108 | uint ExportDialog::selectedFromPage() | ||
109 | { | ||
110 | return (m_pFromPageSpinBox->value()); | ||
111 | } | ||
112 | |||
113 | uint ExportDialog::selectedToPage() | ||
114 | { | ||
115 | return (m_pToPageSpinBox->value()); | ||
116 | } | ||
117 | |||
118 | QString ExportDialog::selectedName() | ||
119 | { | ||
120 | return (m_pNameLineEdit->text()); | ||
121 | } | ||
122 | |||
123 | QString ExportDialog::selectedFormat() | ||
124 | { | ||
125 | return (m_pFormatComboBox->currentText()); | ||
126 | } | ||
127 | |||
128 | void ExportDialog::accept() | ||
129 | { | ||
130 | if (!(m_pNameLineEdit->text().isEmpty())) { | ||
131 | QDialog::accept(); | ||
132 | } | ||
133 | } | ||
134 | |||
135 | void 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 | |||
161 | void ExportDialog::fromPageChanged(int value) | ||
162 | { | ||
163 | if (m_pToPageSpinBox->value() < value) { | ||
164 | m_pToPageSpinBox->setValue(value); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | void 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 | |||
21 | class QComboBox; | ||
22 | class QLineEdit; | ||
23 | class QSpinBox; | ||
24 | |||
25 | class ExportDialog : public QDialog | ||
26 | { | ||
27 | Q_OBJECT | ||
28 | |||
29 | public: | ||
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 | |||
39 | public slots: | ||
40 | void accept(); | ||
41 | |||
42 | private slots: | ||
43 | void selectionChanged(int id); | ||
44 | void fromPageChanged(int value); | ||
45 | void toPageChanged(int value); | ||
46 | |||
47 | private: | ||
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 | |||
22 | FilledEllipseTool::FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | ||
23 | : ShapeTool(drawPad, drawPadCanvas) | ||
24 | { | ||
25 | } | ||
26 | |||
27 | FilledEllipseTool::~FilledEllipseTool() | ||
28 | { | ||
29 | } | ||
30 | |||
31 | void 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 | |||
41 | void 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 | |||
19 | class FilledEllipseTool : public ShapeTool | ||
20 | { | ||
21 | public: | ||
22 | FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas); | ||
23 | ~FilledEllipseTool(); | ||
24 | |||
25 | protected: | ||
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 | |||
19 | FilledRectangleTool::FilledRectangleTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | ||
20 | : ShapeTool(drawPad, drawPadCanvas) | ||
21 | { | ||
22 | } | ||
23 | |||
24 | FilledRectangleTool::~FilledRectangleTool() | ||
25 | { | ||
26 | } | ||
27 | |||
28 | void 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 | |||
38 | void 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 | |||
19 | class FilledRectangleTool : public ShapeTool | ||
20 | { | ||
21 | public: | ||
22 | FilledRectangleTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas); | ||
23 | ~FilledRectangleTool(); | ||
24 | |||
25 | protected: | ||
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 | |||
22 | FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | ||
23 | : Tool(drawPad, drawPadCanvas) | ||
24 | { | ||
25 | } | ||
26 | |||
27 | FillTool::~FillTool() | ||
28 | { | ||
29 | } | ||
30 | |||
31 | void 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 | |||
48 | void FillTool::mouseReleaseEvent(QMouseEvent* e) | ||
49 | { | ||
50 | Q_UNUSED(e) | ||
51 | } | ||
52 | |||
53 | void FillTool::mouseMoveEvent(QMouseEvent* e) | ||
54 | { | ||
55 | Q_UNUSED(e) | ||
56 | } | ||
57 | |||
58 | void 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 | |||
21 | class FillTool : public Tool | ||
22 | { | ||
23 | public: | ||
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 | |||
31 | private: | ||
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 | |||
21 | ImportDialog::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 | |||
34 | ImportDialog::~ImportDialog() | ||
35 | { | ||
36 | } | ||
37 | |||
38 | const 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 | |||
19 | class DocLnk; | ||
20 | class FileSelector; | ||
21 | |||
22 | class ImportDialog : public QDialog | ||
23 | { | ||
24 | Q_OBJECT | ||
25 | |||
26 | public: | ||
27 | ImportDialog(QWidget* parent = 0, const char* name = 0); | ||
28 | ~ImportDialog(); | ||
29 | |||
30 | const DocLnk* selected(); | ||
31 | |||
32 | private: | ||
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 | |||
19 | LineTool::LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | ||
20 | : ShapeTool(drawPad, drawPadCanvas) | ||
21 | { | ||
22 | } | ||
23 | |||
24 | LineTool::~LineTool() | ||
25 | { | ||
26 | } | ||
27 | |||
28 | void 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 | |||
37 | void 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 | |||
19 | class LineTool : public ShapeTool | ||
20 | { | ||
21 | public: | ||
22 | LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas); | ||
23 | ~LineTool(); | ||
24 | |||
25 | protected: | ||
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 | |||
@@ -15,7 +15,11 @@ | |||
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 | ||
20 | NewPageDialog::NewPageDialog(QWidget* parent, const char* name) | 23 | NewPageDialog::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) |
@@ -24,38 +28,75 @@ NewPageDialog::NewPageDialog(QWidget* parent, const char* name) | |||
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 | ||
39 | NewPageDialog::~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 | ||
43 | void NewPageDialog::setWidth(int width) | 72 | NewPageDialog::~NewPageDialog() |
44 | { | 73 | { |
45 | m_pWidthSpinBox->setValue(width); | ||
46 | } | 74 | } |
47 | 75 | ||
48 | void NewPageDialog::setHeight(int height) | 76 | uint NewPageDialog::selectedWidth() |
49 | { | 77 | { |
50 | m_pHeightSpinBox->setValue(height); | 78 | return (m_pWidthSpinBox->value()); |
51 | } | 79 | } |
52 | 80 | ||
53 | int NewPageDialog::width() | 81 | uint NewPageDialog::selectedHeight() |
54 | { | 82 | { |
55 | return m_pWidthSpinBox->value(); | 83 | return (m_pHeightSpinBox->value()); |
56 | } | 84 | } |
57 | 85 | ||
58 | int NewPageDialog::height() | 86 | const 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 | |||
@@ -18,2 +18,3 @@ | |||
18 | 18 | ||
19 | class QButtonGroup; | ||
19 | class QSpinBox; | 20 | class QSpinBox; |
@@ -25,10 +26,9 @@ class NewPageDialog : public QDialog | |||
25 | public: | 26 | public: |
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 | ||
@@ -37,2 +37,7 @@ private: | |||
37 | QSpinBox* m_pHeightSpinBox; | 37 | QSpinBox* m_pHeightSpinBox; |
38 | |||
39 | QColor m_foregroundColor; | ||
40 | QColor m_backgroundColor; | ||
41 | |||
42 | QButtonGroup* m_pContentButtonGroup; | ||
38 | }; | 43 | }; |
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 | |||
22 | PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | ||
23 | : Tool(drawPad, drawPadCanvas) | ||
24 | { | ||
25 | m_mousePressed = false; | ||
26 | m_polyline.resize(3); | ||
27 | } | ||
28 | |||
29 | PointTool::~PointTool() | ||
30 | { | ||
31 | } | ||
32 | |||
33 | void PointTool::mousePressEvent(QMouseEvent* e) | ||
34 | { | ||
35 | m_mousePressed = true; | ||
36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | ||
37 | } | ||
38 | |||
39 | void PointTool::mouseReleaseEvent(QMouseEvent* e) | ||
40 | { | ||
41 | Q_UNUSED(e) | ||
42 | |||
43 | m_mousePressed = false; | ||
44 | } | ||
45 | |||
46 | void 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 | |||
21 | class PointTool : public Tool | ||
22 | { | ||
23 | public: | ||
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 | |||
31 | private: | ||
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 | |||
19 | RectangleTool::RectangleTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | ||
20 | : ShapeTool(drawPad, drawPadCanvas) | ||
21 | { | ||
22 | } | ||
23 | |||
24 | RectangleTool::~RectangleTool() | ||
25 | { | ||
26 | } | ||
27 | |||
28 | void 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 | |||
37 | void 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 | |||
19 | class RectangleTool : public ShapeTool | ||
20 | { | ||
21 | public: | ||
22 | RectangleTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas); | ||
23 | ~RectangleTool(); | ||
24 | |||
25 | protected: | ||
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 | |||
22 | ShapeTool::ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | ||
23 | : Tool(drawPad, drawPadCanvas) | ||
24 | { | ||
25 | m_mousePressed = false; | ||
26 | m_polyline.resize(3); | ||
27 | } | ||
28 | |||
29 | ShapeTool::~ShapeTool() | ||
30 | { | ||
31 | } | ||
32 | |||
33 | void ShapeTool::mousePressEvent(QMouseEvent* e) | ||
34 | { | ||
35 | m_mousePressed = true; | ||
36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | ||
37 | } | ||
38 | |||
39 | void 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 | |||
66 | void 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 | |||
21 | class ShapeTool : public Tool | ||
22 | { | ||
23 | public: | ||
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 | |||
31 | protected: | ||
32 | virtual void drawFinalShape(QPainter& p) = 0; | ||
33 | virtual void drawTemporaryShape(QPainter& p) = 0; | ||
34 | |||
35 | QPointArray m_polyline; | ||
36 | |||
37 | private: | ||
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 | |||
19 | Tool::Tool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | ||
20 | : QObject() | ||
21 | { | ||
22 | m_pDrawPad = drawPad; | ||
23 | m_pDrawPadCanvas = drawPadCanvas; | ||
24 | } | ||
25 | |||
26 | Tool::~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 | |||
19 | class DrawPad; | ||
20 | class DrawPadCanvas; | ||
21 | |||
22 | class Tool : public QObject | ||
23 | { | ||
24 | protected: | ||
25 | Tool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas); | ||
26 | |||
27 | public: | ||
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 | |||
34 | protected: | ||
35 | DrawPad* m_pDrawPad; | ||
36 | DrawPadCanvas* m_pDrawPadCanvas; | ||
37 | }; | ||
38 | |||
39 | #endif // TOOL_H | ||