Back to index

scribus-ng  1.3.4.dfsg+svn20071115
cpalette.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 /***************************************************************************
00008                           cpalette.cpp  -  description
00009                              -------------------
00010     begin                : Wed Apr 25 2001
00011     copyright            : (C) 2001 by Franz Schmid
00012     email                : Franz.Schmid@altmuehlnet.de
00013  ***************************************************************************/
00014 
00015 /***************************************************************************
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 #include "cpalette.h"
00025 #include "cpalette.moc"
00026 
00027 #include <qtooltip.h>
00028 #include <qlistbox.h>
00029 #include <qpixmap.h>
00030 #include <qrect.h>
00031 #include <qpopupmenu.h>
00032 #include <qfont.h>
00033 #include <qlayout.h>
00034 #include <qtoolbutton.h>
00035 #include <qbuttongroup.h>
00036 #include <qgroupbox.h>
00037 #include <qlabel.h>
00038 #include <qspinbox.h>
00039 #include <qiconview.h>
00040 #include "colorlistbox.h"
00041 #include "sccombobox.h"
00042 #include "scribusdoc.h"
00043 #include "mspinbox.h"
00044 #include "gradienteditor.h"
00045 #include "units.h"
00046 #include "page.h"
00047 #include "pageitem.h"
00048 #include "util.h"
00049 #include "dynamictip.h"
00050 #include "commonstrings.h"
00051 #include "linkbutton.h"
00052 #include "sccolorengine.h"
00053 #ifdef HAVE_CAIRO
00054 #include <cairo.h>
00055 #endif
00056 
00057 
00058 Cpalette::Cpalette(QWidget* parent) : QWidget(parent, "Cdouble")
00059 {
00060        Color = "";
00061        Color3 = "";
00062        Shade = 100;
00063        Shade3 = 100;
00064        currentGradient = 0;
00065        currentItem = 0;
00066        Form1Layout = new QVBoxLayout( this, 0, 0, "Form1Layout");
00067        Layout1 = new QHBoxLayout;
00068        Layout1->setSpacing( 4 );
00069        Layout1->setMargin( 1 );
00070        Inhalt = new QToolButton(this, "t1");
00071        Inhalt->setPixmap(loadIcon("16/color-stroke.png"));
00072        Inhalt->setToggleButton(true);
00073 //     Inhalt->setAutoRaise(true);
00074        Inhalt->setBackgroundMode(PaletteBackground);
00075        Layout1->addWidget(Inhalt);
00076        Innen = new QToolButton(this, "t2");
00077        Innen->setPixmap(loadIcon("16/color-fill.png"));
00078        Innen->setToggleButton(true);
00079 //     Innen->setAutoRaise(true);
00080        Innen->setBackgroundMode(PaletteBackground);
00081        Innen->setOn(true);
00082        Layout1->addWidget(Innen);
00083        selectorQSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00084        Layout1->addItem( selectorQSpacer );
00085        Mode = 2;
00086        ShadeTxt = new QLabel( this, "ShadeTxt" );
00087        Layout1->addWidget( ShadeTxt);
00088        PM1 = new QSpinBox( this, "shspin" );
00089        PM1->setMinValue(0);
00090        PM1->setMaxValue(100);
00091        PM1->setLineStep(10);
00092        PM1->setValue(100);
00093        Layout1->addWidget(PM1);
00094        Form1Layout->addLayout(Layout1);
00095        GradLayout = new QVBoxLayout( 0, 0, 6, "GradLayout");
00096        QFont fo = QFont(font());
00097        fo.setPointSize(fo.pointSize()-1);
00098        gradientQCombo = new ScComboBox( false, this, "gradientQCombo" );
00099        gradientQCombo->setFont(fo);
00100        GradLayout->addWidget( gradientQCombo );
00101        gradEdit = new GradientEditor(this);
00102        gradEdit->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding));
00103        GradLayout->addWidget(gradEdit, Qt::AlignHCenter);
00104        freeGradientQFrame = new QFrame( this, "freeGradientQFrame" );
00105        freeGradientQFrame->setFrameShape( QFrame::NoFrame );
00106        freeGradientQFrame->setFrameShadow( QFrame::Plain );
00107        freeGradientLayout = new QGridLayout( freeGradientQFrame, 1, 1, 5, 5, "freeGradientLayout");
00108        GTextX1 = new QLabel("X1:", freeGradientQFrame, "GTextX1" );
00109        freeGradientLayout->addWidget( GTextX1, 0, 0 );
00110        GTextY1 = new QLabel("Y1:", freeGradientQFrame, "GTextY1" );
00111        freeGradientLayout->addWidget( GTextY1, 1, 0 );
00112        gX1 = new MSpinBox( freeGradientQFrame, 2);
00113        gX1->setDecimals(100);
00114        gX1->setMinValue(-3000);
00115        gX1->setMaxValue(3000);
00116        freeGradientLayout->addWidget( gX1, 0, 1 );
00117        gY1 = new MSpinBox( freeGradientQFrame, 2 );
00118        gY1->setDecimals(100);
00119        gY1->setMinValue(-3000);
00120        gY1->setMaxValue(3000);
00121        freeGradientLayout->addWidget( gY1, 1, 1 );
00122        GTextX2 = new QLabel("X2:", freeGradientQFrame, "GTextX2" );
00123        freeGradientLayout->addWidget( GTextX2, 0, 2 );
00124        GTextY2 = new QLabel("Y2:", freeGradientQFrame, "GTextY2" );
00125        freeGradientLayout->addWidget( GTextY2, 1, 2 );
00126        gX2 = new MSpinBox( freeGradientQFrame, 2 );
00127        gX2->setDecimals(100);
00128        gX2->setMinValue(-3000);
00129        gX2->setMaxValue(3000);
00130        freeGradientLayout->addWidget( gX2, 0, 3 );
00131        gY2 = new MSpinBox( freeGradientQFrame, 2 );
00132        gY2->setDecimals(100);
00133        gY2->setMinValue(-3000);
00134        gY2->setMaxValue(3000);
00135        freeGradientLayout->addWidget( gY2, 1, 3 );
00136        gradEditButton = new QToolButton(freeGradientQFrame, "t1");
00137        gradEditButton->setToggleButton(true);
00138        freeGradientLayout->addMultiCellWidget(gradEditButton, 2, 2, 0, 3);
00139        GradLayout->addWidget( freeGradientQFrame );
00140        Form1Layout->addLayout(GradLayout);
00141        colorListQLBox = new ColorListBox(this, "colorListQLBox");
00142        colorListQLBox->setMinimumSize( QSize( 150, 30 ) );
00143        colorListQLBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
00144        Form1Layout->addWidget(colorListQLBox);
00145        dynTip = new DynamicTip(colorListQLBox, &colorList);
00146 
00147        patternFrame = new QFrame( this, "frame3" );
00148        patternFrame->setFrameShape( QFrame::NoFrame );
00149        frame3Layout = new QVBoxLayout( patternFrame, 0, 2, "frame3Layout");
00150        patternBox = new QIconView(patternFrame, "patternBox");
00151        patternBox->setMinimumSize( QSize( 150, 30 ) );
00152        patternBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
00153        patternBox->setResizeMode( QIconView::Adjust );
00154        patternBox->setItemsMovable( false );
00155        frame3Layout->addWidget( patternBox );
00156 
00157        groupOffset = new QGroupBox( patternFrame, "groupOffset" );
00158        groupOffset->setColumnLayout(0, Qt::Vertical );
00159        groupOffset->layout()->setSpacing( 2 );
00160        groupOffset->layout()->setMargin( 3 );
00161        groupOffsetLayout = new QHBoxLayout( groupOffset->layout() );
00162        groupOffsetLayout->setAlignment( Qt::AlignTop );
00163        textLabel1 = new QLabel( groupOffset, "textLabel1" );
00164        groupOffsetLayout->addWidget( textLabel1 );
00165        spinXoffset = new MSpinBox( groupOffset, 2 );
00166        spinXoffset->setDecimals(100);
00167        spinXoffset->setMinValue(-3000);
00168        spinXoffset->setMaxValue(3000);
00169        groupOffsetLayout->addWidget( spinXoffset );
00170        textLabel2 = new QLabel( groupOffset, "textLabel2" );
00171        groupOffsetLayout->addWidget( textLabel2 );
00172        spinYoffset = new MSpinBox( groupOffset, 2 );
00173        spinYoffset->setDecimals(100);
00174        spinYoffset->setMinValue(-3000);
00175        spinYoffset->setMaxValue(3000);
00176        groupOffsetLayout->addWidget( spinYoffset );
00177        frame3Layout->addWidget( groupOffset );
00178 
00179        groupScale = new QGroupBox( patternFrame, "groupScale" );
00180        groupScale->setColumnLayout(0, Qt::Vertical );
00181        groupScale->layout()->setSpacing( 2 );
00182        groupScale->layout()->setMargin( 3 );
00183        groupScaleLayout = new QGridLayout( groupScale->layout() );
00184        groupScaleLayout->setAlignment( Qt::AlignTop );
00185        textLabel5 = new QLabel( groupScale, "textLabel5" );
00186        groupScaleLayout->addWidget( textLabel5, 0, 0 );
00187        spinXscaling = new MSpinBox( groupScale, 0);
00188        spinXscaling->setDecimals(1);
00189        spinXscaling->setMaxValue( 500 );
00190        spinXscaling->setMinValue( 1 );
00191        spinXscaling->setValue( 100 );
00192        groupScaleLayout->addWidget( spinXscaling, 0, 1 );
00193        textLabel6 = new QLabel( groupScale, "textLabel6" );
00194        groupScaleLayout->addWidget( textLabel6, 1, 0 );
00195        spinYscaling = new MSpinBox( groupScale, 0 );
00196        spinYscaling->setDecimals(1);
00197        spinYscaling->setMaxValue( 500 );
00198        spinYscaling->setMinValue( 1 );
00199        spinYscaling->setValue( 100 );
00200        groupScaleLayout->addWidget( spinYscaling, 1, 1 );
00201        keepScaleRatio = new LinkButton( groupScale );
00202        keepScaleRatio->setToggleButton( true );
00203        keepScaleRatio->setAutoRaise( true );
00204        keepScaleRatio->setMaximumSize( QSize( 15, 32767 ) );
00205        groupScaleLayout->addMultiCellWidget( keepScaleRatio, 0, 1, 2, 2 );
00206        frame3Layout->addWidget( groupScale );
00207 
00208        groupRotation = new QGroupBox( patternFrame, "groupRotation" );
00209        groupRotation->setColumnLayout(0, Qt::Vertical );
00210        groupRotation->layout()->setSpacing( 2 );
00211        groupRotation->layout()->setMargin( 3 );
00212        groupRotationLayout = new QHBoxLayout( groupRotation->layout() );
00213        groupRotationLayout->setAlignment( Qt::AlignTop );
00214        textLabel7 = new QLabel( groupRotation, "textLabel7" );
00215        groupRotationLayout->addWidget( textLabel7 );
00216        spinAngle = new MSpinBox( groupRotation, 1 );
00217        spinAngle->setDecimals(10);
00218        spinAngle->setMaxValue( 180 );
00219        spinAngle->setMinValue( -180 );
00220        spinAngle->setValue( 0 );
00221        groupRotationLayout->addWidget( spinAngle );
00222        frame3Layout->addWidget( groupRotation );
00223        Form1Layout->addWidget(patternFrame);
00224        patternFrame->hide();
00225 
00226        TransGroup = new QGroupBox( tr( "Transparency Settings" ), this, "TransGroup" );
00227        TransGroup->setColumnLayout(0, Qt::Vertical );
00228        TransGroup->layout()->setSpacing( 0 );
00229        TransGroup->layout()->setMargin( 0 );
00230        Layout1t = new QGridLayout( TransGroup->layout() );
00231        Layout1t->setAlignment( Qt::AlignTop );
00232        Layout1t->setSpacing( 5 );
00233        Layout1t->setMargin( 5 );
00234        TransTxt = new QLabel( TransGroup, "Transtxt" );
00235        Layout1t->addWidget( TransTxt, 0, 0 );
00236        TransSpin = new QSpinBox( TransGroup, "traspin" );
00237        TransSpin->setMinValue(0);
00238        TransSpin->setMaxValue(100);
00239        TransSpin->setLineStep(10);
00240        TransSpin->setValue(100);
00241        Layout1t->addWidget(TransSpin, 0, 1);
00242        TransTxt2 = new QLabel( TransGroup, "textLabel1" );
00243        Layout1t->addWidget( TransTxt2, 1, 0 );
00244        blendMode = new ScComboBox( false, TransGroup, "blendMode" );
00245        Layout1t->addWidget( blendMode, 1, 1 );
00246        Form1Layout->addWidget(TransGroup);
00247 #ifndef HAVE_CAIRO
00248        groupOffset->hide();
00249        blendMode->hide();
00250        TransTxt2->hide();
00251 /*
00252 #else
00253 #if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 1, 8)
00254        blendMode->hide();
00255        TransTxt2->hide();
00256 #endif
00257 */
00258 #endif
00259 
00260        Inhalt->setOn(true);
00261        InnenButton();
00262        GradientMode = false;
00263 
00264        languageChange();
00265        setActGradient(0);
00266 
00267        connect(Inhalt, SIGNAL(clicked()), this, SLOT(InhaltButton()));
00268        connect(Innen, SIGNAL(clicked()), this, SLOT(InnenButton()));
00269        connect(colorListQLBox, SIGNAL(clicked(QListBoxItem*)), this, SLOT(selectColor(QListBoxItem*)));
00270        connect(colorListQLBox, SIGNAL(selected(QListBoxItem*)), this, SLOT(selectColor(QListBoxItem*)));
00271        connect(PM1, SIGNAL(valueChanged(int)), this, SLOT(setActShade()));
00272        connect(gradientQCombo, SIGNAL(activated(int)), this, SLOT(slotGrad(int)));
00273        connect(TransSpin, SIGNAL(valueChanged(int)), this, SLOT(slotTrans(int)));
00274        connect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
00275        connect(gX1, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00276        connect(gX2, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00277        connect(gY1, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00278        connect(gY2, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00279        connect(spinXoffset, SIGNAL(valueChanged(int)), this, SLOT(changePatternProps()));
00280        connect(spinYoffset, SIGNAL(valueChanged(int)), this, SLOT(changePatternProps()));
00281        connect(spinXscaling, SIGNAL(valueChanged(int)), this, SLOT(HChange()));
00282        connect(spinYscaling, SIGNAL(valueChanged(int)), this, SLOT(VChange()));
00283        connect(keepScaleRatio, SIGNAL(clicked()), this, SLOT(ToggleKette()));
00284        connect(spinAngle, SIGNAL(valueChanged(int)), this, SLOT(changePatternProps()));
00285        connect(gradEdit->Preview, SIGNAL(selectedColor(QString, int )), this, SLOT(slotColor(QString, int )));
00286        connect(gradEdit->Preview, SIGNAL(currTrans(double )), this, SLOT(setGradTrans(double )));
00287        connect(gradEdit, SIGNAL(gradientChanged()), this, SIGNAL(gradientChanged()));
00288        connect(gradEdit->Preview, SIGNAL(gradientChanged()), this, SIGNAL(gradientChanged()));
00289        connect(gradEditButton, SIGNAL(clicked()), this, SIGNAL(editGradient()));
00290 }
00291 
00292 void Cpalette::setCurrentItem(PageItem* item)
00293 {
00294        currentItem = item;
00295 }
00296 
00297 void Cpalette::updateFromItem()
00298 {
00299        if (currentItem == NULL)
00300               return;
00301        if (!currentDoc)
00302               return;
00303        Color = currentItem->lineColor();
00304        Shade = currentItem->lineShade();
00305        Color3 = currentItem->fillColor();
00306        Shade3 = currentItem->fillShade();
00307        setActTrans(currentItem->fillTransparency(), currentItem->lineTransparency());
00308        setActBlend(currentItem->fillBlendmode(), currentItem->lineBlendmode());
00309        if (Mode == 1)
00310        {
00311               updateCList();
00312               setActFarben(Color, Color3, Shade, Shade3);
00313        }
00314        else
00315        {
00316               ChooseGrad(currentItem->GrType);
00317               gradEdit->Preview->fill_gradient = currentItem->fill_gradient;
00318               gradientQCombo->setCurrentItem(currentItem->GrType);
00319               gradEdit->Preview->updateDisplay();
00320               double dur = currentDoc->unitRatio();
00321               setSpecialGradient(currentItem->GrStartX * dur, currentItem->GrStartY * dur, currentItem->GrEndX * dur, currentItem->GrEndY * dur);
00322        }
00323 }
00324 
00325 void Cpalette::InhaltButton()
00326 {
00327        if (Inhalt->isOn())
00328        {
00329               Mode = 1;
00330               Innen->setOn(false);
00331               freeGradientQFrame->hide();
00332               freeGradientQFrame->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00333               gradientQCombo->hide();
00334               gradientQCombo->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00335               gradEdit->hide();
00336               gradEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00337               patternFrame->hide();
00338               patternFrame->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00339               colorListQLBox->show();
00340               colorListQLBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
00341               GradientMode = false;
00342               layout()->activate();
00343 //            updateCList();
00344 //            repaint();
00345        }
00346        updateFromItem();
00347        emit modeChanged();
00348 }
00349 
00350 void Cpalette::InnenButton()
00351 {
00352        if (Innen->isOn())
00353        {
00354               Mode = 2;
00355               Inhalt->setOn(false);
00356               gradientQCombo->show();
00357               gradientQCombo->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
00358               GradientMode = gradientQCombo->currentItem() != 0 ? true : false;
00359               if (GradientMode)
00360               {
00361                      if (gradEdit->isHidden())
00362                      {
00363                             gradEdit->show();
00364                             gradEdit->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
00365                      }
00366                      if (gradientQCombo->currentItem() > 5)
00367                      {
00368                             freeGradientQFrame->show();
00369                             freeGradientQFrame->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
00370                      }
00371                      else
00372                      {
00373                             freeGradientQFrame->hide();
00374                             freeGradientQFrame->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00375                      }
00376               }
00377               layout()->activate();
00378 //            updateCList();
00379 //            repaint();
00380        }
00381        updateFromItem();
00382        emit modeChanged();
00383 }
00384 
00385 void Cpalette::updatePatternList()
00386 {
00387        disconnect(patternBox, SIGNAL(clicked(QIconViewItem*)), this, SLOT(selectPattern(QIconViewItem*)));
00388        patternBox->clear();
00389        QMap<QString, ScPattern>::Iterator it;
00390        for (it = patternList->begin(); it != patternList->end(); ++it)
00391        {
00392               QPixmap pm;
00393               if (it.data().getPattern()->width() > it.data().getPattern()->height())
00394                      pm.convertFromImage(it.data().getPattern()->scaleWidth(48));
00395               else
00396                      pm.convertFromImage(it.data().getPattern()->scaleHeight(48));
00397               (void) new QIconViewItem(patternBox, it.key(), pm);
00398        }
00399        if (patternList->count() == 0)
00400               gradientQCombo->listBox()->item(8)->setSelectable(false);
00401        else
00402               gradientQCombo->listBox()->item(8)->setSelectable(true);
00403        patternBox->setSelected(patternBox->currentItem(), false);
00404        connect(patternBox, SIGNAL(clicked(QIconViewItem*)), this, SLOT(selectPattern(QIconViewItem*)));
00405 }
00406 
00407 void Cpalette::SetPatterns(QMap<QString, ScPattern> *docPatterns)
00408 {
00409        patternList = docPatterns;
00410        updatePatternList();
00411 }
00412 
00413 void Cpalette::selectPattern(QIconViewItem *c)
00414 {
00415        if (c == NULL)
00416               return;
00417        emit NewPattern(c->text());
00418 }
00419 
00420 void Cpalette::changePatternProps()
00421 {
00422        emit NewPatternProps(spinXscaling->value(), spinYscaling->value(), spinXoffset->value(), spinYoffset->value(), spinAngle->value());
00423 }
00424 
00425 void Cpalette::ToggleKette()
00426 {
00427        disconnect(spinXscaling, SIGNAL(valueChanged(int)), this, SLOT(HChange()));
00428        disconnect(spinYscaling, SIGNAL(valueChanged(int)), this, SLOT(VChange()));
00429        if (keepScaleRatio->isOn())
00430        {
00431               spinYscaling->setValue(spinXscaling->value());
00432               changePatternProps();
00433               keepScaleRatio->setOn(true);
00434        }
00435        else
00436               keepScaleRatio->setOn(false);
00437        connect(spinXscaling, SIGNAL(valueChanged(int)), this, SLOT(HChange()));
00438        connect(spinYscaling, SIGNAL(valueChanged(int)), this, SLOT(VChange()));
00439 }
00440 
00441 void Cpalette::HChange()
00442 {
00443        disconnect(spinXscaling, SIGNAL(valueChanged(int)), this, SLOT(HChange()));
00444        disconnect(spinYscaling, SIGNAL(valueChanged(int)), this, SLOT(VChange()));
00445        if (keepScaleRatio->isOn())
00446               spinYscaling->setValue(spinXscaling->value());
00447        changePatternProps();
00448        connect(spinXscaling, SIGNAL(valueChanged(int)), this, SLOT(HChange()));
00449        connect(spinYscaling, SIGNAL(valueChanged(int)), this, SLOT(VChange()));
00450 }
00451 
00452 void Cpalette::VChange()
00453 {
00454        disconnect(spinXscaling, SIGNAL(valueChanged(int)), this, SLOT(HChange()));
00455        disconnect(spinYscaling, SIGNAL(valueChanged(int)), this, SLOT(VChange()));
00456        if (keepScaleRatio->isOn())
00457               spinXscaling->setValue(spinYscaling->value());
00458        changePatternProps();
00459        connect(spinXscaling, SIGNAL(valueChanged(int)), this, SLOT(HChange()));
00460        connect(spinYscaling, SIGNAL(valueChanged(int)), this, SLOT(VChange()));
00461 }
00462 
00463 void Cpalette::SetColors(ColorList newColorList)
00464 {
00465        colorList.clear();
00466        colorList = newColorList;
00467        updateCList();
00468 }
00469 
00470 void Cpalette::updateCList()
00471 {
00472        disconnect(colorListQLBox, SIGNAL(clicked(QListBoxItem*)), this, SLOT(selectColor(QListBoxItem*)));
00473        disconnect(colorListQLBox, SIGNAL(selected(QListBoxItem*)), this, SLOT(selectColor(QListBoxItem*)));
00474        colorListQLBox->clear();
00475        if ((!GradientMode) || (Mode == 1))
00476               colorListQLBox->insertItem(CommonStrings::tr_NoneColor);
00477        colorListQLBox->insertItems(colorList, ColorListBox::fancyPixmap);
00478        colorListQLBox->setSelected(colorListQLBox->currentItem(), false);
00479        connect(colorListQLBox, SIGNAL(clicked(QListBoxItem*)), this, SLOT(selectColor(QListBoxItem*)));
00480        connect(colorListQLBox, SIGNAL(selected(QListBoxItem*)), this, SLOT(selectColor(QListBoxItem*)));
00481 }
00482 
00483 void Cpalette::selectColor(QListBoxItem *c)
00484 {
00485        if (c == NULL) { return; }
00486        sFarbe = c->text();
00487        switch (Mode)
00488        {
00489        case 1:
00490               emit NewPen(sFarbe);
00491               break;
00492        case 2:
00493               if (gradientQCombo->currentItem() == 0)
00494               {
00495                      Color3 = sFarbe;
00496                      emit NewBrush(sFarbe);
00497               }
00498               else if (gradientQCombo->currentItem() < 8)
00499               {
00500                      gradEdit->Preview->setActColor(setColor(sFarbe, Shade), sFarbe, Shade);
00501                      Color = sFarbe;
00502                      emit gradientChanged();
00503               }
00504               break;
00505        }
00506 }
00507 
00508 QColor Cpalette::setColor(QString colorName, int shad)
00509 {
00510        const ScColor& color = colorList[colorName];
00511        return ScColorEngine::getShadeColorProof(color, currentDoc, shad);
00512 }
00513 
00514 void Cpalette::updateBoxS(QString colorName)
00515 {
00516        disconnect(colorListQLBox, SIGNAL(clicked(QListBoxItem*)), this, SLOT(selectColor(QListBoxItem*)));
00517        disconnect(colorListQLBox, SIGNAL(selected(QListBoxItem*)), this, SLOT(selectColor(QListBoxItem*)));
00518        int c = 0;
00519        if ((colorName != CommonStrings::None) && (!colorName.isEmpty()))
00520        {
00521               if (!GradientMode)
00522                      ++c;
00523               ColorList::Iterator itend=colorList.end();
00524               for (ColorList::Iterator it = colorList.begin(); it != itend; ++it)
00525               {
00526                      if (it.key() == colorName)
00527                             break;
00528                      ++c;
00529               }
00530        }
00531        colorListQLBox->setCurrentItem(c);
00532        connect(colorListQLBox, SIGNAL(clicked(QListBoxItem*)), this, SLOT(selectColor(QListBoxItem*)));
00533        connect(colorListQLBox, SIGNAL(selected(QListBoxItem*)), this, SLOT(selectColor(QListBoxItem*)));
00534 }
00535 
00536 void Cpalette::setActFarben(QString p, QString b, int shp, int shb)
00537 {
00538        disconnect(PM1, SIGNAL(valueChanged(int)), this, SLOT(setActShade()));
00539        switch (Mode)
00540        {
00541        case 1:
00542               PM1->setValue(shp);
00543               updateBoxS(p);
00544               break;
00545        case 2:
00546               Color3 = b;
00547               Shade3 = shb;
00548               PM1->setValue(shb);
00549               updateBoxS(b);
00550               break;
00551        }
00552        connect(PM1, SIGNAL(valueChanged(int)), this, SLOT(setActShade()));
00553 }
00554 
00555 void Cpalette::slotColor(QString n, int s)
00556 {
00557        if ((GradientMode) && (Mode ==2))
00558        {
00559               disconnect(PM1, SIGNAL(valueChanged(int)), this, SLOT(setActShade()));
00560               Color = n;
00561               Shade = s;
00562               PM1->setValue(Shade);
00563               updateBoxS(Color);
00564               connect(PM1, SIGNAL(valueChanged(int)), this, SLOT(setActShade()));
00565        }
00566 }
00567 
00568 void Cpalette::slotGrad(int number)
00569 {
00570        if ((number == 8) && (patternList->count() == 0))
00571        {
00572               gradientQCombo->setCurrentItem(currentGradient);
00573               return;
00574        }
00575        int oldgrad = currentGradient;
00576        ChooseGrad(number);
00577        if ((currentGradient != 0) && (oldgrad != currentGradient))
00578        {
00579               gradEdit->Preview->fill_gradient = currentItem->fill_gradient;
00580               gradEdit->Preview->updateDisplay();
00581        }
00582        emit NewGradient(number);
00583 }
00584 
00585 void Cpalette::ChooseGrad(int number)
00586 {
00587        if (number==-1)
00588        {
00589               gradientQCombo->setCurrentItem(0);
00590               currentGradient = 0;
00591        }
00592        //no need to disconnect as qcombobox only emits from user action
00593        /* PFJ - 29.02.04 - Removed GradGroup and Gradient mode from switch */
00594        GradientMode = number == 0 ? false : number == 8 ? false : true;
00595 
00596        if (number != 0)
00597        {
00598               if (number == 8)
00599               {
00600                      PM1->setEnabled(false);
00601                      freeGradientQFrame->hide();
00602                      gradEdit->hide();
00603                      freeGradientQFrame->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00604                      gradEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00605                      colorListQLBox->hide();
00606                      colorListQLBox->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00607                      patternFrame->show();
00608                      patternFrame->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
00609               }
00610               else
00611               {
00612                      PM1->setEnabled(true);
00613                      patternFrame->hide();
00614                      patternFrame->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00615                      colorListQLBox->show();
00616                      colorListQLBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
00617                      gradEdit->show();
00618                      gradEdit->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
00619                      if (gradientQCombo->currentItem() > 5)
00620                      {
00621                             freeGradientQFrame->show();
00622                             freeGradientQFrame->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
00623                      }
00624                      else
00625                      {
00626                             freeGradientQFrame->hide();
00627                             freeGradientQFrame->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00628                      }
00629               }
00630        }
00631        else
00632        {
00633               PM1->setEnabled(true);
00634               patternFrame->hide();
00635               patternFrame->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00636               freeGradientQFrame->hide();
00637               gradEdit->hide();
00638               freeGradientQFrame->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00639               gradEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00640               colorListQLBox->show();
00641               colorListQLBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
00642        }
00643        layout()->activate();
00644        disconnect(PM1, SIGNAL(valueChanged(int)), this, SLOT(setActShade()));
00645        // JG probably not needed at all and should probably not be here
00646        updateCList();
00647        switch (number)
00648        {
00649        case 0:
00650               PM1->setValue(Shade3);
00651               updateBoxS(Color3);
00652               break;
00653        default:
00654               PM1->setValue(Shade);
00655               updateBoxS(Color);
00656               break;
00657        }
00658        setFocus();
00659        repaint();
00660        connect(PM1, SIGNAL(valueChanged(int)), this, SLOT(setActShade()));
00661 }
00662 
00663 void Cpalette::setActTrans(double val, double val2)
00664 {
00665        disconnect(TransSpin, SIGNAL(valueChanged(int)), this, SLOT(slotTrans(int)));
00666        TransSpin->setValue(qRound(100 - (Mode == 1 ? val2 * 100 : val * 100)));
00667        connect(TransSpin, SIGNAL(valueChanged(int)), this, SLOT(slotTrans(int)));
00668 }
00669 
00670 void Cpalette::setActBlend(int val, int val2)
00671 {
00672        disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
00673        blendMode->setCurrentItem(Mode == 1 ? val2 : val);
00674        connect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
00675 }
00676 
00677 void Cpalette::setGradTrans(double val)
00678 {
00679        if ((GradientMode) && (Mode ==2))
00680        {
00681               disconnect(TransSpin, SIGNAL(valueChanged(int)), this, SLOT(slotTrans(int)));
00682               TransSpin->setValue(qRound(val * 100));
00683               connect(TransSpin, SIGNAL(valueChanged(int)), this, SLOT(slotTrans(int)));
00684        }
00685 }
00686 
00687 void Cpalette::changeBlendMode(int blend)
00688 {
00689        if (Mode == 1)
00690               emit NewBlendS(blend);
00691        else
00692        {
00693               if ((gradientQCombo->currentItem() == 0) || (gradientQCombo->currentItem() == 8))
00694                      emit NewBlend(blend);
00695        }
00696 }
00697 
00698 void Cpalette::slotTrans(int val)
00699 {
00700        if (Mode == 1)
00701               emit NewTransS(static_cast<double>(100 - val) / 100.0);
00702        else
00703        {
00704               if ((gradientQCombo->currentItem() == 0) || (gradientQCombo->currentItem() == 8))
00705                      emit NewTrans(static_cast<double>(100 - val) / 100.0);
00706               else
00707               {
00708                      gradEdit->Preview->setActTrans(static_cast<double>(val) / 100.0);
00709                      emit gradientChanged();
00710               }
00711        }
00712        setFocus();
00713 }
00714 
00715 void Cpalette::setActGradient(int typ)
00716 {
00717        disconnect(gradientQCombo, SIGNAL(activated(int)), this, SLOT(slotGrad(int)));
00718        if (Mode == 2)
00719        {
00720               currentGradient = typ;
00721               gradientQCombo->setCurrentItem(typ);
00722               ChooseGrad(typ);
00723        }
00724        connect(gradientQCombo, SIGNAL(activated(int)), this, SLOT(slotGrad(int)));
00725 }
00726 
00727 void Cpalette::setSpecialGradient(double x1, double y1, double x2, double y2)
00728 {
00729        disconnect(gX1, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00730        disconnect(gX2, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00731        disconnect(gY1, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00732        disconnect(gY2, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00733        gX1->setValue(x1);
00734        gX2->setValue(x2);
00735        gY1->setValue(y1);
00736        gY2->setValue(y2);
00737        connect(gX1, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00738        connect(gX2, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00739        connect(gY1, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00740        connect(gY2, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00741 }
00742 
00743 void Cpalette::changeSpecial()
00744 {
00745        emit NewSpecial(gX1->value(), gY1->value(), gX2->value(), gY2->value());
00746 }
00747 
00748 void Cpalette::setActShade()
00749 {
00750        int b = PM1->value();
00751        switch (Mode)
00752        {
00753        case 1:
00754               emit NewPenShade(b);
00755               break;
00756        case 2:
00757               if (gradientQCombo->currentItem() == 0)
00758               {
00759                      Shade3 = b;
00760                      emit NewBrushShade(b);
00761               }
00762               else
00763               {
00764                      gradEdit->Preview->setActColor(setColor(Color, b), Color, b);
00765                      Shade = b;
00766                      emit gradientChanged();
00767               }
00768               break;
00769        }
00770 }
00771 
00772 
00773 void Cpalette::setActPattern(QString pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation)
00774 {
00775        disconnect(patternBox, SIGNAL(clicked(QIconViewItem*)), this, SLOT(selectPattern(QIconViewItem*)));
00776        disconnect(spinXoffset, SIGNAL(valueChanged(int)), this, SLOT(changePatternProps()));
00777        disconnect(spinYoffset, SIGNAL(valueChanged(int)), this, SLOT(changePatternProps()));
00778        disconnect(spinXscaling, SIGNAL(valueChanged(int)), this, SLOT(HChange()));
00779        disconnect(spinYscaling, SIGNAL(valueChanged(int)), this, SLOT(VChange()));
00780        disconnect(spinAngle, SIGNAL(valueChanged(int)), this, SLOT(changePatternProps()));
00781        QIconViewItem *it = patternBox->findItem(pattern);
00782        if (it)
00783               patternBox->setCurrentItem(it);
00784        spinXoffset->setValue(offsetX);
00785        spinYoffset->setValue(offsetY);
00786        spinXscaling->setValue(scaleX);
00787        spinYscaling->setValue(scaleY);
00788        spinAngle->setValue(rotation);
00789        if (scaleX == scaleY)
00790               keepScaleRatio->setOn(true);
00791        else
00792               keepScaleRatio->setOn(false);
00793        connect(patternBox, SIGNAL(clicked(QIconViewItem*)), this, SLOT(selectPattern(QIconViewItem*)));
00794        connect(spinXoffset, SIGNAL(valueChanged(int)), this, SLOT(changePatternProps()));
00795        connect(spinYoffset, SIGNAL(valueChanged(int)), this, SLOT(changePatternProps()));
00796        connect(spinXscaling, SIGNAL(valueChanged(int)), this, SLOT(HChange()));
00797        connect(spinYscaling, SIGNAL(valueChanged(int)), this, SLOT(VChange()));
00798        connect(spinAngle, SIGNAL(valueChanged(int)), this, SLOT(changePatternProps()));
00799 }
00800 
00801 void Cpalette::unitChange(double oldUnitRatio, double newUnitRatio, int unitIndex)
00802 {
00803        disconnect(gX1, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00804        disconnect(gX2, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00805        disconnect(gY1, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00806        disconnect(gY2, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00807        disconnect(spinXoffset, SIGNAL(valueChanged(int)), this, SLOT(changePatternProps()));
00808        disconnect(spinYoffset, SIGNAL(valueChanged(int)), this, SLOT(changePatternProps()));
00809        gX1->setNewUnit(oldUnitRatio, newUnitRatio, unitIndex);
00810        gY1->setNewUnit(oldUnitRatio, newUnitRatio, unitIndex);
00811        gX2->setNewUnit(oldUnitRatio, newUnitRatio, unitIndex);
00812        gY2->setNewUnit(oldUnitRatio, newUnitRatio, unitIndex);
00813        spinXoffset->setNewUnit(oldUnitRatio, newUnitRatio, unitIndex);
00814        spinYoffset->setNewUnit(oldUnitRatio, newUnitRatio, unitIndex);
00815        connect(gX1, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00816        connect(gX2, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00817        connect(gY1, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00818        connect(gY2, SIGNAL(valueChanged(int)), this, SLOT(changeSpecial()));
00819        connect(spinXoffset, SIGNAL(valueChanged(int)), this, SLOT(changePatternProps()));
00820        connect(spinYoffset, SIGNAL(valueChanged(int)), this, SLOT(changePatternProps()));
00821 }
00822 
00823 void Cpalette::languageChange()
00824 {
00825        QString ptSuffix=tr(" pt");
00826        gX1->setSuffix(ptSuffix);
00827        gY1->setSuffix(ptSuffix);
00828        gX2->setSuffix(ptSuffix);
00829        gY2->setSuffix(ptSuffix);
00830        QString pctSuffix=tr(" %");
00831        PM1->setSuffix(pctSuffix);
00832        TransSpin->setSuffix(pctSuffix);
00833        groupOffset->setTitle( tr( "Offsets" ) );
00834        textLabel1->setText( tr( "X:" ) );
00835        spinXoffset->setSuffix( ptSuffix );
00836        textLabel2->setText( tr( "Y:" ) );
00837        spinYoffset->setSuffix( ptSuffix );
00838        groupScale->setTitle( tr( "Scaling" ) );
00839        textLabel5->setText( tr( "X-Scale:" ) );
00840        spinXscaling->setSuffix( pctSuffix );
00841        textLabel6->setText( tr( "Y-Scale:" ) );
00842        spinYscaling->setSuffix( pctSuffix );
00843        groupRotation->setTitle( tr( "Rotation" ) );
00844        textLabel7->setText( tr( "Angle" ) );
00845 
00846        ShadeTxt->setText( tr( "Shade:" ) );
00847        TransTxt->setText( tr( "Opacity:" ) );
00848        GTextX1->setText( tr( "X1:"));
00849        GTextY1->setText( tr( "Y1:" ));
00850        GTextX2->setText( tr( "X2:" ));
00851        GTextY2->setText( tr( "Y2:" ));
00852        gradEditButton->setText( tr("Move Vector"));
00853 
00854        int oldGradient=gradientQCombo->currentItem();
00855        gradientQCombo->clear();
00856        gradientQCombo->insertItem( tr("Normal"));
00857        gradientQCombo->insertItem( tr("Horizontal Gradient"));
00858        gradientQCombo->insertItem( tr("Vertical Gradient"));
00859        gradientQCombo->insertItem( tr("Diagonal Gradient"));
00860        gradientQCombo->insertItem( tr("Cross Diagonal Gradient"));
00861        gradientQCombo->insertItem( tr("Radial Gradient"));
00862        gradientQCombo->insertItem( tr("Free linear Gradient"));
00863        gradientQCombo->insertItem( tr("Free radial Gradient"));
00864        gradientQCombo->insertItem( tr("Pattern"));
00865        gradientQCombo->setCurrentItem(oldGradient);
00866        TransGroup->setTitle( tr( "Transparency Settings" ));
00867        TransTxt2->setText( tr( "Blend Mode:" ) );
00868        blendMode->clear();
00869        blendMode->insertItem( tr("Normal"));
00870        blendMode->insertItem( tr("Darken"));
00871        blendMode->insertItem( tr("Lighten"));
00872        blendMode->insertItem( tr("Multiply"));
00873        blendMode->insertItem( tr("Screen"));
00874        blendMode->insertItem( tr("Overlay"));
00875        blendMode->insertItem( tr("Hard Light"));
00876        blendMode->insertItem( tr("Soft Light"));
00877        blendMode->insertItem( tr("Difference"));
00878        blendMode->insertItem( tr("Exclusion"));
00879        blendMode->insertItem( tr("Color Dodge"));
00880        blendMode->insertItem( tr("Color Burn"));
00881        blendMode->insertItem( tr("Hue"));
00882        blendMode->insertItem( tr("Saturation"));
00883        blendMode->insertItem( tr("Color"));
00884        blendMode->insertItem( tr("Luminosity"));
00885 
00886        QToolTip::add( Inhalt, tr( "Edit Line Color Properties" ) );
00887        QToolTip::add( Innen, tr( "Edit Fill Color Properties" ) );
00888        QToolTip::add( PM1, tr( "Saturation of color" ) );
00889        QToolTip::add( gradientQCombo, tr( "Normal or gradient fill method" ) );
00890        QToolTip::add( TransSpin, tr( "Set the transparency for the color selected" ) );
00891        QToolTip::add( gradEditButton, "<qt>" + tr( "Move the start of the gradient vector with the left mouse button pressed and move the end of the gradient vector with the right mouse button pressed" ) + "</qt>");
00892 }