00001 /*************************************************************************** 00002 * * 00003 * DrawPad - a drawing program for Opie Environment * 00004 * * 00005 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 ***************************************************************************/ 00013 00014 #include "texttool.h" 00015 00016 #include "drawpad.h" 00017 #include "drawpadcanvas.h" 00018 #include "page.h" 00019 00020 #include <qlayout.h> 00021 #include <qlineedit.h> 00022 00023 TextToolDialog::TextToolDialog(QWidget* parent, const char* name) 00024 : QDialog(parent, name, true) 00025 { 00026 setCaption(tr("Insert Text")); 00027 00028 m_pLineEdit = new QLineEdit(this); 00029 00030 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 00031 00032 mainLayout->addWidget(m_pLineEdit); 00033 } 00034 00035 TextToolDialog::~TextToolDialog() 00036 { 00037 } 00038 00039 QString TextToolDialog::text() 00040 { 00041 return m_pLineEdit->text(); 00042 } 00043 00044 TextTool::TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) 00045 : Tool(drawPad, drawPadCanvas) 00046 { 00047 } 00048 00049 TextTool::~TextTool() 00050 { 00051 } 00052 00053 void TextTool::mousePressEvent(QMouseEvent* e) 00054 { 00055 TextToolDialog textToolDialog(m_pDrawPad); 00056 00057 if (textToolDialog.exec() == QDialog::Accepted && !textToolDialog.text().isEmpty()) { 00058 m_pDrawPadCanvas->backupPage(); 00059 00060 QPainter painter; 00061 painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); 00062 painter.setPen(m_pDrawPad->pen()); 00063 painter.drawText(e->x(), e->y(), textToolDialog.text()); 00064 painter.end(); 00065 00066 m_pDrawPadCanvas->viewport()->update(); 00067 } 00068 } 00069 00070 void TextTool::mouseReleaseEvent(QMouseEvent* e) 00071 { 00072 Q_UNUSED(e) 00073 } 00074 00075 void TextTool::mouseMoveEvent(QMouseEvent* e) 00076 { 00077 Q_UNUSED(e) 00078 }
1.4.2