summaryrefslogtreecommitdiff
authorleseb <leseb>2002-03-19 12:58:43 (UTC)
committer leseb <leseb>2002-03-19 12:58:43 (UTC)
commitf298cb9f5557d88b9ff38feb4b5e090e5c164ec2 (patch) (unidiff)
treea27f4d18cf3a0b62987cc37238e78d7269b2504e
parent58a456b92ba8986d4ea2375ddcfd6dd1d84c8fe5 (diff)
downloadopie-f298cb9f5557d88b9ff38feb4b5e090e5c164ec2.zip
opie-f298cb9f5557d88b9ff38feb4b5e090e5c164ec2.tar.gz
opie-f298cb9f5557d88b9ff38feb4b5e090e5c164ec2.tar.bz2
Better color selection
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/colordialog.cpp851
-rw-r--r--noncore/graphics/drawpad/colordialog.h77
-rw-r--r--noncore/graphics/drawpad/colorpanel.cpp134
-rw-r--r--noncore/graphics/drawpad/colorpanel.h65
-rw-r--r--noncore/graphics/drawpad/drawmode.h2
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp64
-rw-r--r--noncore/graphics/drawpad/drawpad.h7
-rw-r--r--noncore/graphics/drawpad/drawpad.pro10
-rw-r--r--noncore/graphics/drawpad/ellipsedrawmode.cpp2
-rw-r--r--noncore/graphics/drawpad/erasedrawmode.cpp2
-rw-r--r--noncore/graphics/drawpad/filldrawmode.cpp4
-rw-r--r--noncore/graphics/drawpad/linedrawmode.cpp2
-rw-r--r--noncore/graphics/drawpad/pointdrawmode.cpp2
-rw-r--r--noncore/graphics/drawpad/rectangledrawmode.cpp2
14 files changed, 1184 insertions, 40 deletions
diff --git a/noncore/graphics/drawpad/colordialog.cpp b/noncore/graphics/drawpad/colordialog.cpp
new file mode 100644
index 0000000..6d72ff6
--- a/dev/null
+++ b/noncore/graphics/drawpad/colordialog.cpp
@@ -0,0 +1,851 @@
1/****************************************************************************
2** $Id$
3**
4** Implementation of QColorDialog class
5**
6** Created : 990222
7**
8** Copyright (C) 1999-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the dialogs module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "colordialog.h"
39
40#include "qpainter.h"
41#include "qlayout.h"
42#include "qlabel.h"
43#include "qpushbutton.h"
44#include "qlineedit.h"
45#include "qimage.h"
46#include "qpixmap.h"
47#include "qdrawutil.h"
48#include "qvalidator.h"
49#include "qdragobject.h"
50#include "qapplication.h"
51#include "qdragobject.h"
52
53static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v )
54{
55 QColor c;
56 c.setRgb( rgb );
57 c.getHsv(h,s,v);
58}
59
60class QColorPicker : public QFrame
61{
62 Q_OBJECT
63public:
64 QColorPicker(QWidget* parent=0, const char* name=0);
65 ~QColorPicker();
66
67public slots:
68 void setCol( int h, int s );
69
70signals:
71 void newCol( int h, int s );
72
73protected:
74 QSize sizeHint() const;
75 QSizePolicy sizePolicy() const;
76 void drawContents(QPainter* p);
77 void mouseMoveEvent( QMouseEvent * );
78 void mousePressEvent( QMouseEvent * );
79
80private:
81 int hue;
82 int sat;
83
84 QPoint colPt();
85 int huePt( const QPoint &pt );
86 int satPt( const QPoint &pt );
87 void setCol( const QPoint &pt );
88
89 QPixmap *pix;
90};
91
92static int pWidth = 200;
93static int pHeight = 200;
94
95class QColorLuminancePicker : public QWidget
96{
97 Q_OBJECT
98public:
99 QColorLuminancePicker(QWidget* parent=0, const char* name=0);
100 ~QColorLuminancePicker();
101
102public slots:
103 void setCol( int h, int s, int v );
104 void setCol( int h, int s );
105
106signals:
107 void newHsv( int h, int s, int v );
108
109protected:
110// QSize sizeHint() const;
111// QSizePolicy sizePolicy() const;
112 void paintEvent( QPaintEvent*);
113 void mouseMoveEvent( QMouseEvent * );
114 void mousePressEvent( QMouseEvent * );
115
116private:
117 enum { foff = 3, coff = 4 }; //frame and contents offset
118 int val;
119 int hue;
120 int sat;
121
122 int y2val( int y );
123 int val2y( int val );
124 void setVal( int v );
125
126 QPixmap *pix;
127};
128
129
130int QColorLuminancePicker::y2val( int y )
131{
132 int d = height() - 2*coff - 1;
133 return 255 - (y - coff)*255/d;
134}
135
136int QColorLuminancePicker::val2y( int v )
137{
138 int d = height() - 2*coff - 1;
139 return coff + (255-v)*d/255;
140}
141
142QColorLuminancePicker::QColorLuminancePicker(QWidget* parent,
143 const char* name)
144 :QWidget( parent, name )
145{
146 hue = 100; val = 100; sat = 100;
147 pix = 0;
148 // setBackgroundMode( NoBackground );
149}
150
151QColorLuminancePicker::~QColorLuminancePicker()
152{
153 delete pix;
154}
155
156void QColorLuminancePicker::mouseMoveEvent( QMouseEvent *m )
157{
158 setVal( y2val(m->y()) );
159}
160void QColorLuminancePicker::mousePressEvent( QMouseEvent *m )
161{
162 setVal( y2val(m->y()) );
163}
164
165void QColorLuminancePicker::setVal( int v )
166{
167 if ( val == v )
168 return;
169 val = QMAX( 0, QMIN(v,255));
170 delete pix; pix=0;
171 repaint( FALSE ); //###
172 emit newHsv( hue, sat, val );
173}
174
175//receives from a hue,sat chooser and relays.
176void QColorLuminancePicker::setCol( int h, int s )
177{
178 setCol( h, s, val );
179 emit newHsv( h, s, val );
180}
181
182void QColorLuminancePicker::paintEvent( QPaintEvent * )
183{
184 int w = width() - 5;
185
186 QRect r( 0, foff, w, height() - 2*foff );
187 int wi = r.width() - 2;
188 int hi = r.height() - 2;
189 if ( !pix || pix->height() != hi || pix->width() != wi ) {
190 delete pix;
191 QImage img( wi, hi, 32 );
192 int y;
193 for ( y = 0; y < hi; y++ ) {
194 QColor c( hue, sat, y2val(y+coff), QColor::Hsv );
195 QRgb r = c.rgb();
196 int x;
197 for ( x = 0; x < wi; x++ )
198 img.setPixel( x, y, r );
199 }
200 pix = new QPixmap;
201 pix->convertFromImage(img);
202 }
203 QPainter p(this);
204 p.drawPixmap( 1, coff, *pix );
205 QColorGroup g = colorGroup();
206 qDrawShadePanel( &p, r, g, TRUE );
207 p.setPen( g.foreground() );
208 p.setBrush( g.foreground() );
209 QPointArray a;
210 int y = val2y(val);
211 a.setPoints( 3, w, y, w+5, y+5, w+5, y-5 );
212 erase( w, 0, 5, height() );
213 p.drawPolygon( a );
214}
215
216void QColorLuminancePicker::setCol( int h, int s , int v )
217{
218 val = v;
219 hue = h;
220 sat = s;
221 delete pix; pix=0;
222 repaint( FALSE );//####
223}
224
225QPoint QColorPicker::colPt()
226{ return QPoint( (360-hue)*(pWidth-1)/360, (255-sat)*(pHeight-1)/255 ); }
227int QColorPicker::huePt( const QPoint &pt )
228{ return 360 - pt.x()*360/(pWidth-1); }
229int QColorPicker::satPt( const QPoint &pt )
230{ return 255 - pt.y()*255/(pHeight-1) ; }
231void QColorPicker::setCol( const QPoint &pt )
232{ setCol( huePt(pt), satPt(pt) ); }
233
234QColorPicker::QColorPicker(QWidget* parent, const char* name )
235 : QFrame( parent, name )
236{
237 hue = 0; sat = 0;
238 setCol( 150, 255 );
239
240 QImage img( pWidth, pHeight, 32 );
241 int x,y;
242 for ( y = 0; y < pHeight; y++ )
243 for ( x = 0; x < pWidth; x++ ) {
244 QPoint p( x, y );
245 img.setPixel( x, y, QColor(huePt(p), satPt(p),
246 200, QColor::Hsv).rgb() );
247 }
248 pix = new QPixmap;
249 pix->convertFromImage(img);
250 setBackgroundMode( NoBackground );
251}
252
253QColorPicker::~QColorPicker()
254{
255 delete pix;
256}
257
258QSize QColorPicker::sizeHint() const
259{
260 return QSize( pWidth + 2*frameWidth(), pHeight + 2*frameWidth() );
261}
262
263QSizePolicy QColorPicker::sizePolicy() const
264{
265 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
266}
267
268void QColorPicker::setCol( int h, int s )
269{
270 int nhue = QMIN( QMAX(0,h), 360 );
271 int nsat = QMIN( QMAX(0,s), 255);
272 if ( nhue == hue && nsat == sat )
273 return;
274 QRect r( colPt(), QSize(20,20) );
275 hue = nhue; sat = nsat;
276 r = r.unite( QRect( colPt(), QSize(20,20) ) );
277 r.moveBy( contentsRect().x()-9, contentsRect().y()-9 );
278 // update( r );
279 repaint( r, FALSE );
280}
281
282void QColorPicker::mouseMoveEvent( QMouseEvent *m )
283{
284 QPoint p = m->pos() - contentsRect().topLeft();
285 setCol( p );
286 emit newCol( hue, sat );
287}
288
289void QColorPicker::mousePressEvent( QMouseEvent *m )
290{
291 QPoint p = m->pos() - contentsRect().topLeft();
292 setCol( p );
293 emit newCol( hue, sat );
294}
295
296void QColorPicker::drawContents(QPainter* p)
297{
298 QRect r = contentsRect();
299
300 p->drawPixmap( r.topLeft(), *pix );
301 QPoint pt = colPt() + r.topLeft();
302 p->setPen( QPen(black) );
303
304 p->fillRect( pt.x()-9, pt.y(), 20, 2, black );
305 p->fillRect( pt.x(), pt.y()-9, 2, 20, black );
306
307}
308
309class QColorShowLabel;
310
311
312
313class QColIntValidator: public QIntValidator
314{
315public:
316 QColIntValidator( int bottom, int top,
317 QWidget * parent, const char *name = 0 )
318 :QIntValidator( bottom, top, parent, name ) {}
319
320 QValidator::State validate( QString &, int & ) const;
321};
322
323QValidator::State QColIntValidator::validate( QString &s, int &pos ) const
324{
325 State state = QIntValidator::validate(s,pos);
326 if ( state == Valid ) {
327 long int val = s.toLong();
328 // This is not a general solution, assumes that top() > 0 and
329 // bottom >= 0
330 if ( val < 0 ) {
331 s = "0";
332 pos = 1;
333 } else if ( val > top() ) {
334 s.setNum( top() );
335 pos = s.length();
336 }
337 }
338 return state;
339}
340
341
342
343class QColNumLineEdit : public QLineEdit
344{
345public:
346 QColNumLineEdit( QWidget *parent, const char* name = 0 )
347 : QLineEdit( parent, name ) { setMaxLength( 3 );}
348 QSize sizeHint() const {
349 return QSize( 30, //#####
350 QLineEdit::sizeHint().height() ); }
351 void setNum( int i ) {
352 QString s;
353 s.setNum(i);
354 bool block = signalsBlocked();
355 blockSignals(TRUE);
356 setText( s );
357 blockSignals(block);
358 }
359 int val() const { return text().toInt(); }
360};
361
362
363class QColorShower : public QWidget
364{
365 Q_OBJECT
366public:
367 QColorShower( QWidget *parent, const char *name = 0 );
368
369 //things that don't emit signals
370 void setHsv( int h, int s, int v );
371
372 int currentAlpha() const { return alphaEd->val(); }
373 void setCurrentAlpha( int a ) { alphaEd->setNum( a ); }
374 void showAlpha( bool b );
375
376
377 QRgb currentColor() const { return curCol; }
378
379public slots:
380 void setRgb( QRgb rgb );
381
382signals:
383 void newCol( QRgb rgb );
384private slots:
385 void rgbEd();
386 void hsvEd();
387private:
388 void showCurrentColor();
389 int hue, sat, val;
390 QRgb curCol;
391 QColNumLineEdit *hEd;
392 QColNumLineEdit *sEd;
393 QColNumLineEdit *vEd;
394 QColNumLineEdit *rEd;
395 QColNumLineEdit *gEd;
396 QColNumLineEdit *bEd;
397 QColNumLineEdit *alphaEd;
398 QLabel *alphaLab;
399 QColorShowLabel *lab;
400 bool rgbOriginal;
401};
402
403class QColorShowLabel : public QFrame
404{
405 Q_OBJECT
406
407public:
408 QColorShowLabel( QWidget *parent ) :QFrame( parent ) {
409 setFrameStyle( QFrame::Panel|QFrame::Sunken );
410 setBackgroundMode( PaletteBackground );
411 setAcceptDrops( TRUE );
412 mousePressed = FALSE;
413 }
414 void setColor( QColor c ) { col = c; }
415
416signals:
417 void colorDropped( QRgb );
418
419protected:
420 void drawContents( QPainter *p );
421 void mousePressEvent( QMouseEvent *e );
422 void mouseReleaseEvent( QMouseEvent *e );
423
424private:
425 QColor col;
426 bool mousePressed;
427 QPoint pressPos;
428
429};
430
431void QColorShowLabel::drawContents( QPainter *p )
432{
433 p->fillRect( contentsRect(), col );
434}
435
436void QColorShower::showAlpha( bool b )
437{
438 if ( b ) {
439 alphaLab->show();
440 alphaEd->show();
441 } else {
442 alphaLab->hide();
443 alphaEd->hide();
444 }
445}
446
447void QColorShowLabel::mousePressEvent( QMouseEvent *e )
448{
449 mousePressed = TRUE;
450 pressPos = e->pos();
451}
452
453void QColorShowLabel::mouseReleaseEvent( QMouseEvent * )
454{
455 if ( !mousePressed )
456 return;
457 mousePressed = FALSE;
458}
459
460QColorShower::QColorShower( QWidget *parent, const char *name )
461 :QWidget( parent, name)
462{
463 curCol = qRgb( -1, -1, -1 );
464 QColIntValidator *val256 = new QColIntValidator( 0, 255, this );
465 QColIntValidator *val360 = new QColIntValidator( 0, 360, this );
466
467 QGridLayout *gl = new QGridLayout( this, 1, 1, 2 );
468 gl->setMargin( 0 );
469 lab = new QColorShowLabel( this );
470 lab->setMinimumWidth( 60 ); //###
471 gl->addMultiCellWidget(lab, 0,-1,0,0);
472 connect( lab, SIGNAL( colorDropped( QRgb ) ),
473 this, SIGNAL( newCol( QRgb ) ) );
474 connect( lab, SIGNAL( colorDropped( QRgb ) ),
475 this, SLOT( setRgb( QRgb ) ) );
476
477 hEd = new QColNumLineEdit( this );
478 hEd->setValidator( val360 );
479 QLabel *l = new QLabel( hEd, QColorDialog::tr("Hue:"), this );
480 l->setAlignment( AlignRight|AlignVCenter );
481 gl->addWidget( l, 0, 1 );
482 gl->addWidget( hEd, 0, 2 );
483
484 sEd = new QColNumLineEdit( this );
485 sEd->setValidator( val256 );
486 l = new QLabel( sEd, QColorDialog::tr("Sat:"), this );
487 l->setAlignment( AlignRight|AlignVCenter );
488 gl->addWidget( l, 1, 1 );
489 gl->addWidget( sEd, 1, 2 );
490
491 vEd = new QColNumLineEdit( this );
492 vEd->setValidator( val256 );
493 l = new QLabel( vEd, QColorDialog::tr("Val:"), this );
494 l->setAlignment( AlignRight|AlignVCenter );
495 gl->addWidget( l, 2, 1 );
496 gl->addWidget( vEd, 2, 2 );
497
498 rEd = new QColNumLineEdit( this );
499 rEd->setValidator( val256 );
500 l = new QLabel( rEd, QColorDialog::tr("Red:"), this );
501 l->setAlignment( AlignRight|AlignVCenter );
502 gl->addWidget( l, 0, 3 );
503 gl->addWidget( rEd, 0, 4 );
504
505 gEd = new QColNumLineEdit( this );
506 gEd->setValidator( val256 );
507 l = new QLabel( gEd, QColorDialog::tr("Green:"), this );
508 l->setAlignment( AlignRight|AlignVCenter );
509 gl->addWidget( l, 1, 3 );
510 gl->addWidget( gEd, 1, 4 );
511
512 bEd = new QColNumLineEdit( this );
513 bEd->setValidator( val256 );
514 l = new QLabel( bEd, QColorDialog::tr("Blue:"), this );
515 l->setAlignment( AlignRight|AlignVCenter );
516 gl->addWidget( l, 2, 3 );
517 gl->addWidget( bEd, 2, 4 );
518
519 alphaEd = new QColNumLineEdit( this );
520 alphaEd->setValidator( val256 );
521 alphaLab = new QLabel( alphaEd, QColorDialog::tr("Alpha channel:"), this );
522 alphaLab->setAlignment( AlignRight|AlignVCenter );
523 gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 );
524 gl->addWidget( alphaEd, 3, 4 );
525 alphaEd->hide();
526 alphaLab->hide();
527
528 connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
529 connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
530 connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
531
532 connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
533 connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
534 connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
535}
536
537void QColorShower::showCurrentColor()
538{
539 lab->setColor( currentColor() );
540 lab->repaint(FALSE); //###
541}
542
543void QColorShower::rgbEd()
544{
545 rgbOriginal = TRUE;
546 curCol = qRgb( rEd->val(), gEd->val(), bEd->val() );
547 rgb2hsv(currentColor(), hue, sat, val );
548
549 hEd->setNum( hue );
550 sEd->setNum( sat );
551 vEd->setNum( val );
552
553 showCurrentColor();
554 emit newCol( currentColor() );
555}
556
557void QColorShower::hsvEd()
558{
559 rgbOriginal = FALSE;
560 hue = hEd->val();
561 sat = sEd->val();
562 val = vEd->val();
563
564 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb();
565
566 rEd->setNum( qRed(currentColor()) );
567 gEd->setNum( qGreen(currentColor()) );
568 bEd->setNum( qBlue(currentColor()) );
569
570 showCurrentColor();
571 emit newCol( currentColor() );
572}
573
574void QColorShower::setRgb( QRgb rgb )
575{
576 rgbOriginal = TRUE;
577 curCol = rgb;
578
579 rgb2hsv( currentColor(), hue, sat, val );
580
581 hEd->setNum( hue );
582 sEd->setNum( sat );
583 vEd->setNum( val );
584
585 rEd->setNum( qRed(currentColor()) );
586 gEd->setNum( qGreen(currentColor()) );
587 bEd->setNum( qBlue(currentColor()) );
588
589 showCurrentColor();
590}
591
592void QColorShower::setHsv( int h, int s, int v )
593{
594 rgbOriginal = FALSE;
595 hue = h; val = v; sat = s; //Range check###
596 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb();
597
598 hEd->setNum( hue );
599 sEd->setNum( sat );
600 vEd->setNum( val );
601
602 rEd->setNum( qRed(currentColor()) );
603 gEd->setNum( qGreen(currentColor()) );
604 bEd->setNum( qBlue(currentColor()) );
605
606
607 showCurrentColor();
608}
609
610class QColorDialogPrivate : public QObject
611{
612Q_OBJECT
613public:
614 QColorDialogPrivate( QColorDialog *p );
615 QRgb currentColor() const { return cs->currentColor(); }
616 void setCurrentColor( QRgb rgb );
617
618 int currentAlpha() const { return cs->currentAlpha(); }
619 void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); }
620 void showAlpha( bool b ) { cs->showAlpha( b ); }
621
622private slots:
623 void newHsv( int h, int s, int v );
624 void newColorTypedIn( QRgb rgb );
625private:
626 QColorPicker *cp;
627 QColorLuminancePicker *lp;
628 QColorShower *cs;
629};
630
631//sets all widgets to display h,s,v
632void QColorDialogPrivate::newHsv( int h, int s, int v )
633{
634 cs->setHsv( h, s, v );
635 cp->setCol( h, s );
636 lp->setCol( h, s, v );
637}
638
639//sets all widgets to display rgb
640void QColorDialogPrivate::setCurrentColor( QRgb rgb )
641{
642 cs->setRgb( rgb );
643 newColorTypedIn( rgb );
644}
645
646//sets all widgets exept cs to display rgb
647void QColorDialogPrivate::newColorTypedIn( QRgb rgb )
648{
649 int h, s, v;
650 rgb2hsv(rgb, h, s, v );
651 cp->setCol( h, s );
652 lp->setCol( h, s, v);
653}
654
655QColorDialogPrivate::QColorDialogPrivate( QColorDialog *dialog ) :
656 QObject(dialog)
657{
658 int border = 2;
659 QVBoxLayout *topLay = new QVBoxLayout( dialog, border, 2 );
660
661 QHBoxLayout *pickLay = new QHBoxLayout( topLay );
662
663
664 cp = new QColorPicker( dialog );
665 cp->setFrameStyle( QFrame::Panel + QFrame::Sunken );
666 pickLay->addWidget( cp );
667
668 pickLay->addStretch();
669
670 lp = new QColorLuminancePicker( dialog );
671 lp->setFixedWidth( 20 ); //###
672 pickLay->addWidget( lp );
673
674 connect( cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)) );
675 connect( lp, SIGNAL(newHsv(int,int,int)), this, SLOT(newHsv(int,int,int)) );
676
677 topLay->addStretch();
678
679 cs = new QColorShower( dialog );
680 connect( cs, SIGNAL(newCol(QRgb)), this, SLOT(newColorTypedIn(QRgb)));
681 topLay->addWidget( cs );
682
683}
684
685
686// BEING REVISED: jo
687/*!
688 \class QColorDialog qcolordialog.h
689 \brief The QColorDialog class provides a dialog widget for specifying colors.
690 \ingroup dialogs
691
692 The color dialog's function is to allow users to choose colors -
693 for instance, you might use this in a drawing program to allow the
694 user to set the brush color.
695
696 This version of Qt only provides modal color dialogs. The static
697 getColor() function shows the dialog and allows the user to specify a color,
698 while getRgba() does the same but allows the user to specify a color with an
699 alpha channel (transparency) value.
700
701 The user can store customCount() different custom colors. The custom
702 colors are shared by all color dialogs, and remembered during the
703 execution of the program. Use setCustomColor() to set the
704 custom colors, and customColor() to get them.
705
706 <img src=qcolordlg-m.png> <img src=qcolordlg-w.png>
707*/
708
709/*!
710 Constructs a default color dialog. Use setColor() for setting an initial value.
711
712 \sa getColor()
713*/
714
715QColorDialog::QColorDialog(QWidget* parent, const char* name, bool modal) :
716 QDialog(parent, name, modal )
717{
718 d = new QColorDialogPrivate( this );
719}
720
721
722/*!
723 Pops up a modal color dialog letting the user choose a color and returns
724 that color. The color is initially set to \a initial. Returns an \link QColor::isValid() invalid\endlink color if the user cancels
725 the dialog. All colors allocated by the dialog will be deallocated
726 before this function returns.
727*/
728
729QColor QColorDialog::getColor( QColor initial, QWidget *parent,
730 const char *name )
731{
732 int allocContext = QColor::enterAllocContext();
733 QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal
734 if ( parent && parent->icon() && !parent->icon()->isNull() )
735 dlg->setIcon( *parent->icon() );
736 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() )
737 dlg->setIcon( *qApp->mainWidget()->icon() );
738
739 dlg->setCaption( QColorDialog::tr( "Select color" ) );
740 dlg->setColor( initial );
741 dlg->showMaximized();
742 int resultCode = dlg->exec();
743 QColor::leaveAllocContext();
744 QColor result;
745 if ( resultCode == QDialog::Accepted ) {
746 result = dlg->color();
747 } else {
748 result = initial;
749 }
750 QColor::destroyAllocContext(allocContext);
751 delete dlg;
752 return result;
753}
754
755
756/*!
757 Pops up a modal color dialog, letting the user choose a color and an
758 alpha channel value. The color+alpha is initially set to \a initial.
759
760 If \a ok is non-null, \c *ok is set to TRUE if the user clicked OK,
761 and FALSE if the user clicked Cancel.
762
763 If the user clicks Cancel the \a initial value is returned.
764*/
765
766QRgb QColorDialog::getRgba( QRgb initial, bool *ok,
767 QWidget *parent, const char* name )
768{
769 int allocContext = QColor::enterAllocContext();
770 QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal
771 dlg->setColor( initial );
772 dlg->setSelectedAlpha( qAlpha(initial) );
773 dlg->showMaximized();
774 int resultCode = dlg->exec();
775 QColor::leaveAllocContext();
776 QRgb result = initial;
777 if ( resultCode == QDialog::Accepted ) {
778 QRgb c = dlg->color().rgb();
779 int alpha = dlg->selectedAlpha();
780 result = qRgba( qRed(c), qGreen(c), qBlue(c), alpha );
781 }
782 if ( ok )
783 *ok = resultCode == QDialog::Accepted;
784
785 QColor::destroyAllocContext(allocContext);
786 delete dlg;
787 return result;
788}
789
790
791
792
793
794/*!
795 Returns the color currently selected in the dialog.
796
797 \sa setColor()
798*/
799
800QColor QColorDialog::color() const
801{
802 return QColor(d->currentColor());
803}
804
805
806/*! Destructs the dialog and frees any memory it allocated.
807
808*/
809
810QColorDialog::~QColorDialog()
811{
812 //d inherits QObject, so it is deleted by Qt.
813}
814
815
816/*!
817 Sets the color shown in the dialog to \a c.
818
819 \sa color()
820*/
821
822void QColorDialog::setColor( QColor c )
823{
824 d->setCurrentColor( c.rgb() );
825}
826
827
828
829
830/*!
831 Sets the initial alpha channel value to \a a, and show the alpha channel
832 entry box.
833*/
834
835void QColorDialog::setSelectedAlpha( int a )
836{
837 d->showAlpha( TRUE );
838 d->setCurrentAlpha( a );
839}
840
841
842/*!
843 Returns the value selected for the alpha channel.
844*/
845
846int QColorDialog::selectedAlpha() const
847{
848 return d->currentAlpha();
849}
850
851#include "colordialog.moc"
diff --git a/noncore/graphics/drawpad/colordialog.h b/noncore/graphics/drawpad/colordialog.h
new file mode 100644
index 0000000..a2d4d30
--- a/dev/null
+++ b/noncore/graphics/drawpad/colordialog.h
@@ -0,0 +1,77 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of QColorDialog class
5**
6** Created : 990222
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the dialogs module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#ifndef QCOLORDIALOG_H
39#define QCOLORDIALOG_H
40
41#ifndef QT_H
42#include <qdialog.h>
43#endif // QT_H
44
45class QColorDialogPrivate;
46
47class Q_EXPORT QColorDialog : public QDialog
48{
49 Q_OBJECT
50
51public:
52 static QColor getColor( QColor, QWidget *parent=0, const char* name=0 ); // ### 3.0: make const QColor&
53 static QRgb getRgba( QRgb, bool* ok = 0,
54 QWidget *parent=0, const char* name=0 );
55
56private:
57 ~QColorDialog();
58
59 QColorDialog( QWidget* parent=0, const char* name=0, bool modal=FALSE );
60 void setColor( QColor ); // ### 3.0: make const QColor&
61 QColor color() const;
62
63private:
64 void setSelectedAlpha( int );
65 int selectedAlpha() const;
66private:
67 QColorDialogPrivate *d;
68 friend class QColorDialogPrivate;
69
70 private:// Disabled copy constructor and operator=
71#if defined(Q_DISABLE_COPY)
72 QColorDialog( const QColorDialog & );
73 QColorDialog& operator=( const QColorDialog & );
74#endif
75};
76
77#endif
diff --git a/noncore/graphics/drawpad/colorpanel.cpp b/noncore/graphics/drawpad/colorpanel.cpp
new file mode 100644
index 0000000..1db0d7b
--- a/dev/null
+++ b/noncore/graphics/drawpad/colorpanel.cpp
@@ -0,0 +1,134 @@
1/***************************************************************************
2 * *
3 * DrawPad - a drawing program for Opie Environment *
4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 ***************************************************************************/
13
14#include "colorpanel.h"
15
16#include <qlayout.h>
17#include <qpainter.h>
18
19ColorPanelButton::ColorPanelButton(const QColor& color, QWidget* parent, const char* name)
20 : QFrame(parent, name)
21{
22 m_color = color;
23
24 setFixedSize(16, 16);
25 setActive(false);
26}
27
28ColorPanelButton::~ColorPanelButton()
29{
30}
31
32void ColorPanelButton::setActive(bool active)
33{
34 m_active = active;
35
36 if (m_active) {
37 setFrameStyle(Panel | Sunken);
38 } else {
39 setFrameStyle(NoFrame);
40 }
41}
42
43void ColorPanelButton::enterEvent(QEvent* e)
44{
45 Q_UNUSED(e)
46
47 if (!m_active) {
48 setFrameStyle(Panel | Sunken);
49 }
50}
51
52void ColorPanelButton::leaveEvent(QEvent* e)
53{
54 Q_UNUSED(e)
55
56 if (!m_active) {
57 setFrameStyle(NoFrame);
58 }
59}
60
61void ColorPanelButton::paintEvent(QPaintEvent* e)
62{
63 QFrame::paintEvent(e);
64
65 QPainter painter;
66 painter.begin(this);
67 painter.fillRect(2, 2, 12, 12, m_color);
68 painter.setPen(Qt::black);
69 painter.drawRect(2, 2, 12, 12);
70 painter.end();
71}
72
73void ColorPanelButton::mouseReleaseEvent(QMouseEvent* e)
74{
75 Q_UNUSED(e)
76
77 emit selected(m_color);
78}
79
80ColorPanel::ColorPanel(QWidget* parent, const char* name)
81 : QWidget(parent, name)
82{
83 m_pGridLayout = new QGridLayout(this, 5, 6);
84
85 addColor(QColor(255, 255, 255), 0, 1);
86 addColor(QColor(192, 192, 192), 0, 2);
87 addColor(QColor(128, 128, 128), 0, 3);
88 addColor(QColor(64, 64, 64), 0, 4);
89 addColor(QColor(0, 0, 0), 0, 5);
90
91 addColor(QColor(255, 0, 0), 1, 0);
92 addColor(QColor(255, 128, 0), 1, 1);
93 addColor(QColor(255, 255, 0), 1, 2);
94 addColor(QColor(128, 255, 0), 1, 3);
95 addColor(QColor(0, 255, 0), 1, 4);
96 addColor(QColor(0, 255, 128), 1, 5);
97
98 addColor(QColor(128, 0, 0), 2, 0);
99 addColor(QColor(128, 64, 0), 2, 1);
100 addColor(QColor(128, 128, 0), 2, 2);
101 addColor(QColor(64, 128, 0), 2, 3);
102 addColor(QColor(0, 128, 0), 2, 4);
103 addColor(QColor(0, 128, 64), 2, 5);
104
105 addColor(QColor(0, 255, 255), 3, 0);
106 addColor(QColor(0, 128, 255), 3, 1);
107 addColor(QColor(0, 0, 255), 3, 2);
108 addColor(QColor(128, 0, 255), 3, 3);
109 addColor(QColor(255, 0, 255), 3, 4);
110 addColor(QColor(255, 0, 128), 3, 5);
111
112 addColor(QColor(0, 128, 128), 4, 0);
113 addColor(QColor(0, 64, 128), 4, 1);
114 addColor(QColor(0, 0, 128), 4, 2);
115 addColor(QColor(64, 0, 128), 4, 3);
116 addColor(QColor(128, 0, 128), 4, 4);
117 addColor(QColor(128, 0, 64), 4, 5);
118}
119
120ColorPanel::~ColorPanel()
121{
122}
123
124void ColorPanel::addColor(const QColor& color, int row, int col)
125{
126 ColorPanelButton* panelButton = new ColorPanelButton(color, this);
127 connect(panelButton, SIGNAL(selected(const QColor&)), this, SLOT(buttonSelected(const QColor&)));
128 m_pGridLayout->addWidget(panelButton, row, col);
129}
130
131void ColorPanel::buttonSelected(const QColor& color)
132{
133 emit colorSelected(color);
134}
diff --git a/noncore/graphics/drawpad/colorpanel.h b/noncore/graphics/drawpad/colorpanel.h
new file mode 100644
index 0000000..05364c1
--- a/dev/null
+++ b/noncore/graphics/drawpad/colorpanel.h
@@ -0,0 +1,65 @@
1/***************************************************************************
2 * *
3 * DrawPad - a drawing program for Opie Environment *
4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 ***************************************************************************/
13
14#ifndef COLORPANEL_H
15#define COLORPANEL_H
16
17#include <qframe.h>
18#include <qwidget.h>
19
20class QGridLayout;
21
22class ColorPanelButton : public QFrame
23{
24 Q_OBJECT
25
26public:
27 ColorPanelButton(const QColor& color, QWidget* parent = 0, const char* name = 0);
28 ~ColorPanelButton();
29
30 void setActive(bool active);
31
32 void enterEvent(QEvent* e);
33 void leaveEvent(QEvent* e);
34 void paintEvent(QPaintEvent* e);
35 void mouseReleaseEvent(QMouseEvent* e);
36
37signals:
38 void selected(const QColor&);
39
40private:
41 QColor m_color;
42 bool m_active;
43};
44
45class ColorPanel : public QWidget
46{
47 Q_OBJECT
48
49public:
50 ColorPanel(QWidget* parent = 0, const char* name = 0);
51 ~ColorPanel();
52
53 void addColor(const QColor& color, int row, int col);
54
55public slots:
56 void buttonSelected(const QColor& color);
57
58signals:
59 void colorSelected(const QColor&);
60
61private:
62 QGridLayout* m_pGridLayout;
63};
64
65#endif // COLORPANEL_H
diff --git a/noncore/graphics/drawpad/drawmode.h b/noncore/graphics/drawpad/drawmode.h
index 4e80fe2..01e42cc 100644
--- a/noncore/graphics/drawpad/drawmode.h
+++ b/noncore/graphics/drawpad/drawmode.h
@@ -18,9 +18,9 @@
18 18
19class DrawPad; 19class DrawPad;
20class DrawPadCanvas; 20class DrawPadCanvas;
21 21
22class DrawMode : QObject 22class DrawMode : public QObject
23{ 23{
24protected: 24protected:
25 DrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas); 25 DrawMode(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
26 26
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 5cc2197..f67bef8 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -12,8 +12,10 @@
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "drawpad.h" 14#include "drawpad.h"
15 15
16#include "colordialog.h"
17#include "colorpanel.h"
16#include "drawpadcanvas.h" 18#include "drawpadcanvas.h"
17#include "ellipsedrawmode.h" 19#include "ellipsedrawmode.h"
18#include "erasedrawmode.h" 20#include "erasedrawmode.h"
19#include "filldrawmode.h" 21#include "filldrawmode.h"
@@ -52,18 +54,8 @@ DrawPad::DrawPad(QWidget* parent, const char* name, WFlags f)
52 } 54 }
53 55
54 setCentralWidget(m_pDrawPadCanvas); 56 setCentralWidget(m_pDrawPadCanvas);
55 57
56 m_colors.resize(8);
57 m_colors.at(0) = Qt::black;
58 m_colors.at(1) = Qt::white;
59 m_colors.at(2) = Qt::red;
60 m_colors.at(3) = Qt::green;
61 m_colors.at(4) = Qt::blue;
62 m_colors.at(5) = Qt::cyan;
63 m_colors.at(6) = Qt::magenta;
64 m_colors.at(7) = Qt::yellow;
65
66 // init menu 58 // init menu
67 59
68 setToolBarsMovable(false); 60 setToolBarsMovable(false);
69 61
@@ -187,16 +179,18 @@ DrawPad::DrawPad(QWidget* parent, const char* name, WFlags f)
187 m_pPenColorToolButton = new QToolButton(drawParametersToolBar); 179 m_pPenColorToolButton = new QToolButton(drawParametersToolBar);
188 m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); 180 m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png"));
189 181
190 QPopupMenu* penColorPopupMenu = new QPopupMenu(m_pPenColorToolButton); 182 QPopupMenu* penColorPopupMenu = new QPopupMenu(m_pPenColorToolButton);
191 connect(penColorPopupMenu, SIGNAL(activated(int)), this, SLOT(changePenColor(int)));
192 183
193 QPixmap penColorPixmap(14, 14); 184 ColorPanel* penColorPanel = new ColorPanel(penColorPopupMenu);
185 connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&)));
186 penColorPopupMenu->insertItem(penColorPanel);
194 187
195 for (uint i = 0; i < m_colors.size(); i++) { 188 penColorPopupMenu->insertSeparator();
196 penColorPixmap.fill(m_colors.at(i)); 189
197 penColorPopupMenu->insertItem(penColorPixmap, i); 190 QAction* choosePenColorAction = new QAction(tr("More"), tr("More..."), 0, this);
198 } 191 connect(choosePenColorAction, SIGNAL(activated()), this, SLOT(choosePenColor()));
192 choosePenColorAction->addTo(penColorPopupMenu);
199 193
200 QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); 194 QToolTip::add(m_pPenColorToolButton, tr("Pen Color"));
201 m_pPenColorToolButton->setPopup(penColorPopupMenu); 195 m_pPenColorToolButton->setPopup(penColorPopupMenu);
202 m_pPenColorToolButton->setPopupDelay(0); 196 m_pPenColorToolButton->setPopupDelay(0);
@@ -206,16 +200,18 @@ DrawPad::DrawPad(QWidget* parent, const char* name, WFlags f)
206 m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); 200 m_pBrushColorToolButton = new QToolButton(drawParametersToolBar);
207 m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png")); 201 m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png"));
208 202
209 QPopupMenu* brushColorPopupMenu = new QPopupMenu(m_pBrushColorToolButton); 203 QPopupMenu* brushColorPopupMenu = new QPopupMenu(m_pBrushColorToolButton);
210 connect(brushColorPopupMenu, SIGNAL(activated(int)), this, SLOT(changeBrushColor(int)));
211 204
212 QPixmap brushColorPixmap(14, 14); 205 ColorPanel* brushColorPanel = new ColorPanel(brushColorPopupMenu);
206 connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&)));
207 brushColorPopupMenu->insertItem(brushColorPanel);
213 208
214 for (uint i = 0; i < m_colors.size(); i++) { 209 brushColorPopupMenu->insertSeparator();
215 brushColorPixmap.fill(m_colors.at(i)); 210
216 brushColorPopupMenu->insertItem(brushColorPixmap, i); 211 QAction* chooseBrushColorAction = new QAction(tr("More"), tr("More..."), 0, this);
217 } 212 connect(chooseBrushColorAction, SIGNAL(activated()), this, SLOT(chooseBrushColor()));
213 chooseBrushColorAction->addTo(brushColorPopupMenu);
218 214
219 QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); 215 QToolTip::add(m_pBrushColorToolButton, tr("Fill Color"));
220 m_pBrushColorToolButton->setPopup(brushColorPopupMenu); 216 m_pBrushColorToolButton->setPopup(brushColorPopupMenu);
221 m_pBrushColorToolButton->setPopupDelay(0); 217 m_pBrushColorToolButton->setPopupDelay(0);
@@ -333,26 +329,42 @@ void DrawPad::changePenWidth(int value)
333{ 329{
334 m_pen.setWidth(value); 330 m_pen.setWidth(value);
335} 331}
336 332
337void DrawPad::changePenColor(int index) 333void DrawPad::changePenColor(const QColor& color)
338{ 334{
339 m_pen.setColor(m_colors.at(index)); 335 m_pen.setColor(color);
340 336
341 QPainter painter; 337 QPainter painter;
342 painter.begin(m_pPenColorToolButton->pixmap()); 338 painter.begin(m_pPenColorToolButton->pixmap());
343 painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); 339 painter.fillRect(QRect(0, 12, 14, 2), m_pen.color());
344 painter.end(); 340 painter.end();
341
342 m_pPenColorToolButton->popup()->hide();
345} 343}
346 344
347void DrawPad::changeBrushColor(int index) 345void DrawPad::changeBrushColor(const QColor& color)
348{ 346{
349 m_brush = QBrush(m_colors.at(index)); 347 m_brush = QBrush(color);
350 348
351 QPainter painter; 349 QPainter painter;
352 painter.begin(m_pBrushColorToolButton->pixmap()); 350 painter.begin(m_pBrushColorToolButton->pixmap());
353 painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); 351 painter.fillRect(QRect(0, 12, 14, 2), m_brush.color());
354 painter.end(); 352 painter.end();
353
354 m_pBrushColorToolButton->popup()->hide();
355}
356
357void DrawPad::choosePenColor()
358{
359 QColor newPenColor = QColorDialog::getColor(m_pen.color());
360 changePenColor(newPenColor);
361}
362
363void DrawPad::chooseBrushColor()
364{
365 QColor newBrushColor = QColorDialog::getColor(m_brush.color());
366 changeBrushColor(newBrushColor);
355} 367}
356 368
357void DrawPad::updateUndoRedoToolButtons() 369void DrawPad::updateUndoRedoToolButtons()
358{ 370{
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h
index ee81ddf..35b3be4 100644
--- a/noncore/graphics/drawpad/drawpad.h
+++ b/noncore/graphics/drawpad/drawpad.h
@@ -46,17 +46,18 @@ private slots:
46 void setFillDrawMode(); 46 void setFillDrawMode();
47 void setEraseDrawMode(); 47 void setEraseDrawMode();
48 48
49 void changePenWidth(int value); 49 void changePenWidth(int value);
50 void changePenColor(int index); 50 void changePenColor(const QColor& color);
51 void changeBrushColor(int index); 51 void changeBrushColor(const QColor& color);
52 void choosePenColor();
53 void chooseBrushColor();
52 54
53 void updateUndoRedoToolButtons(); 55 void updateUndoRedoToolButtons();
54 void updateNavigationToolButtons(); 56 void updateNavigationToolButtons();
55 57
56private: 58private:
57 DrawPadCanvas* m_pDrawPadCanvas; 59 DrawPadCanvas* m_pDrawPadCanvas;
58 QArray<QColor> m_colors;
59 60
60 DrawMode* m_pDrawMode; 61 DrawMode* m_pDrawMode;
61 QPen m_pen; 62 QPen m_pen;
62 QBrush m_brush; 63 QBrush m_brush;
diff --git a/noncore/graphics/drawpad/drawpad.pro b/noncore/graphics/drawpad/drawpad.pro
index f41dc4f..407a039 100644
--- a/noncore/graphics/drawpad/drawpad.pro
+++ b/noncore/graphics/drawpad/drawpad.pro
@@ -1,27 +1,31 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release
3 HEADERS = drawmode.h \ 3 HEADERS = colordialog.h \
4 colorpanel.h \
5 drawmode.h \
4 drawpad.h \ 6 drawpad.h \
5 drawpadcanvas.h \ 7 drawpadcanvas.h \
6 ellipsedrawmode.h \ 8 ellipsedrawmode.h \
7 erasedrawmode.h \ 9 erasedrawmode.h \
8 filldrawmode.h \ 10 filldrawmode.h \
9 linedrawmode.h \ 11 linedrawmode.h \
10 pointdrawmode.h \ 12 pointdrawmode.h \
11 rectangledrawmode.h 13 rectangledrawmode.h
12 SOURCES = main.cpp \ 14 SOURCES = colordialog.cpp \
15 colorpanel.cpp \
13 drawmode.cpp \ 16 drawmode.cpp \
14 drawpad.cpp \ 17 drawpad.cpp \
15 drawpadcanvas.cpp \ 18 drawpadcanvas.cpp \
16 ellipsedrawmode.cpp \ 19 ellipsedrawmode.cpp \
17 erasedrawmode.cpp \ 20 erasedrawmode.cpp \
18 filldrawmode.cpp \ 21 filldrawmode.cpp \
19 linedrawmode.cpp \ 22 linedrawmode.cpp \
23 main.cpp \
20 pointdrawmode.cpp \ 24 pointdrawmode.cpp \
21 rectangledrawmode.cpp 25 rectangledrawmode.cpp
22 INCLUDEPATH+= $(OPIEDIR)/include \ 26 INCLUDEPATH+= $(OPIEDIR)/include \
23 $(QTDIR)/src/3rdparty/zlib 27 $(QTDIR)/src/3rdparty/zlib
24 DEPENDPATH+= $(OPIEDIR)/include 28 DEPENDPATH+= $(OPIEDIR)/include
25 LIBS += -lqpe 29 LIBS += -lqpe
26 DESTDIR = $(OPIEDIR)/bin 30 DESTDIR = $(OPIEDIR)/bin
27 TARGET = drawpad 31 TARGET = drawpad
diff --git a/noncore/graphics/drawpad/ellipsedrawmode.cpp b/noncore/graphics/drawpad/ellipsedrawmode.cpp
index 1051335..12a1113 100644
--- a/noncore/graphics/drawpad/ellipsedrawmode.cpp
+++ b/noncore/graphics/drawpad/ellipsedrawmode.cpp
@@ -37,9 +37,9 @@ void EllipseDrawMode::mousePressEvent(QMouseEvent* e)
37} 37}
38 38
39void EllipseDrawMode::mouseReleaseEvent(QMouseEvent* e) 39void EllipseDrawMode::mouseReleaseEvent(QMouseEvent* e)
40{ 40{
41 Q_UNUSED(e); 41 Q_UNUSED(e)
42 42
43 QPainter painter; 43 QPainter painter;
44 painter.begin(m_pDrawPadCanvas->currentPage()); 44 painter.begin(m_pDrawPadCanvas->currentPage());
45 painter.setRasterOp(Qt::NotROP); 45 painter.setRasterOp(Qt::NotROP);
diff --git a/noncore/graphics/drawpad/erasedrawmode.cpp b/noncore/graphics/drawpad/erasedrawmode.cpp
index b8e80bc..990cecb 100644
--- a/noncore/graphics/drawpad/erasedrawmode.cpp
+++ b/noncore/graphics/drawpad/erasedrawmode.cpp
@@ -37,9 +37,9 @@ void EraseDrawMode::mousePressEvent(QMouseEvent* e)
37} 37}
38 38
39void EraseDrawMode::mouseReleaseEvent(QMouseEvent* e) 39void EraseDrawMode::mouseReleaseEvent(QMouseEvent* e)
40{ 40{
41 Q_UNUSED(e); 41 Q_UNUSED(e)
42 42
43 m_mousePressed = false; 43 m_mousePressed = false;
44} 44}
45 45
diff --git a/noncore/graphics/drawpad/filldrawmode.cpp b/noncore/graphics/drawpad/filldrawmode.cpp
index db86b63..8f68550 100644
--- a/noncore/graphics/drawpad/filldrawmode.cpp
+++ b/noncore/graphics/drawpad/filldrawmode.cpp
@@ -50,14 +50,14 @@ void FillDrawMode::mousePressEvent(QMouseEvent* e)
50} 50}
51 51
52void FillDrawMode::mouseReleaseEvent(QMouseEvent* e) 52void FillDrawMode::mouseReleaseEvent(QMouseEvent* e)
53{ 53{
54 Q_UNUSED(e); 54 Q_UNUSED(e)
55} 55}
56 56
57void FillDrawMode::mouseMoveEvent(QMouseEvent* e) 57void FillDrawMode::mouseMoveEvent(QMouseEvent* e)
58{ 58{
59 Q_UNUSED(e); 59 Q_UNUSED(e)
60} 60}
61 61
62void FillDrawMode::fillEast(int x, int y) 62void FillDrawMode::fillEast(int x, int y)
63{ 63{
diff --git a/noncore/graphics/drawpad/linedrawmode.cpp b/noncore/graphics/drawpad/linedrawmode.cpp
index 57295f8..15445fc 100644
--- a/noncore/graphics/drawpad/linedrawmode.cpp
+++ b/noncore/graphics/drawpad/linedrawmode.cpp
@@ -37,9 +37,9 @@ void LineDrawMode::mousePressEvent(QMouseEvent* e)
37} 37}
38 38
39void LineDrawMode::mouseReleaseEvent(QMouseEvent* e) 39void LineDrawMode::mouseReleaseEvent(QMouseEvent* e)
40{ 40{
41 Q_UNUSED(e); 41 Q_UNUSED(e)
42 42
43 QPainter painter; 43 QPainter painter;
44 painter.begin(m_pDrawPadCanvas->currentPage()); 44 painter.begin(m_pDrawPadCanvas->currentPage());
45 painter.setPen(m_pDrawPad->pen()); 45 painter.setPen(m_pDrawPad->pen());
diff --git a/noncore/graphics/drawpad/pointdrawmode.cpp b/noncore/graphics/drawpad/pointdrawmode.cpp
index 11722c8..30753d6 100644
--- a/noncore/graphics/drawpad/pointdrawmode.cpp
+++ b/noncore/graphics/drawpad/pointdrawmode.cpp
@@ -37,9 +37,9 @@ void PointDrawMode::mousePressEvent(QMouseEvent* e)
37} 37}
38 38
39void PointDrawMode::mouseReleaseEvent(QMouseEvent* e) 39void PointDrawMode::mouseReleaseEvent(QMouseEvent* e)
40{ 40{
41 Q_UNUSED(e); 41 Q_UNUSED(e)
42 42
43 m_mousePressed = false; 43 m_mousePressed = false;
44} 44}
45 45
diff --git a/noncore/graphics/drawpad/rectangledrawmode.cpp b/noncore/graphics/drawpad/rectangledrawmode.cpp
index f54b47b..60d7cea 100644
--- a/noncore/graphics/drawpad/rectangledrawmode.cpp
+++ b/noncore/graphics/drawpad/rectangledrawmode.cpp
@@ -37,9 +37,9 @@ void RectangleDrawMode::mousePressEvent(QMouseEvent* e)
37} 37}
38 38
39void RectangleDrawMode::mouseReleaseEvent(QMouseEvent* e) 39void RectangleDrawMode::mouseReleaseEvent(QMouseEvent* e)
40{ 40{
41 Q_UNUSED(e); 41 Q_UNUSED(e)
42 42
43 QPainter painter; 43 QPainter painter;
44 painter.begin(m_pDrawPadCanvas->currentPage()); 44 painter.begin(m_pDrawPadCanvas->currentPage());
45 painter.setPen(m_pDrawPad->pen()); 45 painter.setPen(m_pDrawPad->pen());