summaryrefslogtreecommitdiff
path: root/libqtaux
Unidiff
Diffstat (limited to 'libqtaux') (more/less context) (ignore whitespace changes)
-rw-r--r--libqtaux/qcolordialog.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/libqtaux/qcolordialog.cpp b/libqtaux/qcolordialog.cpp
index ccef0ad..830fef6 100644
--- a/libqtaux/qcolordialog.cpp
+++ b/libqtaux/qcolordialog.cpp
@@ -511,80 +511,80 @@ static void initRGB()
511{ 511{
512 if ( initrgb ) 512 if ( initrgb )
513 return; 513 return;
514 initrgb = TRUE; 514 initrgb = TRUE;
515 int i = 0; 515 int i = 0;
516 for ( int g = 0; g < 4; g++ ) 516 for ( int g = 0; g < 4; g++ )
517 for ( int r = 0; r < 4; r++ ) 517 for ( int r = 0; r < 4; r++ )
518 for ( int b = 0; b < 3; b++ ) 518 for ( int b = 0; b < 3; b++ )
519 stdrgb[i++] = qRgb( r*255/3, g*255/3, b*255/2 ); 519 stdrgb[i++] = qRgb( r*255/3, g*255/3, b*255/2 );
520 520
521 for ( i = 0; i < 2*8; i++ ) 521 for ( i = 0; i < 2*8; i++ )
522 cusrgb[i] = qRgb(0xff,0xff,0xff); 522 cusrgb[i] = qRgb(0xff,0xff,0xff);
523} 523}
524 524
525/*! 525/*!
526 Returns the number of custom colors supported by 526 Returns the number of custom colors supported by
527 QColorDialog. All color dialogs share the same custom colors. 527 QColorDialog. All color dialogs share the same custom colors.
528*/ 528*/
529int QColorDialog::customCount() 529int QColorDialog::customCount()
530{ 530{
531 return 2*8; 531 return 2*8;
532} 532}
533 533
534/*! 534/*!
535 Returns custom color number \a i as a QRgb. 535 Returns custom color number \a i as a QRgb.
536 */ 536 */
537QRgb QColorDialog::customColor( int i ) 537QRgb QColorDialog::customColor( int i )
538{ 538{
539 initRGB(); 539 initRGB();
540 if ( i < 0 || i >= customCount() ) { 540 if ( i < 0 || i >= customCount() ) {
541#ifdef CHECK_RANGE 541#ifdef CHECK_RANGE
542 qWarning( "QColorDialog::customColor() index %d out of range", i ); 542 qWarning( "QColorDialog::customColor() index %d out of range", i );
543 #endif 543#endif
544 i = 0; 544 i = 0;
545 } 545 }
546 return cusrgb[i]; 546 return cusrgb[i];
547} 547}
548 548
549/*! 549/*!
550 Sets custom color number \a i to the QRgb value \a c. 550 Sets custom color number \a i to the QRgb value \a c.
551*/ 551*/
552void QColorDialog::setCustomColor( int i, QRgb c ) 552void QColorDialog::setCustomColor( int i, QRgb c )
553{ 553{
554 initRGB(); 554 initRGB();
555 if ( i < 0 || i >= customCount() ) { 555 if ( i < 0 || i >= customCount() ) {
556#ifdef CHECK_RANGE 556#ifdef CHECK_RANGE
557 qWarning( "QColorDialog::customColor() index %d out of range", i ); 557 qWarning( "QColorDialog::customColor() index %d out of range", i );
558 #endif 558#endif
559 return; 559 return;
560 } 560 }
561 cusrgb[i] = c; 561 cusrgb[i] = c;
562} 562}
563 563
564static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v ) 564static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v )
565{ 565{
566 QColor c; 566 QColor c;
567 c.setRgb( rgb ); 567 c.setRgb( rgb );
568 c.getHsv(h,s,v); 568 c.getHsv(h,s,v);
569} 569}
570 570
571class QColorWell : public QWellArray 571class QColorWell : public QWellArray
572{ 572{
573public: 573public:
574 QColorWell( QWidget *parent, int r, int c, QRgb *vals ) 574 QColorWell( QWidget *parent, int r, int c, QRgb *vals )
575 :QWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 ) 575 :QWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 )
576 { setDimension(r,c); setWFlags( WResizeNoErase ); } 576 { setDimension(r,c); setWFlags( WResizeNoErase ); }
577 QSizePolicy sizePolicy() const; 577 QSizePolicy sizePolicy() const;
578 578
579protected: 579protected:
580 void drawContents( QPainter *, int row, int col, const QRect& ); 580 void drawContents( QPainter *, int row, int col, const QRect& );
581 void drawContents( QPainter *p ) { QWellArray::drawContents(p); } 581 void drawContents( QPainter *p ) { QWellArray::drawContents(p); }
582 void mousePressEvent( QMouseEvent *e ); 582 void mousePressEvent( QMouseEvent *e );
583 void mouseMoveEvent( QMouseEvent *e ); 583 void mouseMoveEvent( QMouseEvent *e );
584 void mouseReleaseEvent( QMouseEvent *e ); 584 void mouseReleaseEvent( QMouseEvent *e );
585#ifndef QT_NO_DRAGANDDROP 585#ifndef QT_NO_DRAGANDDROP
586 void dragEnterEvent( QDragEnterEvent *e ); 586 void dragEnterEvent( QDragEnterEvent *e );
587 void dragLeaveEvent( QDragLeaveEvent *e ); 587 void dragLeaveEvent( QDragLeaveEvent *e );
588 void dragMoveEvent( QDragMoveEvent *e ); 588 void dragMoveEvent( QDragMoveEvent *e );
589 void dropEvent( QDropEvent *e ); 589 void dropEvent( QDropEvent *e );
590#endif 590#endif
@@ -1074,64 +1074,66 @@ void QColorShower::showAlpha( bool b )
1074{ 1074{
1075 if ( b ) { 1075 if ( b ) {
1076 alphaLab->show(); 1076 alphaLab->show();
1077 alphaEd->show(); 1077 alphaEd->show();
1078 } else { 1078 } else {
1079 alphaLab->hide(); 1079 alphaLab->hide();
1080 alphaEd->hide(); 1080 alphaEd->hide();
1081 } 1081 }
1082} 1082}
1083 1083
1084void QColorShowLabel::mousePressEvent( QMouseEvent *e ) 1084void QColorShowLabel::mousePressEvent( QMouseEvent *e )
1085{ 1085{
1086 mousePressed = TRUE; 1086 mousePressed = TRUE;
1087 pressPos = e->pos(); 1087 pressPos = e->pos();
1088} 1088}
1089 1089
1090void QColorShowLabel::mouseMoveEvent( QMouseEvent *e ) 1090void QColorShowLabel::mouseMoveEvent( QMouseEvent *e )
1091{ 1091{
1092#ifndef QT_NO_DRAGANDDROP 1092#ifndef QT_NO_DRAGANDDROP
1093 if ( !mousePressed ) 1093 if ( !mousePressed )
1094 return; 1094 return;
1095 if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) { 1095 if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) {
1096 QColorDrag *drg = new QColorDrag( col, this ); 1096 QColorDrag *drg = new QColorDrag( col, this );
1097 QPixmap pix( 30, 20 ); 1097 QPixmap pix( 30, 20 );
1098 pix.fill( col ); 1098 pix.fill( col );
1099 QPainter p( &pix ); 1099 QPainter p( &pix );
1100 p.drawRect( 0, 0, pix.width(), pix.height() ); 1100 p.drawRect( 0, 0, pix.width(), pix.height() );
1101 p.end(); 1101 p.end();
1102 drg->setPixmap( pix ); 1102 drg->setPixmap( pix );
1103 mousePressed = FALSE; 1103 mousePressed = FALSE;
1104 drg->dragCopy(); 1104 drg->dragCopy();
1105 } 1105 }
1106#else
1107 Q_UNUSED( e )
1106#endif 1108#endif
1107} 1109}
1108 1110
1109#ifndef QT_NO_DRAGANDDROP 1111#ifndef QT_NO_DRAGANDDROP
1110void QColorShowLabel::dragEnterEvent( QDragEnterEvent *e ) 1112void QColorShowLabel::dragEnterEvent( QDragEnterEvent *e )
1111{ 1113{
1112 if ( QColorDrag::canDecode( e ) ) 1114 if ( QColorDrag::canDecode( e ) )
1113 e->accept(); 1115 e->accept();
1114 else 1116 else
1115 e->ignore(); 1117 e->ignore();
1116} 1118}
1117 1119
1118void QColorShowLabel::dragLeaveEvent( QDragLeaveEvent * ) 1120void QColorShowLabel::dragLeaveEvent( QDragLeaveEvent * )
1119{ 1121{
1120} 1122}
1121 1123
1122void QColorShowLabel::dropEvent( QDropEvent *e ) 1124void QColorShowLabel::dropEvent( QDropEvent *e )
1123{ 1125{
1124 if ( QColorDrag::canDecode( e ) ) { 1126 if ( QColorDrag::canDecode( e ) ) {
1125 QColorDrag::decode( e, col ); 1127 QColorDrag::decode( e, col );
1126 repaint( FALSE ); 1128 repaint( FALSE );
1127 emit colorDropped( col.rgb() ); 1129 emit colorDropped( col.rgb() );
1128 e->accept(); 1130 e->accept();
1129 } else { 1131 } else {
1130 e->ignore(); 1132 e->ignore();
1131 } 1133 }
1132} 1134}
1133#endif // QT_NO_DRAGANDDROP 1135#endif // QT_NO_DRAGANDDROP
1134 1136
1135void QColorShowLabel::mouseReleaseEvent( QMouseEvent * ) 1137void QColorShowLabel::mouseReleaseEvent( QMouseEvent * )
1136{ 1138{
1137 if ( !mousePressed ) 1139 if ( !mousePressed )
@@ -1600,33 +1602,33 @@ QColorDialog::~QColorDialog()
1600*/ 1602*/
1601 1603
1602void QColorDialog::setColor( QColor c ) 1604void QColorDialog::setColor( QColor c )
1603{ 1605{
1604 d->setCurrentColor( c.rgb() ); 1606 d->setCurrentColor( c.rgb() );
1605} 1607}
1606 1608
1607 1609
1608 1610
1609 1611
1610/*! 1612/*!
1611 Sets the initial alpha channel value to \a a, and show the alpha channel 1613 Sets the initial alpha channel value to \a a, and show the alpha channel
1612 entry box. 1614 entry box.
1613*/ 1615*/
1614 1616
1615void QColorDialog::setSelectedAlpha( int a ) 1617void QColorDialog::setSelectedAlpha( int a )
1616{ 1618{
1617 d->showAlpha( TRUE ); 1619 d->showAlpha( TRUE );
1618 d->setCurrentAlpha( a ); 1620 d->setCurrentAlpha( a );
1619} 1621}
1620 1622
1621 1623
1622/*! 1624/*!
1623 Returns the value selected for the alpha channel. 1625 Returns the value selected for the alpha channel.
1624*/ 1626*/
1625 1627
1626int QColorDialog::selectedAlpha() const 1628int QColorDialog::selectedAlpha() const
1627{ 1629{
1628 return d->currentAlpha(); 1630 return d->currentAlpha();
1629} 1631}
1630 1632
1631 1633
1632#include "qcolordialog.moc" \ No newline at end of file 1634#include "qcolordialog.moc"