Back to index

scribus-ng  1.3.4.dfsg+svn20071115
cmykfw.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "cmykfw.h"
00008 #include "cmykfw.moc"
00009 #include <qpainter.h>
00010 #include <qpopupmenu.h>
00011 #include <qcursor.h>
00012 #include <qmessagebox.h>
00013 #include <qfileinfo.h>
00014 #include <qdir.h>
00015 #include <qdom.h>
00016 #include <cstdlib>
00017 
00018 #include "commonstrings.h"
00019 #include "sccombobox.h"
00020 #include "scconfig.h"
00021 #include "scpaths.h"
00022 #include "scribusdoc.h"
00023 #include "colorutil.h"
00024 #include "colorlistbox.h"
00025 #include "util.h"
00026 #include "sccolorengine.h"
00027 
00028 CMYKChoose::CMYKChoose( QWidget* parent, ScribusDoc* doc, ScColor orig, QString name, ColorList *Colors, QStringList Cust, bool newCol  )
00029               : QDialog( parent, "fw", true, 0 ), CurrSwatch(doc)
00030 {
00031        m_doc = doc;
00032        isNew = newCol;
00033        if (orig.getColorModel () == colorModelCMYK)
00034               CMYKmode = true;
00035        else
00036               CMYKmode = false;
00037        dynamic = true;
00038        Wsave = false;
00039        EColors = Colors;
00040        CurrSwatch.clear();
00041        alertIcon = loadIcon("alert.png");
00042        imageA = QPixmap(50,50);
00043        imageA.fill( ScColorEngine::getDisplayColor(orig, m_doc) );
00044        if ( ScColorEngine::isOutOfGamut(orig, m_doc) )
00045               paintAlert(alertIcon,imageA, 2, 2, false);
00046        imageN = QPixmap(50,50);
00047        imageN.fill( ScColorEngine::getDisplayColor(orig, m_doc) );
00048        if ( ScColorEngine::isOutOfGamut(orig, m_doc) )
00049               paintAlert(alertIcon, imageN, 2, 2, false);
00050        Farbe = orig;
00051        QPixmap image0 = SliderPix(180);
00052        QPixmap image1 = SliderPix(300);
00053        QPixmap image2 = SliderPix(60);
00054        QPixmap image3 = SliderBlack();
00055        CMYKColor cmyk;
00056        double ccd, cmd, cyd, ckd;
00057        ScColorEngine::getCMYKValues(orig, m_doc, cmyk);
00058        ccd = cmyk.c / 2.55;
00059        cmd = cmyk.m / 2.55;
00060        cyd = cmyk.y / 2.55;
00061        ckd = cmyk.k / 2.55;
00062        RGBColor rgb;
00063        double crd, cgd, cbd;
00064        ScColorEngine::getRGBValues(orig, m_doc, rgb);
00065        crd = rgb.r / 2.55;
00066        cgd = rgb.g / 2.55;
00067        cbd = rgb.b / 2.55;
00068        resize( 498, 306 );
00069        setCaption( tr( "Edit Color" ) );
00070        setIcon(loadIcon("AppIcon.png"));
00071        CMYKFarbenLayout = new QHBoxLayout( this );
00072        CMYKFarbenLayout->setSpacing( 6 );
00073        CMYKFarbenLayout->setMargin( 11 );
00074        Layout23 = new QVBoxLayout;
00075        Layout23->setSpacing( 7 );
00076        Layout23->setMargin( 0 );
00077 
00078        TextLabel1 = new QLabel( tr( "&Name:" ), this, "TextLabel1" );
00079        TextLabel1->setMinimumSize( QSize( 200, 22 ) );
00080        Layout23->addWidget( TextLabel1 );
00081 
00082        Farbname = new QLineEdit( this, "Farbname" );
00083        Farbname->setMinimumSize( QSize( 200, 22 ) );
00084        Farbname->setText( name );
00085        TextLabel1->setBuddy( Farbname );
00086        Layout23->addWidget( Farbname );
00087 
00088        TextLabel3 = new QLabel( tr( "Color &Model" ), this, "TextLabel3" );
00089        TextLabel3->setMinimumSize( QSize( 100, 22 ) );
00090        Layout23->addWidget( TextLabel3 );
00091 
00092        ComboBox1 = new ScComboBox( false, this, "ComboBox1" );
00093        ComboBox1->insertItem( tr( "CMYK" ) );
00094        ComboBox1->insertItem( tr( "RGB" ) );
00095        ComboBox1->insertItem( tr( "Web Safe RGB" ) );
00096        if (!CMYKmode)
00097               ComboBox1->setCurrentItem( 1 );
00098        TextLabel3->setBuddy( ComboBox1 );
00099        Layout23->addWidget( ComboBox1 );
00100 
00101        Separations = new QCheckBox( this, "Separations" );
00102        Separations->setText( tr( "Is Spot Color" ) );
00103        Separations->setChecked(orig.isSpotColor());
00104        Layout23->addWidget( Separations );
00105 
00106        Regist = new QCheckBox( this, "Regist" );
00107        Regist->setText( tr( "Is Registration Color" ) );
00108        Regist->setChecked(orig.isRegistrationColor());
00109        Layout23->addWidget( Regist );
00110 
00111        QSpacerItem* spacer = new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding );
00112        Layout23->addItem( spacer );
00113 
00114        Layout2 = new QGridLayout;
00115        Layout2->setSpacing( 6 );
00116        Layout2->setMargin( 0 );
00117 
00118        TextLabel5_2 = new QLabel( tr( "New" ), this, "TextLabel5_2" );
00119        TextLabel5_2->setMinimumSize( QSize( 50, 22 ) );
00120        TextLabel5_2->setMaximumSize( QSize( 100, 22 ) );
00121 
00122        Layout2->addWidget( TextLabel5_2, 0, 1 );
00123 
00124        OldC = new QLabel( "", this, "OldC" );
00125        OldC->setMinimumSize( QSize( 50, 50 ) );
00126        OldC->setMaximumSize( QSize( 50, 50 ) );
00127        OldC->setFrameShape( QLabel::WinPanel );
00128        OldC->setFrameShadow( QLabel::Sunken );
00129        OldC->setScaledContents( true );
00130        OldC->setAlignment( int( QLabel::AlignCenter ) );
00131        OldC->setPixmap( imageA );
00132 
00133        Layout2->addWidget( OldC, 1, 0 );
00134 
00135        TextLabel5 = new QLabel( tr( "Old" ), this, "TextLabel5" );
00136        TextLabel5->setMinimumSize( QSize( 50, 22 ) );
00137        TextLabel5->setMaximumSize( QSize( 100, 22 ) );
00138 
00139        Layout2->addWidget( TextLabel5, 0, 0 );
00140 
00141        NewC = new QLabel( "", this, "NewC" );
00142        NewC->setMinimumSize( QSize( 50, 50 ) );
00143        NewC->setMaximumSize( QSize( 50, 50 ) );
00144        NewC->setFrameShape( QLabel::WinPanel );
00145        NewC->setFrameShadow( QLabel::Sunken );
00146        NewC->setScaledContents( true );
00147        NewC->setAlignment( int( QLabel::AlignCenter ) );
00148        NewC->setPixmap( imageN );
00149 
00150        Layout2->addWidget( NewC, 1, 1 );
00151        Layout23->addLayout( Layout2 );
00152 
00153        Layout21 = new QHBoxLayout;
00154        Layout21->setSpacing( 20 );
00155        Layout21->setMargin( 10 );
00156 
00157        Cancel_2 = new QPushButton( CommonStrings::tr_OK, this, "Cancel_2" );
00158        Cancel_2->setDefault( true );
00159        Layout21->addWidget( Cancel_2 );
00160        Cancel = new QPushButton( CommonStrings::tr_Cancel, this, "Cancel" );
00161        Layout21->addWidget( Cancel );
00162        Layout23->addLayout( Layout21 );
00163        CMYKFarbenLayout->addLayout( Layout23 );
00164 
00165        Frame4 = new QFrame( this, "Frame4" );
00166        Frame4->setFrameShape( QFrame::NoFrame );
00167        Frame4->setFrameShadow( QFrame::Raised );
00168        Frame4Layout = new QVBoxLayout( Frame4 );
00169        Frame4Layout->setSpacing( 6 );
00170        Frame4Layout->setMargin( 0 );
00171 
00172        Swatches = new ScComboBox( false, Frame4, "ComboBox1" );
00173        Swatches->insertItem( tr( "HSV-Colormap" ) );
00174 /*
00175        Swatches->insertItem("X11 RGB-Set");
00176        Swatches->insertItem("X11 Grey-Set");
00177        Swatches->insertItem("Gnome-Set");
00178        Swatches->insertItem("SVG-Set");
00179        Swatches->insertItem("OpenOffice.org-Set");
00180 */
00181        csm.findPaletteLocations();
00182        csm.findPalettes();
00183        QStringList allSets(csm.paletteNames());
00184        for ( QStringList::Iterator it = allSets.begin(); it != allSets.end(); ++it )
00185        {
00186               Swatches->insertItem((*it));
00187        }
00188        customSetStartIndex=Swatches->count();
00189 
00190        if (Cust.count() != 0)
00191        {
00192               QStringList realEx;
00193               realEx.clear();
00194               for (uint m = 0; m < Cust.count(); ++m)
00195               {
00196                      QString Cpfad = QDir::convertSeparators( ScPaths::getApplicationDataDir() +Cust[m]);
00197                      QFileInfo cfi(Cpfad);
00198                      if (cfi.exists())
00199                      {
00200                             Swatches->insertItem(Cust[m]);
00201                             realEx.append(Cust[m]);
00202                      }
00203               }
00204               CColSet = realEx;
00205        }
00206        Frame4Layout->addWidget( Swatches );
00207 
00208        TabStack = new QWidgetStack( Frame4, "TabStack" );
00209        TabStack->setFrameShape( QWidgetStack::NoFrame );
00210 
00211        Frame5a = new QFrame( TabStack, "Frame4" );
00212        Frame5a->setFrameShape( QFrame::NoFrame );
00213        Frame5a->setFrameShadow( QFrame::Raised );
00214        Frame5aLayout = new QHBoxLayout( Frame5a );
00215        Frame5aLayout->setSpacing( 0 );
00216        Frame5aLayout->setMargin( 0 );
00217        Frame5 = new QFrame(Frame5a);
00218        Frame5->setFrameShape( QLabel::WinPanel );
00219        Frame5->setFrameShadow( QLabel::Sunken );
00220        Frame5->setMinimumSize( QSize( 182, 130 ) );
00221        Frame5->setMaximumSize( QSize( 182, 130 ) );
00222        Frame5Layout = new QHBoxLayout( Frame5 );
00223        Frame5Layout->setSpacing( 0 );
00224        Frame5Layout->setMargin( 0 );
00225        ColorMap = new ColorChart( Frame5, doc);
00226        ColorMap->setMinimumSize( QSize( 180, 128 ) );
00227        ColorMap->setMaximumSize( QSize( 180, 128 ) );
00228        Frame5Layout->addWidget( ColorMap );
00229        Frame5aLayout->addWidget( Frame5, 0, AlignCenter);
00230        TabStack->addWidget( Frame5a, 0 );
00231 
00232        ColorSwatch = new ColorListBox(TabStack, "StyledL");
00233        TabStack->addWidget( ColorSwatch, 1 );
00234 
00235        Frame4Layout->addWidget( TabStack );
00236 
00237        Layout2x = new QGridLayout;
00238        Layout2x->setSpacing( 6 );
00239        Layout2x->setMargin( 0 );
00240 
00241        CyanT = new QLabel( tr( "C:" ), Frame4, "Cyant" );
00242        Layout2x->addWidget(CyanT, 0, 0);
00243 
00244        Layout1_2 = new QVBoxLayout;
00245        Layout1_2->setSpacing( 0 );
00246        Layout1_2->setMargin( 0 );
00247 
00248        CyanP = new QLabel( Frame4, "CyanP" );
00249        CyanP->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5,
00250                                           CyanP->sizePolicy().hasHeightForWidth() ) );
00251        CyanP->setMinimumSize( QSize( 200, 10 ) );
00252        CyanP->setPixmap(image0);
00253        CyanP->setScaledContents( true );
00254        Layout1_2->addWidget( CyanP );
00255 
00256        CyanSL = new QSlider( Frame4, "CyanSL" );
00257        CyanSL->setMinimumSize( QSize( 200, 16 ) );
00258        CyanSL->setMaxValue( 100 );
00259        CyanSL->setOrientation( QSlider::Horizontal );
00260        CyanSL->setTickmarks( QSlider::NoMarks );
00261        Layout1_2->addWidget( CyanSL );
00262        Layout2x->addLayout(Layout1_2, 0, 1);
00263 
00264        CyanSp = new MSpinBox( Frame4, 0 );
00265        CyanSp->setMaxValue( 100 );
00266        CyanSp->setSuffix( tr(" %"));
00267        Layout2x->addWidget(CyanSp, 0, 2);
00268        CyanSp->setValue(ccd);
00269        CyanSL->setValue(qRound(ccd));
00270 
00271        MagentaT = new QLabel( tr( "M:" ), Frame4, "Cyant" );
00272        Layout2x->addWidget(MagentaT, 1, 0);
00273 
00274        Layout1_2_2 = new QVBoxLayout;
00275        Layout1_2_2->setSpacing( 0 );
00276        Layout1_2_2->setMargin( 0 );
00277 
00278        MagentaP = new QLabel( Frame4, "MagentaP" );
00279        MagentaP->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5,
00280                                              MagentaP->sizePolicy().hasHeightForWidth() ) );
00281        MagentaP->setMinimumSize( QSize( 200, 10 ) );
00282        MagentaP->setPixmap(image1);
00283        MagentaP->setScaledContents( true );
00284        Layout1_2_2->addWidget( MagentaP );
00285 
00286        MagentaSL = new QSlider( Frame4, "MagentaSL" );
00287        MagentaSL->setMinimumSize( QSize( 200, 16 ) );
00288        MagentaSL->setMaxValue( 100 );
00289        MagentaSL->setOrientation( QSlider::Horizontal );
00290        MagentaSL->setTickmarks( QSlider::NoMarks );
00291        Layout1_2_2->addWidget( MagentaSL );
00292        Layout2x->addLayout(Layout1_2_2, 1, 1);
00293 
00294        MagentaSp = new MSpinBox( Frame4, 0 );
00295        MagentaSp->setMaxValue( 100 );
00296        MagentaSp->setSuffix( tr(" %"));
00297        Layout2x->addWidget(MagentaSp, 1, 2);
00298        MagentaSp->setValue(cmd);
00299        MagentaSL->setValue(qRound(cmd));
00300 
00301        YellowT = new QLabel( tr( "Y:" ), Frame4, "Cyant" );
00302        Layout2x->addWidget(YellowT, 2, 0);
00303 
00304        Layout1_2_3 = new QVBoxLayout;
00305        Layout1_2_3->setSpacing( 0 );
00306        Layout1_2_3->setMargin( 0 );
00307 
00308        YellowP = new QLabel( Frame4, "YellowP" );
00309        YellowP->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5,
00310                                             YellowP->sizePolicy().hasHeightForWidth() ) );
00311        YellowP->setMinimumSize( QSize( 200, 10 ) );
00312        YellowP->setPixmap(image2);
00313        YellowP->setScaledContents( true );
00314        Layout1_2_3->addWidget( YellowP );
00315 
00316        YellowSL = new QSlider( Frame4, "YellowSL" );
00317        YellowSL->setMinimumSize( QSize( 200, 16 ) );
00318        YellowSL->setMaxValue( 100 );
00319        YellowSL->setOrientation( QSlider::Horizontal );
00320        YellowSL->setTickmarks( QSlider::NoMarks );
00321        Layout1_2_3->addWidget( YellowSL );
00322        Layout2x->addLayout(Layout1_2_3, 2, 1);
00323 
00324        YellowSp = new MSpinBox( Frame4, 0 );
00325        YellowSp->setMaxValue( 100 );
00326        YellowSp->setSuffix( tr(" %"));
00327        Layout2x->addWidget(YellowSp, 2, 2);
00328        YellowSp->setValue(cyd);
00329        YellowSL->setValue(qRound(cyd));
00330 
00331        BlackT = new QLabel( tr( "K:" ), Frame4, "Cyant" );
00332        Layout2x->addWidget(BlackT, 3, 0);
00333 
00334        Layout1_2_4 = new QVBoxLayout;
00335        Layout1_2_4->setSpacing( 0 );
00336        Layout1_2_4->setMargin( 0 );
00337 
00338        BlackP = new QLabel( Frame4, "BlackP" );
00339        BlackP->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5,
00340                                            BlackP->sizePolicy().hasHeightForWidth() ) );
00341        BlackP->setMinimumSize( QSize( 200, 10 ) );
00342        BlackP->setPixmap(image3);
00343        BlackP->setScaledContents( true );
00344        Layout1_2_4->addWidget( BlackP );
00345 
00346        BlackSL = new QSlider( Frame4, "BlackSL" );
00347        BlackSL->setMinimumSize( QSize( 200, 16 ) );
00348        BlackSL->setMaxValue( 100 );
00349        BlackSL->setOrientation( QSlider::Horizontal );
00350        BlackSL->setTickmarks( QSlider::NoMarks );
00351        Layout1_2_4->addWidget( BlackSL );
00352        Layout2x->addLayout(Layout1_2_4, 3, 1);
00353 
00354        BlackSp = new MSpinBox( Frame4, 0 );
00355        BlackSp->setMaxValue( 100 );
00356        BlackSp->setSuffix( tr(" %"));
00357        Layout2x->addWidget(BlackSp, 3, 2);
00358        BlackSp->setValue(ckd);
00359        BlackSL->setValue(qRound(ckd));
00360        BlackComp = cmyk.k;
00361        Frame4Layout->addLayout( Layout2x );
00362        QSpacerItem* spacer2 = new QSpacerItem( 2, 2, QSizePolicy::Minimum, QSizePolicy::Expanding );
00363        Frame4Layout->addItem( spacer2 );
00364        CMYKFarbenLayout->addWidget( Frame4 );
00365        int h, s, v;
00366        ScColorEngine::getRGBColor(orig, m_doc).hsv(&h, &s, &v);
00367        ColorMap->drawPalette(v);
00368        ColorMap->setMark(h, s);
00369        Fnam = name;
00370        Farbname->selectAll();
00371        Farbname->setFocus();
00372        TabStack->raiseWidget(0);
00373        setFixedSize(minimumSizeHint());
00374        // signals and slots connections
00375        QToolTip::add( Regist, "<qt>" + tr( "Choosing this will enable printing this on all plates. Registration colors are used for printer marks such as crop marks, registration marks and the like. These are not typically used in the layout itself." ) + "</qt>");
00376        QToolTip::add( Separations, "<qt>" + tr( "Choosing this will make this color a spot color, thus creating another spot when creating plates or separations. This is used most often when a logo or other color needs exact representation or cannot be replicated with CMYK inks. Metallic and fluorescent inks are good examples which cannot be easily replicated with CMYK inks." ) + "</qt>");
00377        connect( Cancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
00378        connect( Cancel_2, SIGNAL( clicked() ), this, SLOT( Verlassen() ) );
00379        connect( CyanSp, SIGNAL( valueChanged(int) ), CyanSL, SLOT( setValue(int) ) );
00380        connect( CyanSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00381        connect( MagentaSp, SIGNAL( valueChanged(int) ), MagentaSL, SLOT( setValue(int) ) );
00382        connect( MagentaSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00383        connect( YellowSp, SIGNAL( valueChanged(int) ), YellowSL, SLOT( setValue(int) ) );
00384        connect( YellowSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00385        connect( BlackSp, SIGNAL( valueChanged(int) ), BlackSL, SLOT( setValue(int) ) );
00386        connect( BlackSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00387        connect( CyanSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00388        connect( MagentaSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00389        connect( YellowSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00390        connect( BlackSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00391        connect( ColorMap, SIGNAL( ColorVal(int, int, bool)), this, SLOT( setColor2(int, int, bool)));
00392        connect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
00393        connect( Swatches, SIGNAL(activated(int)), this, SLOT(SelSwatch(int)));
00394        connect(ColorSwatch, SIGNAL(highlighted(int)), this, SLOT(SelFromSwatch(int)));
00395        connect(Separations, SIGNAL(clicked()), this, SLOT(setSpot()));
00396        connect(Regist, SIGNAL(clicked()), this, SLOT(setRegist()));
00397        layout()->activate();
00398        if (!CMYKmode)
00399               SelModel ( tr( "RGB" ));
00400 }
00401 
00402 void CMYKChoose::mouseReleaseEvent(QMouseEvent *m)
00403 {
00404        if (m->button() == RightButton)
00405        {
00406               QPopupMenu *pmen = new QPopupMenu();
00407               qApp->setOverrideCursor(QCursor(ArrowCursor), true);
00408               int px = pmen->insertItem( tr("Dynamic Color Bars"), this, SLOT(ToggleSL()));
00409               int py = pmen->insertItem( tr("Static Color Bars"), this, SLOT(ToggleSL()));
00410               pmen->setItemChecked((dynamic ? px : py) , true);
00411               pmen->exec(QCursor::pos());
00412               delete pmen;
00413        }
00414 }
00415 
00416 void CMYKChoose::SetValueS(int val)
00417 {
00418        disconnect( CyanSp, SIGNAL( valueChanged(int) ), CyanSL, SLOT( setValue(int) ) );
00419        disconnect( MagentaSp, SIGNAL( valueChanged(int) ), MagentaSL, SLOT( setValue(int) ) );
00420        disconnect( YellowSp, SIGNAL( valueChanged(int) ), YellowSL, SLOT( setValue(int) ) );
00421        disconnect( BlackSp, SIGNAL( valueChanged(int) ), BlackSL, SLOT( setValue(int) ) );
00422        if (CyanSL == sender())
00423               CyanSp->setValue(val);
00424        if (MagentaSL == sender())
00425               MagentaSp->setValue(val);
00426        if (YellowSL == sender())
00427               YellowSp->setValue(val);
00428        if (BlackSL == sender())
00429               BlackSp->setValue(val);
00430        setColor();
00431        connect( CyanSp, SIGNAL( valueChanged(int) ), CyanSL, SLOT( setValue(int) ) );
00432        connect( MagentaSp, SIGNAL( valueChanged(int) ), MagentaSL, SLOT( setValue(int) ) );
00433        connect( YellowSp, SIGNAL( valueChanged(int) ), YellowSL, SLOT( setValue(int) ) );
00434        connect( BlackSp, SIGNAL( valueChanged(int) ), BlackSL, SLOT( setValue(int) ) );
00435 }
00436 
00437 void CMYKChoose::ToggleSL()
00438 {
00439        dynamic = !dynamic;
00440        CyanP->setPixmap(SliderPix(CMYKmode ? 180 : 0));
00441        MagentaP->setPixmap(SliderPix(CMYKmode? 300 : 120));
00442        YellowP->setPixmap(SliderPix(CMYKmode? 60 : 240));
00443        if (CMYKmode)
00444               BlackP->setPixmap(SliderBlack());
00445 }
00446 
00447 QPixmap CMYKChoose::SliderPix(int farbe)
00448 {
00449        RGBColor rgb;
00450        CMYKColor cmyk;
00451        QPixmap image0 = QPixmap(255,10);
00452        QPainter p;
00453        p.begin(&image0);
00454        p.setPen(NoPen);
00455        int r, g, b, c, m, y, k;
00456        QColor tmp;
00457        for (int x = 0; x < 255; x += 5)
00458        {
00459               if (CMYKmode)
00460               {
00461                      ScColorEngine::getCMYKValues(Farbe, m_doc, cmyk);
00462                      cmyk.getValues(c, m, y, k);
00463                      if (dynamic)
00464                      {
00465                             switch (farbe)
00466                             {
00467                             case 180:
00468                                    tmp = ScColorEngine::getDisplayColorGC(ScColor(x, m, y, k), m_doc);
00469                                    break;
00470                             case 300:
00471                                    tmp = ScColorEngine::getDisplayColorGC(ScColor(c, x, y, k), m_doc);
00472                                    break;
00473                             case 60:
00474                                    tmp = ScColorEngine::getDisplayColorGC(ScColor(c, m, x, k), m_doc);
00475                                    break;
00476                             }
00477                             p.setBrush(tmp);
00478                      }
00479                      else
00480                      {
00481                             switch (farbe)
00482                             {
00483                             case 180:
00484                                    tmp = ScColorEngine::getDisplayColorGC(ScColor(x, 0, 0, 0), m_doc);
00485                                    break;
00486                             case 300:
00487                                    tmp = ScColorEngine::getDisplayColorGC(ScColor(0, x, 0, 0), m_doc);
00488                                    break;
00489                             case 60:
00490                                    tmp = ScColorEngine::getDisplayColorGC(ScColor(0, 0, x, 0), m_doc);
00491                                    break;
00492                             }
00493                             p.setBrush(tmp);
00494                      }
00495               }
00496               else
00497               {
00498                      ScColorEngine::getRGBValues(Farbe, m_doc, rgb);
00499                      rgb.getValues(r, g, b);
00500                      if (dynamic)
00501                      {
00502                             switch (farbe)
00503                             {
00504                             case 0:
00505                                    tmp = ScColorEngine::getDisplayColorGC(ScColor(x, g, b), m_doc);
00506                                    break;
00507                             case 120:
00508                                    tmp = ScColorEngine::getDisplayColorGC(ScColor(r, x, b), m_doc);
00509                                    break;
00510                             case 240:
00511                                    tmp = ScColorEngine::getDisplayColorGC(ScColor(r, g, x), m_doc);
00512                                    break;
00513                             }
00514                             p.setBrush(tmp);
00515                      }
00516                      else
00517                      {
00518                             switch (farbe)
00519                             {
00520                             case 0:
00521                                    tmp = ScColorEngine::getDisplayColorGC(ScColor(x, 0, 0), m_doc);
00522                                    break;
00523                             case 120:
00524                                    tmp = ScColorEngine::getDisplayColorGC(ScColor(0, x, 0), m_doc);
00525                                    break;
00526                             case 240:
00527                                    tmp = ScColorEngine::getDisplayColorGC(ScColor(0, 0, x), m_doc);
00528                                    break;
00529                             }
00530                             p.setBrush(tmp);
00531                      }
00532               }
00533               p.drawRect(x, 0, 5, 10);
00534        }
00535        p.end();
00536        return image0;
00537 }
00538 
00539 QPixmap CMYKChoose::SliderBlack()
00540 {
00541        QPixmap image0 = QPixmap(255,10);
00542        QPainter p;
00543        int val = 255;
00544        p.begin(&image0);
00545        p.setPen(NoPen);
00546        int c, m, y, k;
00547        CMYKColor cmyk;
00548        ScColorEngine::getCMYKValues(Farbe, m_doc, cmyk);
00549        cmyk.getValues(c, m, y, k);
00550        for (int x = 0; x < 255; x += 5)
00551        {
00552               if (dynamic)
00553                      p.setBrush( ScColorEngine::getDisplayColorGC(ScColor(c, m, y, x), m_doc) );
00554               else
00555                      p.setBrush( ScColorEngine::getDisplayColorGC(ScColor(0, 0, 0, x), m_doc) );
00556               p.drawRect(x, 0, 5, 10);
00557               val -= 5;
00558        }
00559        p.end();
00560        return image0;
00561 }
00562 
00563 void CMYKChoose::SelSwatch(int n)
00564 {
00565        if (n == 0)
00566               TabStack->raiseWidget(0);
00567        else
00568        {
00569               bool cus = false;
00570               CurrSwatch.clear();
00571               QString Cpfad = QDir::convertSeparators(ScPaths::getApplicationDataDir() + Swatches->currentText());
00572               QString pfadC = ScPaths::instance().libDir()+"swatches/";
00573               QString pfadC2 = pfadC + "Scribus_X11.txt";
00574               switch (n)
00575               {
00576                      /*
00577               case 1:
00578                      pfadC2 = pfadC + "Scribus_X11.txt";
00579                      break;
00580               case 2:
00581                      pfadC2 = pfadC + "Scribus_X11Grey.txt";
00582                      break;
00583               case 3:
00584                      pfadC2 = pfadC + "Scribus_Gnome.txt";
00585                      break;
00586               case 4:
00587                      pfadC2 = pfadC + "Scribus_SVG.txt";
00588                      break;
00589               case 5:
00590                      pfadC2 = pfadC + "Scribus_OpenOffice.txt";
00591                      cus = true;
00592                      break;
00593                      */
00594               default:
00595                      if (n<customSetStartIndex)
00596                      {
00597                             QString listText=Swatches->text(n);
00598                             if (listText=="Scribus OpenOffice")
00599                                    cus=true;
00600                             pfadC2 = csm.paletteFileFromName(listText);
00601                      }
00602                      else
00603                      {
00604                             pfadC2 = Cpfad;
00605                             cus = true;
00606                      }
00607                      break;
00608               }
00609               if (n != 0)
00610               {
00611                      QFile fiC(pfadC2);
00612                      if (fiC.open(IO_ReadOnly))
00613                      {
00614                             QString ColorEn, Cname;
00615                             int Rval, Gval, Bval, Kval;
00616                             QTextStream tsC(&fiC);
00617                             ColorEn = tsC.readLine();
00618                             if (ColorEn.startsWith("<?xml version="))
00619                             {
00620                                    QCString docBytes("");
00621                                    loadRawText(pfadC2, docBytes);
00622                                    QString docText("");
00623                                    docText = QString::fromUtf8(docBytes);
00624                                    QDomDocument docu("scridoc");
00625                                    docu.setContent(docText);
00626                                    ScColor lf = ScColor();
00627                                    QDomElement elem = docu.documentElement();
00628                                    QDomNode PAGE = elem.firstChild();
00629                                    while(!PAGE.isNull())
00630                                    {
00631                                           QDomElement pg = PAGE.toElement();
00632                                           if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
00633                                           {
00634                                                  if (pg.hasAttribute("CMYK"))
00635                                                         lf.setNamedColor(pg.attribute("CMYK"));
00636                                                  else
00637                                                         lf.fromQColor(QColor(pg.attribute("RGB")));
00638                                                  if (pg.hasAttribute("Spot"))
00639                                                         lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
00640                                                  else
00641                                                         lf.setSpotColor(false);
00642                                                  if (pg.hasAttribute("Register"))
00643                                                         lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
00644                                                  else
00645                                                         lf.setRegistrationColor(false);
00646                                                  CurrSwatch.insert(pg.attribute("NAME"), lf);
00647                                           }
00648                                           PAGE=PAGE.nextSibling();
00649                                    }
00650                             }
00651                             else
00652                             {
00653                                    while (!tsC.atEnd())
00654                                    {
00655                                           ScColor tmp;
00656                                           ColorEn = tsC.readLine();
00657                                           if (ColorEn.length()>0 && ColorEn[0]==QChar('#'))
00658                                                  continue;
00659                                           QTextStream CoE(&ColorEn, IO_ReadOnly);
00660                                           CoE >> Rval;
00661                                           CoE >> Gval;
00662                                           CoE >> Bval;
00663                                           if (cus)
00664                                           {
00665                                                  CoE >> Kval;
00666                                                  Cname = CoE.read().stripWhiteSpace();
00667                                                  tmp.setColor(Rval, Gval, Bval, Kval);
00668                                           }
00669                                           else
00670                                           {
00671                                                  Cname = CoE.read().stripWhiteSpace();
00672                                                  tmp.setColorRGB(Rval, Gval, Bval);
00673                                           }
00674        
00675                                           if ((n<customSetStartIndex) && (Cname.length()==0))
00676                                           {
00677                                                  if (!cus)
00678                                                         Cname=QString("#%1%2%3").arg(Rval,2,16).arg(Gval,2,16).arg(Bval,2,16).upper();
00679                                                  else
00680                                                         Cname=QString("#%1%2%3%4").arg(Rval,2,16).arg(Gval,2,16).arg(Bval,2,16).arg(Kval,2,16).upper();
00681                                                  Cname.replace(" ","0");
00682                                           }
00683                                           if (CurrSwatch.contains(Cname))
00684                                           {
00685                                                  if (tmp==CurrSwatch[Cname])
00686                                                         continue;
00687                                                  Cname=QString("%1%2").arg(Cname).arg(CurrSwatch.count());
00688                                           }
00689        
00690                                           CurrSwatch.insert(Cname, tmp);
00691                                    }
00692                             }
00693                             fiC.close();
00694                      }
00695                      else
00696                      {
00697                             CurrSwatch.insert("White", ScColor(0, 0, 0, 0));
00698                             CurrSwatch.insert("Black", ScColor(0, 0, 0, 255));
00699                             CurrSwatch.insert("Blue", ScColor(255, 255, 0, 0));
00700                             CurrSwatch.insert("Cyan", ScColor(255, 0, 0, 0));
00701                             CurrSwatch.insert("Green", ScColor(255, 0, 255, 0));
00702                             CurrSwatch.insert("Red", ScColor(0, 255, 255, 0));
00703                             CurrSwatch.insert("Yellow", ScColor(0, 0, 255, 0));
00704                             CurrSwatch.insert("Magenta", ScColor(0, 255, 0, 0));
00705                      }
00706               }
00707               ColorSwatch->clear();
00708               ColorList::Iterator it;
00709               QPixmap pm = QPixmap(30, 15);
00710               for (it = CurrSwatch.begin(); it != CurrSwatch.end(); ++it)
00711               {
00712                      ColorSwatch->insertItem( new ColorFancyPixmapItem(it.data(), m_doc, it.key()) );
00713 //                   pm.fill( ScColorEngine::getDisplayColor(CurrSwatch[it.key()], m_doc) );
00714 //                   ColorSwatch->insertItem(pm, it.key());
00715               }
00716               ColorSwatch->setSelected(ColorSwatch->currentItem(), false);
00717               TabStack->raiseWidget(1);
00718        }
00719 }
00720 
00721 void CMYKChoose::setRegist()
00722 {
00723        disconnect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
00724        if (Regist->isChecked())
00725        {
00726               ComboBox1->setCurrentItem( 0 );
00727               Separations->setChecked(false);
00728               SelModel( tr("CMYK"));
00729        }
00730        connect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
00731 }
00732 
00733 void CMYKChoose::setSpot()
00734 {
00735        disconnect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
00736        if (Separations->isChecked())
00737        {
00738               ComboBox1->setCurrentItem( 0 );
00739               Regist->setChecked(false);
00740               SelModel( tr("CMYK"));
00741        }
00742        connect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
00743 }
00744 
00745 void CMYKChoose::SelModel(const QString& mod)
00746 {
00747        disconnect( CyanSp, SIGNAL( valueChanged(int) ), CyanSL, SLOT( setValue(int) ) );
00748        disconnect( MagentaSp, SIGNAL( valueChanged(int) ), MagentaSL, SLOT( setValue(int) ) );
00749        disconnect( YellowSp, SIGNAL( valueChanged(int) ), YellowSL, SLOT( setValue(int) ) );
00750        disconnect( BlackSp, SIGNAL( valueChanged(int) ), BlackSL, SLOT( setValue(int) ) );
00751        disconnect( CyanSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00752        disconnect( MagentaSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00753        disconnect( YellowSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00754        disconnect( BlackSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00755        disconnect( CyanSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00756        disconnect( MagentaSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00757        disconnect( YellowSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00758        disconnect( BlackSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00759        if (mod == tr("CMYK"))
00760        {
00761               CMYKmode = true;
00762               Wsave = false;
00763               CyanSL->setMaxValue( 100 );
00764               MagentaSL->setMaxValue( 100 );
00765               YellowSL->setMaxValue( 100 );
00766               CyanSp->setMaxValue( 100 );
00767               MagentaSp->setMaxValue( 100);
00768               YellowSp->setMaxValue( 100 );
00769               CyanSL->setLineStep(1);
00770               MagentaSL->setLineStep(1);
00771               YellowSL->setLineStep(1);
00772               CyanSL->setPageStep(10);
00773               MagentaSL->setPageStep(10);
00774               YellowSL->setPageStep(10);
00775               CyanSp->setDecimals(1);
00776               MagentaSp->setDecimals(1);
00777               YellowSp->setDecimals(1);
00778               CyanSp->setLineStep(1);
00779               MagentaSp->setLineStep(1);
00780               YellowSp->setLineStep(1);
00781               CyanSp->setSuffix( tr(" %"));
00782               MagentaSp->setSuffix( tr(" %"));
00783               YellowSp->setSuffix( tr(" %"));
00784               CyanT->setText( tr("C:"));
00785               MagentaT->setText( tr("M:"));
00786               YellowT->setText( tr("Y:"));
00787               CyanP->setPixmap(SliderPix(180));
00788               MagentaP->setPixmap(SliderPix(300));
00789               YellowP->setPixmap(SliderPix(60));
00790               BlackP->setPixmap(SliderBlack());
00791 /*            BlackP->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
00792               BlackSL->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
00793               BlackSp->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
00794               BlackT->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); */
00795               BlackP->show();
00796               BlackSL->show();
00797               BlackSp->show();
00798               BlackT->show();
00799               Farbe = ScColorEngine::convertToModel(Farbe, m_doc, colorModelCMYK);
00800               setValues();
00801        }
00802        else
00803               //     if (mod == tr("RGB"))
00804        {
00805               CMYKmode = false;
00806               Wsave = false;
00807               CyanSL->setMaxValue( 255 );
00808               MagentaSL->setMaxValue( 255 );
00809               YellowSL->setMaxValue( 255 );
00810               CyanSL->setLineStep(1);
00811               MagentaSL->setLineStep(1);
00812               YellowSL->setLineStep(1);
00813               CyanSL->setPageStep(1);
00814               MagentaSL->setPageStep(1);
00815               YellowSL->setPageStep(1);
00816               CyanSp->setDecimals(1);
00817               MagentaSp->setDecimals(1);
00818               YellowSp->setDecimals(1);
00819               CyanSp->setLineStep(1);
00820               MagentaSp->setLineStep(1);
00821               YellowSp->setLineStep(1);
00822               CyanSp->setMaxValue( 255 );
00823               MagentaSp->setMaxValue( 255 );
00824               YellowSp->setMaxValue( 255 );
00825               CyanSp->setSuffix("");
00826               MagentaSp->setSuffix("");
00827               YellowSp->setSuffix("");
00828               CyanT->setText( tr("R:"));
00829               MagentaT->setText( tr("G:"));
00830               YellowT->setText( tr("B:"));
00831               CyanP->setPixmap(SliderPix(0));
00832               MagentaP->setPixmap(SliderPix(120));
00833               YellowP->setPixmap(SliderPix(240));
00834               Layout2x->setResizeMode(QLayout::Fixed);
00835 /*            BlackP->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00836               BlackSL->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00837               BlackSp->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00838               BlackT->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored)); */
00839               BlackP->hide();
00840               BlackSL->hide();
00841               BlackSp->hide();
00842               BlackT->hide();
00843               if (mod == tr("Web Safe RGB"))
00844               {
00845                      Wsave = true;
00846                      CyanSL->setLineStep(51);
00847                      MagentaSL->setLineStep(51);
00848                      YellowSL->setLineStep(51);
00849                      CyanSL->setPageStep(51);
00850                      MagentaSL->setPageStep(51);
00851                      YellowSL->setPageStep(51);
00852                      CyanSp->setLineStep(51);
00853                      MagentaSp->setLineStep(51);
00854                      YellowSp->setLineStep(51);
00855               }
00856               Farbe = ScColorEngine::convertToModel(Farbe, m_doc, colorModelRGB);
00857               setValues();
00858        }
00859        imageN.fill( ScColorEngine::getDisplayColor(Farbe, m_doc) );
00860        if (ScColorEngine::isOutOfGamut(Farbe, m_doc))
00861               paintAlert(alertIcon, imageN, 2, 2, false);
00862        NewC->setPixmap( imageN );
00863         QToolTip::add( NewC, "<qt>" + tr( "If color management is enabled, a triangle warning indicator is a warning the the color maybe outside of the color gamut of the current printer profile selected. What this means is the color may not print exactly as indicated on screen. More hints about gamut warnings are in the online help under Color Management." ) + "</qt>");
00864         QToolTip::add( OldC, "<qt>" + tr( "If color management is enabled, a triangle warning indicator is a warning the the color maybe outside of the color gamut of the current printer profile selected. What this means is the color may not print exactly as indicated on screen. More hints about gamut warnings are in the online help under Color Management." ) + "</qt>");
00865 
00866        connect( CyanSp, SIGNAL( valueChanged(int) ), CyanSL, SLOT( setValue(int) ) );
00867        connect( MagentaSp, SIGNAL( valueChanged(int) ), MagentaSL, SLOT( setValue(int) ) );
00868        connect( YellowSp, SIGNAL( valueChanged(int) ), YellowSL, SLOT( setValue(int) ) );
00869        connect( BlackSp, SIGNAL( valueChanged(int) ), BlackSL, SLOT( setValue(int) ) );
00870        connect( CyanSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00871        connect( MagentaSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00872        connect( YellowSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00873        connect( BlackSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00874        connect( CyanSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00875        connect( MagentaSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00876        connect( YellowSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00877        connect( BlackSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00878 }
00879 
00880 void CMYKChoose::setColor()
00881 {
00882        int c, m, y, k;
00883        if (CMYKmode)
00884        {
00885               c = qRound(CyanSp->value() * 2.55);
00886               m = qRound(MagentaSp->value() * 2.55);
00887               y = qRound(YellowSp->value() * 2.55);
00888               k = qRound(BlackSp->value() * 2.55);
00889        }
00890        else
00891        {
00892               c = qRound(CyanSp->value());
00893               m = qRound(MagentaSp->value());
00894               y = qRound(YellowSp->value());
00895               k = qRound(BlackSp->value());
00896        }
00897        int h, s, v;
00898        BlackComp = k;
00899        if (Wsave)
00900        {
00901               blockSignals(true);
00902               c = c / 51 * 51;
00903               m = m / 51 * 51;
00904               y = y / 51 * 51;
00905               CyanSp->setValue(c);
00906               MagentaSp->setValue(m);
00907               YellowSp->setValue(y);
00908               CyanSL->setValue(c);
00909               MagentaSL->setValue(m);
00910               YellowSL->setValue(y);
00911               blockSignals(false);
00912        }
00913        ScColor tmp;
00914        if (CMYKmode)
00915        {
00916               tmp.setColor(c, m, y, k);
00917               if (dynamic)
00918               {
00919                      CyanP->setPixmap(SliderPix(180));
00920                      MagentaP->setPixmap(SliderPix(300));
00921                      YellowP->setPixmap(SliderPix(60));
00922                      BlackP->setPixmap(SliderBlack());
00923               }
00924        }
00925        else
00926        {
00927               tmp.setColorRGB(c, m, y);
00928               QColor tmp2 = QColor(c, m, y, QColor::Rgb);
00929               tmp2.hsv(&h, &s, &v);
00930               BlackComp = 255 - v;
00931               if (dynamic)
00932               {
00933                      CyanP->setPixmap(SliderPix(0));
00934                      MagentaP->setPixmap(SliderPix(120));
00935                      YellowP->setPixmap(SliderPix(240));
00936               }
00937        }
00938        imageN.fill(ScColorEngine::getDisplayColor(tmp, m_doc) );
00939        if ( ScColorEngine::isOutOfGamut(tmp, m_doc) )
00940               paintAlert(alertIcon, imageN, 2, 2, false);
00941        ScColorEngine::getRGBColor(tmp, m_doc).hsv(&h, &s, &v);
00942        NewC->setPixmap( imageN );
00943        Farbe = tmp;
00944        ColorMap->drawPalette(v);
00945        ColorMap->setMark(h, s);
00946 }
00947 
00948 void CMYKChoose::setColor2(int h, int s, bool ende)
00949 {
00950        QColor tm = QColor(QMAX(QMIN(359,h),0), QMAX(QMIN(255,255-s),0), 255-BlackComp, QColor::Hsv);
00951        int r, g, b;
00952        tm.rgb(&r, &g, &b);
00953        ScColor tmp;
00954        tmp.fromQColor(tm);
00955        if (CMYKmode)
00956        {
00957               CMYKColor cmyk;
00958               ScColorEngine::getCMYKValues(tmp, m_doc, cmyk);
00959               tmp.setColor(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
00960        }
00961        imageN.fill( ScColorEngine::getDisplayColor(tmp, m_doc) );
00962        if ( ScColorEngine::isOutOfGamut(tmp, m_doc) )
00963               paintAlert(alertIcon, imageN, 2, 2, false);
00964        NewC->setPixmap( imageN );
00965        Farbe = tmp;
00966        if (ende)
00967               setValues();
00968 }
00969 
00970 void CMYKChoose::SelFromSwatch(int c)
00971 {
00972        ScColor tmp = CurrSwatch[ColorSwatch->text(c)];
00973        if (tmp.getColorModel() == colorModelCMYK)
00974               SelModel( tr("CMYK"));
00975        else
00976               SelModel( tr("RGB"));
00977 /*     if (CMYKmode)
00978        {
00979               CMYKColor cmyk;
00980               ScColorEngine::getCMYKValues(tmp, m_doc, cmyk);
00981               tmp.setColor(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
00982        } */
00983        imageN.fill( ScColorEngine::getDisplayColor(tmp, m_doc) );
00984        if ( ScColorEngine::isOutOfGamut(tmp, m_doc) )
00985               paintAlert(alertIcon, imageN, 2, 2, false);
00986        NewC->setPixmap( imageN );
00987        Farbe = tmp;
00988        setValues();
00989        Separations->setChecked(tmp.isSpotColor());
00990        Regist->setChecked(tmp.isRegistrationColor());
00991 }
00992 
00993 void CMYKChoose::setValues()
00994 {
00995        if (CMYKmode)
00996        {
00997               CMYKColor cmyk;
00998               int cc, cm, cy, ck;
00999               ScColorEngine::getCMYKValues(Farbe, m_doc, cmyk);
01000               cmyk.getValues(cc, cm, cy, ck);
01001               CyanSp->setValue(cc / 2.55);
01002               CyanSL->setValue(qRound(cc / 2.55));
01003               MagentaSp->setValue(cm / 2.55);
01004               MagentaSL->setValue(qRound(cm / 2.55));
01005               YellowSp->setValue(cy / 2.55);
01006               YellowSL->setValue(qRound(cy / 2.55));
01007               BlackSp->setValue(ck / 2.55);
01008               BlackSL->setValue(qRound(ck / 2.55));
01009               if (dynamic)
01010               {
01011                      CyanP->setPixmap(SliderPix(180));
01012                      MagentaP->setPixmap(SliderPix(300));
01013                      YellowP->setPixmap(SliderPix(60));
01014                      BlackP->setPixmap(SliderBlack());
01015               }
01016        }
01017        else
01018        {
01019               RGBColor rgb;
01020               int r, g, b;
01021               ScColorEngine::getRGBValues(Farbe, m_doc, rgb);
01022               rgb.getValues(r, g, b);
01023               CyanSp->setValue(static_cast<double>(r));
01024               CyanSL->setValue(r);
01025               MagentaSp->setValue(static_cast<double>(g));
01026               MagentaSL->setValue(g);
01027               YellowSp->setValue(static_cast<double>(b));
01028               YellowSL->setValue(b);
01029               int h, s, v;
01030               ScColorEngine::getRGBColor(Farbe, m_doc).hsv(&h, &s, &v);
01031               BlackComp = 255 - v;
01032               if (dynamic)
01033               {
01034                      CyanP->setPixmap(SliderPix(0));
01035                      MagentaP->setPixmap(SliderPix(120));
01036                      YellowP->setPixmap(SliderPix(240));
01037               }
01038        }
01039 }
01040 
01041 void CMYKChoose::Verlassen()
01042 {
01043        // if condition 10/21/2004 pv #1191 - just be sure that user cannot create "None" color
01044        if (Farbname->text() == CommonStrings::None || Farbname->text() == CommonStrings::tr_NoneColor)
01045        {
01046               QMessageBox::information(this, CommonStrings::trWarning, tr("You cannot create a color named \"%1\".\nIt is a reserved name for transparent color").arg(Farbname->text()), 0);
01047               Farbname->setFocus();
01048               Farbname->selectAll();
01049               return;
01050        }
01051        if ((Fnam != Farbname->text()) || (isNew))
01052        {
01053               if (EColors->contains(Farbname->text()))
01054               {
01055                      QMessageBox::information(this, CommonStrings::trWarning, tr("The name of the color already exists,\nplease choose another one."), CommonStrings::tr_OK, 0, 0, 0, QMessageBox::Ok);
01056                      Farbname->selectAll();
01057                      Farbname->setFocus();
01058                      return;
01059               }
01060               else
01061                      accept();
01062        }
01063        else
01064               accept();
01065 }