summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp1
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp2
-rw-r--r--noncore/graphics/drawpad/ellipsetool.cpp1
-rw-r--r--noncore/graphics/drawpad/erasetool.cpp1
-rw-r--r--noncore/graphics/drawpad/exportdialog.cpp1
-rw-r--r--noncore/graphics/drawpad/filledellipsetool.cpp1
-rw-r--r--noncore/graphics/drawpad/filltool.cpp1
-rw-r--r--noncore/graphics/drawpad/importdialog.cpp1
-rw-r--r--noncore/graphics/drawpad/linetool.cpp1
-rw-r--r--noncore/graphics/drawpad/main.cpp1
-rw-r--r--noncore/graphics/drawpad/newpagedialog.cpp1
-rw-r--r--noncore/graphics/drawpad/pointtool.cpp1
-rw-r--r--noncore/graphics/drawpad/shapetool.cpp1
-rw-r--r--noncore/graphics/drawpad/texttool.cpp1
-rw-r--r--noncore/graphics/drawpad/thumbnailview.cpp1
-rw-r--r--noncore/graphics/drawpad/tool.cpp2
16 files changed, 0 insertions, 18 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 86a10a5..71c9695 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -1,302 +1,301 @@
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/config.h> 37#include <qpe/config.h>
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qmenubar.h> 39#include <qmenubar.h>
40#include <qpe/qpetoolbar.h> 40#include <qpe/qpetoolbar.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42 42
43#include <qaction.h> 43#include <qaction.h>
44#include <qfile.h> 44#include <qfile.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qpainter.h>
47#include <qspinbox.h> 46#include <qspinbox.h>
48#include <qtoolbutton.h> 47#include <qtoolbutton.h>
49#include <qtooltip.h> 48#include <qtooltip.h>
50#include <qwhatsthis.h> 49#include <qwhatsthis.h>
51 50
52DrawPad::DrawPad(QWidget* parent, const char* name, WFlags fl ) 51DrawPad::DrawPad(QWidget* parent, const char* name, WFlags fl )
53 : QMainWindow(parent, name, WStyle_ContextHelp) 52 : QMainWindow(parent, name, WStyle_ContextHelp)
54{ 53{
55 // init members 54 // init members
56 55
57 m_pDrawPadCanvas = new DrawPadCanvas(this, this); 56 m_pDrawPadCanvas = new DrawPadCanvas(this, this);
58 57
59 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); 58 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView()));
60 59
61 setCentralWidget(m_pDrawPadCanvas); 60 setCentralWidget(m_pDrawPadCanvas);
62 61
63 // init menu 62 // init menu
64 63
65 setToolBarsMovable(false); 64 setToolBarsMovable(false);
66 65
67 QToolBar* menuToolBar = new QToolBar(this); 66 QToolBar* menuToolBar = new QToolBar(this);
68 QMenuBar* menuBar = new QMenuBar(menuToolBar); 67 QMenuBar* menuBar = new QMenuBar(menuToolBar);
69 68
70 QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); 69 QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar);
71 70
72 QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); 71 QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
73 connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); 72 connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll()));
74 deleteAllAction->addTo(toolsPopupMenu); 73 deleteAllAction->addTo(toolsPopupMenu);
75 74
76 toolsPopupMenu->insertSeparator(); 75 toolsPopupMenu->insertSeparator();
77 76
78 QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); 77 QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this);
79 connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); 78 connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage()));
80 importPageAction->addTo(toolsPopupMenu); 79 importPageAction->addTo(toolsPopupMenu);
81 80
82 QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); 81 QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this);
83 connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); 82 connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage()));
84 exportPageAction->addTo(toolsPopupMenu); 83 exportPageAction->addTo(toolsPopupMenu);
85 84
86 toolsPopupMenu->insertSeparator(); 85 toolsPopupMenu->insertSeparator();
87 86
88 QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); 87 QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this);
89 connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); 88 connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView()));
90 thumbnailViewAction->addTo(toolsPopupMenu); 89 thumbnailViewAction->addTo(toolsPopupMenu);
91 90
92 QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); 91 QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this);
93 connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); 92 connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation()));
94 pageInformationAction->addTo(toolsPopupMenu); 93 pageInformationAction->addTo(toolsPopupMenu);
95 94
96 toolsPopupMenu->insertSeparator(); 95 toolsPopupMenu->insertSeparator();
97 96
98 m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); 97 m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this);
99 m_pAntiAliasingAction->setToggleAction(true); 98 m_pAntiAliasingAction->setToggleAction(true);
100 m_pAntiAliasingAction->addTo(toolsPopupMenu); 99 m_pAntiAliasingAction->addTo(toolsPopupMenu);
101 100
102 menuBar->insertItem(tr("Tools"), toolsPopupMenu); 101 menuBar->insertItem(tr("Tools"), toolsPopupMenu);
103 102
104 // init page toolbar 103 // init page toolbar
105 104
106 QToolBar* pageToolBar = new QToolBar(this); 105 QToolBar* pageToolBar = new QToolBar(this);
107 106
108 QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this); 107 QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this);
109 connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); 108 connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage()));
110 newPageAction->addTo(pageToolBar); 109 newPageAction->addTo(pageToolBar);
111 newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); 110 newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) );
112 111
113 QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this); 112 QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this);
114 connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); 113 connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage()));
115 clearPageAction->addTo(pageToolBar); 114 clearPageAction->addTo(pageToolBar);
116 clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); 115 clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) );
117 116
118 QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this); 117 QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this);
119 connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); 118 connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage()));
120 deletePageAction->addTo(pageToolBar); 119 deletePageAction->addTo(pageToolBar);
121 deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); 120 deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) );
122 121
123 QToolBar* emptyToolBar = new QToolBar(this); 122 QToolBar* emptyToolBar = new QToolBar(this);
124 emptyToolBar->setHorizontalStretchable(true); 123 emptyToolBar->setHorizontalStretchable(true);
125 124
126 // init navigation toolbar 125 // init navigation toolbar
127 126
128 QToolBar* navigationToolBar = new QToolBar(this); 127 QToolBar* navigationToolBar = new QToolBar(this);
129 128
130 m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this); 129 m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this);
131 connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); 130 connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo()));
132 m_pUndoAction->addTo(navigationToolBar); 131 m_pUndoAction->addTo(navigationToolBar);
133 m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); 132 m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) );
134 133
135 m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this); 134 m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this);
136 connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); 135 connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo()));
137 m_pRedoAction->addTo(navigationToolBar); 136 m_pRedoAction->addTo(navigationToolBar);
138 m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); 137 m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) );
139 138
140 m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); 139 m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this);
141 connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); 140 connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage()));
142 m_pFirstPageAction->addTo(navigationToolBar); 141 m_pFirstPageAction->addTo(navigationToolBar);
143 m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); 142 m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) );
144 143
145 m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); 144 m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this);
146 connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); 145 connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage()));
147 m_pPreviousPageAction->addTo(navigationToolBar); 146 m_pPreviousPageAction->addTo(navigationToolBar);
148 m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); 147 m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) );
149 148
150 m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); 149 m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this);
151 connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); 150 connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage()));
152 m_pNextPageAction->addTo(navigationToolBar); 151 m_pNextPageAction->addTo(navigationToolBar);
153 m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); 152 m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) );
154 153
155 m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); 154 m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this);
156 connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); 155 connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage()));
157 m_pLastPageAction->addTo(navigationToolBar); 156 m_pLastPageAction->addTo(navigationToolBar);
158 m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); 157 m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) );
159 158
160 // init draw mode toolbar 159 // init draw mode toolbar
161 160
162 QToolBar* drawModeToolBar = new QToolBar(this); 161 QToolBar* drawModeToolBar = new QToolBar(this);
163 162
164 m_pLineToolButton = new QToolButton(drawModeToolBar); 163 m_pLineToolButton = new QToolButton(drawModeToolBar);
165 m_pLineToolButton->setToggleButton(true); 164 m_pLineToolButton->setToggleButton(true);
166 QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) ); 165 QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) );
167 166
168 167
169 QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); 168 QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton);
170 169
171 m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this); 170 m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this);
172 connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); 171 connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool()));
173 m_pPointToolAction->addTo(linePopupMenu); 172 m_pPointToolAction->addTo(linePopupMenu);
174 173
175 m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this); 174 m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this);
176 connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); 175 connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool()));
177 m_pLineToolAction->addTo(linePopupMenu); 176 m_pLineToolAction->addTo(linePopupMenu);
178 177
179 m_pLineToolButton->setPopup(linePopupMenu); 178 m_pLineToolButton->setPopup(linePopupMenu);
180 m_pLineToolButton->setPopupDelay(0); 179 m_pLineToolButton->setPopupDelay(0);
181 180
182 m_pRectangleToolButton = new QToolButton(drawModeToolBar); 181 m_pRectangleToolButton = new QToolButton(drawModeToolBar);
183 m_pRectangleToolButton->setToggleButton(true); 182 m_pRectangleToolButton->setToggleButton(true);
184 QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) ); 183 QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) );
185 184
186 QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); 185 QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton);
187 186
188 m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this); 187 m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this);
189 connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); 188 connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool()));
190 m_pRectangleToolAction->addTo(rectanglePopupMenu); 189 m_pRectangleToolAction->addTo(rectanglePopupMenu);
191 190
192 m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this); 191 m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this);
193 connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); 192 connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool()));
194 m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); 193 m_pFilledRectangleToolAction->addTo(rectanglePopupMenu);
195 194
196 m_pRectangleToolButton->setPopup(rectanglePopupMenu); 195 m_pRectangleToolButton->setPopup(rectanglePopupMenu);
197 m_pRectangleToolButton->setPopupDelay(0); 196 m_pRectangleToolButton->setPopupDelay(0);
198 197
199 m_pEllipseToolButton = new QToolButton(drawModeToolBar); 198 m_pEllipseToolButton = new QToolButton(drawModeToolBar);
200 m_pEllipseToolButton->setToggleButton(true); 199 m_pEllipseToolButton->setToggleButton(true);
201 QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) ); 200 QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) );
202 201
203 QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); 202 QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton);
204 203
205 m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this); 204 m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this);
206 connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); 205 connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool()));
207 m_pEllipseToolAction->addTo(ellipsePopupMenu); 206 m_pEllipseToolAction->addTo(ellipsePopupMenu);
208 207
209 m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this); 208 m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this);
210 connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); 209 connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool()));
211 m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); 210 m_pFilledEllipseToolAction->addTo(ellipsePopupMenu);
212 211
213 m_pEllipseToolButton->setPopup(ellipsePopupMenu); 212 m_pEllipseToolButton->setPopup(ellipsePopupMenu);
214 m_pEllipseToolButton->setPopupDelay(0); 213 m_pEllipseToolButton->setPopupDelay(0);
215 214
216 m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this); 215 m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this);
217 m_pTextToolAction->setToggleAction(true); 216 m_pTextToolAction->setToggleAction(true);
218 connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); 217 connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool()));
219 m_pTextToolAction->addTo(drawModeToolBar); 218 m_pTextToolAction->addTo(drawModeToolBar);
220 m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) ); 219 m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) );
221 220
222 m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this); 221 m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this);
223 m_pFillToolAction->setToggleAction(true); 222 m_pFillToolAction->setToggleAction(true);
224 connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); 223 connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool()));
225 m_pFillToolAction->addTo(drawModeToolBar); 224 m_pFillToolAction->addTo(drawModeToolBar);
226 m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) ); 225 m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) );
227 226
228 m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this); 227 m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this);
229 m_pEraseToolAction->setToggleAction(true); 228 m_pEraseToolAction->setToggleAction(true);
230 connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); 229 connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool()));
231 m_pEraseToolAction->addTo(drawModeToolBar); 230 m_pEraseToolAction->addTo(drawModeToolBar);
232 m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) ); 231 m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) );
233 232
234 m_pTool = 0; 233 m_pTool = 0;
235 setRectangleTool(); 234 setRectangleTool();
236 setEllipseTool(); 235 setEllipseTool();
237 setPointTool(); 236 setPointTool();
238 237
239 emptyToolBar = new QToolBar(this); 238 emptyToolBar = new QToolBar(this);
240 emptyToolBar->setHorizontalStretchable(true); 239 emptyToolBar->setHorizontalStretchable(true);
241 emptyToolBar->addSeparator(); 240 emptyToolBar->addSeparator();
242 241
243 // init draw parameters toolbar 242 // init draw parameters toolbar
244 243
245 QToolBar* drawParametersToolBar = new QToolBar(this); 244 QToolBar* drawParametersToolBar = new QToolBar(this);
246 245
247 m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); 246 m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar);
248 connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); 247 connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int)));
249 248
250 QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); 249 QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width"));
251 m_pPenWidthSpinBox->setValue(1); 250 m_pPenWidthSpinBox->setValue(1);
252 m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); 251 m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus);
253 QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) ); 252 QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) );
254 253
255 m_pPenColorToolButton = new QToolButton(drawParametersToolBar); 254 m_pPenColorToolButton = new QToolButton(drawParametersToolBar);
256 m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor")); 255 m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor"));
257 QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); 256 QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) );
258 257
259 OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, m_pPenColorToolButton); 258 OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, m_pPenColorToolButton);
260 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); 259 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&)));
261 260
262 QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); 261 QToolTip::add(m_pPenColorToolButton, tr("Pen Color"));
263 m_pPenColorToolButton->setPopup(penColorPopupMenu); 262 m_pPenColorToolButton->setPopup(penColorPopupMenu);
264 m_pPenColorToolButton->setPopupDelay(0); 263 m_pPenColorToolButton->setPopupDelay(0);
265 264
266 changePenColor(Qt::black); 265 changePenColor(Qt::black);
267 266
268 m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); 267 m_pBrushColorToolButton = new QToolButton(drawParametersToolBar);
269 m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor")); 268 m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor"));
270 QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) ); 269 QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) );
271 270
272 OColorPopupMenu* brushColorPopupMenu = new OColorPopupMenu(Qt::white, m_pBrushColorToolButton); 271 OColorPopupMenu* brushColorPopupMenu = new OColorPopupMenu(Qt::white, m_pBrushColorToolButton);
273 connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); 272 connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&)));
274 273
275 QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); 274 QToolTip::add(m_pBrushColorToolButton, tr("Fill Color"));
276 m_pBrushColorToolButton->setPopup(brushColorPopupMenu); 275 m_pBrushColorToolButton->setPopup(brushColorPopupMenu);
277 m_pBrushColorToolButton->setPopupDelay(0); 276 m_pBrushColorToolButton->setPopupDelay(0);
278 277
279 changeBrushColor(Qt::white); 278 changeBrushColor(Qt::white);
280 279
281 finishStartup(); 280 finishStartup();
282} 281}
283 282
284 283
285void DrawPad::finishStartup() 284void DrawPad::finishStartup()
286{ 285{
287 // init pages 286 // init pages
288 287
289 QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); 288 QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
290 289
291 if (file.open(IO_ReadOnly)) { 290 if (file.open(IO_ReadOnly)) {
292 m_pDrawPadCanvas->load(&file); 291 m_pDrawPadCanvas->load(&file);
293 file.close(); 292 file.close();
294 } else { 293 } else {
295 m_pDrawPadCanvas->initialPage(); 294 m_pDrawPadCanvas->initialPage();
296 } 295 }
297 296
298 loadConfig(); 297 loadConfig();
299 298
300} 299}
301 300
302DrawPad::~DrawPad() 301DrawPad::~DrawPad()
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index dec498b..446096c 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -1,284 +1,282 @@
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 "drawpadcanvas.h" 14#include "drawpadcanvas.h"
15 15
16#include "drawpad.h" 16#include "drawpad.h"
17#include "page.h" 17#include "page.h"
18#include "tool.h" 18#include "tool.h"
19 19
20#include <qpe/applnk.h> 20#include <qpe/applnk.h>
21#include <qpe/filemanager.h> 21#include <qpe/filemanager.h>
22#include <qpe/mimetype.h> 22#include <qpe/mimetype.h>
23 23
24#include <qbuffer.h> 24#include <qbuffer.h>
25#include <qimage.h> 25#include <qimage.h>
26#include <qpainter.h>
27#include <qtextcodec.h> 26#include <qtextcodec.h>
28#include <qtextstream.h>
29#include <qxml.h> 27#include <qxml.h>
30 28
31class DrawPadCanvasXmlHandler: public QXmlDefaultHandler 29class DrawPadCanvasXmlHandler: public QXmlDefaultHandler
32{ 30{
33public: 31public:
34 DrawPadCanvasXmlHandler(); 32 DrawPadCanvasXmlHandler();
35 ~DrawPadCanvasXmlHandler(); 33 ~DrawPadCanvasXmlHandler();
36 34
37 QList<Page> pages(); 35 QList<Page> pages();
38 36
39 bool startElement(const QString& namespaceURI, const QString& localName, 37 bool startElement(const QString& namespaceURI, const QString& localName,
40 const QString& qName, const QXmlAttributes& atts); 38 const QString& qName, const QXmlAttributes& atts);
41 bool endElement(const QString& namespaceURI, const QString& localName, 39 bool endElement(const QString& namespaceURI, const QString& localName,
42 const QString& qName); 40 const QString& qName);
43 bool characters(const QString& ch); 41 bool characters(const QString& ch);
44 42
45private: 43private:
46 enum State { 44 enum State {
47 Unknown, 45 Unknown,
48 InTitle, 46 InTitle,
49 InDate, 47 InDate,
50 InData 48 InData
51 }; 49 };
52 50
53 State m_state; 51 State m_state;
54 QString m_title; 52 QString m_title;
55 QDateTime m_date; 53 QDateTime m_date;
56 ulong m_dataLenght; 54 ulong m_dataLenght;
57 QString m_dataFormat; 55 QString m_dataFormat;
58 QList<Page> m_pages; 56 QList<Page> m_pages;
59}; 57};
60 58
61DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() 59DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler()
62{ 60{
63 m_state = Unknown; 61 m_state = Unknown;
64} 62}
65 63
66DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() 64DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler()
67{ 65{
68} 66}
69 67
70QList<Page> DrawPadCanvasXmlHandler::pages() 68QList<Page> DrawPadCanvasXmlHandler::pages()
71{ 69{
72 return m_pages; 70 return m_pages;
73} 71}
74 72
75bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, 73bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName,
76 const QString& qName, const QXmlAttributes& atts) 74 const QString& qName, const QXmlAttributes& atts)
77{ 75{
78 Q_CONST_UNUSED(namespaceURI) 76 Q_CONST_UNUSED(namespaceURI)
79 Q_CONST_UNUSED(localName) 77 Q_CONST_UNUSED(localName)
80 78
81 if (qName == "image") { 79 if (qName == "image") {
82 m_title = QString(); 80 m_title = QString();
83 m_date = QDateTime::currentDateTime(); 81 m_date = QDateTime::currentDateTime();
84 } else if (qName == "title") { 82 } else if (qName == "title") {
85 m_state = InTitle; 83 m_state = InTitle;
86 } else if (qName == "date") { 84 } else if (qName == "date") {
87 m_state = InDate; 85 m_state = InDate;
88 } else if (qName == "data") { 86 } else if (qName == "data") {
89 m_state = InData; 87 m_state = InData;
90 m_dataLenght = atts.value("length").toULong(); 88 m_dataLenght = atts.value("length").toULong();
91 m_dataFormat = atts.value("format"); 89 m_dataFormat = atts.value("format");
92 } 90 }
93 91
94 return true; 92 return true;
95} 93}
96 94
97bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, 95bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName,
98 const QString& qName) 96 const QString& qName)
99{ 97{
100 Q_CONST_UNUSED(namespaceURI) 98 Q_CONST_UNUSED(namespaceURI)
101 Q_CONST_UNUSED(localName) 99 Q_CONST_UNUSED(localName)
102 100
103 if (qName == "title") { 101 if (qName == "title") {
104 m_state = Unknown; 102 m_state = Unknown;
105 } else if (qName == "date") { 103 } else if (qName == "date") {
106 m_state = Unknown; 104 m_state = Unknown;
107 } else if (qName == "data") { 105 } else if (qName == "data") {
108 m_state = Unknown; 106 m_state = Unknown;
109 } 107 }
110 108
111 return true; 109 return true;
112} 110}
113 111
114bool DrawPadCanvasXmlHandler::characters(const QString& ch) 112bool DrawPadCanvasXmlHandler::characters(const QString& ch)
115{ 113{
116 if (m_state == InTitle) { 114 if (m_state == InTitle) {
117 m_title = ch; 115 m_title = ch;
118 } else if (m_state == InDate) { 116 } else if (m_state == InDate) {
119 m_date = QDateTime(QDate(1970, 1, 1)).addSecs(ch.toInt()); 117 m_date = QDateTime(QDate(1970, 1, 1)).addSecs(ch.toInt());
120 } else if (m_state == InData) { 118 } else if (m_state == InData) {
121 QByteArray byteArray(ch.length() / 2); 119 QByteArray byteArray(ch.length() / 2);
122 120
123 for (int i = 0; i < (int)ch.length() / 2; i++) { 121 for (int i = 0; i < (int)ch.length() / 2; i++) {
124 char h = ch[2 * i].latin1(); 122 char h = ch[2 * i].latin1();
125 char l = ch[2 * i + 1].latin1(); 123 char l = ch[2 * i + 1].latin1();
126 uchar r = 0; 124 uchar r = 0;
127 125
128 if (h <= '9') { 126 if (h <= '9') {
129 r += h - '0'; 127 r += h - '0';
130 } else { 128 } else {
131 r += h - 'a' + 10; 129 r += h - 'a' + 10;
132 } 130 }
133 131
134 r = r << 4; 132 r = r << 4;
135 133
136 if (l <= '9') { 134 if (l <= '9') {
137 r += l - '0'; 135 r += l - '0';
138 } else { 136 } else {
139 r += l - 'a' + 10; 137 r += l - 'a' + 10;
140 } 138 }
141 139
142 byteArray[i] = r; 140 byteArray[i] = r;
143 } 141 }
144 142
145 QImage image; 143 QImage image;
146 image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); 144 image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat);
147 145
148 Page* page = new Page(m_title, image.width(), image.height()); 146 Page* page = new Page(m_title, image.width(), image.height());
149 page->setLastModified(m_date); 147 page->setLastModified(m_date);
150 page->pixmap()->convertFromImage(image); 148 page->pixmap()->convertFromImage(image);
151 m_pages.append(page); 149 m_pages.append(page);
152 } 150 }
153 151
154 return true; 152 return true;
155} 153}
156 154
157DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) 155DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name)
158 : QScrollView(parent, name) 156 : QScrollView(parent, name)
159{ 157{
160 m_pDrawPad = drawPad; 158 m_pDrawPad = drawPad;
161 m_pages.setAutoDelete(true); 159 m_pages.setAutoDelete(true);
162 160
163 viewport()->setBackgroundMode(QWidget::NoBackground); 161 viewport()->setBackgroundMode(QWidget::NoBackground);
164} 162}
165 163
166DrawPadCanvas::~DrawPadCanvas() 164DrawPadCanvas::~DrawPadCanvas()
167{ 165{
168} 166}
169 167
170void DrawPadCanvas::load(QIODevice* ioDevice) 168void DrawPadCanvas::load(QIODevice* ioDevice)
171{ 169{
172 QTextStream textStream(ioDevice); 170 QTextStream textStream(ioDevice);
173 textStream.setCodec(QTextCodec::codecForName("UTF-8")); 171 textStream.setCodec(QTextCodec::codecForName("UTF-8"));
174 172
175 QXmlInputSource xmlInputSource(textStream); 173 QXmlInputSource xmlInputSource(textStream);
176 QXmlSimpleReader xmlSimpleReader; 174 QXmlSimpleReader xmlSimpleReader;
177 DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; 175 DrawPadCanvasXmlHandler drawPadCanvasXmlHandler;
178 176
179 xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); 177 xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler);
180 xmlSimpleReader.parse(xmlInputSource); 178 xmlSimpleReader.parse(xmlInputSource);
181 179
182 m_pages = drawPadCanvasXmlHandler.pages(); 180 m_pages = drawPadCanvasXmlHandler.pages();
183 181
184 if (m_pages.isEmpty()) { 182 if (m_pages.isEmpty()) {
185 m_pages.append(new Page("", 183 m_pages.append(new Page("",
186 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 184 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
187 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 185 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
188 m_pages.current()->pixmap()->fill(Qt::white); 186 m_pages.current()->pixmap()->fill(Qt::white);
189 } 187 }
190 188
191 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 189 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
192 viewport()->update(); 190 viewport()->update();
193 191
194 emit pagesChanged(); 192 emit pagesChanged();
195} 193}
196 194
197void DrawPadCanvas::initialPage() 195void DrawPadCanvas::initialPage()
198{ 196{
199 m_pages.append(new Page("", 197 m_pages.append(new Page("",
200 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 198 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
201 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 199 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
202 //236, 232)); no more fixed sizes 200 //236, 232)); no more fixed sizes
203 201
204 m_pages.current()->pixmap()->fill(Qt::white); 202 m_pages.current()->pixmap()->fill(Qt::white);
205 203
206 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 204 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
207 viewport()->update(); 205 viewport()->update();
208 206
209 emit pagesChanged(); 207 emit pagesChanged();
210} 208}
211 209
212void DrawPadCanvas::save(QIODevice* ioDevice) 210void DrawPadCanvas::save(QIODevice* ioDevice)
213{ 211{
214 QTextStream textStream(ioDevice); 212 QTextStream textStream(ioDevice);
215 textStream.setCodec(QTextCodec::codecForName("UTF-8")); 213 textStream.setCodec(QTextCodec::codecForName("UTF-8"));
216 214
217 textStream << "<drawpad>" << endl; 215 textStream << "<drawpad>" << endl;
218 textStream << " <images>" << endl; 216 textStream << " <images>" << endl;
219 217
220 QListIterator<Page> bufferIterator(m_pages); 218 QListIterator<Page> bufferIterator(m_pages);
221 219
222 for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { 220 for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) {
223 textStream << " <image>" << endl; 221 textStream << " <image>" << endl;
224 textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl; 222 textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl;
225 223
226 int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified()); 224 int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified());
227 textStream << " <date>" << intDate << "</date>" << endl; 225 textStream << " <date>" << intDate << "</date>" << endl;
228 226
229 QImage image = bufferIterator.current()->pixmap()->convertToImage(); 227 QImage image = bufferIterator.current()->pixmap()->convertToImage();
230 QByteArray byteArray; 228 QByteArray byteArray;
231 QBuffer buffer(byteArray); 229 QBuffer buffer(byteArray);
232 QImageIO imageIO(&buffer, "PNG"); 230 QImageIO imageIO(&buffer, "PNG");
233 231
234 buffer.open(IO_WriteOnly); 232 buffer.open(IO_WriteOnly);
235 imageIO.setImage(image); 233 imageIO.setImage(image);
236 imageIO.write(); 234 imageIO.write();
237 buffer.close(); 235 buffer.close();
238 236
239 textStream << " <data length=\"" << byteArray.size() << "\" format=\"PNG\">"; 237 textStream << " <data length=\"" << byteArray.size() << "\" format=\"PNG\">";
240 238
241 static const char hexchars[] = "0123456789abcdef"; 239 static const char hexchars[] = "0123456789abcdef";
242 240
243 for (int i = 0; i < (int)byteArray.size(); i++ ) { 241 for (int i = 0; i < (int)byteArray.size(); i++ ) {
244 uchar s = (uchar)byteArray[i]; 242 uchar s = (uchar)byteArray[i];
245 textStream << hexchars[s >> 4]; 243 textStream << hexchars[s >> 4];
246 textStream << hexchars[s & 0x0f]; 244 textStream << hexchars[s & 0x0f];
247 } 245 }
248 246
249 textStream << "</data>" << endl; 247 textStream << "</data>" << endl;
250 textStream << " </image>" << endl; 248 textStream << " </image>" << endl;
251 } 249 }
252 250
253 textStream << " </images>" << endl; 251 textStream << " </images>" << endl;
254 textStream << "</drawpad>"; 252 textStream << "</drawpad>";
255} 253}
256 254
257void DrawPadCanvas::importPage(const QString& fileName) 255void DrawPadCanvas::importPage(const QString& fileName)
258{ 256{
259 Page* importedPage = new Page(); 257 Page* importedPage = new Page();
260 258
261 importedPage->pixmap()->load(fileName); 259 importedPage->pixmap()->load(fileName);
262 m_pages.insert(m_pages.at() + 1, importedPage); 260 m_pages.insert(m_pages.at() + 1, importedPage);
263 261
264 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 262 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
265 viewport()->update(); 263 viewport()->update();
266 264
267 emit pagesChanged(); 265 emit pagesChanged();
268} 266}
269 267
270void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) 268void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format)
271{ 269{
272 if (fromPage == toPage) { 270 if (fromPage == toPage) {
273 DocLnk docLnk; 271 DocLnk docLnk;
274 MimeType mimeType(format); 272 MimeType mimeType(format);
275 273
276 docLnk.setName(name); 274 docLnk.setName(name);
277 docLnk.setType(mimeType.id()); 275 docLnk.setType(mimeType.id());
278 276
279 FileManager fileManager; 277 FileManager fileManager;
280 QIODevice* ioDevice = fileManager.saveFile(docLnk); 278 QIODevice* ioDevice = fileManager.saveFile(docLnk);
281 QImageIO imageIO(ioDevice, format); 279 QImageIO imageIO(ioDevice, format);
282 280
283 QImage image = m_pages.current()->pixmap()->convertToImage(); 281 QImage image = m_pages.current()->pixmap()->convertToImage();
284 imageIO.setImage(image); 282 imageIO.setImage(image);
diff --git a/noncore/graphics/drawpad/ellipsetool.cpp b/noncore/graphics/drawpad/ellipsetool.cpp
index 0cdb731..2173c97 100644
--- a/noncore/graphics/drawpad/ellipsetool.cpp
+++ b/noncore/graphics/drawpad/ellipsetool.cpp
@@ -1,81 +1,80 @@
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>
21 20
22EllipseTool::EllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) 21EllipseTool::EllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : ShapeTool(drawPad, drawPadCanvas) 22 : ShapeTool(drawPad, drawPadCanvas)
24{ 23{
25} 24}
26 25
27EllipseTool::~EllipseTool() 26EllipseTool::~EllipseTool()
28{ 27{
29} 28}
30 29
31void EllipseTool::drawFinalShape(QPainter& p) 30void EllipseTool::drawFinalShape(QPainter& p)
32{ 31{
33 p.setRasterOp(Qt::NotROP); 32 p.setRasterOp(Qt::NotROP);
34 p.drawRect(QRect(m_polyline[2], m_polyline[0])); 33 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
35 p.setRasterOp(Qt::CopyROP); 34 p.setRasterOp(Qt::CopyROP);
36 35
37 if (m_pDrawPad->antiAliasing()) { 36 if (m_pDrawPad->antiAliasing()) {
38 QRect r = m_polyline.boundingRect(); 37 QRect r = m_polyline.boundingRect();
39 r = r.normalize(); 38 r = r.normalize();
40 r.setLeft(r.left() - m_pDrawPad->pen().width()); 39 r.setLeft(r.left() - m_pDrawPad->pen().width());
41 r.setTop(r.top() - m_pDrawPad->pen().width()); 40 r.setTop(r.top() - m_pDrawPad->pen().width());
42 r.setRight(r.right() + m_pDrawPad->pen().width()); 41 r.setRight(r.right() + m_pDrawPad->pen().width());
43 r.setBottom(r.bottom() + m_pDrawPad->pen().width()); 42 r.setBottom(r.bottom() + m_pDrawPad->pen().width());
44 43
45 QPixmap areaPixmap(r.width(), r.height()); 44 QPixmap areaPixmap(r.width(), r.height());
46 bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); 45 bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
47 46
48 QImage areaImage = areaPixmap.convertToImage(); 47 QImage areaImage = areaPixmap.convertToImage();
49 QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); 48 QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
50 49
51 QPixmap bigAreaPixmap; 50 QPixmap bigAreaPixmap;
52 bigAreaPixmap.convertFromImage(bigAreaImage); 51 bigAreaPixmap.convertFromImage(bigAreaImage);
53 52
54 QPen bigAreaPen = m_pDrawPad->pen(); 53 QPen bigAreaPen = m_pDrawPad->pen();
55 bigAreaPen.setWidth(bigAreaPen.width() * 3); 54 bigAreaPen.setWidth(bigAreaPen.width() * 3);
56 55
57 QPainter bigAreaPainter; 56 QPainter bigAreaPainter;
58 bigAreaPainter.begin(&bigAreaPixmap); 57 bigAreaPainter.begin(&bigAreaPixmap);
59 bigAreaPainter.setPen(bigAreaPen); 58 bigAreaPainter.setPen(bigAreaPen);
60 bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, 59 bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1,
61 bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), 60 bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1),
62 bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); 61 bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1)));
63 bigAreaPainter.end(); 62 bigAreaPainter.end();
64 63
65 bigAreaImage = bigAreaPixmap.convertToImage(); 64 bigAreaImage = bigAreaPixmap.convertToImage();
66 areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); 65 areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
67 areaPixmap.convertFromImage(areaImage); 66 areaPixmap.convertFromImage(areaImage);
68 67
69 p.drawPixmap(r.x(), r.y(), areaPixmap); 68 p.drawPixmap(r.x(), r.y(), areaPixmap);
70 } else { 69 } else {
71 p.setPen(m_pDrawPad->pen()); 70 p.setPen(m_pDrawPad->pen());
72 p.drawEllipse(QRect(m_polyline[2], m_polyline[0])); 71 p.drawEllipse(QRect(m_polyline[2], m_polyline[0]));
73 } 72 }
74} 73}
75 74
76void EllipseTool::drawTemporaryShape(QPainter& p) 75void EllipseTool::drawTemporaryShape(QPainter& p)
77{ 76{
78 p.setRasterOp(Qt::NotROP); 77 p.setRasterOp(Qt::NotROP);
79 p.drawRect(QRect(m_polyline[2], m_polyline[1])); 78 p.drawRect(QRect(m_polyline[2], m_polyline[1]));
80 p.drawRect(QRect(m_polyline[2], m_polyline[0])); 79 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
81} 80}
diff --git a/noncore/graphics/drawpad/erasetool.cpp b/noncore/graphics/drawpad/erasetool.cpp
index 2326da5..5d123c4 100644
--- a/noncore/graphics/drawpad/erasetool.cpp
+++ b/noncore/graphics/drawpad/erasetool.cpp
@@ -1,76 +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 "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#include "page.h" 18#include "page.h"
19 19
20#include <qpainter.h>
21 20
22EraseTool::EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) 21EraseTool::EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : Tool(drawPad, drawPadCanvas) 22 : Tool(drawPad, drawPadCanvas)
24{ 23{
25 m_mousePressed = false; 24 m_mousePressed = false;
26 m_polyline.resize(3); 25 m_polyline.resize(3);
27} 26}
28 27
29EraseTool::~EraseTool() 28EraseTool::~EraseTool()
30{ 29{
31} 30}
32 31
33void EraseTool::mousePressEvent(QMouseEvent* e) 32void EraseTool::mousePressEvent(QMouseEvent* e)
34{ 33{
35 m_pDrawPadCanvas->backupPage(); 34 m_pDrawPadCanvas->backupPage();
36 35
37 m_mousePressed = true; 36 m_mousePressed = true;
38 m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); 37 m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
39} 38}
40 39
41void EraseTool::mouseReleaseEvent(QMouseEvent* e) 40void EraseTool::mouseReleaseEvent(QMouseEvent* e)
42{ 41{
43 Q_UNUSED(e) 42 Q_UNUSED(e)
44 43
45 m_mousePressed = false; 44 m_mousePressed = false;
46} 45}
47 46
48void EraseTool::mouseMoveEvent(QMouseEvent* e) 47void EraseTool::mouseMoveEvent(QMouseEvent* e)
49{ 48{
50 if (m_mousePressed) { 49 if (m_mousePressed) {
51 QPainter painter; 50 QPainter painter;
52 QPen pen(Qt::white, m_pDrawPad->pen().width()); 51 QPen pen(Qt::white, m_pDrawPad->pen().width());
53 painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); 52 painter.begin(m_pDrawPadCanvas->currentPage()->pixmap());
54 painter.setPen(pen); 53 painter.setPen(pen);
55 m_polyline[2] = m_polyline[1]; 54 m_polyline[2] = m_polyline[1];
56 m_polyline[1] = m_polyline[0]; 55 m_polyline[1] = m_polyline[0];
57 m_polyline[0] = e->pos(); 56 m_polyline[0] = e->pos();
58 painter.drawPolyline(m_polyline); 57 painter.drawPolyline(m_polyline);
59 painter.end(); 58 painter.end();
60 59
61 QRect r = m_polyline.boundingRect(); 60 QRect r = m_polyline.boundingRect();
62 r = r.normalize(); 61 r = r.normalize();
63 r.setLeft(r.left() - m_pDrawPad->pen().width()); 62 r.setLeft(r.left() - m_pDrawPad->pen().width());
64 r.setTop(r.top() - m_pDrawPad->pen().width()); 63 r.setTop(r.top() - m_pDrawPad->pen().width());
65 r.setRight(r.right() + m_pDrawPad->pen().width()); 64 r.setRight(r.right() + m_pDrawPad->pen().width());
66 r.setBottom(r.bottom() + m_pDrawPad->pen().width()); 65 r.setBottom(r.bottom() + m_pDrawPad->pen().width());
67 66
68 QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), 67 QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()),
69 m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); 68 m_pDrawPadCanvas->contentsToViewport(r.bottomRight()));
70 69
71 bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), 70 bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(),
72 m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); 71 m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height());
73 72
74 m_pDrawPadCanvas->viewport()->update(viewportRect); 73 m_pDrawPadCanvas->viewport()->update(viewportRect);
75 } 74 }
76} 75}
diff --git a/noncore/graphics/drawpad/exportdialog.cpp b/noncore/graphics/drawpad/exportdialog.cpp
index adbd612..d63f428 100644
--- a/noncore/graphics/drawpad/exportdialog.cpp
+++ b/noncore/graphics/drawpad/exportdialog.cpp
@@ -1,176 +1,175 @@
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 "exportdialog.h" 14#include "exportdialog.h"
15 15
16#include <opie/ofileselector.h> 16#include <opie/ofileselector.h>
17 17
18#include <qbuttongroup.h> 18#include <qbuttongroup.h>
19#include <qcombobox.h> 19#include <qcombobox.h>
20#include <qgroupbox.h>
21#include <qimage.h> 20#include <qimage.h>
22#include <qlabel.h> 21#include <qlabel.h>
23#include <qlayout.h> 22#include <qlayout.h>
24#include <qlineedit.h> 23#include <qlineedit.h>
25#include <qradiobutton.h> 24#include <qradiobutton.h>
26#include <qspinbox.h> 25#include <qspinbox.h>
27 26
28#include <stdlib.h> 27#include <stdlib.h>
29 28
30ExportDialog::ExportDialog(uint pageAt, uint pageCount, QWidget* parent, const char* name) 29ExportDialog::ExportDialog(uint pageAt, uint pageCount, QWidget* parent, const char* name)
31 : QDialog(parent, name, true) 30 : QDialog(parent, name, true)
32{ 31{
33 setCaption(tr("DrawPad - Export")); 32 setCaption(tr("DrawPad - Export"));
34 33
35 m_pageAt = pageAt; 34 m_pageAt = pageAt;
36 m_pageCount = pageCount; 35 m_pageCount = pageCount;
37 36
38 QButtonGroup* selectionButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Page Selection"), this); 37 QButtonGroup* selectionButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Page Selection"), this);
39 connect(selectionButtonGroup, SIGNAL(pressed(int)), this, SLOT(selectionChanged(int))); 38 connect(selectionButtonGroup, SIGNAL(pressed(int)), this, SLOT(selectionChanged(int)));
40 39
41 QRadioButton* selectAllRadioButton = new QRadioButton(tr("All"), selectionButtonGroup); 40 QRadioButton* selectAllRadioButton = new QRadioButton(tr("All"), selectionButtonGroup);
42 QRadioButton* selectCurrentRadioButton = new QRadioButton(tr("Current"), selectionButtonGroup); 41 QRadioButton* selectCurrentRadioButton = new QRadioButton(tr("Current"), selectionButtonGroup);
43 QRadioButton* selectRangeRadioButton = new QRadioButton(tr("Range"), selectionButtonGroup); 42 QRadioButton* selectRangeRadioButton = new QRadioButton(tr("Range"), selectionButtonGroup);
44 43
45 QLabel* toLabel = new QLabel(tr("To:"), selectionButtonGroup); 44 QLabel* toLabel = new QLabel(tr("To:"), selectionButtonGroup);
46 45
47 m_pFromPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup); 46 m_pFromPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
48 connect(m_pFromPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fromPageChanged(int))); 47 connect(m_pFromPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fromPageChanged(int)));
49 48
50 m_pToPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup); 49 m_pToPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
51 connect(m_pToPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(toPageChanged(int))); 50 connect(m_pToPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(toPageChanged(int)));
52 51
53 selectionButtonGroup->setButton(1); 52 selectionButtonGroup->setButton(1);
54 selectionChanged(1); 53 selectionChanged(1);
55 54
56 m_pFromPageSpinBox->setValue(pageAt); 55 m_pFromPageSpinBox->setValue(pageAt);
57 m_pToPageSpinBox->setValue(pageAt); 56 m_pToPageSpinBox->setValue(pageAt);
58 57
59 QGroupBox* exportGroupBox = new QGroupBox(0, Qt::Vertical, tr("Export As"), this); 58 QGroupBox* exportGroupBox = new QGroupBox(0, Qt::Vertical, tr("Export As"), this);
60 59
61 QLabel* nameLabel = new QLabel(tr("Name:"), exportGroupBox); 60 QLabel* nameLabel = new QLabel(tr("Name:"), exportGroupBox);
62 QLabel* formatLabel = new QLabel(tr("Format:"), exportGroupBox); 61 QLabel* formatLabel = new QLabel(tr("Format:"), exportGroupBox);
63 62
64 m_pNameLineEdit = new QLineEdit(exportGroupBox); 63 m_pNameLineEdit = new QLineEdit(exportGroupBox);
65 64
66 m_pFormatComboBox = new QComboBox(exportGroupBox); 65 m_pFormatComboBox = new QComboBox(exportGroupBox);
67 m_pFormatComboBox->insertStrList(QImageIO::outputFormats()); 66 m_pFormatComboBox->insertStrList(QImageIO::outputFormats());
68 67
69 MimeTypes types; types.insert( tr("All Images"), "image/*" ); 68 MimeTypes types; types.insert( tr("All Images"), "image/*" );
70 OFileSelector* fileSelector = new OFileSelector(this, OFileSelector::FileSelector, 69 OFileSelector* fileSelector = new OFileSelector(this, OFileSelector::FileSelector,
71 OFileSelector::Normal, 70 OFileSelector::Normal,
72 QString::null, QString::null, 71 QString::null, QString::null,
73 types ); 72 types );
74 fileSelector->setNameVisible( false ); 73 fileSelector->setNameVisible( false );
75 74
76 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 75 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
77 selectionButtonGroup->layout()->setSpacing(4); 76 selectionButtonGroup->layout()->setSpacing(4);
78 exportGroupBox->layout()->setSpacing(4); 77 exportGroupBox->layout()->setSpacing(4);
79 QGridLayout* selectionLayout = new QGridLayout(selectionButtonGroup->layout(), 2, 2); 78 QGridLayout* selectionLayout = new QGridLayout(selectionButtonGroup->layout(), 2, 2);
80 QHBoxLayout* rangeLayout = new QHBoxLayout(); 79 QHBoxLayout* rangeLayout = new QHBoxLayout();
81 QGridLayout* exportLayout = new QGridLayout(exportGroupBox->layout(), 2, 2); 80 QGridLayout* exportLayout = new QGridLayout(exportGroupBox->layout(), 2, 2);
82 81
83 selectionLayout->addWidget(selectAllRadioButton, 0, 0); 82 selectionLayout->addWidget(selectAllRadioButton, 0, 0);
84 selectionLayout->addWidget(selectCurrentRadioButton, 1, 0); 83 selectionLayout->addWidget(selectCurrentRadioButton, 1, 0);
85 selectionLayout->addWidget(selectRangeRadioButton, 0, 1); 84 selectionLayout->addWidget(selectRangeRadioButton, 0, 1);
86 selectionLayout->addLayout(rangeLayout, 1, 1); 85 selectionLayout->addLayout(rangeLayout, 1, 1);
87 86
88 rangeLayout->addWidget(m_pFromPageSpinBox); 87 rangeLayout->addWidget(m_pFromPageSpinBox);
89 rangeLayout->addWidget(toLabel); 88 rangeLayout->addWidget(toLabel);
90 rangeLayout->addWidget(m_pToPageSpinBox); 89 rangeLayout->addWidget(m_pToPageSpinBox);
91 90
92 exportLayout->addWidget(nameLabel, 0, 0); 91 exportLayout->addWidget(nameLabel, 0, 0);
93 exportLayout->addWidget(formatLabel, 1, 0); 92 exportLayout->addWidget(formatLabel, 1, 0);
94 93
95 exportLayout->addWidget(m_pNameLineEdit, 0, 1); 94 exportLayout->addWidget(m_pNameLineEdit, 0, 1);
96 exportLayout->addWidget(m_pFormatComboBox, 1, 1); 95 exportLayout->addWidget(m_pFormatComboBox, 1, 1);
97 96
98 exportLayout->setColStretch(1, 1); 97 exportLayout->setColStretch(1, 1);
99 98
100 mainLayout->addWidget(selectionButtonGroup); 99 mainLayout->addWidget(selectionButtonGroup);
101 mainLayout->addWidget(exportGroupBox); 100 mainLayout->addWidget(exportGroupBox);
102 mainLayout->addWidget(fileSelector); 101 mainLayout->addWidget(fileSelector);
103 102
104 m_pNameLineEdit->setFocus(); 103 m_pNameLineEdit->setFocus();
105} 104}
106 105
107ExportDialog::~ExportDialog() 106ExportDialog::~ExportDialog()
108{ 107{
109} 108}
110 109
111uint ExportDialog::selectedFromPage() 110uint ExportDialog::selectedFromPage()
112{ 111{
113 return (m_pFromPageSpinBox->value()); 112 return (m_pFromPageSpinBox->value());
114} 113}
115 114
116uint ExportDialog::selectedToPage() 115uint ExportDialog::selectedToPage()
117{ 116{
118 return (m_pToPageSpinBox->value()); 117 return (m_pToPageSpinBox->value());
119} 118}
120 119
121QString ExportDialog::selectedName() 120QString ExportDialog::selectedName()
122{ 121{
123 return (m_pNameLineEdit->text()); 122 return (m_pNameLineEdit->text());
124} 123}
125 124
126QString ExportDialog::selectedFormat() 125QString ExportDialog::selectedFormat()
127{ 126{
128 return (m_pFormatComboBox->currentText()); 127 return (m_pFormatComboBox->currentText());
129} 128}
130 129
131void ExportDialog::accept() 130void ExportDialog::accept()
132{ 131{
133 if (!(m_pNameLineEdit->text().isEmpty())) { 132 if (!(m_pNameLineEdit->text().isEmpty())) {
134 QDialog::accept(); 133 QDialog::accept();
135 } 134 }
136} 135}
137 136
138void ExportDialog::selectionChanged(int id) 137void ExportDialog::selectionChanged(int id)
139{ 138{
140 switch (id) { 139 switch (id) {
141 case 0: 140 case 0:
142 m_pFromPageSpinBox->setValue(1); 141 m_pFromPageSpinBox->setValue(1);
143 m_pToPageSpinBox->setValue(m_pageCount); 142 m_pToPageSpinBox->setValue(m_pageCount);
144 143
145 m_pFromPageSpinBox->setEnabled(false); 144 m_pFromPageSpinBox->setEnabled(false);
146 m_pToPageSpinBox->setEnabled(false); 145 m_pToPageSpinBox->setEnabled(false);
147 break; 146 break;
148 case 1: 147 case 1:
149 m_pFromPageSpinBox->setValue(m_pageAt); 148 m_pFromPageSpinBox->setValue(m_pageAt);
150 m_pToPageSpinBox->setValue(m_pageAt); 149 m_pToPageSpinBox->setValue(m_pageAt);
151 150
152 m_pFromPageSpinBox->setEnabled(false); 151 m_pFromPageSpinBox->setEnabled(false);
153 m_pToPageSpinBox->setEnabled(false); 152 m_pToPageSpinBox->setEnabled(false);
154 break; 153 break;
155 case 2: 154 case 2:
156 m_pFromPageSpinBox->setEnabled(true); 155 m_pFromPageSpinBox->setEnabled(true);
157 m_pToPageSpinBox->setEnabled(true); 156 m_pToPageSpinBox->setEnabled(true);
158 break; 157 break;
159 default: 158 default:
160 break; 159 break;
161 } 160 }
162} 161}
163 162
164void ExportDialog::fromPageChanged(int value) 163void ExportDialog::fromPageChanged(int value)
165{ 164{
166 if (m_pToPageSpinBox->value() < value) { 165 if (m_pToPageSpinBox->value() < value) {
167 m_pToPageSpinBox->setValue(value); 166 m_pToPageSpinBox->setValue(value);
168 } 167 }
169} 168}
170 169
171void ExportDialog::toPageChanged(int value) 170void ExportDialog::toPageChanged(int value)
172{ 171{
173 if (m_pFromPageSpinBox->value() > value) { 172 if (m_pFromPageSpinBox->value() > value) {
174 m_pFromPageSpinBox->setValue(value); 173 m_pFromPageSpinBox->setValue(value);
175 } 174 }
176} 175}
diff --git a/noncore/graphics/drawpad/filledellipsetool.cpp b/noncore/graphics/drawpad/filledellipsetool.cpp
index 6b5bbc6..41b8571 100644
--- a/noncore/graphics/drawpad/filledellipsetool.cpp
+++ b/noncore/graphics/drawpad/filledellipsetool.cpp
@@ -1,83 +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 "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>
21 20
22FilledEllipseTool::FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) 21FilledEllipseTool::FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : ShapeTool(drawPad, drawPadCanvas) 22 : ShapeTool(drawPad, drawPadCanvas)
24{ 23{
25} 24}
26 25
27FilledEllipseTool::~FilledEllipseTool() 26FilledEllipseTool::~FilledEllipseTool()
28{ 27{
29} 28}
30 29
31void FilledEllipseTool::drawFinalShape(QPainter& p) 30void FilledEllipseTool::drawFinalShape(QPainter& p)
32{ 31{
33 p.setRasterOp(Qt::NotROP); 32 p.setRasterOp(Qt::NotROP);
34 p.drawRect(QRect(m_polyline[2], m_polyline[0])); 33 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
35 p.setRasterOp(Qt::CopyROP); 34 p.setRasterOp(Qt::CopyROP);
36 35
37 if (m_pDrawPad->antiAliasing()) { 36 if (m_pDrawPad->antiAliasing()) {
38 QRect r = m_polyline.boundingRect(); 37 QRect r = m_polyline.boundingRect();
39 r = r.normalize(); 38 r = r.normalize();
40 r.setLeft(r.left() - m_pDrawPad->pen().width()); 39 r.setLeft(r.left() - m_pDrawPad->pen().width());
41 r.setTop(r.top() - m_pDrawPad->pen().width()); 40 r.setTop(r.top() - m_pDrawPad->pen().width());
42 r.setRight(r.right() + m_pDrawPad->pen().width()); 41 r.setRight(r.right() + m_pDrawPad->pen().width());
43 r.setBottom(r.bottom() + m_pDrawPad->pen().width()); 42 r.setBottom(r.bottom() + m_pDrawPad->pen().width());
44 43
45 QPixmap areaPixmap(r.width(), r.height()); 44 QPixmap areaPixmap(r.width(), r.height());
46 bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); 45 bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
47 46
48 QImage areaImage = areaPixmap.convertToImage(); 47 QImage areaImage = areaPixmap.convertToImage();
49 QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); 48 QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
50 49
51 QPixmap bigAreaPixmap; 50 QPixmap bigAreaPixmap;
52 bigAreaPixmap.convertFromImage(bigAreaImage); 51 bigAreaPixmap.convertFromImage(bigAreaImage);
53 52
54 QPen bigAreaPen = m_pDrawPad->pen(); 53 QPen bigAreaPen = m_pDrawPad->pen();
55 bigAreaPen.setWidth(bigAreaPen.width() * 3); 54 bigAreaPen.setWidth(bigAreaPen.width() * 3);
56 55
57 QPainter bigAreaPainter; 56 QPainter bigAreaPainter;
58 bigAreaPainter.begin(&bigAreaPixmap); 57 bigAreaPainter.begin(&bigAreaPixmap);
59 bigAreaPainter.setPen(bigAreaPen); 58 bigAreaPainter.setPen(bigAreaPen);
60 bigAreaPainter.setBrush(m_pDrawPad->brush()); 59 bigAreaPainter.setBrush(m_pDrawPad->brush());
61 bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, 60 bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1,
62 bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), 61 bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1),
63 bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); 62 bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1)));
64 bigAreaPainter.end(); 63 bigAreaPainter.end();
65 64
66 bigAreaImage = bigAreaPixmap.convertToImage(); 65 bigAreaImage = bigAreaPixmap.convertToImage();
67 areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); 66 areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
68 areaPixmap.convertFromImage(areaImage); 67 areaPixmap.convertFromImage(areaImage);
69 68
70 p.drawPixmap(r.x(), r.y(), areaPixmap); 69 p.drawPixmap(r.x(), r.y(), areaPixmap);
71 } else { 70 } else {
72 p.setPen(m_pDrawPad->pen()); 71 p.setPen(m_pDrawPad->pen());
73 p.setBrush(m_pDrawPad->brush()); 72 p.setBrush(m_pDrawPad->brush());
74 p.drawEllipse(QRect(m_polyline[2], m_polyline[0])); 73 p.drawEllipse(QRect(m_polyline[2], m_polyline[0]));
75 } 74 }
76} 75}
77 76
78void FilledEllipseTool::drawTemporaryShape(QPainter& p) 77void FilledEllipseTool::drawTemporaryShape(QPainter& p)
79{ 78{
80 p.setRasterOp(Qt::NotROP); 79 p.setRasterOp(Qt::NotROP);
81 p.drawRect(QRect(m_polyline[2], m_polyline[1])); 80 p.drawRect(QRect(m_polyline[2], m_polyline[1]));
82 p.drawRect(QRect(m_polyline[2], m_polyline[0])); 81 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
83} 82}
diff --git a/noncore/graphics/drawpad/filltool.cpp b/noncore/graphics/drawpad/filltool.cpp
index b47aa60..fedf3a5 100644
--- a/noncore/graphics/drawpad/filltool.cpp
+++ b/noncore/graphics/drawpad/filltool.cpp
@@ -1,165 +1,164 @@
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#include "page.h" 18#include "page.h"
19 19
20#include <qimage.h>
21 20
22const int FILL_THRESHOLD = 65536; 21const int FILL_THRESHOLD = 65536;
23 22
24FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) 23FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
25 : Tool(drawPad, drawPadCanvas) 24 : Tool(drawPad, drawPadCanvas)
26{ 25{
27} 26}
28 27
29FillTool::~FillTool() 28FillTool::~FillTool()
30{ 29{
31} 30}
32 31
33void FillTool::mousePressEvent(QMouseEvent* e) 32void FillTool::mousePressEvent(QMouseEvent* e)
34{ 33{
35 int x = e->x(); 34 int x = e->x();
36 int y = e->y(); 35 int y = e->y();
37 36
38 m_image = m_pDrawPadCanvas->currentPage()->pixmap()->convertToImage(); 37 m_image = m_pDrawPadCanvas->currentPage()->pixmap()->convertToImage();
39 38
40 if (m_image.depth() <= 8) { 39 if (m_image.depth() <= 8) {
41 m_image = m_image.convertDepth(32); 40 m_image = m_image.convertDepth(32);
42 } 41 }
43 42
44 m_fillRgb = m_pDrawPad->brush().color().rgb(); 43 m_fillRgb = m_pDrawPad->brush().color().rgb();
45 m_oldRgb = m_image.pixel(x, y); 44 m_oldRgb = m_image.pixel(x, y);
46 45
47 if (m_oldRgb != m_fillRgb) { 46 if (m_oldRgb != m_fillRgb) {
48 m_pDrawPadCanvas->backupPage(); 47 m_pDrawPadCanvas->backupPage();
49 48
50 if (m_pDrawPad->antiAliasing()) { 49 if (m_pDrawPad->antiAliasing()) {
51 m_mask.create(m_image.width(), m_image.height(), 8, 2); 50 m_mask.create(m_image.width(), m_image.height(), 8, 2);
52 m_mask.fill(0); 51 m_mask.fill(0);
53 52
54 fillMaskLine(x, y); 53 fillMaskLine(x, y);
55 54
56 for (int i = 0; i < m_image.width(); i++) { 55 for (int i = 0; i < m_image.width(); i++) {
57 for (int j = 0; j < m_image.height(); j++) { 56 for (int j = 0; j < m_image.height(); j++) {
58 if (m_mask.pixelIndex(i, j) == 1) { 57 if (m_mask.pixelIndex(i, j) == 1) {
59 setInterpolatedPixel(i, j); 58 setInterpolatedPixel(i, j);
60 } 59 }
61 } 60 }
62 } 61 }
63 62
64 } else { 63 } else {
65 fillLine(x, y); 64 fillLine(x, y);
66 } 65 }
67 66
68 m_pDrawPadCanvas->currentPage()->pixmap()->convertFromImage(m_image); 67 m_pDrawPadCanvas->currentPage()->pixmap()->convertFromImage(m_image);
69 m_pDrawPadCanvas->viewport()->update(); 68 m_pDrawPadCanvas->viewport()->update();
70 } 69 }
71} 70}
72 71
73void FillTool::mouseReleaseEvent(QMouseEvent* e) 72void FillTool::mouseReleaseEvent(QMouseEvent* e)
74{ 73{
75 Q_UNUSED(e) 74 Q_UNUSED(e)
76} 75}
77 76
78void FillTool::mouseMoveEvent(QMouseEvent* e) 77void FillTool::mouseMoveEvent(QMouseEvent* e)
79{ 78{
80 Q_UNUSED(e) 79 Q_UNUSED(e)
81} 80}
82 81
83void FillTool::fillLine(int x, int y) 82void FillTool::fillLine(int x, int y)
84{ 83{
85 if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) { 84 if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) {
86 if (m_image.pixel(x, y) == m_oldRgb) { 85 if (m_image.pixel(x, y) == m_oldRgb) {
87 int x1, x2; 86 int x1, x2;
88 87
89 x1 = x - 1; 88 x1 = x - 1;
90 x2 = x + 1; 89 x2 = x + 1;
91 90
92 while ((x1 >= 0) && (m_image.pixel(x1, y) == m_oldRgb)) { 91 while ((x1 >= 0) && (m_image.pixel(x1, y) == m_oldRgb)) {
93 x1--; 92 x1--;
94 } 93 }
95 94
96 while ((x2 < m_image.width()) && (m_image.pixel(x2, y) == m_oldRgb)) { 95 while ((x2 < m_image.width()) && (m_image.pixel(x2, y) == m_oldRgb)) {
97 x2++; 96 x2++;
98 } 97 }
99 98
100 for (int i = x1 + 1; i < x2; i++) { 99 for (int i = x1 + 1; i < x2; i++) {
101 m_image.setPixel(i, y, m_fillRgb); 100 m_image.setPixel(i, y, m_fillRgb);
102 } 101 }
103 102
104 for (int i = x1 + 1; i < x2; i++) { 103 for (int i = x1 + 1; i < x2; i++) {
105 fillLine(i, y - 1); 104 fillLine(i, y - 1);
106 } 105 }
107 106
108 for (int i = x1 + 1; i < x2; i++) { 107 for (int i = x1 + 1; i < x2; i++) {
109 fillLine(i, y + 1); 108 fillLine(i, y + 1);
110 } 109 }
111 } 110 }
112 } 111 }
113} 112}
114 113
115void FillTool::fillMaskLine(int x, int y) 114void FillTool::fillMaskLine(int x, int y)
116{ 115{
117 if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) { 116 if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) {
118 if (m_mask.pixelIndex(x, y) == 0) { 117 if (m_mask.pixelIndex(x, y) == 0) {
119 if (rgbDistance(m_image.pixel(x, y), m_oldRgb) < FILL_THRESHOLD) { 118 if (rgbDistance(m_image.pixel(x, y), m_oldRgb) < FILL_THRESHOLD) {
120 int x1, x2; 119 int x1, x2;
121 120
122 x1 = x - 1; 121 x1 = x - 1;
123 x2 = x + 1; 122 x2 = x + 1;
124 123
125 while ((x1 >= 0) && (rgbDistance(m_image.pixel(x1, y), m_oldRgb) < FILL_THRESHOLD)) { 124 while ((x1 >= 0) && (rgbDistance(m_image.pixel(x1, y), m_oldRgb) < FILL_THRESHOLD)) {
126 x1--; 125 x1--;
127 } 126 }
128 127
129 while ((x2 < m_image.width()) && (rgbDistance(m_image.pixel(x2, y), m_oldRgb) < FILL_THRESHOLD)) { 128 while ((x2 < m_image.width()) && (rgbDistance(m_image.pixel(x2, y), m_oldRgb) < FILL_THRESHOLD)) {
130 x2++; 129 x2++;
131 } 130 }
132 131
133 for (int i = x1 + 1; i < x2; i++) { 132 for (int i = x1 + 1; i < x2; i++) {
134 m_mask.setPixel(i, y, 1); 133 m_mask.setPixel(i, y, 1);
135 } 134 }
136 135
137 for (int i = x1 + 1; i < x2; i++) { 136 for (int i = x1 + 1; i < x2; i++) {
138 fillMaskLine(i, y - 1); 137 fillMaskLine(i, y - 1);
139 } 138 }
140 139
141 for (int i = x1 + 1; i < x2; i++) { 140 for (int i = x1 + 1; i < x2; i++) {
142 fillMaskLine(i, y + 1); 141 fillMaskLine(i, y + 1);
143 } 142 }
144 } 143 }
145 } 144 }
146 } 145 }
147} 146}
148 147
149void FillTool::setInterpolatedPixel(int x, int y) 148void FillTool::setInterpolatedPixel(int x, int y)
150{ 149{
151 int fillRed = QMIN(QMAX(qRed(m_fillRgb) + qRed(m_image.pixel(x, y)) - qRed(m_oldRgb), 0), 255); 150 int fillRed = QMIN(QMAX(qRed(m_fillRgb) + qRed(m_image.pixel(x, y)) - qRed(m_oldRgb), 0), 255);
152 int fillGreen = QMIN(QMAX(qGreen(m_fillRgb) + qGreen(m_image.pixel(x, y)) - qGreen(m_oldRgb), 0), 255); 151 int fillGreen = QMIN(QMAX(qGreen(m_fillRgb) + qGreen(m_image.pixel(x, y)) - qGreen(m_oldRgb), 0), 255);
153 int fillBlue = QMIN(QMAX(qBlue(m_fillRgb) + qBlue(m_image.pixel(x, y)) - qBlue(m_oldRgb), 0), 255); 152 int fillBlue = QMIN(QMAX(qBlue(m_fillRgb) + qBlue(m_image.pixel(x, y)) - qBlue(m_oldRgb), 0), 255);
154 153
155 m_image.setPixel(x, y, qRgb(fillRed, fillGreen, fillBlue)); 154 m_image.setPixel(x, y, qRgb(fillRed, fillGreen, fillBlue));
156} 155}
157 156
158int FillTool::rgbDistance(QRgb rgb1, QRgb rgb2) 157int FillTool::rgbDistance(QRgb rgb1, QRgb rgb2)
159{ 158{
160 int redDistance = qRed(rgb2) - qRed(rgb1); 159 int redDistance = qRed(rgb2) - qRed(rgb1);
161 int greenDistance = qGreen(rgb2) - qGreen(rgb1); 160 int greenDistance = qGreen(rgb2) - qGreen(rgb1);
162 int blueDistance = qBlue(rgb2) - qBlue(rgb1); 161 int blueDistance = qBlue(rgb2) - qBlue(rgb1);
163 162
164 return (redDistance * redDistance + greenDistance * greenDistance + blueDistance * blueDistance); 163 return (redDistance * redDistance + greenDistance * greenDistance + blueDistance * blueDistance);
165} 164}
diff --git a/noncore/graphics/drawpad/importdialog.cpp b/noncore/graphics/drawpad/importdialog.cpp
index 9a59a20..ce2e7ee 100644
--- a/noncore/graphics/drawpad/importdialog.cpp
+++ b/noncore/graphics/drawpad/importdialog.cpp
@@ -1,117 +1,116 @@
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 "importdialog.h" 14#include "importdialog.h"
15 15
16#include <qpe/applnk.h>
17#include <opie/ofileselector.h> 16#include <opie/ofileselector.h>
18 17
19#include <qcheckbox.h> 18#include <qcheckbox.h>
20#include <qimage.h> 19#include <qimage.h>
21#include <qlabel.h> 20#include <qlabel.h>
22#include <qlayout.h> 21#include <qlayout.h>
23#include <qpushbutton.h> 22#include <qpushbutton.h>
24 23
25ImportDialog::ImportDialog(QWidget* parent, const char* name) 24ImportDialog::ImportDialog(QWidget* parent, const char* name)
26 : QDialog(parent, name, true) 25 : QDialog(parent, name, true)
27{ 26{
28 setCaption(tr("DrawPad - Import")); 27 setCaption(tr("DrawPad - Import"));
29 28
30 MimeTypes types; types.insert( tr("All images"),"image/*" ); 29 MimeTypes types; types.insert( tr("All images"),"image/*" );
31 m_pFileSelector = new OFileSelector(this, 30 m_pFileSelector = new OFileSelector(this,
32 OFileSelector::FileSelector, 31 OFileSelector::FileSelector,
33 OFileSelector::Normal, 32 OFileSelector::Normal,
34 QString::null, 33 QString::null,
35 QString::null, types ); 34 QString::null, types );
36 m_pFileSelector->setNameVisible( false ); 35 m_pFileSelector->setNameVisible( false );
37 connect(m_pFileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(fileChanged())); 36 connect(m_pFileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(fileChanged()));
38 37
39 m_pPreviewLabel = new QLabel(this); 38 m_pPreviewLabel = new QLabel(this);
40 m_pPreviewLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); 39 m_pPreviewLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
41 m_pPreviewLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 40 m_pPreviewLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
42 m_pPreviewLabel->setFixedSize(114, 114); 41 m_pPreviewLabel->setFixedSize(114, 114);
43 m_pPreviewLabel->setBackgroundMode(QWidget::PaletteMid); 42 m_pPreviewLabel->setBackgroundMode(QWidget::PaletteMid);
44 43
45 m_pAutomaticPreviewCheckBox = new QCheckBox(tr("Automatic preview"), this); 44 m_pAutomaticPreviewCheckBox = new QCheckBox(tr("Automatic preview"), this);
46 m_pAutomaticPreviewCheckBox->setChecked(true); 45 m_pAutomaticPreviewCheckBox->setChecked(true);
47 46
48 QPushButton* previewPushButton = new QPushButton(tr("Preview"), this); 47 QPushButton* previewPushButton = new QPushButton(tr("Preview"), this);
49 connect(previewPushButton, SIGNAL(clicked()), this, SLOT(preview())); 48 connect(previewPushButton, SIGNAL(clicked()), this, SLOT(preview()));
50 49
51 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 50 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
52 QHBoxLayout* previewLayout = new QHBoxLayout(4); 51 QHBoxLayout* previewLayout = new QHBoxLayout(4);
53 QVBoxLayout* previewSecondLayout = new QVBoxLayout(4); 52 QVBoxLayout* previewSecondLayout = new QVBoxLayout(4);
54 53
55 previewSecondLayout->addWidget(m_pAutomaticPreviewCheckBox); 54 previewSecondLayout->addWidget(m_pAutomaticPreviewCheckBox);
56 previewSecondLayout->addWidget(previewPushButton); 55 previewSecondLayout->addWidget(previewPushButton);
57 previewSecondLayout->addStretch(); 56 previewSecondLayout->addStretch();
58 57
59 previewLayout->addWidget(m_pPreviewLabel); 58 previewLayout->addWidget(m_pPreviewLabel);
60 previewLayout->addLayout(previewSecondLayout); 59 previewLayout->addLayout(previewSecondLayout);
61 60
62 mainLayout->addWidget(m_pFileSelector); 61 mainLayout->addWidget(m_pFileSelector);
63 mainLayout->addLayout(previewLayout); 62 mainLayout->addLayout(previewLayout);
64 63
65 preview(); 64 preview();
66} 65}
67 66
68ImportDialog::~ImportDialog() 67ImportDialog::~ImportDialog()
69{ 68{
70} 69}
71 70
72const DocLnk* ImportDialog::selected() 71const DocLnk* ImportDialog::selected()
73{ 72{
74 // FIXME change from pointer to reference -zecke 73 // FIXME change from pointer to reference -zecke
75 DocLnk *lnk = new DocLnk( m_pFileSelector->selectedDocument() ); 74 DocLnk *lnk = new DocLnk( m_pFileSelector->selectedDocument() );
76 return lnk; 75 return lnk;
77} 76}
78 77
79void ImportDialog::fileChanged() 78void ImportDialog::fileChanged()
80{ 79{
81 if (m_pAutomaticPreviewCheckBox->isChecked()) { 80 if (m_pAutomaticPreviewCheckBox->isChecked()) {
82 preview(); 81 preview();
83 } 82 }
84} 83}
85 84
86void ImportDialog::preview() 85void ImportDialog::preview()
87{ 86{
88 const DocLnk* docLnk = selected(); 87 const DocLnk* docLnk = selected();
89 88
90 if (docLnk) { 89 if (docLnk) {
91 QImage image(docLnk->file()); 90 QImage image(docLnk->file());
92 91
93 int previewWidth = m_pPreviewLabel->contentsRect().width(); 92 int previewWidth = m_pPreviewLabel->contentsRect().width();
94 int previewHeight = m_pPreviewLabel->contentsRect().height(); 93 int previewHeight = m_pPreviewLabel->contentsRect().height();
95 94
96 float widthScale = 1.0; 95 float widthScale = 1.0;
97 float heightScale = 1.0; 96 float heightScale = 1.0;
98 97
99 if (previewWidth < image.width()) { 98 if (previewWidth < image.width()) {
100 widthScale = (float)previewWidth / float(image.width()); 99 widthScale = (float)previewWidth / float(image.width());
101 } 100 }
102 101
103 if (previewHeight < image.height()) { 102 if (previewHeight < image.height()) {
104 heightScale = (float)previewHeight / float(image.height()); 103 heightScale = (float)previewHeight / float(image.height());
105 } 104 }
106 105
107 float scale = (widthScale < heightScale ? widthScale : heightScale); 106 float scale = (widthScale < heightScale ? widthScale : heightScale);
108 QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); 107 QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale));
109 108
110 QPixmap previewPixmap; 109 QPixmap previewPixmap;
111 previewPixmap.convertFromImage(previewImage); 110 previewPixmap.convertFromImage(previewImage);
112 111
113 m_pPreviewLabel->setPixmap(previewPixmap); 112 m_pPreviewLabel->setPixmap(previewPixmap);
114 113
115 delete docLnk; 114 delete docLnk;
116 } 115 }
117} 116}
diff --git a/noncore/graphics/drawpad/linetool.cpp b/noncore/graphics/drawpad/linetool.cpp
index b6baa2a..5ea068c 100644
--- a/noncore/graphics/drawpad/linetool.cpp
+++ b/noncore/graphics/drawpad/linetool.cpp
@@ -1,82 +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 "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>
21 20
22LineTool::LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) 21LineTool::LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : ShapeTool(drawPad, drawPadCanvas) 22 : ShapeTool(drawPad, drawPadCanvas)
24{ 23{
25} 24}
26 25
27LineTool::~LineTool() 26LineTool::~LineTool()
28{ 27{
29} 28}
30 29
31void LineTool::drawFinalShape(QPainter& p) 30void LineTool::drawFinalShape(QPainter& p)
32{ 31{
33 p.setRasterOp(Qt::NotROP); 32 p.setRasterOp(Qt::NotROP);
34 p.drawLine(m_polyline[2], m_polyline[0]); 33 p.drawLine(m_polyline[2], m_polyline[0]);
35 p.setRasterOp(Qt::CopyROP); 34 p.setRasterOp(Qt::CopyROP);
36 35
37 if (m_pDrawPad->antiAliasing()) { 36 if (m_pDrawPad->antiAliasing()) {
38 QRect r = m_polyline.boundingRect(); 37 QRect r = m_polyline.boundingRect();
39 r = r.normalize(); 38 r = r.normalize();
40 r.setLeft(r.left() - m_pDrawPad->pen().width()); 39 r.setLeft(r.left() - m_pDrawPad->pen().width());
41 r.setTop(r.top() - m_pDrawPad->pen().width()); 40 r.setTop(r.top() - m_pDrawPad->pen().width());
42 r.setRight(r.right() + m_pDrawPad->pen().width()); 41 r.setRight(r.right() + m_pDrawPad->pen().width());
43 r.setBottom(r.bottom() + m_pDrawPad->pen().width()); 42 r.setBottom(r.bottom() + m_pDrawPad->pen().width());
44 43
45 QPixmap areaPixmap(r.width(), r.height()); 44 QPixmap areaPixmap(r.width(), r.height());
46 bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); 45 bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
47 46
48 QImage areaImage = areaPixmap.convertToImage(); 47 QImage areaImage = areaPixmap.convertToImage();
49 QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); 48 QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
50 49
51 QPixmap bigAreaPixmap; 50 QPixmap bigAreaPixmap;
52 bigAreaPixmap.convertFromImage(bigAreaImage); 51 bigAreaPixmap.convertFromImage(bigAreaImage);
53 52
54 QPen bigAreaPen = m_pDrawPad->pen(); 53 QPen bigAreaPen = m_pDrawPad->pen();
55 bigAreaPen.setWidth(bigAreaPen.width() * 3); 54 bigAreaPen.setWidth(bigAreaPen.width() * 3);
56 55
57 QPainter bigAreaPainter; 56 QPainter bigAreaPainter;
58 bigAreaPainter.begin(&bigAreaPixmap); 57 bigAreaPainter.begin(&bigAreaPixmap);
59 bigAreaPainter.setPen(bigAreaPen); 58 bigAreaPainter.setPen(bigAreaPen);
60 59
61 bigAreaPainter.drawLine((m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1, 60 bigAreaPainter.drawLine((m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1,
62 (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); 61 (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1);
63 62
64 bigAreaPainter.end(); 63 bigAreaPainter.end();
65 64
66 bigAreaImage = bigAreaPixmap.convertToImage(); 65 bigAreaImage = bigAreaPixmap.convertToImage();
67 areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); 66 areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
68 areaPixmap.convertFromImage(areaImage); 67 areaPixmap.convertFromImage(areaImage);
69 68
70 p.drawPixmap(r.x(), r.y(), areaPixmap); 69 p.drawPixmap(r.x(), r.y(), areaPixmap);
71 } else { 70 } else {
72 p.setPen(m_pDrawPad->pen()); 71 p.setPen(m_pDrawPad->pen());
73 p.drawLine(m_polyline[2], m_polyline[0]); 72 p.drawLine(m_polyline[2], m_polyline[0]);
74 } 73 }
75} 74}
76 75
77void LineTool::drawTemporaryShape(QPainter& p) 76void LineTool::drawTemporaryShape(QPainter& p)
78{ 77{
79 p.setRasterOp(Qt::NotROP); 78 p.setRasterOp(Qt::NotROP);
80 p.drawLine(m_polyline[2], m_polyline[1]); 79 p.drawLine(m_polyline[2], m_polyline[1]);
81 p.drawLine(m_polyline[2], m_polyline[0]); 80 p.drawLine(m_polyline[2], m_polyline[0]);
82} 81}
diff --git a/noncore/graphics/drawpad/main.cpp b/noncore/graphics/drawpad/main.cpp
index 87bc621..c87cc0f 100644
--- a/noncore/graphics/drawpad/main.cpp
+++ b/noncore/graphics/drawpad/main.cpp
@@ -1,19 +1,18 @@
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 <qpe/qpeapplication.h>
17#include <opie/oapplicationfactory.h> 16#include <opie/oapplicationfactory.h>
18 17
19OPIE_EXPORT_APP( OApplicationFactory<DrawPad> ) 18OPIE_EXPORT_APP( OApplicationFactory<DrawPad> )
diff --git a/noncore/graphics/drawpad/newpagedialog.cpp b/noncore/graphics/drawpad/newpagedialog.cpp
index e6e7fcb..dc8999a 100644
--- a/noncore/graphics/drawpad/newpagedialog.cpp
+++ b/noncore/graphics/drawpad/newpagedialog.cpp
@@ -1,119 +1,118 @@
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 "newpagedialog.h" 14#include "newpagedialog.h"
15 15
16#include <qbuttongroup.h> 16#include <qbuttongroup.h>
17#include <qgroupbox.h>
18#include <qlabel.h> 17#include <qlabel.h>
19#include <qlayout.h> 18#include <qlayout.h>
20#include <qlineedit.h> 19#include <qlineedit.h>
21#include <qradiobutton.h> 20#include <qradiobutton.h>
22#include <qspinbox.h> 21#include <qspinbox.h>
23 22
24NewPageDialog::NewPageDialog(uint width, uint height, const QColor& penColor, 23NewPageDialog::NewPageDialog(uint width, uint height, const QColor& penColor,
25 const QColor& brushColor, QWidget* parent, const char* name) 24 const QColor& brushColor, QWidget* parent, const char* name)
26 : QDialog(parent, name, true) 25 : QDialog(parent, name, true)
27{ 26{
28 setCaption(tr("New Page")); 27 setCaption(tr("New Page"));
29 28
30 m_penColor = penColor; 29 m_penColor = penColor;
31 m_brushColor = brushColor; 30 m_brushColor = brushColor;
32 31
33 QGroupBox* generalGroupBox = new QGroupBox(0, Qt::Vertical, tr("General"), this); 32 QGroupBox* generalGroupBox = new QGroupBox(0, Qt::Vertical, tr("General"), this);
34 33
35 QLabel* titleLabel = new QLabel(tr("Title:"), generalGroupBox); 34 QLabel* titleLabel = new QLabel(tr("Title:"), generalGroupBox);
36 m_pTitleLineEdit = new QLineEdit(generalGroupBox); 35 m_pTitleLineEdit = new QLineEdit(generalGroupBox);
37 36
38 QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Size"), this); 37 QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Size"), this);
39 38
40 QLabel* widthLabel = new QLabel(tr("Width:"), sizeGroupBox); 39 QLabel* widthLabel = new QLabel(tr("Width:"), sizeGroupBox);
41 QLabel* heightLabel = new QLabel(tr("Height:"), sizeGroupBox); 40 QLabel* heightLabel = new QLabel(tr("Height:"), sizeGroupBox);
42 41
43 m_pWidthSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox); 42 m_pWidthSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox);
44 m_pHeightSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox); 43 m_pHeightSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox);
45 44
46 m_pWidthSpinBox->setValue(width); 45 m_pWidthSpinBox->setValue(width);
47 m_pHeightSpinBox->setValue(height); 46 m_pHeightSpinBox->setValue(height);
48 47
49 m_pContentButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Background"), this); 48 m_pContentButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Background"), this);
50 49
51 QRadioButton* whiteColorRadioButton = new QRadioButton(tr("White"), m_pContentButtonGroup); 50 QRadioButton* whiteColorRadioButton = new QRadioButton(tr("White"), m_pContentButtonGroup);
52 QRadioButton* penColorRadioButton = new QRadioButton(tr("Pen Color"), m_pContentButtonGroup); 51 QRadioButton* penColorRadioButton = new QRadioButton(tr("Pen Color"), m_pContentButtonGroup);
53 QRadioButton* brushColorRadioButton = new QRadioButton(tr("Fill Color"), m_pContentButtonGroup); 52 QRadioButton* brushColorRadioButton = new QRadioButton(tr("Fill Color"), m_pContentButtonGroup);
54 53
55 m_pContentButtonGroup->setButton(0); 54 m_pContentButtonGroup->setButton(0);
56 55
57 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 56 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
58 generalGroupBox->layout()->setSpacing(4); 57 generalGroupBox->layout()->setSpacing(4);
59 sizeGroupBox->layout()->setSpacing(4); 58 sizeGroupBox->layout()->setSpacing(4);
60 m_pContentButtonGroup->layout()->setSpacing(4); 59 m_pContentButtonGroup->layout()->setSpacing(4);
61 QGridLayout* generalLayout = new QGridLayout(generalGroupBox->layout(), 1, 1); 60 QGridLayout* generalLayout = new QGridLayout(generalGroupBox->layout(), 1, 1);
62 QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2); 61 QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2);
63 QVBoxLayout* contentLayout = new QVBoxLayout(m_pContentButtonGroup->layout()); 62 QVBoxLayout* contentLayout = new QVBoxLayout(m_pContentButtonGroup->layout());
64 63
65 generalLayout->addWidget(titleLabel, 0, 0); 64 generalLayout->addWidget(titleLabel, 0, 0);
66 generalLayout->addWidget(m_pTitleLineEdit, 0, 1); 65 generalLayout->addWidget(m_pTitleLineEdit, 0, 1);
67 66
68 sizeLayout->addWidget(widthLabel, 0, 0); 67 sizeLayout->addWidget(widthLabel, 0, 0);
69 sizeLayout->addWidget(heightLabel, 1, 0); 68 sizeLayout->addWidget(heightLabel, 1, 0);
70 sizeLayout->addWidget(m_pWidthSpinBox, 0, 1); 69 sizeLayout->addWidget(m_pWidthSpinBox, 0, 1);
71 sizeLayout->addWidget(m_pHeightSpinBox, 1, 1); 70 sizeLayout->addWidget(m_pHeightSpinBox, 1, 1);
72 71
73 sizeLayout->setColStretch(1, 1); 72 sizeLayout->setColStretch(1, 1);
74 73
75 contentLayout->addWidget(whiteColorRadioButton); 74 contentLayout->addWidget(whiteColorRadioButton);
76 contentLayout->addWidget(penColorRadioButton); 75 contentLayout->addWidget(penColorRadioButton);
77 contentLayout->addWidget(brushColorRadioButton); 76 contentLayout->addWidget(brushColorRadioButton);
78 77
79 mainLayout->addWidget(generalGroupBox); 78 mainLayout->addWidget(generalGroupBox);
80 mainLayout->addWidget(sizeGroupBox); 79 mainLayout->addWidget(sizeGroupBox);
81 mainLayout->addWidget(m_pContentButtonGroup); 80 mainLayout->addWidget(m_pContentButtonGroup);
82} 81}
83 82
84NewPageDialog::~NewPageDialog() 83NewPageDialog::~NewPageDialog()
85{ 84{
86} 85}
87 86
88QString NewPageDialog::selectedTitle() 87QString NewPageDialog::selectedTitle()
89{ 88{
90 return (m_pTitleLineEdit->text()); 89 return (m_pTitleLineEdit->text());
91} 90}
92 91
93uint NewPageDialog::selectedWidth() 92uint NewPageDialog::selectedWidth()
94{ 93{
95 return (m_pWidthSpinBox->value()); 94 return (m_pWidthSpinBox->value());
96} 95}
97 96
98uint NewPageDialog::selectedHeight() 97uint NewPageDialog::selectedHeight()
99{ 98{
100 return (m_pHeightSpinBox->value()); 99 return (m_pHeightSpinBox->value());
101} 100}
102 101
103const QColor& NewPageDialog::selectedColor() 102const QColor& NewPageDialog::selectedColor()
104{ 103{
105 switch (m_pContentButtonGroup->id(m_pContentButtonGroup->selected())) { 104 switch (m_pContentButtonGroup->id(m_pContentButtonGroup->selected())) {
106 case 0: 105 case 0:
107 return (Qt::white); 106 return (Qt::white);
108 break; 107 break;
109 case 1: 108 case 1:
110 return (m_penColor); 109 return (m_penColor);
111 break; 110 break;
112 case 2: 111 case 2:
113 return (m_brushColor); 112 return (m_brushColor);
114 break; 113 break;
115 default: 114 default:
116 return (Qt::white); 115 return (Qt::white);
117 break; 116 break;
118 } 117 }
119} 118}
diff --git a/noncore/graphics/drawpad/pointtool.cpp b/noncore/graphics/drawpad/pointtool.cpp
index b9b52bc..4fb7ad1 100644
--- a/noncore/graphics/drawpad/pointtool.cpp
+++ b/noncore/graphics/drawpad/pointtool.cpp
@@ -1,111 +1,110 @@
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>
22 21
23PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) 22PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
24 : Tool(drawPad, drawPadCanvas) 23 : Tool(drawPad, drawPadCanvas)
25{ 24{
26 m_mousePressed = false; 25 m_mousePressed = false;
27 m_polyline.resize(3); 26 m_polyline.resize(3);
28} 27}
29 28
30PointTool::~PointTool() 29PointTool::~PointTool()
31{ 30{
32} 31}
33 32
34void PointTool::mousePressEvent(QMouseEvent* e) 33void PointTool::mousePressEvent(QMouseEvent* e)
35{ 34{
36 m_pDrawPadCanvas->backupPage(); 35 m_pDrawPadCanvas->backupPage();
37 36
38 m_mousePressed = true; 37 m_mousePressed = true;
39 m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); 38 m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
40} 39}
41 40
42void PointTool::mouseReleaseEvent(QMouseEvent* e) 41void PointTool::mouseReleaseEvent(QMouseEvent* e)
43{ 42{
44 Q_UNUSED(e) 43 Q_UNUSED(e)
45 44
46 m_mousePressed = false; 45 m_mousePressed = false;
47} 46}
48 47
49void PointTool::mouseMoveEvent(QMouseEvent* e) 48void PointTool::mouseMoveEvent(QMouseEvent* e)
50{ 49{
51 if (m_mousePressed) { 50 if (m_mousePressed) {
52 m_polyline[2] = m_polyline[1]; 51 m_polyline[2] = m_polyline[1];
53 m_polyline[1] = m_polyline[0]; 52 m_polyline[1] = m_polyline[0];
54 m_polyline[0] = e->pos(); 53 m_polyline[0] = e->pos();
55 54
56 QRect r = m_polyline.boundingRect(); 55 QRect r = m_polyline.boundingRect();
57 r = r.normalize(); 56 r = r.normalize();
58 r.setLeft(r.left() - m_pDrawPad->pen().width()); 57 r.setLeft(r.left() - m_pDrawPad->pen().width());
59 r.setTop(r.top() - m_pDrawPad->pen().width()); 58 r.setTop(r.top() - m_pDrawPad->pen().width());
60 r.setRight(r.right() + m_pDrawPad->pen().width()); 59 r.setRight(r.right() + m_pDrawPad->pen().width());
61 r.setBottom(r.bottom() + m_pDrawPad->pen().width()); 60 r.setBottom(r.bottom() + m_pDrawPad->pen().width());
62 61
63 QPainter painter; 62 QPainter painter;
64 painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); 63 painter.begin(m_pDrawPadCanvas->currentPage()->pixmap());
65 64
66 if (m_pDrawPad->antiAliasing()) { 65 if (m_pDrawPad->antiAliasing()) {
67 QPixmap areaPixmap(r.width(), r.height()); 66 QPixmap areaPixmap(r.width(), r.height());
68 bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r); 67 bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r);
69 68
70 QImage areaImage = areaPixmap.convertToImage(); 69 QImage areaImage = areaPixmap.convertToImage();
71 QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); 70 QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
72 71
73 QPixmap bigAreaPixmap; 72 QPixmap bigAreaPixmap;
74 bigAreaPixmap.convertFromImage(bigAreaImage); 73 bigAreaPixmap.convertFromImage(bigAreaImage);
75 74
76 QPen bigAreaPen = m_pDrawPad->pen(); 75 QPen bigAreaPen = m_pDrawPad->pen();
77 bigAreaPen.setWidth(bigAreaPen.width() * 3); 76 bigAreaPen.setWidth(bigAreaPen.width() * 3);
78 77
79 QPainter bigAreaPainter; 78 QPainter bigAreaPainter;
80 bigAreaPainter.begin(&bigAreaPixmap); 79 bigAreaPainter.begin(&bigAreaPixmap);
81 bigAreaPainter.setPen(bigAreaPen); 80 bigAreaPainter.setPen(bigAreaPen);
82 81
83 QPointArray bigAreaPolyline(3); 82 QPointArray bigAreaPolyline(3);
84 bigAreaPolyline.setPoint(0, (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); 83 bigAreaPolyline.setPoint(0, (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1);
85 bigAreaPolyline.setPoint(1, (m_polyline[1].x() - r.x()) * 3 + 1, (m_polyline[1].y() - r.y()) * 3 + 1); 84 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); 85 bigAreaPolyline.setPoint(2, (m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1);
87 86
88 bigAreaPainter.drawPolyline(bigAreaPolyline); 87 bigAreaPainter.drawPolyline(bigAreaPolyline);
89 bigAreaPainter.end(); 88 bigAreaPainter.end();
90 89
91 bigAreaImage = bigAreaPixmap.convertToImage(); 90 bigAreaImage = bigAreaPixmap.convertToImage();
92 areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); 91 areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
93 areaPixmap.convertFromImage(areaImage); 92 areaPixmap.convertFromImage(areaImage);
94 93
95 painter.drawPixmap(r.x(), r.y(), areaPixmap); 94 painter.drawPixmap(r.x(), r.y(), areaPixmap);
96 } else { 95 } else {
97 painter.setPen(m_pDrawPad->pen()); 96 painter.setPen(m_pDrawPad->pen());
98 painter.drawPolyline(m_polyline); 97 painter.drawPolyline(m_polyline);
99 } 98 }
100 99
101 painter.end(); 100 painter.end();
102 101
103 QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), 102 QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()),
104 m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); 103 m_pDrawPadCanvas->contentsToViewport(r.bottomRight()));
105 104
106 bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), 105 bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(),
107 m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); 106 m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height());
108 107
109 m_pDrawPadCanvas->viewport()->update(viewportRect); 108 m_pDrawPadCanvas->viewport()->update(viewportRect);
110 } 109 }
111} 110}
diff --git a/noncore/graphics/drawpad/shapetool.cpp b/noncore/graphics/drawpad/shapetool.cpp
index 22e3dd6..6e4276d 100644
--- a/noncore/graphics/drawpad/shapetool.cpp
+++ b/noncore/graphics/drawpad/shapetool.cpp
@@ -1,94 +1,93 @@
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 "shapetool.h" 14#include "shapetool.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 <qpainter.h>
21 20
22ShapeTool::ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) 21ShapeTool::ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
23 : Tool(drawPad, drawPadCanvas) 22 : Tool(drawPad, drawPadCanvas)
24{ 23{
25 m_mousePressed = false; 24 m_mousePressed = false;
26 m_polyline.resize(3); 25 m_polyline.resize(3);
27} 26}
28 27
29ShapeTool::~ShapeTool() 28ShapeTool::~ShapeTool()
30{ 29{
31} 30}
32 31
33void ShapeTool::mousePressEvent(QMouseEvent* e) 32void ShapeTool::mousePressEvent(QMouseEvent* e)
34{ 33{
35 m_pDrawPadCanvas->backupPage(); 34 m_pDrawPadCanvas->backupPage();
36 35
37 m_mousePressed = true; 36 m_mousePressed = true;
38 m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); 37 m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
39} 38}
40 39
41void ShapeTool::mouseReleaseEvent(QMouseEvent* e) 40void ShapeTool::mouseReleaseEvent(QMouseEvent* e)
42{ 41{
43 Q_UNUSED(e) 42 Q_UNUSED(e)
44 43
45 QPainter painter; 44 QPainter painter;
46 painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); 45 painter.begin(m_pDrawPadCanvas->currentPage()->pixmap());
47 drawFinalShape(painter); 46 drawFinalShape(painter);
48 painter.end(); 47 painter.end();
49 48
50 QRect r = m_polyline.boundingRect(); 49 QRect r = m_polyline.boundingRect();
51 r = r.normalize(); 50 r = r.normalize();
52 r.setLeft(r.left() - m_pDrawPad->pen().width()); 51 r.setLeft(r.left() - m_pDrawPad->pen().width());
53 r.setTop(r.top() - m_pDrawPad->pen().width()); 52 r.setTop(r.top() - m_pDrawPad->pen().width());
54 r.setRight(r.right() + m_pDrawPad->pen().width()); 53 r.setRight(r.right() + m_pDrawPad->pen().width());
55 r.setBottom(r.bottom() + m_pDrawPad->pen().width()); 54 r.setBottom(r.bottom() + m_pDrawPad->pen().width());
56 55
57 QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), 56 QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()),
58 m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); 57 m_pDrawPadCanvas->contentsToViewport(r.bottomRight()));
59 58
60 bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), 59 bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(),
61 m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); 60 m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height());
62 61
63 m_pDrawPadCanvas->viewport()->update(viewportRect); 62 m_pDrawPadCanvas->viewport()->update(viewportRect);
64 63
65 m_mousePressed = false; 64 m_mousePressed = false;
66} 65}
67 66
68void ShapeTool::mouseMoveEvent(QMouseEvent* e) 67void ShapeTool::mouseMoveEvent(QMouseEvent* e)
69{ 68{
70 if (m_mousePressed) { 69 if (m_mousePressed) {
71 m_polyline[0] = e->pos(); 70 m_polyline[0] = e->pos();
72 QPainter painter; 71 QPainter painter;
73 painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); 72 painter.begin(m_pDrawPadCanvas->currentPage()->pixmap());
74 drawTemporaryShape(painter); 73 drawTemporaryShape(painter);
75 painter.end(); 74 painter.end();
76 75
77 QRect r = m_polyline.boundingRect(); 76 QRect r = m_polyline.boundingRect();
78 r = r.normalize(); 77 r = r.normalize();
79 r.setLeft(r.left() - m_pDrawPad->pen().width()); 78 r.setLeft(r.left() - m_pDrawPad->pen().width());
80 r.setTop(r.top() - m_pDrawPad->pen().width()); 79 r.setTop(r.top() - m_pDrawPad->pen().width());
81 r.setRight(r.right() + m_pDrawPad->pen().width()); 80 r.setRight(r.right() + m_pDrawPad->pen().width());
82 r.setBottom(r.bottom() + m_pDrawPad->pen().width()); 81 r.setBottom(r.bottom() + m_pDrawPad->pen().width());
83 82
84 QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), 83 QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()),
85 m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); 84 m_pDrawPadCanvas->contentsToViewport(r.bottomRight()));
86 85
87 bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), 86 bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(),
88 m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); 87 m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height());
89 88
90 m_pDrawPadCanvas->viewport()->update(viewportRect); 89 m_pDrawPadCanvas->viewport()->update(viewportRect);
91 90
92 m_polyline[1] = m_polyline[0]; 91 m_polyline[1] = m_polyline[0];
93 } 92 }
94} 93}
diff --git a/noncore/graphics/drawpad/texttool.cpp b/noncore/graphics/drawpad/texttool.cpp
index 9037abd..3a89e80 100644
--- a/noncore/graphics/drawpad/texttool.cpp
+++ b/noncore/graphics/drawpad/texttool.cpp
@@ -1,79 +1,78 @@
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 "texttool.h" 14#include "texttool.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 <qlayout.h> 20#include <qlayout.h>
21#include <qlineedit.h> 21#include <qlineedit.h>
22#include <qpainter.h>
23 22
24TextToolDialog::TextToolDialog(QWidget* parent, const char* name) 23TextToolDialog::TextToolDialog(QWidget* parent, const char* name)
25 : QDialog(parent, name, true) 24 : QDialog(parent, name, true)
26{ 25{
27 setCaption(tr("Insert Text")); 26 setCaption(tr("Insert Text"));
28 27
29 m_pLineEdit = new QLineEdit(this); 28 m_pLineEdit = new QLineEdit(this);
30 29
31 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 30 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
32 31
33 mainLayout->addWidget(m_pLineEdit); 32 mainLayout->addWidget(m_pLineEdit);
34} 33}
35 34
36TextToolDialog::~TextToolDialog() 35TextToolDialog::~TextToolDialog()
37{ 36{
38} 37}
39 38
40QString TextToolDialog::text() 39QString TextToolDialog::text()
41{ 40{
42 return m_pLineEdit->text(); 41 return m_pLineEdit->text();
43} 42}
44 43
45TextTool::TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) 44TextTool::TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
46 : Tool(drawPad, drawPadCanvas) 45 : Tool(drawPad, drawPadCanvas)
47{ 46{
48} 47}
49 48
50TextTool::~TextTool() 49TextTool::~TextTool()
51{ 50{
52} 51}
53 52
54void TextTool::mousePressEvent(QMouseEvent* e) 53void TextTool::mousePressEvent(QMouseEvent* e)
55{ 54{
56 TextToolDialog textToolDialog(m_pDrawPad); 55 TextToolDialog textToolDialog(m_pDrawPad);
57 56
58 if (textToolDialog.exec() == QDialog::Accepted && !textToolDialog.text().isEmpty()) { 57 if (textToolDialog.exec() == QDialog::Accepted && !textToolDialog.text().isEmpty()) {
59 m_pDrawPadCanvas->backupPage(); 58 m_pDrawPadCanvas->backupPage();
60 59
61 QPainter painter; 60 QPainter painter;
62 painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); 61 painter.begin(m_pDrawPadCanvas->currentPage()->pixmap());
63 painter.setPen(m_pDrawPad->pen()); 62 painter.setPen(m_pDrawPad->pen());
64 painter.drawText(e->x(), e->y(), textToolDialog.text()); 63 painter.drawText(e->x(), e->y(), textToolDialog.text());
65 painter.end(); 64 painter.end();
66 65
67 m_pDrawPadCanvas->viewport()->update(); 66 m_pDrawPadCanvas->viewport()->update();
68 } 67 }
69} 68}
70 69
71void TextTool::mouseReleaseEvent(QMouseEvent* e) 70void TextTool::mouseReleaseEvent(QMouseEvent* e)
72{ 71{
73 Q_UNUSED(e) 72 Q_UNUSED(e)
74} 73}
75 74
76void TextTool::mouseMoveEvent(QMouseEvent* e) 75void TextTool::mouseMoveEvent(QMouseEvent* e)
77{ 76{
78 Q_UNUSED(e) 77 Q_UNUSED(e)
79} 78}
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp
index 90ba39c..1ccf484 100644
--- a/noncore/graphics/drawpad/thumbnailview.cpp
+++ b/noncore/graphics/drawpad/thumbnailview.cpp
@@ -1,282 +1,281 @@
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 "thumbnailview.h" 14#include "thumbnailview.h"
15 15
16#include "drawpad.h" 16#include "drawpad.h"
17#include "drawpadcanvas.h" 17#include "drawpadcanvas.h"
18#include "newpagedialog.h" 18#include "newpagedialog.h"
19#include "page.h" 19#include "page.h"
20 20
21#include <qpe/config.h> 21#include <qpe/config.h>
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/timestring.h> 23#include <qpe/timestring.h>
24 24
25#include <qapplication.h> 25#include <qapplication.h>
26#include <qimage.h>
27#include <qlayout.h> 26#include <qlayout.h>
28#include <qmessagebox.h> 27#include <qmessagebox.h>
29#include <qtoolbutton.h> 28#include <qtoolbutton.h>
30#include <qwhatsthis.h> 29#include <qwhatsthis.h>
31 30
32#define THUMBNAIL_SIZE 48 31#define THUMBNAIL_SIZE 48
33 32
34PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) 33PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent)
35 : QListBoxItem(parent) 34 : QListBoxItem(parent)
36{ 35{
37 m_pPage = page; 36 m_pPage = page;
38 37
39 QImage image = m_pPage->pixmap()->convertToImage(); 38 QImage image = m_pPage->pixmap()->convertToImage();
40 39
41 int previewWidth = THUMBNAIL_SIZE; 40 int previewWidth = THUMBNAIL_SIZE;
42 int previewHeight = THUMBNAIL_SIZE; 41 int previewHeight = THUMBNAIL_SIZE;
43 42
44 float widthScale = 1.0; 43 float widthScale = 1.0;
45 float heightScale = 1.0; 44 float heightScale = 1.0;
46 45
47 if (previewWidth < image.width()) { 46 if (previewWidth < image.width()) {
48 widthScale = (float)previewWidth / float(image.width()); 47 widthScale = (float)previewWidth / float(image.width());
49 } 48 }
50 49
51 if (previewHeight < image.height()) { 50 if (previewHeight < image.height()) {
52 heightScale = (float)previewHeight / float(image.height()); 51 heightScale = (float)previewHeight / float(image.height());
53 } 52 }
54 53
55 float scale = (widthScale < heightScale ? widthScale : heightScale); 54 float scale = (widthScale < heightScale ? widthScale : heightScale);
56 QImage thumbnailImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); 55 QImage thumbnailImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale));
57 56
58 m_thumbnail.convertFromImage(thumbnailImage); 57 m_thumbnail.convertFromImage(thumbnailImage);
59 58
60 m_titleText = QObject::tr( "Title: %1" ).arg( m_pPage->title() ); 59 m_titleText = QObject::tr( "Title: %1" ).arg( m_pPage->title() );
61 m_dimensionText = QObject::tr( "Dimension: %1x%2" ). 60 m_dimensionText = QObject::tr( "Dimension: %1x%2" ).
62 arg( m_pPage->pixmap()->width() ). 61 arg( m_pPage->pixmap()->width() ).
63 arg( m_pPage->pixmap()->height() ); 62 arg( m_pPage->pixmap()->height() );
64 m_dateText = QObject::tr( "Date: %1" ).arg( dateTimeString(m_pPage->lastModified()) ); 63 m_dateText = QObject::tr( "Date: %1" ).arg( dateTimeString(m_pPage->lastModified()) );
65 64
66 QColor baseColor = parent->colorGroup().base(); 65 QColor baseColor = parent->colorGroup().base();
67 int h, s, v; 66 int h, s, v;
68 baseColor.hsv(&h, &s, &v); 67 baseColor.hsv(&h, &s, &v);
69 68
70 if (v > 128) { 69 if (v > 128) {
71 m_alternateColor = baseColor.dark(115); 70 m_alternateColor = baseColor.dark(115);
72 } else if (baseColor != Qt::black) { 71 } else if (baseColor != Qt::black) {
73 m_alternateColor = baseColor.light(115); 72 m_alternateColor = baseColor.light(115);
74 } else { 73 } else {
75 m_alternateColor = QColor(32, 32, 32); 74 m_alternateColor = QColor(32, 32, 32);
76 } 75 }
77} 76}
78 77
79PageListBoxItem::~PageListBoxItem() 78PageListBoxItem::~PageListBoxItem()
80{ 79{
81} 80}
82 81
83int PageListBoxItem::height(const QListBox*) const 82int PageListBoxItem::height(const QListBox*) const
84{ 83{
85 return QMAX(THUMBNAIL_SIZE + 4, QApplication::globalStrut().height()); 84 return QMAX(THUMBNAIL_SIZE + 4, QApplication::globalStrut().height());
86} 85}
87 86
88int PageListBoxItem::width(const QListBox* lb) const 87int PageListBoxItem::width(const QListBox* lb) const
89{ 88{
90 QFontMetrics fontMetrics = lb->fontMetrics(); 89 QFontMetrics fontMetrics = lb->fontMetrics();
91 int maxtextLength = QMAX(fontMetrics.width(m_titleText), 90 int maxtextLength = QMAX(fontMetrics.width(m_titleText),
92 QMAX(fontMetrics.width(m_dimensionText), 91 QMAX(fontMetrics.width(m_dimensionText),
93 fontMetrics.width(m_dateText))); 92 fontMetrics.width(m_dateText)));
94 93
95 return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width()); 94 return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width());
96} 95}
97 96
98void PageListBoxItem::paint(QPainter *painter) 97void PageListBoxItem::paint(QPainter *painter)
99{ 98{
100 QRect itemRect = listBox()->itemRect(this); 99 QRect itemRect = listBox()->itemRect(this);
101 100
102 if (!selected() && (listBox()->index(this) % 2)) { 101 if (!selected() && (listBox()->index(this) % 2)) {
103 painter->fillRect(0, 0, itemRect.width(), itemRect.height(), m_alternateColor); 102 painter->fillRect(0, 0, itemRect.width(), itemRect.height(), m_alternateColor);
104 } 103 }
105 104
106 painter->drawPixmap(2 + (THUMBNAIL_SIZE - m_thumbnail.width()) / 2, 105 painter->drawPixmap(2 + (THUMBNAIL_SIZE - m_thumbnail.width()) / 2,
107 2 + (THUMBNAIL_SIZE - m_thumbnail.height()) / 2, 106 2 + (THUMBNAIL_SIZE - m_thumbnail.height()) / 2,
108 m_thumbnail); 107 m_thumbnail);
109 108
110 QFont standardFont = painter->font(); 109 QFont standardFont = painter->font();
111 QFont boldFont = painter->font(); 110 QFont boldFont = painter->font();
112 boldFont.setBold(TRUE); 111 boldFont.setBold(TRUE);
113 112
114 QFontMetrics fontMetrics = painter->fontMetrics(); 113 QFontMetrics fontMetrics = painter->fontMetrics();
115 QRect textRect(THUMBNAIL_SIZE + 6, 2, 114 QRect textRect(THUMBNAIL_SIZE + 6, 2,
116 itemRect.width() - THUMBNAIL_SIZE - 8, 115 itemRect.width() - THUMBNAIL_SIZE - 8,
117 itemRect.height() - 4); 116 itemRect.height() - 4);
118 117
119 painter->setFont(boldFont); 118 painter->setFont(boldFont);
120 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, m_titleText); 119 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, m_titleText);
121 120
122 painter->setFont(standardFont); 121 painter->setFont(standardFont);
123 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_dimensionText); 122 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_dimensionText);
124 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateText); 123 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateText);
125 124
126 if (!selected() && !(listBox()->hasFocus() && listBox()->item(listBox()->currentItem()) == this)) { 125 if (!selected() && !(listBox()->hasFocus() && listBox()->item(listBox()->currentItem()) == this)) {
127 painter->drawLine(0, itemRect.height() - 1, itemRect.width() - 1, itemRect.height() - 1); 126 painter->drawLine(0, itemRect.height() - 1, itemRect.width() - 1, itemRect.height() - 1);
128 } 127 }
129} 128}
130 129
131Page* PageListBoxItem::page() const 130Page* PageListBoxItem::page() const
132{ 131{
133 return m_pPage; 132 return m_pPage;
134} 133}
135 134
136QString PageListBoxItem::dateTimeString(QDateTime dateTime) 135QString PageListBoxItem::dateTimeString(QDateTime dateTime)
137{ 136{
138 QString result; 137 QString result;
139 138
140 Config config("qpe"); 139 Config config("qpe");
141 config.setGroup("Date"); 140 config.setGroup("Date");
142 141
143 QChar separator = config.readEntry("Separator", "/")[0]; 142 QChar separator = config.readEntry("Separator", "/")[0];
144 DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear); 143 DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear);
145 144
146 for (int i = 0; i < 3; i++) { 145 for (int i = 0; i < 3; i++) {
147 switch((shortOrder >> (i * 3)) & 0x0007) { 146 switch((shortOrder >> (i * 3)) & 0x0007) {
148 case 0x0001: 147 case 0x0001:
149 result.append( QString().sprintf("%02d", dateTime.date().day()) ); 148 result.append( QString().sprintf("%02d", dateTime.date().day()) );
150 break; 149 break;
151 case 0x0002: 150 case 0x0002:
152 result.append( QString().sprintf("%02d", dateTime.date().month()) ); 151 result.append( QString().sprintf("%02d", dateTime.date().month()) );
153 break; 152 break;
154 case 0x0004: 153 case 0x0004:
155 result.append( QString().sprintf("%04d", dateTime.date().year()) ); 154 result.append( QString().sprintf("%04d", dateTime.date().year()) );
156 break; 155 break;
157 default: 156 default:
158 break; 157 break;
159 } 158 }
160 159
161 if (i < 2) { 160 if (i < 2) {
162 result.append( separator ); 161 result.append( separator );
163 } 162 }
164 } 163 }
165 164
166 result.append( QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()) ); 165 result.append( QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()) );
167 166
168 return result; 167 return result;
169} 168}
170 169
171PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) 170PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name)
172 : QListBox(parent, name) 171 : QListBox(parent, name)
173{ 172{
174 m_pDrawPadCanvas = drawPadCanvas; 173 m_pDrawPadCanvas = drawPadCanvas;
175 174
176 setVScrollBarMode(QScrollView::AlwaysOn); 175 setVScrollBarMode(QScrollView::AlwaysOn);
177 176
178 updateView(); 177 updateView();
179} 178}
180 179
181PageListBox::~PageListBox() 180PageListBox::~PageListBox()
182{ 181{
183} 182}
184 183
185void PageListBox::updateView() 184void PageListBox::updateView()
186{ 185{
187 clear(); 186 clear();
188 187
189 if (m_pDrawPadCanvas) { 188 if (m_pDrawPadCanvas) {
190 QList<Page> pageList = m_pDrawPadCanvas->pages(); 189 QList<Page> pageList = m_pDrawPadCanvas->pages();
191 QListIterator<Page> it(pageList); 190 QListIterator<Page> it(pageList);
192 191
193 for (; it.current(); ++it) { 192 for (; it.current(); ++it) {
194 new PageListBoxItem(it.current(), this); 193 new PageListBoxItem(it.current(), this);
195 } 194 }
196 195
197 select(m_pDrawPadCanvas->currentPage()); 196 select(m_pDrawPadCanvas->currentPage());
198 } 197 }
199} 198}
200 199
201void PageListBox::select(Page* page) 200void PageListBox::select(Page* page)
202{ 201{
203 uint i = 0; 202 uint i = 0;
204 uint itemCount = count(); 203 uint itemCount = count();
205 204
206 while (i < itemCount) { 205 while (i < itemCount) {
207 PageListBoxItem* currentItem = (PageListBoxItem*)item(i); 206 PageListBoxItem* currentItem = (PageListBoxItem*)item(i);
208 207
209 if (currentItem->page() == page) { 208 if (currentItem->page() == page) {
210 setCurrentItem(currentItem); 209 setCurrentItem(currentItem);
211 break; 210 break;
212 } 211 }
213 212
214 i++; 213 i++;
215 } 214 }
216} 215}
217 216
218Page* PageListBox::selected() const 217Page* PageListBox::selected() const
219{ 218{
220 Page* page; 219 Page* page;
221 220
222 PageListBoxItem* selectedItem = (PageListBoxItem*)item(currentItem()); 221 PageListBoxItem* selectedItem = (PageListBoxItem*)item(currentItem());
223 222
224 if (selectedItem) { 223 if (selectedItem) {
225 page = selectedItem->page(); 224 page = selectedItem->page();
226 } else { 225 } else {
227 page = NULL; 226 page = NULL;
228 } 227 }
229 228
230 return page; 229 return page;
231} 230}
232 231
233ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) 232ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name)
234 : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel | Qt::WStyle_ContextHelp) 233 : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel | Qt::WStyle_ContextHelp)
235{ 234{
236 inLoop = false; 235 inLoop = false;
237 236
238 m_pDrawPad = drawPad; 237 m_pDrawPad = drawPad;
239 m_pDrawPadCanvas = drawPadCanvas; 238 m_pDrawPadCanvas = drawPadCanvas;
240 239
241 setCaption(tr("DrawPad - Thumbnail View")); 240 setCaption(tr("DrawPad - Thumbnail View"));
242 241
243 QToolButton* newPageButton = new QToolButton(this); 242 QToolButton* newPageButton = new QToolButton(this);
244 newPageButton->setIconSet(Resource::loadIconSet("new")); 243 newPageButton->setIconSet(Resource::loadIconSet("new"));
245 newPageButton->setAutoRaise(true); 244 newPageButton->setAutoRaise(true);
246 connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); 245 connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage()));
247 QWhatsThis::add( newPageButton, tr( "Click here to add a new sheet." ) ); 246 QWhatsThis::add( newPageButton, tr( "Click here to add a new sheet." ) );
248 247
249 QToolButton* clearPageButton = new QToolButton(this); 248 QToolButton* clearPageButton = new QToolButton(this);
250 clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); 249 clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear"));
251 clearPageButton->setAutoRaise(true); 250 clearPageButton->setAutoRaise(true);
252 connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); 251 connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage()));
253 QWhatsThis::add( clearPageButton, tr( "Click here to erase the current sheet." ) ); 252 QWhatsThis::add( clearPageButton, tr( "Click here to erase the current sheet." ) );
254 253
255 QToolButton* deletePageButton = new QToolButton(this); 254 QToolButton* deletePageButton = new QToolButton(this);
256 deletePageButton->setIconSet(Resource::loadIconSet("trash")); 255 deletePageButton->setIconSet(Resource::loadIconSet("trash"));
257 deletePageButton->setAutoRaise(true); 256 deletePageButton->setAutoRaise(true);
258 connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); 257 connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage()));
259 QWhatsThis::add( deletePageButton, tr( "Click here to remove the current sheet." ) ); 258 QWhatsThis::add( deletePageButton, tr( "Click here to remove the current sheet." ) );
260 259
261 m_pMovePageUpButton = new QToolButton(this); 260 m_pMovePageUpButton = new QToolButton(this);
262 m_pMovePageUpButton->setIconSet(Resource::loadIconSet("up")); 261 m_pMovePageUpButton->setIconSet(Resource::loadIconSet("up"));
263 m_pMovePageUpButton->setAutoRaise(true); 262 m_pMovePageUpButton->setAutoRaise(true);
264 connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp())); 263 connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp()));
265 QWhatsThis::add( m_pMovePageUpButton, tr( "Click here to move the current sheet up one position in the list." ) ); 264 QWhatsThis::add( m_pMovePageUpButton, tr( "Click here to move the current sheet up one position in the list." ) );
266 265
267 m_pMovePageDownButton = new QToolButton(this); 266 m_pMovePageDownButton = new QToolButton(this);
268 m_pMovePageDownButton->setIconSet(Resource::loadIconSet("down")); 267 m_pMovePageDownButton->setIconSet(Resource::loadIconSet("down"));
269 m_pMovePageDownButton->setAutoRaise(true); 268 m_pMovePageDownButton->setAutoRaise(true);
270 connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown())); 269 connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown()));
271 QWhatsThis::add( m_pMovePageDownButton, tr( "Click here to move the current sheet down one position in the list." ) ); 270 QWhatsThis::add( m_pMovePageDownButton, tr( "Click here to move the current sheet down one position in the list." ) );
272 271
273 m_pPageListBox = new PageListBox(m_pDrawPadCanvas, this); 272 m_pPageListBox = new PageListBox(m_pDrawPadCanvas, this);
274 connect(m_pPageListBox, SIGNAL(selectionChanged()), this, SLOT(changePage())); 273 connect(m_pPageListBox, SIGNAL(selectionChanged()), this, SLOT(changePage()));
275 274
276 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 275 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
277 QHBoxLayout* buttonLayout = new QHBoxLayout(0); 276 QHBoxLayout* buttonLayout = new QHBoxLayout(0);
278 277
279 buttonLayout->addWidget(newPageButton); 278 buttonLayout->addWidget(newPageButton);
280 buttonLayout->addWidget(clearPageButton); 279 buttonLayout->addWidget(clearPageButton);
281 buttonLayout->addWidget(deletePageButton); 280 buttonLayout->addWidget(deletePageButton);
282 buttonLayout->addStretch(); 281 buttonLayout->addStretch();
diff --git a/noncore/graphics/drawpad/tool.cpp b/noncore/graphics/drawpad/tool.cpp
index 0d36912..656078e 100644
--- a/noncore/graphics/drawpad/tool.cpp
+++ b/noncore/graphics/drawpad/tool.cpp
@@ -1,28 +1,26 @@
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 "tool.h" 14#include "tool.h"
15 15
16#include "drawpad.h"
17#include "drawpadcanvas.h"
18 16
19Tool::Tool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) 17Tool::Tool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
20 : QObject() 18 : QObject()
21{ 19{
22 m_pDrawPad = drawPad; 20 m_pDrawPad = drawPad;
23 m_pDrawPadCanvas = drawPadCanvas; 21 m_pDrawPadCanvas = drawPadCanvas;
24} 22}
25 23
26Tool::~Tool() 24Tool::~Tool()
27{ 25{
28} 26}