summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp84
-rw-r--r--noncore/graphics/drawpad/drawpad.h3
-rw-r--r--noncore/graphics/drawpad/drawpad.pro2
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp29
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h2
-rw-r--r--noncore/graphics/drawpad/erasetool.cpp2
-rw-r--r--noncore/graphics/drawpad/filltool.cpp2
-rw-r--r--noncore/graphics/drawpad/pointtool.cpp2
-rw-r--r--noncore/graphics/drawpad/shapetool.cpp2
-rw-r--r--noncore/graphics/drawpad/texttool.cpp79
-rw-r--r--noncore/graphics/drawpad/texttool.h46
-rw-r--r--pics/drawpad/text.pngbin0 -> 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
@@ -27,4 +27,5 @@
#include "pointtool.h"
#include "rectangletool.h"
+#include "texttool.h"
#include <qpe/applnk.h>
@@ -130,13 +131,19 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
QPEToolBar* drawModeToolBar = new QPEToolBar(this);
- m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), QString::null, 0, this);
- m_pPointToolAction->setToggleAction(true);
+ m_pLineToolButton = new QToolButton(drawModeToolBar);
+ m_pLineToolButton->setToggleButton(true);
+
+ QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton);
+
+ m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), "", 0, this);
connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool()));
- m_pPointToolAction->addTo(drawModeToolBar);
+ m_pPointToolAction->addTo(linePopupMenu);
- m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), QString::null, 0, this);
- m_pLineToolAction->setToggleAction(true);
+ m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), "", 0, this);
connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool()));
- m_pLineToolAction->addTo(drawModeToolBar);
+ m_pLineToolAction->addTo(linePopupMenu);
+
+ m_pLineToolButton->setPopup(linePopupMenu);
+ m_pLineToolButton->setPopupDelay(0);
m_pRectangleToolButton = new QToolButton(drawModeToolBar);
@@ -172,4 +179,9 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
m_pEllipseToolButton->setPopupDelay(0);
+ m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadIconSet("drawpad/text.png"), QString::null, 0, this);
+ m_pTextToolAction->setToggleAction(true);
+ connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool()));
+ m_pTextToolAction->addTo(drawModeToolBar);
+
m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this);
m_pFillToolAction->setToggleAction(true);
@@ -274,8 +286,14 @@ void DrawPad::setPointTool()
m_pTool = new PointTool(this, m_pDrawPadCanvas);
- m_pPointToolAction->setOn(true);
- m_pLineToolAction->setOn(false);
+ m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet());
+ QToolTip::add(m_pLineToolButton, m_pPointToolAction->text());
+
+ disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0);
+ connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated()));
+
+ m_pLineToolButton->setOn(true);
m_pRectangleToolButton->setOn(false);
m_pEllipseToolButton->setOn(false);
+ m_pTextToolAction->setOn(false);
m_pFillToolAction->setOn(false);
m_pEraseToolAction->setOn(false);
@@ -290,8 +308,14 @@ void DrawPad::setLineTool()
m_pTool = new LineTool(this, m_pDrawPadCanvas);
- m_pPointToolAction->setOn(false);
- m_pLineToolAction->setOn(true);
+ m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet());
+ QToolTip::add(m_pLineToolButton, m_pLineToolAction->text());
+
+ disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0);
+ connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated()));
+
+ m_pLineToolButton->setOn(true);
m_pRectangleToolButton->setOn(false);
m_pEllipseToolButton->setOn(false);
+ m_pTextToolAction->setOn(false);
m_pFillToolAction->setOn(false);
m_pEraseToolAction->setOn(false);
@@ -312,8 +336,8 @@ void DrawPad::setRectangleTool()
connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated()));
- m_pPointToolAction->setOn(false);
- m_pLineToolAction->setOn(false);
+ m_pLineToolButton->setOn(false);
m_pRectangleToolButton->setOn(true);
m_pEllipseToolButton->setOn(false);
+ m_pTextToolAction->setOn(false);
m_pFillToolAction->setOn(false);
m_pEraseToolAction->setOn(false);
@@ -334,8 +358,8 @@ void DrawPad::setFilledRectangleTool()
connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated()));
- m_pPointToolAction->setOn(false);
- m_pLineToolAction->setOn(false);
+ m_pLineToolButton->setOn(false);
m_pRectangleToolButton->setOn(true);
m_pEllipseToolButton->setOn(false);
+ m_pTextToolAction->setOn(false);
m_pFillToolAction->setOn(false);
m_pEraseToolAction->setOn(false);
@@ -356,8 +380,8 @@ void DrawPad::setEllipseTool()
connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated()));
- m_pPointToolAction->setOn(false);
- m_pLineToolAction->setOn(false);
+ m_pLineToolButton->setOn(false);
m_pRectangleToolButton->setOn(false);
m_pEllipseToolButton->setOn(true);
+ m_pTextToolAction->setOn(false);
m_pFillToolAction->setOn(false);
m_pEraseToolAction->setOn(false);
@@ -378,8 +402,24 @@ void DrawPad::setFilledEllipseTool()
connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated()));
- m_pPointToolAction->setOn(false);
- m_pLineToolAction->setOn(false);
+ m_pLineToolButton->setOn(false);
m_pRectangleToolButton->setOn(false);
m_pEllipseToolButton->setOn(true);
+ m_pTextToolAction->setOn(false);
+ m_pFillToolAction->setOn(false);
+ m_pEraseToolAction->setOn(false);
+}
+
+void DrawPad::setTextTool()
+{
+ if (m_pTool) {
+ delete m_pTool;
+ }
+
+ m_pTool = new TextTool(this, m_pDrawPadCanvas);
+
+ m_pLineToolButton->setOn(false);
+ m_pRectangleToolButton->setOn(false);
+ m_pEllipseToolButton->setOn(false);
+ m_pTextToolAction->setOn(true);
m_pFillToolAction->setOn(false);
m_pEraseToolAction->setOn(false);
@@ -394,8 +434,8 @@ void DrawPad::setFillTool()
m_pTool = new FillTool(this, m_pDrawPadCanvas);
- m_pPointToolAction->setOn(false);
- m_pLineToolAction->setOn(false);
+ m_pLineToolButton->setOn(false);
m_pRectangleToolButton->setOn(false);
m_pEllipseToolButton->setOn(false);
+ m_pTextToolAction->setOn(false);
m_pFillToolAction->setOn(true);
m_pEraseToolAction->setOn(false);
@@ -410,8 +450,8 @@ void DrawPad::setEraseTool()
m_pTool = new EraseTool(this, m_pDrawPadCanvas);
- m_pPointToolAction->setOn(false);
- m_pLineToolAction->setOn(false);
+ m_pLineToolButton->setOn(false);
m_pRectangleToolButton->setOn(false);
m_pEllipseToolButton->setOn(false);
+ m_pTextToolAction->setOn(false);
m_pFillToolAction->setOn(false);
m_pEraseToolAction->setOn(true);
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
@@ -46,4 +46,5 @@ private slots:
void setEllipseTool();
void setFilledEllipseTool();
+ void setTextTool();
void setFillTool();
void setEraseTool();
@@ -83,7 +84,9 @@ private:
QAction* m_pEllipseToolAction;
QAction* m_pFilledEllipseToolAction;
+ QAction* m_pTextToolAction;
QAction* m_pFillToolAction;
QAction* m_pEraseToolAction;
+ QToolButton* m_pLineToolButton;
QToolButton* m_pRectangleToolButton;
QToolButton* m_pEllipseToolButton;
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
@@ -17,4 +17,5 @@ HEADERS = colordialog.h \
rectangletool.h \
shapetool.h \
+ texttool.h \
tool.h
SOURCES = colordialog.cpp \
@@ -35,4 +36,5 @@ SOURCES = colordialog.cpp \
rectangletool.cpp \
shapetool.cpp \
+ texttool.cpp \
tool.cpp
INCLUDEPATH += $(OPIEDIR)/include \
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
@@ -329,4 +329,20 @@ uint DrawPadCanvas::pageCount()
}
+void DrawPadCanvas::backupPage()
+{
+ QPixmap* currentBackup = m_pageBackups.current();
+ while (m_pageBackups.last() != currentBackup) {
+ m_pageBackups.removeLast();
+ }
+
+ while (m_pageBackups.count() >= (5 + 1)) {
+ m_pageBackups.removeFirst();
+ }
+
+ m_pageBackups.append(new QPixmap(*(m_pages.current())));
+
+ emit pageBackupsChanged();
+}
+
void DrawPadCanvas::deleteAll()
{
@@ -514,17 +530,4 @@ void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e)
{
m_pDrawPad->tool()->mouseReleaseEvent(e);
-
- QPixmap* currentBackup = m_pageBackups.current();
- while (m_pageBackups.last() != currentBackup) {
- m_pageBackups.removeLast();
- }
-
- while (m_pageBackups.count() >= (5 + 1)) {
- m_pageBackups.removeFirst();
- }
-
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
-
- emit pageBackupsChanged();
}
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
@@ -49,4 +49,6 @@ public:
uint pageCount();
+ void backupPage();
+
public slots:
void deleteAll();
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
@@ -42,4 +42,6 @@ void EraseTool::mouseReleaseEvent(QMouseEvent* e)
m_mousePressed = false;
+
+ m_pDrawPadCanvas->backupPage();
}
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
@@ -43,4 +43,6 @@ void FillTool::mousePressEvent(QMouseEvent* e)
m_pDrawPadCanvas->currentPage()->convertFromImage(m_image);
m_pDrawPadCanvas->viewport()->update();
+
+ m_pDrawPadCanvas->backupPage();
}
}
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
@@ -42,4 +42,6 @@ void PointTool::mouseReleaseEvent(QMouseEvent* e)
m_mousePressed = false;
+
+ m_pDrawPadCanvas->backupPage();
}
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
@@ -62,4 +62,6 @@ void ShapeTool::mouseReleaseEvent(QMouseEvent* e)
m_mousePressed = false;
+
+ m_pDrawPadCanvas->backupPage();
}
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 @@
+/***************************************************************************
+ * *
+ * DrawPad - a drawing program for Opie Environment *
+ * *
+ * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "texttool.h"
+
+#include "drawpad.h"
+#include "drawpadcanvas.h"
+
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+
+TextToolDialog::TextToolDialog(QWidget* parent, const char* name)
+ : QDialog(parent, name, true)
+{
+ setCaption(tr("Insert Text"));
+
+ m_pLineEdit = new QLineEdit(this);
+
+ QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
+
+ mainLayout->addWidget(m_pLineEdit);
+}
+
+TextToolDialog::~TextToolDialog()
+{
+}
+
+QString TextToolDialog::text()
+{
+ return m_pLineEdit->text();
+}
+
+TextTool::TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
+ : Tool(drawPad, drawPadCanvas)
+{
+}
+
+TextTool::~TextTool()
+{
+}
+
+void TextTool::mousePressEvent(QMouseEvent* e)
+{
+ TextToolDialog textToolDialog(m_pDrawPad);
+
+ if (textToolDialog.exec() == QDialog::Accepted && !textToolDialog.text().isEmpty()) {
+ QPainter painter;
+ painter.begin(m_pDrawPadCanvas->currentPage());
+ painter.setPen(m_pDrawPad->pen());
+ painter.drawText(e->x(), e->y(), textToolDialog.text());
+ painter.end();
+
+ m_pDrawPadCanvas->viewport()->update();
+
+ m_pDrawPadCanvas->backupPage();
+ }
+}
+
+void TextTool::mouseReleaseEvent(QMouseEvent* e)
+{
+ Q_UNUSED(e)
+}
+
+void TextTool::mouseMoveEvent(QMouseEvent* e)
+{
+ Q_UNUSED(e)
+}
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 @@
+/***************************************************************************
+ * *
+ * DrawPad - a drawing program for Opie Environment *
+ * *
+ * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef TEXTTOOL_H
+#define TEXTTOOL_H
+
+#include "tool.h"
+
+#include <qdialog.h>
+
+class QLineEdit;
+
+class TextToolDialog : public QDialog
+{
+public:
+ TextToolDialog(QWidget* parent = 0, const char* name = 0);
+ ~TextToolDialog();
+
+ QString text();
+
+private:
+ QLineEdit* m_pLineEdit;
+};
+
+class TextTool : public Tool
+{
+public:
+ TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
+ ~TextTool();
+
+ void mousePressEvent(QMouseEvent* e);
+ void mouseReleaseEvent(QMouseEvent* e);
+ void mouseMoveEvent(QMouseEvent* e);
+};
+
+#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