00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "colordialog.h"
00039
00040 #include "qpainter.h"
00041 #include "qlayout.h"
00042 #include "qlabel.h"
00043 #include "qpushbutton.h"
00044 #include "qlineedit.h"
00045 #include "qimage.h"
00046 #include "qpixmap.h"
00047 #include "qdrawutil.h"
00048 #include "qvalidator.h"
00049 #include "qapplication.h"
00050
00051 static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v )
00052 {
00053 QColor c;
00054 c.setRgb( rgb );
00055 c.getHsv(h,s,v);
00056 }
00057
00058
00059
00060
00061 namespace {
00062
00063 class QColorPicker : public QFrame
00064 {
00065 Q_OBJECT
00066 public:
00067 QColorPicker(QWidget* parent=0, const char* name=0);
00068 ~QColorPicker();
00069
00070 public slots:
00071 void setCol( int h, int s );
00072
00073 signals:
00074 void newCol( int h, int s );
00075
00076 protected:
00077 QSize sizeHint() const;
00078 QSizePolicy sizePolicy() const;
00079 void drawContents(QPainter* p);
00080 void mouseMoveEvent( QMouseEvent * );
00081 void mousePressEvent( QMouseEvent * );
00082
00083 private:
00084 int hue;
00085 int sat;
00086
00087 QPoint colPt();
00088 int huePt( const QPoint &pt );
00089 int satPt( const QPoint &pt );
00090 void setCol( const QPoint &pt );
00091
00092 QPixmap *pix;
00093 };
00094
00095 static int pWidth = 200;
00096 static int pHeight = 200;
00097
00098 class QColorLuminancePicker : public QWidget
00099 {
00100 Q_OBJECT
00101 public:
00102 QColorLuminancePicker(QWidget* parent=0, const char* name=0);
00103 ~QColorLuminancePicker();
00104
00105 public slots:
00106 void setCol( int h, int s, int v );
00107 void setCol( int h, int s );
00108
00109 signals:
00110 void newHsv( int h, int s, int v );
00111
00112 protected:
00113
00114
00115 void paintEvent( QPaintEvent*);
00116 void mouseMoveEvent( QMouseEvent * );
00117 void mousePressEvent( QMouseEvent * );
00118
00119 private:
00120 enum { foff = 3, coff = 4 };
00121 int val;
00122 int hue;
00123 int sat;
00124
00125 int y2val( int y );
00126 int val2y( int val );
00127 void setVal( int v );
00128
00129 QPixmap *pix;
00130 };
00131
00132
00133 int QColorLuminancePicker::y2val( int y )
00134 {
00135 int d = height() - 2*coff - 1;
00136 return 255 - (y - coff)*255/d;
00137 }
00138
00139 int QColorLuminancePicker::val2y( int v )
00140 {
00141 int d = height() - 2*coff - 1;
00142 return coff + (255-v)*d/255;
00143 }
00144
00145 QColorLuminancePicker::QColorLuminancePicker(QWidget* parent,
00146 const char* name)
00147 :QWidget( parent, name )
00148 {
00149 hue = 100; val = 100; sat = 100;
00150 pix = 0;
00151
00152 }
00153
00154 QColorLuminancePicker::~QColorLuminancePicker()
00155 {
00156 delete pix;
00157 }
00158
00159 void QColorLuminancePicker::mouseMoveEvent( QMouseEvent *m )
00160 {
00161 setVal( y2val(m->y()) );
00162 }
00163 void QColorLuminancePicker::mousePressEvent( QMouseEvent *m )
00164 {
00165 setVal( y2val(m->y()) );
00166 }
00167
00168 void QColorLuminancePicker::setVal( int v )
00169 {
00170 if ( val == v )
00171 return;
00172 val = QMAX( 0, QMIN(v,255));
00173 delete pix; pix=0;
00174 repaint( FALSE );
00175 emit newHsv( hue, sat, val );
00176 }
00177
00178
00179 void QColorLuminancePicker::setCol( int h, int s )
00180 {
00181 setCol( h, s, val );
00182 emit newHsv( h, s, val );
00183 }
00184
00185 void QColorLuminancePicker::paintEvent( QPaintEvent * )
00186 {
00187 int w = width() - 5;
00188
00189 QRect r( 0, foff, w, height() - 2*foff );
00190 int wi = r.width() - 2;
00191 int hi = r.height() - 2;
00192 if ( !pix || pix->height() != hi || pix->width() != wi ) {
00193 delete pix;
00194 QImage img( wi, hi, 32 );
00195 int y;
00196 for ( y = 0; y < hi; y++ ) {
00197 QColor c( hue, sat, y2val(y+coff), QColor::Hsv );
00198 QRgb r = c.rgb();
00199 int x;
00200 for ( x = 0; x < wi; x++ )
00201 img.setPixel( x, y, r );
00202 }
00203 pix = new QPixmap;
00204 pix->convertFromImage(img);
00205 }
00206 QPainter p(this);
00207 p.drawPixmap( 1, coff, *pix );
00208 QColorGroup g = colorGroup();
00209 qDrawShadePanel( &p, r, g, TRUE );
00210 p.setPen( g.foreground() );
00211 p.setBrush( g.foreground() );
00212 QPointArray a;
00213 int y = val2y(val);
00214 a.setPoints( 3, w, y, w+5, y+5, w+5, y-5 );
00215 erase( w, 0, 5, height() );
00216 p.drawPolygon( a );
00217 }
00218
00219 void QColorLuminancePicker::setCol( int h, int s , int v )
00220 {
00221 val = v;
00222 hue = h;
00223 sat = s;
00224 delete pix; pix=0;
00225 repaint( FALSE );
00226 }
00227
00228 QPoint QColorPicker::colPt()
00229 { return QPoint( (360-hue)*(pWidth-1)/360, (255-sat)*(pHeight-1)/255 ); }
00230 int QColorPicker::huePt( const QPoint &pt )
00231 { return 360 - pt.x()*360/(pWidth-1); }
00232 int QColorPicker::satPt( const QPoint &pt )
00233 { return 255 - pt.y()*255/(pHeight-1) ; }
00234 void QColorPicker::setCol( const QPoint &pt )
00235 { setCol( huePt(pt), satPt(pt) ); }
00236
00237 QColorPicker::QColorPicker(QWidget* parent, const char* name )
00238 : QFrame( parent, name )
00239 {
00240 hue = 0; sat = 0;
00241 setCol( 150, 255 );
00242
00243 QImage img( pWidth, pHeight, 32 );
00244 int x,y;
00245 for ( y = 0; y < pHeight; y++ )
00246 for ( x = 0; x < pWidth; x++ ) {
00247 QPoint p( x, y );
00248 img.setPixel( x, y, QColor(huePt(p), satPt(p),
00249 200, QColor::Hsv).rgb() );
00250 }
00251 pix = new QPixmap;
00252 pix->convertFromImage(img);
00253 setBackgroundMode( NoBackground );
00254 }
00255
00256 QColorPicker::~QColorPicker()
00257 {
00258 delete pix;
00259 }
00260
00261 QSize QColorPicker::sizeHint() const
00262 {
00263 return QSize( pWidth + 2*frameWidth(), pHeight + 2*frameWidth() );
00264 }
00265
00266 QSizePolicy QColorPicker::sizePolicy() const
00267 {
00268 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
00269 }
00270
00271 void QColorPicker::setCol( int h, int s )
00272 {
00273 int nhue = QMIN( QMAX(0,h), 360 );
00274 int nsat = QMIN( QMAX(0,s), 255);
00275 if ( nhue == hue && nsat == sat )
00276 return;
00277 QRect r( colPt(), QSize(20,20) );
00278 hue = nhue; sat = nsat;
00279 r = r.unite( QRect( colPt(), QSize(20,20) ) );
00280 r.moveBy( contentsRect().x()-9, contentsRect().y()-9 );
00281
00282 repaint( r, FALSE );
00283 }
00284
00285 void QColorPicker::mouseMoveEvent( QMouseEvent *m )
00286 {
00287 QPoint p = m->pos() - contentsRect().topLeft();
00288 setCol( p );
00289 emit newCol( hue, sat );
00290 }
00291
00292 void QColorPicker::mousePressEvent( QMouseEvent *m )
00293 {
00294 QPoint p = m->pos() - contentsRect().topLeft();
00295 setCol( p );
00296 emit newCol( hue, sat );
00297 }
00298
00299 void QColorPicker::drawContents(QPainter* p)
00300 {
00301 QRect r = contentsRect();
00302
00303 p->drawPixmap( r.topLeft(), *pix );
00304 QPoint pt = colPt() + r.topLeft();
00305 p->setPen( QPen(black) );
00306
00307 p->fillRect( pt.x()-9, pt.y(), 20, 2, black );
00308 p->fillRect( pt.x(), pt.y()-9, 2, 20, black );
00309
00310 }
00311
00312 class QColorShowLabel;
00313
00314
00315
00316 class QColIntValidator: public QIntValidator
00317 {
00318 public:
00319 QColIntValidator( int bottom, int top,
00320 QWidget * parent, const char *name = 0 )
00321 :QIntValidator( bottom, top, parent, name ) {}
00322
00323 QValidator::State validate( QString &, int & ) const;
00324 };
00325
00326 QValidator::State QColIntValidator::validate( QString &s, int &pos ) const
00327 {
00328 State state = QIntValidator::validate(s,pos);
00329 if ( state == Valid ) {
00330 long int val = s.toLong();
00331
00332
00333 if ( val < 0 ) {
00334 s = "0";
00335 pos = 1;
00336 } else if ( val > top() ) {
00337 s.setNum( top() );
00338 pos = s.length();
00339 }
00340 }
00341 return state;
00342 }
00343
00344
00345
00346 class QColNumLineEdit : public QLineEdit
00347 {
00348 public:
00349 QColNumLineEdit( QWidget *parent, const char* name = 0 )
00350 : QLineEdit( parent, name ) { setMaxLength( 3 );}
00351 QSize sizeHint() const {
00352 return QSize( 30,
00353 QLineEdit::sizeHint().height() ); }
00354 void setNum( int i ) {
00355 QString s;
00356 s.setNum(i);
00357 bool block = signalsBlocked();
00358 blockSignals(TRUE);
00359 setText( s );
00360 blockSignals(block);
00361 }
00362 int val() const { return text().toInt(); }
00363 };
00364
00365
00366 class QColorShower : public QWidget
00367 {
00368 Q_OBJECT
00369 public:
00370 QColorShower( QWidget *parent, const char *name = 0 );
00371
00372
00373 void setHsv( int h, int s, int v );
00374
00375 int currentAlpha() const { return alphaEd->val(); }
00376 void setCurrentAlpha( int a ) { alphaEd->setNum( a ); }
00377 void showAlpha( bool b );
00378
00379
00380 QRgb currentColor() const { return curCol; }
00381
00382 public slots:
00383 void setRgb( QRgb rgb );
00384
00385 signals:
00386 void newCol( QRgb rgb );
00387 private slots:
00388 void rgbEd();
00389 void hsvEd();
00390 private:
00391 void showCurrentColor();
00392 int hue, sat, val;
00393 QRgb curCol;
00394 QColNumLineEdit *hEd;
00395 QColNumLineEdit *sEd;
00396 QColNumLineEdit *vEd;
00397 QColNumLineEdit *rEd;
00398 QColNumLineEdit *gEd;
00399 QColNumLineEdit *bEd;
00400 QColNumLineEdit *alphaEd;
00401 QLabel *alphaLab;
00402 QColorShowLabel *lab;
00403 bool rgbOriginal;
00404 };
00405
00406 class QColorShowLabel : public QFrame
00407 {
00408 Q_OBJECT
00409
00410 public:
00411 QColorShowLabel( QWidget *parent ) :QFrame( parent ) {
00412 setFrameStyle( QFrame::Panel|QFrame::Sunken );
00413 setBackgroundMode( PaletteBackground );
00414 setAcceptDrops( TRUE );
00415 mousePressed = FALSE;
00416 }
00417 void setColor( QColor c ) { col = c; }
00418
00419 signals:
00420 void colorDropped( QRgb );
00421
00422 protected:
00423 void drawContents( QPainter *p );
00424 void mousePressEvent( QMouseEvent *e );
00425 void mouseReleaseEvent( QMouseEvent *e );
00426
00427 private:
00428 QColor col;
00429 bool mousePressed;
00430 QPoint pressPos;
00431
00432 };
00433
00434 void QColorShowLabel::drawContents( QPainter *p )
00435 {
00436 p->fillRect( contentsRect(), col );
00437 }
00438
00439 void QColorShower::showAlpha( bool b )
00440 {
00441 if ( b ) {
00442 alphaLab->show();
00443 alphaEd->show();
00444 } else {
00445 alphaLab->hide();
00446 alphaEd->hide();
00447 }
00448 }
00449
00450 void QColorShowLabel::mousePressEvent( QMouseEvent *e )
00451 {
00452 mousePressed = TRUE;
00453 pressPos = e->pos();
00454 }
00455
00456 void QColorShowLabel::mouseReleaseEvent( QMouseEvent * )
00457 {
00458 if ( !mousePressed )
00459 return;
00460 mousePressed = FALSE;
00461 }
00462
00463 QColorShower::QColorShower( QWidget *parent, const char *name )
00464 :QWidget( parent, name)
00465 {
00466 curCol = qRgb( -1, -1, -1 );
00467 QColIntValidator *val256 = new QColIntValidator( 0, 255, this );
00468 QColIntValidator *val360 = new QColIntValidator( 0, 360, this );
00469
00470 QGridLayout *gl = new QGridLayout( this, 1, 1, 2 );
00471 gl->setMargin( 0 );
00472 lab = new QColorShowLabel( this );
00473 lab->setMinimumWidth( 60 );
00474 gl->addMultiCellWidget(lab, 0,-1,0,0);
00475 connect( lab, SIGNAL( colorDropped(QRgb) ),
00476 this, SIGNAL( newCol(QRgb) ) );
00477 connect( lab, SIGNAL( colorDropped(QRgb) ),
00478 this, SLOT( setRgb(QRgb) ) );
00479
00480 hEd = new QColNumLineEdit( this );
00481 hEd->setValidator( val360 );
00482 QLabel *l = new QLabel( hEd, OColorDialog::tr("Hue:"), this );
00483 l->setAlignment( AlignRight|AlignVCenter );
00484 gl->addWidget( l, 0, 1 );
00485 gl->addWidget( hEd, 0, 2 );
00486
00487 sEd = new QColNumLineEdit( this );
00488 sEd->setValidator( val256 );
00489 l = new QLabel( sEd, OColorDialog::tr("Sat:"), this );
00490 l->setAlignment( AlignRight|AlignVCenter );
00491 gl->addWidget( l, 1, 1 );
00492 gl->addWidget( sEd, 1, 2 );
00493
00494 vEd = new QColNumLineEdit( this );
00495 vEd->setValidator( val256 );
00496 l = new QLabel( vEd, OColorDialog::tr("Val:"), this );
00497 l->setAlignment( AlignRight|AlignVCenter );
00498 gl->addWidget( l, 2, 1 );
00499 gl->addWidget( vEd, 2, 2 );
00500
00501 rEd = new QColNumLineEdit( this );
00502 rEd->setValidator( val256 );
00503 l = new QLabel( rEd, OColorDialog::tr("Red:"), this );
00504 l->setAlignment( AlignRight|AlignVCenter );
00505 gl->addWidget( l, 0, 3 );
00506 gl->addWidget( rEd, 0, 4 );
00507
00508 gEd = new QColNumLineEdit( this );
00509 gEd->setValidator( val256 );
00510 l = new QLabel( gEd, OColorDialog::tr("Green:"), this );
00511 l->setAlignment( AlignRight|AlignVCenter );
00512 gl->addWidget( l, 1, 3 );
00513 gl->addWidget( gEd, 1, 4 );
00514
00515 bEd = new QColNumLineEdit( this );
00516 bEd->setValidator( val256 );
00517 l = new QLabel( bEd, OColorDialog::tr("Blue:"), this );
00518 l->setAlignment( AlignRight|AlignVCenter );
00519 gl->addWidget( l, 2, 3 );
00520 gl->addWidget( bEd, 2, 4 );
00521
00522 alphaEd = new QColNumLineEdit( this );
00523 alphaEd->setValidator( val256 );
00524 alphaLab = new QLabel( alphaEd, OColorDialog::tr("Alpha channel:"), this );
00525 alphaLab->setAlignment( AlignRight|AlignVCenter );
00526 gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 );
00527 gl->addWidget( alphaEd, 3, 4 );
00528 alphaEd->hide();
00529 alphaLab->hide();
00530
00531 connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
00532 connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
00533 connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
00534
00535 connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
00536 connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
00537 connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
00538 }
00539
00540 void QColorShower::showCurrentColor()
00541 {
00542 lab->setColor( currentColor() );
00543 lab->repaint(FALSE);
00544 }
00545
00546 void QColorShower::rgbEd()
00547 {
00548 rgbOriginal = TRUE;
00549 curCol = qRgb( rEd->val(), gEd->val(), bEd->val() );
00550 rgb2hsv(currentColor(), hue, sat, val );
00551
00552 hEd->setNum( hue );
00553 sEd->setNum( sat );
00554 vEd->setNum( val );
00555
00556 showCurrentColor();
00557 emit newCol( currentColor() );
00558 }
00559
00560 void QColorShower::hsvEd()
00561 {
00562 rgbOriginal = FALSE;
00563 hue = hEd->val();
00564 sat = sEd->val();
00565 val = vEd->val();
00566
00567 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb();
00568
00569 rEd->setNum( qRed(currentColor()) );
00570 gEd->setNum( qGreen(currentColor()) );
00571 bEd->setNum( qBlue(currentColor()) );
00572
00573 showCurrentColor();
00574 emit newCol( currentColor() );
00575 }
00576
00577 void QColorShower::setRgb( QRgb rgb )
00578 {
00579 rgbOriginal = TRUE;
00580 curCol = rgb;
00581
00582 rgb2hsv( currentColor(), hue, sat, val );
00583
00584 hEd->setNum( hue );
00585 sEd->setNum( sat );
00586 vEd->setNum( val );
00587
00588 rEd->setNum( qRed(currentColor()) );
00589 gEd->setNum( qGreen(currentColor()) );
00590 bEd->setNum( qBlue(currentColor()) );
00591
00592 showCurrentColor();
00593 }
00594
00595 void QColorShower::setHsv( int h, int s, int v )
00596 {
00597 rgbOriginal = FALSE;
00598 hue = h; val = v; sat = s;
00599 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb();
00600
00601 hEd->setNum( hue );
00602 sEd->setNum( sat );
00603 vEd->setNum( val );
00604
00605 rEd->setNum( qRed(currentColor()) );
00606 gEd->setNum( qGreen(currentColor()) );
00607 bEd->setNum( qBlue(currentColor()) );
00608
00609
00610 showCurrentColor();
00611 }
00612
00613 }
00614
00615 class OColorDialogPrivate : public QObject
00616 {
00617 Q_OBJECT
00618 public:
00619 OColorDialogPrivate( OColorDialog *p );
00620 QRgb currentColor() const { return cs->currentColor(); }
00621 void setCurrentColor( const QRgb& rgb );
00622
00623 int currentAlpha() const { return cs->currentAlpha(); }
00624 void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); }
00625 void showAlpha( bool b ) { cs->showAlpha( b ); }
00626
00627 private slots:
00628 void newHsv( int h, int s, int v );
00629 void newColorTypedIn( QRgb rgb );
00630 private:
00631 QColorPicker *cp;
00632 QColorLuminancePicker *lp;
00633 QColorShower *cs;
00634 };
00635
00636
00637 void OColorDialogPrivate::newHsv( int h, int s, int v )
00638 {
00639 cs->setHsv( h, s, v );
00640 cp->setCol( h, s );
00641 lp->setCol( h, s, v );
00642 }
00643
00644
00645 void OColorDialogPrivate::setCurrentColor( const QRgb& rgb )
00646 {
00647 cs->setRgb( rgb );
00648 newColorTypedIn( rgb );
00649 }
00650
00651
00652 void OColorDialogPrivate::newColorTypedIn( QRgb rgb )
00653 {
00654 int h, s, v;
00655 rgb2hsv(rgb, h, s, v );
00656 cp->setCol( h, s );
00657 lp->setCol( h, s, v);
00658 }
00659
00660 OColorDialogPrivate::OColorDialogPrivate( OColorDialog *dialog ) :
00661 QObject(dialog)
00662 {
00663 int border = 2;
00664 QVBoxLayout *topLay = new QVBoxLayout( dialog, border, 2 );
00665
00666 QHBoxLayout *pickLay = new QHBoxLayout( topLay );
00667
00668
00669 cp = new QColorPicker( dialog );
00670 cp->setFrameStyle( QFrame::Panel + QFrame::Sunken );
00671 pickLay->addWidget( cp );
00672
00673 pickLay->addStretch();
00674
00675 lp = new QColorLuminancePicker( dialog );
00676 lp->setFixedWidth( 20 );
00677 pickLay->addWidget( lp );
00678
00679 connect( cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)) );
00680 connect( lp, SIGNAL(newHsv(int,int,int)), this, SLOT(newHsv(int,int,int)) );
00681
00682 topLay->addStretch();
00683
00684 cs = new QColorShower( dialog );
00685 connect( cs, SIGNAL(newCol(QRgb)), this, SLOT(newColorTypedIn(QRgb)));
00686 topLay->addWidget( cs );
00687
00688 }
00689
00690
00691
00720 OColorDialog::OColorDialog(QWidget* parent, const char* name, bool modal) :
00721 QDialog(parent, name, modal )
00722 {
00723 d = new OColorDialogPrivate( this );
00724 }
00725
00726
00734 QColor OColorDialog::getColor( const QColor& initial, QWidget *parent,
00735 const char *name )
00736 {
00737 int allocContext = QColor::enterAllocContext();
00738 OColorDialog *dlg = new OColorDialog( parent, name, TRUE );
00739 if ( parent && parent->icon() && !parent->icon()->isNull() )
00740 dlg->setIcon( *parent->icon() );
00741 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() )
00742 dlg->setIcon( *qApp->mainWidget()->icon() );
00743
00744 dlg->setCaption( OColorDialog::tr( "Select color" ) );
00745 dlg->setColor( initial );
00746 dlg->showMaximized();
00747 int resultCode = dlg->exec();
00748 QColor::leaveAllocContext();
00749 QColor result;
00750 if ( resultCode == QDialog::Accepted ) {
00751 result = dlg->color();
00752 } else {
00753 result = initial;
00754 }
00755 QColor::destroyAllocContext(allocContext);
00756 delete dlg;
00757 return result;
00758 }
00759
00760
00771 QRgb OColorDialog::getRgba( const QRgb& initial, bool *ok,
00772 QWidget *parent, const char* name )
00773 {
00774 int allocContext = QColor::enterAllocContext();
00775 OColorDialog *dlg = new OColorDialog( parent, name, TRUE );
00776 dlg->setColor( initial );
00777 dlg->setSelectedAlpha( qAlpha(initial) );
00778 dlg->showMaximized();
00779 int resultCode = dlg->exec();
00780 QColor::leaveAllocContext();
00781 QRgb result = initial;
00782 if ( resultCode == QDialog::Accepted ) {
00783 QRgb c = dlg->color().rgb();
00784 int alpha = dlg->selectedAlpha();
00785 result = qRgba( qRed(c), qGreen(c), qBlue(c), alpha );
00786 }
00787 if ( ok )
00788 *ok = resultCode == QDialog::Accepted;
00789
00790 QColor::destroyAllocContext(allocContext);
00791 delete dlg;
00792 return result;
00793 }
00794
00795
00796
00797
00798
00805 QColor OColorDialog::color() const
00806 {
00807 return QColor(d->currentColor());
00808 }
00809
00810
00815 OColorDialog::~OColorDialog()
00816 {
00817
00818 }
00819
00820
00827 void OColorDialog::setColor( const QColor& c )
00828 {
00829 d->setCurrentColor( c.rgb() );
00830 }
00831
00832
00833
00834
00840 void OColorDialog::setSelectedAlpha( int a )
00841 {
00842 d->showAlpha( TRUE );
00843 d->setCurrentAlpha( a );
00844 }
00845
00846
00851 int OColorDialog::selectedAlpha() const
00852 {
00853 return d->currentAlpha();
00854 }
00855
00856 #include "colordialog.moc"