Back to index

scribus-ng  1.3.4.dfsg+svn20071115
layers.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 **
00009 **
00010 ** Created: Son Jun 2 11:23:14 2002
00011 **      by:  Franz Schmid
00012 **
00013 **
00014 ****************************************************************************/
00015 #include <qpushbutton.h>
00016 #include <qtoolbutton.h>
00017 #include <qlayout.h>
00018 #include <qtooltip.h>
00019 #include <qpixmap.h>
00020 #include <qcheckbox.h>
00021 #include <qheader.h>
00022 #include <qvaluelist.h>
00023 #include <qtooltip.h>
00024 #include <qcheckbox.h>
00025 #include <qspinbox.h>
00026 #include <qlabel.h>
00027 #include <qcolordialog.h>
00028 
00029 #include "dynamictip.h"
00030 #include "scmessagebox.h"
00031 #include "sccombobox.h"
00032 #include "scribus.h"
00033 
00034 #include "layers.h"
00035 #include "layers.moc"
00036 #ifdef HAVE_CAIRO
00037 #include <cairo.h>
00038 #endif
00039 
00040 extern QPixmap loadIcon(QString nam);
00041 
00042 LayerLabel::LayerLabel(QTable *parent) : QTableItem (parent, QTableItem::OnTyping)
00043 {
00044 }
00045 
00046 void LayerLabel::paint(QPainter * p, const QColorGroup &cg, const QRect &cr, bool selected)
00047 {
00048        p->fillRect( 0, 0, cr.width(), cr.height(), selected ? cg.brush( QColorGroup::Highlight ) : cg.brush( QColorGroup::Base ) );
00049        int w = cr.width();
00050        int h = cr.height();
00051        int x = 0;
00052        if ( selected )
00053               p->setPen( cg.highlightedText() );
00054        else
00055               p->setPen( cg.text() );
00056        QString txt = text();
00057        QString ellipsis("...");
00058        QString elided;
00059        QFontMetrics fontMetrics(table()->font());
00060        int ellipsisWidth = fontMetrics.width(ellipsis) + 4;
00061        int length = txt.length();
00062        int i = 0;
00063        if (fontMetrics.width(txt) > w)
00064        {
00065               int offset = 0;
00066               while (i < length && fontMetrics.width(elided + txt.at(offset)) + ellipsisWidth < w)
00067               {
00068                      elided.append(txt.at(offset));
00069                      offset = ++i;
00070               }
00071               if (elided.isEmpty())
00072                      elided = txt.left(1);
00073               elided.append(ellipsis);
00074        }
00075        else
00076               elided = txt;
00077        p->drawText( x + 2, 0, w - x - 4, h, alignment(), elided );
00078 }
00079 
00080 LayerTable::LayerTable(QWidget* parent) : QTable(parent)
00081 {
00082 }
00083 
00084 void LayerTable::endEdit ( int row, int col, bool accept, bool replace )
00085 {
00086        QTable::EditMode ed = editMode();
00087        if ((row < 0) || (col < 0))
00088        {
00089               QTable::endEdit(row, col, accept, replace);
00090               return;
00091        }
00092        QString oldCont = text(row, col);
00093        QTable::endEdit(row, col, accept, replace);
00094        QString newCont = item(row, col)->text();
00095        bool realAccept = true;
00096        int b = numRows();
00097        for (int a = 0; a < b; ++a)
00098        {
00099               if (a != row)
00100               {
00101                      if (newCont == text(a, 6))
00102                             realAccept = false;
00103               }
00104        }
00105        if (newCont.isEmpty())
00106               realAccept = false;
00107        if (realAccept)
00108        {
00109               if (ed != QTable::NotEditing)
00110                      emit updtName(row);
00111        }
00112        else
00113        {
00114               setText(row, col, oldCont);
00115               emit updtName(row);
00116        }
00117 }
00118 
00119 LayerPalette::LayerPalette(QWidget* parent)
00120               : ScrPaletteBase( parent, "Layers", false, 0 ),
00121               m_Doc(0)
00122 {
00123        LayerPaletteLayout = new QVBoxLayout( this, 1, 2, "LayerPaletteLayout");
00124 
00125        layout1 = new QHBoxLayout( 0, 0, 2, "layout1");
00126        textLabel1 = new QLabel( this, "textLabel1" );
00127        layout1->addWidget( textLabel1 );
00128        blendMode = new ScComboBox( false, this, "blendMode" );
00129        layout1->addWidget( blendMode );
00130        textLabel2 = new QLabel( this, "textLabel2" );
00131        textLabel2->setText( tr( "Opacity:" ) );
00132        layout1->addWidget( textLabel2 );
00133        opacitySpinBox = new QSpinBox( this, "opacitySpinBox" );
00134        opacitySpinBox->setMinValue(0);
00135        opacitySpinBox->setMaxValue(100);
00136        opacitySpinBox->setLineStep(10);
00137        opacitySpinBox->setSuffix( tr(" %"));
00138        opacitySpinBox->setFocusPolicy(QWidget::ClickFocus);
00139        layout1->addWidget( opacitySpinBox );
00140        LayerPaletteLayout->addLayout( layout1 );
00141 #ifndef HAVE_CAIRO
00142        blendMode->hide();
00143        textLabel1->hide();
00144        textLabel2->hide();
00145        opacitySpinBox->hide();
00146 /*
00147 #else
00148 #if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 1, 8)
00149        blendMode->hide();
00150        textLabel1->hide();
00151 #endif
00152 #if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 1, 6)
00153        opacitySpinBox->hide();
00154        textLabel2->hide();
00155 #endif
00156 */
00157 #endif
00158 
00159        Table = new LayerTable( this );
00160        Table->setNumRows( 0 );
00161        Table->setNumCols( 7 );
00162        QHeader *header = Table->horizontalHeader();
00163        header->setLabel(0, "");
00164        header->setLabel(1, loadIcon("16/show-object.png"), "");
00165        header->setLabel(2, loadIcon("16/document-print.png"), "");
00166        header->setLabel(3, loadIcon("16/lock.png"), "");
00167        header->setLabel(4, loadIcon("16/layer-flow-around.png"), "");
00168        header->setLabel(5, loadIcon("layer-outline.png"), "");
00169        Table->setColumnReadOnly(0, true);
00170        Table->setColumnReadOnly(1, true);
00171        Table->setColumnReadOnly(2, true);
00172        Table->setColumnReadOnly(3, true);
00173        Table->setColumnReadOnly(4, true);
00174        Table->setColumnReadOnly(5, true);
00175        Table->setColumnWidth(0, 24);
00176        Table->setColumnWidth(1, 24);
00177        Table->setColumnWidth(2, 24);
00178        Table->setColumnWidth(3, 24);
00179        Table->setColumnWidth(4, 24);
00180        Table->setColumnWidth(5, 24);
00181        header->setResizeEnabled(false, 0);
00182        header->setResizeEnabled(false, 1);
00183        header->setResizeEnabled(false, 2);
00184        header->setResizeEnabled(false, 3);
00185        header->setResizeEnabled(false, 4);
00186        header->setResizeEnabled(false, 5);
00187        header->setResizeEnabled(true, 6);
00188        dynTip = new DynamicTip(header);
00189        Table->setRowMovingEnabled(false);
00190        Table->setSorting(false);
00191        Table->setSelectionMode( QTable::SingleRow );
00192        Table->setFocusStyle( QTable::FollowStyle );
00193        Header = Table->verticalHeader();
00194        Header->setMovingEnabled(false);
00195        Header->setResizeEnabled(false);
00196        Table->setLeftMargin(0);
00197        Header->hide();
00198        LayerPaletteLayout->addWidget( Table );
00199 
00200        Layout1 = new QHBoxLayout( 0, 0, 0, "Layout1");
00201        QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00202        Layout1->addItem( spacer );
00203 
00204        newLayerButton = new QPushButton( this, "newLayerButton" );
00205        newLayerButton->setMinimumSize( QSize( 50, 24 ) );
00206        newLayerButton->setMaximumSize( QSize( 50, 24 ) );
00207        newLayerButton->setText( "" );
00208        newLayerButton->setPixmap(loadIcon("16/list-add.png"));
00209        Layout1->addWidget( newLayerButton );
00210 
00211        deleteLayerButton = new QPushButton( this, "deleteLayerButton" );
00212        deleteLayerButton->setMinimumSize( QSize( 50, 24 ) );
00213        deleteLayerButton->setMaximumSize( QSize( 50, 24 ) );
00214        deleteLayerButton->setText( "" );
00215        deleteLayerButton->setPixmap(loadIcon("16/list-remove.png"));
00216        Layout1->addWidget( deleteLayerButton );
00217        
00218        duplicateLayerButton = new QPushButton( this, "duplicateLayerButton" );
00219        duplicateLayerButton->setMinimumSize( QSize( 50, 24 ) );
00220        duplicateLayerButton->setMaximumSize( QSize( 50, 24 ) );
00221        duplicateLayerButton->setText( "" );
00222        duplicateLayerButton->setPixmap(loadIcon("16/edit-copy.png"));
00223        Layout1->addWidget( duplicateLayerButton );
00224 
00225        raiseLayerButton = new QPushButton( this, "raiseLayerButton" );
00226        raiseLayerButton->setMinimumSize( QSize( 50, 24 ) );
00227        raiseLayerButton->setMaximumSize( QSize( 50, 24 ) );
00228        raiseLayerButton->setText( "" );
00229 //     raiseLayerButton->setPixmap(loadIcon("Raiselayer.png"));
00230        raiseLayerButton->setPixmap(loadIcon("16/go-up.png"));
00231        Layout1->addWidget( raiseLayerButton );
00232 
00233        lowerLayerButton = new QPushButton( this, "lowerLayerButton" );
00234        lowerLayerButton->setMinimumSize( QSize( 50, 24 ) );
00235        lowerLayerButton->setMaximumSize( QSize( 50, 24 ) );
00236        lowerLayerButton->setText( "" );
00237 //     lowerLayerButton->setPixmap(loadIcon("Lowerlayer.png"));
00238        lowerLayerButton->setPixmap(loadIcon("16/go-down.png"));
00239        Layout1->addWidget( lowerLayerButton );
00240 
00241        LayerPaletteLayout->addLayout( Layout1 );
00242        ClearInhalt();
00243        languageChange();
00244 
00245        connect(newLayerButton, SIGNAL(clicked()), this, SLOT(addLayer()));
00246        connect(duplicateLayerButton, SIGNAL(clicked()), this, SLOT(dupLayer()));
00247        connect(deleteLayerButton, SIGNAL(clicked()), this, SLOT(removeLayer()));
00248        connect(raiseLayerButton, SIGNAL(clicked()), this, SLOT(upLayer()));
00249        connect(lowerLayerButton, SIGNAL(clicked()), this, SLOT(downLayer()));
00250        connect(Table, SIGNAL(updtName(int)), this, SLOT(updateName(int)));
00251        connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeOpacity()));
00252        connect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
00253 
00254 }
00255 
00256 void LayerPalette::updateName(int r)
00257 {
00258        changeName(r, 6);
00259        m_Doc->scMW()->changeLayer(m_Doc->activeLayer());
00260 }
00261 
00262 void LayerPalette::ClearInhalt()
00263 {
00264        disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
00265        disconnect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeOpacity()));
00266        disconnect(Table, SIGNAL(currentChanged(int, int)), this, SLOT(setActiveLayer(int)));
00267        int b = Table->numRows();
00268        for (int a = 0; a < b; ++a)
00269               Table->removeRow(0);
00270        flagsPrintable.clear();
00271        flagsVisible.clear();
00272        flagsFlow.clear();
00273        flagsOutline.clear();
00274        flagsMarker.clear();
00275        newLayerButton->setEnabled(false);
00276        deleteLayerButton->setEnabled(false);
00277        raiseLayerButton->setEnabled(false);
00278        lowerLayerButton->setEnabled(false);
00279 }
00280 
00281 void LayerPalette::setDoc(ScribusDoc* doc)
00282 {
00283        m_Doc=doc;
00284        disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
00285        disconnect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeOpacity()));
00286        disconnect(Table, SIGNAL(currentChanged(int, int)), this, SLOT(setActiveLayer(int)));
00287        if (!m_Doc)
00288        {
00289               layers=0;
00290               newLayerButton->setEnabled(false);
00291               duplicateLayerButton->setEnabled(false);
00292               deleteLayerButton->setEnabled(false);
00293               raiseLayerButton->setEnabled(false);
00294               lowerLayerButton->setEnabled(false);
00295               markActiveLayer(0);
00296        }
00297        layers=&m_Doc->Layers;
00298        rebuildList();
00299 
00300        markActiveLayer(m_Doc->activeLayer());
00301        newLayerButton->setEnabled(true);
00302        duplicateLayerButton->setEnabled(true);
00303 
00304        connect(Table, SIGNAL(currentChanged(int, int)), this, SLOT(setActiveLayer(int)));
00305        connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeOpacity()));
00306        connect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
00307 }
00308 
00309 void LayerPalette::rebuildList()
00310 {
00311        disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
00312        disconnect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeOpacity()));
00313        disconnect(Table, SIGNAL(currentChanged(int, int)), this, SLOT(setActiveLayer(int)));
00314        flagsPrintable.clear();
00315        flagsVisible.clear();
00316        flagsFlow.clear();
00317        flagsOutline.clear();
00318        flagsMarker.clear();
00319        QString tmp;
00320        QValueList<Layer>::iterator it;
00321        int layerCount=m_Doc->layerCount();
00322        Table->setNumRows(layerCount);
00323        for (it = layers->begin(); it != layers->end(); ++it)
00324        {
00325               int layerNumber=(*it).LNr;
00326               //TODO once "layers" is not set anymore, need to get layer number differently
00327               int layerLevel=m_Doc->layerLevelFromNumber(layerNumber);
00328               int row=layerCount-layerLevel-1;
00329               QToolButton *pb = new QToolButton(this, tmp.setNum(layerLevel));
00330               pb->setAutoRaise(true);
00331               pb->setText( "" );
00332               QPixmap pm(20,15);
00333               pm.fill(m_Doc->layerMarker(layerNumber));
00334               QIconSet ic;
00335               ic.setPixmap(pm, QIconSet::Small, QIconSet::Normal);
00336               ic.setPixmap(pm, QIconSet::Small, QIconSet::Active);
00337               pb->setIconSet(ic);
00338               Table->setCellWidget(row, 0, pb);
00339               flagsMarker.append(pb);
00340               connect(pb, SIGNAL(clicked()), this, SLOT(markLayer()));
00341               QCheckBox *cp2 = new QCheckBox(this, tmp.setNum(layerLevel));
00342               cp2->setChecked(m_Doc->layerVisible(layerNumber));
00343               flagsVisible.append(cp2);
00344               connect(cp2, SIGNAL(clicked()), this, SLOT(visibleLayer()));
00345               Table->setCellWidget(row, 1, cp2);
00346               QCheckBox *cp = new QCheckBox(this, tmp.setNum(layerLevel));
00347               cp->setChecked(m_Doc->layerPrintable(layerNumber));
00348               Table->setCellWidget(row, 2, cp);
00349               flagsPrintable.append(cp);
00350               connect(cp, SIGNAL(clicked()), this, SLOT(printLayer()));
00351               QCheckBox *cp3 = new QCheckBox(this, tmp.setNum(layerLevel));
00352               cp3->setChecked(m_Doc->layerLocked(layerNumber));
00353               flagsLocked.append(cp3);
00354               connect(cp3, SIGNAL(clicked()), this, SLOT(lockLayer()));
00355               Table->setCellWidget(row, 3, cp3);
00356               QCheckBox *cp4 = new QCheckBox(this, tmp.setNum(layerLevel));
00357               cp4->setChecked(m_Doc->layerFlow(layerNumber));
00358               flagsFlow.append(cp4);
00359               connect(cp4, SIGNAL(clicked()), this, SLOT(flowToggleLayer()));
00360               Table->setCellWidget(row, 4, cp4);
00361               QCheckBox *cp5 = new QCheckBox(this, tmp.setNum(layerLevel));
00362               cp5->setChecked(m_Doc->layerOutline(layerNumber));
00363               flagsOutline.append(cp5);
00364               connect(cp5, SIGNAL(clicked()), this, SLOT(outlineToggleLayer()));
00365               Table->setCellWidget(row, 5, cp5);
00366               LayerLabel *lbl = new LayerLabel(Table);
00367               lbl->setText(m_Doc->layerName(layerNumber));
00368               Table->setItem(row, 6, lbl);
00369 //            Table->setText(row, 6, m_Doc->layerName(layerNumber));
00370               Header->setLabel(row, tmp.setNum(layerLevel));
00371        }
00372        Table->setColumnStretchable(6, true);
00373 //     Table->adjustColumn(6);
00374        connect(Table, SIGNAL(currentChanged(int, int)), this, SLOT(setActiveLayer(int)));
00375        connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeOpacity()));
00376        connect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
00377 }
00378 
00379 void LayerPalette::addLayer()
00380 {
00381        m_Doc->addLayer(QString::null, true);
00382        rebuildList();
00383        markActiveLayer();
00384        m_Doc->scMW()->changeLayer(m_Doc->activeLayer());
00385        m_Doc->changed();
00386 }
00387 
00388 void LayerPalette::dupLayer()
00389 {
00390        int current = m_Doc->activeLayer();
00391        m_Doc->addLayer(QString::null, true);
00392        rebuildList();
00393        markActiveLayer();
00394        m_Doc->copyLayer(current, m_Doc->activeLayer());
00395        m_Doc->scMW()->changeLayer(m_Doc->activeLayer());
00396        m_Doc->changed();
00397 }
00398 
00399 void LayerPalette::removeLayer()
00400 {
00401        int layerCount=m_Doc->layerCount();
00402        if (layerCount < 2)
00403               return;
00404        int level = layerCount-1-Table->currentRow();
00405        int layerNumber=m_Doc->layerNumberFromLevel(level);
00406        bool delToo = false;
00407        if (m_Doc->layerContainsItems(layerNumber))
00408        {
00409               int scmReturn=ScMessageBox::warning(this, tr("Delete Layer"),
00410                                                                tr("Do you want to delete all objects on this layer too?"),
00411                                                                QMessageBox::Yes,
00412                                                                QMessageBox::No,
00413                                                                QMessageBox::Cancel | QMessageBox::Default | QMessageBox::Escape);
00414               if (scmReturn == QMessageBox::Cancel)
00415                      return;
00416               delToo = (scmReturn != QMessageBox::No);
00417        }
00418 
00419        if (!m_Doc->deleteLayer(layerNumber, delToo))
00420               return;
00421 
00422        rebuildList();
00423        markActiveLayer();
00424        m_Doc->scMW()->changeLayer(m_Doc->activeLayer());
00425        m_Doc->changed();
00426 }
00427 
00428 void LayerPalette::upLayer()
00429 {
00430        int layerCount=m_Doc->layerCount();
00431        if ((layerCount < 2) || (Table->currentRow() == 0))
00432               return;
00433        int layerLevel = layerCount-1-Table->currentRow();
00434        m_Doc->raiseLayerByLevel(layerLevel);
00435        rebuildList();
00436        markActiveLayer();
00437        m_Doc->scMW()->changeLayer(m_Doc->activeLayer());
00438        emit LayerChanged();
00439        m_Doc->changed();
00440 }
00441 
00442 void LayerPalette::downLayer()
00443 {
00444        int layerCount=m_Doc->layerCount();
00445        if ((layerCount < 2) || (Table->currentRow() == static_cast<int>(layerCount) - 1))
00446               return;
00447        int layerLevel = layerCount-1-Table->currentRow();
00448        m_Doc->lowerLayerByLevel(layerLevel);
00449        rebuildList();
00450        m_Doc->scMW()->changeLayer(m_Doc->activeLayer());
00451        emit LayerChanged();
00452        markActiveLayer();
00453        m_Doc->changed();
00454 }
00455 
00456 void LayerPalette::changeName(int row, int col)
00457 {
00458        if (col == 6)
00459        {
00460               int layerLevel = m_Doc->layerCount()-1-row;
00461               int layerNumber=m_Doc->layerNumberFromLevel(layerLevel);
00462               if (layerNumber!=-1)
00463                      m_Doc->changeLayerName(layerNumber, Table->item(row, col)->text());
00464        }
00465 }
00466 
00467 void LayerPalette::visibleLayer()
00468 {
00469        int level = QString(sender()->name()).toInt();
00470        int layerNumber=m_Doc->layerNumberFromLevel(level);
00471        if (layerNumber==-1)
00472               return;
00473        const QObject* senderBox=sender();
00474        if (senderBox->isA("QCheckBox"))
00475        {
00476               m_Doc->setLayerVisible(layerNumber,((QCheckBox*)(senderBox))->isChecked());
00477               emit LayerChanged();
00478        }
00479 }
00480 
00481 void LayerPalette::printLayer()
00482 {
00483        int level = QString(sender()->name()).toInt();
00484        int layerNumber=m_Doc->layerNumberFromLevel(level);
00485        if (layerNumber==-1)
00486               return;
00487        const QObject* senderBox=sender();
00488        if (senderBox->isA("QCheckBox"))
00489               m_Doc->setLayerPrintable(layerNumber,((QCheckBox*)(senderBox))->isChecked());
00490 }
00491 
00492 void LayerPalette::lockLayer()
00493 {
00494        int level = QString(sender()->name()).toInt();
00495        int layerNumber=m_Doc->layerNumberFromLevel(level);
00496        if (layerNumber==-1)
00497               return;
00498        const QObject* senderBox=sender();
00499        if (senderBox->isA("QCheckBox"))
00500        {
00501               m_Doc->setLayerLocked(layerNumber,((QCheckBox*)(senderBox))->isChecked());
00502               deleteLayerButton->setEnabled(!((QCheckBox*)(senderBox))->isChecked());
00503        }
00504        m_Doc->scMW()->changeLayer(m_Doc->activeLayer());
00505 }
00506 
00507 void LayerPalette::flowToggleLayer()
00508 {
00509        int level = QString(sender()->name()).toInt();
00510        int layerNumber=m_Doc->layerNumberFromLevel(level);
00511        if (layerNumber==-1)
00512               return;
00513        const QObject* senderBox=sender();
00514        if (senderBox->isA("QCheckBox"))
00515               m_Doc->setLayerFlow(layerNumber,((QCheckBox*)(senderBox))->isChecked());
00516 }
00517 
00518 void LayerPalette::outlineToggleLayer()
00519 {
00520        int level = QString(sender()->name()).toInt();
00521        int layerNumber=m_Doc->layerNumberFromLevel(level);
00522        if (layerNumber==-1)
00523               return;
00524        const QObject* senderBox=sender();
00525        if (senderBox->isA("QCheckBox"))
00526        {
00527               m_Doc->setLayerOutline(layerNumber,((QCheckBox*)(senderBox))->isChecked());
00528               emit LayerChanged();
00529        }
00530 }
00531 
00532 void LayerPalette::markLayer()
00533 {
00534        int level = QString(sender()->name()).toInt();
00535        int layerNumber=m_Doc->layerNumberFromLevel(level);
00536        if (layerNumber==-1)
00537               return;
00538        const QObject* senderBox=sender();
00539        if (senderBox->isA("QToolButton"))
00540        {
00541               QColor neu = QColor();
00542               neu = QColorDialog::getColor(m_Doc->layerMarker(layerNumber), this);
00543               QPixmap pm(20,15);
00544               pm.fill(neu);
00545               QIconSet ic;
00546               ic.setPixmap(pm, QIconSet::Small, QIconSet::Normal);
00547               ic.setPixmap(pm, QIconSet::Small, QIconSet::Active);
00548               ((QToolButton*)(senderBox))->setIconSet(ic);
00549               m_Doc->setLayerMarker(layerNumber,neu);
00550               emit LayerChanged();
00551        }
00552 }
00553 
00554 void LayerPalette::changeOpacity()
00555 {
00556        m_Doc->setLayerTransparency(m_Doc->activeLayer(), opacitySpinBox->value() / 100.0);
00557        emit LayerChanged();
00558 }
00559 
00560 void LayerPalette::changeBlendMode(int blend)
00561 {
00562        m_Doc->setLayerBlendMode(m_Doc->activeLayer(), blend);
00563        emit LayerChanged();
00564 }
00565 
00566 void LayerPalette::markActiveLayer(int layerNumber)
00567 {
00568        disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
00569        disconnect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeOpacity()));
00570        disconnect(Table, SIGNAL(currentChanged(int, int)), this, SLOT(setActiveLayer(int)));
00571        int layerToMark=layerNumber;
00572        if (layerNumber==-1)
00573               layerToMark=m_Doc->activeLayer();
00574        Table->setCurrentCell(m_Doc->layerCount()-1-m_Doc->layerLevelFromNumber(layerToMark), 6);
00575        opacitySpinBox->setValue(qRound(m_Doc->layerTransparency(layerToMark) * 100));
00576        blendMode->setCurrentItem(m_Doc->layerBlendMode(layerToMark));
00577        deleteLayerButton->setEnabled(m_Doc->layerCount()>1 && !m_Doc->layerLocked( m_Doc->activeLayer() ));
00578               
00579        if (layers->count()>1)
00580        {
00581               raiseLayerButton->setEnabled(Table->currentRow()!=0);
00582               lowerLayerButton->setEnabled(Table->currentRow()!=Table->numRows()-1);
00583        }
00584        else
00585        {
00586               raiseLayerButton->setEnabled(false);
00587               lowerLayerButton->setEnabled(false);
00588        }
00589        connect(Table, SIGNAL(currentChanged(int, int)), this, SLOT(setActiveLayer(int)));
00590        connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeOpacity()));
00591        connect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
00592 }
00593 
00594 void LayerPalette::setActiveLayer(int row)
00595 {
00596        disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
00597        disconnect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeOpacity()));
00598        int layerNumber=m_Doc->layerNumberFromLevel(m_Doc->layerCount()-1-row);
00599        bool found=m_Doc->setActiveLayer(layerNumber);
00600        if (found)
00601        {
00602               m_Doc->scMW()->changeLayer(m_Doc->activeLayer());
00603               opacitySpinBox->setValue(qRound(m_Doc->layerTransparency(m_Doc->activeLayer()) * 100));
00604               blendMode->setCurrentItem(m_Doc->layerBlendMode(m_Doc->activeLayer()));
00605               deleteLayerButton->setEnabled(m_Doc->layerCount()>1 && !m_Doc->layerLocked( m_Doc->activeLayer() ));
00606               if (layers->count()>1)
00607               {
00608                      raiseLayerButton->setEnabled(Table->currentRow()!=0);
00609                      lowerLayerButton->setEnabled(Table->currentRow()!=Table->numRows()-1);
00610               }
00611               else
00612               {
00613                      raiseLayerButton->setEnabled(false);
00614                      lowerLayerButton->setEnabled(false);
00615               }
00616        }
00617        connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeOpacity()));
00618        connect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
00619 }
00620 
00621 void LayerPalette::languageChange()
00622 {
00623        setCaption( tr( "Layers" ) );
00624        textLabel1->setText( tr( "Blend Mode:" ) );
00625        blendMode->clear();
00626        blendMode->insertItem( tr("Normal"));
00627        blendMode->insertItem( tr("Darken"));
00628        blendMode->insertItem( tr("Lighten"));
00629        blendMode->insertItem( tr("Multiply"));
00630        blendMode->insertItem( tr("Screen"));
00631        blendMode->insertItem( tr("Overlay"));
00632        blendMode->insertItem( tr("Hard Light"));
00633        blendMode->insertItem( tr("Soft Light"));
00634        blendMode->insertItem( tr("Difference"));
00635        blendMode->insertItem( tr("Exclusion"));
00636        blendMode->insertItem( tr("Color Dodge"));
00637        blendMode->insertItem( tr("Color Burn"));
00638        blendMode->insertItem( tr("Hue"));
00639        blendMode->insertItem( tr("Saturation"));
00640        blendMode->insertItem( tr("Color"));
00641        blendMode->insertItem( tr("Luminosity"));
00642        textLabel2->setText( tr( "Opacity:" ) );
00643        opacitySpinBox->setSuffix( tr(" %"));
00644        Table->horizontalHeader()->setLabel(6, tr("Name"));
00645        QToolTip::remove( newLayerButton );
00646        QToolTip::remove( duplicateLayerButton );
00647        QToolTip::remove( deleteLayerButton );
00648        QToolTip::remove( raiseLayerButton );
00649        QToolTip::remove( lowerLayerButton );
00650        QToolTip::add( newLayerButton, tr( "Add a new layer" ) );
00651        QToolTip::add( duplicateLayerButton, tr( "Duplicates the current layer" ) );
00652        QToolTip::add( deleteLayerButton, tr( "Delete layer" ) );
00653        QToolTip::add( raiseLayerButton, tr( "Raise layer" ) );
00654        QToolTip::add( lowerLayerButton, tr( "Lower layer" ) );
00655        dynTip->clearHeaderTips();
00656        dynTip->addHeaderTip("<qt>" + tr("Color of the Layer Indicator - Each layer has a color assigned to display on the canvas when layer indicators are enabled. You can double click to edit the color. ") + "</qt>");
00657        dynTip->addHeaderTip( "<qt>" + tr("Make Layer Visible - Uncheck to hide the layer from the display ") + "</qt>" );
00658        dynTip->addHeaderTip( "<qt>" + tr("Print Layer - Uncheck to disable printing. ") + "</qt>" );
00659        dynTip->addHeaderTip( "<qt>" + tr("Lock or Unlock Layer - Unchecked is unlocked ") + "</qt>" );
00660        dynTip->addHeaderTip( "<qt>" + tr("Text flows around objects in lower Layers - Enabling this forces text frames to flow around other objects, even in layers below") + "</qt>" );
00661        dynTip->addHeaderTip( "<qt>" + tr("Outline Mode - Toggles the 'wireframe' display of objects to speed the display of very complex objects.") + "</qt>" ) ;
00662        dynTip->addHeaderTip( "<qt>" + tr("Name of the Layer - Double clicking on the name of a layer enabled editing") + "</qt>" );
00663 }
00664