author | leseb <leseb> | 2002-06-23 17:47:47 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-23 17:47:47 (UTC) |
commit | 6fd46f6d23538ec6e0f48209f6c0f0d939a2effe (patch) (unidiff) | |
tree | 2a5d407155f72dc5496d3a7d412922cc6be97e61 | |
parent | 3251c55f854ecbd4ece8bf169177ffac28081aaa (diff) | |
download | opie-6fd46f6d23538ec6e0f48209f6c0f0d939a2effe.zip opie-6fd46f6d23538ec6e0f48209f6c0f0d939a2effe.tar.gz opie-6fd46f6d23538ec6e0f48209f6c0f0d939a2effe.tar.bz2 |
Anti-aliasing as an option
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 13 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 4 | ||||
-rw-r--r-- | noncore/graphics/drawpad/ellipsetool.cpp | 57 | ||||
-rw-r--r-- | noncore/graphics/drawpad/filledellipsetool.cpp | 60 | ||||
-rw-r--r-- | noncore/graphics/drawpad/linetool.cpp | 55 | ||||
-rw-r--r-- | noncore/graphics/drawpad/pointtool.cpp | 54 |
6 files changed, 140 insertions, 103 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index 45fb886..b29f5ba 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -1,610 +1,621 @@ | |||
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 "drawpadcanvas.h" | 16 | #include "drawpadcanvas.h" |
17 | #include "ellipsetool.h" | 17 | #include "ellipsetool.h" |
18 | #include "erasetool.h" | 18 | #include "erasetool.h" |
19 | #include "exportdialog.h" | 19 | #include "exportdialog.h" |
20 | #include "filledellipsetool.h" | 20 | #include "filledellipsetool.h" |
21 | #include "filledrectangletool.h" | 21 | #include "filledrectangletool.h" |
22 | #include "filltool.h" | 22 | #include "filltool.h" |
23 | #include "importdialog.h" | 23 | #include "importdialog.h" |
24 | #include "linetool.h" | 24 | #include "linetool.h" |
25 | #include "newpagedialog.h" | 25 | #include "newpagedialog.h" |
26 | #include "page.h" | 26 | #include "page.h" |
27 | #include "pageinformationdialog.h" | 27 | #include "pageinformationdialog.h" |
28 | #include "pointtool.h" | 28 | #include "pointtool.h" |
29 | #include "rectangletool.h" | 29 | #include "rectangletool.h" |
30 | #include "texttool.h" | 30 | #include "texttool.h" |
31 | #include "thumbnailview.h" | 31 | #include "thumbnailview.h" |
32 | 32 | ||
33 | #include <opie/colordialog.h> | 33 | #include <opie/colordialog.h> |
34 | #include <opie/colorpopupmenu.h> | 34 | #include <opie/colorpopupmenu.h> |
35 | 35 | ||
36 | #include <qpe/applnk.h> | 36 | #include <qpe/applnk.h> |
37 | #include <qpe/global.h> | 37 | #include <qpe/global.h> |
38 | #include <qpe/qpemenubar.h> | 38 | #include <qpe/qpemenubar.h> |
39 | #include <qpe/qpetoolbar.h> | 39 | #include <qpe/qpetoolbar.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | 41 | ||
42 | #include <qaction.h> | 42 | #include <qaction.h> |
43 | #include <qfile.h> | 43 | #include <qfile.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qpainter.h> | 45 | #include <qpainter.h> |
46 | #include <qspinbox.h> | 46 | #include <qspinbox.h> |
47 | #include <qtoolbutton.h> | 47 | #include <qtoolbutton.h> |
48 | #include <qtooltip.h> | 48 | #include <qtooltip.h> |
49 | 49 | ||
50 | DrawPad::DrawPad(QWidget* parent, const char* name) | 50 | DrawPad::DrawPad(QWidget* parent, const char* name) |
51 | : QMainWindow(parent, name) | 51 | : QMainWindow(parent, name) |
52 | { | 52 | { |
53 | // init members | 53 | // init members |
54 | 54 | ||
55 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); | 55 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); |
56 | 56 | ||
57 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); | 57 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); |
58 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); | 58 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); |
59 | connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); | 59 | connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); |
60 | 60 | ||
61 | setCentralWidget(m_pDrawPadCanvas); | 61 | setCentralWidget(m_pDrawPadCanvas); |
62 | 62 | ||
63 | // init menu | 63 | // init menu |
64 | 64 | ||
65 | setToolBarsMovable(false); | 65 | setToolBarsMovable(false); |
66 | 66 | ||
67 | QPEToolBar* menuToolBar = new QPEToolBar(this); | 67 | QPEToolBar* menuToolBar = new QPEToolBar(this); |
68 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); | 68 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); |
69 | 69 | ||
70 | QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar); | 70 | QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); |
71 | 71 | ||
72 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); | 72 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); |
73 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); | 73 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); |
74 | deleteAllAction->addTo(toolsPopupMenu); | 74 | deleteAllAction->addTo(toolsPopupMenu); |
75 | 75 | ||
76 | toolsPopupMenu->insertSeparator(); | 76 | toolsPopupMenu->insertSeparator(); |
77 | 77 | ||
78 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); | 78 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); |
79 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); | 79 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); |
80 | importPageAction->addTo(toolsPopupMenu); | 80 | importPageAction->addTo(toolsPopupMenu); |
81 | 81 | ||
82 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); | 82 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); |
83 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); | 83 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); |
84 | exportPageAction->addTo(toolsPopupMenu); | 84 | exportPageAction->addTo(toolsPopupMenu); |
85 | 85 | ||
86 | toolsPopupMenu->insertSeparator(); | 86 | toolsPopupMenu->insertSeparator(); |
87 | 87 | ||
88 | QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); | 88 | QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); |
89 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); | 89 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); |
90 | thumbnailViewAction->addTo(toolsPopupMenu); | 90 | thumbnailViewAction->addTo(toolsPopupMenu); |
91 | 91 | ||
92 | QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); | 92 | QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); |
93 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); | 93 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); |
94 | pageInformationAction->addTo(toolsPopupMenu); | 94 | pageInformationAction->addTo(toolsPopupMenu); |
95 | 95 | ||
96 | toolsPopupMenu->insertSeparator(); | ||
97 | |||
98 | m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); | ||
99 | m_pAntiAliasingAction->setToggleAction(true); | ||
100 | m_pAntiAliasingAction->addTo(toolsPopupMenu); | ||
101 | |||
96 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); | 102 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); |
97 | 103 | ||
98 | // init page toolbar | 104 | // init page toolbar |
99 | 105 | ||
100 | QPEToolBar* pageToolBar = new QPEToolBar(this); | 106 | QPEToolBar* pageToolBar = new QPEToolBar(this); |
101 | 107 | ||
102 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); | 108 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); |
103 | connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); | 109 | connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); |
104 | newPageAction->addTo(pageToolBar); | 110 | newPageAction->addTo(pageToolBar); |
105 | 111 | ||
106 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); | 112 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); |
107 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); | 113 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); |
108 | clearPageAction->addTo(pageToolBar); | 114 | clearPageAction->addTo(pageToolBar); |
109 | 115 | ||
110 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); | 116 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); |
111 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); | 117 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); |
112 | deletePageAction->addTo(pageToolBar); | 118 | deletePageAction->addTo(pageToolBar); |
113 | 119 | ||
114 | QPEToolBar* emptyToolBar = new QPEToolBar(this); | 120 | QPEToolBar* emptyToolBar = new QPEToolBar(this); |
115 | emptyToolBar->setHorizontalStretchable(true); | 121 | emptyToolBar->setHorizontalStretchable(true); |
116 | 122 | ||
117 | // init navigation toolbar | 123 | // init navigation toolbar |
118 | 124 | ||
119 | QPEToolBar* navigationToolBar = new QPEToolBar(this); | 125 | QPEToolBar* navigationToolBar = new QPEToolBar(this); |
120 | 126 | ||
121 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); | 127 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); |
122 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); | 128 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); |
123 | m_pUndoAction->addTo(navigationToolBar); | 129 | m_pUndoAction->addTo(navigationToolBar); |
124 | 130 | ||
125 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); | 131 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); |
126 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); | 132 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); |
127 | m_pRedoAction->addTo(navigationToolBar); | 133 | m_pRedoAction->addTo(navigationToolBar); |
128 | 134 | ||
129 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); | 135 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); |
130 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); | 136 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); |
131 | m_pFirstPageAction->addTo(navigationToolBar); | 137 | m_pFirstPageAction->addTo(navigationToolBar); |
132 | 138 | ||
133 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); | 139 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); |
134 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); | 140 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); |
135 | m_pPreviousPageAction->addTo(navigationToolBar); | 141 | m_pPreviousPageAction->addTo(navigationToolBar); |
136 | 142 | ||
137 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); | 143 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); |
138 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); | 144 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); |
139 | m_pNextPageAction->addTo(navigationToolBar); | 145 | m_pNextPageAction->addTo(navigationToolBar); |
140 | 146 | ||
141 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); | 147 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); |
142 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); | 148 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); |
143 | m_pLastPageAction->addTo(navigationToolBar); | 149 | m_pLastPageAction->addTo(navigationToolBar); |
144 | 150 | ||
145 | // init draw mode toolbar | 151 | // init draw mode toolbar |
146 | 152 | ||
147 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); | 153 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); |
148 | 154 | ||
149 | m_pLineToolButton = new QToolButton(drawModeToolBar); | 155 | m_pLineToolButton = new QToolButton(drawModeToolBar); |
150 | m_pLineToolButton->setToggleButton(true); | 156 | m_pLineToolButton->setToggleButton(true); |
151 | 157 | ||
152 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); | 158 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); |
153 | 159 | ||
154 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), "", 0, this); | 160 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), "", 0, this); |
155 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); | 161 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); |
156 | m_pPointToolAction->addTo(linePopupMenu); | 162 | m_pPointToolAction->addTo(linePopupMenu); |
157 | 163 | ||
158 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), "", 0, this); | 164 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), "", 0, this); |
159 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); | 165 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); |
160 | m_pLineToolAction->addTo(linePopupMenu); | 166 | m_pLineToolAction->addTo(linePopupMenu); |
161 | 167 | ||
162 | m_pLineToolButton->setPopup(linePopupMenu); | 168 | m_pLineToolButton->setPopup(linePopupMenu); |
163 | m_pLineToolButton->setPopupDelay(0); | 169 | m_pLineToolButton->setPopupDelay(0); |
164 | 170 | ||
165 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); | 171 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); |
166 | m_pRectangleToolButton->setToggleButton(true); | 172 | m_pRectangleToolButton->setToggleButton(true); |
167 | 173 | ||
168 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); | 174 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); |
169 | 175 | ||
170 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this); | 176 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this); |
171 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); | 177 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); |
172 | m_pRectangleToolAction->addTo(rectanglePopupMenu); | 178 | m_pRectangleToolAction->addTo(rectanglePopupMenu); |
173 | 179 | ||
174 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this); | 180 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this); |
175 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); | 181 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); |
176 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); | 182 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); |
177 | 183 | ||
178 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); | 184 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); |
179 | m_pRectangleToolButton->setPopupDelay(0); | 185 | m_pRectangleToolButton->setPopupDelay(0); |
180 | 186 | ||
181 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); | 187 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); |
182 | m_pEllipseToolButton->setToggleButton(true); | 188 | m_pEllipseToolButton->setToggleButton(true); |
183 | 189 | ||
184 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); | 190 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); |
185 | 191 | ||
186 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this); | 192 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this); |
187 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); | 193 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); |
188 | m_pEllipseToolAction->addTo(ellipsePopupMenu); | 194 | m_pEllipseToolAction->addTo(ellipsePopupMenu); |
189 | 195 | ||
190 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this); | 196 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this); |
191 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); | 197 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); |
192 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); | 198 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); |
193 | 199 | ||
194 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); | 200 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); |
195 | m_pEllipseToolButton->setPopupDelay(0); | 201 | m_pEllipseToolButton->setPopupDelay(0); |
196 | 202 | ||
197 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadIconSet("drawpad/text.png"), QString::null, 0, this); | 203 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadIconSet("drawpad/text.png"), QString::null, 0, this); |
198 | m_pTextToolAction->setToggleAction(true); | 204 | m_pTextToolAction->setToggleAction(true); |
199 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); | 205 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); |
200 | m_pTextToolAction->addTo(drawModeToolBar); | 206 | m_pTextToolAction->addTo(drawModeToolBar); |
201 | 207 | ||
202 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); | 208 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); |
203 | m_pFillToolAction->setToggleAction(true); | 209 | m_pFillToolAction->setToggleAction(true); |
204 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); | 210 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); |
205 | m_pFillToolAction->addTo(drawModeToolBar); | 211 | m_pFillToolAction->addTo(drawModeToolBar); |
206 | 212 | ||
207 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); | 213 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); |
208 | m_pEraseToolAction->setToggleAction(true); | 214 | m_pEraseToolAction->setToggleAction(true); |
209 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); | 215 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); |
210 | m_pEraseToolAction->addTo(drawModeToolBar); | 216 | m_pEraseToolAction->addTo(drawModeToolBar); |
211 | 217 | ||
212 | m_pTool = 0; | 218 | m_pTool = 0; |
213 | setRectangleTool(); | 219 | setRectangleTool(); |
214 | setEllipseTool(); | 220 | setEllipseTool(); |
215 | setPointTool(); | 221 | setPointTool(); |
216 | 222 | ||
217 | emptyToolBar = new QPEToolBar(this); | 223 | emptyToolBar = new QPEToolBar(this); |
218 | emptyToolBar->setHorizontalStretchable(true); | 224 | emptyToolBar->setHorizontalStretchable(true); |
219 | emptyToolBar->addSeparator(); | 225 | emptyToolBar->addSeparator(); |
220 | 226 | ||
221 | // init draw parameters toolbar | 227 | // init draw parameters toolbar |
222 | 228 | ||
223 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); | 229 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); |
224 | 230 | ||
225 | QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); | 231 | QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); |
226 | connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); | 232 | connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); |
227 | 233 | ||
228 | QToolTip::add(penWidthSpinBox, tr("Pen Width")); | 234 | QToolTip::add(penWidthSpinBox, tr("Pen Width")); |
229 | penWidthSpinBox->setValue(1); | 235 | penWidthSpinBox->setValue(1); |
230 | penWidthSpinBox->setFocusPolicy(QWidget::NoFocus); | 236 | penWidthSpinBox->setFocusPolicy(QWidget::NoFocus); |
231 | 237 | ||
232 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); | 238 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); |
233 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); | 239 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); |
234 | 240 | ||
235 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, m_pPenColorToolButton); | 241 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, m_pPenColorToolButton); |
236 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); | 242 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); |
237 | 243 | ||
238 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); | 244 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); |
239 | m_pPenColorToolButton->setPopup(penColorPopupMenu); | 245 | m_pPenColorToolButton->setPopup(penColorPopupMenu); |
240 | m_pPenColorToolButton->setPopupDelay(0); | 246 | m_pPenColorToolButton->setPopupDelay(0); |
241 | 247 | ||
242 | changePenColor(Qt::black); | 248 | changePenColor(Qt::black); |
243 | 249 | ||
244 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); | 250 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); |
245 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png")); | 251 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png")); |
246 | 252 | ||
247 | ColorPopupMenu* brushColorPopupMenu = new ColorPopupMenu(Qt::white, m_pBrushColorToolButton); | 253 | ColorPopupMenu* brushColorPopupMenu = new ColorPopupMenu(Qt::white, m_pBrushColorToolButton); |
248 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); | 254 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); |
249 | 255 | ||
250 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); | 256 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); |
251 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); | 257 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); |
252 | m_pBrushColorToolButton->setPopupDelay(0); | 258 | m_pBrushColorToolButton->setPopupDelay(0); |
253 | 259 | ||
254 | changeBrushColor(Qt::white); | 260 | changeBrushColor(Qt::white); |
255 | 261 | ||
256 | // init pages | 262 | // init pages |
257 | 263 | ||
258 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 264 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
259 | 265 | ||
260 | if (file.open(IO_ReadOnly)) { | 266 | if (file.open(IO_ReadOnly)) { |
261 | m_pDrawPadCanvas->load(&file); | 267 | m_pDrawPadCanvas->load(&file); |
262 | file.close(); | 268 | file.close(); |
263 | } else { | 269 | } else { |
264 | m_pDrawPadCanvas->initialPage(); | 270 | m_pDrawPadCanvas->initialPage(); |
265 | } | 271 | } |
266 | } | 272 | } |
267 | 273 | ||
268 | DrawPad::~DrawPad() | 274 | DrawPad::~DrawPad() |
269 | { | 275 | { |
270 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 276 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
271 | 277 | ||
272 | if (file.open(IO_WriteOnly)) { | 278 | if (file.open(IO_WriteOnly)) { |
273 | m_pDrawPadCanvas->save(&file); | 279 | m_pDrawPadCanvas->save(&file); |
274 | file.close(); | 280 | file.close(); |
275 | } | 281 | } |
276 | } | 282 | } |
277 | 283 | ||
284 | bool DrawPad::antiAliasing() | ||
285 | { | ||
286 | return (m_pAntiAliasingAction->isOn()); | ||
287 | } | ||
288 | |||
278 | void DrawPad::newPage() | 289 | void DrawPad::newPage() |
279 | { | 290 | { |
280 | QRect rect = m_pDrawPadCanvas->contentsRect(); | 291 | QRect rect = m_pDrawPadCanvas->contentsRect(); |
281 | 292 | ||
282 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); | 293 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); |
283 | 294 | ||
284 | if (newPageDialog.exec() == QDialog::Accepted) { | 295 | if (newPageDialog.exec() == QDialog::Accepted) { |
285 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), | 296 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), |
286 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); | 297 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); |
287 | } | 298 | } |
288 | } | 299 | } |
289 | 300 | ||
290 | void DrawPad::clearPage() | 301 | void DrawPad::clearPage() |
291 | { | 302 | { |
292 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), | 303 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), |
293 | QMessageBox::Information, QMessageBox::Yes, | 304 | QMessageBox::Information, QMessageBox::Yes, |
294 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 305 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
295 | QMessageBox::NoButton, this); | 306 | QMessageBox::NoButton, this); |
296 | 307 | ||
297 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 308 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
298 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 309 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
299 | 310 | ||
300 | if (messageBox.exec() == QMessageBox::Yes) { | 311 | if (messageBox.exec() == QMessageBox::Yes) { |
301 | m_pDrawPadCanvas->clearPage(); | 312 | m_pDrawPadCanvas->clearPage(); |
302 | } | 313 | } |
303 | } | 314 | } |
304 | 315 | ||
305 | void DrawPad::deletePage() | 316 | void DrawPad::deletePage() |
306 | { | 317 | { |
307 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), | 318 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), |
308 | QMessageBox::Information, QMessageBox::Yes, | 319 | QMessageBox::Information, QMessageBox::Yes, |
309 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 320 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
310 | QMessageBox::NoButton, this); | 321 | QMessageBox::NoButton, this); |
311 | 322 | ||
312 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 323 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
313 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 324 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
314 | 325 | ||
315 | if (messageBox.exec() == QMessageBox::Yes) { | 326 | if (messageBox.exec() == QMessageBox::Yes) { |
316 | m_pDrawPadCanvas->deletePage(); | 327 | m_pDrawPadCanvas->deletePage(); |
317 | } | 328 | } |
318 | } | 329 | } |
319 | 330 | ||
320 | void DrawPad::setPointTool() | 331 | void DrawPad::setPointTool() |
321 | { | 332 | { |
322 | if (m_pTool) { | 333 | if (m_pTool) { |
323 | delete m_pTool; | 334 | delete m_pTool; |
324 | } | 335 | } |
325 | 336 | ||
326 | m_pTool = new PointTool(this, m_pDrawPadCanvas); | 337 | m_pTool = new PointTool(this, m_pDrawPadCanvas); |
327 | 338 | ||
328 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); | 339 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); |
329 | QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); | 340 | QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); |
330 | 341 | ||
331 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | 342 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); |
332 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); | 343 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); |
333 | 344 | ||
334 | m_pLineToolButton->setOn(true); | 345 | m_pLineToolButton->setOn(true); |
335 | m_pRectangleToolButton->setOn(false); | 346 | m_pRectangleToolButton->setOn(false); |
336 | m_pEllipseToolButton->setOn(false); | 347 | m_pEllipseToolButton->setOn(false); |
337 | m_pTextToolAction->setOn(false); | 348 | m_pTextToolAction->setOn(false); |
338 | m_pFillToolAction->setOn(false); | 349 | m_pFillToolAction->setOn(false); |
339 | m_pEraseToolAction->setOn(false); | 350 | m_pEraseToolAction->setOn(false); |
340 | } | 351 | } |
341 | 352 | ||
342 | void DrawPad::setLineTool() | 353 | void DrawPad::setLineTool() |
343 | { | 354 | { |
344 | if (m_pTool) { | 355 | if (m_pTool) { |
345 | delete m_pTool; | 356 | delete m_pTool; |
346 | } | 357 | } |
347 | 358 | ||
348 | m_pTool = new LineTool(this, m_pDrawPadCanvas); | 359 | m_pTool = new LineTool(this, m_pDrawPadCanvas); |
349 | 360 | ||
350 | m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); | 361 | m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); |
351 | QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); | 362 | QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); |
352 | 363 | ||
353 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | 364 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); |
354 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); | 365 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); |
355 | 366 | ||
356 | m_pLineToolButton->setOn(true); | 367 | m_pLineToolButton->setOn(true); |
357 | m_pRectangleToolButton->setOn(false); | 368 | m_pRectangleToolButton->setOn(false); |
358 | m_pEllipseToolButton->setOn(false); | 369 | m_pEllipseToolButton->setOn(false); |
359 | m_pTextToolAction->setOn(false); | 370 | m_pTextToolAction->setOn(false); |
360 | m_pFillToolAction->setOn(false); | 371 | m_pFillToolAction->setOn(false); |
361 | m_pEraseToolAction->setOn(false); | 372 | m_pEraseToolAction->setOn(false); |
362 | } | 373 | } |
363 | 374 | ||
364 | void DrawPad::setRectangleTool() | 375 | void DrawPad::setRectangleTool() |
365 | { | 376 | { |
366 | if (m_pTool) { | 377 | if (m_pTool) { |
367 | delete m_pTool; | 378 | delete m_pTool; |
368 | } | 379 | } |
369 | 380 | ||
370 | m_pTool = new RectangleTool(this, m_pDrawPadCanvas); | 381 | m_pTool = new RectangleTool(this, m_pDrawPadCanvas); |
371 | 382 | ||
372 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); | 383 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); |
373 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); | 384 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); |
374 | 385 | ||
375 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 386 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
376 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); | 387 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); |
377 | 388 | ||
378 | m_pLineToolButton->setOn(false); | 389 | m_pLineToolButton->setOn(false); |
379 | m_pRectangleToolButton->setOn(true); | 390 | m_pRectangleToolButton->setOn(true); |
380 | m_pEllipseToolButton->setOn(false); | 391 | m_pEllipseToolButton->setOn(false); |
381 | m_pTextToolAction->setOn(false); | 392 | m_pTextToolAction->setOn(false); |
382 | m_pFillToolAction->setOn(false); | 393 | m_pFillToolAction->setOn(false); |
383 | m_pEraseToolAction->setOn(false); | 394 | m_pEraseToolAction->setOn(false); |
384 | } | 395 | } |
385 | 396 | ||
386 | void DrawPad::setFilledRectangleTool() | 397 | void DrawPad::setFilledRectangleTool() |
387 | { | 398 | { |
388 | if (m_pTool) { | 399 | if (m_pTool) { |
389 | delete m_pTool; | 400 | delete m_pTool; |
390 | } | 401 | } |
391 | 402 | ||
392 | m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); | 403 | m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); |
393 | 404 | ||
394 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); | 405 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); |
395 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); | 406 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); |
396 | 407 | ||
397 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 408 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
398 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); | 409 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); |
399 | 410 | ||
400 | m_pLineToolButton->setOn(false); | 411 | m_pLineToolButton->setOn(false); |
401 | m_pRectangleToolButton->setOn(true); | 412 | m_pRectangleToolButton->setOn(true); |
402 | m_pEllipseToolButton->setOn(false); | 413 | m_pEllipseToolButton->setOn(false); |
403 | m_pTextToolAction->setOn(false); | 414 | m_pTextToolAction->setOn(false); |
404 | m_pFillToolAction->setOn(false); | 415 | m_pFillToolAction->setOn(false); |
405 | m_pEraseToolAction->setOn(false); | 416 | m_pEraseToolAction->setOn(false); |
406 | } | 417 | } |
407 | 418 | ||
408 | void DrawPad::setEllipseTool() | 419 | void DrawPad::setEllipseTool() |
409 | { | 420 | { |
410 | if (m_pTool) { | 421 | if (m_pTool) { |
411 | delete m_pTool; | 422 | delete m_pTool; |
412 | } | 423 | } |
413 | 424 | ||
414 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); | 425 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); |
415 | 426 | ||
416 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); | 427 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); |
417 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); | 428 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); |
418 | 429 | ||
419 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 430 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
420 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); | 431 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); |
421 | 432 | ||
422 | m_pLineToolButton->setOn(false); | 433 | m_pLineToolButton->setOn(false); |
423 | m_pRectangleToolButton->setOn(false); | 434 | m_pRectangleToolButton->setOn(false); |
424 | m_pEllipseToolButton->setOn(true); | 435 | m_pEllipseToolButton->setOn(true); |
425 | m_pTextToolAction->setOn(false); | 436 | m_pTextToolAction->setOn(false); |
426 | m_pFillToolAction->setOn(false); | 437 | m_pFillToolAction->setOn(false); |
427 | m_pEraseToolAction->setOn(false); | 438 | m_pEraseToolAction->setOn(false); |
428 | } | 439 | } |
429 | 440 | ||
430 | void DrawPad::setFilledEllipseTool() | 441 | void DrawPad::setFilledEllipseTool() |
431 | { | 442 | { |
432 | if (m_pTool) { | 443 | if (m_pTool) { |
433 | delete m_pTool; | 444 | delete m_pTool; |
434 | } | 445 | } |
435 | 446 | ||
436 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); | 447 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); |
437 | 448 | ||
438 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); | 449 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); |
439 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); | 450 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); |
440 | 451 | ||
441 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 452 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
442 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); | 453 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); |
443 | 454 | ||
444 | m_pLineToolButton->setOn(false); | 455 | m_pLineToolButton->setOn(false); |
445 | m_pRectangleToolButton->setOn(false); | 456 | m_pRectangleToolButton->setOn(false); |
446 | m_pEllipseToolButton->setOn(true); | 457 | m_pEllipseToolButton->setOn(true); |
447 | m_pTextToolAction->setOn(false); | 458 | m_pTextToolAction->setOn(false); |
448 | m_pFillToolAction->setOn(false); | 459 | m_pFillToolAction->setOn(false); |
449 | m_pEraseToolAction->setOn(false); | 460 | m_pEraseToolAction->setOn(false); |
450 | } | 461 | } |
451 | 462 | ||
452 | void DrawPad::setTextTool() | 463 | void DrawPad::setTextTool() |
453 | { | 464 | { |
454 | if (m_pTool) { | 465 | if (m_pTool) { |
455 | delete m_pTool; | 466 | delete m_pTool; |
456 | } | 467 | } |
457 | 468 | ||
458 | m_pTool = new TextTool(this, m_pDrawPadCanvas); | 469 | m_pTool = new TextTool(this, m_pDrawPadCanvas); |
459 | 470 | ||
460 | m_pLineToolButton->setOn(false); | 471 | m_pLineToolButton->setOn(false); |
461 | m_pRectangleToolButton->setOn(false); | 472 | m_pRectangleToolButton->setOn(false); |
462 | m_pEllipseToolButton->setOn(false); | 473 | m_pEllipseToolButton->setOn(false); |
463 | m_pTextToolAction->setOn(true); | 474 | m_pTextToolAction->setOn(true); |
464 | m_pFillToolAction->setOn(false); | 475 | m_pFillToolAction->setOn(false); |
465 | m_pEraseToolAction->setOn(false); | 476 | m_pEraseToolAction->setOn(false); |
466 | } | 477 | } |
467 | 478 | ||
468 | void DrawPad::setFillTool() | 479 | void DrawPad::setFillTool() |
469 | { | 480 | { |
470 | if (m_pTool) { | 481 | if (m_pTool) { |
471 | delete m_pTool; | 482 | delete m_pTool; |
472 | } | 483 | } |
473 | 484 | ||
474 | m_pTool = new FillTool(this, m_pDrawPadCanvas); | 485 | m_pTool = new FillTool(this, m_pDrawPadCanvas); |
475 | 486 | ||
476 | m_pLineToolButton->setOn(false); | 487 | m_pLineToolButton->setOn(false); |
477 | m_pRectangleToolButton->setOn(false); | 488 | m_pRectangleToolButton->setOn(false); |
478 | m_pEllipseToolButton->setOn(false); | 489 | m_pEllipseToolButton->setOn(false); |
479 | m_pTextToolAction->setOn(false); | 490 | m_pTextToolAction->setOn(false); |
480 | m_pFillToolAction->setOn(true); | 491 | m_pFillToolAction->setOn(true); |
481 | m_pEraseToolAction->setOn(false); | 492 | m_pEraseToolAction->setOn(false); |
482 | } | 493 | } |
483 | 494 | ||
484 | void DrawPad::setEraseTool() | 495 | void DrawPad::setEraseTool() |
485 | { | 496 | { |
486 | if (m_pTool) { | 497 | if (m_pTool) { |
487 | delete m_pTool; | 498 | delete m_pTool; |
488 | } | 499 | } |
489 | 500 | ||
490 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); | 501 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); |
491 | 502 | ||
492 | m_pLineToolButton->setOn(false); | 503 | m_pLineToolButton->setOn(false); |
493 | m_pRectangleToolButton->setOn(false); | 504 | m_pRectangleToolButton->setOn(false); |
494 | m_pEllipseToolButton->setOn(false); | 505 | m_pEllipseToolButton->setOn(false); |
495 | m_pTextToolAction->setOn(false); | 506 | m_pTextToolAction->setOn(false); |
496 | m_pFillToolAction->setOn(false); | 507 | m_pFillToolAction->setOn(false); |
497 | m_pEraseToolAction->setOn(true); | 508 | m_pEraseToolAction->setOn(true); |
498 | } | 509 | } |
499 | 510 | ||
500 | void DrawPad::changePenWidth(int value) | 511 | void DrawPad::changePenWidth(int value) |
501 | { | 512 | { |
502 | m_pen.setWidth(value); | 513 | m_pen.setWidth(value); |
503 | } | 514 | } |
504 | 515 | ||
505 | void DrawPad::changePenColor(const QColor& color) | 516 | void DrawPad::changePenColor(const QColor& color) |
506 | { | 517 | { |
507 | m_pen.setColor(color); | 518 | m_pen.setColor(color); |
508 | 519 | ||
509 | QPainter painter; | 520 | QPainter painter; |
510 | painter.begin(m_pPenColorToolButton->pixmap()); | 521 | painter.begin(m_pPenColorToolButton->pixmap()); |
511 | painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); | 522 | painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); |
512 | painter.end(); | 523 | painter.end(); |
513 | 524 | ||
514 | m_pPenColorToolButton->popup()->hide(); | 525 | m_pPenColorToolButton->popup()->hide(); |
515 | } | 526 | } |
516 | 527 | ||
517 | void DrawPad::changeBrushColor(const QColor& color) | 528 | void DrawPad::changeBrushColor(const QColor& color) |
518 | { | 529 | { |
519 | m_brush = QBrush(color); | 530 | m_brush = QBrush(color); |
520 | 531 | ||
521 | QPainter painter; | 532 | QPainter painter; |
522 | painter.begin(m_pBrushColorToolButton->pixmap()); | 533 | painter.begin(m_pBrushColorToolButton->pixmap()); |
523 | painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); | 534 | painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); |
524 | painter.end(); | 535 | painter.end(); |
525 | 536 | ||
526 | m_pBrushColorToolButton->popup()->hide(); | 537 | m_pBrushColorToolButton->popup()->hide(); |
527 | } | 538 | } |
528 | 539 | ||
529 | void DrawPad::updateUndoRedoToolButtons() | 540 | void DrawPad::updateUndoRedoToolButtons() |
530 | { | 541 | { |
531 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled()); | 542 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled()); |
532 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->redoEnabled()); | 543 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->redoEnabled()); |
533 | } | 544 | } |
534 | 545 | ||
535 | void DrawPad::updateNavigationToolButtons() | 546 | void DrawPad::updateNavigationToolButtons() |
536 | { | 547 | { |
537 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 548 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
538 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 549 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
539 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 550 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
540 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 551 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
541 | } | 552 | } |
542 | 553 | ||
543 | void DrawPad::updateCaption() | 554 | void DrawPad::updateCaption() |
544 | { | 555 | { |
545 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); | 556 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); |
546 | uint pageCount = m_pDrawPadCanvas->pageCount(); | 557 | uint pageCount = m_pDrawPadCanvas->pageCount(); |
547 | 558 | ||
548 | setCaption(tr("DrawPad") + " - " + tr("Page") + " " | 559 | setCaption(tr("DrawPad") + " - " + tr("Page") + " " |
549 | + QString::number(pagePosition) + "/" + QString::number(pageCount)); | 560 | + QString::number(pagePosition) + "/" + QString::number(pageCount)); |
550 | } | 561 | } |
551 | 562 | ||
552 | void DrawPad::deleteAll() | 563 | void DrawPad::deleteAll() |
553 | { | 564 | { |
554 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), | 565 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), |
555 | QMessageBox::Information, QMessageBox::Yes, | 566 | QMessageBox::Information, QMessageBox::Yes, |
556 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 567 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
557 | QMessageBox::NoButton, this); | 568 | QMessageBox::NoButton, this); |
558 | 569 | ||
559 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 570 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
560 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 571 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
561 | 572 | ||
562 | if (messageBox.exec() == QMessageBox::Yes) { | 573 | if (messageBox.exec() == QMessageBox::Yes) { |
563 | m_pDrawPadCanvas->deleteAll(); | 574 | m_pDrawPadCanvas->deleteAll(); |
564 | } | 575 | } |
565 | } | 576 | } |
566 | 577 | ||
567 | void DrawPad::importPage() | 578 | void DrawPad::importPage() |
568 | { | 579 | { |
569 | ImportDialog importDialog(this); | 580 | ImportDialog importDialog(this); |
570 | 581 | ||
571 | importDialog.showMaximized(); | 582 | importDialog.showMaximized(); |
572 | 583 | ||
573 | if (importDialog.exec() == QDialog::Accepted) { | 584 | if (importDialog.exec() == QDialog::Accepted) { |
574 | const DocLnk* docLnk = importDialog.selected(); | 585 | const DocLnk* docLnk = importDialog.selected(); |
575 | 586 | ||
576 | if (docLnk) { | 587 | if (docLnk) { |
577 | m_pDrawPadCanvas->importPage(docLnk->file()); | 588 | m_pDrawPadCanvas->importPage(docLnk->file()); |
578 | delete docLnk; | 589 | delete docLnk; |
579 | } | 590 | } |
580 | } | 591 | } |
581 | } | 592 | } |
582 | 593 | ||
583 | void DrawPad::exportPage() | 594 | void DrawPad::exportPage() |
584 | { | 595 | { |
585 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); | 596 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); |
586 | 597 | ||
587 | exportDialog.showMaximized(); | 598 | exportDialog.showMaximized(); |
588 | 599 | ||
589 | if (exportDialog.exec() == QDialog::Accepted) { | 600 | if (exportDialog.exec() == QDialog::Accepted) { |
590 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), | 601 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), |
591 | exportDialog.selectedName(), exportDialog.selectedFormat()); | 602 | exportDialog.selectedName(), exportDialog.selectedFormat()); |
592 | } | 603 | } |
593 | } | 604 | } |
594 | 605 | ||
595 | void DrawPad::thumbnailView() | 606 | void DrawPad::thumbnailView() |
596 | { | 607 | { |
597 | ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); | 608 | ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); |
598 | 609 | ||
599 | thumbnailView.showMaximized(); | 610 | thumbnailView.showMaximized(); |
600 | thumbnailView.exec(); | 611 | thumbnailView.exec(); |
601 | } | 612 | } |
602 | 613 | ||
603 | void DrawPad::pageInformation() | 614 | void DrawPad::pageInformation() |
604 | { | 615 | { |
605 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); | 616 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); |
606 | 617 | ||
607 | if (pageInformationDialog.exec() == QDialog::Accepted) { | 618 | if (pageInformationDialog.exec() == QDialog::Accepted) { |
608 | m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); | 619 | m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); |
609 | } | 620 | } |
610 | } | 621 | } |
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h index ce62802..8e29c61 100644 --- a/noncore/graphics/drawpad/drawpad.h +++ b/noncore/graphics/drawpad/drawpad.h | |||
@@ -1,102 +1,106 @@ | |||
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 | bool antiAliasing(); | ||
42 | |||
41 | private slots: | 43 | private slots: |
42 | void newPage(); | 44 | void newPage(); |
43 | void clearPage(); | 45 | void clearPage(); |
44 | void deletePage(); | 46 | void deletePage(); |
45 | 47 | ||
46 | void setPointTool(); | 48 | void setPointTool(); |
47 | void setLineTool(); | 49 | void setLineTool(); |
48 | void setRectangleTool(); | 50 | void setRectangleTool(); |
49 | void setFilledRectangleTool(); | 51 | void setFilledRectangleTool(); |
50 | void setEllipseTool(); | 52 | void setEllipseTool(); |
51 | void setFilledEllipseTool(); | 53 | void setFilledEllipseTool(); |
52 | void setTextTool(); | 54 | void setTextTool(); |
53 | void setFillTool(); | 55 | void setFillTool(); |
54 | void setEraseTool(); | 56 | void setEraseTool(); |
55 | 57 | ||
56 | void changePenWidth(int value); | 58 | void changePenWidth(int value); |
57 | void changePenColor(const QColor& color); | 59 | void changePenColor(const QColor& color); |
58 | void changeBrushColor(const QColor& color); | 60 | void changeBrushColor(const QColor& color); |
59 | 61 | ||
60 | void updateUndoRedoToolButtons(); | 62 | void updateUndoRedoToolButtons(); |
61 | void updateNavigationToolButtons(); | 63 | void updateNavigationToolButtons(); |
62 | void updateCaption(); | 64 | void updateCaption(); |
63 | 65 | ||
64 | void deleteAll(); | 66 | void deleteAll(); |
65 | void importPage(); | 67 | void importPage(); |
66 | void exportPage(); | 68 | void exportPage(); |
67 | void thumbnailView(); | 69 | void thumbnailView(); |
68 | void pageInformation(); | 70 | void pageInformation(); |
69 | 71 | ||
70 | private: | 72 | private: |
71 | DrawPadCanvas* m_pDrawPadCanvas; | 73 | DrawPadCanvas* m_pDrawPadCanvas; |
72 | 74 | ||
73 | Tool* m_pTool; | 75 | Tool* m_pTool; |
74 | QPen m_pen; | 76 | QPen m_pen; |
75 | QBrush m_brush; | 77 | QBrush m_brush; |
76 | 78 | ||
79 | QAction* m_pAntiAliasingAction; | ||
80 | |||
77 | QAction* m_pUndoAction; | 81 | QAction* m_pUndoAction; |
78 | QAction* m_pRedoAction; | 82 | QAction* m_pRedoAction; |
79 | 83 | ||
80 | QAction* m_pFirstPageAction; | 84 | QAction* m_pFirstPageAction; |
81 | QAction* m_pPreviousPageAction; | 85 | QAction* m_pPreviousPageAction; |
82 | QAction* m_pNextPageAction; | 86 | QAction* m_pNextPageAction; |
83 | QAction* m_pLastPageAction; | 87 | QAction* m_pLastPageAction; |
84 | 88 | ||
85 | QAction* m_pPointToolAction; | 89 | QAction* m_pPointToolAction; |
86 | QAction* m_pLineToolAction; | 90 | QAction* m_pLineToolAction; |
87 | QAction* m_pRectangleToolAction; | 91 | QAction* m_pRectangleToolAction; |
88 | QAction* m_pFilledRectangleToolAction; | 92 | QAction* m_pFilledRectangleToolAction; |
89 | QAction* m_pEllipseToolAction; | 93 | QAction* m_pEllipseToolAction; |
90 | QAction* m_pFilledEllipseToolAction; | 94 | QAction* m_pFilledEllipseToolAction; |
91 | QAction* m_pTextToolAction; | 95 | QAction* m_pTextToolAction; |
92 | QAction* m_pFillToolAction; | 96 | QAction* m_pFillToolAction; |
93 | QAction* m_pEraseToolAction; | 97 | QAction* m_pEraseToolAction; |
94 | 98 | ||
95 | QToolButton* m_pLineToolButton; | 99 | QToolButton* m_pLineToolButton; |
96 | QToolButton* m_pRectangleToolButton; | 100 | QToolButton* m_pRectangleToolButton; |
97 | QToolButton* m_pEllipseToolButton; | 101 | QToolButton* m_pEllipseToolButton; |
98 | QToolButton* m_pPenColorToolButton; | 102 | QToolButton* m_pPenColorToolButton; |
99 | QToolButton* m_pBrushColorToolButton; | 103 | QToolButton* m_pBrushColorToolButton; |
100 | }; | 104 | }; |
101 | 105 | ||
102 | #endif // DRAWPAD_H | 106 | #endif // DRAWPAD_H |
diff --git a/noncore/graphics/drawpad/ellipsetool.cpp b/noncore/graphics/drawpad/ellipsetool.cpp index 733bade..0cdb731 100644 --- a/noncore/graphics/drawpad/ellipsetool.cpp +++ b/noncore/graphics/drawpad/ellipsetool.cpp | |||
@@ -1,76 +1,81 @@ | |||
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 "ellipsetool.h" | 14 | #include "ellipsetool.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 | EllipseTool::EllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | EllipseTool::EllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : ShapeTool(drawPad, drawPadCanvas) | 23 | : ShapeTool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | } | 25 | } |
26 | 26 | ||
27 | EllipseTool::~EllipseTool() | 27 | EllipseTool::~EllipseTool() |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | void EllipseTool::drawFinalShape(QPainter& p) | 31 | void EllipseTool::drawFinalShape(QPainter& p) |
32 | { | 32 | { |
33 | p.setRasterOp(Qt::NotROP); | 33 | p.setRasterOp(Qt::NotROP); |
34 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); | 34 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
35 | p.setRasterOp(Qt::CopyROP); | ||
35 | 36 | ||
36 | QRect r = m_polyline.boundingRect(); | 37 | if (m_pDrawPad->antiAliasing()) { |
37 | r = r.normalize(); | 38 | QRect r = m_polyline.boundingRect(); |
38 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 39 | r = r.normalize(); |
39 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 40 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
40 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 41 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
41 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 42 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
43 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | ||
42 | 44 | ||
43 | QPixmap areaPixmap(r.width(), r.height()); | 45 | QPixmap areaPixmap(r.width(), r.height()); |
44 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); | 46 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); |
45 | 47 | ||
46 | QImage areaImage = areaPixmap.convertToImage(); | 48 | QImage areaImage = areaPixmap.convertToImage(); |
47 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | 49 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); |
48 | 50 | ||
49 | QPixmap bigAreaPixmap; | 51 | QPixmap bigAreaPixmap; |
50 | bigAreaPixmap.convertFromImage(bigAreaImage); | 52 | bigAreaPixmap.convertFromImage(bigAreaImage); |
51 | 53 | ||
52 | QPen bigAreaPen = m_pDrawPad->pen(); | 54 | QPen bigAreaPen = m_pDrawPad->pen(); |
53 | bigAreaPen.setWidth(bigAreaPen.width() * 3); | 55 | bigAreaPen.setWidth(bigAreaPen.width() * 3); |
54 | 56 | ||
55 | QPainter bigAreaPainter; | 57 | QPainter bigAreaPainter; |
56 | bigAreaPainter.begin(&bigAreaPixmap); | 58 | bigAreaPainter.begin(&bigAreaPixmap); |
57 | bigAreaPainter.setPen(bigAreaPen); | 59 | bigAreaPainter.setPen(bigAreaPen); |
58 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, | 60 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, |
59 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), | 61 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), |
60 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); | 62 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); |
61 | bigAreaPainter.end(); | 63 | bigAreaPainter.end(); |
62 | 64 | ||
63 | bigAreaImage = bigAreaPixmap.convertToImage(); | 65 | bigAreaImage = bigAreaPixmap.convertToImage(); |
64 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); | 66 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); |
65 | areaPixmap.convertFromImage(areaImage); | 67 | areaPixmap.convertFromImage(areaImage); |
66 | 68 | ||
67 | p.setRasterOp(Qt::CopyROP); | 69 | p.drawPixmap(r.x(), r.y(), areaPixmap); |
68 | p.drawPixmap(r.x(), r.y(), areaPixmap); | 70 | } else { |
71 | p.setPen(m_pDrawPad->pen()); | ||
72 | p.drawEllipse(QRect(m_polyline[2], m_polyline[0])); | ||
73 | } | ||
69 | } | 74 | } |
70 | 75 | ||
71 | void EllipseTool::drawTemporaryShape(QPainter& p) | 76 | void EllipseTool::drawTemporaryShape(QPainter& p) |
72 | { | 77 | { |
73 | p.setRasterOp(Qt::NotROP); | 78 | p.setRasterOp(Qt::NotROP); |
74 | p.drawRect(QRect(m_polyline[2], m_polyline[1])); | 79 | p.drawRect(QRect(m_polyline[2], m_polyline[1])); |
75 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); | 80 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
76 | } | 81 | } |
diff --git a/noncore/graphics/drawpad/filledellipsetool.cpp b/noncore/graphics/drawpad/filledellipsetool.cpp index 2f7ec8f..6b5bbc6 100644 --- a/noncore/graphics/drawpad/filledellipsetool.cpp +++ b/noncore/graphics/drawpad/filledellipsetool.cpp | |||
@@ -1,77 +1,83 @@ | |||
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 "filledellipsetool.h" | 14 | #include "filledellipsetool.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 | FilledEllipseTool::FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | FilledEllipseTool::FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : ShapeTool(drawPad, drawPadCanvas) | 23 | : ShapeTool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | } | 25 | } |
26 | 26 | ||
27 | FilledEllipseTool::~FilledEllipseTool() | 27 | FilledEllipseTool::~FilledEllipseTool() |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | void FilledEllipseTool::drawFinalShape(QPainter& p) | 31 | void FilledEllipseTool::drawFinalShape(QPainter& p) |
32 | { | 32 | { |
33 | p.setRasterOp(Qt::NotROP); | 33 | p.setRasterOp(Qt::NotROP); |
34 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); | 34 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
35 | p.setRasterOp(Qt::CopyROP); | ||
35 | 36 | ||
36 | QRect r = m_polyline.boundingRect(); | 37 | if (m_pDrawPad->antiAliasing()) { |
37 | r = r.normalize(); | 38 | QRect r = m_polyline.boundingRect(); |
38 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 39 | r = r.normalize(); |
39 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 40 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
40 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 41 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
41 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 42 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
43 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | ||
42 | 44 | ||
43 | QPixmap areaPixmap(r.width(), r.height()); | 45 | QPixmap areaPixmap(r.width(), r.height()); |
44 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); | 46 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); |
45 | 47 | ||
46 | QImage areaImage = areaPixmap.convertToImage(); | 48 | QImage areaImage = areaPixmap.convertToImage(); |
47 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | 49 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); |
48 | 50 | ||
49 | QPixmap bigAreaPixmap; | 51 | QPixmap bigAreaPixmap; |
50 | bigAreaPixmap.convertFromImage(bigAreaImage); | 52 | bigAreaPixmap.convertFromImage(bigAreaImage); |
51 | 53 | ||
52 | QPen bigAreaPen = m_pDrawPad->pen(); | 54 | QPen bigAreaPen = m_pDrawPad->pen(); |
53 | bigAreaPen.setWidth(bigAreaPen.width() * 3); | 55 | bigAreaPen.setWidth(bigAreaPen.width() * 3); |
54 | 56 | ||
55 | QPainter bigAreaPainter; | 57 | QPainter bigAreaPainter; |
56 | bigAreaPainter.begin(&bigAreaPixmap); | 58 | bigAreaPainter.begin(&bigAreaPixmap); |
57 | bigAreaPainter.setPen(bigAreaPen); | 59 | bigAreaPainter.setPen(bigAreaPen); |
58 | bigAreaPainter.setBrush(m_pDrawPad->brush()); | 60 | bigAreaPainter.setBrush(m_pDrawPad->brush()); |
59 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, | 61 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, |
60 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), | 62 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), |
61 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); | 63 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); |
62 | bigAreaPainter.end(); | 64 | bigAreaPainter.end(); |
63 | 65 | ||
64 | bigAreaImage = bigAreaPixmap.convertToImage(); | 66 | bigAreaImage = bigAreaPixmap.convertToImage(); |
65 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); | 67 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); |
66 | areaPixmap.convertFromImage(areaImage); | 68 | areaPixmap.convertFromImage(areaImage); |
67 | 69 | ||
68 | p.setRasterOp(Qt::CopyROP); | 70 | p.drawPixmap(r.x(), r.y(), areaPixmap); |
69 | p.drawPixmap(r.x(), r.y(), areaPixmap); | 71 | } else { |
72 | p.setPen(m_pDrawPad->pen()); | ||
73 | p.setBrush(m_pDrawPad->brush()); | ||
74 | p.drawEllipse(QRect(m_polyline[2], m_polyline[0])); | ||
75 | } | ||
70 | } | 76 | } |
71 | 77 | ||
72 | void FilledEllipseTool::drawTemporaryShape(QPainter& p) | 78 | void FilledEllipseTool::drawTemporaryShape(QPainter& p) |
73 | { | 79 | { |
74 | p.setRasterOp(Qt::NotROP); | 80 | p.setRasterOp(Qt::NotROP); |
75 | p.drawRect(QRect(m_polyline[2], m_polyline[1])); | 81 | p.drawRect(QRect(m_polyline[2], m_polyline[1])); |
76 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); | 82 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
77 | } | 83 | } |
diff --git a/noncore/graphics/drawpad/linetool.cpp b/noncore/graphics/drawpad/linetool.cpp index 99cd6de..b6baa2a 100644 --- a/noncore/graphics/drawpad/linetool.cpp +++ b/noncore/graphics/drawpad/linetool.cpp | |||
@@ -1,77 +1,82 @@ | |||
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 "linetool.h" | 14 | #include "linetool.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 | LineTool::LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | LineTool::LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : ShapeTool(drawPad, drawPadCanvas) | 23 | : ShapeTool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | } | 25 | } |
26 | 26 | ||
27 | LineTool::~LineTool() | 27 | LineTool::~LineTool() |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | void LineTool::drawFinalShape(QPainter& p) | 31 | void LineTool::drawFinalShape(QPainter& p) |
32 | { | 32 | { |
33 | p.setRasterOp(Qt::NotROP); | 33 | p.setRasterOp(Qt::NotROP); |
34 | p.drawLine(m_polyline[2], m_polyline[0]); | 34 | p.drawLine(m_polyline[2], m_polyline[0]); |
35 | p.setRasterOp(Qt::CopyROP); | ||
35 | 36 | ||
36 | QRect r = m_polyline.boundingRect(); | 37 | if (m_pDrawPad->antiAliasing()) { |
37 | r = r.normalize(); | 38 | QRect r = m_polyline.boundingRect(); |
38 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 39 | r = r.normalize(); |
39 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 40 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
40 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 41 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
41 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 42 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
43 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | ||
42 | 44 | ||
43 | QPixmap areaPixmap(r.width(), r.height()); | 45 | QPixmap areaPixmap(r.width(), r.height()); |
44 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); | 46 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); |
45 | 47 | ||
46 | QImage areaImage = areaPixmap.convertToImage(); | 48 | QImage areaImage = areaPixmap.convertToImage(); |
47 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | 49 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); |
48 | 50 | ||
49 | QPixmap bigAreaPixmap; | 51 | QPixmap bigAreaPixmap; |
50 | bigAreaPixmap.convertFromImage(bigAreaImage); | 52 | bigAreaPixmap.convertFromImage(bigAreaImage); |
51 | 53 | ||
52 | QPen bigAreaPen = m_pDrawPad->pen(); | 54 | QPen bigAreaPen = m_pDrawPad->pen(); |
53 | bigAreaPen.setWidth(bigAreaPen.width() * 3); | 55 | bigAreaPen.setWidth(bigAreaPen.width() * 3); |
54 | 56 | ||
55 | QPainter bigAreaPainter; | 57 | QPainter bigAreaPainter; |
56 | bigAreaPainter.begin(&bigAreaPixmap); | 58 | bigAreaPainter.begin(&bigAreaPixmap); |
57 | bigAreaPainter.setPen(bigAreaPen); | 59 | bigAreaPainter.setPen(bigAreaPen); |
58 | 60 | ||
59 | bigAreaPainter.drawLine((m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1, | 61 | bigAreaPainter.drawLine((m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1, |
60 | (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); | 62 | (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); |
61 | 63 | ||
62 | bigAreaPainter.end(); | 64 | bigAreaPainter.end(); |
63 | 65 | ||
64 | bigAreaImage = bigAreaPixmap.convertToImage(); | 66 | bigAreaImage = bigAreaPixmap.convertToImage(); |
65 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); | 67 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); |
66 | areaPixmap.convertFromImage(areaImage); | 68 | areaPixmap.convertFromImage(areaImage); |
67 | 69 | ||
68 | p.setRasterOp(Qt::CopyROP); | 70 | p.drawPixmap(r.x(), r.y(), areaPixmap); |
69 | p.drawPixmap(r.x(), r.y(), areaPixmap); | 71 | } else { |
72 | p.setPen(m_pDrawPad->pen()); | ||
73 | p.drawLine(m_polyline[2], m_polyline[0]); | ||
74 | } | ||
70 | } | 75 | } |
71 | 76 | ||
72 | void LineTool::drawTemporaryShape(QPainter& p) | 77 | void LineTool::drawTemporaryShape(QPainter& p) |
73 | { | 78 | { |
74 | p.setRasterOp(Qt::NotROP); | 79 | p.setRasterOp(Qt::NotROP); |
75 | p.drawLine(m_polyline[2], m_polyline[1]); | 80 | p.drawLine(m_polyline[2], m_polyline[1]); |
76 | p.drawLine(m_polyline[2], m_polyline[0]); | 81 | p.drawLine(m_polyline[2], m_polyline[0]); |
77 | } | 82 | } |
diff --git a/noncore/graphics/drawpad/pointtool.cpp b/noncore/graphics/drawpad/pointtool.cpp index 22bb089..a4f846e 100644 --- a/noncore/graphics/drawpad/pointtool.cpp +++ b/noncore/graphics/drawpad/pointtool.cpp | |||
@@ -1,105 +1,111 @@ | |||
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 | #include "page.h" | 18 | #include "page.h" |
19 | 19 | ||
20 | #include <qimage.h> | 20 | #include <qimage.h> |
21 | #include <qpainter.h> | 21 | #include <qpainter.h> |
22 | 22 | ||
23 | PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 23 | PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
24 | : Tool(drawPad, drawPadCanvas) | 24 | : Tool(drawPad, drawPadCanvas) |
25 | { | 25 | { |
26 | m_mousePressed = false; | 26 | m_mousePressed = false; |
27 | m_polyline.resize(3); | 27 | m_polyline.resize(3); |
28 | } | 28 | } |
29 | 29 | ||
30 | PointTool::~PointTool() | 30 | PointTool::~PointTool() |
31 | { | 31 | { |
32 | } | 32 | } |
33 | 33 | ||
34 | void PointTool::mousePressEvent(QMouseEvent* e) | 34 | void PointTool::mousePressEvent(QMouseEvent* e) |
35 | { | 35 | { |
36 | m_mousePressed = true; | 36 | m_mousePressed = true; |
37 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | 37 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); |
38 | } | 38 | } |
39 | 39 | ||
40 | void PointTool::mouseReleaseEvent(QMouseEvent* e) | 40 | void PointTool::mouseReleaseEvent(QMouseEvent* e) |
41 | { | 41 | { |
42 | Q_UNUSED(e) | 42 | Q_UNUSED(e) |
43 | 43 | ||
44 | m_mousePressed = false; | 44 | m_mousePressed = false; |
45 | 45 | ||
46 | m_pDrawPadCanvas->backupPage(); | 46 | m_pDrawPadCanvas->backupPage(); |
47 | } | 47 | } |
48 | 48 | ||
49 | void PointTool::mouseMoveEvent(QMouseEvent* e) | 49 | void PointTool::mouseMoveEvent(QMouseEvent* e) |
50 | { | 50 | { |
51 | if (m_mousePressed) { | 51 | if (m_mousePressed) { |
52 | m_polyline[2] = m_polyline[1]; | 52 | m_polyline[2] = m_polyline[1]; |
53 | m_polyline[1] = m_polyline[0]; | 53 | m_polyline[1] = m_polyline[0]; |
54 | m_polyline[0] = e->pos(); | 54 | m_polyline[0] = e->pos(); |
55 | 55 | ||
56 | QPainter painter; | ||
57 | painter.begin(m_pDrawPadCanvas->currentPage()); | ||
58 | |||
59 | QRect r = m_polyline.boundingRect(); | 56 | QRect r = m_polyline.boundingRect(); |
60 | r = r.normalize(); | 57 | r = r.normalize(); |
61 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 58 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
62 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 59 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
63 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 60 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
64 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 61 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
65 | 62 | ||
66 | QPixmap areaPixmap(r.width(), r.height()); | 63 | QPainter painter; |
67 | bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r); | 64 | painter.begin(m_pDrawPadCanvas->currentPage()); |
65 | |||
66 | if (m_pDrawPad->antiAliasing()) { | ||
67 | QPixmap areaPixmap(r.width(), r.height()); | ||
68 | bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r); | ||
69 | |||
70 | QImage areaImage = areaPixmap.convertToImage(); | ||
71 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | ||
68 | 72 | ||
69 | QImage areaImage = areaPixmap.convertToImage(); | 73 | QPixmap bigAreaPixmap; |
70 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | 74 | bigAreaPixmap.convertFromImage(bigAreaImage); |
71 | 75 | ||
72 | QPixmap bigAreaPixmap; | 76 | QPen bigAreaPen = m_pDrawPad->pen(); |
73 | bigAreaPixmap.convertFromImage(bigAreaImage); | 77 | bigAreaPen.setWidth(bigAreaPen.width() * 3); |
74 | 78 | ||
75 | QPen bigAreaPen = m_pDrawPad->pen(); | 79 | QPainter bigAreaPainter; |
76 | bigAreaPen.setWidth(bigAreaPen.width() * 3); | 80 | bigAreaPainter.begin(&bigAreaPixmap); |
81 | bigAreaPainter.setPen(bigAreaPen); | ||
77 | 82 | ||
78 | QPainter bigAreaPainter; | 83 | QPointArray bigAreaPolyline(3); |
79 | bigAreaPainter.begin(&bigAreaPixmap); | 84 | bigAreaPolyline.setPoint(0, (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); |
80 | bigAreaPainter.setPen(bigAreaPen); | 85 | bigAreaPolyline.setPoint(1, (m_polyline[1].x() - r.x()) * 3 + 1, (m_polyline[1].y() - r.y()) * 3 + 1); |
86 | bigAreaPolyline.setPoint(2, (m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1); | ||
81 | 87 | ||
82 | QPointArray bigAreaPolyline(3); | 88 | bigAreaPainter.drawPolyline(bigAreaPolyline); |
83 | bigAreaPolyline.setPoint(0, (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); | 89 | bigAreaPainter.end(); |
84 | bigAreaPolyline.setPoint(1, (m_polyline[1].x() - r.x()) * 3 + 1, (m_polyline[1].y() - r.y()) * 3 + 1); | ||
85 | bigAreaPolyline.setPoint(2, (m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1); | ||
86 | 90 | ||
87 | bigAreaPainter.drawPolyline(bigAreaPolyline); | 91 | bigAreaImage = bigAreaPixmap.convertToImage(); |
88 | bigAreaPainter.end(); | 92 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); |
93 | areaPixmap.convertFromImage(areaImage); | ||
89 | 94 | ||
90 | bigAreaImage = bigAreaPixmap.convertToImage(); | 95 | painter.drawPixmap(r.x(), r.y(), areaPixmap); |
91 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); | 96 | } else { |
92 | areaPixmap.convertFromImage(areaImage); | 97 | painter.setPen(m_pDrawPad->pen()); |
98 | painter.drawPolyline(m_polyline); | ||
99 | } | ||
93 | 100 | ||
94 | painter.drawPixmap(r.x(), r.y(), areaPixmap); | ||
95 | painter.end(); | 101 | painter.end(); |
96 | 102 | ||
97 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), | 103 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), |
98 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 104 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
99 | 105 | ||
100 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 106 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
101 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | 107 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); |
102 | 108 | ||
103 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 109 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
104 | } | 110 | } |
105 | } | 111 | } |