-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 84 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 3 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.pro | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 29 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.h | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/erasetool.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/filltool.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/pointtool.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/shapetool.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/texttool.cpp | 79 | ||||
-rw-r--r-- | noncore/graphics/drawpad/texttool.h | 46 | ||||
-rw-r--r-- | pics/drawpad/text.png | bin | 0 -> 142 bytes |
12 files changed, 218 insertions, 35 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index 1375792..7e6fc53 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -23,12 +23,13 @@ | |||
23 | #include "filledrectangletool.h" | 23 | #include "filledrectangletool.h" |
24 | #include "filltool.h" | 24 | #include "filltool.h" |
25 | #include "importdialog.h" | 25 | #include "importdialog.h" |
26 | #include "linetool.h" | 26 | #include "linetool.h" |
27 | #include "pointtool.h" | 27 | #include "pointtool.h" |
28 | #include "rectangletool.h" | 28 | #include "rectangletool.h" |
29 | #include "texttool.h" | ||
29 | 30 | ||
30 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
31 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
32 | #include <qpe/qpemenubar.h> | 33 | #include <qpe/qpemenubar.h> |
33 | #include <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
34 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
@@ -126,21 +127,27 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
126 | m_pLastPageAction->addTo(navigationToolBar); | 127 | m_pLastPageAction->addTo(navigationToolBar); |
127 | 128 | ||
128 | // init draw mode toolbar | 129 | // init draw mode toolbar |
129 | 130 | ||
130 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); | 131 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); |
131 | 132 | ||
132 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), QString::null, 0, this); | 133 | m_pLineToolButton = new QToolButton(drawModeToolBar); |
133 | m_pPointToolAction->setToggleAction(true); | 134 | m_pLineToolButton->setToggleButton(true); |
135 | |||
136 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); | ||
137 | |||
138 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), "", 0, this); | ||
134 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); | 139 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); |
135 | m_pPointToolAction->addTo(drawModeToolBar); | 140 | m_pPointToolAction->addTo(linePopupMenu); |
136 | 141 | ||
137 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), QString::null, 0, this); | 142 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), "", 0, this); |
138 | m_pLineToolAction->setToggleAction(true); | ||
139 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); | 143 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); |
140 | m_pLineToolAction->addTo(drawModeToolBar); | 144 | m_pLineToolAction->addTo(linePopupMenu); |
145 | |||
146 | m_pLineToolButton->setPopup(linePopupMenu); | ||
147 | m_pLineToolButton->setPopupDelay(0); | ||
141 | 148 | ||
142 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); | 149 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); |
143 | m_pRectangleToolButton->setToggleButton(true); | 150 | m_pRectangleToolButton->setToggleButton(true); |
144 | 151 | ||
145 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); | 152 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); |
146 | 153 | ||
@@ -168,12 +175,17 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
168 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); | 175 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); |
169 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); | 176 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); |
170 | 177 | ||
171 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); | 178 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); |
172 | m_pEllipseToolButton->setPopupDelay(0); | 179 | m_pEllipseToolButton->setPopupDelay(0); |
173 | 180 | ||
181 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadIconSet("drawpad/text.png"), QString::null, 0, this); | ||
182 | m_pTextToolAction->setToggleAction(true); | ||
183 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); | ||
184 | m_pTextToolAction->addTo(drawModeToolBar); | ||
185 | |||
174 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); | 186 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); |
175 | m_pFillToolAction->setToggleAction(true); | 187 | m_pFillToolAction->setToggleAction(true); |
176 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); | 188 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); |
177 | m_pFillToolAction->addTo(drawModeToolBar); | 189 | m_pFillToolAction->addTo(drawModeToolBar); |
178 | 190 | ||
179 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); | 191 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); |
@@ -270,32 +282,44 @@ void DrawPad::setPointTool() | |||
270 | if (m_pTool) { | 282 | if (m_pTool) { |
271 | delete m_pTool; | 283 | delete m_pTool; |
272 | } | 284 | } |
273 | 285 | ||
274 | m_pTool = new PointTool(this, m_pDrawPadCanvas); | 286 | m_pTool = new PointTool(this, m_pDrawPadCanvas); |
275 | 287 | ||
276 | m_pPointToolAction->setOn(true); | 288 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); |
277 | m_pLineToolAction->setOn(false); | 289 | QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); |
290 | |||
291 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | ||
292 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); | ||
293 | |||
294 | m_pLineToolButton->setOn(true); | ||
278 | m_pRectangleToolButton->setOn(false); | 295 | m_pRectangleToolButton->setOn(false); |
279 | m_pEllipseToolButton->setOn(false); | 296 | m_pEllipseToolButton->setOn(false); |
297 | m_pTextToolAction->setOn(false); | ||
280 | m_pFillToolAction->setOn(false); | 298 | m_pFillToolAction->setOn(false); |
281 | m_pEraseToolAction->setOn(false); | 299 | m_pEraseToolAction->setOn(false); |
282 | } | 300 | } |
283 | 301 | ||
284 | void DrawPad::setLineTool() | 302 | void DrawPad::setLineTool() |
285 | { | 303 | { |
286 | if (m_pTool) { | 304 | if (m_pTool) { |
287 | delete m_pTool; | 305 | delete m_pTool; |
288 | } | 306 | } |
289 | 307 | ||
290 | m_pTool = new LineTool(this, m_pDrawPadCanvas); | 308 | m_pTool = new LineTool(this, m_pDrawPadCanvas); |
291 | 309 | ||
292 | m_pPointToolAction->setOn(false); | 310 | m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); |
293 | m_pLineToolAction->setOn(true); | 311 | QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); |
312 | |||
313 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | ||
314 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); | ||
315 | |||
316 | m_pLineToolButton->setOn(true); | ||
294 | m_pRectangleToolButton->setOn(false); | 317 | m_pRectangleToolButton->setOn(false); |
295 | m_pEllipseToolButton->setOn(false); | 318 | m_pEllipseToolButton->setOn(false); |
319 | m_pTextToolAction->setOn(false); | ||
296 | m_pFillToolAction->setOn(false); | 320 | m_pFillToolAction->setOn(false); |
297 | m_pEraseToolAction->setOn(false); | 321 | m_pEraseToolAction->setOn(false); |
298 | } | 322 | } |
299 | 323 | ||
300 | void DrawPad::setRectangleTool() | 324 | void DrawPad::setRectangleTool() |
301 | { | 325 | { |
@@ -308,16 +332,16 @@ void DrawPad::setRectangleTool() | |||
308 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); | 332 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); |
309 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); | 333 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); |
310 | 334 | ||
311 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 335 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
312 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); | 336 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); |
313 | 337 | ||
314 | m_pPointToolAction->setOn(false); | 338 | m_pLineToolButton->setOn(false); |
315 | m_pLineToolAction->setOn(false); | ||
316 | m_pRectangleToolButton->setOn(true); | 339 | m_pRectangleToolButton->setOn(true); |
317 | m_pEllipseToolButton->setOn(false); | 340 | m_pEllipseToolButton->setOn(false); |
341 | m_pTextToolAction->setOn(false); | ||
318 | m_pFillToolAction->setOn(false); | 342 | m_pFillToolAction->setOn(false); |
319 | m_pEraseToolAction->setOn(false); | 343 | m_pEraseToolAction->setOn(false); |
320 | } | 344 | } |
321 | 345 | ||
322 | void DrawPad::setFilledRectangleTool() | 346 | void DrawPad::setFilledRectangleTool() |
323 | { | 347 | { |
@@ -330,16 +354,16 @@ void DrawPad::setFilledRectangleTool() | |||
330 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); | 354 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); |
331 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); | 355 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); |
332 | 356 | ||
333 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 357 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
334 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); | 358 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); |
335 | 359 | ||
336 | m_pPointToolAction->setOn(false); | 360 | m_pLineToolButton->setOn(false); |
337 | m_pLineToolAction->setOn(false); | ||
338 | m_pRectangleToolButton->setOn(true); | 361 | m_pRectangleToolButton->setOn(true); |
339 | m_pEllipseToolButton->setOn(false); | 362 | m_pEllipseToolButton->setOn(false); |
363 | m_pTextToolAction->setOn(false); | ||
340 | m_pFillToolAction->setOn(false); | 364 | m_pFillToolAction->setOn(false); |
341 | m_pEraseToolAction->setOn(false); | 365 | m_pEraseToolAction->setOn(false); |
342 | } | 366 | } |
343 | 367 | ||
344 | void DrawPad::setEllipseTool() | 368 | void DrawPad::setEllipseTool() |
345 | { | 369 | { |
@@ -352,16 +376,16 @@ void DrawPad::setEllipseTool() | |||
352 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); | 376 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); |
353 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); | 377 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); |
354 | 378 | ||
355 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 379 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
356 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); | 380 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); |
357 | 381 | ||
358 | m_pPointToolAction->setOn(false); | 382 | m_pLineToolButton->setOn(false); |
359 | m_pLineToolAction->setOn(false); | ||
360 | m_pRectangleToolButton->setOn(false); | 383 | m_pRectangleToolButton->setOn(false); |
361 | m_pEllipseToolButton->setOn(true); | 384 | m_pEllipseToolButton->setOn(true); |
385 | m_pTextToolAction->setOn(false); | ||
362 | m_pFillToolAction->setOn(false); | 386 | m_pFillToolAction->setOn(false); |
363 | m_pEraseToolAction->setOn(false); | 387 | m_pEraseToolAction->setOn(false); |
364 | } | 388 | } |
365 | 389 | ||
366 | void DrawPad::setFilledEllipseTool() | 390 | void DrawPad::setFilledEllipseTool() |
367 | { | 391 | { |
@@ -374,48 +398,64 @@ void DrawPad::setFilledEllipseTool() | |||
374 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); | 398 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); |
375 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); | 399 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); |
376 | 400 | ||
377 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 401 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
378 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); | 402 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); |
379 | 403 | ||
380 | m_pPointToolAction->setOn(false); | 404 | m_pLineToolButton->setOn(false); |
381 | m_pLineToolAction->setOn(false); | ||
382 | m_pRectangleToolButton->setOn(false); | 405 | m_pRectangleToolButton->setOn(false); |
383 | m_pEllipseToolButton->setOn(true); | 406 | m_pEllipseToolButton->setOn(true); |
407 | m_pTextToolAction->setOn(false); | ||
408 | m_pFillToolAction->setOn(false); | ||
409 | m_pEraseToolAction->setOn(false); | ||
410 | } | ||
411 | |||
412 | void DrawPad::setTextTool() | ||
413 | { | ||
414 | if (m_pTool) { | ||
415 | delete m_pTool; | ||
416 | } | ||
417 | |||
418 | m_pTool = new TextTool(this, m_pDrawPadCanvas); | ||
419 | |||
420 | m_pLineToolButton->setOn(false); | ||
421 | m_pRectangleToolButton->setOn(false); | ||
422 | m_pEllipseToolButton->setOn(false); | ||
423 | m_pTextToolAction->setOn(true); | ||
384 | m_pFillToolAction->setOn(false); | 424 | m_pFillToolAction->setOn(false); |
385 | m_pEraseToolAction->setOn(false); | 425 | m_pEraseToolAction->setOn(false); |
386 | } | 426 | } |
387 | 427 | ||
388 | void DrawPad::setFillTool() | 428 | void DrawPad::setFillTool() |
389 | { | 429 | { |
390 | if (m_pTool) { | 430 | if (m_pTool) { |
391 | delete m_pTool; | 431 | delete m_pTool; |
392 | } | 432 | } |
393 | 433 | ||
394 | m_pTool = new FillTool(this, m_pDrawPadCanvas); | 434 | m_pTool = new FillTool(this, m_pDrawPadCanvas); |
395 | 435 | ||
396 | m_pPointToolAction->setOn(false); | 436 | m_pLineToolButton->setOn(false); |
397 | m_pLineToolAction->setOn(false); | ||
398 | m_pRectangleToolButton->setOn(false); | 437 | m_pRectangleToolButton->setOn(false); |
399 | m_pEllipseToolButton->setOn(false); | 438 | m_pEllipseToolButton->setOn(false); |
439 | m_pTextToolAction->setOn(false); | ||
400 | m_pFillToolAction->setOn(true); | 440 | m_pFillToolAction->setOn(true); |
401 | m_pEraseToolAction->setOn(false); | 441 | m_pEraseToolAction->setOn(false); |
402 | } | 442 | } |
403 | 443 | ||
404 | void DrawPad::setEraseTool() | 444 | void DrawPad::setEraseTool() |
405 | { | 445 | { |
406 | if (m_pTool) { | 446 | if (m_pTool) { |
407 | delete m_pTool; | 447 | delete m_pTool; |
408 | } | 448 | } |
409 | 449 | ||
410 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); | 450 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); |
411 | 451 | ||
412 | m_pPointToolAction->setOn(false); | 452 | m_pLineToolButton->setOn(false); |
413 | m_pLineToolAction->setOn(false); | ||
414 | m_pRectangleToolButton->setOn(false); | 453 | m_pRectangleToolButton->setOn(false); |
415 | m_pEllipseToolButton->setOn(false); | 454 | m_pEllipseToolButton->setOn(false); |
455 | m_pTextToolAction->setOn(false); | ||
416 | m_pFillToolAction->setOn(false); | 456 | m_pFillToolAction->setOn(false); |
417 | m_pEraseToolAction->setOn(true); | 457 | m_pEraseToolAction->setOn(true); |
418 | } | 458 | } |
419 | 459 | ||
420 | void DrawPad::changePenWidth(int value) | 460 | void DrawPad::changePenWidth(int value) |
421 | { | 461 | { |
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h index 62a73c9..e4fd831 100644 --- a/noncore/graphics/drawpad/drawpad.h +++ b/noncore/graphics/drawpad/drawpad.h | |||
@@ -42,12 +42,13 @@ private slots: | |||
42 | void setPointTool(); | 42 | void setPointTool(); |
43 | void setLineTool(); | 43 | void setLineTool(); |
44 | void setRectangleTool(); | 44 | void setRectangleTool(); |
45 | void setFilledRectangleTool(); | 45 | void setFilledRectangleTool(); |
46 | void setEllipseTool(); | 46 | void setEllipseTool(); |
47 | void setFilledEllipseTool(); | 47 | void setFilledEllipseTool(); |
48 | void setTextTool(); | ||
48 | void setFillTool(); | 49 | void setFillTool(); |
49 | void setEraseTool(); | 50 | void setEraseTool(); |
50 | 51 | ||
51 | void changePenWidth(int value); | 52 | void changePenWidth(int value); |
52 | void changePenColor(const QColor& color); | 53 | void changePenColor(const QColor& color); |
53 | void changeBrushColor(const QColor& color); | 54 | void changeBrushColor(const QColor& color); |
@@ -79,15 +80,17 @@ private: | |||
79 | QAction* m_pPointToolAction; | 80 | QAction* m_pPointToolAction; |
80 | QAction* m_pLineToolAction; | 81 | QAction* m_pLineToolAction; |
81 | QAction* m_pRectangleToolAction; | 82 | QAction* m_pRectangleToolAction; |
82 | QAction* m_pFilledRectangleToolAction; | 83 | QAction* m_pFilledRectangleToolAction; |
83 | QAction* m_pEllipseToolAction; | 84 | QAction* m_pEllipseToolAction; |
84 | QAction* m_pFilledEllipseToolAction; | 85 | QAction* m_pFilledEllipseToolAction; |
86 | QAction* m_pTextToolAction; | ||
85 | QAction* m_pFillToolAction; | 87 | QAction* m_pFillToolAction; |
86 | QAction* m_pEraseToolAction; | 88 | QAction* m_pEraseToolAction; |
87 | 89 | ||
90 | QToolButton* m_pLineToolButton; | ||
88 | QToolButton* m_pRectangleToolButton; | 91 | QToolButton* m_pRectangleToolButton; |
89 | QToolButton* m_pEllipseToolButton; | 92 | QToolButton* m_pEllipseToolButton; |
90 | QToolButton* m_pPenColorToolButton; | 93 | QToolButton* m_pPenColorToolButton; |
91 | QToolButton* m_pBrushColorToolButton; | 94 | QToolButton* m_pBrushColorToolButton; |
92 | }; | 95 | }; |
93 | 96 | ||
diff --git a/noncore/graphics/drawpad/drawpad.pro b/noncore/graphics/drawpad/drawpad.pro index fce0701..00eb00d 100644 --- a/noncore/graphics/drawpad/drawpad.pro +++ b/noncore/graphics/drawpad/drawpad.pro | |||
@@ -13,12 +13,13 @@ HEADERS = colordialog.h \ | |||
13 | importdialog.h \ | 13 | importdialog.h \ |
14 | linetool.h \ | 14 | linetool.h \ |
15 | newpagedialog.h \ | 15 | newpagedialog.h \ |
16 | pointtool.h \ | 16 | pointtool.h \ |
17 | rectangletool.h \ | 17 | rectangletool.h \ |
18 | shapetool.h \ | 18 | shapetool.h \ |
19 | texttool.h \ | ||
19 | tool.h | 20 | tool.h |
20 | SOURCES = colordialog.cpp \ | 21 | SOURCES = colordialog.cpp \ |
21 | colorpanel.cpp \ | 22 | colorpanel.cpp \ |
22 | drawpad.cpp \ | 23 | drawpad.cpp \ |
23 | drawpadcanvas.cpp \ | 24 | drawpadcanvas.cpp \ |
24 | ellipsetool.cpp \ | 25 | ellipsetool.cpp \ |
@@ -31,12 +32,13 @@ SOURCES = colordialog.cpp \ | |||
31 | linetool.cpp \ | 32 | linetool.cpp \ |
32 | main.cpp \ | 33 | main.cpp \ |
33 | newpagedialog.cpp \ | 34 | newpagedialog.cpp \ |
34 | pointtool.cpp \ | 35 | pointtool.cpp \ |
35 | rectangletool.cpp \ | 36 | rectangletool.cpp \ |
36 | shapetool.cpp \ | 37 | shapetool.cpp \ |
38 | texttool.cpp \ | ||
37 | tool.cpp | 39 | tool.cpp |
38 | INCLUDEPATH+= $(OPIEDIR)/include \ | 40 | INCLUDEPATH+= $(OPIEDIR)/include \ |
39 | $(QTDIR)/src/3rdparty/zlib | 41 | $(QTDIR)/src/3rdparty/zlib |
40 | DEPENDPATH+= $(OPIEDIR)/include | 42 | DEPENDPATH+= $(OPIEDIR)/include |
41 | LIBS += -lqpe | 43 | LIBS += -lqpe |
42 | DESTDIR = $(OPIEDIR)/bin | 44 | DESTDIR = $(OPIEDIR)/bin |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index db6288f..b39a633 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -325,12 +325,28 @@ uint DrawPadCanvas::pagePosition() | |||
325 | 325 | ||
326 | uint DrawPadCanvas::pageCount() | 326 | uint DrawPadCanvas::pageCount() |
327 | { | 327 | { |
328 | return m_pages.count(); | 328 | return m_pages.count(); |
329 | } | 329 | } |
330 | 330 | ||
331 | void DrawPadCanvas::backupPage() | ||
332 | { | ||
333 | QPixmap* currentBackup = m_pageBackups.current(); | ||
334 | while (m_pageBackups.last() != currentBackup) { | ||
335 | m_pageBackups.removeLast(); | ||
336 | } | ||
337 | |||
338 | while (m_pageBackups.count() >= (5 + 1)) { | ||
339 | m_pageBackups.removeFirst(); | ||
340 | } | ||
341 | |||
342 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | ||
343 | |||
344 | emit pageBackupsChanged(); | ||
345 | } | ||
346 | |||
331 | void DrawPadCanvas::deleteAll() | 347 | void DrawPadCanvas::deleteAll() |
332 | { | 348 | { |
333 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), | 349 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), |
334 | QMessageBox::Information, QMessageBox::Yes, | 350 | QMessageBox::Information, QMessageBox::Yes, |
335 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 351 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
336 | QMessageBox::NoButton, this); | 352 | QMessageBox::NoButton, this); |
@@ -510,25 +526,12 @@ void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) | |||
510 | m_pDrawPad->tool()->mousePressEvent(e); | 526 | m_pDrawPad->tool()->mousePressEvent(e); |
511 | } | 527 | } |
512 | 528 | ||
513 | void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) | 529 | void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) |
514 | { | 530 | { |
515 | m_pDrawPad->tool()->mouseReleaseEvent(e); | 531 | m_pDrawPad->tool()->mouseReleaseEvent(e); |
516 | |||
517 | QPixmap* currentBackup = m_pageBackups.current(); | ||
518 | while (m_pageBackups.last() != currentBackup) { | ||
519 | m_pageBackups.removeLast(); | ||
520 | } | ||
521 | |||
522 | while (m_pageBackups.count() >= (5 + 1)) { | ||
523 | m_pageBackups.removeFirst(); | ||
524 | } | ||
525 | |||
526 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | ||
527 | |||
528 | emit pageBackupsChanged(); | ||
529 | } | 532 | } |
530 | 533 | ||
531 | void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) | 534 | void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) |
532 | { | 535 | { |
533 | m_pDrawPad->tool()->mouseMoveEvent(e); | 536 | m_pDrawPad->tool()->mouseMoveEvent(e); |
534 | } | 537 | } |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h index a1a9466..e05ce8a 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.h +++ b/noncore/graphics/drawpad/drawpadcanvas.h | |||
@@ -45,12 +45,14 @@ public: | |||
45 | 45 | ||
46 | QPixmap* currentPage(); | 46 | QPixmap* currentPage(); |
47 | QList<QPixmap> pages(); | 47 | QList<QPixmap> pages(); |
48 | uint pagePosition(); | 48 | uint pagePosition(); |
49 | uint pageCount(); | 49 | uint pageCount(); |
50 | 50 | ||
51 | void backupPage(); | ||
52 | |||
51 | public slots: | 53 | public slots: |
52 | void deleteAll(); | 54 | void deleteAll(); |
53 | void newPage(); | 55 | void newPage(); |
54 | void clearPage(); | 56 | void clearPage(); |
55 | void deletePage(); | 57 | void deletePage(); |
56 | 58 | ||
diff --git a/noncore/graphics/drawpad/erasetool.cpp b/noncore/graphics/drawpad/erasetool.cpp index d37c901..828994b 100644 --- a/noncore/graphics/drawpad/erasetool.cpp +++ b/noncore/graphics/drawpad/erasetool.cpp | |||
@@ -38,12 +38,14 @@ void EraseTool::mousePressEvent(QMouseEvent* e) | |||
38 | 38 | ||
39 | void EraseTool::mouseReleaseEvent(QMouseEvent* e) | 39 | void EraseTool::mouseReleaseEvent(QMouseEvent* e) |
40 | { | 40 | { |
41 | Q_UNUSED(e) | 41 | Q_UNUSED(e) |
42 | 42 | ||
43 | m_mousePressed = false; | 43 | m_mousePressed = false; |
44 | |||
45 | m_pDrawPadCanvas->backupPage(); | ||
44 | } | 46 | } |
45 | 47 | ||
46 | void EraseTool::mouseMoveEvent(QMouseEvent* e) | 48 | void EraseTool::mouseMoveEvent(QMouseEvent* e) |
47 | { | 49 | { |
48 | if (m_mousePressed) { | 50 | if (m_mousePressed) { |
49 | QPainter painter; | 51 | QPainter painter; |
diff --git a/noncore/graphics/drawpad/filltool.cpp b/noncore/graphics/drawpad/filltool.cpp index 3297d21..004da02 100644 --- a/noncore/graphics/drawpad/filltool.cpp +++ b/noncore/graphics/drawpad/filltool.cpp | |||
@@ -39,12 +39,14 @@ void FillTool::mousePressEvent(QMouseEvent* e) | |||
39 | 39 | ||
40 | if (m_oldRgb != m_fillRgb) { | 40 | if (m_oldRgb != m_fillRgb) { |
41 | fillLine(x, y); | 41 | fillLine(x, y); |
42 | 42 | ||
43 | m_pDrawPadCanvas->currentPage()->convertFromImage(m_image); | 43 | m_pDrawPadCanvas->currentPage()->convertFromImage(m_image); |
44 | m_pDrawPadCanvas->viewport()->update(); | 44 | m_pDrawPadCanvas->viewport()->update(); |
45 | |||
46 | m_pDrawPadCanvas->backupPage(); | ||
45 | } | 47 | } |
46 | } | 48 | } |
47 | 49 | ||
48 | void FillTool::mouseReleaseEvent(QMouseEvent* e) | 50 | void FillTool::mouseReleaseEvent(QMouseEvent* e) |
49 | { | 51 | { |
50 | Q_UNUSED(e) | 52 | Q_UNUSED(e) |
diff --git a/noncore/graphics/drawpad/pointtool.cpp b/noncore/graphics/drawpad/pointtool.cpp index 5661b03..e281284 100644 --- a/noncore/graphics/drawpad/pointtool.cpp +++ b/noncore/graphics/drawpad/pointtool.cpp | |||
@@ -38,12 +38,14 @@ void PointTool::mousePressEvent(QMouseEvent* e) | |||
38 | 38 | ||
39 | void PointTool::mouseReleaseEvent(QMouseEvent* e) | 39 | void PointTool::mouseReleaseEvent(QMouseEvent* e) |
40 | { | 40 | { |
41 | Q_UNUSED(e) | 41 | Q_UNUSED(e) |
42 | 42 | ||
43 | m_mousePressed = false; | 43 | m_mousePressed = false; |
44 | |||
45 | m_pDrawPadCanvas->backupPage(); | ||
44 | } | 46 | } |
45 | 47 | ||
46 | void PointTool::mouseMoveEvent(QMouseEvent* e) | 48 | void PointTool::mouseMoveEvent(QMouseEvent* e) |
47 | { | 49 | { |
48 | if (m_mousePressed) { | 50 | if (m_mousePressed) { |
49 | QPainter painter; | 51 | QPainter painter; |
diff --git a/noncore/graphics/drawpad/shapetool.cpp b/noncore/graphics/drawpad/shapetool.cpp index 3c99370..bc5d9c0 100644 --- a/noncore/graphics/drawpad/shapetool.cpp +++ b/noncore/graphics/drawpad/shapetool.cpp | |||
@@ -58,12 +58,14 @@ void ShapeTool::mouseReleaseEvent(QMouseEvent* e) | |||
58 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 58 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
59 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | 59 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); |
60 | 60 | ||
61 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 61 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
62 | 62 | ||
63 | m_mousePressed = false; | 63 | m_mousePressed = false; |
64 | |||
65 | m_pDrawPadCanvas->backupPage(); | ||
64 | } | 66 | } |
65 | 67 | ||
66 | void ShapeTool::mouseMoveEvent(QMouseEvent* e) | 68 | void ShapeTool::mouseMoveEvent(QMouseEvent* e) |
67 | { | 69 | { |
68 | if (m_mousePressed) { | 70 | if (m_mousePressed) { |
69 | m_polyline[0] = e->pos(); | 71 | m_polyline[0] = e->pos(); |
diff --git a/noncore/graphics/drawpad/texttool.cpp b/noncore/graphics/drawpad/texttool.cpp new file mode 100644 index 0000000..37b4801 --- a/dev/null +++ b/noncore/graphics/drawpad/texttool.cpp | |||
@@ -0,0 +1,79 @@ | |||
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 "texttool.h" | ||
15 | |||
16 | #include "drawpad.h" | ||
17 | #include "drawpadcanvas.h" | ||
18 | |||
19 | #include <qlayout.h> | ||
20 | #include <qlineedit.h> | ||
21 | #include <qpainter.h> | ||
22 | #include <qpixmap.h> | ||
23 | |||
24 | TextToolDialog::TextToolDialog(QWidget* parent, const char* name) | ||
25 | : QDialog(parent, name, true) | ||
26 | { | ||
27 | setCaption(tr("Insert Text")); | ||
28 | |||
29 | m_pLineEdit = new QLineEdit(this); | ||
30 | |||
31 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | ||
32 | |||
33 | mainLayout->addWidget(m_pLineEdit); | ||
34 | } | ||
35 | |||
36 | TextToolDialog::~TextToolDialog() | ||
37 | { | ||
38 | } | ||
39 | |||
40 | QString TextToolDialog::text() | ||
41 | { | ||
42 | return m_pLineEdit->text(); | ||
43 | } | ||
44 | |||
45 | TextTool::TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | ||
46 | : Tool(drawPad, drawPadCanvas) | ||
47 | { | ||
48 | } | ||
49 | |||
50 | TextTool::~TextTool() | ||
51 | { | ||
52 | } | ||
53 | |||
54 | void TextTool::mousePressEvent(QMouseEvent* e) | ||
55 | { | ||
56 | TextToolDialog textToolDialog(m_pDrawPad); | ||
57 | |||
58 | if (textToolDialog.exec() == QDialog::Accepted && !textToolDialog.text().isEmpty()) { | ||
59 | QPainter painter; | ||
60 | painter.begin(m_pDrawPadCanvas->currentPage()); | ||
61 | painter.setPen(m_pDrawPad->pen()); | ||
62 | painter.drawText(e->x(), e->y(), textToolDialog.text()); | ||
63 | painter.end(); | ||
64 | |||
65 | m_pDrawPadCanvas->viewport()->update(); | ||
66 | |||
67 | m_pDrawPadCanvas->backupPage(); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | void TextTool::mouseReleaseEvent(QMouseEvent* e) | ||
72 | { | ||
73 | Q_UNUSED(e) | ||
74 | } | ||
75 | |||
76 | void TextTool::mouseMoveEvent(QMouseEvent* e) | ||
77 | { | ||
78 | Q_UNUSED(e) | ||
79 | } | ||
diff --git a/noncore/graphics/drawpad/texttool.h b/noncore/graphics/drawpad/texttool.h new file mode 100644 index 0000000..3187675 --- a/dev/null +++ b/noncore/graphics/drawpad/texttool.h | |||
@@ -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 | #ifndef TEXTTOOL_H | ||
15 | #define TEXTTOOL_H | ||
16 | |||
17 | #include "tool.h" | ||
18 | |||
19 | #include <qdialog.h> | ||
20 | |||
21 | class QLineEdit; | ||
22 | |||
23 | class TextToolDialog : public QDialog | ||
24 | { | ||
25 | public: | ||
26 | TextToolDialog(QWidget* parent = 0, const char* name = 0); | ||
27 | ~TextToolDialog(); | ||
28 | |||
29 | QString text(); | ||
30 | |||
31 | private: | ||
32 | QLineEdit* m_pLineEdit; | ||
33 | }; | ||
34 | |||
35 | class TextTool : public Tool | ||
36 | { | ||
37 | public: | ||
38 | TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas); | ||
39 | ~TextTool(); | ||
40 | |||
41 | void mousePressEvent(QMouseEvent* e); | ||
42 | void mouseReleaseEvent(QMouseEvent* e); | ||
43 | void mouseMoveEvent(QMouseEvent* e); | ||
44 | }; | ||
45 | |||
46 | #endif // TEXTTOOL_H | ||
diff --git a/pics/drawpad/text.png b/pics/drawpad/text.png new file mode 100644 index 0000000..230d72b --- a/dev/null +++ b/pics/drawpad/text.png | |||
Binary files differ | |||