lib

koColorChooser.cc

00001 /* This file is part of the KDE project
00002   Copyright (c) 1999 Matthias Elter (me@kde.org)
00003   Copyright (c) 2001-2002 Igor Jansen (rm@kde.org)
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "koColorChooser.h"
00022 
00023 #include <qcolor.h>
00024 #include <qlayout.h>
00025 #include <qspinbox.h>
00026 #include <qtabwidget.h>
00027 
00028 #include <klocale.h>
00029 #include <kiconloader.h>
00030 #include <kcolordialog.h>
00031 #include <ktabctl.h>
00032 #include <koFrameButton.h>
00033 #include <koColorSlider.h>
00034 
00035 KoColorChooser::KoColorChooser(QWidget *parent, const char *name) : QWidget(parent, name)
00036 {
00037   m_current = 0;
00038   m_tab = new QTabWidget(this, "KoColorChooser tab");
00039   mGrid = new QGridLayout(this, 3, 5);
00040   mRGBWidget = new RGBWidget(m_tab);
00041   m_current = mRGBWidget;
00042   m_tab -> addTab(mRGBWidget, "RGB");
00043   mHSVWidget = new HSVWidget(m_tab);
00044   m_tab -> addTab(mHSVWidget, "HSV");
00045 #if 0
00046   mCMYKWidget = new QWidget(m_tab);
00047   m_tab -> addTab(mCMYKWidget, "CMYK");
00048   mLABWidget = new LABWidget(m_tab);
00049   m_tab -> addTab(mLABWidget, "LAB");
00050 #endif
00051   mGreyWidget = new GreyWidget(m_tab);
00052   m_tab -> addTab(mGreyWidget, i18n("Gray"));
00053   mColorSelector = new KHSSelector(this);
00054   mColorSelector->setFixedHeight(20);
00055   mGrid->addMultiCellWidget(m_tab, 0, 1, 0, 4);
00056   mGrid->addMultiCellWidget(mColorSelector, 2, 2, 0, 4);
00057   connect(mRGBWidget, SIGNAL(colorChanged(const KoColor &)), this, SLOT(childColorChanged(const KoColor &)));
00058   connect(mHSVWidget, SIGNAL(colorChanged(const KoColor &)), this, SLOT(childColorChanged(const KoColor &)));
00059 //  connect(mLABWidget, SIGNAL(colorChanged(const KoColor &)), this, SLOT(childColorChanged(const KoColor &)));
00060   connect(mGreyWidget, SIGNAL(colorChanged(const KoColor &)), this, SLOT(childColorChanged(const KoColor &)));
00061   connect(mColorSelector, SIGNAL(valueChanged(int, int)), this, SLOT(slotChangeXY(int, int)));
00062   connect(m_tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(slotCurrentChanged(QWidget*)));
00063   slotChangeColor(KoColor::black());
00064 }
00065 
00066 void KoColorChooser::slotCurrentChanged(QWidget *current)
00067 {
00068   m_current = static_cast<ColorWidget*>(current);
00069   m_current -> slotChangeColor(mColor);
00070 }
00071 
00072 void KoColorChooser::slotChangeXY(int h, int s)
00073 {
00074   KoColor c(h, s, 192, KoColor::csHSV);
00075 
00076   m_current -> slotChangeColor(c);
00077 }
00078 
00079 void KoColorChooser::slotChangeColor(const QColor &c)
00080 {
00081   slotChangeColor(KoColor(c));
00082 }
00083 
00084 void KoColorChooser::childColorChanged(const KoColor& c)
00085 {
00086   mColor.setRGB(c.R(), c.G(), c.B());
00087   emit colorChanged(mColor);
00088 }
00089 
00090 void KoColorChooser::slotChangeColor(const KoColor &c)
00091 {
00092   mColor = c;
00093   m_current -> slotChangeColor(mColor);
00094   mColorSelector->setValues(c.H(), c.S());
00095 }
00096 
00097 /*           RGBWidget         */
00098 RGBWidget::RGBWidget(QWidget *parent) : ColorWidget(parent)
00099 {
00100   QGridLayout *mGrid = new QGridLayout(this, 4, 5);
00101 
00102   mColorPatch = new KColorPatch(this);
00103 
00104   /* setup color sliders */
00105   mRSlider = new KoColorSlider(this);
00106   mRSlider->setMaximumHeight(20);
00107   mRSlider->slotSetRange(0, 255);
00108 
00109   mGSlider = new KoColorSlider(this);
00110   mGSlider->setMaximumHeight(20);
00111   mGSlider->slotSetRange(0, 255);
00112 
00113   mBSlider = new KoColorSlider(this);
00114   mBSlider->setMaximumHeight(20);
00115   mBSlider->slotSetRange(0, 255);
00116 
00117   /* setup slider labels */
00118   mRLabel = new QLabel("R", this);
00119   mRLabel->setFixedWidth(16);
00120   mRLabel->setFixedHeight(20);
00121   mGLabel = new QLabel("G", this);
00122   mGLabel->setFixedWidth(16);
00123   mGLabel->setFixedHeight(20);
00124   mBLabel = new QLabel("B", this);
00125   mBLabel->setFixedWidth(16);
00126   mBLabel->setFixedHeight(20);
00127 
00128   /* setup spin box */
00129   mRIn = new QSpinBox(0, 255, 1, this);
00130   mRIn->setFixedWidth(42);
00131   mRIn->setFixedHeight(20);
00132   mGIn = new QSpinBox(0, 255, 1, this);
00133   mGIn->setFixedWidth(42);
00134   mGIn->setFixedHeight(20);
00135   mBIn = new QSpinBox(0, 255, 1, this);
00136   mBIn->setFixedWidth(42);
00137   mBIn->setFixedHeight(20);
00138 
00139   mGrid->addMultiCellWidget(mColorPatch, 0, 4, 0, 0);
00140   mGrid->addWidget(mRLabel, 1, 1);
00141   mGrid->addWidget(mGLabel, 2, 1);
00142   mGrid->addWidget(mBLabel, 3, 1);
00143   mGrid->addMultiCellWidget(mRSlider, 1, 1, 2, 3);
00144   mGrid->addMultiCellWidget(mGSlider, 2, 2, 2, 3);
00145   mGrid->addMultiCellWidget(mBSlider, 3, 3, 2, 3);
00146   mGrid->addWidget(mRIn, 1, 4);
00147   mGrid->addWidget(mGIn, 2, 4);
00148   mGrid->addWidget(mBIn, 3, 4);
00149 
00150   connect(mColorPatch, SIGNAL(colorChanged(const QColor &)), this, SLOT(slotPatchChanged(const QColor &)));
00151 
00152   /* connect color sliders */
00153   connect(mRSlider, SIGNAL(valueChanged(int)), this, SLOT(slotRSliderChanged(int)));
00154   connect(mGSlider, SIGNAL(valueChanged(int)), this, SLOT(slotGSliderChanged(int)));
00155   connect(mBSlider, SIGNAL(valueChanged(int)), this, SLOT(slotBSliderChanged(int)));
00156 
00157   /* connect spin box */
00158   connect(mRIn, SIGNAL(valueChanged(int)), this, SLOT(slotRInChanged(int)));
00159   connect(mGIn, SIGNAL(valueChanged(int)), this, SLOT(slotGInChanged(int)));
00160   connect(mBIn, SIGNAL(valueChanged(int)), this, SLOT(slotBInChanged(int)));
00161 }
00162 
00163 ColorWidget::ColorWidget(QWidget *parent) : QWidget(parent)
00164 {
00165 }
00166 
00167 ColorWidget::~ColorWidget()
00168 {
00169 }
00170 
00171 void ColorWidget::slotChangeColor(const KoColor& c)
00172 {
00173   mColor.setRGB(c.R(), c.G(), c.B());
00174   slotRefreshColor();
00175 }
00176 
00177 void ColorWidget::slotChangeColor(const QColor& c)
00178 {
00179   mColor.setColor(c);
00180   slotRefreshColor();
00181 }
00182 
00183 void RGBWidget::slotRefreshColor()
00184 {
00185   int r = mColor.R();
00186   int g = mColor.G();
00187   int b = mColor.B();
00188 
00189   mRSlider->slotSetColor1(QColor(0, g, b));
00190   mRSlider->slotSetColor2(QColor(255, g, b));
00191   mRSlider->slotSetValue(r);
00192   mRIn->setValue(r);
00193 
00194   mGSlider->slotSetColor1(QColor(r, 0, b));
00195   mGSlider->slotSetColor2(QColor(r, 255, b));
00196   mGSlider->slotSetValue(g);
00197   mGIn->setValue(g);
00198 
00199   mBSlider->slotSetColor1(QColor(r, g, 0));
00200   mBSlider->slotSetColor2(QColor(r, g, 255));
00201   mBSlider->slotSetValue(b);
00202   mBIn->setValue(b);
00203   mColorPatch -> setColor(mColor.color());
00204 }
00205 
00206 void RGBWidget::slotRSliderChanged(int r)
00207 {
00208   int g = mColor.G();
00209   int b = mColor.B();
00210 
00211   mColor.setRGB(r, g, b);
00212   slotRefreshColor();
00213   emit colorChanged(KoColor(r, g, b, KoColor::csRGB));
00214 }
00215 
00216 void RGBWidget::slotGSliderChanged(int g)
00217 {
00218   int r = mColor.R();
00219   int b = mColor.B();
00220 
00221   mColor.setRGB(r, g, b);
00222   slotRefreshColor();
00223   emit colorChanged(KoColor( r, g, b, KoColor::csRGB));
00224 }
00225 
00226 void RGBWidget::slotBSliderChanged(int b)
00227 {
00228   int r = mColor.R();
00229   int g = mColor.G();
00230 
00231   mColor.setRGB(r, g, b);
00232   slotRefreshColor();
00233   emit colorChanged(KoColor(r, g, b, KoColor::csRGB));
00234 }
00235 
00236 void RGBWidget::slotRInChanged(int r)
00237 {
00238   int g = mColor.G();
00239   int b = mColor.B();
00240 
00241   mColor.setRGB(r, g, b);
00242   slotRefreshColor();
00243   emit colorChanged(KoColor(r, g, b, KoColor::csRGB));
00244 }
00245 
00246 void RGBWidget::slotGInChanged(int g)
00247 {
00248   int r = mColor.R();
00249   int b = mColor.B();
00250 
00251   mColor.setRGB(r, g, b);
00252   slotRefreshColor();
00253   emit colorChanged(KoColor(r, g, b, KoColor::csRGB));
00254 }
00255 
00256 void RGBWidget::slotBInChanged(int b)
00257 {
00258   int r = mColor.R();
00259   int g = mColor.G();
00260 
00261   mColor.setRGB(r, g, b);
00262   slotRefreshColor();
00263   emit colorChanged(KoColor(r, g, b, KoColor::csRGB));
00264 }
00265 
00266 void RGBWidget::slotPatchChanged(const QColor& clr)
00267 {
00268   int r = clr.red();
00269   int g = clr.green();
00270   int b = clr.blue();
00271 
00272   mColor.setRGB(r, g, b);
00273   slotRefreshColor();
00274   emit colorChanged(KoColor(r, g, b, KoColor::csRGB));
00275 }
00276 
00277 /*           HSVWidget         */
00278 
00279 HSVWidget::HSVWidget(QWidget *parent): ColorWidget(parent)
00280 {
00281   QGridLayout *mGrid = new QGridLayout(this, 3, 3);
00282 
00283   mColorPatch = new KColorPatch(this);
00284 
00285   /* setup color sliders */
00286   mHSlider = new KoColorSlider(this);
00287   mHSlider->setMaximumHeight(20);
00288   mHSlider->slotSetRange(0, 359);
00289 
00290   mSSlider = new KoColorSlider(this);
00291   mSSlider->setMaximumHeight(20);
00292   mSSlider->slotSetRange(0, 255);
00293 
00294   mVSlider = new KoColorSlider(this);
00295   mVSlider->setMaximumHeight(20);
00296   mVSlider->slotSetRange(0, 255);
00297 
00298   /* setup slider labels */
00299   mHLabel = new QLabel("H", this);
00300   mHLabel->setFixedWidth(16);
00301   mHLabel->setFixedHeight(20);
00302   mSLabel = new QLabel("S", this);
00303   mSLabel->setFixedWidth(16);
00304   mSLabel->setFixedHeight(20);
00305   mVLabel = new QLabel("V", this);
00306   mVLabel->setFixedWidth(16);
00307   mVLabel->setFixedHeight(20);
00308 
00309   /* setup spin box */
00310   mHIn = new QSpinBox(0, 359, 1, this);
00311   mHIn->setFixedWidth(42);
00312   mHIn->setFixedHeight(20);
00313   mSIn = new QSpinBox(0, 255, 1, this);
00314   mSIn->setFixedWidth(42);
00315   mSIn->setFixedHeight(20);
00316   mVIn = new QSpinBox(0, 255, 1, this);
00317   mVIn->setFixedWidth(42);
00318   mVIn->setFixedHeight(20);
00319 
00320   mGrid->addMultiCellWidget(mColorPatch, 0, 4, 0, 0);
00321   mGrid->addWidget(mHLabel, 1, 1);
00322   mGrid->addWidget(mSLabel, 2, 1);
00323   mGrid->addWidget(mVLabel, 3, 1);
00324   mGrid->addMultiCellWidget(mHSlider, 1, 1, 2, 3);
00325   mGrid->addMultiCellWidget(mSSlider, 2, 2, 2, 3);
00326   mGrid->addMultiCellWidget(mVSlider, 3, 3, 2, 3);
00327   mGrid->addWidget(mHIn, 1, 4);
00328   mGrid->addWidget(mSIn, 2, 4);
00329   mGrid->addWidget(mVIn, 3, 4);
00330 
00331   connect(mColorPatch, SIGNAL(colorChanged(const QColor &)), this, SLOT(slotPatchChanged(const QColor &)));
00332 
00333   /* connect color sliders */
00334   connect(mHSlider, SIGNAL(valueChanged(int)), this, SLOT(slotHSliderChanged(int)));
00335   connect(mSSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSSliderChanged(int)));
00336   connect(mVSlider, SIGNAL(valueChanged(int)), this, SLOT(slotVSliderChanged(int)));
00337 
00338   /* connect spin box */
00339   connect(mHIn, SIGNAL(valueChanged(int)), this, SLOT(slotHInChanged(int)));
00340   connect(mSIn, SIGNAL(valueChanged(int)), this, SLOT(slotSInChanged(int)));
00341   connect(mVIn, SIGNAL(valueChanged(int)), this, SLOT(slotVInChanged(int)));
00342 }
00343 
00344 void HSVWidget::slotRefreshColor()
00345 {
00346   int h = mColor.H();
00347   int s = mColor.S();
00348   int v = mColor.V();
00349 
00350   mHSlider->slotSetColor1(KoColor(0, s, v, KoColor::csHSV).color());
00351   mHSlider->slotSetColor2(KoColor(359, s, v, KoColor::csHSV).color());
00352   mHSlider->slotSetValue(h);
00353   mHIn->setValue(h);
00354 
00355   mSSlider->slotSetColor1(KoColor(h, 0, v, KoColor::csHSV).color());
00356   mSSlider->slotSetColor2(KoColor(h, 255, v, KoColor::csHSV).color());
00357   mSSlider->slotSetValue(s);
00358   mSIn->setValue(s);
00359 
00360   mVSlider->slotSetColor1(KoColor(h, s, 0, KoColor::csHSV).color());
00361   mVSlider->slotSetColor2(KoColor(h, s, 255, KoColor::csHSV).color());
00362   mVSlider->slotSetValue(v);
00363   mVIn->setValue(v);
00364   mColorPatch -> setColor(mColor.color());
00365 }
00366 
00367 void HSVWidget::slotHSliderChanged(int h)
00368 {
00369   int v = mColor.V();
00370   int s = mColor.S();
00371 
00372   mColor.setHSV(h, s, v);
00373   slotRefreshColor();
00374   emit colorChanged(mColor);
00375 }
00376 
00377 void HSVWidget::slotSSliderChanged(int s)
00378 {
00379   int h = mColor.H();
00380   int v = mColor.V();
00381 
00382   mColor.setHSV(h, s, v);
00383   slotRefreshColor();
00384   emit colorChanged(mColor);
00385 }
00386 
00387 void HSVWidget::slotVSliderChanged(int v)
00388 {
00389   int h = mColor.H();
00390   int s = mColor.S();
00391 
00392   mColor.setHSV(h, s, v);
00393   slotRefreshColor();
00394   emit colorChanged(mColor);
00395 }
00396 
00397 void HSVWidget::slotHInChanged(int h)
00398 {
00399   int s = mColor.S();
00400   int v = mColor.V();
00401 
00402   mColor.setHSV(h, s, v);
00403   slotRefreshColor();
00404   emit colorChanged(mColor);
00405 }
00406 
00407 void HSVWidget::slotSInChanged(int s)
00408 {
00409   int h = mColor.H();
00410   int v = mColor.V();
00411 
00412   mColor.setHSV(h, s, v);
00413   slotRefreshColor();
00414   emit colorChanged(mColor);
00415 }
00416 
00417 void HSVWidget::slotVInChanged(int v)
00418 {
00419   int h = mColor.H();
00420   int s = mColor.S();
00421 
00422   mColor.setHSV(h, s, v);
00423   slotRefreshColor();
00424   emit colorChanged(mColor);
00425 }
00426 
00427 void HSVWidget::slotPatchChanged(const QColor& clr)
00428 {
00429   int r = clr.red();
00430   int g = clr.green();
00431   int b = clr.blue();
00432 
00433   mColor.setRGB(r, g, b);
00434   slotRefreshColor();
00435   emit colorChanged(mColor);
00436 }
00437 
00438 /*          GreyWidget         */
00439 
00440 GreyWidget::GreyWidget(QWidget *parent): ColorWidget(parent)
00441 {
00442   QGridLayout *mGrid = new QGridLayout(this, 3, 3);
00443 
00444   mColorPatch = new KColorPatch(this);
00445 
00446   /* setup slider */
00447   mVSlider = new KoColorSlider(this);
00448   mVSlider->setMaximumHeight(20);
00449   mVSlider->slotSetRange(0, 255);
00450   mVSlider->slotSetColor1(QColor(255, 255, 255));
00451   mVSlider->slotSetColor2(QColor(0, 0, 0));
00452 
00453   /* setup slider label */
00454   mVLabel = new QLabel("K", this);
00455   mVLabel->setFixedWidth(18);
00456   mVLabel->setFixedHeight(20);
00457 
00458   /* setup spin box */
00459   mVIn = new QSpinBox(0, 255, 1, this);
00460   mVIn->setFixedWidth(42);
00461   mVIn->setFixedHeight(20);
00462 
00463   mGrid->addMultiCellWidget(mColorPatch, 0, 4, 0, 0);
00464   mGrid->addWidget(mVLabel, 1, 1);
00465   mGrid->addMultiCellWidget(mVSlider, 1, 1, 2, 3);
00466   mGrid->addWidget(mVIn, 1, 4);
00467 
00468   connect(mColorPatch, SIGNAL(colorChanged(const QColor &)), this, SLOT(slotPatchChanged(const QColor &)));
00469 
00470   /* connect color slider */
00471   connect(mVSlider, SIGNAL(valueChanged(int)), this, SLOT(slotVSliderChanged(int)));
00472 
00473   /* connect spin box */
00474   connect(mVIn, SIGNAL(valueChanged(int)), mVSlider, SLOT(slotSetValue(int)));
00475 }
00476 
00477 void GreyWidget::slotRefreshColor()
00478 {
00479   double v = mColor.R() + mColor.G() + mColor.B();
00480   v /= 3.0;
00481   v = 255.0 - v;
00482   mVIn->setValue(static_cast<int>(v));
00483   mVSlider->slotSetValue(static_cast<int>(v));
00484   mColorPatch -> setColor(mColor.color());
00485 }
00486 
00487 void GreyWidget::slotVSliderChanged(int v)
00488 {
00489   v = 255 - v;
00490 
00491   mColor.setRGB(v, v, v);
00492   slotRefreshColor();
00493   emit colorChanged(mColor);
00494 }
00495 
00496 void GreyWidget::slotVInChanged(int v)
00497 {
00498   v = 255 - v;
00499 
00500   mColor.setRGB(v, v, v);
00501   slotRefreshColor();
00502   emit colorChanged(mColor);
00503 }
00504 
00505 void GreyWidget::slotPatchChanged(const QColor& clr)
00506 {
00507   int gray = qGray(clr.red(), clr.green(), clr.blue());
00508 
00509   mColor.setRGB(gray, gray, gray);
00510   slotRefreshColor();
00511   emit colorChanged(mColor);
00512 }
00513 
00514 LABWidget::LABWidget(QWidget *parent) : ColorWidget(parent)
00515 {
00516   QGridLayout *mGrid = new QGridLayout(this, 4, 5);
00517 
00518   mColorPatch = new KColorPatch(this);
00519 
00520   /* setup color sliders */
00521   mLSlider = new KoColorSlider(this);
00522   mLSlider->setMaximumHeight(20);
00523   mLSlider->slotSetRange(0, 255);
00524 
00525   mASlider = new KoColorSlider(this);
00526   mASlider->setMaximumHeight(20);
00527   mASlider->slotSetRange(0, 255);
00528 
00529   mBSlider = new KoColorSlider(this);
00530   mBSlider->setMaximumHeight(20);
00531   mBSlider->slotSetRange(0, 255);
00532 
00533   /* setup slider labels */
00534   mLLabel = new QLabel("L", this);
00535   mLLabel->setFixedWidth(16);
00536   mLLabel->setFixedHeight(20);
00537   mALabel = new QLabel("A", this);
00538   mALabel->setFixedWidth(16);
00539   mALabel->setFixedHeight(20);
00540   mBLabel = new QLabel("B", this);
00541   mBLabel->setFixedWidth(16);
00542   mBLabel->setFixedHeight(20);
00543 
00544   /* setup spin box */
00545   mLIn = new QSpinBox(0, 255, 1, this);
00546   mLIn->setFixedWidth(42);
00547   mLIn->setFixedHeight(20);
00548   mAIn = new QSpinBox(0, 255, 1, this);
00549   mAIn->setFixedWidth(42);
00550   mAIn->setFixedHeight(20);
00551   mBIn = new QSpinBox(0, 255, 1, this);
00552   mBIn->setFixedWidth(42);
00553   mBIn->setFixedHeight(20);
00554 
00555   mGrid->addMultiCellWidget(mColorPatch, 0, 4, 0, 0);
00556   mGrid->addWidget(mLLabel, 1, 1);
00557   mGrid->addWidget(mALabel, 2, 1);
00558   mGrid->addWidget(mBLabel, 3, 1);
00559   mGrid->addMultiCellWidget(mLSlider, 1, 1, 2, 3);
00560   mGrid->addMultiCellWidget(mASlider, 2, 2, 2, 3);
00561   mGrid->addMultiCellWidget(mBSlider, 3, 3, 2, 3);
00562   mGrid->addWidget(mLIn, 1, 4);
00563   mGrid->addWidget(mAIn, 2, 4);
00564   mGrid->addWidget(mBIn, 3, 4);
00565 
00566   connect(mColorPatch, SIGNAL(colorChanged(const QColor &)), this, SLOT(slotPatchChanged(const QColor &)));
00567 
00568   /* connect color sliders */
00569   connect(mLSlider, SIGNAL(valueChanged(int)), this, SLOT(slotLSliderChanged(int)));
00570   connect(mASlider, SIGNAL(valueChanged(int)), this, SLOT(slotASliderChanged(int)));
00571   connect(mBSlider, SIGNAL(valueChanged(int)), this, SLOT(slotBSliderChanged(int)));
00572 
00573   /* connect spin box */
00574   connect(mLIn, SIGNAL(valueChanged(int)), this, SLOT(slotLInChanged(int)));
00575   connect(mAIn, SIGNAL(valueChanged(int)), this, SLOT(slotAInChanged(int)));
00576   connect(mBIn, SIGNAL(valueChanged(int)), this, SLOT(slotBInChanged(int)));
00577 }
00578 
00579 void LABWidget::slotRefreshColor()
00580 {
00581   int l = mColor.L();
00582   int a = mColor.a();
00583   int b = mColor.b();
00584 
00585   mLSlider->slotSetColor1(KoColor(0, a, b, KoColor::csLab).color());
00586   mLSlider->slotSetColor2(KoColor(255, a, b, KoColor::csLab).color());
00587   mLSlider->slotSetValue(l);
00588   mLIn->setValue(l);
00589 
00590   mASlider->slotSetColor1(KoColor(l, 0, b, KoColor::csLab).color());
00591   mASlider->slotSetColor2(KoColor(l, 255, b, KoColor::csLab).color());
00592   mASlider->slotSetValue(a);
00593   mAIn->setValue(a);
00594 
00595   mBSlider->slotSetColor1(KoColor(l, a, 0, KoColor::csLab).color());
00596   mBSlider->slotSetColor2(KoColor(l, a, 255, KoColor::csLab).color());
00597   mBSlider->slotSetValue(b);
00598   mBIn->setValue(b);
00599   mColorPatch -> setColor(mColor.color());
00600 }
00601 
00602 void LABWidget::slotLSliderChanged(int l)
00603 {
00604   int a = mColor.a();
00605   int b = mColor.b();
00606 
00607   mColor.setLab(l, a, b);
00608   slotRefreshColor();
00609   emit colorChanged(mColor);
00610 
00611 }
00612 
00613 void LABWidget::slotASliderChanged(int a)
00614 {
00615   int l = mColor.L();
00616   int b = mColor.b();
00617 
00618   mColor.setLab(l, a, b);
00619   slotRefreshColor();
00620   emit colorChanged(mColor);
00621 }
00622 
00623 void LABWidget::slotBSliderChanged(int b)
00624 {
00625   int l = mColor.L();
00626   int a = mColor.a();
00627 
00628   mColor.setLab(l, a, b);
00629   slotRefreshColor();
00630   emit colorChanged(mColor);
00631 }
00632 
00633 void LABWidget::slotLInChanged(int l)
00634 {
00635   int a = mColor.a();
00636   int b = mColor.b();
00637 
00638   mColor.setLab(l, a, b);
00639   slotRefreshColor();
00640   emit colorChanged(mColor);
00641 }
00642 
00643 void LABWidget::slotAInChanged(int a)
00644 {
00645   int l = mColor.L();
00646   int b = mColor.b();
00647 
00648   mColor.setLab(l, a, b);
00649   slotRefreshColor();
00650   emit colorChanged(mColor);
00651 }
00652 
00653 void LABWidget::slotBInChanged(int b)
00654 {
00655   int l = mColor.L();
00656   int a = mColor.a();
00657 
00658   mColor.setLab(l, a, b);
00659   slotRefreshColor();
00660   emit colorChanged(mColor);
00661 }
00662 
00663 void LABWidget::slotPatchChanged(const QColor& clr)
00664 {
00665   int r = clr.red();
00666   int g = clr.green();
00667   int b = clr.blue();
00668 
00669   mColor.setRGB(r, g, b);
00670   slotRefreshColor();
00671   emit colorChanged(mColor);
00672 }
00673 
00674 #include "koColorChooser.moc"
00675 
KDE Home | KDE Accessibility Home | Description of Access Keys