Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

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 
00009 #include <QHBoxLayout>
00010 #include <QVBoxLayout>
00011 #include <QGridLayout>
00012 #include <QLabel>
00013 #include <QFrame>
00014 #include <QLineEdit>
00015 #include <QCheckBox>
00016 #include <QPushButton>
00017 #include <QStackedWidget>
00018 #include <QSlider>
00019 #include <QMenu>
00020 #include <QPainter>
00021 #include <QCursor>
00022 #include <QDir>
00023 #include <QFileInfo>
00024 #include <QMessageBox>
00025 #include <QDomDocument>
00026 #include <QToolTip>
00027 #include <QTextStream>
00028 #include <QSpacerItem>
00029 #include <QByteArray>
00030 #include <QPixmap>
00031 #include <QAction>
00032 #include <cstdlib>
00033 
00034 #include "colorchart.h"
00035 #include "colorlistbox.h"
00036 #include "commonstrings.h"
00037 #include "sccolorengine.h"
00038 #include "sccombobox.h"
00039 #include "scconfig.h"
00040 #include "scpaths.h"
00041 #include "scribusdoc.h"
00042 #include "scrspinbox.h"
00043 #include "util.h"
00044 #include "util_color.h"
00045 #include "util_icon.h"
00046 
00047 
00048 CMYKChoose::CMYKChoose( QWidget* parent, ScribusDoc* doc, ScColor orig, QString name, ColorList *Colors, QStringList Cust, bool newCol  )
00049         : QDialog( parent ), CurrSwatch(doc)
00050 {
00051     setModal(true);
00052     m_doc = doc;
00053     isNew = newCol;
00054     if (orig.getColorModel () == colorModelCMYK)
00055         CMYKmode = true;
00056     else
00057         CMYKmode = false;
00058     dynamic = true;
00059     Wsave = false;
00060     EColors = Colors;
00061     CurrSwatch.clear();
00062     alertIcon = loadIcon("alert.png");
00063     imageA = QPixmap(50,50);
00064     imageA.fill( ScColorEngine::getDisplayColor(orig, m_doc) );
00065     if ( ScColorEngine::isOutOfGamut(orig, m_doc) )
00066         paintAlert(alertIcon,imageA, 2, 2, false);
00067     imageN = QPixmap(50,50);
00068     imageN.fill( ScColorEngine::getDisplayColor(orig, m_doc) );
00069     if ( ScColorEngine::isOutOfGamut(orig, m_doc) )
00070         paintAlert(alertIcon, imageN, 2, 2, false);
00071     Farbe = orig;
00072     QPixmap image0 = SliderPix(180);
00073     QPixmap image1 = SliderPix(300);
00074     QPixmap image2 = SliderPix(60);
00075     QPixmap image3 = SliderBlack();
00076     CMYKColor cmyk;
00077     double ccd, cmd, cyd, ckd;
00078     ScColorEngine::getCMYKValues(orig, m_doc, cmyk);
00079     ccd = cmyk.c / 2.55;
00080     cmd = cmyk.m / 2.55;
00081     cyd = cmyk.y / 2.55;
00082     ckd = cmyk.k / 2.55;
00083     RGBColor rgb;
00084     double crd, cgd, cbd;
00085     ScColorEngine::getRGBValues(orig, m_doc, rgb);
00086     crd = rgb.r / 2.55;
00087     cgd = rgb.g / 2.55;
00088     cbd = rgb.b / 2.55;
00089     resize( 498, 306 );
00090     setWindowTitle( tr( "Edit Color" ) );
00091     setWindowIcon(QIcon(loadIcon("AppIcon.png")));
00092     CMYKFarbenLayout = new QHBoxLayout( this );
00093     CMYKFarbenLayout->setSpacing( 5 );
00094     CMYKFarbenLayout->setMargin( 10 );
00095     Layout23 = new QVBoxLayout;
00096     Layout23->setSpacing( 5 );
00097     Layout23->setMargin( 0 );
00098 
00099     TextLabel1 = new QLabel( tr( "&Name:" ), this );
00100     TextLabel1->setMinimumSize( QSize( 200, 22 ) );
00101     Layout23->addWidget( TextLabel1 );
00102 
00103     Farbname = new QLineEdit( this );
00104     Farbname->setMinimumSize( QSize( 200, 22 ) );
00105     Farbname->setText( name );
00106     TextLabel1->setBuddy( Farbname );
00107     Layout23->addWidget( Farbname );
00108 
00109     TextLabel3 = new QLabel( tr( "Color &Model" ), this );
00110     TextLabel3->setMinimumSize( QSize( 100, 22 ) );
00111     Layout23->addWidget( TextLabel3 );
00112 
00113     ComboBox1 = new ScComboBox( this );
00114     ComboBox1->addItem( tr( "CMYK" ) );
00115     ComboBox1->addItem( tr( "RGB" ) );
00116     ComboBox1->addItem( tr( "Web Safe RGB" ) );
00117     if (!CMYKmode)
00118         ComboBox1->setCurrentIndex( 1 );
00119     TextLabel3->setBuddy( ComboBox1 );
00120     Layout23->addWidget( ComboBox1 );
00121 
00122     Separations = new QCheckBox( this );
00123     Separations->setText( tr( "Is Spot Color" ) );
00124     Separations->setChecked(orig.isSpotColor());
00125     Layout23->addWidget( Separations );
00126 /*
00127     Regist = new QCheckBox( this );
00128     Regist->setText( tr( "Is Registration Color" ) );
00129     Regist->setChecked(orig.isRegistrationColor());
00130     Layout23->addWidget( Regist );
00131 */
00132     QSpacerItem* spacer = new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding );
00133     Layout23->addItem( spacer );
00134 
00135     Layout2 = new QGridLayout();
00136     Layout2->setSpacing( 6 );
00137     Layout2->setMargin( 0 );
00138 
00139     TextLabel5_2 = new QLabel( tr( "New" ), this );
00140     TextLabel5_2->setMinimumSize( QSize( 50, 22 ) );
00141     TextLabel5_2->setMaximumSize( QSize( 100, 22 ) );
00142 
00143     Layout2->addWidget( TextLabel5_2, 0, 1 );
00144 
00145     OldC = new QLabel( "", this );
00146     OldC->setMinimumSize( QSize( 50, 50 ) );
00147     OldC->setMaximumSize( QSize( 50, 50 ) );
00148     OldC->setFrameShape( QLabel::WinPanel );
00149     OldC->setFrameShadow( QLabel::Sunken );
00150     OldC->setScaledContents( true );
00151     OldC->setAlignment(Qt::AlignCenter);
00152     OldC->setPixmap( imageA );
00153 
00154     Layout2->addWidget( OldC, 1, 0 );
00155 
00156     TextLabel5 = new QLabel( tr( "Old" ), this );
00157     TextLabel5->setMinimumSize( QSize( 50, 22 ) );
00158     TextLabel5->setMaximumSize( QSize( 100, 22 ) );
00159 
00160     Layout2->addWidget( TextLabel5, 0, 0 );
00161 
00162     NewC = new QLabel( "", this );
00163     NewC->setMinimumSize( QSize( 50, 50 ) );
00164     NewC->setMaximumSize( QSize( 50, 50 ) );
00165     NewC->setFrameShape( QLabel::WinPanel );
00166     NewC->setFrameShadow( QLabel::Sunken );
00167     NewC->setScaledContents( true );
00168     NewC->setAlignment(Qt::AlignCenter);
00169     NewC->setPixmap( imageN );
00170 
00171     Layout2->addWidget( NewC, 1, 1 );
00172     Layout23->addLayout( Layout2 );
00173 
00174     Layout21 = new QHBoxLayout;
00175     Layout21->setSpacing( 20 );
00176     Layout21->setMargin( 10 );
00177 
00178     Cancel_2 = new QPushButton( CommonStrings::tr_OK, this );
00179     Cancel_2->setDefault( true );
00180     Layout21->addWidget( Cancel_2 );
00181     Cancel = new QPushButton( CommonStrings::tr_Cancel, this );
00182     Layout21->addWidget( Cancel );
00183     Layout23->addLayout( Layout21 );
00184     CMYKFarbenLayout->addLayout( Layout23 );
00185 
00186     Frame4 = new QFrame( this );
00187     Frame4->setFrameShape( QFrame::NoFrame );
00188     Frame4->setFrameShadow( QFrame::Raised );
00189     Frame4Layout = new QVBoxLayout( Frame4 );
00190     Frame4Layout->setSpacing( 5 );
00191     Frame4Layout->setMargin( 0 );
00192 
00193     Swatches = new ScComboBox( Frame4 );
00194     Swatches->addItem( tr( "HSV-Colormap" ) );
00195 /*
00196     Swatches->insertItem("X11 RGB-Set");
00197     Swatches->insertItem("X11 Grey-Set");
00198     Swatches->insertItem("Gnome-Set");
00199     Swatches->insertItem("SVG-Set");
00200     Swatches->insertItem("OpenOffice.org-Set");
00201 */
00202     csm.findPaletteLocations();
00203     csm.findPalettes();
00204     QStringList allSets(csm.paletteNames());
00205     for ( QStringList::Iterator it = allSets.begin(); it != allSets.end(); ++it )
00206     {
00207         Swatches->addItem((*it));
00208     }
00209     customSetStartIndex=Swatches->count();
00210 
00211     if (Cust.count() != 0)
00212     {
00213         QStringList realEx;
00214         realEx.clear();
00215         for (int m = 0; m < Cust.count(); ++m)
00216         {
00217             QString Cpfad = QDir::convertSeparators( ScPaths::getApplicationDataDir() +Cust[m]);
00218             QFileInfo cfi(Cpfad);
00219             if (cfi.exists())
00220             {
00221                 Swatches->addItem(Cust[m]);
00222                 realEx.append(Cust[m]);
00223             }
00224         }
00225         CColSet = realEx;
00226     }
00227     Frame4Layout->addWidget( Swatches );
00228 
00229     TabStack = new QStackedWidget( Frame4 );
00230     TabStack->setFrameShape( QFrame::NoFrame );
00231 
00232     Frame5a = new QFrame( TabStack );
00233     Frame5a->setFrameShape( QFrame::NoFrame );
00234     Frame5a->setFrameShadow( QFrame::Raised );
00235     Frame5aLayout = new QHBoxLayout( Frame5a );
00236     Frame5aLayout->setSpacing( 0 );
00237     Frame5aLayout->setMargin( 0 );
00238     Frame5 = new QFrame(Frame5a);
00239     Frame5->setFrameShape( QLabel::WinPanel );
00240     Frame5->setFrameShadow( QLabel::Sunken );
00241     Frame5->setMinimumSize( QSize( 182, 130 ) );
00242     Frame5->setMaximumSize( QSize( 182, 130 ) );
00243     Frame5Layout = new QHBoxLayout( Frame5 );
00244     Frame5Layout->setSpacing( 0 );
00245     Frame5Layout->setMargin( 0 );
00246     ColorMap = new ColorChart( Frame5, doc);
00247     ColorMap->setMinimumSize( QSize( 180, 128 ) );
00248     ColorMap->setMaximumSize( QSize( 180, 128 ) );
00249     Frame5Layout->addWidget( ColorMap );
00250     Frame5aLayout->addWidget( Frame5, 0, Qt::AlignCenter);
00251     TabStack->addWidget( Frame5a );
00252 
00253     ColorSwatch = new ColorListBox(TabStack);
00254     TabStack->addWidget( ColorSwatch );
00255 
00256     Frame4Layout->addWidget( TabStack );
00257 
00258     Layout2x = new QGridLayout();
00259     Layout2x->setSpacing( 5 );
00260     Layout2x->setMargin( 0 );
00261 
00262     CyanT = new QLabel( tr( "C:" ), Frame4 );
00263     Layout2x->addWidget(CyanT, 0, 0);
00264 
00265     Layout1_2 = new QVBoxLayout;
00266     Layout1_2->setSpacing( 0 );
00267     Layout1_2->setMargin( 0 );
00268 
00269     CyanP = new QLabel( Frame4 );
00270 //  CyanP->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, CyanP->sizePolicy().hasHeightForWidth() ) );
00271     CyanP->setMinimumSize( QSize( 200, 10 ) );
00272     CyanP->setPixmap(image0);
00273     CyanP->setScaledContents( true );
00274     Layout1_2->addWidget( CyanP );
00275 
00276     CyanSL = new QSlider( Frame4 );
00277     CyanSL->setMinimumSize( QSize( 200, 16 ) );
00278     CyanSL->setMaximum( 100 );
00279     CyanSL->setOrientation( Qt::Horizontal );
00280     Layout1_2->addWidget( CyanSL );
00281     Layout2x->addLayout(Layout1_2, 0, 1);
00282 
00283     CyanSp = new ScrSpinBox( 0, 100, Frame4, 0 );
00284     CyanSp->setSuffix( tr(" %"));
00285     Layout2x->addWidget(CyanSp, 0, 2);
00286     CyanSp->setValue(ccd);
00287     CyanSL->setValue(qRound(ccd));
00288 
00289     MagentaT = new QLabel( tr( "M:" ), Frame4 );
00290     Layout2x->addWidget(MagentaT, 1, 0);
00291 
00292     Layout1_2_2 = new QVBoxLayout;
00293     Layout1_2_2->setSpacing( 0 );
00294     Layout1_2_2->setMargin( 0 );
00295 
00296     MagentaP = new QLabel( Frame4 );
00297 //  MagentaP->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, MagentaP->sizePolicy().hasHeightForWidth() ) );
00298     MagentaP->setMinimumSize( QSize( 200, 10 ) );
00299     MagentaP->setPixmap(image1);
00300     MagentaP->setScaledContents( true );
00301     Layout1_2_2->addWidget( MagentaP );
00302 
00303     MagentaSL = new QSlider( Frame4 );
00304     MagentaSL->setMinimumSize( QSize( 200, 16 ) );
00305     MagentaSL->setMaximum( 100 );
00306     MagentaSL->setOrientation( Qt::Horizontal );
00307     Layout1_2_2->addWidget( MagentaSL );
00308     Layout2x->addLayout(Layout1_2_2, 1, 1);
00309 
00310     MagentaSp = new ScrSpinBox( 0, 100, Frame4, 0 );
00311     MagentaSp->setSuffix( tr(" %"));
00312     Layout2x->addWidget(MagentaSp, 1, 2);
00313     MagentaSp->setValue(cmd);
00314     MagentaSL->setValue(qRound(cmd));
00315 
00316     YellowT = new QLabel( tr( "Y:" ), Frame4 );
00317     Layout2x->addWidget(YellowT, 2, 0);
00318 
00319     Layout1_2_3 = new QVBoxLayout;
00320     Layout1_2_3->setSpacing( 0 );
00321     Layout1_2_3->setMargin( 0 );
00322 
00323     YellowP = new QLabel( Frame4);
00324 //  YellowP->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, YellowP->sizePolicy().hasHeightForWidth() ) );
00325     YellowP->setMinimumSize( QSize( 200, 10 ) );
00326     YellowP->setPixmap(image2);
00327     YellowP->setScaledContents( true );
00328     Layout1_2_3->addWidget( YellowP );
00329 
00330     YellowSL = new QSlider( Frame4 );
00331     YellowSL->setMinimumSize( QSize( 200, 16 ) );
00332     YellowSL->setMaximum( 100 );
00333     YellowSL->setOrientation( Qt::Horizontal );
00334     Layout1_2_3->addWidget( YellowSL );
00335     Layout2x->addLayout(Layout1_2_3, 2, 1);
00336 
00337     YellowSp = new ScrSpinBox( 0, 100, Frame4, 0 );
00338     YellowSp->setSuffix( tr(" %"));
00339     Layout2x->addWidget(YellowSp, 2, 2);
00340     YellowSp->setValue(cyd);
00341     YellowSL->setValue(qRound(cyd));
00342 
00343     BlackT = new QLabel( tr( "K:" ), Frame4 );
00344     Layout2x->addWidget(BlackT, 3, 0);
00345 
00346     Layout1_2_4 = new QVBoxLayout;
00347     Layout1_2_4->setSpacing( 0 );
00348     Layout1_2_4->setMargin( 0 );
00349 
00350     BlackP = new QLabel( Frame4 );
00351 //  BlackP->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, BlackP->sizePolicy().hasHeightForWidth() ) );
00352     BlackP->setMinimumSize( QSize( 200, 10 ) );
00353     BlackP->setPixmap(image3);
00354     BlackP->setScaledContents( true );
00355     Layout1_2_4->addWidget( BlackP );
00356 
00357     BlackSL = new QSlider( Frame4 );
00358     BlackSL->setMinimumSize( QSize( 200, 16 ) );
00359     BlackSL->setMaximum( 100 );
00360     BlackSL->setOrientation( Qt::Horizontal );
00361     Layout1_2_4->addWidget( BlackSL );
00362     Layout2x->addLayout(Layout1_2_4, 3, 1);
00363 
00364     BlackSp = new ScrSpinBox( 0, 100, Frame4, 0 );
00365     BlackSp->setSuffix( tr(" %"));
00366     Layout2x->addWidget(BlackSp, 3, 2);
00367     BlackSp->setValue(ckd);
00368     BlackSL->setValue(qRound(ckd));
00369     BlackComp = cmyk.k;
00370     Frame4Layout->addLayout( Layout2x );
00371     QSpacerItem* spacer2 = new QSpacerItem( 2, 2, QSizePolicy::Minimum, QSizePolicy::Expanding );
00372     Frame4Layout->addItem( spacer2 );
00373     CMYKFarbenLayout->addWidget( Frame4 );
00374     int h, s, v;
00375     ScColorEngine::getRGBColor(orig, m_doc).getHsv(&h, &s, &v);
00376     ColorMap->drawPalette(v);
00377     ColorMap->setMark(h, s);
00378     Fnam = name;
00379     Farbname->selectAll();
00380     Farbname->setFocus();
00381     TabStack->setCurrentIndex(0);
00382     setFixedSize(minimumSizeHint());
00383     setContextMenuPolicy(Qt::CustomContextMenu);
00384     // signals and slots connections
00385 //  Regist->setToolTip( "<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>");
00386     Separations->setToolTip( "<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>");
00387     connect( Cancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
00388     connect( Cancel_2, SIGNAL( clicked() ), this, SLOT( Verlassen() ) );
00389     connect( CyanSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00390     connect( MagentaSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00391     connect( YellowSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00392     connect( BlackSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00393     connect( CyanSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00394     connect( MagentaSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00395     connect( YellowSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00396     connect( BlackSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00397     connect( CyanSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00398     connect( MagentaSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00399     connect( YellowSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00400     connect( BlackSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00401     connect( ColorMap, SIGNAL( ColorVal(int, int, bool)), this, SLOT( setColor2(int, int, bool)));
00402     connect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
00403     connect( Swatches, SIGNAL(activated(int)), this, SLOT(SelSwatch(int)));
00404     connect(ColorSwatch, SIGNAL( itemClicked(QListWidgetItem*) ), this, SLOT( SelFromSwatch(QListWidgetItem*) ) );
00405     connect(Separations, SIGNAL(clicked()), this, SLOT(setSpot()));
00406 //  connect(Regist, SIGNAL(clicked()), this, SLOT(setRegist()));
00407     connect(this, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(slotRightClick()));
00408     layout()->activate();
00409     if (!CMYKmode)
00410         SelModel ( tr( "RGB" ));
00411     isRegistration = Farbe.isRegistrationColor();
00412     if (Farbe.isRegistrationColor())
00413     {
00414         ComboBox1->setEnabled(false);
00415         Separations->setEnabled(false);
00416     }
00417 }
00418 
00419 void CMYKChoose::setValSLiders(double value)
00420 {
00421     int val = qRound(value);
00422     if (CyanSp == sender())
00423         CyanSL->setValue(val);
00424     if (MagentaSp == sender())
00425         MagentaSL->setValue(val);
00426     if (YellowSp == sender())
00427         YellowSL->setValue(val);
00428     if (BlackSp == sender())
00429         BlackSL->setValue(val);
00430 }
00431 
00432 void CMYKChoose::slotRightClick()
00433 {
00434     QMenu *pmen = new QMenu();
00435     qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
00436     QAction* dynAct;
00437     if (dynamic)
00438         dynAct = pmen->addAction( tr("Static Color Bars"));
00439     else
00440         dynAct = pmen->addAction( tr("Dynamic Color Bars"));
00441     connect(dynAct, SIGNAL(triggered()), this, SLOT(ToggleSL()));
00442     pmen->exec(QCursor::pos());
00443     delete pmen;
00444 }
00445 
00446 void CMYKChoose::SetValueS(int val)
00447 {
00448     disconnect( CyanSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00449     disconnect( MagentaSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00450     disconnect( YellowSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00451     disconnect( BlackSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00452     if (CyanSL == sender())
00453         CyanSp->setValue(val);
00454     if (MagentaSL == sender())
00455         MagentaSp->setValue(val);
00456     if (YellowSL == sender())
00457         YellowSp->setValue(val);
00458     if (BlackSL == sender())
00459         BlackSp->setValue(val);
00460     setColor();
00461     connect( CyanSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00462     connect( MagentaSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00463     connect( YellowSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00464     connect( BlackSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00465 }
00466 
00467 void CMYKChoose::ToggleSL()
00468 {
00469     dynamic = !dynamic;
00470     CyanP->setPixmap(SliderPix(CMYKmode ? 180 : 0));
00471     MagentaP->setPixmap(SliderPix(CMYKmode? 300 : 120));
00472     YellowP->setPixmap(SliderPix(CMYKmode? 60 : 240));
00473     if (CMYKmode)
00474         BlackP->setPixmap(SliderBlack());
00475 }
00476 
00477 QPixmap CMYKChoose::SliderPix(int farbe)
00478 {
00479     RGBColor rgb;
00480     CMYKColor cmyk;
00481     QPixmap image0 = QPixmap(255,10);
00482     QPainter p;
00483     p.begin(&image0);
00484     p.setPen(Qt::NoPen);
00485     int r, g, b, c, m, y, k;
00486     QColor tmp;
00487     for (int x = 0; x < 255; x += 5)
00488     {
00489         if (CMYKmode)
00490         {
00491             ScColorEngine::getCMYKValues(Farbe, m_doc, cmyk);
00492             cmyk.getValues(c, m, y, k);
00493             if (dynamic)
00494             {
00495                 switch (farbe)
00496                 {
00497                 case 180:
00498                     tmp = ScColorEngine::getDisplayColorGC(ScColor(x, m, y, k), m_doc);
00499                     break;
00500                 case 300:
00501                     tmp = ScColorEngine::getDisplayColorGC(ScColor(c, x, y, k), m_doc);
00502                     break;
00503                 case 60:
00504                     tmp = ScColorEngine::getDisplayColorGC(ScColor(c, m, x, k), m_doc);
00505                     break;
00506                 }
00507                 p.setBrush(tmp);
00508             }
00509             else
00510             {
00511                 switch (farbe)
00512                 {
00513                 case 180:
00514                     tmp = ScColorEngine::getDisplayColorGC(ScColor(x, 0, 0, 0), m_doc);
00515                     break;
00516                 case 300:
00517                     tmp = ScColorEngine::getDisplayColorGC(ScColor(0, x, 0, 0), m_doc);
00518                     break;
00519                 case 60:
00520                     tmp = ScColorEngine::getDisplayColorGC(ScColor(0, 0, x, 0), m_doc);
00521                     break;
00522                 }
00523                 p.setBrush(tmp);
00524             }
00525         }
00526         else
00527         {
00528             ScColorEngine::getRGBValues(Farbe, m_doc, rgb);
00529             rgb.getValues(r, g, b);
00530             if (dynamic)
00531             {
00532                 switch (farbe)
00533                 {
00534                 case 0:
00535                     tmp = ScColorEngine::getDisplayColorGC(ScColor(x, g, b), m_doc);
00536                     break;
00537                 case 120:
00538                     tmp = ScColorEngine::getDisplayColorGC(ScColor(r, x, b), m_doc);
00539                     break;
00540                 case 240:
00541                     tmp = ScColorEngine::getDisplayColorGC(ScColor(r, g, x), m_doc);
00542                     break;
00543                 }
00544                 p.setBrush(tmp);
00545             }
00546             else
00547             {
00548                 switch (farbe)
00549                 {
00550                 case 0:
00551                     tmp = ScColorEngine::getDisplayColorGC(ScColor(x, 0, 0), m_doc);
00552                     break;
00553                 case 120:
00554                     tmp = ScColorEngine::getDisplayColorGC(ScColor(0, x, 0), m_doc);
00555                     break;
00556                 case 240:
00557                     tmp = ScColorEngine::getDisplayColorGC(ScColor(0, 0, x), m_doc);
00558                     break;
00559                 }
00560                 p.setBrush(tmp);
00561             }
00562         }
00563         p.drawRect(x, 0, 5, 10);
00564     }
00565     p.end();
00566     return image0;
00567 }
00568 
00569 QPixmap CMYKChoose::SliderBlack()
00570 {
00571     QPixmap image0 = QPixmap(255,10);
00572     QPainter p;
00573     int val = 255;
00574     p.begin(&image0);
00575     p.setPen(Qt::NoPen);
00576     int c, m, y, k;
00577     CMYKColor cmyk;
00578     ScColorEngine::getCMYKValues(Farbe, m_doc, cmyk);
00579     cmyk.getValues(c, m, y, k);
00580     for (int x = 0; x < 255; x += 5)
00581     {
00582         if (dynamic)
00583             p.setBrush( ScColorEngine::getDisplayColorGC(ScColor(c, m, y, x), m_doc) );
00584         else
00585             p.setBrush( ScColorEngine::getDisplayColorGC(ScColor(0, 0, 0, x), m_doc) );
00586         p.drawRect(x, 0, 5, 10);
00587         val -= 5;
00588     }
00589     p.end();
00590     return image0;
00591 }
00592 
00593 void CMYKChoose::SelSwatch(int n)
00594 {
00595     if (n == 0)
00596         TabStack->setCurrentIndex(0);
00597     else
00598     {
00599         bool cus = false;
00600         CurrSwatch.clear();
00601         QString Cpfad = QDir::convertSeparators(ScPaths::getApplicationDataDir() + Swatches->currentText());
00602         QString pfadC = ScPaths::instance().libDir()+"swatches/";
00603         QString pfadC2 = pfadC + "Scribus_Basic.txt";
00604         if (n<customSetStartIndex)
00605         {
00606             QString listText=Swatches->itemText(n);
00607             if (listText=="Scribus OpenOffice")
00608                 cus=true;
00609             pfadC2 = csm.paletteFileFromName(listText);
00610         }
00611         else
00612         {
00613             pfadC2 = Cpfad;
00614             cus = true;
00615         }
00616         if (n != 0)
00617         {
00618             QFile fiC(pfadC2);
00619             if (fiC.open(QIODevice::ReadOnly))
00620             {
00621                 QString ColorEn, Cname;
00622                 int Rval, Gval, Bval, Kval;
00623                 QTextStream tsC(&fiC);
00624                 ColorEn = tsC.readLine();
00625                 if (ColorEn.startsWith("<?xml version="))
00626                 {
00627                     QByteArray docBytes("");
00628                     loadRawText(pfadC2, docBytes);
00629                     QString docText("");
00630                     docText = QString::fromUtf8(docBytes);
00631                     QDomDocument docu("scridoc");
00632                     docu.setContent(docText);
00633                     ScColor lf = ScColor();
00634                     QDomElement elem = docu.documentElement();
00635                     QDomNode PAGE = elem.firstChild();
00636                     while(!PAGE.isNull())
00637                     {
00638                         QDomElement pg = PAGE.toElement();
00639                         if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
00640                         {
00641                             if (pg.hasAttribute("CMYK"))
00642                                 lf.setNamedColor(pg.attribute("CMYK"));
00643                             else
00644                                 lf.fromQColor(QColor(pg.attribute("RGB")));
00645                             if (pg.hasAttribute("Spot"))
00646                                 lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
00647                             else
00648                                 lf.setSpotColor(false);
00649                             if (pg.hasAttribute("Register"))
00650                                 lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
00651                             else
00652                                 lf.setRegistrationColor(false);
00653                             CurrSwatch.insert(pg.attribute("NAME"), lf);
00654                         }
00655                         PAGE=PAGE.nextSibling();
00656                     }
00657                 }
00658                 else
00659                 {
00660                     while (!tsC.atEnd())
00661                     {
00662                         ScColor tmp;
00663                         ColorEn = tsC.readLine();
00664                         if (ColorEn.length()>0 && ColorEn[0]==QChar('#'))
00665                             continue;
00666                         QTextStream CoE(&ColorEn, QIODevice::ReadOnly);
00667                         CoE >> Rval;
00668                         CoE >> Gval;
00669                         CoE >> Bval;
00670                         if (cus)
00671                         {
00672                             CoE >> Kval;
00673                             Cname = CoE.readAll().trimmed();
00674                             tmp.setColor(Rval, Gval, Bval, Kval);
00675                         }
00676                         else
00677                         {
00678                             Cname = CoE.readAll().trimmed();
00679                             tmp.setColorRGB(Rval, Gval, Bval);
00680                         }
00681     
00682                         if ((n<customSetStartIndex) && (Cname.length()==0))
00683                         {
00684                             if (!cus)
00685                                 Cname=QString("#%1%2%3").arg(Rval,2,16).arg(Gval,2,16).arg(Bval,2,16).toUpper();
00686                             else
00687                                 Cname=QString("#%1%2%3%4").arg(Rval,2,16).arg(Gval,2,16).arg(Bval,2,16).arg(Kval,2,16).toUpper();
00688                             Cname.replace(" ","0");
00689                         }
00690                         if (CurrSwatch.contains(Cname))
00691                         {
00692                             if (tmp==CurrSwatch[Cname])
00693                                 continue;
00694                             Cname=QString("%1%2").arg(Cname).arg(CurrSwatch.count());
00695                         }
00696     
00697                         CurrSwatch.insert(Cname, tmp);
00698                     }
00699                 }
00700                 fiC.close();
00701             }
00702             else
00703             {
00704                 CurrSwatch.insert("White", ScColor(0, 0, 0, 0));
00705                 CurrSwatch.insert("Black", ScColor(0, 0, 0, 255));
00706                 ScColor cc = ScColor(255, 255, 255, 255);
00707                 cc.setRegistrationColor(true);
00708                 CurrSwatch.insert("Registration", cc);
00709                 CurrSwatch.insert("Blue", ScColor(255, 255, 0, 0));
00710                 CurrSwatch.insert("Cyan", ScColor(255, 0, 0, 0));
00711                 CurrSwatch.insert("Green", ScColor(255, 0, 255, 0));
00712                 CurrSwatch.insert("Red", ScColor(0, 255, 255, 0));
00713                 CurrSwatch.insert("Yellow", ScColor(0, 0, 255, 0));
00714                 CurrSwatch.insert("Magenta", ScColor(0, 255, 0, 0));
00715             }
00716         }
00717         ColorSwatch->clear();
00718         ColorSwatch->insertFancyPixmapItems(CurrSwatch);
00719         ColorSwatch->setCurrentRow( 0 );
00720         TabStack->setCurrentIndex(1);
00721     }
00722 }
00723 /*
00724 void CMYKChoose::setRegist()
00725 {
00726     disconnect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
00727     if (Regist->isChecked())
00728     {
00729         ComboBox1->setCurrentIndex( 0 );
00730         Separations->setChecked(false);
00731         SelModel( tr("CMYK"));
00732     }
00733     connect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
00734 }
00735 */
00736 void CMYKChoose::setSpot()
00737 {
00738     disconnect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
00739     if (Separations->isChecked())
00740     {
00741         ComboBox1->setCurrentIndex( 0 );
00742         SelModel( tr("CMYK"));
00743     }
00744     connect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
00745 }
00746 
00747 void CMYKChoose::SelModel(const QString& mod)
00748 {
00749     disconnect( CyanSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00750     disconnect( MagentaSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00751     disconnect( YellowSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00752     disconnect( BlackSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
00753     disconnect( CyanSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00754     disconnect( MagentaSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00755     disconnect( YellowSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00756     disconnect( BlackSL, SIGNAL( valueChanged(int) ), this, SLOT( SetValueS(int) ) );
00757     disconnect( CyanSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00758     disconnect( MagentaSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00759     disconnect( YellowSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00760     disconnect( BlackSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
00761     if (mod == tr("CMYK"))
00762     {
00763         CMYKmode = true;
00764         Wsave = false;
00765         CyanSL->setMaximum( 100 );
00766         MagentaSL->setMaximum( 100 );
00767         YellowSL->setMaximum( 100 );
00768         CyanSp->setMaximum( 100 );
00769         MagentaSp->setMaximum( 100);
00770         YellowSp->setMaximum( 100 );
00771         CyanSL->setSingleStep(1);
00772         MagentaSL->setSingleStep(1);
00773         YellowSL->setSingleStep(1);
00774         CyanSL->setPageStep(10);
00775         MagentaSL->setPageStep(10);
00776         YellowSL->setPageStep(10);
00777         CyanSp->setDecimals(1);
00778         MagentaSp->setDecimals(1);
00779         YellowSp->setDecimals(1);
00780         CyanSp->setSingleStep(1);
00781         MagentaSp->setSingleStep(1);
00782         YellowSp->setSingleStep(1);
00783         CyanSp->setSuffix( tr(" %"));
00784         MagentaSp->setSuffix( tr(" %"));
00785         YellowSp->setSuffix( tr(" %"));
00786         CyanT->setText( tr("C:"));
00787         MagentaT->setText( tr("M:"));
00788         YellowT->setText( tr("Y:"));
00789         CyanP->setPixmap(SliderPix(180));
00790         MagentaP->setPixmap(SliderPix(300));
00791         YellowP->setPixmap(SliderPix(60));
00792         BlackP->setPixmap(SliderBlack());
00793 /*      BlackP->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
00794         BlackSL->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
00795         BlackSp->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
00796         BlackT->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); */
00797         BlackP->show();
00798         BlackSL->show();
00799         BlackSp->show();
00800         BlackT->show();
00801         Farb