summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp19
-rw-r--r--noncore/graphics/drawpad/drawpad.h2
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp20
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h5
4 files changed, 40 insertions, 6 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 3331193..d9d0ce0 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -33,48 +33,50 @@
33#include <opie2/qcolordialog.h> 33#include <opie2/qcolordialog.h>
34#include <opie2/ocolorpopupmenu.h> 34#include <opie2/ocolorpopupmenu.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 <qtoolbar.h> 38#include <qtoolbar.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40#include <qpe/qpeapplication.h> 40#include <qpe/qpeapplication.h>
41 41
42#include <qmenubar.h> 42#include <qmenubar.h>
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 <qspinbox.h> 46#include <qspinbox.h>
47#include <qtoolbutton.h> 47#include <qtoolbutton.h>
48#include <qtooltip.h> 48#include <qtooltip.h>
49#include <qwhatsthis.h> 49#include <qwhatsthis.h>
50 50
51using namespace Opie::Ui; 51using namespace Opie::Ui;
52using namespace Opie::Ui; 52using namespace Opie::Ui;
53DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ ) 53DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ )
54 : QMainWindow(parent, name, WStyle_ContextHelp) 54 : QMainWindow(parent, name, WStyle_ContextHelp)
55{ 55{
56 // init members 56 // init members
57 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
58 this, SLOT(slotAppMessage(const QCString&, const QByteArray&)) );
57 59
58 m_pDrawPadCanvas = new DrawPadCanvas(this, this); 60 m_pDrawPadCanvas = new DrawPadCanvas(this, this);
59 61
60 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); 62 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView()));
61 63
62 setCentralWidget(m_pDrawPadCanvas); 64 setCentralWidget(m_pDrawPadCanvas);
63 65
64 // init menu 66 // init menu
65 67
66 setToolBarsMovable(false); 68 setToolBarsMovable(false);
67 69
68 QToolBar* menuToolBar = new QToolBar(this); 70 QToolBar* menuToolBar = new QToolBar(this);
69 QMenuBar* menuBar = new QMenuBar(menuToolBar); 71 QMenuBar* menuBar = new QMenuBar(menuToolBar);
70 72
71 QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); 73 QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar);
72 74
73 QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); 75 QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
74 connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); 76 connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll()));
75 deleteAllAction->addTo(toolsPopupMenu); 77 deleteAllAction->addTo(toolsPopupMenu);
76 78
77 toolsPopupMenu->insertSeparator(); 79 toolsPopupMenu->insertSeparator();
78 80
79 QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); 81 QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this);
80 connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); 82 connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage()));
@@ -642,24 +644,41 @@ void DrawPad::pageInformation()
642 644
643void DrawPad::loadConfig() 645void DrawPad::loadConfig()
644{ 646{
645 Config config("drawpad"); 647 Config config("drawpad");
646 config.setGroup("General"); 648 config.setGroup("General");
647 649
648 m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false)); 650 m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false));
649 m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1)); 651 m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1));
650 changePenColor(QColor(config.readEntry("PenColor", Qt::black.name()))); 652 changePenColor(QColor(config.readEntry("PenColor", Qt::black.name())));
651 changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name()))); 653 changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name())));
652 m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1)); 654 m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1));
653} 655}
654 656
655void DrawPad::saveConfig() 657void DrawPad::saveConfig()
656{ 658{
657 Config config("drawpad"); 659 Config config("drawpad");
658 config.setGroup("General"); 660 config.setGroup("General");
659 661
660 config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition()); 662 config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition());
661 config.writeEntry("AntiAliasing", antiAliasing()); 663 config.writeEntry("AntiAliasing", antiAliasing());
662 config.writeEntry("PenWidth", (int)m_pen.width()); 664 config.writeEntry("PenWidth", (int)m_pen.width());
663 config.writeEntry("PenColor", m_pen.color().name()); 665 config.writeEntry("PenColor", m_pen.color().name());
664 config.writeEntry("BrushColor", m_brush.color().name()); 666 config.writeEntry("BrushColor", m_brush.color().name());
665} 667}
668
669
670/*
671 * Import a Thumbnail from SCAP or similiar
672 */
673void DrawPad::slotAppMessage( const QCString& str, const QByteArray& ar ) {
674 QDataStream stream(ar, IO_ReadOnly );
675 /*
676 * import the pixmap
677 */
678 if ( str == "importPixmap(QPixmap)" ) {
679 QPixmap pix;
680 stream >> pix;;
681 m_pDrawPadCanvas->importPixmap( pix );
682 QPEApplication::setKeepRunning();
683 }
684}
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h
index 8ba6e58..ba9e47d 100644
--- a/noncore/graphics/drawpad/drawpad.h
+++ b/noncore/graphics/drawpad/drawpad.h
@@ -27,48 +27,50 @@ class QToolButton;
27class QWidgetStack; 27class QWidgetStack;
28 28
29class DrawPad : public QMainWindow 29class DrawPad : public QMainWindow
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32 32
33public: 33public:
34 DrawPad(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 34 DrawPad(QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
35 ~DrawPad(); 35 ~DrawPad();
36 36
37 static QString appName() { return QString::fromLatin1("drawpad"); } 37 static QString appName() { return QString::fromLatin1("drawpad"); }
38 38
39 Tool* tool() { return m_pTool; } 39 Tool* tool() { return m_pTool; }
40 QPen pen() { return m_pen; } 40 QPen pen() { return m_pen; }
41 QBrush brush() { return m_brush; } 41 QBrush brush() { return m_brush; }
42 42
43 bool antiAliasing(); 43 bool antiAliasing();
44 void finishStartup(); 44 void finishStartup();
45 45
46private slots: 46private slots:
47 void newPage(); 47 void newPage();
48 void clearPage(); 48 void clearPage();
49 void deletePage(); 49 void deletePage();
50 50
51 void slotAppMessage( const QCString&, const QByteArray& );
52
51 void setPointTool(); 53 void setPointTool();
52 void setLineTool(); 54 void setLineTool();
53 void setRectangleTool(); 55 void setRectangleTool();
54 void setFilledRectangleTool(); 56 void setFilledRectangleTool();
55 void setEllipseTool(); 57 void setEllipseTool();
56 void setFilledEllipseTool(); 58 void setFilledEllipseTool();
57 void setTextTool(); 59 void setTextTool();
58 void setFillTool(); 60 void setFillTool();
59 void setEraseTool(); 61 void setEraseTool();
60 62
61 void changePenWidth(int value); 63 void changePenWidth(int value);
62 void changePenColor(const QColor& color); 64 void changePenColor(const QColor& color);
63 void changeBrushColor(const QColor& color); 65 void changeBrushColor(const QColor& color);
64 66
65 void updateView(); 67 void updateView();
66 68
67 void deleteAll(); 69 void deleteAll();
68 void importPage(); 70 void importPage();
69 void exportPage(); 71 void exportPage();
70 void thumbnailView(); 72 void thumbnailView();
71 void pageInformation(); 73 void pageInformation();
72 74
73private: 75private:
74 void loadConfig(); 76 void loadConfig();
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 446096c..423ef26 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -159,63 +159,63 @@ DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name
159 m_pages.setAutoDelete(true); 159 m_pages.setAutoDelete(true);
160 160
161 viewport()->setBackgroundMode(QWidget::NoBackground); 161 viewport()->setBackgroundMode(QWidget::NoBackground);
162} 162}
163 163
164DrawPadCanvas::~DrawPadCanvas() 164DrawPadCanvas::~DrawPadCanvas()
165{ 165{
166} 166}
167 167
168void DrawPadCanvas::load(QIODevice* ioDevice) 168void DrawPadCanvas::load(QIODevice* ioDevice)
169{ 169{
170 QTextStream textStream(ioDevice); 170 QTextStream textStream(ioDevice);
171 textStream.setCodec(QTextCodec::codecForName("UTF-8")); 171 textStream.setCodec(QTextCodec::codecForName("UTF-8"));
172 172
173 QXmlInputSource xmlInputSource(textStream); 173 QXmlInputSource xmlInputSource(textStream);
174 QXmlSimpleReader xmlSimpleReader; 174 QXmlSimpleReader xmlSimpleReader;
175 DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; 175 DrawPadCanvasXmlHandler drawPadCanvasXmlHandler;
176 176
177 xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); 177 xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler);
178 xmlSimpleReader.parse(xmlInputSource); 178 xmlSimpleReader.parse(xmlInputSource);
179 179
180 m_pages = drawPadCanvasXmlHandler.pages(); 180 m_pages = drawPadCanvasXmlHandler.pages();
181 181
182 if (m_pages.isEmpty()) { 182 if (m_pages.isEmpty()) {
183 m_pages.append(new Page("", 183 m_pages.append(new Page("",
184 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 184 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
185 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 185 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
186 m_pages.current()->pixmap()->fill(Qt::white); 186 m_pages.current()->pixmap()->fill(Qt::white);
187 } 187 }
188 188
189 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 189 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
190 viewport()->update(); 190 viewport()->update();
191 191
192 emit pagesChanged(); 192 emit pagesChanged();
193} 193}
194 194
195void DrawPadCanvas::initialPage() 195void DrawPadCanvas::initialPage()
196{ 196{
197 m_pages.append(new Page("", 197 m_pages.append(new Page("",
198 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 198 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
199 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 199 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
200 //236, 232)); no more fixed sizes 200 //236, 232)); no more fixed sizes
201 201
202 m_pages.current()->pixmap()->fill(Qt::white); 202 m_pages.current()->pixmap()->fill(Qt::white);
203 203
204 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 204 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
205 viewport()->update(); 205 viewport()->update();
206 206
207 emit pagesChanged(); 207 emit pagesChanged();
208} 208}
209 209
210void DrawPadCanvas::save(QIODevice* ioDevice) 210void DrawPadCanvas::save(QIODevice* ioDevice)
211{ 211{
212 QTextStream textStream(ioDevice); 212 QTextStream textStream(ioDevice);
213 textStream.setCodec(QTextCodec::codecForName("UTF-8")); 213 textStream.setCodec(QTextCodec::codecForName("UTF-8"));
214 214
215 textStream << "<drawpad>" << endl; 215 textStream << "<drawpad>" << endl;
216 textStream << " <images>" << endl; 216 textStream << " <images>" << endl;
217 217
218 QListIterator<Page> bufferIterator(m_pages); 218 QListIterator<Page> bufferIterator(m_pages);
219 219
220 for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { 220 for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) {
221 textStream << " <image>" << endl; 221 textStream << " <image>" << endl;
@@ -244,48 +244,60 @@ void DrawPadCanvas::save(QIODevice* ioDevice)
244 textStream << hexchars[s & 0x0f]; 244 textStream << hexchars[s & 0x0f];
245 } 245 }
246 246
247 textStream << "</data>" << endl; 247 textStream << "</data>" << endl;
248 textStream << " </image>" << endl; 248 textStream << " </image>" << endl;
249 } 249 }
250 250
251 textStream << " </images>" << endl; 251 textStream << " </images>" << endl;
252 textStream << "</drawpad>"; 252 textStream << "</drawpad>";
253} 253}
254 254
255void DrawPadCanvas::importPage(const QString& fileName) 255void DrawPadCanvas::importPage(const QString& fileName)
256{ 256{
257 Page* importedPage = new Page(); 257 Page* importedPage = new Page();
258 258
259 importedPage->pixmap()->load(fileName); 259 importedPage->pixmap()->load(fileName);
260 m_pages.insert(m_pages.at() + 1, importedPage); 260 m_pages.insert(m_pages.at() + 1, importedPage);
261 261
262 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 262 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
263 viewport()->update(); 263 viewport()->update();
264 264
265 emit pagesChanged(); 265 emit pagesChanged();
266} 266}
267 267
268void DrawPadCanvas::importPixmap( const QPixmap& pix ) {
269 Page* importedPage = new Page();
270
271 (*importedPage->pixmap()) = pix;
272 m_pages.insert(m_pages.at()+1, importedPage );
273 resizeContents(m_pages.current()->pixmap()->width(),
274 m_pages.current()->pixmap()->height() );
275 viewport()->update();
276
277 emit pagesChanged();
278}
279
268void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) 280void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format)
269{ 281{
270 if (fromPage == toPage) { 282 if (fromPage == toPage) {
271 DocLnk docLnk; 283 DocLnk docLnk;
272 MimeType mimeType(format); 284 MimeType mimeType(format);
273 285
274 docLnk.setName(name); 286 docLnk.setName(name);
275 docLnk.setType(mimeType.id()); 287 docLnk.setType(mimeType.id());
276 288
277 FileManager fileManager; 289 FileManager fileManager;
278 QIODevice* ioDevice = fileManager.saveFile(docLnk); 290 QIODevice* ioDevice = fileManager.saveFile(docLnk);
279 QImageIO imageIO(ioDevice, format); 291 QImageIO imageIO(ioDevice, format);
280 292
281 QImage image = m_pages.current()->pixmap()->convertToImage(); 293 QImage image = m_pages.current()->pixmap()->convertToImage();
282 imageIO.setImage(image); 294 imageIO.setImage(image);
283 imageIO.write(); 295 imageIO.write();
284 delete ioDevice; 296 delete ioDevice;
285 } else { 297 } else {
286 for (uint i = fromPage; i <= toPage; i++) { 298 for (uint i = fromPage; i <= toPage; i++) {
287 DocLnk docLnk; 299 DocLnk docLnk;
288 MimeType mimeType(format); 300 MimeType mimeType(format);
289 301
290 docLnk.setName(name + QString::number(i)); 302 docLnk.setName(name + QString::number(i));
291 docLnk.setType(mimeType.id()); 303 docLnk.setType(mimeType.id());
@@ -332,85 +344,85 @@ void DrawPadCanvas::selectPage(Page* page)
332 emit pagesChanged(); 344 emit pagesChanged();
333} 345}
334 346
335void DrawPadCanvas::backupPage() 347void DrawPadCanvas::backupPage()
336{ 348{
337 m_pages.current()->backup(); 349 m_pages.current()->backup();
338 350
339 emit pagesChanged(); 351 emit pagesChanged();
340} 352}
341 353
342void DrawPadCanvas::selectPage(uint pagePosition) 354void DrawPadCanvas::selectPage(uint pagePosition)
343{ 355{
344 m_pages.at(pagePosition - 1); 356 m_pages.at(pagePosition - 1);
345 357
346 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 358 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
347 viewport()->update(); 359 viewport()->update();
348 360
349 emit pagesChanged(); 361 emit pagesChanged();
350} 362}
351 363
352void DrawPadCanvas::deleteAll() 364void DrawPadCanvas::deleteAll()
353{ 365{
354 m_pages.clear(); 366 m_pages.clear();
355 367
356 m_pages.append(new Page("", 368 m_pages.append(new Page("",
357 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 369 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
358 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 370 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
359 371
360 m_pages.current()->pixmap()->fill(Qt::white); 372 m_pages.current()->pixmap()->fill(Qt::white);
361 373
362 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 374 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
363 viewport()->update(); 375 viewport()->update();
364 376
365 emit pagesChanged(); 377 emit pagesChanged();
366} 378}
367 379
368void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) 380void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color)
369{ 381{
370 m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); 382 m_pages.insert(m_pages.at() + 1, new Page(title, width, height));
371 m_pages.current()->pixmap()->fill(color); 383 m_pages.current()->pixmap()->fill(color);
372 384
373 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 385 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
374 viewport()->update(); 386 viewport()->update();
375 387
376 emit pagesChanged(); 388 emit pagesChanged();
377} 389}
378 390
379void DrawPadCanvas::clearPage() 391void DrawPadCanvas::clearPage()
380{ 392{
381 m_pages.current()->pixmap()->fill(Qt::white); 393 m_pages.current()->pixmap()->fill(Qt::white);
382 394
383 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 395 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
384 viewport()->update(); 396 viewport()->update();
385} 397}
386 398
387void DrawPadCanvas::deletePage() 399void DrawPadCanvas::deletePage()
388{ 400{
389 m_pages.remove(m_pages.current()); 401 m_pages.remove(m_pages.current());
390 402
391 if (m_pages.isEmpty()) { 403 if (m_pages.isEmpty()) {
392 m_pages.append(new Page("", 404 m_pages.append(new Page("",
393 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 405 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
394 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 406 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
395 407
396 m_pages.current()->pixmap()->fill(Qt::white); 408 m_pages.current()->pixmap()->fill(Qt::white);
397 } 409 }
398 410
399 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 411 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
400 viewport()->update(); 412 viewport()->update();
401 413
402 emit pagesChanged(); 414 emit pagesChanged();
403} 415}
404 416
405void DrawPadCanvas::movePageUp() 417void DrawPadCanvas::movePageUp()
406{ 418{
407 int index = m_pages.at(); 419 int index = m_pages.at();
408 Page* page = m_pages.take(); 420 Page* page = m_pages.take();
409 m_pages.insert(index - 1, page); 421 m_pages.insert(index - 1, page);
410 422
411 emit pagesChanged(); 423 emit pagesChanged();
412} 424}
413 425
414void DrawPadCanvas::movePageDown() 426void DrawPadCanvas::movePageDown()
415{ 427{
416 int index = m_pages.at(); 428 int index = m_pages.at();
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h
index 80a2a7e..2b3d4a5 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.h
+++ b/noncore/graphics/drawpad/drawpadcanvas.h
@@ -2,81 +2,82 @@
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#ifndef DRAWPADCANVAS_H 14#ifndef DRAWPADCANVAS_H
15#define DRAWPADCANVAS_H 15#define DRAWPADCANVAS_H
16 16
17#include <qscrollview.h> 17#include <qscrollview.h>
18 18
19#include <qlist.h> 19#include <qlist.h>
20#include <qpointarray.h> 20#include <qpointarray.h>
21 21
22class DrawPad; 22class DrawPad;
23class Page; 23class Page;
24 24
25class DrawPadCanvas : public QScrollView 25class DrawPadCanvas : public QScrollView
26{ 26{
27 Q_OBJECT 27 Q_OBJECT
28 28
29public: 29public:
30 DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0); 30 DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0);
31 ~DrawPadCanvas(); 31 ~DrawPadCanvas();
32 32
33 void load(QIODevice* ioDevice); 33 void load(QIODevice* ioDevice);
34 void initialPage(); 34 void initialPage();
35 void save(QIODevice* ioDevice); 35 void save(QIODevice* ioDevice);
36 36
37 void importPage(const QString& fileName); 37 void importPage(const QString& fileName);
38 void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format); 38 void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format);
39 void importPixmap( const QPixmap& );
39 40
40 bool goPreviousPageEnabled(); 41 bool goPreviousPageEnabled();
41 bool goNextPageEnabled(); 42 bool goNextPageEnabled();
42 43
43 Page* currentPage(); 44 Page* currentPage();
44 QList<Page> pages(); 45 QList<Page> pages();
45 uint pagePosition(); 46 uint pagePosition();
46 uint pageCount(); 47 uint pageCount();
47 48
48 void selectPage(Page* page); 49 void selectPage(Page* page);
49 void selectPage(uint pagePosition); 50 void selectPage(uint pagePosition);
50 void backupPage(); 51 void backupPage();
51 52
52public slots: 53public slots:
53 void deleteAll(); 54 void deleteAll();
54 void newPage(QString title, uint width, uint height, const QColor& color); 55 void newPage(QString title, uint width, uint height, const QColor& color);
55 void clearPage(); 56 void clearPage();
56 void deletePage(); 57 void deletePage();
57 void movePageUp(); 58 void movePageUp();
58 void movePageDown(); 59 void movePageDown();
59 60
60 void undo(); 61 void undo();
61 void redo(); 62 void redo();
62 63
63 void goFirstPage(); 64 void goFirstPage();
64 void goPreviousPage(); 65 void goPreviousPage();
65 void goNextPage(); 66 void goNextPage();
66 void goLastPage(); 67 void goLastPage();
67 68
68signals: 69signals:
69 void pagesChanged(); 70 void pagesChanged();
70 71
71protected: 72protected:
72 void contentsMousePressEvent(QMouseEvent* e); 73 void contentsMousePressEvent(QMouseEvent* e);
73 void contentsMouseReleaseEvent(QMouseEvent* e); 74 void contentsMouseReleaseEvent(QMouseEvent* e);
74 void contentsMouseMoveEvent(QMouseEvent* e); 75 void contentsMouseMoveEvent(QMouseEvent* e);
75 void drawContents(QPainter* p, int cx, int cy, int cw, int ch); 76 void drawContents(QPainter* p, int cx, int cy, int cw, int ch);
76 77
77private: 78private:
78 DrawPad* m_pDrawPad; 79 DrawPad* m_pDrawPad;
79 QList<Page> m_pages; 80 QList<Page> m_pages;
80}; 81};
81 82
82#endif // DRAWPADCANVAS_H 83#endif // DRAWPADCANVAS_H