summaryrefslogtreecommitdiff
path: root/noncore/graphics/drawpad/texttool.cpp
Unidiff
Diffstat (limited to 'noncore/graphics/drawpad/texttool.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/texttool.cpp79
1 files changed, 79 insertions, 0 deletions
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
24TextToolDialog::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
36TextToolDialog::~TextToolDialog()
37{
38}
39
40QString TextToolDialog::text()
41{
42 return m_pLineEdit->text();
43}
44
45TextTool::TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
46 : Tool(drawPad, drawPadCanvas)
47{
48}
49
50TextTool::~TextTool()
51{
52}
53
54void 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
71void TextTool::mouseReleaseEvent(QMouseEvent* e)
72{
73 Q_UNUSED(e)
74}
75
76void TextTool::mouseMoveEvent(QMouseEvent* e)
77{
78 Q_UNUSED(e)
79}