author | leseb <leseb> | 2002-04-17 20:43:39 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-04-17 20:43:39 (UTC) |
commit | 106073977316103f057930daf45f3a083114d48d (patch) (unidiff) | |
tree | eede3bce7915e473d1204ecc93efb61946022447 | |
parent | c2c343110573bd8b4d59fbff577969ff23d5c544 (diff) | |
download | opie-106073977316103f057930daf45f3a083114d48d.zip opie-106073977316103f057930daf45f3a083114d48d.tar.gz opie-106073977316103f057930daf45f3a083114d48d.tar.bz2 |
Add text tool
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 84 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 3 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.pro | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 29 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.h | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/erasetool.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/filltool.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/pointtool.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/shapetool.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/texttool.cpp | 79 | ||||
-rw-r--r-- | noncore/graphics/drawpad/texttool.h | 46 | ||||
-rw-r--r-- | pics/drawpad/text.png | bin | 0 -> 142 bytes |
12 files changed, 218 insertions, 35 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index 1375792..7e6fc53 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -1,76 +1,77 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * DrawPad - a drawing program for Opie Environment * | 3 | * DrawPad - a drawing program for Opie Environment * |
4 | * * | 4 | * * |
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | 5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * |
6 | * * | 6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | * * | 11 | * * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | 13 | ||
14 | #include "drawpad.h" | 14 | #include "drawpad.h" |
15 | 15 | ||
16 | #include "colordialog.h" | 16 | #include "colordialog.h" |
17 | #include "colorpanel.h" | 17 | #include "colorpanel.h" |
18 | #include "drawpadcanvas.h" | 18 | #include "drawpadcanvas.h" |
19 | #include "ellipsetool.h" | 19 | #include "ellipsetool.h" |
20 | #include "erasetool.h" | 20 | #include "erasetool.h" |
21 | #include "exportdialog.h" | 21 | #include "exportdialog.h" |
22 | #include "filledellipsetool.h" | 22 | #include "filledellipsetool.h" |
23 | #include "filledrectangletool.h" | 23 | #include "filledrectangletool.h" |
24 | #include "filltool.h" | 24 | #include "filltool.h" |
25 | #include "importdialog.h" | 25 | #include "importdialog.h" |
26 | #include "linetool.h" | 26 | #include "linetool.h" |
27 | #include "pointtool.h" | 27 | #include "pointtool.h" |
28 | #include "rectangletool.h" | 28 | #include "rectangletool.h" |
29 | #include "texttool.h" | ||
29 | 30 | ||
30 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
31 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
32 | #include <qpe/qpemenubar.h> | 33 | #include <qpe/qpemenubar.h> |
33 | #include <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
34 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
35 | 36 | ||
36 | #include <qaction.h> | 37 | #include <qaction.h> |
37 | #include <qfile.h> | 38 | #include <qfile.h> |
38 | #include <qpainter.h> | 39 | #include <qpainter.h> |
39 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
40 | #include <qtoolbutton.h> | 41 | #include <qtoolbutton.h> |
41 | #include <qtooltip.h> | 42 | #include <qtooltip.h> |
42 | 43 | ||
43 | DrawPad::DrawPad(QWidget* parent, const char* name) | 44 | DrawPad::DrawPad(QWidget* parent, const char* name) |
44 | : QMainWindow(parent, name) | 45 | : QMainWindow(parent, name) |
45 | { | 46 | { |
46 | // init members | 47 | // init members |
47 | 48 | ||
48 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); | 49 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); |
49 | 50 | ||
50 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); | 51 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); |
51 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); | 52 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); |
52 | connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); | 53 | connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); |
53 | 54 | ||
54 | setCentralWidget(m_pDrawPadCanvas); | 55 | setCentralWidget(m_pDrawPadCanvas); |
55 | 56 | ||
56 | // init menu | 57 | // init menu |
57 | 58 | ||
58 | setToolBarsMovable(false); | 59 | setToolBarsMovable(false); |
59 | 60 | ||
60 | QPEToolBar* menuToolBar = new QPEToolBar(this); | 61 | QPEToolBar* menuToolBar = new QPEToolBar(this); |
61 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); | 62 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); |
62 | 63 | ||
63 | QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar); | 64 | QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar); |
64 | 65 | ||
65 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); | 66 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); |
66 | connect(deleteAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deleteAll())); | 67 | connect(deleteAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deleteAll())); |
67 | deleteAllAction->addTo(toolsPopupMenu); | 68 | deleteAllAction->addTo(toolsPopupMenu); |
68 | 69 | ||
69 | toolsPopupMenu->insertSeparator(); | 70 | toolsPopupMenu->insertSeparator(); |
70 | 71 | ||
71 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); | 72 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); |
72 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); | 73 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); |
73 | importPageAction->addTo(toolsPopupMenu); | 74 | importPageAction->addTo(toolsPopupMenu); |
74 | 75 | ||
75 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); | 76 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); |
76 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); | 77 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); |
@@ -84,138 +85,149 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
84 | 85 | ||
85 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); | 86 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); |
86 | connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage())); | 87 | connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage())); |
87 | newPageAction->addTo(pageToolBar); | 88 | newPageAction->addTo(pageToolBar); |
88 | 89 | ||
89 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); | 90 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); |
90 | connect(clearPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearPage())); | 91 | connect(clearPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearPage())); |
91 | clearPageAction->addTo(pageToolBar); | 92 | clearPageAction->addTo(pageToolBar); |
92 | 93 | ||
93 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); | 94 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); |
94 | connect(deletePageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deletePage())); | 95 | connect(deletePageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deletePage())); |
95 | deletePageAction->addTo(pageToolBar); | 96 | deletePageAction->addTo(pageToolBar); |
96 | 97 | ||
97 | QPEToolBar* emptyToolBar = new QPEToolBar(this); | 98 | QPEToolBar* emptyToolBar = new QPEToolBar(this); |
98 | emptyToolBar->setHorizontalStretchable(true); | 99 | emptyToolBar->setHorizontalStretchable(true); |
99 | 100 | ||
100 | // init navigation toolbar | 101 | // init navigation toolbar |
101 | 102 | ||
102 | QPEToolBar* navigationToolBar = new QPEToolBar(this); | 103 | QPEToolBar* navigationToolBar = new QPEToolBar(this); |
103 | 104 | ||
104 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); | 105 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); |
105 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); | 106 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); |
106 | m_pUndoAction->addTo(navigationToolBar); | 107 | m_pUndoAction->addTo(navigationToolBar); |
107 | 108 | ||
108 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); | 109 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); |
109 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); | 110 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); |
110 | m_pRedoAction->addTo(navigationToolBar); | 111 | m_pRedoAction->addTo(navigationToolBar); |
111 | 112 | ||
112 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); | 113 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); |
113 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); | 114 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); |
114 | m_pFirstPageAction->addTo(navigationToolBar); | 115 | m_pFirstPageAction->addTo(navigationToolBar); |
115 | 116 | ||
116 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); | 117 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); |
117 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); | 118 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); |
118 | m_pPreviousPageAction->addTo(navigationToolBar); | 119 | m_pPreviousPageAction->addTo(navigationToolBar); |
119 | 120 | ||
120 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); | 121 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); |
121 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); | 122 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); |
122 | m_pNextPageAction->addTo(navigationToolBar); | 123 | m_pNextPageAction->addTo(navigationToolBar); |
123 | 124 | ||
124 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); | 125 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); |
125 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); | 126 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); |
126 | m_pLastPageAction->addTo(navigationToolBar); | 127 | m_pLastPageAction->addTo(navigationToolBar); |
127 | 128 | ||
128 | // init draw mode toolbar | 129 | // init draw mode toolbar |
129 | 130 | ||
130 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); | 131 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); |
131 | 132 | ||
132 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), QString::null, 0, this); | 133 | m_pLineToolButton = new QToolButton(drawModeToolBar); |
133 | m_pPointToolAction->setToggleAction(true); | 134 | m_pLineToolButton->setToggleButton(true); |
135 | |||
136 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); | ||
137 | |||
138 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), "", 0, this); | ||
134 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); | 139 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); |
135 | m_pPointToolAction->addTo(drawModeToolBar); | 140 | m_pPointToolAction->addTo(linePopupMenu); |
136 | 141 | ||
137 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), QString::null, 0, this); | 142 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), "", 0, this); |
138 | m_pLineToolAction->setToggleAction(true); | ||
139 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); | 143 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); |
140 | m_pLineToolAction->addTo(drawModeToolBar); | 144 | m_pLineToolAction->addTo(linePopupMenu); |
145 | |||
146 | m_pLineToolButton->setPopup(linePopupMenu); | ||
147 | m_pLineToolButton->setPopupDelay(0); | ||
141 | 148 | ||
142 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); | 149 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); |
143 | m_pRectangleToolButton->setToggleButton(true); | 150 | m_pRectangleToolButton->setToggleButton(true); |
144 | 151 | ||
145 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); | 152 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); |
146 | 153 | ||
147 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this); | 154 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this); |
148 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); | 155 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); |
149 | m_pRectangleToolAction->addTo(rectanglePopupMenu); | 156 | m_pRectangleToolAction->addTo(rectanglePopupMenu); |
150 | 157 | ||
151 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this); | 158 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this); |
152 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); | 159 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); |
153 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); | 160 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); |
154 | 161 | ||
155 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); | 162 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); |
156 | m_pRectangleToolButton->setPopupDelay(0); | 163 | m_pRectangleToolButton->setPopupDelay(0); |
157 | 164 | ||
158 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); | 165 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); |
159 | m_pEllipseToolButton->setToggleButton(true); | 166 | m_pEllipseToolButton->setToggleButton(true); |
160 | 167 | ||
161 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); | 168 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); |
162 | 169 | ||
163 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this); | 170 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this); |
164 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); | 171 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); |
165 | m_pEllipseToolAction->addTo(ellipsePopupMenu); | 172 | m_pEllipseToolAction->addTo(ellipsePopupMenu); |
166 | 173 | ||
167 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this); | 174 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this); |
168 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); | 175 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); |
169 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); | 176 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); |
170 | 177 | ||
171 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); | 178 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); |
172 | m_pEllipseToolButton->setPopupDelay(0); | 179 | m_pEllipseToolButton->setPopupDelay(0); |
173 | 180 | ||
181 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadIconSet("drawpad/text.png"), QString::null, 0, this); | ||
182 | m_pTextToolAction->setToggleAction(true); | ||
183 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); | ||
184 | m_pTextToolAction->addTo(drawModeToolBar); | ||
185 | |||
174 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); | 186 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); |
175 | m_pFillToolAction->setToggleAction(true); | 187 | m_pFillToolAction->setToggleAction(true); |
176 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); | 188 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); |
177 | m_pFillToolAction->addTo(drawModeToolBar); | 189 | m_pFillToolAction->addTo(drawModeToolBar); |
178 | 190 | ||
179 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); | 191 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); |
180 | m_pEraseToolAction->setToggleAction(true); | 192 | m_pEraseToolAction->setToggleAction(true); |
181 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); | 193 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); |
182 | m_pEraseToolAction->addTo(drawModeToolBar); | 194 | m_pEraseToolAction->addTo(drawModeToolBar); |
183 | 195 | ||
184 | m_pTool = 0; | 196 | m_pTool = 0; |
185 | setRectangleTool(); | 197 | setRectangleTool(); |
186 | setEllipseTool(); | 198 | setEllipseTool(); |
187 | setPointTool(); | 199 | setPointTool(); |
188 | 200 | ||
189 | emptyToolBar = new QPEToolBar(this); | 201 | emptyToolBar = new QPEToolBar(this); |
190 | emptyToolBar->setHorizontalStretchable(true); | 202 | emptyToolBar->setHorizontalStretchable(true); |
191 | emptyToolBar->addSeparator(); | 203 | emptyToolBar->addSeparator(); |
192 | 204 | ||
193 | // init draw parameters toolbar | 205 | // init draw parameters toolbar |
194 | 206 | ||
195 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); | 207 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); |
196 | 208 | ||
197 | QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); | 209 | QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); |
198 | connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); | 210 | connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); |
199 | 211 | ||
200 | QToolTip::add(penWidthSpinBox, tr("Pen Width")); | 212 | QToolTip::add(penWidthSpinBox, tr("Pen Width")); |
201 | penWidthSpinBox->setValue(1); | 213 | penWidthSpinBox->setValue(1); |
202 | penWidthSpinBox->setFocusPolicy(QWidget::NoFocus); | 214 | penWidthSpinBox->setFocusPolicy(QWidget::NoFocus); |
203 | 215 | ||
204 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); | 216 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); |
205 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); | 217 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); |
206 | 218 | ||
207 | QPopupMenu* penColorPopupMenu = new QPopupMenu(m_pPenColorToolButton); | 219 | QPopupMenu* penColorPopupMenu = new QPopupMenu(m_pPenColorToolButton); |
208 | 220 | ||
209 | ColorPanel* penColorPanel = new ColorPanel(penColorPopupMenu); | 221 | ColorPanel* penColorPanel = new ColorPanel(penColorPopupMenu); |
210 | connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); | 222 | connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); |
211 | 223 | ||
212 | penColorPopupMenu->insertItem(penColorPanel); | 224 | penColorPopupMenu->insertItem(penColorPanel); |
213 | penColorPopupMenu->insertSeparator(); | 225 | penColorPopupMenu->insertSeparator(); |
214 | 226 | ||
215 | QAction* choosePenColorAction = new QAction(tr("More"), tr("More..."), 0, this); | 227 | QAction* choosePenColorAction = new QAction(tr("More"), tr("More..."), 0, this); |
216 | connect(choosePenColorAction, SIGNAL(activated()), this, SLOT(choosePenColor())); | 228 | connect(choosePenColorAction, SIGNAL(activated()), this, SLOT(choosePenColor())); |
217 | choosePenColorAction->addTo(penColorPopupMenu); | 229 | choosePenColorAction->addTo(penColorPopupMenu); |
218 | 230 | ||
219 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); | 231 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); |
220 | m_pPenColorToolButton->setPopup(penColorPopupMenu); | 232 | m_pPenColorToolButton->setPopup(penColorPopupMenu); |
221 | m_pPenColorToolButton->setPopupDelay(0); | 233 | m_pPenColorToolButton->setPopupDelay(0); |
@@ -228,236 +240,264 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
228 | QPopupMenu* brushColorPopupMenu = new QPopupMenu(m_pBrushColorToolButton); | 240 | QPopupMenu* brushColorPopupMenu = new QPopupMenu(m_pBrushColorToolButton); |
229 | 241 | ||
230 | ColorPanel* brushColorPanel = new ColorPanel(brushColorPopupMenu); | 242 | ColorPanel* brushColorPanel = new ColorPanel(brushColorPopupMenu); |
231 | connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); | 243 | connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); |
232 | 244 | ||
233 | brushColorPopupMenu->insertItem(brushColorPanel); | 245 | brushColorPopupMenu->insertItem(brushColorPanel); |
234 | brushColorPopupMenu->insertSeparator(); | 246 | brushColorPopupMenu->insertSeparator(); |
235 | 247 | ||
236 | QAction* chooseBrushColorAction = new QAction(tr("More"), tr("More..."), 0, this); | 248 | QAction* chooseBrushColorAction = new QAction(tr("More"), tr("More..."), 0, this); |
237 | connect(chooseBrushColorAction, SIGNAL(activated()), this, SLOT(chooseBrushColor())); | 249 | connect(chooseBrushColorAction, SIGNAL(activated()), this, SLOT(chooseBrushColor())); |
238 | chooseBrushColorAction->addTo(brushColorPopupMenu); | 250 | chooseBrushColorAction->addTo(brushColorPopupMenu); |
239 | 251 | ||
240 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); | 252 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); |
241 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); | 253 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); |
242 | m_pBrushColorToolButton->setPopupDelay(0); | 254 | m_pBrushColorToolButton->setPopupDelay(0); |
243 | 255 | ||
244 | brushColorPanel->buttonSelected(Qt::white); | 256 | brushColorPanel->buttonSelected(Qt::white); |
245 | 257 | ||
246 | // init pages | 258 | // init pages |
247 | 259 | ||
248 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 260 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
249 | 261 | ||
250 | if (file.open(IO_ReadOnly)) { | 262 | if (file.open(IO_ReadOnly)) { |
251 | m_pDrawPadCanvas->load(&file); | 263 | m_pDrawPadCanvas->load(&file); |
252 | file.close(); | 264 | file.close(); |
253 | } else { | 265 | } else { |
254 | m_pDrawPadCanvas->initialPage(); | 266 | m_pDrawPadCanvas->initialPage(); |
255 | } | 267 | } |
256 | } | 268 | } |
257 | 269 | ||
258 | DrawPad::~DrawPad() | 270 | DrawPad::~DrawPad() |
259 | { | 271 | { |
260 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 272 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
261 | 273 | ||
262 | if (file.open(IO_WriteOnly)) { | 274 | if (file.open(IO_WriteOnly)) { |
263 | m_pDrawPadCanvas->save(&file); | 275 | m_pDrawPadCanvas->save(&file); |
264 | file.close(); | 276 | file.close(); |
265 | } | 277 | } |
266 | } | 278 | } |
267 | 279 | ||
268 | void DrawPad::setPointTool() | 280 | void DrawPad::setPointTool() |
269 | { | 281 | { |
270 | if (m_pTool) { | 282 | if (m_pTool) { |
271 | delete m_pTool; | 283 | delete m_pTool; |
272 | } | 284 | } |
273 | 285 | ||
274 | m_pTool = new PointTool(this, m_pDrawPadCanvas); | 286 | m_pTool = new PointTool(this, m_pDrawPadCanvas); |
275 | 287 | ||
276 | m_pPointToolAction->setOn(true); | 288 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); |
277 | m_pLineToolAction->setOn(false); | 289 | QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); |
290 | |||
291 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | ||
292 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); | ||
293 | |||
294 | m_pLineToolButton->setOn(true); | ||
278 | m_pRectangleToolButton->setOn(false); | 295 | m_pRectangleToolButton->setOn(false); |
279 | m_pEllipseToolButton->setOn(false); | 296 | m_pEllipseToolButton->setOn(false); |
297 | m_pTextToolAction->setOn(false); | ||
280 | m_pFillToolAction->setOn(false); | 298 | m_pFillToolAction->setOn(false); |
281 | m_pEraseToolAction->setOn(false); | 299 | m_pEraseToolAction->setOn(false); |
282 | } | 300 | } |
283 | 301 | ||
284 | void DrawPad::setLineTool() | 302 | void DrawPad::setLineTool() |
285 | { | 303 | { |
286 | if (m_pTool) { | 304 | if (m_pTool) { |
287 | delete m_pTool; | 305 | delete m_pTool; |
288 | } | 306 | } |
289 | 307 | ||
290 | m_pTool = new LineTool(this, m_pDrawPadCanvas); | 308 | m_pTool = new LineTool(this, m_pDrawPadCanvas); |
291 | 309 | ||
292 | m_pPointToolAction->setOn(false); | 310 | m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); |
293 | m_pLineToolAction->setOn(true); | 311 | QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); |
312 | |||
313 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | ||
314 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); | ||
315 | |||
316 | m_pLineToolButton->setOn(true); | ||
294 | m_pRectangleToolButton->setOn(false); | 317 | m_pRectangleToolButton->setOn(false); |
295 | m_pEllipseToolButton->setOn(false); | 318 | m_pEllipseToolButton->setOn(false); |
319 | m_pTextToolAction->setOn(false); | ||
296 | m_pFillToolAction->setOn(false); | 320 | m_pFillToolAction->setOn(false); |
297 | m_pEraseToolAction->setOn(false); | 321 | m_pEraseToolAction->setOn(false); |
298 | } | 322 | } |
299 | 323 | ||
300 | void DrawPad::setRectangleTool() | 324 | void DrawPad::setRectangleTool() |
301 | { | 325 | { |
302 | if (m_pTool) { | 326 | if (m_pTool) { |
303 | delete m_pTool; | 327 | delete m_pTool; |
304 | } | 328 | } |
305 | 329 | ||
306 | m_pTool = new RectangleTool(this, m_pDrawPadCanvas); | 330 | m_pTool = new RectangleTool(this, m_pDrawPadCanvas); |
307 | 331 | ||
308 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); | 332 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); |
309 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); | 333 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); |
310 | 334 | ||
311 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 335 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
312 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); | 336 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); |
313 | 337 | ||
314 | m_pPointToolAction->setOn(false); | 338 | m_pLineToolButton->setOn(false); |
315 | m_pLineToolAction->setOn(false); | ||
316 | m_pRectangleToolButton->setOn(true); | 339 | m_pRectangleToolButton->setOn(true); |
317 | m_pEllipseToolButton->setOn(false); | 340 | m_pEllipseToolButton->setOn(false); |
341 | m_pTextToolAction->setOn(false); | ||
318 | m_pFillToolAction->setOn(false); | 342 | m_pFillToolAction->setOn(false); |
319 | m_pEraseToolAction->setOn(false); | 343 | m_pEraseToolAction->setOn(false); |
320 | } | 344 | } |
321 | 345 | ||
322 | void DrawPad::setFilledRectangleTool() | 346 | void DrawPad::setFilledRectangleTool() |
323 | { | 347 | { |
324 | if (m_pTool) { | 348 | if (m_pTool) { |
325 | delete m_pTool; | 349 | delete m_pTool; |
326 | } | 350 | } |
327 | 351 | ||
328 | m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); | 352 | m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); |
329 | 353 | ||
330 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); | 354 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); |
331 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); | 355 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); |
332 | 356 | ||
333 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 357 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
334 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); | 358 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); |
335 | 359 | ||
336 | m_pPointToolAction->setOn(false); | 360 | m_pLineToolButton->setOn(false); |
337 | m_pLineToolAction->setOn(false); | ||
338 | m_pRectangleToolButton->setOn(true); | 361 | m_pRectangleToolButton->setOn(true); |
339 | m_pEllipseToolButton->setOn(false); | 362 | m_pEllipseToolButton->setOn(false); |
363 | m_pTextToolAction->setOn(false); | ||
340 | m_pFillToolAction->setOn(false); | 364 | m_pFillToolAction->setOn(false); |
341 | m_pEraseToolAction->setOn(false); | 365 | m_pEraseToolAction->setOn(false); |
342 | } | 366 | } |
343 | 367 | ||
344 | void DrawPad::setEllipseTool() | 368 | void DrawPad::setEllipseTool() |
345 | { | 369 | { |
346 | if (m_pTool) { | 370 | if (m_pTool) { |
347 | delete m_pTool; | 371 | delete m_pTool; |
348 | } | 372 | } |
349 | 373 | ||
350 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); | 374 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); |
351 | 375 | ||
352 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); | 376 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); |
353 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); | 377 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); |
354 | 378 | ||
355 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 379 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
356 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); | 380 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); |
357 | 381 | ||
358 | m_pPointToolAction->setOn(false); | 382 | m_pLineToolButton->setOn(false); |
359 | m_pLineToolAction->setOn(false); | ||
360 | m_pRectangleToolButton->setOn(false); | 383 | m_pRectangleToolButton->setOn(false); |
361 | m_pEllipseToolButton->setOn(true); | 384 | m_pEllipseToolButton->setOn(true); |
385 | m_pTextToolAction->setOn(false); | ||
362 | m_pFillToolAction->setOn(false); | 386 | m_pFillToolAction->setOn(false); |
363 | m_pEraseToolAction->setOn(false); | 387 | m_pEraseToolAction->setOn(false); |
364 | } | 388 | } |
365 | 389 | ||
366 | void DrawPad::setFilledEllipseTool() | 390 | void DrawPad::setFilledEllipseTool() |
367 | { | 391 | { |
368 | if (m_pTool) { | 392 | if (m_pTool) { |
369 | delete m_pTool; | 393 | delete m_pTool; |
370 | } | 394 | } |
371 | 395 | ||
372 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); | 396 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); |
373 | 397 | ||
374 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); | 398 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); |
375 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); | 399 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); |
376 | 400 | ||
377 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 401 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
378 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); | 402 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); |
379 | 403 | ||
380 | m_pPointToolAction->setOn(false); | 404 | m_pLineToolButton->setOn(false); |
381 | m_pLineToolAction->setOn(false); | ||
382 | m_pRectangleToolButton->setOn(false); | 405 | m_pRectangleToolButton->setOn(false); |
383 | m_pEllipseToolButton->setOn(true); | 406 | m_pEllipseToolButton->setOn(true); |
407 | m_pTextToolAction->setOn(false); | ||
408 | m_pFillToolAction->setOn(false); | ||
409 | m_pEraseToolAction->setOn(false); | ||
410 | } | ||
411 | |||
412 | void DrawPad::setTextTool() | ||
413 | { | ||
414 | if (m_pTool) { | ||
415 | delete m_pTool; | ||
416 | } | ||
417 | |||
418 | m_pTool = new TextTool(this, m_pDrawPadCanvas); | ||
419 | |||
420 | m_pLineToolButton->setOn(false); | ||
421 | m_pRectangleToolButton->setOn(false); | ||
422 | m_pEllipseToolButton->setOn(false); | ||
423 | m_pTextToolAction->setOn(true); | ||
384 | m_pFillToolAction->setOn(false); | 424 | m_pFillToolAction->setOn(false); |
385 | m_pEraseToolAction->setOn(false); | 425 | m_pEraseToolAction->setOn(false); |
386 | } | 426 | } |
387 | 427 | ||
388 | void DrawPad::setFillTool() | 428 | void DrawPad::setFillTool() |
389 | { | 429 | { |
390 | if (m_pTool) { | 430 | if (m_pTool) { |
391 | delete m_pTool; | 431 | delete m_pTool; |
392 | } | 432 | } |
393 | 433 | ||
394 | m_pTool = new FillTool(this, m_pDrawPadCanvas); | 434 | m_pTool = new FillTool(this, m_pDrawPadCanvas); |
395 | 435 | ||
396 | m_pPointToolAction->setOn(false); | 436 | m_pLineToolButton->setOn(false); |
397 | m_pLineToolAction->setOn(false); | ||
398 | m_pRectangleToolButton->setOn(false); | 437 | m_pRectangleToolButton->setOn(false); |
399 | m_pEllipseToolButton->setOn(false); | 438 | m_pEllipseToolButton->setOn(false); |
439 | m_pTextToolAction->setOn(false); | ||
400 | m_pFillToolAction->setOn(true); | 440 | m_pFillToolAction->setOn(true); |
401 | m_pEraseToolAction->setOn(false); | 441 | m_pEraseToolAction->setOn(false); |
402 | } | 442 | } |
403 | 443 | ||
404 | void DrawPad::setEraseTool() | 444 | void DrawPad::setEraseTool() |
405 | { | 445 | { |
406 | if (m_pTool) { | 446 | if (m_pTool) { |
407 | delete m_pTool; | 447 | delete m_pTool; |
408 | } | 448 | } |
409 | 449 | ||
410 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); | 450 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); |
411 | 451 | ||
412 | m_pPointToolAction->setOn(false); | 452 | m_pLineToolButton->setOn(false); |
413 | m_pLineToolAction->setOn(false); | ||
414 | m_pRectangleToolButton->setOn(false); | 453 | m_pRectangleToolButton->setOn(false); |
415 | m_pEllipseToolButton->setOn(false); | 454 | m_pEllipseToolButton->setOn(false); |
455 | m_pTextToolAction->setOn(false); | ||
416 | m_pFillToolAction->setOn(false); | 456 | m_pFillToolAction->setOn(false); |
417 | m_pEraseToolAction->setOn(true); | 457 | m_pEraseToolAction->setOn(true); |
418 | } | 458 | } |
419 | 459 | ||
420 | void DrawPad::changePenWidth(int value) | 460 | void DrawPad::changePenWidth(int value) |
421 | { | 461 | { |
422 | m_pen.setWidth(value); | 462 | m_pen.setWidth(value); |
423 | } | 463 | } |
424 | 464 | ||
425 | void DrawPad::changePenColor(const QColor& color) | 465 | void DrawPad::changePenColor(const QColor& color) |
426 | { | 466 | { |
427 | m_pen.setColor(color); | 467 | m_pen.setColor(color); |
428 | 468 | ||
429 | QPainter painter; | 469 | QPainter painter; |
430 | painter.begin(m_pPenColorToolButton->pixmap()); | 470 | painter.begin(m_pPenColorToolButton->pixmap()); |
431 | painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); | 471 | painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); |
432 | painter.end(); | 472 | painter.end(); |
433 | 473 | ||
434 | m_pPenColorToolButton->popup()->hide(); | 474 | m_pPenColorToolButton->popup()->hide(); |
435 | } | 475 | } |
436 | 476 | ||
437 | void DrawPad::changeBrushColor(const QColor& color) | 477 | void DrawPad::changeBrushColor(const QColor& color) |
438 | { | 478 | { |
439 | m_brush = QBrush(color); | 479 | m_brush = QBrush(color); |
440 | 480 | ||
441 | QPainter painter; | 481 | QPainter painter; |
442 | painter.begin(m_pBrushColorToolButton->pixmap()); | 482 | painter.begin(m_pBrushColorToolButton->pixmap()); |
443 | painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); | 483 | painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); |
444 | painter.end(); | 484 | painter.end(); |
445 | 485 | ||
446 | m_pBrushColorToolButton->popup()->hide(); | 486 | m_pBrushColorToolButton->popup()->hide(); |
447 | } | 487 | } |
448 | 488 | ||
449 | void DrawPad::choosePenColor() | 489 | void DrawPad::choosePenColor() |
450 | { | 490 | { |
451 | QColor newPenColor = QColorDialog::getColor(m_pen.color()); | 491 | QColor newPenColor = QColorDialog::getColor(m_pen.color()); |
452 | changePenColor(newPenColor); | 492 | changePenColor(newPenColor); |
453 | } | 493 | } |
454 | 494 | ||
455 | void DrawPad::chooseBrushColor() | 495 | void DrawPad::chooseBrushColor() |
456 | { | 496 | { |
457 | QColor newBrushColor = QColorDialog::getColor(m_brush.color()); | 497 | QColor newBrushColor = QColorDialog::getColor(m_brush.color()); |
458 | changeBrushColor(newBrushColor); | 498 | changeBrushColor(newBrushColor); |
459 | } | 499 | } |
460 | 500 | ||
461 | void DrawPad::updateUndoRedoToolButtons() | 501 | void DrawPad::updateUndoRedoToolButtons() |
462 | { | 502 | { |
463 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled()); | 503 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled()); |
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h index 62a73c9..e4fd831 100644 --- a/noncore/graphics/drawpad/drawpad.h +++ b/noncore/graphics/drawpad/drawpad.h | |||
@@ -1,94 +1,97 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * DrawPad - a drawing program for Opie Environment * | 3 | * DrawPad - a drawing program for Opie Environment * |
4 | * * | 4 | * * |
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | 5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * |
6 | * * | 6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | * * | 11 | * * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | 13 | ||
14 | #ifndef DRAWPAD_H | 14 | #ifndef DRAWPAD_H |
15 | #define DRAWPAD_H | 15 | #define DRAWPAD_H |
16 | 16 | ||
17 | #include <qmainwindow.h> | 17 | #include <qmainwindow.h> |
18 | 18 | ||
19 | #include <qpen.h> | 19 | #include <qpen.h> |
20 | 20 | ||
21 | class DrawPadCanvas; | 21 | class DrawPadCanvas; |
22 | class Tool; | 22 | class Tool; |
23 | 23 | ||
24 | class QAction; | 24 | class QAction; |
25 | class QColor; | 25 | class QColor; |
26 | class QToolButton; | 26 | class QToolButton; |
27 | class QWidgetStack; | 27 | class QWidgetStack; |
28 | 28 | ||
29 | class DrawPad : public QMainWindow | 29 | class DrawPad : public QMainWindow |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | 32 | ||
33 | public: | 33 | public: |
34 | DrawPad(QWidget* parent = 0, const char* name = 0); | 34 | DrawPad(QWidget* parent = 0, const char* name = 0); |
35 | ~DrawPad(); | 35 | ~DrawPad(); |
36 | 36 | ||
37 | Tool* tool() { return m_pTool; } | 37 | Tool* tool() { return m_pTool; } |
38 | QPen pen() { return m_pen; } | 38 | QPen pen() { return m_pen; } |
39 | QBrush brush() { return m_brush; } | 39 | QBrush brush() { return m_brush; } |
40 | 40 | ||
41 | private slots: | 41 | private slots: |
42 | void setPointTool(); | 42 | void setPointTool(); |
43 | void setLineTool(); | 43 | void setLineTool(); |
44 | void setRectangleTool(); | 44 | void setRectangleTool(); |
45 | void setFilledRectangleTool(); | 45 | void setFilledRectangleTool(); |
46 | void setEllipseTool(); | 46 | void setEllipseTool(); |
47 | void setFilledEllipseTool(); | 47 | void setFilledEllipseTool(); |
48 | void setTextTool(); | ||
48 | void setFillTool(); | 49 | void setFillTool(); |
49 | void setEraseTool(); | 50 | void setEraseTool(); |
50 | 51 | ||
51 | void changePenWidth(int value); | 52 | void changePenWidth(int value); |
52 | void changePenColor(const QColor& color); | 53 | void changePenColor(const QColor& color); |
53 | void changeBrushColor(const QColor& color); | 54 | void changeBrushColor(const QColor& color); |
54 | void choosePenColor(); | 55 | void choosePenColor(); |
55 | void chooseBrushColor(); | 56 | void chooseBrushColor(); |
56 | 57 | ||
57 | void updateUndoRedoToolButtons(); | 58 | void updateUndoRedoToolButtons(); |
58 | void updateNavigationToolButtons(); | 59 | void updateNavigationToolButtons(); |
59 | void updateCaption(); | 60 | void updateCaption(); |
60 | 61 | ||
61 | void importPage(); | 62 | void importPage(); |
62 | void exportPage(); | 63 | void exportPage(); |
63 | 64 | ||
64 | private: | 65 | private: |
65 | DrawPadCanvas* m_pDrawPadCanvas; | 66 | DrawPadCanvas* m_pDrawPadCanvas; |
66 | 67 | ||
67 | Tool* m_pTool; | 68 | Tool* m_pTool; |
68 | QPen m_pen; | 69 | QPen m_pen; |
69 | QBrush m_brush; | 70 | QBrush m_brush; |
70 | 71 | ||
71 | QAction* m_pUndoAction; | 72 | QAction* m_pUndoAction; |
72 | QAction* m_pRedoAction; | 73 | QAction* m_pRedoAction; |
73 | 74 | ||
74 | QAction* m_pFirstPageAction; | 75 | QAction* m_pFirstPageAction; |
75 | QAction* m_pPreviousPageAction; | 76 | QAction* m_pPreviousPageAction; |
76 | QAction* m_pNextPageAction; | 77 | QAction* m_pNextPageAction; |
77 | QAction* m_pLastPageAction; | 78 | QAction* m_pLastPageAction; |
78 | 79 | ||
79 | QAction* m_pPointToolAction; | 80 | QAction* m_pPointToolAction; |
80 | QAction* m_pLineToolAction; | 81 | QAction* m_pLineToolAction; |
81 | QAction* m_pRectangleToolAction; | 82 | QAction* m_pRectangleToolAction; |
82 | QAction* m_pFilledRectangleToolAction; | 83 | QAction* m_pFilledRectangleToolAction; |
83 | QAction* m_pEllipseToolAction; | 84 | QAction* m_pEllipseToolAction; |
84 | QAction* m_pFilledEllipseToolAction; | 85 | QAction* m_pFilledEllipseToolAction; |
86 | QAction* m_pTextToolAction; | ||
85 | QAction* m_pFillToolAction; | 87 | QAction* m_pFillToolAction; |
86 | QAction* m_pEraseToolAction; | 88 | QAction* m_pEraseToolAction; |
87 | 89 | ||
90 | QToolButton* m_pLineToolButton; | ||
88 | QToolButton* m_pRectangleToolButton; | 91 | QToolButton* m_pRectangleToolButton; |
89 | QToolButton* m_pEllipseToolButton; | 92 | QToolButton* m_pEllipseToolButton; |
90 | QToolButton* m_pPenColorToolButton; | 93 | QToolButton* m_pPenColorToolButton; |
91 | QToolButton* m_pBrushColorToolButton; | 94 | QToolButton* m_pBrushColorToolButton; |
92 | }; | 95 | }; |
93 | 96 | ||
94 | #endif // DRAWPAD_H | 97 | #endif // DRAWPAD_H |
diff --git a/noncore/graphics/drawpad/drawpad.pro b/noncore/graphics/drawpad/drawpad.pro index fce0701..00eb00d 100644 --- a/noncore/graphics/drawpad/drawpad.pro +++ b/noncore/graphics/drawpad/drawpad.pro | |||
@@ -1,56 +1,58 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | HEADERS = colordialog.h \ | 3 | HEADERS = colordialog.h \ |
4 | colorpanel.h \ | 4 | colorpanel.h \ |
5 | drawpad.h \ | 5 | drawpad.h \ |
6 | drawpadcanvas.h \ | 6 | drawpadcanvas.h \ |
7 | ellipsetool.h \ | 7 | ellipsetool.h \ |
8 | erasetool.h \ | 8 | erasetool.h \ |
9 | exportdialog.h \ | 9 | exportdialog.h \ |
10 | filltool.h \ | 10 | filltool.h \ |
11 | filledellipsetool.h \ | 11 | filledellipsetool.h \ |
12 | filledrectangletool.h \ | 12 | filledrectangletool.h \ |
13 | importdialog.h \ | 13 | importdialog.h \ |
14 | linetool.h \ | 14 | linetool.h \ |
15 | newpagedialog.h \ | 15 | newpagedialog.h \ |
16 | pointtool.h \ | 16 | pointtool.h \ |
17 | rectangletool.h \ | 17 | rectangletool.h \ |
18 | shapetool.h \ | 18 | shapetool.h \ |
19 | texttool.h \ | ||
19 | tool.h | 20 | tool.h |
20 | SOURCES = colordialog.cpp \ | 21 | SOURCES = colordialog.cpp \ |
21 | colorpanel.cpp \ | 22 | colorpanel.cpp \ |
22 | drawpad.cpp \ | 23 | drawpad.cpp \ |
23 | drawpadcanvas.cpp \ | 24 | drawpadcanvas.cpp \ |
24 | ellipsetool.cpp \ | 25 | ellipsetool.cpp \ |
25 | erasetool.cpp \ | 26 | erasetool.cpp \ |
26 | exportdialog.cpp \ | 27 | exportdialog.cpp \ |
27 | filltool.cpp \ | 28 | filltool.cpp \ |
28 | filledellipsetool.cpp \ | 29 | filledellipsetool.cpp \ |
29 | filledrectangletool.cpp \ | 30 | filledrectangletool.cpp \ |
30 | importdialog.cpp \ | 31 | importdialog.cpp \ |
31 | linetool.cpp \ | 32 | linetool.cpp \ |
32 | main.cpp \ | 33 | main.cpp \ |
33 | newpagedialog.cpp \ | 34 | newpagedialog.cpp \ |
34 | pointtool.cpp \ | 35 | pointtool.cpp \ |
35 | rectangletool.cpp \ | 36 | rectangletool.cpp \ |
36 | shapetool.cpp \ | 37 | shapetool.cpp \ |
38 | texttool.cpp \ | ||
37 | tool.cpp | 39 | tool.cpp |
38 | INCLUDEPATH+= $(OPIEDIR)/include \ | 40 | INCLUDEPATH+= $(OPIEDIR)/include \ |
39 | $(QTDIR)/src/3rdparty/zlib | 41 | $(QTDIR)/src/3rdparty/zlib |
40 | DEPENDPATH+= $(OPIEDIR)/include | 42 | DEPENDPATH+= $(OPIEDIR)/include |
41 | LIBS += -lqpe | 43 | LIBS += -lqpe |
42 | DESTDIR = $(OPIEDIR)/bin | 44 | DESTDIR = $(OPIEDIR)/bin |
43 | TARGET = drawpad | 45 | TARGET = drawpad |
44 | 46 | ||
45 | TRANSLATIONS = ../../i18n/pt_BR/drawpad.ts | 47 | TRANSLATIONS = ../../i18n/pt_BR/drawpad.ts |
46 | TRANSLATIONS += ../../i18n/de/drawpad.ts | 48 | TRANSLATIONS += ../../i18n/de/drawpad.ts |
47 | TRANSLATIONS += ../../i18n/en/drawpad.ts | 49 | TRANSLATIONS += ../../i18n/en/drawpad.ts |
48 | TRANSLATIONS += ../../i18n/hu/drawpad.ts | 50 | TRANSLATIONS += ../../i18n/hu/drawpad.ts |
49 | TRANSLATIONS += ../../i18n/pl/drawpad.ts | 51 | TRANSLATIONS += ../../i18n/pl/drawpad.ts |
50 | TRANSLATIONS += ../../i18n/ja/drawpad.ts | 52 | TRANSLATIONS += ../../i18n/ja/drawpad.ts |
51 | TRANSLATIONS += ../../i18n/sl/drawpad.ts | 53 | TRANSLATIONS += ../../i18n/sl/drawpad.ts |
52 | TRANSLATIONS += ../../i18n/fr/drawpad.ts | 54 | TRANSLATIONS += ../../i18n/fr/drawpad.ts |
53 | TRANSLATIONS += ../../i18n/ko/drawpad.ts | 55 | TRANSLATIONS += ../../i18n/ko/drawpad.ts |
54 | TRANSLATIONS += ../../i18n/no/drawpad.ts | 56 | TRANSLATIONS += ../../i18n/no/drawpad.ts |
55 | TRANSLATIONS += ../../i18n/zh_CN/drawpad.ts | 57 | TRANSLATIONS += ../../i18n/zh_CN/drawpad.ts |
56 | TRANSLATIONS += ../../i18n/zh_TW/drawpad.ts | 58 | TRANSLATIONS += ../../i18n/zh_TW/drawpad.ts |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index db6288f..b39a633 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -283,96 +283,112 @@ void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,c | |||
283 | FileManager fileManager; | 283 | FileManager fileManager; |
284 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 284 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
285 | QImageIO imageIO(ioDevice, format); | 285 | QImageIO imageIO(ioDevice, format); |
286 | 286 | ||
287 | QImage image = m_pages.current()->convertToImage(); | 287 | QImage image = m_pages.current()->convertToImage(); |
288 | imageIO.setImage(image); | 288 | imageIO.setImage(image); |
289 | imageIO.write(); | 289 | imageIO.write(); |
290 | delete ioDevice; | 290 | delete ioDevice; |
291 | } else { | 291 | } else { |
292 | for (uint i = fromPage; i <= toPage; i++) { | 292 | for (uint i = fromPage; i <= toPage; i++) { |
293 | DocLnk docLnk; | 293 | DocLnk docLnk; |
294 | MimeType mimeType(format); | 294 | MimeType mimeType(format); |
295 | 295 | ||
296 | docLnk.setName(name + QString::number(i)); | 296 | docLnk.setName(name + QString::number(i)); |
297 | docLnk.setType(mimeType.id()); | 297 | docLnk.setType(mimeType.id()); |
298 | 298 | ||
299 | FileManager fileManager; | 299 | FileManager fileManager; |
300 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 300 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
301 | QImageIO imageIO(ioDevice, format); | 301 | QImageIO imageIO(ioDevice, format); |
302 | 302 | ||
303 | QImage image = m_pages.at(i - 1)->convertToImage(); | 303 | QImage image = m_pages.at(i - 1)->convertToImage(); |
304 | imageIO.setImage(image); | 304 | imageIO.setImage(image); |
305 | imageIO.write(); | 305 | imageIO.write(); |
306 | delete ioDevice; | 306 | delete ioDevice; |
307 | } | 307 | } |
308 | } | 308 | } |
309 | } | 309 | } |
310 | 310 | ||
311 | QPixmap* DrawPadCanvas::currentPage() | 311 | QPixmap* DrawPadCanvas::currentPage() |
312 | { | 312 | { |
313 | return m_pages.current(); | 313 | return m_pages.current(); |
314 | } | 314 | } |
315 | 315 | ||
316 | QList<QPixmap> DrawPadCanvas::pages() | 316 | QList<QPixmap> DrawPadCanvas::pages() |
317 | { | 317 | { |
318 | return m_pages; | 318 | return m_pages; |
319 | } | 319 | } |
320 | 320 | ||
321 | uint DrawPadCanvas::pagePosition() | 321 | uint DrawPadCanvas::pagePosition() |
322 | { | 322 | { |
323 | return (m_pages.at() + 1); | 323 | return (m_pages.at() + 1); |
324 | } | 324 | } |
325 | 325 | ||
326 | uint DrawPadCanvas::pageCount() | 326 | uint DrawPadCanvas::pageCount() |
327 | { | 327 | { |
328 | return m_pages.count(); | 328 | return m_pages.count(); |
329 | } | 329 | } |
330 | 330 | ||
331 | void DrawPadCanvas::backupPage() | ||
332 | { | ||
333 | QPixmap* currentBackup = m_pageBackups.current(); | ||
334 | while (m_pageBackups.last() != currentBackup) { | ||
335 | m_pageBackups.removeLast(); | ||
336 | } | ||
337 | |||
338 | while (m_pageBackups.count() >= (5 + 1)) { | ||
339 | m_pageBackups.removeFirst(); | ||
340 | } | ||
341 | |||
342 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | ||
343 | |||
344 | emit pageBackupsChanged(); | ||
345 | } | ||
346 | |||
331 | void DrawPadCanvas::deleteAll() | 347 | void DrawPadCanvas::deleteAll() |
332 | { | 348 | { |
333 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), | 349 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), |
334 | QMessageBox::Information, QMessageBox::Yes, | 350 | QMessageBox::Information, QMessageBox::Yes, |
335 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 351 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
336 | QMessageBox::NoButton, this); | 352 | QMessageBox::NoButton, this); |
337 | 353 | ||
338 | if (messageBox.exec() == QMessageBox::Yes) { | 354 | if (messageBox.exec() == QMessageBox::Yes) { |
339 | m_pages.clear(); | 355 | m_pages.clear(); |
340 | 356 | ||
341 | m_pages.append(new QPixmap(contentsRect().size())); | 357 | m_pages.append(new QPixmap(contentsRect().size())); |
342 | m_pages.current()->fill(Qt::white); | 358 | m_pages.current()->fill(Qt::white); |
343 | 359 | ||
344 | m_pageBackups.clear(); | 360 | m_pageBackups.clear(); |
345 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 361 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
346 | 362 | ||
347 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 363 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
348 | viewport()->update(); | 364 | viewport()->update(); |
349 | 365 | ||
350 | emit pagesChanged(); | 366 | emit pagesChanged(); |
351 | emit pageBackupsChanged(); | 367 | emit pageBackupsChanged(); |
352 | } | 368 | } |
353 | } | 369 | } |
354 | 370 | ||
355 | void DrawPadCanvas::newPage() | 371 | void DrawPadCanvas::newPage() |
356 | { | 372 | { |
357 | QRect rect = contentsRect(); | 373 | QRect rect = contentsRect(); |
358 | 374 | ||
359 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), | 375 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), |
360 | m_pDrawPad->brush().color(), this); | 376 | m_pDrawPad->brush().color(), this); |
361 | 377 | ||
362 | if (newPageDialog.exec() == QDialog::Accepted) { | 378 | if (newPageDialog.exec() == QDialog::Accepted) { |
363 | m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.selectedWidth(), | 379 | m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.selectedWidth(), |
364 | newPageDialog.selectedHeight())); | 380 | newPageDialog.selectedHeight())); |
365 | m_pages.current()->fill(newPageDialog.selectedColor()); | 381 | m_pages.current()->fill(newPageDialog.selectedColor()); |
366 | 382 | ||
367 | m_pageBackups.clear(); | 383 | m_pageBackups.clear(); |
368 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 384 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
369 | 385 | ||
370 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 386 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
371 | viewport()->update(); | 387 | viewport()->update(); |
372 | 388 | ||
373 | emit pagesChanged(); | 389 | emit pagesChanged(); |
374 | emit pageBackupsChanged(); | 390 | emit pageBackupsChanged(); |
375 | } | 391 | } |
376 | } | 392 | } |
377 | 393 | ||
378 | void DrawPadCanvas::clearPage() | 394 | void DrawPadCanvas::clearPage() |
@@ -468,74 +484,61 @@ void DrawPadCanvas::goFirstPage() | |||
468 | 484 | ||
469 | void DrawPadCanvas::goPreviousPage() | 485 | void DrawPadCanvas::goPreviousPage() |
470 | { | 486 | { |
471 | m_pages.prev(); | 487 | m_pages.prev(); |
472 | m_pageBackups.clear(); | 488 | m_pageBackups.clear(); |
473 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 489 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
474 | 490 | ||
475 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 491 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
476 | viewport()->update(); | 492 | viewport()->update(); |
477 | 493 | ||
478 | emit pagesChanged(); | 494 | emit pagesChanged(); |
479 | emit pageBackupsChanged(); | 495 | emit pageBackupsChanged(); |
480 | } | 496 | } |
481 | 497 | ||
482 | void DrawPadCanvas::goNextPage() | 498 | void DrawPadCanvas::goNextPage() |
483 | { | 499 | { |
484 | m_pages.next(); | 500 | m_pages.next(); |
485 | m_pageBackups.clear(); | 501 | m_pageBackups.clear(); |
486 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 502 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
487 | 503 | ||
488 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 504 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
489 | viewport()->update(); | 505 | viewport()->update(); |
490 | 506 | ||
491 | emit pagesChanged(); | 507 | emit pagesChanged(); |
492 | emit pageBackupsChanged(); | 508 | emit pageBackupsChanged(); |
493 | } | 509 | } |
494 | 510 | ||
495 | void DrawPadCanvas::goLastPage() | 511 | void DrawPadCanvas::goLastPage() |
496 | { | 512 | { |
497 | m_pages.last(); | 513 | m_pages.last(); |
498 | m_pageBackups.clear(); | 514 | m_pageBackups.clear(); |
499 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 515 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
500 | 516 | ||
501 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 517 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
502 | viewport()->update(); | 518 | viewport()->update(); |
503 | 519 | ||
504 | emit pagesChanged(); | 520 | emit pagesChanged(); |
505 | emit pageBackupsChanged(); | 521 | emit pageBackupsChanged(); |
506 | } | 522 | } |
507 | 523 | ||
508 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) | 524 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) |
509 | { | 525 | { |
510 | m_pDrawPad->tool()->mousePressEvent(e); | 526 | m_pDrawPad->tool()->mousePressEvent(e); |
511 | } | 527 | } |
512 | 528 | ||
513 | void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) | 529 | void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) |
514 | { | 530 | { |
515 | m_pDrawPad->tool()->mouseReleaseEvent(e); | 531 | m_pDrawPad->tool()->mouseReleaseEvent(e); |
516 | |||
517 | QPixmap* currentBackup = m_pageBackups.current(); | ||
518 | while (m_pageBackups.last() != currentBackup) { | ||
519 | m_pageBackups.removeLast(); | ||
520 | } | ||
521 | |||
522 | while (m_pageBackups.count() >= (5 + 1)) { | ||
523 | m_pageBackups.removeFirst(); | ||
524 | } | ||
525 | |||
526 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | ||
527 | |||
528 | emit pageBackupsChanged(); | ||
529 | } | 532 | } |
530 | 533 | ||
531 | void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) | 534 | void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) |
532 | { | 535 | { |
533 | m_pDrawPad->tool()->mouseMoveEvent(e); | 536 | m_pDrawPad->tool()->mouseMoveEvent(e); |
534 | } | 537 | } |
535 | 538 | ||
536 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 539 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
537 | { | 540 | { |
538 | QRect clipRect(cx, cy, cw, ch); | 541 | QRect clipRect(cx, cy, cw, ch); |
539 | 542 | ||
540 | p->drawPixmap(clipRect.topLeft(), *(m_pages.current()), clipRect); | 543 | p->drawPixmap(clipRect.topLeft(), *(m_pages.current()), clipRect); |
541 | } | 544 | } |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h index a1a9466..e05ce8a 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.h +++ b/noncore/graphics/drawpad/drawpadcanvas.h | |||
@@ -3,79 +3,81 @@ | |||
3 | * DrawPad - a drawing program for Opie Environment * | 3 | * DrawPad - a drawing program for Opie Environment * |
4 | * * | 4 | * * |
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | 5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * |
6 | * * | 6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | * * | 11 | * * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | 13 | ||
14 | #ifndef DRAWPADCANVAS_H | 14 | #ifndef DRAWPADCANVAS_H |
15 | #define DRAWPADCANVAS_H | 15 | #define DRAWPADCANVAS_H |
16 | 16 | ||
17 | #include <qscrollview.h> | 17 | #include <qscrollview.h> |
18 | 18 | ||
19 | #include <qlist.h> | 19 | #include <qlist.h> |
20 | #include <qpointarray.h> | 20 | #include <qpointarray.h> |
21 | 21 | ||
22 | class DrawPad; | 22 | class DrawPad; |
23 | 23 | ||
24 | class QPixmap; | 24 | class QPixmap; |
25 | 25 | ||
26 | class DrawPadCanvas : public QScrollView | 26 | class DrawPadCanvas : public QScrollView |
27 | { | 27 | { |
28 | Q_OBJECT | 28 | Q_OBJECT |
29 | 29 | ||
30 | public: | 30 | public: |
31 | DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0); | 31 | DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0); |
32 | ~DrawPadCanvas(); | 32 | ~DrawPadCanvas(); |
33 | 33 | ||
34 | void load(QIODevice* ioDevice); | 34 | void load(QIODevice* ioDevice); |
35 | void initialPage(); | 35 | void initialPage(); |
36 | void save(QIODevice* ioDevice); | 36 | void save(QIODevice* ioDevice); |
37 | 37 | ||
38 | void importPage(const QString& fileName); | 38 | void importPage(const QString& fileName); |
39 | void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format); | 39 | void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format); |
40 | 40 | ||
41 | bool undoEnabled(); | 41 | bool undoEnabled(); |
42 | bool redoEnabled(); | 42 | bool redoEnabled(); |
43 | bool goPreviousPageEnabled(); | 43 | bool goPreviousPageEnabled(); |
44 | bool goNextPageEnabled(); | 44 | bool goNextPageEnabled(); |
45 | 45 | ||
46 | QPixmap* currentPage(); | 46 | QPixmap* currentPage(); |
47 | QList<QPixmap> pages(); | 47 | QList<QPixmap> pages(); |
48 | uint pagePosition(); | 48 | uint pagePosition(); |
49 | uint pageCount(); | 49 | uint pageCount(); |
50 | 50 | ||
51 | void backupPage(); | ||
52 | |||
51 | public slots: | 53 | public slots: |
52 | void deleteAll(); | 54 | void deleteAll(); |
53 | void newPage(); | 55 | void newPage(); |
54 | void clearPage(); | 56 | void clearPage(); |
55 | void deletePage(); | 57 | void deletePage(); |
56 | 58 | ||
57 | void undo(); | 59 | void undo(); |
58 | void redo(); | 60 | void redo(); |
59 | 61 | ||
60 | void goFirstPage(); | 62 | void goFirstPage(); |
61 | void goPreviousPage(); | 63 | void goPreviousPage(); |
62 | void goNextPage(); | 64 | void goNextPage(); |
63 | void goLastPage(); | 65 | void goLastPage(); |
64 | 66 | ||
65 | signals: | 67 | signals: |
66 | void pagesChanged(); | 68 | void pagesChanged(); |
67 | void pageBackupsChanged(); | 69 | void pageBackupsChanged(); |
68 | 70 | ||
69 | protected: | 71 | protected: |
70 | void contentsMousePressEvent(QMouseEvent* e); | 72 | void contentsMousePressEvent(QMouseEvent* e); |
71 | void contentsMouseReleaseEvent(QMouseEvent* e); | 73 | void contentsMouseReleaseEvent(QMouseEvent* e); |
72 | void contentsMouseMoveEvent(QMouseEvent* e); | 74 | void contentsMouseMoveEvent(QMouseEvent* e); |
73 | void drawContents(QPainter* p, int cx, int cy, int cw, int ch); | 75 | void drawContents(QPainter* p, int cx, int cy, int cw, int ch); |
74 | 76 | ||
75 | private: | 77 | private: |
76 | DrawPad* m_pDrawPad; | 78 | DrawPad* m_pDrawPad; |
77 | QList<QPixmap> m_pages; | 79 | QList<QPixmap> m_pages; |
78 | QList<QPixmap> m_pageBackups; | 80 | QList<QPixmap> m_pageBackups; |
79 | }; | 81 | }; |
80 | 82 | ||
81 | #endif // DRAWPADCANVAS_H | 83 | #endif // DRAWPADCANVAS_H |
diff --git a/noncore/graphics/drawpad/erasetool.cpp b/noncore/graphics/drawpad/erasetool.cpp index d37c901..828994b 100644 --- a/noncore/graphics/drawpad/erasetool.cpp +++ b/noncore/graphics/drawpad/erasetool.cpp | |||
@@ -1,74 +1,76 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * DrawPad - a drawing program for Opie Environment * | 3 | * DrawPad - a drawing program for Opie Environment * |
4 | * * | 4 | * * |
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | 5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * |
6 | * * | 6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | * * | 11 | * * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | 13 | ||
14 | #include "erasetool.h" | 14 | #include "erasetool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | 18 | ||
19 | #include <qpainter.h> | 19 | #include <qpainter.h> |
20 | #include <qpixmap.h> | 20 | #include <qpixmap.h> |
21 | 21 | ||
22 | EraseTool::EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | EraseTool::EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : Tool(drawPad, drawPadCanvas) | 23 | : Tool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | m_mousePressed = false; | 25 | m_mousePressed = false; |
26 | m_polyline.resize(3); | 26 | m_polyline.resize(3); |
27 | } | 27 | } |
28 | 28 | ||
29 | EraseTool::~EraseTool() | 29 | EraseTool::~EraseTool() |
30 | { | 30 | { |
31 | } | 31 | } |
32 | 32 | ||
33 | void EraseTool::mousePressEvent(QMouseEvent* e) | 33 | void EraseTool::mousePressEvent(QMouseEvent* e) |
34 | { | 34 | { |
35 | m_mousePressed = true; | 35 | m_mousePressed = true; |
36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | 36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); |
37 | } | 37 | } |
38 | 38 | ||
39 | void EraseTool::mouseReleaseEvent(QMouseEvent* e) | 39 | void EraseTool::mouseReleaseEvent(QMouseEvent* e) |
40 | { | 40 | { |
41 | Q_UNUSED(e) | 41 | Q_UNUSED(e) |
42 | 42 | ||
43 | m_mousePressed = false; | 43 | m_mousePressed = false; |
44 | |||
45 | m_pDrawPadCanvas->backupPage(); | ||
44 | } | 46 | } |
45 | 47 | ||
46 | void EraseTool::mouseMoveEvent(QMouseEvent* e) | 48 | void EraseTool::mouseMoveEvent(QMouseEvent* e) |
47 | { | 49 | { |
48 | if (m_mousePressed) { | 50 | if (m_mousePressed) { |
49 | QPainter painter; | 51 | QPainter painter; |
50 | QPen pen(Qt::white, m_pDrawPad->pen().width()); | 52 | QPen pen(Qt::white, m_pDrawPad->pen().width()); |
51 | painter.begin(m_pDrawPadCanvas->currentPage()); | 53 | painter.begin(m_pDrawPadCanvas->currentPage()); |
52 | painter.setPen(pen); | 54 | painter.setPen(pen); |
53 | m_polyline[2] = m_polyline[1]; | 55 | m_polyline[2] = m_polyline[1]; |
54 | m_polyline[1] = m_polyline[0]; | 56 | m_polyline[1] = m_polyline[0]; |
55 | m_polyline[0] = e->pos(); | 57 | m_polyline[0] = e->pos(); |
56 | painter.drawPolyline(m_polyline); | 58 | painter.drawPolyline(m_polyline); |
57 | painter.end(); | 59 | painter.end(); |
58 | 60 | ||
59 | QRect r = m_polyline.boundingRect(); | 61 | QRect r = m_polyline.boundingRect(); |
60 | r = r.normalize(); | 62 | r = r.normalize(); |
61 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 63 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
62 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 64 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
63 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 65 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
64 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 66 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
65 | 67 | ||
66 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), | 68 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), |
67 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 69 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
68 | 70 | ||
69 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 71 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
70 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | 72 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); |
71 | 73 | ||
72 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 74 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
73 | } | 75 | } |
74 | } | 76 | } |
diff --git a/noncore/graphics/drawpad/filltool.cpp b/noncore/graphics/drawpad/filltool.cpp index 3297d21..004da02 100644 --- a/noncore/graphics/drawpad/filltool.cpp +++ b/noncore/graphics/drawpad/filltool.cpp | |||
@@ -1,88 +1,90 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * DrawPad - a drawing program for Opie Environment * | 3 | * DrawPad - a drawing program for Opie Environment * |
4 | * * | 4 | * * |
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | 5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * |
6 | * * | 6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | * * | 11 | * * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | 13 | ||
14 | #include "filltool.h" | 14 | #include "filltool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | 18 | ||
19 | #include <qimage.h> | 19 | #include <qimage.h> |
20 | #include <qpixmap.h> | 20 | #include <qpixmap.h> |
21 | 21 | ||
22 | FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : Tool(drawPad, drawPadCanvas) | 23 | : Tool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | } | 25 | } |
26 | 26 | ||
27 | FillTool::~FillTool() | 27 | FillTool::~FillTool() |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | void FillTool::mousePressEvent(QMouseEvent* e) | 31 | void FillTool::mousePressEvent(QMouseEvent* e) |
32 | { | 32 | { |
33 | int x = e->x(); | 33 | int x = e->x(); |
34 | int y = e->y(); | 34 | int y = e->y(); |
35 | 35 | ||
36 | m_image = m_pDrawPadCanvas->currentPage()->convertToImage(); | 36 | m_image = m_pDrawPadCanvas->currentPage()->convertToImage(); |
37 | m_fillRgb = m_pDrawPad->brush().color().rgb(); | 37 | m_fillRgb = m_pDrawPad->brush().color().rgb(); |
38 | m_oldRgb = m_image.pixel(x, y); | 38 | m_oldRgb = m_image.pixel(x, y); |
39 | 39 | ||
40 | if (m_oldRgb != m_fillRgb) { | 40 | if (m_oldRgb != m_fillRgb) { |
41 | fillLine(x, y); | 41 | fillLine(x, y); |
42 | 42 | ||
43 | m_pDrawPadCanvas->currentPage()->convertFromImage(m_image); | 43 | m_pDrawPadCanvas->currentPage()->convertFromImage(m_image); |
44 | m_pDrawPadCanvas->viewport()->update(); | 44 | m_pDrawPadCanvas->viewport()->update(); |
45 | |||
46 | m_pDrawPadCanvas->backupPage(); | ||
45 | } | 47 | } |
46 | } | 48 | } |
47 | 49 | ||
48 | void FillTool::mouseReleaseEvent(QMouseEvent* e) | 50 | void FillTool::mouseReleaseEvent(QMouseEvent* e) |
49 | { | 51 | { |
50 | Q_UNUSED(e) | 52 | Q_UNUSED(e) |
51 | } | 53 | } |
52 | 54 | ||
53 | void FillTool::mouseMoveEvent(QMouseEvent* e) | 55 | void FillTool::mouseMoveEvent(QMouseEvent* e) |
54 | { | 56 | { |
55 | Q_UNUSED(e) | 57 | Q_UNUSED(e) |
56 | } | 58 | } |
57 | 59 | ||
58 | void FillTool::fillLine(int x, int y) | 60 | void FillTool::fillLine(int x, int y) |
59 | { | 61 | { |
60 | if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) { | 62 | if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) { |
61 | if (m_image.pixel(x, y) == m_oldRgb) { | 63 | if (m_image.pixel(x, y) == m_oldRgb) { |
62 | int x1, x2; | 64 | int x1, x2; |
63 | 65 | ||
64 | x1 = x - 1; | 66 | x1 = x - 1; |
65 | x2 = x + 1; | 67 | x2 = x + 1; |
66 | 68 | ||
67 | while ((x1 >= 0) && (m_image.pixel(x1, y) == m_oldRgb)) { | 69 | while ((x1 >= 0) && (m_image.pixel(x1, y) == m_oldRgb)) { |
68 | x1--; | 70 | x1--; |
69 | } | 71 | } |
70 | 72 | ||
71 | while ((x2 < m_image.width()) && (m_image.pixel(x2, y) == m_oldRgb)) { | 73 | while ((x2 < m_image.width()) && (m_image.pixel(x2, y) == m_oldRgb)) { |
72 | x2++; | 74 | x2++; |
73 | } | 75 | } |
74 | 76 | ||
75 | for (int i = x1 + 1; i < x2; i++) { | 77 | for (int i = x1 + 1; i < x2; i++) { |
76 | m_image.setPixel(i, y, m_fillRgb); | 78 | m_image.setPixel(i, y, m_fillRgb); |
77 | } | 79 | } |
78 | 80 | ||
79 | for (int i = x1 + 1; i < x2; i++) { | 81 | for (int i = x1 + 1; i < x2; i++) { |
80 | fillLine(i, y - 1); | 82 | fillLine(i, y - 1); |
81 | } | 83 | } |
82 | 84 | ||
83 | for (int i = x1 + 1; i < x2; i++) { | 85 | for (int i = x1 + 1; i < x2; i++) { |
84 | fillLine(i, y + 1); | 86 | fillLine(i, y + 1); |
85 | } | 87 | } |
86 | } | 88 | } |
87 | } | 89 | } |
88 | } | 90 | } |
diff --git a/noncore/graphics/drawpad/pointtool.cpp b/noncore/graphics/drawpad/pointtool.cpp index 5661b03..e281284 100644 --- a/noncore/graphics/drawpad/pointtool.cpp +++ b/noncore/graphics/drawpad/pointtool.cpp | |||
@@ -1,73 +1,75 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * DrawPad - a drawing program for Opie Environment * | 3 | * DrawPad - a drawing program for Opie Environment * |
4 | * * | 4 | * * |
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | 5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * |
6 | * * | 6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | * * | 11 | * * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | 13 | ||
14 | #include "pointtool.h" | 14 | #include "pointtool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | 18 | ||
19 | #include <qpainter.h> | 19 | #include <qpainter.h> |
20 | #include <qpixmap.h> | 20 | #include <qpixmap.h> |
21 | 21 | ||
22 | PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : Tool(drawPad, drawPadCanvas) | 23 | : Tool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | m_mousePressed = false; | 25 | m_mousePressed = false; |
26 | m_polyline.resize(3); | 26 | m_polyline.resize(3); |
27 | } | 27 | } |
28 | 28 | ||
29 | PointTool::~PointTool() | 29 | PointTool::~PointTool() |
30 | { | 30 | { |
31 | } | 31 | } |
32 | 32 | ||
33 | void PointTool::mousePressEvent(QMouseEvent* e) | 33 | void PointTool::mousePressEvent(QMouseEvent* e) |
34 | { | 34 | { |
35 | m_mousePressed = true; | 35 | m_mousePressed = true; |
36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | 36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); |
37 | } | 37 | } |
38 | 38 | ||
39 | void PointTool::mouseReleaseEvent(QMouseEvent* e) | 39 | void PointTool::mouseReleaseEvent(QMouseEvent* e) |
40 | { | 40 | { |
41 | Q_UNUSED(e) | 41 | Q_UNUSED(e) |
42 | 42 | ||
43 | m_mousePressed = false; | 43 | m_mousePressed = false; |
44 | |||
45 | m_pDrawPadCanvas->backupPage(); | ||
44 | } | 46 | } |
45 | 47 | ||
46 | void PointTool::mouseMoveEvent(QMouseEvent* e) | 48 | void PointTool::mouseMoveEvent(QMouseEvent* e) |
47 | { | 49 | { |
48 | if (m_mousePressed) { | 50 | if (m_mousePressed) { |
49 | QPainter painter; | 51 | QPainter painter; |
50 | painter.begin(m_pDrawPadCanvas->currentPage()); | 52 | painter.begin(m_pDrawPadCanvas->currentPage()); |
51 | painter.setPen(m_pDrawPad->pen()); | 53 | painter.setPen(m_pDrawPad->pen()); |
52 | m_polyline[2] = m_polyline[1]; | 54 | m_polyline[2] = m_polyline[1]; |
53 | m_polyline[1] = m_polyline[0]; | 55 | m_polyline[1] = m_polyline[0]; |
54 | m_polyline[0] = e->pos(); | 56 | m_polyline[0] = e->pos(); |
55 | painter.drawPolyline(m_polyline); | 57 | painter.drawPolyline(m_polyline); |
56 | painter.end(); | 58 | painter.end(); |
57 | 59 | ||
58 | QRect r = m_polyline.boundingRect(); | 60 | QRect r = m_polyline.boundingRect(); |
59 | r = r.normalize(); | 61 | r = r.normalize(); |
60 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 62 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
61 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 63 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
62 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 64 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
63 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 65 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
64 | 66 | ||
65 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), | 67 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), |
66 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 68 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
67 | 69 | ||
68 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 70 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
69 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | 71 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); |
70 | 72 | ||
71 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 73 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
72 | } | 74 | } |
73 | } | 75 | } |
diff --git a/noncore/graphics/drawpad/shapetool.cpp b/noncore/graphics/drawpad/shapetool.cpp index 3c99370..bc5d9c0 100644 --- a/noncore/graphics/drawpad/shapetool.cpp +++ b/noncore/graphics/drawpad/shapetool.cpp | |||
@@ -16,77 +16,79 @@ | |||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | 18 | ||
19 | #include <qpainter.h> | 19 | #include <qpainter.h> |
20 | #include <qpixmap.h> | 20 | #include <qpixmap.h> |
21 | 21 | ||
22 | ShapeTool::ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | ShapeTool::ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : Tool(drawPad, drawPadCanvas) | 23 | : Tool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | m_mousePressed = false; | 25 | m_mousePressed = false; |
26 | m_polyline.resize(3); | 26 | m_polyline.resize(3); |
27 | } | 27 | } |
28 | 28 | ||
29 | ShapeTool::~ShapeTool() | 29 | ShapeTool::~ShapeTool() |
30 | { | 30 | { |
31 | } | 31 | } |
32 | 32 | ||
33 | void ShapeTool::mousePressEvent(QMouseEvent* e) | 33 | void ShapeTool::mousePressEvent(QMouseEvent* e) |
34 | { | 34 | { |
35 | m_mousePressed = true; | 35 | m_mousePressed = true; |
36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | 36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); |
37 | } | 37 | } |
38 | 38 | ||
39 | void ShapeTool::mouseReleaseEvent(QMouseEvent* e) | 39 | void ShapeTool::mouseReleaseEvent(QMouseEvent* e) |
40 | { | 40 | { |
41 | Q_UNUSED(e) | 41 | Q_UNUSED(e) |
42 | 42 | ||
43 | QPainter painter; | 43 | QPainter painter; |
44 | painter.begin(m_pDrawPadCanvas->currentPage()); | 44 | painter.begin(m_pDrawPadCanvas->currentPage()); |
45 | drawFinalShape(painter); | 45 | drawFinalShape(painter); |
46 | painter.end(); | 46 | painter.end(); |
47 | 47 | ||
48 | QRect r = m_polyline.boundingRect(); | 48 | QRect r = m_polyline.boundingRect(); |
49 | r = r.normalize(); | 49 | r = r.normalize(); |
50 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 50 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
51 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 51 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
52 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 52 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
53 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 53 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
54 | 54 | ||
55 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), | 55 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), |
56 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 56 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
57 | 57 | ||
58 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 58 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
59 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | 59 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); |
60 | 60 | ||
61 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 61 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
62 | 62 | ||
63 | m_mousePressed = false; | 63 | m_mousePressed = false; |
64 | |||
65 | m_pDrawPadCanvas->backupPage(); | ||
64 | } | 66 | } |
65 | 67 | ||
66 | void ShapeTool::mouseMoveEvent(QMouseEvent* e) | 68 | void ShapeTool::mouseMoveEvent(QMouseEvent* e) |
67 | { | 69 | { |
68 | if (m_mousePressed) { | 70 | if (m_mousePressed) { |
69 | m_polyline[0] = e->pos(); | 71 | m_polyline[0] = e->pos(); |
70 | QPainter painter; | 72 | QPainter painter; |
71 | painter.begin(m_pDrawPadCanvas->currentPage()); | 73 | painter.begin(m_pDrawPadCanvas->currentPage()); |
72 | drawTemporaryShape(painter); | 74 | drawTemporaryShape(painter); |
73 | painter.end(); | 75 | painter.end(); |
74 | 76 | ||
75 | QRect r = m_polyline.boundingRect(); | 77 | QRect r = m_polyline.boundingRect(); |
76 | r = r.normalize(); | 78 | r = r.normalize(); |
77 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 79 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
78 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 80 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
79 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 81 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
80 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 82 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
81 | 83 | ||
82 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), | 84 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), |
83 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 85 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
84 | 86 | ||
85 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 87 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
86 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | 88 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); |
87 | 89 | ||
88 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 90 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
89 | 91 | ||
90 | m_polyline[1] = m_polyline[0]; | 92 | m_polyline[1] = m_polyline[0]; |
91 | } | 93 | } |
92 | } | 94 | } |
diff --git a/noncore/graphics/drawpad/texttool.cpp b/noncore/graphics/drawpad/texttool.cpp new file mode 100644 index 0000000..37b4801 --- a/dev/null +++ b/noncore/graphics/drawpad/texttool.cpp | |||
@@ -0,0 +1,79 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * DrawPad - a drawing program for Opie Environment * | ||
4 | * * | ||
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | ||
6 | * * | ||
7 | * This program is free software; you can redistribute it and/or modify * | ||
8 | * it under the terms of the GNU General Public License as published by * | ||
9 | * the Free Software Foundation; either version 2 of the License, or * | ||
10 | * (at your option) any later version. * | ||
11 | * * | ||
12 | ***************************************************************************/ | ||
13 | |||
14 | #include "texttool.h" | ||
15 | |||
16 | #include "drawpad.h" | ||
17 | #include "drawpadcanvas.h" | ||
18 | |||
19 | #include <qlayout.h> | ||
20 | #include <qlineedit.h> | ||
21 | #include <qpainter.h> | ||
22 | #include <qpixmap.h> | ||
23 | |||
24 | TextToolDialog::TextToolDialog(QWidget* parent, const char* name) | ||
25 | : QDialog(parent, name, true) | ||
26 | { | ||
27 | setCaption(tr("Insert Text")); | ||
28 | |||
29 | m_pLineEdit = new QLineEdit(this); | ||
30 | |||
31 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | ||
32 | |||
33 | mainLayout->addWidget(m_pLineEdit); | ||
34 | } | ||
35 | |||
36 | TextToolDialog::~TextToolDialog() | ||
37 | { | ||
38 | } | ||
39 | |||
40 | QString TextToolDialog::text() | ||
41 | { | ||
42 | return m_pLineEdit->text(); | ||
43 | } | ||
44 | |||
45 | TextTool::TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | ||
46 | : Tool(drawPad, drawPadCanvas) | ||
47 | { | ||
48 | } | ||
49 | |||
50 | TextTool::~TextTool() | ||
51 | { | ||
52 | } | ||
53 | |||
54 | void TextTool::mousePressEvent(QMouseEvent* e) | ||
55 | { | ||
56 | TextToolDialog textToolDialog(m_pDrawPad); | ||
57 | |||
58 | if (textToolDialog.exec() == QDialog::Accepted && !textToolDialog.text().isEmpty()) { | ||
59 | QPainter painter; | ||
60 | painter.begin(m_pDrawPadCanvas->currentPage()); | ||
61 | painter.setPen(m_pDrawPad->pen()); | ||
62 | painter.drawText(e->x(), e->y(), textToolDialog.text()); | ||
63 | painter.end(); | ||
64 | |||
65 | m_pDrawPadCanvas->viewport()->update(); | ||
66 | |||
67 | m_pDrawPadCanvas->backupPage(); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | void TextTool::mouseReleaseEvent(QMouseEvent* e) | ||
72 | { | ||
73 | Q_UNUSED(e) | ||
74 | } | ||
75 | |||
76 | void TextTool::mouseMoveEvent(QMouseEvent* e) | ||
77 | { | ||
78 | Q_UNUSED(e) | ||
79 | } | ||
diff --git a/noncore/graphics/drawpad/texttool.h b/noncore/graphics/drawpad/texttool.h new file mode 100644 index 0000000..3187675 --- a/dev/null +++ b/noncore/graphics/drawpad/texttool.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * DrawPad - a drawing program for Opie Environment * | ||
4 | * * | ||
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | ||
6 | * * | ||
7 | * This program is free software; you can redistribute it and/or modify * | ||
8 | * it under the terms of the GNU General Public License as published by * | ||
9 | * the Free Software Foundation; either version 2 of the License, or * | ||
10 | * (at your option) any later version. * | ||
11 | * * | ||
12 | ***************************************************************************/ | ||
13 | |||
14 | #ifndef TEXTTOOL_H | ||
15 | #define TEXTTOOL_H | ||
16 | |||
17 | #include "tool.h" | ||
18 | |||
19 | #include <qdialog.h> | ||
20 | |||
21 | class QLineEdit; | ||
22 | |||
23 | class TextToolDialog : public QDialog | ||
24 | { | ||
25 | public: | ||
26 | TextToolDialog(QWidget* parent = 0, const char* name = 0); | ||
27 | ~TextToolDialog(); | ||
28 | |||
29 | QString text(); | ||
30 | |||
31 | private: | ||
32 | QLineEdit* m_pLineEdit; | ||
33 | }; | ||
34 | |||
35 | class TextTool : public Tool | ||
36 | { | ||
37 | public: | ||
38 | TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas); | ||
39 | ~TextTool(); | ||
40 | |||
41 | void mousePressEvent(QMouseEvent* e); | ||
42 | void mouseReleaseEvent(QMouseEvent* e); | ||
43 | void mouseMoveEvent(QMouseEvent* e); | ||
44 | }; | ||
45 | |||
46 | #endif // TEXTTOOL_H | ||
diff --git a/pics/drawpad/text.png b/pics/drawpad/text.png new file mode 100644 index 0000000..230d72b --- a/dev/null +++ b/pics/drawpad/text.png | |||
Binary files differ | |||