summaryrefslogtreecommitdiff
authorleseb <leseb>2002-06-23 17:47:47 (UTC)
committer leseb <leseb>2002-06-23 17:47:47 (UTC)
commit6fd46f6d23538ec6e0f48209f6c0f0d939a2effe (patch) (side-by-side diff)
tree2a5d407155f72dc5496d3a7d412922cc6be97e61
parent3251c55f854ecbd4ece8bf169177ffac28081aaa (diff)
downloadopie-6fd46f6d23538ec6e0f48209f6c0f0d939a2effe.zip
opie-6fd46f6d23538ec6e0f48209f6c0f0d939a2effe.tar.gz
opie-6fd46f6d23538ec6e0f48209f6c0f0d939a2effe.tar.bz2
Anti-aliasing as an option
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp13
-rw-r--r--noncore/graphics/drawpad/drawpad.h4
-rw-r--r--noncore/graphics/drawpad/ellipsetool.cpp57
-rw-r--r--noncore/graphics/drawpad/filledellipsetool.cpp60
-rw-r--r--noncore/graphics/drawpad/linetool.cpp55
-rw-r--r--noncore/graphics/drawpad/pointtool.cpp54
6 files changed, 140 insertions, 103 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 45fb886..b29f5ba 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -22,122 +22,128 @@
#include "filltool.h"
#include "importdialog.h"
#include "linetool.h"
#include "newpagedialog.h"
#include "page.h"
#include "pageinformationdialog.h"
#include "pointtool.h"
#include "rectangletool.h"
#include "texttool.h"
#include "thumbnailview.h"
#include <opie/colordialog.h>
#include <opie/colorpopupmenu.h>
#include <qpe/applnk.h>
#include <qpe/global.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/resource.h>
#include <qaction.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qpainter.h>
#include <qspinbox.h>
#include <qtoolbutton.h>
#include <qtooltip.h>
DrawPad::DrawPad(QWidget* parent, const char* name)
: QMainWindow(parent, name)
{
// init members
m_pDrawPadCanvas = new DrawPadCanvas(this, this);
connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons()));
connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption()));
connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons()));
setCentralWidget(m_pDrawPadCanvas);
// init menu
setToolBarsMovable(false);
QPEToolBar* menuToolBar = new QPEToolBar(this);
QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar);
- QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar);
+ QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar);
QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll()));
deleteAllAction->addTo(toolsPopupMenu);
toolsPopupMenu->insertSeparator();
QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this);
connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage()));
importPageAction->addTo(toolsPopupMenu);
QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this);
connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage()));
exportPageAction->addTo(toolsPopupMenu);
toolsPopupMenu->insertSeparator();
QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this);
connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView()));
thumbnailViewAction->addTo(toolsPopupMenu);
QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this);
connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation()));
pageInformationAction->addTo(toolsPopupMenu);
+ toolsPopupMenu->insertSeparator();
+
+ m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this);
+ m_pAntiAliasingAction->setToggleAction(true);
+ m_pAntiAliasingAction->addTo(toolsPopupMenu);
+
menuBar->insertItem(tr("Tools"), toolsPopupMenu);
// init page toolbar
QPEToolBar* pageToolBar = new QPEToolBar(this);
QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this);
connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage()));
newPageAction->addTo(pageToolBar);
QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this);
connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage()));
clearPageAction->addTo(pageToolBar);
QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this);
connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage()));
deletePageAction->addTo(pageToolBar);
QPEToolBar* emptyToolBar = new QPEToolBar(this);
emptyToolBar->setHorizontalStretchable(true);
// init navigation toolbar
QPEToolBar* navigationToolBar = new QPEToolBar(this);
m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this);
connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo()));
m_pUndoAction->addTo(navigationToolBar);
m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this);
connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo()));
m_pRedoAction->addTo(navigationToolBar);
m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this);
connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage()));
m_pFirstPageAction->addTo(navigationToolBar);
m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this);
connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage()));
m_pPreviousPageAction->addTo(navigationToolBar);
m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this);
connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage()));
m_pNextPageAction->addTo(navigationToolBar);
m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this);
connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage()));
m_pLastPageAction->addTo(navigationToolBar);
@@ -230,96 +236,101 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
penWidthSpinBox->setFocusPolicy(QWidget::NoFocus);
m_pPenColorToolButton = new QToolButton(drawParametersToolBar);
m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png"));
ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, m_pPenColorToolButton);
connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&)));
QToolTip::add(m_pPenColorToolButton, tr("Pen Color"));
m_pPenColorToolButton->setPopup(penColorPopupMenu);
m_pPenColorToolButton->setPopupDelay(0);
changePenColor(Qt::black);
m_pBrushColorToolButton = new QToolButton(drawParametersToolBar);
m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png"));
ColorPopupMenu* brushColorPopupMenu = new ColorPopupMenu(Qt::white, m_pBrushColorToolButton);
connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&)));
QToolTip::add(m_pBrushColorToolButton, tr("Fill Color"));
m_pBrushColorToolButton->setPopup(brushColorPopupMenu);
m_pBrushColorToolButton->setPopupDelay(0);
changeBrushColor(Qt::white);
// init pages
QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
if (file.open(IO_ReadOnly)) {
m_pDrawPadCanvas->load(&file);
file.close();
} else {
m_pDrawPadCanvas->initialPage();
}
}
DrawPad::~DrawPad()
{
QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
if (file.open(IO_WriteOnly)) {
m_pDrawPadCanvas->save(&file);
file.close();
}
}
+bool DrawPad::antiAliasing()
+{
+ return (m_pAntiAliasingAction->isOn());
+}
+
void DrawPad::newPage()
{
QRect rect = m_pDrawPadCanvas->contentsRect();
NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this);
if (newPageDialog.exec() == QDialog::Accepted) {
m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(),
newPageDialog.selectedHeight(), newPageDialog.selectedColor());
}
}
void DrawPad::clearPage()
{
QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"),
QMessageBox::Information, QMessageBox::Yes,
QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
QMessageBox::NoButton, this);
messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
messageBox.setButtonText(QMessageBox::No, tr("No"));
if (messageBox.exec() == QMessageBox::Yes) {
m_pDrawPadCanvas->clearPage();
}
}
void DrawPad::deletePage()
{
QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"),
QMessageBox::Information, QMessageBox::Yes,
QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
QMessageBox::NoButton, this);
messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
messageBox.setButtonText(QMessageBox::No, tr("No"));
if (messageBox.exec() == QMessageBox::Yes) {
m_pDrawPadCanvas->deletePage();
}
}
void DrawPad::setPointTool()
{
if (m_pTool) {
delete m_pTool;
}
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h
index ce62802..8e29c61 100644
--- a/noncore/graphics/drawpad/drawpad.h
+++ b/noncore/graphics/drawpad/drawpad.h
@@ -1,102 +1,106 @@
/***************************************************************************
* *
* 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 DRAWPAD_H
#define DRAWPAD_H
#include <qmainwindow.h>
#include <qpen.h>
class DrawPadCanvas;
class Tool;
class QAction;
class QColor;
class QToolButton;
class QWidgetStack;
class DrawPad : public QMainWindow
{
Q_OBJECT
public:
DrawPad(QWidget* parent = 0, const char* name = 0);
~DrawPad();
Tool* tool() { return m_pTool; }
QPen pen() { return m_pen; }
QBrush brush() { return m_brush; }
+ bool antiAliasing();
+
private slots:
void newPage();
void clearPage();
void deletePage();
void setPointTool();
void setLineTool();
void setRectangleTool();
void setFilledRectangleTool();
void setEllipseTool();
void setFilledEllipseTool();
void setTextTool();
void setFillTool();
void setEraseTool();
void changePenWidth(int value);
void changePenColor(const QColor& color);
void changeBrushColor(const QColor& color);
void updateUndoRedoToolButtons();
void updateNavigationToolButtons();
void updateCaption();
void deleteAll();
void importPage();
void exportPage();
void thumbnailView();
void pageInformation();
private:
DrawPadCanvas* m_pDrawPadCanvas;
Tool* m_pTool;
QPen m_pen;
QBrush m_brush;
+ QAction* m_pAntiAliasingAction;
+
QAction* m_pUndoAction;
QAction* m_pRedoAction;
QAction* m_pFirstPageAction;
QAction* m_pPreviousPageAction;
QAction* m_pNextPageAction;
QAction* m_pLastPageAction;
QAction* m_pPointToolAction;
QAction* m_pLineToolAction;
QAction* m_pRectangleToolAction;
QAction* m_pFilledRectangleToolAction;
QAction* m_pEllipseToolAction;
QAction* m_pFilledEllipseToolAction;
QAction* m_pTextToolAction;
QAction* m_pFillToolAction;
QAction* m_pEraseToolAction;
QToolButton* m_pLineToolButton;
QToolButton* m_pRectangleToolButton;
QToolButton* m_pEllipseToolButton;
QToolButton* m_pPenColorToolButton;
QToolButton* m_pBrushColorToolButton;
};
#endif // DRAWPAD_H
diff --git a/noncore/graphics/drawpad/ellipsetool.cpp b/noncore/graphics/drawpad/ellipsetool.cpp
index 733bade..0cdb731 100644
--- a/noncore/graphics/drawpad/ellipsetool.cpp
+++ b/noncore/graphics/drawpad/ellipsetool.cpp
@@ -1,76 +1,81 @@
/***************************************************************************
* *
* 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 "ellipsetool.h"
#include "drawpad.h"
#include "drawpadcanvas.h"
#include <qimage.h>
#include <qpixmap.h>
EllipseTool::EllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
: ShapeTool(drawPad, drawPadCanvas)
{
}
EllipseTool::~EllipseTool()
{
}
void EllipseTool::drawFinalShape(QPainter& p)
{
p.setRasterOp(Qt::NotROP);
p.drawRect(QRect(m_polyline[2], m_polyline[0]));
+ p.setRasterOp(Qt::CopyROP);
- QRect r = m_polyline.boundingRect();
- r = r.normalize();
- r.setLeft(r.left() - m_pDrawPad->pen().width());
- r.setTop(r.top() - m_pDrawPad->pen().width());
- r.setRight(r.right() + m_pDrawPad->pen().width());
- r.setBottom(r.bottom() + m_pDrawPad->pen().width());
+ if (m_pDrawPad->antiAliasing()) {
+ QRect r = m_polyline.boundingRect();
+ r = r.normalize();
+ r.setLeft(r.left() - m_pDrawPad->pen().width());
+ r.setTop(r.top() - m_pDrawPad->pen().width());
+ r.setRight(r.right() + m_pDrawPad->pen().width());
+ r.setBottom(r.bottom() + m_pDrawPad->pen().width());
- QPixmap areaPixmap(r.width(), r.height());
- bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
+ QPixmap areaPixmap(r.width(), r.height());
+ bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
- QImage areaImage = areaPixmap.convertToImage();
- QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
+ QImage areaImage = areaPixmap.convertToImage();
+ QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
- QPixmap bigAreaPixmap;
- bigAreaPixmap.convertFromImage(bigAreaImage);
+ QPixmap bigAreaPixmap;
+ bigAreaPixmap.convertFromImage(bigAreaImage);
- QPen bigAreaPen = m_pDrawPad->pen();
- bigAreaPen.setWidth(bigAreaPen.width() * 3);
+ QPen bigAreaPen = m_pDrawPad->pen();
+ bigAreaPen.setWidth(bigAreaPen.width() * 3);
- QPainter bigAreaPainter;
- bigAreaPainter.begin(&bigAreaPixmap);
- bigAreaPainter.setPen(bigAreaPen);
- bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1,
- bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1),
- bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1)));
- bigAreaPainter.end();
+ QPainter bigAreaPainter;
+ bigAreaPainter.begin(&bigAreaPixmap);
+ bigAreaPainter.setPen(bigAreaPen);
+ bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1,
+ bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1),
+ bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1)));
+ bigAreaPainter.end();
- bigAreaImage = bigAreaPixmap.convertToImage();
- areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
- areaPixmap.convertFromImage(areaImage);
+ bigAreaImage = bigAreaPixmap.convertToImage();
+ areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
+ areaPixmap.convertFromImage(areaImage);
- p.setRasterOp(Qt::CopyROP);
- p.drawPixmap(r.x(), r.y(), areaPixmap);
+ p.drawPixmap(r.x(), r.y(), areaPixmap);
+ } else {
+ p.setPen(m_pDrawPad->pen());
+ p.drawEllipse(QRect(m_polyline[2], m_polyline[0]));
+ }
}
void EllipseTool::drawTemporaryShape(QPainter& p)
{
p.setRasterOp(Qt::NotROP);
p.drawRect(QRect(m_polyline[2], m_polyline[1]));
p.drawRect(QRect(m_polyline[2], m_polyline[0]));
}
diff --git a/noncore/graphics/drawpad/filledellipsetool.cpp b/noncore/graphics/drawpad/filledellipsetool.cpp
index 2f7ec8f..6b5bbc6 100644
--- a/noncore/graphics/drawpad/filledellipsetool.cpp
+++ b/noncore/graphics/drawpad/filledellipsetool.cpp
@@ -1,77 +1,83 @@
/***************************************************************************
* *
* 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 "filledellipsetool.h"
#include "drawpad.h"
#include "drawpadcanvas.h"
#include <qimage.h>
#include <qpixmap.h>
FilledEllipseTool::FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
: ShapeTool(drawPad, drawPadCanvas)
{
}
FilledEllipseTool::~FilledEllipseTool()
{
}
void FilledEllipseTool::drawFinalShape(QPainter& p)
{
p.setRasterOp(Qt::NotROP);
p.drawRect(QRect(m_polyline[2], m_polyline[0]));
+ p.setRasterOp(Qt::CopyROP);
- QRect r = m_polyline.boundingRect();
- r = r.normalize();
- r.setLeft(r.left() - m_pDrawPad->pen().width());
- r.setTop(r.top() - m_pDrawPad->pen().width());
- r.setRight(r.right() + m_pDrawPad->pen().width());
- r.setBottom(r.bottom() + m_pDrawPad->pen().width());
+ if (m_pDrawPad->antiAliasing()) {
+ QRect r = m_polyline.boundingRect();
+ r = r.normalize();
+ r.setLeft(r.left() - m_pDrawPad->pen().width());
+ r.setTop(r.top() - m_pDrawPad->pen().width());
+ r.setRight(r.right() + m_pDrawPad->pen().width());
+ r.setBottom(r.bottom() + m_pDrawPad->pen().width());
- QPixmap areaPixmap(r.width(), r.height());
- bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
+ QPixmap areaPixmap(r.width(), r.height());
+ bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
- QImage areaImage = areaPixmap.convertToImage();
- QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
+ QImage areaImage = areaPixmap.convertToImage();
+ QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
- QPixmap bigAreaPixmap;
- bigAreaPixmap.convertFromImage(bigAreaImage);
+ QPixmap bigAreaPixmap;
+ bigAreaPixmap.convertFromImage(bigAreaImage);
- QPen bigAreaPen = m_pDrawPad->pen();
- bigAreaPen.setWidth(bigAreaPen.width() * 3);
+ QPen bigAreaPen = m_pDrawPad->pen();
+ bigAreaPen.setWidth(bigAreaPen.width() * 3);
- QPainter bigAreaPainter;
- bigAreaPainter.begin(&bigAreaPixmap);
- bigAreaPainter.setPen(bigAreaPen);
- bigAreaPainter.setBrush(m_pDrawPad->brush());
- bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1,
- bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1),
- bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1)));
- bigAreaPainter.end();
+ QPainter bigAreaPainter;
+ bigAreaPainter.begin(&bigAreaPixmap);
+ bigAreaPainter.setPen(bigAreaPen);
+ bigAreaPainter.setBrush(m_pDrawPad->brush());
+ bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1,
+ bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1),
+ bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1)));
+ bigAreaPainter.end();
- bigAreaImage = bigAreaPixmap.convertToImage();
- areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
- areaPixmap.convertFromImage(areaImage);
+ bigAreaImage = bigAreaPixmap.convertToImage();
+ areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
+ areaPixmap.convertFromImage(areaImage);
- p.setRasterOp(Qt::CopyROP);
- p.drawPixmap(r.x(), r.y(), areaPixmap);
+ p.drawPixmap(r.x(), r.y(), areaPixmap);
+ } else {
+ p.setPen(m_pDrawPad->pen());
+ p.setBrush(m_pDrawPad->brush());
+ p.drawEllipse(QRect(m_polyline[2], m_polyline[0]));
+ }
}
void FilledEllipseTool::drawTemporaryShape(QPainter& p)
{
p.setRasterOp(Qt::NotROP);
p.drawRect(QRect(m_polyline[2], m_polyline[1]));
p.drawRect(QRect(m_polyline[2], m_polyline[0]));
}
diff --git a/noncore/graphics/drawpad/linetool.cpp b/noncore/graphics/drawpad/linetool.cpp
index 99cd6de..b6baa2a 100644
--- a/noncore/graphics/drawpad/linetool.cpp
+++ b/noncore/graphics/drawpad/linetool.cpp
@@ -1,77 +1,82 @@
/***************************************************************************
* *
* 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 "linetool.h"
#include "drawpad.h"
#include "drawpadcanvas.h"
#include <qimage.h>
#include <qpixmap.h>
LineTool::LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
: ShapeTool(drawPad, drawPadCanvas)
{
}
LineTool::~LineTool()
{
}
void LineTool::drawFinalShape(QPainter& p)
{
p.setRasterOp(Qt::NotROP);
p.drawLine(m_polyline[2], m_polyline[0]);
+ p.setRasterOp(Qt::CopyROP);
- QRect r = m_polyline.boundingRect();
- r = r.normalize();
- r.setLeft(r.left() - m_pDrawPad->pen().width());
- r.setTop(r.top() - m_pDrawPad->pen().width());
- r.setRight(r.right() + m_pDrawPad->pen().width());
- r.setBottom(r.bottom() + m_pDrawPad->pen().width());
+ if (m_pDrawPad->antiAliasing()) {
+ QRect r = m_polyline.boundingRect();
+ r = r.normalize();
+ r.setLeft(r.left() - m_pDrawPad->pen().width());
+ r.setTop(r.top() - m_pDrawPad->pen().width());
+ r.setRight(r.right() + m_pDrawPad->pen().width());
+ r.setBottom(r.bottom() + m_pDrawPad->pen().width());
- QPixmap areaPixmap(r.width(), r.height());
- bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
+ QPixmap areaPixmap(r.width(), r.height());
+ bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
- QImage areaImage = areaPixmap.convertToImage();
- QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
+ QImage areaImage = areaPixmap.convertToImage();
+ QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
- QPixmap bigAreaPixmap;
- bigAreaPixmap.convertFromImage(bigAreaImage);
+ QPixmap bigAreaPixmap;
+ bigAreaPixmap.convertFromImage(bigAreaImage);
- QPen bigAreaPen = m_pDrawPad->pen();
- bigAreaPen.setWidth(bigAreaPen.width() * 3);
+ QPen bigAreaPen = m_pDrawPad->pen();
+ bigAreaPen.setWidth(bigAreaPen.width() * 3);
- QPainter bigAreaPainter;
- bigAreaPainter.begin(&bigAreaPixmap);
- bigAreaPainter.setPen(bigAreaPen);
+ QPainter bigAreaPainter;
+ bigAreaPainter.begin(&bigAreaPixmap);
+ bigAreaPainter.setPen(bigAreaPen);
- bigAreaPainter.drawLine((m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1,
- (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1);
+ bigAreaPainter.drawLine((m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1,
+ (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1);
- bigAreaPainter.end();
+ bigAreaPainter.end();
- bigAreaImage = bigAreaPixmap.convertToImage();
- areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
- areaPixmap.convertFromImage(areaImage);
+ bigAreaImage = bigAreaPixmap.convertToImage();
+ areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
+ areaPixmap.convertFromImage(areaImage);
- p.setRasterOp(Qt::CopyROP);
- p.drawPixmap(r.x(), r.y(), areaPixmap);
+ p.drawPixmap(r.x(), r.y(), areaPixmap);
+ } else {
+ p.setPen(m_pDrawPad->pen());
+ p.drawLine(m_polyline[2], m_polyline[0]);
+ }
}
void LineTool::drawTemporaryShape(QPainter& p)
{
p.setRasterOp(Qt::NotROP);
p.drawLine(m_polyline[2], m_polyline[1]);
p.drawLine(m_polyline[2], m_polyline[0]);
}
diff --git a/noncore/graphics/drawpad/pointtool.cpp b/noncore/graphics/drawpad/pointtool.cpp
index 22bb089..a4f846e 100644
--- a/noncore/graphics/drawpad/pointtool.cpp
+++ b/noncore/graphics/drawpad/pointtool.cpp
@@ -8,98 +8,104 @@
* 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 "pointtool.h"
#include "drawpad.h"
#include "drawpadcanvas.h"
#include "page.h"
#include <qimage.h>
#include <qpainter.h>
PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
: Tool(drawPad, drawPadCanvas)
{
m_mousePressed = false;
m_polyline.resize(3);
}
PointTool::~PointTool()
{
}
void PointTool::mousePressEvent(QMouseEvent* e)
{
m_mousePressed = true;
m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
}
void PointTool::mouseReleaseEvent(QMouseEvent* e)
{
Q_UNUSED(e)
m_mousePressed = false;
m_pDrawPadCanvas->backupPage();
}
void PointTool::mouseMoveEvent(QMouseEvent* e)
{
if (m_mousePressed) {
m_polyline[2] = m_polyline[1];
m_polyline[1] = m_polyline[0];
m_polyline[0] = e->pos();
- QPainter painter;
- painter.begin(m_pDrawPadCanvas->currentPage());
-
QRect r = m_polyline.boundingRect();
r = r.normalize();
r.setLeft(r.left() - m_pDrawPad->pen().width());
r.setTop(r.top() - m_pDrawPad->pen().width());
r.setRight(r.right() + m_pDrawPad->pen().width());
r.setBottom(r.bottom() + m_pDrawPad->pen().width());
- QPixmap areaPixmap(r.width(), r.height());
- bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r);
+ QPainter painter;
+ painter.begin(m_pDrawPadCanvas->currentPage());
+
+ if (m_pDrawPad->antiAliasing()) {
+ QPixmap areaPixmap(r.width(), r.height());
+ bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r);
+
+ QImage areaImage = areaPixmap.convertToImage();
+ QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
- QImage areaImage = areaPixmap.convertToImage();
- QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
+ QPixmap bigAreaPixmap;
+ bigAreaPixmap.convertFromImage(bigAreaImage);
- QPixmap bigAreaPixmap;
- bigAreaPixmap.convertFromImage(bigAreaImage);
+ QPen bigAreaPen = m_pDrawPad->pen();
+ bigAreaPen.setWidth(bigAreaPen.width() * 3);
- QPen bigAreaPen = m_pDrawPad->pen();
- bigAreaPen.setWidth(bigAreaPen.width() * 3);
+ QPainter bigAreaPainter;
+ bigAreaPainter.begin(&bigAreaPixmap);
+ bigAreaPainter.setPen(bigAreaPen);
- QPainter bigAreaPainter;
- bigAreaPainter.begin(&bigAreaPixmap);
- bigAreaPainter.setPen(bigAreaPen);
+ QPointArray bigAreaPolyline(3);
+ bigAreaPolyline.setPoint(0, (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1);
+ bigAreaPolyline.setPoint(1, (m_polyline[1].x() - r.x()) * 3 + 1, (m_polyline[1].y() - r.y()) * 3 + 1);
+ bigAreaPolyline.setPoint(2, (m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1);
- QPointArray bigAreaPolyline(3);
- bigAreaPolyline.setPoint(0, (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1);
- bigAreaPolyline.setPoint(1, (m_polyline[1].x() - r.x()) * 3 + 1, (m_polyline[1].y() - r.y()) * 3 + 1);
- bigAreaPolyline.setPoint(2, (m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1);
+ bigAreaPainter.drawPolyline(bigAreaPolyline);
+ bigAreaPainter.end();
- bigAreaPainter.drawPolyline(bigAreaPolyline);
- bigAreaPainter.end();
+ bigAreaImage = bigAreaPixmap.convertToImage();
+ areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
+ areaPixmap.convertFromImage(areaImage);
- bigAreaImage = bigAreaPixmap.convertToImage();
- areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
- areaPixmap.convertFromImage(areaImage);
+ painter.drawPixmap(r.x(), r.y(), areaPixmap);
+ } else {
+ painter.setPen(m_pDrawPad->pen());
+ painter.drawPolyline(m_polyline);
+ }
- painter.drawPixmap(r.x(), r.y(), areaPixmap);
painter.end();
QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()),
m_pDrawPadCanvas->contentsToViewport(r.bottomRight()));
bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(),
m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height());
m_pDrawPadCanvas->viewport()->update(viewportRect);
}
}