summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/colorpanel.cpp22
-rw-r--r--noncore/graphics/drawpad/colorpanel.h3
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp317
-rw-r--r--noncore/graphics/drawpad/drawpad.h41
-rw-r--r--noncore/graphics/drawpad/drawpad.pro40
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp144
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h5
-rw-r--r--noncore/graphics/drawpad/ellipsetool.cpp45
-rw-r--r--noncore/graphics/drawpad/ellipsetool.h30
-rw-r--r--noncore/graphics/drawpad/erasetool.cpp74
-rw-r--r--noncore/graphics/drawpad/erasetool.h36
-rw-r--r--noncore/graphics/drawpad/exportdialog.cpp173
-rw-r--r--noncore/graphics/drawpad/exportdialog.h58
-rw-r--r--noncore/graphics/drawpad/filledellipsetool.cpp46
-rw-r--r--noncore/graphics/drawpad/filledellipsetool.h30
-rw-r--r--noncore/graphics/drawpad/filledrectangletool.cpp43
-rw-r--r--noncore/graphics/drawpad/filledrectangletool.h30
-rw-r--r--noncore/graphics/drawpad/filltool.cpp88
-rw-r--r--noncore/graphics/drawpad/filltool.h39
-rw-r--r--noncore/graphics/drawpad/importdialog.cpp41
-rw-r--r--noncore/graphics/drawpad/importdialog.h36
-rw-r--r--noncore/graphics/drawpad/linetool.cpp42
-rw-r--r--noncore/graphics/drawpad/linetool.h30
-rw-r--r--noncore/graphics/drawpad/newpagedialog.cpp83
-rw-r--r--noncore/graphics/drawpad/newpagedialog.h17
-rw-r--r--noncore/graphics/drawpad/pointtool.cpp73
-rw-r--r--noncore/graphics/drawpad/pointtool.h36
-rw-r--r--noncore/graphics/drawpad/rectangletool.cpp42
-rw-r--r--noncore/graphics/drawpad/rectangletool.h30
-rw-r--r--noncore/graphics/drawpad/shapetool.cpp92
-rw-r--r--noncore/graphics/drawpad/shapetool.h41
-rw-r--r--noncore/graphics/drawpad/tool.cpp28
-rw-r--r--noncore/graphics/drawpad/tool.h39
33 files changed, 1679 insertions, 215 deletions
diff --git a/noncore/graphics/drawpad/colorpanel.cpp b/noncore/graphics/drawpad/colorpanel.cpp
index 1db0d7b..9327012 100644
--- a/noncore/graphics/drawpad/colorpanel.cpp
+++ b/noncore/graphics/drawpad/colorpanel.cpp
@@ -22,40 +22,25 @@ ColorPanelButton::ColorPanelButton(const QColor& color, QWidget* parent, const c
m_color = color;
setFixedSize(16, 16);
- setActive(false);
+ setFrameStyle(NoFrame);
}
ColorPanelButton::~ColorPanelButton()
{
}
-void ColorPanelButton::setActive(bool active)
-{
- m_active = active;
-
- if (m_active) {
- setFrameStyle(Panel | Sunken);
- } else {
- setFrameStyle(NoFrame);
- }
-}
-
void ColorPanelButton::enterEvent(QEvent* e)
{
Q_UNUSED(e)
- if (!m_active) {
- setFrameStyle(Panel | Sunken);
- }
+ setFrameStyle(Panel | Sunken);
}
void ColorPanelButton::leaveEvent(QEvent* e)
{
Q_UNUSED(e)
- if (!m_active) {
- setFrameStyle(NoFrame);
- }
+ setFrameStyle(NoFrame);
}
void ColorPanelButton::paintEvent(QPaintEvent* e)
@@ -125,6 +110,7 @@ void ColorPanel::addColor(const QColor& color, int row, int col)
{
ColorPanelButton* panelButton = new ColorPanelButton(color, this);
connect(panelButton, SIGNAL(selected(const QColor&)), this, SLOT(buttonSelected(const QColor&)));
+
m_pGridLayout->addWidget(panelButton, row, col);
}
diff --git a/noncore/graphics/drawpad/colorpanel.h b/noncore/graphics/drawpad/colorpanel.h
index 05364c1..4664879 100644
--- a/noncore/graphics/drawpad/colorpanel.h
+++ b/noncore/graphics/drawpad/colorpanel.h
@@ -27,8 +27,6 @@ public:
ColorPanelButton(const QColor& color, QWidget* parent = 0, const char* name = 0);
~ColorPanelButton();
- void setActive(bool active);
-
void enterEvent(QEvent* e);
void leaveEvent(QEvent* e);
void paintEvent(QPaintEvent* e);
@@ -39,7 +37,6 @@ signals:
private:
QColor m_color;
- bool m_active;
};
class ColorPanel : public QWidget
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index e94187f..5c7e541 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -16,13 +16,18 @@
#include "colordialog.h"
#include "colorpanel.h"
#include "drawpadcanvas.h"
-#include "ellipsedrawmode.h"
-#include "erasedrawmode.h"
-#include "filldrawmode.h"
-#include "linedrawmode.h"
-#include "pointdrawmode.h"
-#include "rectangledrawmode.h"
-
+#include "ellipsetool.h"
+#include "erasetool.h"
+#include "exportdialog.h"
+#include "filledellipsetool.h"
+#include "filledrectangletool.h"
+#include "filltool.h"
+#include "importdialog.h"
+#include "linetool.h"
+#include "pointtool.h"
+#include "rectangletool.h"
+
+#include <qpe/applnk.h>
#include <qpe/global.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
@@ -57,14 +62,19 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar);
- QAction* clearAllAction = new QAction(tr("Clear All"), QString::null, 0, this);
- connect(clearAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearAll()));
- clearAllAction->addTo(toolsPopupMenu);
+ QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
+ connect(deleteAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deleteAll()));
+ deleteAllAction->addTo(toolsPopupMenu);
toolsPopupMenu->insertSeparator();
- QAction* setOptionsAction = new QAction(tr("Options"), tr("Options..."), 0, this);
- setOptionsAction->addTo(toolsPopupMenu);
+ 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);
menuBar->insertItem(tr("Tools"), toolsPopupMenu);
@@ -119,38 +129,60 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
QPEToolBar* drawModeToolBar = new QPEToolBar(this);
- m_pPointDrawModeAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), QString::null, 0, this);
- m_pPointDrawModeAction->setToggleAction(true);
- connect(m_pPointDrawModeAction, SIGNAL(activated()), this, SLOT(setPointDrawMode()));
- m_pPointDrawModeAction->addTo(drawModeToolBar);
+ m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), QString::null, 0, this);
+ m_pPointToolAction->setToggleAction(true);
+ connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool()));
+ m_pPointToolAction->addTo(drawModeToolBar);
+
+ m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), QString::null, 0, this);
+ m_pLineToolAction->setToggleAction(true);
+ connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool()));
+ m_pLineToolAction->addTo(drawModeToolBar);
+
+ m_pRectangleToolButton = new QToolButton(drawModeToolBar);
+ m_pRectangleToolButton->setToggleButton(true);
+
+ QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton);
+
+ m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this);
+ connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool()));
+ m_pRectangleToolAction->addTo(rectanglePopupMenu);
- m_pLineDrawModeAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), QString::null, 0, this);
- m_pLineDrawModeAction->setToggleAction(true);
- connect(m_pLineDrawModeAction, SIGNAL(activated()), this, SLOT(setLineDrawMode()));
- m_pLineDrawModeAction->addTo(drawModeToolBar);
+ m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this);
+ connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool()));
+ m_pFilledRectangleToolAction->addTo(rectanglePopupMenu);
- m_pRectangleDrawModeAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), QString::null, 0, this);
- m_pRectangleDrawModeAction->setToggleAction(true);
- connect(m_pRectangleDrawModeAction, SIGNAL(activated()), this, SLOT(setRectangleDrawMode()));
- m_pRectangleDrawModeAction->addTo(drawModeToolBar);
+ m_pRectangleToolButton->setPopup(rectanglePopupMenu);
- m_pEllipseDrawModeAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), QString::null, 0, this);
- m_pEllipseDrawModeAction->setToggleAction(true);
- connect(m_pEllipseDrawModeAction, SIGNAL(activated()), this, SLOT(setEllipseDrawMode()));
- m_pEllipseDrawModeAction->addTo(drawModeToolBar);
+ m_pEllipseToolButton = new QToolButton(drawModeToolBar);
+ m_pEllipseToolButton->setToggleButton(true);
- m_pFillDrawModeAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this);
- m_pFillDrawModeAction->setToggleAction(true);
- connect(m_pFillDrawModeAction, SIGNAL(activated()), this, SLOT(setFillDrawMode()));
- m_pFillDrawModeAction->addTo(drawModeToolBar);
+ QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton);
- m_pEraseDrawModeAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this);
- m_pEraseDrawModeAction->setToggleAction(true);
- connect(m_pEraseDrawModeAction, SIGNAL(activated()), this, SLOT(setEraseDrawMode()));
- m_pEraseDrawModeAction->addTo(drawModeToolBar);
+ m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this);
+ connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool()));
+ m_pEllipseToolAction->addTo(ellipsePopupMenu);
- m_pDrawMode = 0;
- setPointDrawMode();
+ m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this);
+ connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool()));
+ m_pFilledEllipseToolAction->addTo(ellipsePopupMenu);
+
+ m_pEllipseToolButton->setPopup(ellipsePopupMenu);
+
+ m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this);
+ m_pFillToolAction->setToggleAction(true);
+ connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool()));
+ m_pFillToolAction->addTo(drawModeToolBar);
+
+ m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this);
+ m_pEraseToolAction->setToggleAction(true);
+ connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool()));
+ m_pEraseToolAction->addTo(drawModeToolBar);
+
+ m_pTool = 0;
+ setRectangleTool();
+ setEllipseTool();
+ setPointTool();
emptyToolBar = new QPEToolBar(this);
emptyToolBar->setHorizontalStretchable(true);
@@ -163,7 +195,9 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar);
connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int)));
+ QToolTip::add(penWidthSpinBox, tr("Pen Width"));
penWidthSpinBox->setValue(1);
+ penWidthSpinBox->setFocusPolicy(QWidget::NoFocus);
m_pPenColorToolButton = new QToolButton(drawParametersToolBar);
m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png"));
@@ -172,8 +206,8 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
ColorPanel* penColorPanel = new ColorPanel(penColorPopupMenu);
connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&)));
- penColorPopupMenu->insertItem(penColorPanel);
+ penColorPopupMenu->insertItem(penColorPanel);
penColorPopupMenu->insertSeparator();
QAction* choosePenColorAction = new QAction(tr("More"), tr("More..."), 0, this);
@@ -184,7 +218,7 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
m_pPenColorToolButton->setPopup(penColorPopupMenu);
m_pPenColorToolButton->setPopupDelay(0);
- penColorPopupMenu->activateItemAt(0);
+ penColorPanel->buttonSelected(Qt::black);
m_pBrushColorToolButton = new QToolButton(drawParametersToolBar);
m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png"));
@@ -193,8 +227,8 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
ColorPanel* brushColorPanel = new ColorPanel(brushColorPopupMenu);
connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&)));
- brushColorPopupMenu->insertItem(brushColorPanel);
+ brushColorPopupMenu->insertItem(brushColorPanel);
brushColorPopupMenu->insertSeparator();
QAction* chooseBrushColorAction = new QAction(tr("More"), tr("More..."), 0, this);
@@ -205,7 +239,7 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
m_pBrushColorToolButton->setPopup(brushColorPopupMenu);
m_pBrushColorToolButton->setPopupDelay(0);
- brushColorPopupMenu->activateItemAt(1);
+ brushColorPanel->buttonSelected(Qt::white);
// init pages
@@ -229,100 +263,156 @@ DrawPad::~DrawPad()
}
}
-void DrawPad::setPointDrawMode()
+void DrawPad::setPointTool()
+{
+ if (m_pTool) {
+ delete m_pTool;
+ }
+
+ m_pTool = new PointTool(this, m_pDrawPadCanvas);
+
+ m_pPointToolAction->setOn(true);
+ m_pLineToolAction->setOn(false);
+ m_pRectangleToolButton->setOn(false);
+ m_pEllipseToolButton->setOn(false);
+ m_pFillToolAction->setOn(false);
+ m_pEraseToolAction->setOn(false);
+}
+
+void DrawPad::setLineTool()
+{
+ if (m_pTool) {
+ delete m_pTool;
+ }
+
+ m_pTool = new LineTool(this, m_pDrawPadCanvas);
+
+ m_pPointToolAction->setOn(false);
+ m_pLineToolAction->setOn(true);
+ m_pRectangleToolButton->setOn(false);
+ m_pEllipseToolButton->setOn(false);
+ m_pFillToolAction->setOn(false);
+ m_pEraseToolAction->setOn(false);
+}
+
+void DrawPad::setRectangleTool()
{
- if (m_pDrawMode) {
- delete m_pDrawMode;
+ if (m_pTool) {
+ delete m_pTool;
}
- m_pDrawMode = new PointDrawMode(this, m_pDrawPadCanvas);
+ m_pTool = new RectangleTool(this, m_pDrawPadCanvas);
- m_pPointDrawModeAction->setOn(true);
- m_pLineDrawModeAction->setOn(false);
- m_pRectangleDrawModeAction->setOn(false);
- m_pEllipseDrawModeAction->setOn(false);
- m_pFillDrawModeAction->setOn(false);
- m_pEraseDrawModeAction->setOn(false);
+ m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet());
+ QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text());
+
+ disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0);
+ connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated()));
+
+ m_pPointToolAction->setOn(false);
+ m_pLineToolAction->setOn(false);
+ m_pRectangleToolButton->setOn(true);
+ m_pEllipseToolButton->setOn(false);
+ m_pFillToolAction->setOn(false);
+ m_pEraseToolAction->setOn(false);
}
-void DrawPad::setLineDrawMode()
+void DrawPad::setFilledRectangleTool()
{
- if (m_pDrawMode) {
- delete m_pDrawMode;
+ if (m_pTool) {
+ delete m_pTool;
}
- m_pDrawMode = new LineDrawMode(this, m_pDrawPadCanvas);
+ m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas);
+
+ m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet());
+ QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text());
- m_pPointDrawModeAction->setOn(false);
- m_pLineDrawModeAction->setOn(true);
- m_pRectangleDrawModeAction->setOn(false);
- m_pEllipseDrawModeAction->setOn(false);
- m_pFillDrawModeAction->setOn(false);
- m_pEraseDrawModeAction->setOn(false);
+ disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0);
+ connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated()));
+
+ m_pPointToolAction->setOn(false);
+ m_pLineToolAction->setOn(false);
+ m_pRectangleToolButton->setOn(true);
+ m_pEllipseToolButton->setOn(false);
+ m_pFillToolAction->setOn(false);
+ m_pEraseToolAction->setOn(false);
}
-void DrawPad::setRectangleDrawMode()
+void DrawPad::setEllipseTool()
{
- if (m_pDrawMode) {
- delete m_pDrawMode;
+ if (m_pTool) {
+ delete m_pTool;
}
- m_pDrawMode = new RectangleDrawMode(this, m_pDrawPadCanvas);
+ m_pTool = new EllipseTool(this, m_pDrawPadCanvas);
+
+ m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet());
+ QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text());
+
+ disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0);
+ connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated()));
- m_pPointDrawModeAction->setOn(false);
- m_pLineDrawModeAction->setOn(false);
- m_pRectangleDrawModeAction->setOn(true);
- m_pEllipseDrawModeAction->setOn(false);
- m_pFillDrawModeAction->setOn(false);
- m_pEraseDrawModeAction->setOn(false);
+ m_pPointToolAction->setOn(false);
+ m_pLineToolAction->setOn(false);
+ m_pRectangleToolButton->setOn(false);
+ m_pEllipseToolButton->setOn(true);
+ m_pFillToolAction->setOn(false);
+ m_pEraseToolAction->setOn(false);
}
-void DrawPad::setEllipseDrawMode()
+void DrawPad::setFilledEllipseTool()
{
- if (m_pDrawMode) {
- delete m_pDrawMode;
+ if (m_pTool) {
+ delete m_pTool;
}
- m_pDrawMode = new EllipseDrawMode(this, m_pDrawPadCanvas);
+ m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas);
- m_pPointDrawModeAction->setOn(false);
- m_pLineDrawModeAction->setOn(false);
- m_pRectangleDrawModeAction->setOn(false);
- m_pEllipseDrawModeAction->setOn(true);
- m_pFillDrawModeAction->setOn(false);
- m_pEraseDrawModeAction->setOn(false);
+ m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet());
+ QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text());
+
+ disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0);
+ connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated()));
+
+ m_pPointToolAction->setOn(false);
+ m_pLineToolAction->setOn(false);
+ m_pRectangleToolButton->setOn(false);
+ m_pEllipseToolButton->setOn(true);
+ m_pFillToolAction->setOn(false);
+ m_pEraseToolAction->setOn(false);
}
-void DrawPad::setFillDrawMode()
+void DrawPad::setFillTool()
{
- if (m_pDrawMode) {
- delete m_pDrawMode;
+ if (m_pTool) {
+ delete m_pTool;
}
- m_pDrawMode = new FillDrawMode(this, m_pDrawPadCanvas);
+ m_pTool = new FillTool(this, m_pDrawPadCanvas);
- m_pPointDrawModeAction->setOn(false);
- m_pLineDrawModeAction->setOn(false);
- m_pRectangleDrawModeAction->setOn(false);
- m_pEllipseDrawModeAction->setOn(false);
- m_pFillDrawModeAction->setOn(true);
- m_pEraseDrawModeAction->setOn(false);
+ m_pPointToolAction->setOn(false);
+ m_pLineToolAction->setOn(false);
+ m_pRectangleToolButton->setOn(false);
+ m_pEllipseToolButton->setOn(false);
+ m_pFillToolAction->setOn(true);
+ m_pEraseToolAction->setOn(false);
}
-void DrawPad::setEraseDrawMode()
+void DrawPad::setEraseTool()
{
- if (m_pDrawMode) {
- delete m_pDrawMode;
+ if (m_pTool) {
+ delete m_pTool;
}
- m_pDrawMode = new EraseDrawMode(this, m_pDrawPadCanvas);
+ m_pTool = new EraseTool(this, m_pDrawPadCanvas);
- m_pPointDrawModeAction->setOn(false);
- m_pLineDrawModeAction->setOn(false);
- m_pRectangleDrawModeAction->setOn(false);
- m_pEllipseDrawModeAction->setOn(false);
- m_pFillDrawModeAction->setOn(false);
- m_pEraseDrawModeAction->setOn(true);
+ m_pPointToolAction->setOn(false);
+ m_pLineToolAction->setOn(false);
+ m_pRectangleToolButton->setOn(false);
+ m_pEllipseToolButton->setOn(false);
+ m_pFillToolAction->setOn(false);
+ m_pEraseToolAction->setOn(true);
}
void DrawPad::changePenWidth(int value)
@@ -388,3 +478,26 @@ void DrawPad::updateCaption()
setCaption(tr("DrawPad") + " - " + tr("Page") + " "
+ QString::number(pagePosition) + "/" + QString::number(pageCount));
}
+
+void DrawPad::importPage()
+{
+ ImportDialog importDialog(this);
+
+ importDialog.showMaximized();
+
+ if (importDialog.exec() == QDialog::Accepted) {
+ m_pDrawPadCanvas->importPage(importDialog.selected()->file());
+ }
+}
+
+void DrawPad::exportPage()
+{
+ ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this);
+
+ exportDialog.showMaximized();
+
+ if (exportDialog.exec() == QDialog::Accepted) {
+ m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(),
+ exportDialog.selectedName(), exportDialog.selectedFormat());
+ }
+}
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h
index c49a559..fbe67b8 100644
--- a/noncore/graphics/drawpad/drawpad.h
+++ b/noncore/graphics/drawpad/drawpad.h
@@ -18,7 +18,7 @@
#include <qpen.h>
-class DrawMode;
+class Tool;
class DrawPadCanvas;
class QAction;
@@ -34,17 +34,19 @@ public:
DrawPad(QWidget* parent = 0, const char* name = 0);
~DrawPad();
- DrawMode* drawMode() { return m_pDrawMode; }
+ Tool* tool() { return m_pTool; }
QPen pen() { return m_pen; }
QBrush brush() { return m_brush; }
private slots:
- void setPointDrawMode();
- void setLineDrawMode();
- void setRectangleDrawMode();
- void setEllipseDrawMode();
- void setFillDrawMode();
- void setEraseDrawMode();
+ void setPointTool();
+ void setLineTool();
+ void setRectangleTool();
+ void setFilledRectangleTool();
+ void setEllipseTool();
+ void setFilledEllipseTool();
+ void setFillTool();
+ void setEraseTool();
void changePenWidth(int value);
void changePenColor(const QColor& color);
@@ -56,10 +58,13 @@ private slots:
void updateNavigationToolButtons();
void updateCaption();
+ void importPage();
+ void exportPage();
+
private:
DrawPadCanvas* m_pDrawPadCanvas;
- DrawMode* m_pDrawMode;
+ Tool* m_pTool;
QPen m_pen;
QBrush m_brush;
@@ -71,13 +76,17 @@ private:
QAction* m_pNextPageAction;
QAction* m_pLastPageAction;
- QAction* m_pPointDrawModeAction;
- QAction* m_pLineDrawModeAction;
- QAction* m_pRectangleDrawModeAction;
- QAction* m_pEllipseDrawModeAction;
- QAction* m_pFillDrawModeAction;
- QAction* m_pEraseDrawModeAction;
-
+ QAction* m_pPointToolAction;
+ QAction* m_pLineToolAction;
+ QAction* m_pRectangleToolAction;
+ QAction* m_pFilledRectangleToolAction;
+ QAction* m_pEllipseToolAction;
+ QAction* m_pFilledEllipseToolAction;
+ QAction* m_pFillToolAction;
+ QAction* m_pEraseToolAction;
+
+ QToolButton* m_pRectangleToolButton;
+ QToolButton* m_pEllipseToolButton;
QToolButton* m_pPenColorToolButton;
QToolButton* m_pBrushColorToolButton;
};
diff --git a/noncore/graphics/drawpad/drawpad.pro b/noncore/graphics/drawpad/drawpad.pro
index b0eb009..5f14515 100644
--- a/noncore/graphics/drawpad/drawpad.pro
+++ b/noncore/graphics/drawpad/drawpad.pro
@@ -2,31 +2,39 @@ TEMPLATE = app
CONFIG = qt warn_on release
HEADERS = colordialog.h \
colorpanel.h \
- drawmode.h \
drawpad.h \
drawpadcanvas.h \
- ellipsedrawmode.h \
- erasedrawmode.h \
- filldrawmode.h \
- linedrawmode.h \
+ ellipsetool.h \
+ erasetool.h \
+ exportdialog.h \
+ filltool.h \
+ filledellipsetool.h \
+ filledrectangletool.h \
+ importdialog.h \
+ linetool.h \
newpagedialog.h \
- pointdrawmode.h \
- rectangledrawmode.h \
- shapedrawmode.h
+ pointtool.h \
+ rectangletool.h \
+ shapetool.h \
+ tool.h
SOURCES = colordialog.cpp \
colorpanel.cpp \
- drawmode.cpp \
drawpad.cpp \
drawpadcanvas.cpp \
- ellipsedrawmode.cpp \
- erasedrawmode.cpp \
- filldrawmode.cpp \
- linedrawmode.cpp \
+ ellipsetool.cpp \
+ erasetool.cpp \
+ exportdialog.cpp \
+ filltool.cpp \
+ filledellipsetool.cpp \
+ filledrectangletool.cpp \
+ importdialog.cpp \
+ linetool.cpp \
main.cpp \
newpagedialog.cpp \
- pointdrawmode.cpp \
- rectangledrawmode.cpp \
- shapedrawmode.cpp
+ pointtool.cpp \
+ rectangletool.cpp \
+ shapetool.cpp \
+ tool.cpp
INCLUDEPATH += $(OPIEDIR)/include \
$(QTDIR)/src/3rdparty/zlib
DEPENDPATH += $(OPIEDIR)/include
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 40c27b5..8818c03 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -13,12 +13,17 @@
#include "drawpadcanvas.h"
-#include "drawmode.h"
#include "drawpad.h"
#include "newpagedialog.h"
+#include "tool.h"
+
+#include <qpe/applnk.h>
+#include <qpe/filemanager.h>
+#include <qpe/mimetype.h>
#include <qbuffer.h>
#include <qimage.h>
+#include <qmessagebox.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <qtextcodec.h>
@@ -239,6 +244,60 @@ void DrawPadCanvas::save(QIODevice* ioDevice)
textStream << "</drawpad>";
}
+void DrawPadCanvas::importPage(const QString& fileName)
+{
+ QPixmap* importedPixmap = new QPixmap();
+
+ importedPixmap->load(fileName);
+ m_pages.insert(m_pages.at() + 1, importedPixmap);
+
+ m_pageBackups.clear();
+ m_pageBackups.append(new QPixmap(*(m_pages.current())));
+
+ resizeContents(m_pages.current()->width(), m_pages.current()->height());
+ viewport()->update();
+
+ emit pagesChanged();
+ emit pageBackupsChanged();
+}
+
+void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format)
+{
+ if (fromPage == toPage) {
+ DocLnk docLnk;
+ MimeType mimeType(format);
+
+ docLnk.setName(name);
+ docLnk.setType(mimeType.id());
+
+ FileManager fileManager;
+ QIODevice* ioDevice = fileManager.saveFile(docLnk);
+ QImageIO imageIO(ioDevice, format);
+
+ QImage image = m_pages.current()->convertToImage();
+ imageIO.setImage(image);
+ imageIO.write();
+ delete ioDevice;
+ } else {
+ for (uint i = fromPage; i <= toPage; i++) {
+ DocLnk docLnk;
+ MimeType mimeType(format);
+
+ docLnk.setName(name + QString::number(i));
+ docLnk.setType(mimeType.id());
+
+ FileManager fileManager;
+ QIODevice* ioDevice = fileManager.saveFile(docLnk);
+ QImageIO imageIO(ioDevice, format);
+
+ QImage image = m_pages.at(i - 1)->convertToImage();
+ imageIO.setImage(image);
+ imageIO.write();
+ delete ioDevice;
+ }
+ }
+}
+
QPixmap* DrawPadCanvas::currentPage()
{
return m_pages.current();
@@ -254,34 +313,41 @@ uint DrawPadCanvas::pageCount()
return m_pages.count();
}
-void DrawPadCanvas::clearAll()
+void DrawPadCanvas::deleteAll()
{
- m_pages.clear();
+ QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"),
+ QMessageBox::Information, QMessageBox::Yes,
+ QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
+ QMessageBox::NoButton, this);
- m_pages.append(new QPixmap(contentsRect().size()));
- m_pages.current()->fill(Qt::white);
+ if (messageBox.exec() == QMessageBox::Yes) {
+ m_pages.clear();
- m_pageBackups.clear();
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
+ m_pages.append(new QPixmap(contentsRect().size()));
+ m_pages.current()->fill(Qt::white);
- resizeContents(m_pages.current()->width(), m_pages.current()->height());
- viewport()->update();
+ m_pageBackups.clear();
+ m_pageBackups.append(new QPixmap(*(m_pages.current())));
- emit pagesChanged();
- emit pageBackupsChanged();
+ resizeContents(m_pages.current()->width(), m_pages.current()->height());
+ viewport()->update();
+
+ emit pagesChanged();
+ emit pageBackupsChanged();
+ }
}
void DrawPadCanvas::newPage()
{
QRect rect = contentsRect();
- NewPageDialog newPageDialog(this);
- newPageDialog.setWidth(rect.width());
- newPageDialog.setHeight(rect.height());
+ NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(),
+ m_pDrawPad->brush().color(), this);
if (newPageDialog.exec() == QDialog::Accepted) {
- m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.width(), newPageDialog.height()));
- m_pages.current()->fill(Qt::white);
+ m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.selectedWidth(),
+ newPageDialog.selectedHeight()));
+ m_pages.current()->fill(newPageDialog.selectedColor());
m_pageBackups.clear();
m_pageBackups.append(new QPixmap(*(m_pages.current())));
@@ -296,28 +362,42 @@ void DrawPadCanvas::newPage()
void DrawPadCanvas::clearPage()
{
- m_pages.current()->fill(Qt::white);
+ 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);
- viewport()->update();
+ if (messageBox.exec() == QMessageBox::Yes) {
+ m_pages.current()->fill(Qt::white);
+
+ viewport()->update();
+ }
}
void DrawPadCanvas::deletePage()
{
- m_pages.remove(m_pages.current());
+ 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);
- if (m_pages.isEmpty()) {
- m_pages.append(new QPixmap(contentsRect().size()));
- m_pages.current()->fill(Qt::white);
- }
+ if (messageBox.exec() == QMessageBox::Yes) {
+ m_pages.remove(m_pages.current());
- m_pageBackups.clear();
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
+ if (m_pages.isEmpty()) {
+ m_pages.append(new QPixmap(contentsRect().size()));
+ m_pages.current()->fill(Qt::white);
+ }
- resizeContents(m_pages.current()->width(), m_pages.current()->height());
- viewport()->update();
+ m_pageBackups.clear();
+ m_pageBackups.append(new QPixmap(*(m_pages.current())));
- emit pagesChanged();
- emit pageBackupsChanged();
+ resizeContents(m_pages.current()->width(), m_pages.current()->height());
+ viewport()->update();
+
+ emit pagesChanged();
+ emit pageBackupsChanged();
+ }
}
bool DrawPadCanvas::undoEnabled()
@@ -412,12 +492,12 @@ void DrawPadCanvas::goLastPage()
void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e)
{
- m_pDrawPad->drawMode()->mousePressEvent(e);
+ m_pDrawPad->tool()->mousePressEvent(e);
}
void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e)
{
- m_pDrawPad->drawMode()->mouseReleaseEvent(e);
+ m_pDrawPad->tool()->mouseReleaseEvent(e);
QPixmap* currentBackup = m_pageBackups.current();
while (m_pageBackups.last() != currentBackup) {
@@ -435,7 +515,7 @@ void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e)
void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e)
{
- m_pDrawPad->drawMode()->mouseMoveEvent(e);
+ m_pDrawPad->tool()->mouseMoveEvent(e);
}
void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h
index 4836a3f..90dd951 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.h
+++ b/noncore/graphics/drawpad/drawpadcanvas.h
@@ -35,6 +35,9 @@ public:
void initialPage();
void save(QIODevice* ioDevice);
+ void importPage(const QString& fileName);
+ void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format);
+
bool undoEnabled();
bool redoEnabled();
bool goPreviousPageEnabled();
@@ -45,7 +48,7 @@ public:
uint pageCount();
public slots:
- void clearAll();
+ void deleteAll();
void newPage();
void clearPage();
void deletePage();
diff --git a/noncore/graphics/drawpad/ellipsetool.cpp b/noncore/graphics/drawpad/ellipsetool.cpp
new file mode 100644
index 0000000..c3badc3
--- a/dev/null
+++ b/noncore/graphics/drawpad/ellipsetool.cpp
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * *
+ * 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 <qpainter.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.setPen(m_pDrawPad->pen());
+ p.setRasterOp(Qt::CopyROP);
+ 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/ellipsetool.h b/noncore/graphics/drawpad/ellipsetool.h
new file mode 100644
index 0000000..1f48b39
--- a/dev/null
+++ b/noncore/graphics/drawpad/ellipsetool.h
@@ -0,0 +1,30 @@
+/***************************************************************************
+ * *
+ * 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 ELLIPSETOOL_H
+#define ELLIPSETOOL_H
+
+#include "shapetool.h"
+
+class EllipseTool : public ShapeTool
+{
+public:
+ EllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
+ ~EllipseTool();
+
+protected:
+ void drawFinalShape(QPainter& p);
+ void drawTemporaryShape(QPainter& p);
+};
+
+#endif // ELLIPSETOOL_H
diff --git a/noncore/graphics/drawpad/erasetool.cpp b/noncore/graphics/drawpad/erasetool.cpp
new file mode 100644
index 0000000..d37c901
--- a/dev/null
+++ b/noncore/graphics/drawpad/erasetool.cpp
@@ -0,0 +1,74 @@
+/***************************************************************************
+ * *
+ * 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 "erasetool.h"
+
+#include "drawpad.h"
+#include "drawpadcanvas.h"
+
+#include <qpainter.h>
+#include <qpixmap.h>
+
+EraseTool::EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
+ : Tool(drawPad, drawPadCanvas)
+{
+ m_mousePressed = false;
+ m_polyline.resize(3);
+}
+
+EraseTool::~EraseTool()
+{
+}
+
+void EraseTool::mousePressEvent(QMouseEvent* e)
+{
+ m_mousePressed = true;
+ m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
+}
+
+void EraseTool::mouseReleaseEvent(QMouseEvent* e)
+{
+ Q_UNUSED(e)
+
+ m_mousePressed = false;
+}
+
+void EraseTool::mouseMoveEvent(QMouseEvent* e)
+{
+ if (m_mousePressed) {
+ QPainter painter;
+ QPen pen(Qt::white, m_pDrawPad->pen().width());
+ painter.begin(m_pDrawPadCanvas->currentPage());
+ painter.setPen(pen);
+ m_polyline[2] = m_polyline[1];
+ m_polyline[1] = m_polyline[0];
+ m_polyline[0] = e->pos();
+ painter.drawPolyline(m_polyline);
+ painter.end();
+
+ 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());
+
+ 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);
+ }
+}
diff --git a/noncore/graphics/drawpad/erasetool.h b/noncore/graphics/drawpad/erasetool.h
new file mode 100644
index 0000000..3871404
--- a/dev/null
+++ b/noncore/graphics/drawpad/erasetool.h
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * *
+ * 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 ERASETOOL_H
+#define ERASEPOINTTOOL_H
+
+#include "tool.h"
+
+#include <qpointarray.h>
+
+class EraseTool : public Tool
+{
+public:
+ EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
+ ~EraseTool();
+
+ void mousePressEvent(QMouseEvent* e);
+ void mouseReleaseEvent(QMouseEvent* e);
+ void mouseMoveEvent(QMouseEvent* e);
+
+private:
+ bool m_mousePressed;
+ QPointArray m_polyline;
+};
+
+#endif // ERASETOOL_H
diff --git a/noncore/graphics/drawpad/exportdialog.cpp b/noncore/graphics/drawpad/exportdialog.cpp
new file mode 100644
index 0000000..0a980fc
--- a/dev/null
+++ b/noncore/graphics/drawpad/exportdialog.cpp
@@ -0,0 +1,173 @@
+/***************************************************************************
+ * *
+ * 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 "exportdialog.h"
+
+#include <qpe/fileselector.h>
+
+#include <qbuttongroup.h>
+#include <qcombobox.h>
+#include <qgroupbox.h>
+#include <qimage.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qradiobutton.h>
+#include <qspinbox.h>
+
+#include <stdlib.h>
+
+ExportDialog::ExportDialog(uint pageAt, uint pageCount, QWidget* parent, const char* name)
+ : QDialog(parent, name, true)
+{
+ setCaption(tr("Export"));
+
+ m_pageAt = pageAt;
+ m_pageCount = pageCount;
+
+ QButtonGroup* selectionButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Page Selection"), this);
+ connect(selectionButtonGroup, SIGNAL(pressed(int)), this, SLOT(selectionChanged(int)));
+
+ QRadioButton* selectAllRadioButton = new QRadioButton(tr("All"), selectionButtonGroup);
+ QRadioButton* selectCurrentRadioButton = new QRadioButton(tr("Current"), selectionButtonGroup);
+ QRadioButton* selectRangeRadioButton = new QRadioButton(tr("Range"), selectionButtonGroup);
+
+ QLabel* toLabel = new QLabel(tr("To:"), selectionButtonGroup);
+
+ m_pFromPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
+ connect(m_pFromPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fromPageChanged(int)));
+
+ m_pToPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
+ connect(m_pToPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(toPageChanged(int)));
+
+ selectionButtonGroup->setButton(1);
+ selectionChanged(1);
+
+ m_pFromPageSpinBox->setValue(pageAt);
+ m_pToPageSpinBox->setValue(pageAt);
+
+ QGroupBox* exportGroupBox = new QGroupBox(0, Qt::Vertical, tr("Export As"), this);
+
+ QLabel* nameLabel = new QLabel(tr("Name:"), exportGroupBox);
+ QLabel* formatLabel = new QLabel(tr("Format:"), exportGroupBox);
+
+ m_pNameLineEdit = new QLineEdit(exportGroupBox);
+
+ m_pFormatComboBox = new QComboBox(exportGroupBox);
+ m_pFormatComboBox->insertStrList(QImageIO::outputFormats());
+
+ FileSelector* fileSelector = new FileSelector("image/*", this, "fileselector");
+ fileSelector->setNewVisible(false);
+ fileSelector->setCloseVisible(false);
+
+ QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
+ selectionButtonGroup->layout()->setSpacing(4);
+ exportGroupBox->layout()->setSpacing(4);
+ QGridLayout* selectionLayout = new QGridLayout(selectionButtonGroup->layout(), 2, 2);
+ QHBoxLayout* rangeLayout = new QHBoxLayout();
+ QGridLayout* exportLayout = new QGridLayout(exportGroupBox->layout(), 2, 2);
+
+ selectionLayout->addWidget(selectAllRadioButton, 0, 0);
+ selectionLayout->addWidget(selectCurrentRadioButton, 1, 0);
+ selectionLayout->addWidget(selectRangeRadioButton, 0, 1);
+ selectionLayout->addLayout(rangeLayout, 1, 1);
+
+ rangeLayout->addWidget(m_pFromPageSpinBox);
+ rangeLayout->addWidget(toLabel);
+ rangeLayout->addWidget(m_pToPageSpinBox);
+
+ exportLayout->addWidget(nameLabel, 0, 0);
+ exportLayout->addWidget(formatLabel, 1, 0);
+
+ exportLayout->addWidget(m_pNameLineEdit, 0, 1);
+ exportLayout->addWidget(m_pFormatComboBox, 1, 1);
+
+ exportLayout->setColStretch(1, 1);
+
+ mainLayout->addWidget(selectionButtonGroup);
+ mainLayout->addWidget(exportGroupBox);
+ mainLayout->addWidget(fileSelector);
+
+ m_pNameLineEdit->setFocus();
+}
+
+ExportDialog::~ExportDialog()
+{
+}
+
+uint ExportDialog::selectedFromPage()
+{
+ return (m_pFromPageSpinBox->value());
+}
+
+uint ExportDialog::selectedToPage()
+{
+ return (m_pToPageSpinBox->value());
+}
+
+QString ExportDialog::selectedName()
+{
+ return (m_pNameLineEdit->text());
+}
+
+QString ExportDialog::selectedFormat()
+{
+ return (m_pFormatComboBox->currentText());
+}
+
+void ExportDialog::accept()
+{
+ if (!(m_pNameLineEdit->text().isEmpty())) {
+ QDialog::accept();
+ }
+}
+
+void ExportDialog::selectionChanged(int id)
+{
+ switch (id) {
+ case 0:
+ m_pFromPageSpinBox->setValue(1);
+ m_pToPageSpinBox->setValue(m_pageCount);
+
+ m_pFromPageSpinBox->setEnabled(false);
+ m_pToPageSpinBox->setEnabled(false);
+ break;
+ case 1:
+ m_pFromPageSpinBox->setValue(m_pageAt);
+ m_pToPageSpinBox->setValue(m_pageAt);
+
+ m_pFromPageSpinBox->setEnabled(false);
+ m_pToPageSpinBox->setEnabled(false);
+ break;
+ case 2:
+ m_pFromPageSpinBox->setEnabled(true);
+ m_pToPageSpinBox->setEnabled(true);
+ break;
+ default:
+ break;
+ }
+}
+
+void ExportDialog::fromPageChanged(int value)
+{
+ if (m_pToPageSpinBox->value() < value) {
+ m_pToPageSpinBox->setValue(value);
+ }
+}
+
+void ExportDialog::toPageChanged(int value)
+{
+ if (m_pFromPageSpinBox->value() > value) {
+ m_pFromPageSpinBox->setValue(value);
+ }
+}
diff --git a/noncore/graphics/drawpad/exportdialog.h b/noncore/graphics/drawpad/exportdialog.h
new file mode 100644
index 0000000..7379f6d
--- a/dev/null
+++ b/noncore/graphics/drawpad/exportdialog.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * *
+ * 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 EXPORTDIALOG_H
+#define EXPORTDIALOG_H
+
+#include <qdialog.h>
+
+#include <qstrlist.h>
+
+class QComboBox;
+class QLineEdit;
+class QSpinBox;
+
+class ExportDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ ExportDialog(uint pageAt, uint pageCount, QWidget* parent = 0, const char* name = 0);
+ ~ExportDialog();
+
+ uint selectedFromPage();
+ uint selectedToPage();
+
+ QString selectedName();
+ QString selectedFormat();
+
+public slots:
+ void accept();
+
+private slots:
+ void selectionChanged(int id);
+ void fromPageChanged(int value);
+ void toPageChanged(int value);
+
+private:
+ uint m_pageAt;
+ uint m_pageCount;
+
+ QSpinBox* m_pFromPageSpinBox;
+ QSpinBox* m_pToPageSpinBox;
+
+ QLineEdit* m_pNameLineEdit;
+ QComboBox* m_pFormatComboBox;
+};
+
+#endif // EXPORTDIALOG_H
diff --git a/noncore/graphics/drawpad/filledellipsetool.cpp b/noncore/graphics/drawpad/filledellipsetool.cpp
new file mode 100644
index 0000000..b446000
--- a/dev/null
+++ b/noncore/graphics/drawpad/filledellipsetool.cpp
@@ -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. *
+ * *
+ ***************************************************************************/
+
+#include "filledellipsetool.h"
+
+#include "drawpad.h"
+#include "drawpadcanvas.h"
+
+#include <qpainter.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.setPen(m_pDrawPad->pen());
+ p.setBrush(m_pDrawPad->brush());
+ p.setRasterOp(Qt::CopyROP);
+ 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/filledellipsetool.h b/noncore/graphics/drawpad/filledellipsetool.h
new file mode 100644
index 0000000..b29be20
--- a/dev/null
+++ b/noncore/graphics/drawpad/filledellipsetool.h
@@ -0,0 +1,30 @@
+/***************************************************************************
+ * *
+ * 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 FILLEDELLIPSETOOL_H
+#define FILLEDELLIPSETOOL_H
+
+#include "shapetool.h"
+
+class FilledEllipseTool : public ShapeTool
+{
+public:
+ FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
+ ~FilledEllipseTool();
+
+protected:
+ void drawFinalShape(QPainter& p);
+ void drawTemporaryShape(QPainter& p);
+};
+
+#endif // FILLEDELLIPSETOOL_H
diff --git a/noncore/graphics/drawpad/filledrectangletool.cpp b/noncore/graphics/drawpad/filledrectangletool.cpp
new file mode 100644
index 0000000..388acbd
--- a/dev/null
+++ b/noncore/graphics/drawpad/filledrectangletool.cpp
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * *
+ * 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 "filledrectangletool.h"
+
+#include "drawpad.h"
+#include "drawpadcanvas.h"
+
+FilledRectangleTool::FilledRectangleTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
+ : ShapeTool(drawPad, drawPadCanvas)
+{
+}
+
+FilledRectangleTool::~FilledRectangleTool()
+{
+}
+
+void FilledRectangleTool::drawFinalShape(QPainter& p)
+{
+ p.setRasterOp(Qt::NotROP);
+ p.drawRect(QRect(m_polyline[2], m_polyline[0]));
+ p.setRasterOp(Qt::CopyROP);
+ p.fillRect(QRect(m_polyline[2], m_polyline[0]), m_pDrawPad->brush());
+ p.setPen(m_pDrawPad->pen());
+ p.drawRect(QRect(m_polyline[2], m_polyline[0]));
+}
+
+void FilledRectangleTool::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/filledrectangletool.h b/noncore/graphics/drawpad/filledrectangletool.h
new file mode 100644
index 0000000..7364911
--- a/dev/null
+++ b/noncore/graphics/drawpad/filledrectangletool.h
@@ -0,0 +1,30 @@
+/***************************************************************************
+ * *
+ * 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 FILLEDRECTANGLETOOL_H
+#define FILLEDRECTANGLETOOL_H
+
+#include "shapetool.h"
+
+class FilledRectangleTool : public ShapeTool
+{
+public:
+ FilledRectangleTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
+ ~FilledRectangleTool();
+
+protected:
+ void drawFinalShape(QPainter& p);
+ void drawTemporaryShape(QPainter& p);
+};
+
+#endif // FILLEDRECTANGLETOOL_H
diff --git a/noncore/graphics/drawpad/filltool.cpp b/noncore/graphics/drawpad/filltool.cpp
new file mode 100644
index 0000000..3297d21
--- a/dev/null
+++ b/noncore/graphics/drawpad/filltool.cpp
@@ -0,0 +1,88 @@
+/***************************************************************************
+ * *
+ * 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 "filltool.h"
+
+#include "drawpad.h"
+#include "drawpadcanvas.h"
+
+#include <qimage.h>
+#include <qpixmap.h>
+
+FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
+ : Tool(drawPad, drawPadCanvas)
+{
+}
+
+FillTool::~FillTool()
+{
+}
+
+void FillTool::mousePressEvent(QMouseEvent* e)
+{
+ int x = e->x();
+ int y = e->y();
+
+ m_image = m_pDrawPadCanvas->currentPage()->convertToImage();
+ m_fillRgb = m_pDrawPad->brush().color().rgb();
+ m_oldRgb = m_image.pixel(x, y);
+
+ if (m_oldRgb != m_fillRgb) {
+ fillLine(x, y);
+
+ m_pDrawPadCanvas->currentPage()->convertFromImage(m_image);
+ m_pDrawPadCanvas->viewport()->update();
+ }
+}
+
+void FillTool::mouseReleaseEvent(QMouseEvent* e)
+{
+ Q_UNUSED(e)
+}
+
+void FillTool::mouseMoveEvent(QMouseEvent* e)
+{
+ Q_UNUSED(e)
+}
+
+void FillTool::fillLine(int x, int y)
+{
+ if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) {
+ if (m_image.pixel(x, y) == m_oldRgb) {
+ int x1, x2;
+
+ x1 = x - 1;
+ x2 = x + 1;
+
+ while ((x1 >= 0) && (m_image.pixel(x1, y) == m_oldRgb)) {
+ x1--;
+ }
+
+ while ((x2 < m_image.width()) && (m_image.pixel(x2, y) == m_oldRgb)) {
+ x2++;
+ }
+
+ for (int i = x1 + 1; i < x2; i++) {
+ m_image.setPixel(i, y, m_fillRgb);
+ }
+
+ for (int i = x1 + 1; i < x2; i++) {
+ fillLine(i, y - 1);
+ }
+
+ for (int i = x1 + 1; i < x2; i++) {
+ fillLine(i, y + 1);
+ }
+ }
+ }
+}
diff --git a/noncore/graphics/drawpad/filltool.h b/noncore/graphics/drawpad/filltool.h
new file mode 100644
index 0000000..eaf9a27
--- a/dev/null
+++ b/noncore/graphics/drawpad/filltool.h
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * *
+ * 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 FILLTOOL_H
+#define FILLTOOL_H
+
+#include "tool.h"
+
+#include <qimage.h>
+
+class FillTool : public Tool
+{
+public:
+ FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
+ ~FillTool();
+
+ void mousePressEvent(QMouseEvent* e);
+ void mouseReleaseEvent(QMouseEvent* e);
+ void mouseMoveEvent(QMouseEvent* e);
+
+private:
+ void fillLine(int x, int y);
+
+ QImage m_image;
+ QRgb m_fillRgb;
+ QRgb m_oldRgb;
+};
+
+#endif // FILLTOOL_H
diff --git a/noncore/graphics/drawpad/importdialog.cpp b/noncore/graphics/drawpad/importdialog.cpp
new file mode 100644
index 0000000..7722417
--- a/dev/null
+++ b/noncore/graphics/drawpad/importdialog.cpp
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * *
+ * 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 "importdialog.h"
+
+#include <qpe/applnk.h>
+#include <qpe/fileselector.h>
+
+#include <qlayout.h>
+
+ImportDialog::ImportDialog(QWidget* parent, const char* name)
+ : QDialog(parent, name, true)
+{
+ setCaption(tr("Import"));
+
+ m_pFileSelector = new FileSelector("image/*", this, "fileselector");
+ m_pFileSelector->setNewVisible(false);
+ m_pFileSelector->setCloseVisible(false);
+
+ QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
+ mainLayout->addWidget(m_pFileSelector);
+}
+
+ImportDialog::~ImportDialog()
+{
+}
+
+const DocLnk* ImportDialog::selected()
+{
+ return m_pFileSelector->selected();
+}
diff --git a/noncore/graphics/drawpad/importdialog.h b/noncore/graphics/drawpad/importdialog.h
new file mode 100644
index 0000000..1c67145
--- a/dev/null
+++ b/noncore/graphics/drawpad/importdialog.h
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * *
+ * 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 IMPORTDIALOG_H
+#define IMPORTDIALOG_H
+
+#include <qdialog.h>
+
+class DocLnk;
+class FileSelector;
+
+class ImportDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ ImportDialog(QWidget* parent = 0, const char* name = 0);
+ ~ImportDialog();
+
+ const DocLnk* selected();
+
+private:
+ FileSelector* m_pFileSelector;
+};
+
+#endif // IMPORTDIALOG_H
diff --git a/noncore/graphics/drawpad/linetool.cpp b/noncore/graphics/drawpad/linetool.cpp
new file mode 100644
index 0000000..94ca165
--- a/dev/null
+++ b/noncore/graphics/drawpad/linetool.cpp
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * *
+ * 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"
+
+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.setPen(m_pDrawPad->pen());
+ p.setRasterOp(Qt::CopyROP);
+ 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/linetool.h b/noncore/graphics/drawpad/linetool.h
new file mode 100644
index 0000000..6108b5a
--- a/dev/null
+++ b/noncore/graphics/drawpad/linetool.h
@@ -0,0 +1,30 @@
+/***************************************************************************
+ * *
+ * 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 LINETOOL_H
+#define LINETOOL_H
+
+#include "shapetool.h"
+
+class LineTool : public ShapeTool
+{
+public:
+ LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
+ ~LineTool();
+
+protected:
+ void drawFinalShape(QPainter& p);
+ void drawTemporaryShape(QPainter& p);
+};
+
+#endif // LINETOOL_H
diff --git a/noncore/graphics/drawpad/newpagedialog.cpp b/noncore/graphics/drawpad/newpagedialog.cpp
index c11d977..b1b26ef 100644
--- a/noncore/graphics/drawpad/newpagedialog.cpp
+++ b/noncore/graphics/drawpad/newpagedialog.cpp
@@ -13,49 +13,90 @@
#include "newpagedialog.h"
+#include <qbuttongroup.h>
+#include <qgroupbox.h>
#include <qlabel.h>
#include <qlayout.h>
+#include <qradiobutton.h>
#include <qspinbox.h>
-NewPageDialog::NewPageDialog(QWidget* parent, const char* name)
+NewPageDialog::NewPageDialog(uint width, uint height, const QColor& foregroundColor,
+ const QColor& backgroundColor, QWidget* parent, const char* name)
: QDialog(parent, name, true)
{
setCaption(tr("New Page"));
- QLabel* widthLabel = new QLabel(tr("Width :"), this);
- QLabel* heightLabel = new QLabel(tr("Height :"), this);
+ m_foregroundColor = foregroundColor;
+ m_backgroundColor = backgroundColor;
- m_pWidthSpinBox = new QSpinBox(1, 1024, 1, this);
- m_pHeightSpinBox = new QSpinBox(1, 1024, 1, this);
+ QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Page Size"), this);
- QGridLayout* gridLayout = new QGridLayout(this, 2, 2, 2, 2);
+ QLabel* widthLabel = new QLabel(tr("Width :"), sizeGroupBox);
+ QLabel* heightLabel = new QLabel(tr("Height :"), sizeGroupBox);
- gridLayout->addWidget(widthLabel, 0, 0);
- gridLayout->addWidget(heightLabel, 1, 0);
- gridLayout->addWidget(m_pWidthSpinBox, 0, 1);
- gridLayout->addWidget(m_pHeightSpinBox, 1, 1);
-}
+ m_pWidthSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox);
+ m_pHeightSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox);
-NewPageDialog::~NewPageDialog()
-{
+ m_pWidthSpinBox->setValue(width);
+ m_pHeightSpinBox->setValue(height);
+
+ m_pContentButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Contents"), this);
+
+ QRadioButton* whiteColorRadioButton = new QRadioButton(tr("White"), m_pContentButtonGroup);
+ QRadioButton* foregroundColorRadioButton = new QRadioButton(tr("Foreground Color"), m_pContentButtonGroup);
+ QRadioButton* backgroundColorRadioButton = new QRadioButton(tr("Background Color"), m_pContentButtonGroup);
+
+ m_pContentButtonGroup->setButton(0);
+
+ QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
+ sizeGroupBox->layout()->setSpacing(4);
+ m_pContentButtonGroup->layout()->setSpacing(4);
+ QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2);
+ QVBoxLayout* contentLayout = new QVBoxLayout(m_pContentButtonGroup->layout());
+
+ sizeLayout->addWidget(widthLabel, 0, 0);
+ sizeLayout->addWidget(heightLabel, 1, 0);
+ sizeLayout->addWidget(m_pWidthSpinBox, 0, 1);
+ sizeLayout->addWidget(m_pHeightSpinBox, 1, 1);
+
+ sizeLayout->setColStretch(1, 1);
+
+ contentLayout->addWidget(whiteColorRadioButton);
+ contentLayout->addWidget(foregroundColorRadioButton);
+ contentLayout->addWidget(backgroundColorRadioButton);
+
+ mainLayout->addWidget(sizeGroupBox);
+ mainLayout->addWidget(m_pContentButtonGroup);
}
-void NewPageDialog::setWidth(int width)
+NewPageDialog::~NewPageDialog()
{
- m_pWidthSpinBox->setValue(width);
}
-void NewPageDialog::setHeight(int height)
+uint NewPageDialog::selectedWidth()
{
- m_pHeightSpinBox->setValue(height);
+ return (m_pWidthSpinBox->value());
}
-int NewPageDialog::width()
+uint NewPageDialog::selectedHeight()
{
- return m_pWidthSpinBox->value();
+ return (m_pHeightSpinBox->value());
}
-int NewPageDialog::height()
+const QColor& NewPageDialog::selectedColor()
{
- return m_pHeightSpinBox->value();
+ switch (m_pContentButtonGroup->id(m_pContentButtonGroup->selected())) {
+ case 0:
+ return (Qt::white);
+ break;
+ case 1:
+ return (m_foregroundColor);
+ break;
+ case 2:
+ return (m_backgroundColor);
+ break;
+ default:
+ return (Qt::white);
+ break;
+ }
}
diff --git a/noncore/graphics/drawpad/newpagedialog.h b/noncore/graphics/drawpad/newpagedialog.h
index a2b6b87..f418340 100644
--- a/noncore/graphics/drawpad/newpagedialog.h
+++ b/noncore/graphics/drawpad/newpagedialog.h
@@ -16,6 +16,7 @@
#include <qdialog.h>
+class QButtonGroup;
class QSpinBox;
class NewPageDialog : public QDialog
@@ -23,18 +24,22 @@ class NewPageDialog : public QDialog
Q_OBJECT
public:
- NewPageDialog(QWidget* parent = 0, const char* name = 0);
+ NewPageDialog(uint width, uint height, const QColor& foregroundColor,
+ const QColor& backgroundColor, QWidget* parent = 0, const char* name = 0);
~NewPageDialog();
- void setWidth(int width);
- void setHeight(int height);
-
- int width();
- int height();
+ uint selectedWidth();
+ uint selectedHeight();
+ const QColor& selectedColor();
private:
QSpinBox* m_pWidthSpinBox;
QSpinBox* m_pHeightSpinBox;
+
+ QColor m_foregroundColor;
+ QColor m_backgroundColor;
+
+ QButtonGroup* m_pContentButtonGroup;
};
#endif // NEWPAGEDIALOG_H
diff --git a/noncore/graphics/drawpad/pointtool.cpp b/noncore/graphics/drawpad/pointtool.cpp
new file mode 100644
index 0000000..5661b03
--- a/dev/null
+++ b/noncore/graphics/drawpad/pointtool.cpp
@@ -0,0 +1,73 @@
+/***************************************************************************
+ * *
+ * 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 "pointtool.h"
+
+#include "drawpad.h"
+#include "drawpadcanvas.h"
+
+#include <qpainter.h>
+#include <qpixmap.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;
+}
+
+void PointTool::mouseMoveEvent(QMouseEvent* e)
+{
+ if (m_mousePressed) {
+ QPainter painter;
+ painter.begin(m_pDrawPadCanvas->currentPage());
+ painter.setPen(m_pDrawPad->pen());
+ m_polyline[2] = m_polyline[1];
+ m_polyline[1] = m_polyline[0];
+ m_polyline[0] = e->pos();
+ painter.drawPolyline(m_polyline);
+ painter.end();
+
+ 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());
+
+ 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);
+ }
+}
diff --git a/noncore/graphics/drawpad/pointtool.h b/noncore/graphics/drawpad/pointtool.h
new file mode 100644
index 0000000..4bbbac2
--- a/dev/null
+++ b/noncore/graphics/drawpad/pointtool.h
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * *
+ * 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 POINTTOOL_H
+#define POINTTOOL_H
+
+#include "tool.h"
+
+#include <qpointarray.h>
+
+class PointTool : public Tool
+{
+public:
+ PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
+ ~PointTool();
+
+ void mousePressEvent(QMouseEvent* e);
+ void mouseReleaseEvent(QMouseEvent* e);
+ void mouseMoveEvent(QMouseEvent* e);
+
+private:
+ bool m_mousePressed;
+ QPointArray m_polyline;
+};
+
+#endif // POINTTOOL_H
diff --git a/noncore/graphics/drawpad/rectangletool.cpp b/noncore/graphics/drawpad/rectangletool.cpp
new file mode 100644
index 0000000..a2f6026
--- a/dev/null
+++ b/noncore/graphics/drawpad/rectangletool.cpp
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * *
+ * 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 "rectangletool.h"
+
+#include "drawpad.h"
+#include "drawpadcanvas.h"
+
+RectangleTool::RectangleTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
+ : ShapeTool(drawPad, drawPadCanvas)
+{
+}
+
+RectangleTool::~RectangleTool()
+{
+}
+
+void RectangleTool::drawFinalShape(QPainter& p)
+{
+ p.setRasterOp(Qt::NotROP);
+ p.drawRect(QRect(m_polyline[2], m_polyline[0]));
+ p.setPen(m_pDrawPad->pen());
+ p.setRasterOp(Qt::CopyROP);
+ p.drawRect(QRect(m_polyline[2], m_polyline[0]));
+}
+
+void RectangleTool::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/rectangletool.h b/noncore/graphics/drawpad/rectangletool.h
new file mode 100644
index 0000000..b5164dc
--- a/dev/null
+++ b/noncore/graphics/drawpad/rectangletool.h
@@ -0,0 +1,30 @@
+/***************************************************************************
+ * *
+ * 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 RECTANGLETOOL_H
+#define RECTANGLETOOL_H
+
+#include "shapetool.h"
+
+class RectangleTool : public ShapeTool
+{
+public:
+ RectangleTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
+ ~RectangleTool();
+
+protected:
+ void drawFinalShape(QPainter& p);
+ void drawTemporaryShape(QPainter& p);
+};
+
+#endif // RECTANGLETOOL_H
diff --git a/noncore/graphics/drawpad/shapetool.cpp b/noncore/graphics/drawpad/shapetool.cpp
new file mode 100644
index 0000000..3c99370
--- a/dev/null
+++ b/noncore/graphics/drawpad/shapetool.cpp
@@ -0,0 +1,92 @@
+/***************************************************************************
+ * *
+ * 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 "shapetool.h"
+
+#include "drawpad.h"
+#include "drawpadcanvas.h"
+
+#include <qpainter.h>
+#include <qpixmap.h>
+
+ShapeTool::ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
+ : Tool(drawPad, drawPadCanvas)
+{
+ m_mousePressed = false;
+ m_polyline.resize(3);
+}
+
+ShapeTool::~ShapeTool()
+{
+}
+
+void ShapeTool::mousePressEvent(QMouseEvent* e)
+{
+ m_mousePressed = true;
+ m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
+}
+
+void ShapeTool::mouseReleaseEvent(QMouseEvent* e)
+{
+ Q_UNUSED(e)
+
+ QPainter painter;
+ painter.begin(m_pDrawPadCanvas->currentPage());
+ drawFinalShape(painter);
+ painter.end();
+
+ 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());
+
+ 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);
+
+ m_mousePressed = false;
+}
+
+void ShapeTool::mouseMoveEvent(QMouseEvent* e)
+{
+ if (m_mousePressed) {
+ m_polyline[0] = e->pos();
+ QPainter painter;
+ painter.begin(m_pDrawPadCanvas->currentPage());
+ drawTemporaryShape(painter);
+ painter.end();
+
+ 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());
+
+ 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);
+
+ m_polyline[1] = m_polyline[0];
+ }
+}
diff --git a/noncore/graphics/drawpad/shapetool.h b/noncore/graphics/drawpad/shapetool.h
new file mode 100644
index 0000000..3f2f7a9
--- a/dev/null
+++ b/noncore/graphics/drawpad/shapetool.h
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * *
+ * 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 SHAPETOOL_H
+#define SHAPETOOL_H
+
+#include "tool.h"
+
+#include <qpointarray.h>
+
+class ShapeTool : public Tool
+{
+public:
+ ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
+ ~ShapeTool();
+
+ void mousePressEvent(QMouseEvent* e);
+ void mouseReleaseEvent(QMouseEvent* e);
+ void mouseMoveEvent(QMouseEvent* e);
+
+protected:
+ virtual void drawFinalShape(QPainter& p) = 0;
+ virtual void drawTemporaryShape(QPainter& p) = 0;
+
+ QPointArray m_polyline;
+
+private:
+ bool m_mousePressed;
+};
+
+#endif // SHAPETOOL_H
diff --git a/noncore/graphics/drawpad/tool.cpp b/noncore/graphics/drawpad/tool.cpp
new file mode 100644
index 0000000..0d36912
--- a/dev/null
+++ b/noncore/graphics/drawpad/tool.cpp
@@ -0,0 +1,28 @@
+/***************************************************************************
+ * *
+ * 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 "tool.h"
+
+#include "drawpad.h"
+#include "drawpadcanvas.h"
+
+Tool::Tool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
+ : QObject()
+{
+ m_pDrawPad = drawPad;
+ m_pDrawPadCanvas = drawPadCanvas;
+}
+
+Tool::~Tool()
+{
+}
diff --git a/noncore/graphics/drawpad/tool.h b/noncore/graphics/drawpad/tool.h
new file mode 100644
index 0000000..5848215
--- a/dev/null
+++ b/noncore/graphics/drawpad/tool.h
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * *
+ * 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 TOOL_H
+#define TOOL_H
+
+#include <qobject.h>
+
+class DrawPad;
+class DrawPadCanvas;
+
+class Tool : public QObject
+{
+protected:
+ Tool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
+
+public:
+ virtual ~Tool();
+
+ virtual void mousePressEvent(QMouseEvent* e) = 0;
+ virtual void mouseReleaseEvent(QMouseEvent* e) = 0;
+ virtual void mouseMoveEvent(QMouseEvent* e) = 0;
+
+protected:
+ DrawPad* m_pDrawPad;
+ DrawPadCanvas* m_pDrawPadCanvas;
+};
+
+#endif // TOOL_H