Back to index

scribus-ng  1.3.4.dfsg+svn20071115
smtextstylewidgets.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 #include "smtextstylewidgets.h"
00009 #include "smtextstylewidgets.moc"
00010 #include "units.h"
00011 #include "util.h"
00012 #include "commonstrings.h"
00013 #include "smwidgets.h"
00014 
00015 #include <qgroupbox.h>
00016 #include <qlayout.h>
00017 #include <qtoolbutton.h>
00018 #include <qlabel.h>
00019 #include <qpopupmenu.h>
00020 #include <qcombobox.h>
00021 #include <qspinbox.h>
00022 #include <qframe.h>
00023 #include <qpixmap.h>
00024 #include <qtabwidget.h>
00025 #include <qmap.h>
00026 #include <cmath>
00027 
00028 static bool isEqual(double a, double b)
00029 {
00030        Q_ASSERT(a >  -21473 && b > -21473 && a < 21474 && b < 21474);
00031        long al = static_cast<long>(10000 * a);
00032        long bl = static_cast<long>(10000 * b);
00033     return al == bl;
00034 }
00035 
00036 SMPStyleWidget::SMPStyleWidget()
00037 {
00038        setupDistances();
00039        setupDropCaps();
00040        setupTabs();
00041        setupCharStyle();
00042 }
00043 
00044 void SMPStyleWidget::setupDistances()
00045 {
00046        distancesBox->setColumnLayout(0, Qt::Vertical );
00047        distancesBox->layout()->setSpacing( 0 );
00048        distancesBox->layout()->setMargin( 0 );
00049        distancesBoxLayout = new QGridLayout( distancesBox->layout() );
00050        distancesBoxLayout->setAlignment( Qt::AlignTop );
00051        distancesBoxLayout->setSpacing( 5 );
00052        distancesBoxLayout->setMargin( 10 );
00053 
00054        pixmapLabel0 = new QLabel(distancesBox, "pixmapLabel0");
00055        pixmapLabel0->setMinimumSize(QSize(22,22));
00056        pixmapLabel0->setMaximumSize(QSize(22,22));
00057        pixmapLabel0->setPixmap(loadIcon("linespacing2.png"));
00058        distancesBoxLayout->addWidget(pixmapLabel0, 0, 0);
00059        
00060        lineSpacingMode_ = new SMScComboBox(distancesBox, "linespacingCombo");
00061        lineSpacingMode_->insertItem( tr("Fixed Linespacing"));
00062        lineSpacingMode_->insertItem( tr("Automatic Linespacing"));
00063        lineSpacingMode_->insertItem( tr("Align to Baseline Grid"));
00064        distancesBoxLayout->addMultiCellWidget(lineSpacingMode_, 0, 0, 1, 2);
00065        connect(lineSpacingMode_, SIGNAL(highlighted(int)), this, SLOT(slotLineSpacingModeChanged(int)));
00066 
00067        lineSpacing_ = new SMMSpinBox(1, 300, distancesBox, 1 );
00068        lineSpacing_->setSuffix(unitGetSuffixFromIndex(0));
00069        distancesBoxLayout->addWidget(lineSpacing_, 0, 3);
00070 
00071        pixmapLabel3 = new QLabel( "", distancesBox, "TextLabel1_2_2" );
00072        pixmapLabel3->setPixmap( loadIcon("above.png") );
00073        distancesBoxLayout->addWidget( pixmapLabel3, 1, 0 );
00074 
00075        spaceAbove_ = new SMMSpinBox( 0, 300, distancesBox, 1 );
00076        spaceAbove_->setSuffix(unitGetSuffixFromIndex(0));
00077        distancesBoxLayout->addWidget( spaceAbove_, 1, 1 );
00078 
00079        pixmapLabel4 = new QLabel( "", distancesBox, "TextLabel1_2_3" );
00080        pixmapLabel4->setPixmap( loadIcon("below.png") );
00081        distancesBoxLayout->addWidget( pixmapLabel4, 2, 0 );
00082 
00083        spaceBelow_ = new SMMSpinBox( 0, 300, distancesBox, 1 );
00084        spaceBelow_->setSuffix(unitGetSuffixFromIndex(0));
00085        distancesBoxLayout->addWidget( spaceBelow_, 2, 1 );
00086 
00087        alignement_ = new SMAlignSelect(distancesBox);
00088        distancesBoxLayout->addMultiCellWidget(alignement_, 3,3,0,3);
00089 }
00090 
00091 void SMPStyleWidget::slotLineSpacingModeChanged(int i)
00092 {
00093        lineSpacing_->setEnabled(i == 0);
00094 }
00095 
00096 void SMPStyleWidget::languageChange()
00097 {
00098 /***********************************/
00099 /*      Begin Tooltips             */
00100 /***********************************/
00101 // These are for the paragraph style
00102 
00103        QToolTip::add(parentCombo,      tr("Parent Style"));
00104        QToolTip::add(lineSpacingMode_, tr("Line Spacing Mode"));
00105        QToolTip::add(lineSpacing_,     tr("Line Spacing"));
00106        QToolTip::add(spaceAbove_,      tr("Space Above"));
00107        QToolTip::add(spaceBelow_,      tr("Space Below"));
00108        //CB Unneeded, gets in the way of single widget tooltips
00109        //QToolTip::add(dropCapsBox,      tr("Enable or disable drop cap"));
00110        QToolTip::add(dropCapLines_,    tr("Drop Cap Lines"));
00111        QToolTip::add(dropCapOffset_,   tr("Drop Cap Offset"));
00112        QToolTip::add(alignement_,      tr("Alignment"));
00113        QToolTip::add(tabList_->first_, tr("First Line Indent"));
00114        QToolTip::add(tabList_->left_,  tr("Left Indent"));
00115        QToolTip::add(tabList_->right_, tr("Right Indent"));
00116        //CB Unneeded, gets in the way of single widget tooltips 
00117        //QToolTip::add(tabList_,         tr("Tabulators"));
00118 
00119 /***********************************/
00120 /*      End Tooltips               */
00121 /***********************************/
00122 
00123        lineSpacingMode_->clear();
00124        lineSpacingMode_->insertItem( tr("Fixed Linespacing"));
00125        lineSpacingMode_->insertItem( tr("Automatic Linespacing"));
00126        lineSpacingMode_->insertItem( tr("Align to Baseline Grid"));
00127        lineSpacing_->setSuffix(unitGetSuffixFromIndex(0));
00128        spaceAbove_->setSuffix(unitGetSuffixFromIndex(0));
00129        spaceBelow_->setSuffix(unitGetSuffixFromIndex(0));
00130        parentLabel->setText( tr("Based On:"));
00131        distancesBox->setTitle( tr("Distances and Alignment"));
00132        dropCapsBox->setTitle( tr("Drop Caps"));
00133        tabsBox->setTitle( tr("Tabulators and Indentation"));
00134        tabWidget->setTabLabel(tabWidget->page(0), tr("Properties"));
00135        tabWidget->setTabLabel(tabWidget->page(1), tr("Character Style"));
00136 }
00137 
00138 void SMPStyleWidget::unitChange(double oldRatio, double newRatio, int unitIndex)
00139 {
00140     spaceAbove_->setNewUnit(oldRatio, newRatio, unitIndex);
00141        spaceBelow_->setNewUnit(oldRatio, newRatio, unitIndex);
00142        dropCapOffset_->setNewUnit(oldRatio, newRatio, unitIndex);
00143        tabList_->left_->setNewUnit(oldRatio, newRatio, unitIndex);
00144        tabList_->right_->setNewUnit(oldRatio, newRatio, unitIndex);
00145        tabList_->first_->setNewUnit(oldRatio, newRatio, unitIndex);
00146 }
00147 
00148 void SMPStyleWidget::setupDropCaps()
00149 {
00150        dropCapsBox->setCheckable( true );
00151        dropCapsBox->setColumnLayout(0, Qt::Vertical );
00152        dropCapsBox->layout()->setSpacing( 5 );
00153        dropCapsBox->layout()->setMargin( 10 );
00154 
00155        dropCapsBoxLayout = new QGridLayout(dropCapsBox->layout());
00156        dropCapsBoxLayout->setAlignment(Qt::AlignTop);
00157 
00158        dropCapLines_ = new SMSpinBox(dropCapsBox, "DropLines");
00159        dropCapLines_->setMinValue(2);
00160        dropCapLines_->setMaxValue(20);
00161        capLabel1 = new QLabel(dropCapLines_, tr("&Lines:"), dropCapsBox, "CapLabel");
00162        dropCapsBoxLayout->addWidget(capLabel1, 0, 0);
00163        dropCapsBoxLayout->addWidget(dropCapLines_, 0, 1);
00164 
00165        dropCapOffset_ = new SMMSpinBox(-3000, 3000, dropCapsBox, 1);
00166        dropCapOffset_->setSuffix(unitGetSuffixFromIndex(0));
00167        capLabel2 = new QLabel(dropCapLines_, tr("Distance from Text:"), dropCapsBox, "CapLabel2");
00168        dropCapsBoxLayout->addWidget(capLabel2, 1, 0);
00169        dropCapsBoxLayout->addWidget(dropCapOffset_, 1, 1);
00170 }
00171 
00172 void SMPStyleWidget::setupTabs()
00173 {
00174        tabsBox->setColumnLayout(0, Qt::Vertical );
00175        tabsBox->layout()->setSpacing( 0 );
00176        tabsBox->layout()->setMargin( 0 );
00177 
00178        tabsBoxLayout = new QVBoxLayout(tabsBox->layout());
00179        tabsBoxLayout->setAlignment( Qt::AlignTop );
00180        tabsBoxLayout->setSpacing( 5 );
00181        tabsBoxLayout->setMargin( 10 );
00182 
00183        tabList_ = new SMTabruler(tabsBox);
00184        tabsBoxLayout->addWidget( tabList_ );
00185 }
00186 
00187 void SMPStyleWidget::setupCharStyle()
00188 {
00189        QHBoxLayout *la = new QHBoxLayout(characterBox, 0, 0, "la");
00190        cpage = new SMCStylePage(characterBox);
00191        la->addWidget(cpage);
00192        characterBox->setEnabled(true);
00193 }
00194 
00195 void SMPStyleWidget::show(ParagraphStyle *pstyle, QValueList<ParagraphStyle> &pstyles, QValueList<CharStyle> &cstyles, int unitIndex, const QString &defLang)
00196 {
00197        double unitRatio = unitGetRatioFromIndex(unitIndex);
00198        parentCombo->setEnabled(true);
00199        const ParagraphStyle *parent = dynamic_cast<const ParagraphStyle*>(pstyle->parentStyle());
00200        hasParent_ = pstyle->hasParent() && parent != NULL && parent->hasName() && pstyle->parent() != "";
00201 
00202        lineSpacingMode_->clear();
00203        lineSpacingMode_->insertItem( tr("Fixed Linespacing"));
00204        lineSpacingMode_->insertItem( tr("Automatic Linespacing"));
00205        lineSpacingMode_->insertItem( tr("Align to Baseline Grid"));
00206 
00207        if (hasParent_)
00208        {
00209               lineSpacingMode_->setCurrentItem(pstyle->lineSpacingMode(), pstyle->isInhLineSpacingMode());
00210               lineSpacingMode_->setParentItem(parent->lineSpacingMode());
00211 
00212               lineSpacing_->setValue(pstyle->lineSpacing(), pstyle->isInhLineSpacing());
00213               lineSpacing_->setParentValue(parent->lineSpacing());
00214 
00215               spaceAbove_->setValue(pstyle->gapBefore() * unitRatio, pstyle->isInhGapBefore());
00216               spaceAbove_->setParentValue(parent->gapBefore() * unitRatio);
00217 
00218               spaceBelow_->setValue(pstyle->gapAfter() * unitRatio, pstyle->isInhGapAfter());
00219               spaceBelow_->setParentValue(parent->gapAfter() * unitRatio);
00220 
00221               dropCapsBox->setChecked(pstyle->hasDropCap());;
00222               parentDropCap_ = parent->hasDropCap();
00223               if (pstyle->isInhHasDropCap())
00224                      parentDropCapButton->hide();
00225               else
00226                      parentDropCapButton->show();
00227 
00228               connect(parentDropCapButton, SIGNAL(clicked()), this, SLOT(slotParentDropCap()));
00229 
00230               dropCapLines_->setValue(pstyle->dropCapLines(), pstyle->isInhDropCapLines());
00231               dropCapLines_->setParentValue(parent->dropCapLines());
00232 
00233               dropCapOffset_->setValue(pstyle->dropCapOffset() * unitRatio, pstyle->isInhDropCapOffset());
00234               dropCapOffset_->setParentValue(parent->dropCapOffset() * unitRatio);
00235 
00236               alignement_->setStyle(pstyle->alignment(), pstyle->isInhAlignment());
00237               alignement_->setParentItem(parent->alignment());
00238 
00239               bool hasParentTabs = pstyle->isInhTabValues();
00240               QValueList<ParagraphStyle::TabRecord> tabs;
00241               if (hasParentTabs)
00242                      tabs = QValueList<ParagraphStyle::TabRecord>(parent->tabValues());
00243               else
00244                      tabs = pstyle->tabValues();
00245 
00246               tabList_->setTabs(tabs, unitIndex, hasParentTabs);
00247               tabList_->setParentTabs(parent->tabValues());
00248 
00249               tabList_->setLeftIndentValue(pstyle->leftMargin() * unitRatio,pstyle->isInhLeftMargin());
00250               tabList_->setParentLeftIndent(parent->leftMargin() * unitRatio);
00251 
00252               tabList_->setFirstLineValue(pstyle->firstIndent() * unitRatio, pstyle->isInhFirstIndent());
00253               tabList_->setParentFirstLine(parent->firstIndent() * unitRatio);
00254 
00255               tabList_->setRightIndentValue(pstyle->rightMargin() * unitRatio, pstyle->isInhRightMargin());
00256               tabList_->setParentRightIndent(parent->rightMargin() * unitRatio);
00257        }
00258        else
00259        {
00260               lineSpacingMode_->setCurrentItem(pstyle->lineSpacingMode());
00261               lineSpacing_->setValue(pstyle->lineSpacing());
00262               spaceAbove_->setValue(pstyle->gapBefore() * unitRatio);
00263               spaceBelow_->setValue(pstyle->gapAfter() * unitRatio);
00264               dropCapsBox->setChecked(pstyle->hasDropCap());
00265               parentDropCapButton->hide();
00266               disconnect(parentDropCapButton, SIGNAL(clicked()), this, SLOT(slotParentDropCap()));
00267               dropCapLines_->setValue(pstyle->dropCapLines());
00268               dropCapOffset_->setValue(pstyle->dropCapOffset() * unitRatio);
00269               parentDropCapButton->hide();
00270               alignement_->setStyle(pstyle->alignment());
00271               tabList_->setTabs(pstyle->tabValues(), unitIndex);
00272               tabList_->setLeftIndentValue(pstyle->leftMargin() * unitRatio);
00273               tabList_->setFirstLineValue(pstyle->firstIndent() * unitRatio);
00274               tabList_->setRightIndentValue(pstyle->rightMargin() * unitRatio);
00275        }
00276 
00277        lineSpacing_->setEnabled(pstyle->lineSpacingMode() == ParagraphStyle::FixedLineSpacing);
00278        dropCapLines_->setEnabled(pstyle->hasDropCap());
00279        dropCapOffset_->setEnabled(pstyle->hasDropCap());
00280 
00281        QFont f(font());
00282        f.setBold(true);
00283        parentDropCapButton->setFont(f);
00284 
00285        cpage->parentLabel->setText( tr("Based On:"));
00286        cpage->show(&pstyle->charStyle(), cstyles, defLang, unitIndex);
00287 
00288        parentCombo->clear();
00289        parentCombo->insertItem("");
00290 
00291        for (uint i = 0; i < pstyles.count(); ++i)
00292        {
00293               if (pstyles[i].hasName() && pstyles[i].name() != pstyle->name())
00294                      parentCombo->insertItem(pstyles[i].name());
00295        }
00296 
00297        if (hasParent_)
00298        {
00299               int index = 0;
00300               for (int i = 0; i < parentCombo->count(); ++i)
00301               {
00302                      if (parentCombo->text(i) == parent->name())
00303                      {
00304                             index = i;
00305                             break;
00306                      }
00307               }
00308               parentCombo->setCurrentItem(index);
00309        }
00310        else
00311               parentCombo->setCurrentItem(0);
00312 
00313        connect(dropCapsBox, SIGNAL(toggled(bool)), this, SLOT(slotDropCap(bool)));
00314 }
00315 
00316 void SMPStyleWidget::show(QValueList<ParagraphStyle*> &pstyles, QValueList<ParagraphStyle> &pstylesAll, QValueList<CharStyle> &cstyles, int unitIndex, const QString &defLang)
00317 {
00318        if (pstyles.count() == 1)
00319               show(pstyles[0], pstylesAll, cstyles, unitIndex, defLang);
00320        else if (pstyles.count() > 1)
00321        {
00322               showLineSpacing(pstyles);
00323               showSpaceAB(pstyles, unitIndex);
00324               showDropCap(pstyles, unitIndex);
00325               showAlignment(pstyles);
00326               showTabs(pstyles, unitIndex);
00327               showCStyle(pstyles, cstyles, defLang, unitIndex);
00328               showParent(pstyles);
00329        }
00330 }
00331 
00332 void SMPStyleWidget::showLineSpacing(QValueList<ParagraphStyle*> &pstyles)
00333 {
00334        lineSpacingMode_->clear();
00335        lineSpacingMode_->insertItem( tr("Fixed Linespacing"));
00336        lineSpacingMode_->insertItem( tr("Automatic Linespacing"));
00337        lineSpacingMode_->insertItem( tr("Align to Baseline Grid"));
00338 
00339        int tmpLP = -1;
00340        for (uint i = 0; i < pstyles.count(); ++i)
00341        {
00342               if (tmpLP != -1 && pstyles[i]->lineSpacingMode() != tmpLP)
00343               {
00344                      tmpLP = -1;
00345                      break;
00346               }
00347               else
00348                      tmpLP = pstyles[i]->lineSpacingMode();
00349        }
00350 
00351        if (tmpLP == -1)
00352        {
00353               if (lineSpacingMode_->text(lineSpacingMode_->count() - 1) != "")
00354                      lineSpacingMode_->insertItem("");
00355               lineSpacingMode_->setCurrentItem(lineSpacingMode_->count() - 1);
00356        }
00357        else
00358               lineSpacingMode_->setCurrentItem(tmpLP);
00359 
00360        double tmpLS = -1.0;
00361        for (uint i = 0; i < pstyles.count(); ++i)
00362        {
00363               if (tmpLS > 0 && !isEqual(pstyles[i]->lineSpacing(), tmpLS))
00364               {
00365                      tmpLS = -1.0;
00366                      break;
00367               }
00368               else
00369                      tmpLS = pstyles[i]->lineSpacing();
00370        }
00371        lineSpacing_->setEnabled(true);
00372        if (tmpLS < 0)
00373               lineSpacing_->clear();
00374        else
00375               lineSpacing_->setValue(tmpLS);
00376 }
00377 
00378 void SMPStyleWidget::showSpaceAB(QValueList<ParagraphStyle*> &pstyles, int unitIndex)
00379 {
00380        double unitRatio = unitGetRatioFromIndex(unitIndex);
00381        double tmpA = -1.2;
00382        for (uint i = 0; i < pstyles.count(); ++i)
00383        {
00384               if (tmpA > -1.0 && !isEqual(pstyles[i]->gapBefore(), tmpA))
00385               {
00386                      tmpA = -1.2;
00387                      break;
00388               }
00389               else
00390                      tmpA = pstyles[i]->gapBefore();
00391        }
00392 
00393        if (tmpA < 0)
00394               spaceAbove_->clear();
00395        else
00396               spaceAbove_->setValue(tmpA * unitRatio);
00397 
00398        tmpA = -1.2;
00399        for (uint i = 0; i < pstyles.count(); ++i)
00400        {
00401               if (tmpA > -1.0 && !isEqual(pstyles[i]->gapAfter(), tmpA))
00402               {
00403                      tmpA = -1.2;
00404                      break;
00405               }
00406        }
00407 
00408        if (tmpA < 0)
00409               spaceBelow_->clear();
00410        else
00411               spaceBelow_->setValue(tmpA * unitRatio);
00412 }
00413 
00414 void SMPStyleWidget::showDropCap(QValueList<ParagraphStyle*> &pstyles, int unitIndex)
00415 {
00416        double unitRatio = unitGetRatioFromIndex(unitIndex);
00417        parentDropCapButton->hide();
00418        disconnect(parentDropCapButton, SIGNAL(clicked()), this, SLOT(slotParentDropCap()));
00419 
00420        bool dc = pstyles[0]->hasDropCap();
00421        for (uint i = 0; i < pstyles.count(); ++i)
00422        {
00423               if (dc != pstyles[i]->hasDropCap())
00424               {
00425                      dc = false;
00426                      break;
00427               }
00428        }
00429        dropCapsBox->setChecked(dc);
00430 
00431        int lines = -1;
00432        for (uint i = 0; i < pstyles.count(); ++i)
00433        {
00434               if (lines > -1 && pstyles[i]->dropCapLines() != lines)
00435               {
00436                      lines = -1;
00437                      break;
00438               }
00439               else
00440                      lines = pstyles[i]->dropCapLines();
00441        }
00442        if (lines == -1)
00443               dropCapLines_->clear();
00444        else
00445               dropCapLines_->setValue(lines);
00446 
00447        double dco = -4000.0;
00448        for (uint i = 0; i < pstyles.count(); ++i)
00449        {
00450               if (dco > -3980.0 && !isEqual(pstyles[i]->dropCapOffset(), dco))
00451               {
00452                      dco = -4000.0;
00453                      break;
00454               }
00455               else
00456                      dco = pstyles[i]->dropCapOffset();
00457        }
00458 
00459        if (dco < -3800.0)
00460               dropCapOffset_->clear();
00461        else
00462               dropCapOffset_->setValue(dco * unitRatio);
00463 
00464        connect(dropCapsBox, SIGNAL(toggled(bool)), this, SLOT(slotDropCap(bool)));
00465        dropCapsBox->setEnabled(true);
00466        dropCapLines_->setEnabled(true);
00467        dropCapOffset_->setEnabled(true);
00468 }
00469 
00470 void SMPStyleWidget::showAlignment(QValueList<ParagraphStyle*> &pstyles)
00471 {
00472        ParagraphStyle::AlignmentType a = pstyles[0]->alignment();
00473        for (uint i = 0; i < pstyles.count(); ++i)
00474        {
00475               if (a != pstyles[i]->alignment())
00476               {
00477                      if (alignement_->selectedId() > -1)
00478                      {
00479                             alignement_->setExclusive(false);
00480                             alignement_->selected()->toggle();
00481                             alignement_->setExclusive(true);
00482                      }
00483                      return;
00484               }
00485        }
00486        alignement_->setStyle(a);
00487 }
00488 
00489 void SMPStyleWidget::showTabs(QValueList<ParagraphStyle*> &pstyles, int unitIndex)
00490 {
00491        double unitRatio = unitGetRatioFromIndex(unitIndex);
00492        QValueList<ParagraphStyle::TabRecord> t = pstyles[0]->tabValues();
00493        for (uint i = 0; i < pstyles.count(); ++i)
00494        {
00495               if (t != pstyles[i]->tabValues())
00496               {
00497                      t = QValueList<ParagraphStyle::TabRecord>();
00498                      break;
00499               }
00500        }
00501        tabList_->setTabs(t, unitIndex);
00502 
00503        double l = -4000.0;
00504        for (uint i = 0; i < pstyles.count(); ++i)
00505        {
00506               if (l > -3800.0 && !isEqual(pstyles[i]->leftMargin(), l))
00507               {
00508                      l = -4000.0;
00509                      break;
00510               }
00511               else
00512                      l = pstyles[i]->leftMargin();
00513        }
00514        if (l < -3800.0)
00515        {
00516               tabList_->setLeftIndentValue(0.0);
00517               tabList_->left_->clear();
00518        }
00519        else
00520               tabList_->setLeftIndentValue(l * unitRatio);
00521 
00522        l = -4000.0;
00523        for (uint i = 0; i < pstyles.count(); ++i)
00524        {
00525               if (l > -3800.0 && !isEqual(pstyles[i]->firstIndent(), l))
00526               {
00527                      l = -4000.0;
00528                      break;
00529               }
00530               else
00531                      l = pstyles[i]->firstIndent();
00532        }
00533        if (l < -3800.0)
00534        {
00535               tabList_->setFirstLineValue(0.0);
00536               tabList_->first_->clear();
00537        }
00538        else
00539               tabList_->setFirstLineValue(l * unitRatio);
00540 
00541        l = -4000.0;
00542        for (uint i = 0; i < pstyles.count(); ++i)
00543        {
00544               if (l > -3800.0 && !isEqual(pstyles[i]->rightMargin(), l))
00545               {
00546                      l = -4000.0;
00547                      break;
00548               }
00549               else
00550                      l = pstyles[i]->rightMargin();
00551        }
00552        if (l < -3800.0)
00553        {
00554               tabList_->setRightIndentData(0.0);
00555               tabList_->right_->clear();
00556        }
00557        else
00558               tabList_->setRightIndentValue(l * unitRatio);
00559 
00560 }
00561 
00562 void SMPStyleWidget::showCStyle(QValueList<ParagraphStyle*> &pstyles, QValueList<CharStyle> &cstyles, const QString &defLang, int unitIndex)
00563 {
00564        cpage->parentLabel->setText( tr("Based On:"));
00565 
00566        QValueList<CharStyle*> cstyle;
00567        for (uint i = 0; i < pstyles.count(); ++i)
00568               cstyle << &pstyles[i]->charStyle();
00569 
00570        cpage->show(cstyle, cstyles, defLang, unitIndex);
00571 }
00572 
00573 void SMPStyleWidget::showParent(QValueList<ParagraphStyle*> &pstyles)
00574 {
00575        parentCombo->setEnabled(false);
00576 
00577 //     parentCombo->clear();
00578 //     parentCombo->insertItem("");
00579 //     for (uint i = 0; i < pstyles.count(); ++i)
00580 //     {
00581 //            if (pstyles[i].hasName() && pstyles[i].name() != pstyle->name())
00582 //                   parentCombo->insertItem(pstyles[i].name());
00583 //     }
00584 // 
00585 //     if (hasParent_)
00586 //     {
00587 //            int index = 0;
00588 //            for (int i = 0; i < parentCombo->count(); ++i)
00589 //            {
00590 //                   if (parentCombo->text(i) == parent->name())
00591 //                   {
00592 //                          index = i;
00593 //                          break;
00594 //                   }
00595 //            }
00596 //            parentCombo->setCurrentItem(index);
00597 //     }
00598 //     else
00599 //            parentCombo->setCurrentItem(0);
00600 }
00601 
00602 void SMPStyleWidget::clearAll()
00603 {
00604 
00605 }
00606 
00607 void SMPStyleWidget::slotDropCap(bool isOn)
00608 {
00609        if (isOn)
00610        {
00611               dropCapsBox->setEnabled(true);
00612               dropCapLines_->setEnabled(true);
00613               dropCapOffset_->setEnabled(true);
00614        }
00615        else
00616        {
00617               dropCapsBox->setEnabled(true);
00618               dropCapLines_->setEnabled(false);
00619               dropCapOffset_->setEnabled(false);
00620        }
00621        if (hasParent_)
00622               parentDropCapButton->show();
00623 }
00624 
00625 void SMPStyleWidget::slotParentDropCap()
00626 {
00627        disconnect(parentDropCapButton, SIGNAL(clicked()), this, SLOT(slotParentDropCap()));
00628        disconnect(dropCapsBox, SIGNAL(toggled(bool)), this, SLOT(slotDropCap(bool)));
00629        parentDropCapButton->hide();
00630        dropCapsBox->setChecked(parentDropCap_);
00631        emit useParentDropCap();
00632        connect(parentDropCapButton, SIGNAL(clicked()), this, SLOT(slotParentDropCap()));
00633        connect(dropCapsBox, SIGNAL(toggled(bool)), this, SLOT(slotDropCap(bool)));
00634 }
00635 
00636 SMPStyleWidget::~SMPStyleWidget()
00637 {
00638        
00639 }
00640 
00641 /******************************************************************************/
00642 /******************************************************************************/
00643 
00644 SMCStylePage::SMCStylePage(QWidget *parent) : CStylePBase(parent)
00645 {
00646        basicGroup->setColumnLayout(0, Qt::Vertical );
00647        basicGroup->layout()->setSpacing( 0 );
00648        basicGroup->layout()->setMargin( 0 );
00649        basicBoxLayout = new QVBoxLayout(basicGroup->layout()); 
00650        basicBoxLayout->setAlignment( Qt::AlignTop );
00651        basicBoxLayout->setSpacing( 5 );
00652        basicBoxLayout->setMargin( 10 );
00653 
00654        fontFace_ = new SMFontComboH(basicGroup);
00655        basicBoxLayout->addWidget( fontFace_ );
00656        
00657        spinBoxLayoutBasic_ = new QGridLayout(1, 9);
00658        fontSize_ = new SMMSpinBox( 1, 2048, basicGroup, 1 );
00659        fontSize_->setMinimumSize( QSize( 70, 22 ) );
00660        fontSize_->setSuffix(unitGetSuffixFromIndex(0));
00661        fontSizeLabel_ = new QLabel( "" ,basicGroup, "TextF2" );
00662        fontSizeLabel_->setPixmap(loadIcon("Zeichen.xpm"));
00663        fontSizeLabel_->setMinimumSize( QSize( 22, 22 ) );
00664        fontSizeLabel_->setMaximumSize( QSize( 22, 22 ) );
00665        trackingLabel_ = new QLabel( basicGroup, "pixmapLabel3_3" );
00666        trackingLabel_->setMinimumSize( QSize( 22, 22 ) );
00667        trackingLabel_->setMaximumSize( QSize( 22, 22 ) );
00668        trackingLabel_->setPixmap( loadIcon("textkern.png") );
00669        tracking_ = new SMMSpinBox( -300, 300, basicGroup, 1 );
00670        tracking_->setSuffix( tr( " %" ) );
00671        spinBoxLayoutBasic_->addWidget(fontSizeLabel_, 0, 0);
00672        spinBoxLayoutBasic_->addMultiCellWidget(fontSize_, 0, 0, 1, 2);
00673        spinBoxLayoutBasic_->addWidget(trackingLabel_, 0, 3);
00674        spinBoxLayoutBasic_->addMultiCellWidget(tracking_, 0, 0, 4, 5);
00675        spacer4 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00676        spinBoxLayoutBasic_->addItem( spacer4 );
00677        basicBoxLayout->addLayout( spinBoxLayoutBasic_ );
00678        
00679        layout8 = new QHBoxLayout( 0, 0, 0, "layout8");
00680        effects_ = new SMStyleSelect(basicGroup);
00681        layout8->addWidget(effects_);
00682        spacer2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00683        layout8->addItem( spacer2 );
00684 
00685        basicBoxLayout->addLayout( layout8, Qt::AlignLeft );
00686 
00687        advGroup->setColumnLayout(0, Qt::Vertical );
00688        advGroup->layout()->setSpacing( 0 );
00689        advGroup->layout()->setMargin( 0 );
00690        advBoxLayout = new QVBoxLayout(advGroup->layout());     
00691        advBoxLayout->setAlignment( Qt::AlignTop );
00692        advBoxLayout->setSpacing( 5 );
00693        advBoxLayout->setMargin( 10 );
00694        
00695        spinBoxLayout_ = new QGridLayout(1, 9);
00696 
00697        baselineOffsetLabel_ = new QLabel( advGroup, "pixmapLabel2" );
00698        baselineOffsetLabel_->setMinimumSize( QSize( 22, 22 ) );
00699        baselineOffsetLabel_->setMaximumSize( QSize( 22, 22 ) );
00700        baselineOffsetLabel_->setPixmap( loadIcon("textbase.png") );
00701 
00702        baselineOffset_ = new SMMSpinBox( -100, 100, advGroup, 1 );
00703        baselineOffset_->setSuffix( tr( " %" ) );
00704 
00705        spinBoxLayout_->addWidget(baselineOffsetLabel_, 0, 6);
00706        spinBoxLayout_->addMultiCellWidget(baselineOffset_, 0, 0, 7, 8);
00707 
00708        hscaleLabel_ = new QLabel( "", advGroup, "pixmapLabel3" );
00709        hscaleLabel_->setMinimumSize( QSize( 22, 22 ) );
00710        hscaleLabel_->setMaximumSize( QSize( 22, 22 ) );
00711        hscaleLabel_->setPixmap( loadIcon("textscaleh.png") );
00712 
00713        fontHScale_ = new SMMSpinBox( 10, 400, advGroup, 1 );
00714        fontHScale_->setSuffix( tr( " %" ) );
00715 
00716        spinBoxLayout_->addWidget(hscaleLabel_, 0, 0);
00717        spinBoxLayout_->addMultiCellWidget(fontHScale_, 0, 0, 1, 2);
00718 
00719        vscaleLabel_ = new QLabel( "", advGroup, "pixmapLabel3_2" );
00720        vscaleLabel_->setMinimumSize( QSize( 22, 22 ) );
00721        vscaleLabel_->setMaximumSize( QSize( 22, 22 ) );
00722        vscaleLabel_->setPixmap( loadIcon("textscalev.png") );
00723 
00724        fontVScale_ = new SMMSpinBox( 10, 400, advGroup, 1 );
00725        fontVScale_->setSuffix( tr( " %" ) );
00726 
00727        spinBoxLayout_->addWidget(vscaleLabel_, 0, 3);
00728        spinBoxLayout_->addMultiCellWidget(fontVScale_, 0, 0, 4, 5);
00729 
00730        spinBoxLayout_->setColStretch(9, 10);
00731 
00732        advBoxLayout->addLayout( spinBoxLayout_, Qt::AlignLeft );
00733        
00734        layout9a = new QHBoxLayout( 0, 0, 0, "layout9");
00735        languageLabel_ = new QLabel( "", advGroup, "languageLabel_" );
00736        language_ = new SMScComboBox(false, advGroup, "language_");
00737        layout9a->addWidget(languageLabel_);
00738        layout9a->addWidget(language_);
00739 
00740        spacer1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00741        layout9a->addItem( spacer1 );
00742        advBoxLayout->addLayout( layout9a, Qt::AlignLeft );
00743        
00744        
00745        
00746        
00747        colorGroup->setColumnLayout(0, Qt::Vertical );
00748        colorGroup->layout()->setSpacing( 0 );
00749        colorGroup->layout()->setMargin( 0 );
00750        colorBoxLayout = new QVBoxLayout(colorGroup->layout()); 
00751        colorBoxLayout->setAlignment( Qt::AlignTop );
00752        colorBoxLayout->setSpacing( 5 );
00753        colorBoxLayout->setMargin( 10 );
00754        
00755        layout5 = new QHBoxLayout( 0, 0, 5, "layout5");
00756        FillIcon = new QLabel( "", colorGroup, "FillIcon" );
00757        FillIcon->setPixmap(loadIcon("16/color-fill.png"));
00758        layout5->addWidget( FillIcon );
00759 
00760        fillColor_ = new SMColorCombo(colorGroup, "TxFill");
00761        layout5->addWidget( fillColor_ );
00762 
00763        pixmapLabel3_20 = new QLabel( colorGroup, "pixmapLabel3_20" );
00764        pixmapLabel3_20->setMinimumSize( QSize( 22, 22 ) );
00765        pixmapLabel3_20->setMaximumSize( QSize( 22, 22 ) );
00766        pixmapLabel3_20->setPixmap( loadIcon("shade.png") );
00767        layout5->addWidget( pixmapLabel3_20 );
00768 
00769        fillShade_ = new SMShadeButton(colorGroup);
00770        layout5->addWidget( fillShade_ );
00771        QSpacerItem* spacer3 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00772        layout5->addItem( spacer3 );
00773        colorBoxLayout->addLayout( layout5 );
00774 
00775        layout6 = new QHBoxLayout( 0, 0, 5, "layout6");
00776        StrokeIcon = new QLabel( "", colorGroup, "StrokeIcon" );
00777        StrokeIcon->setPixmap(loadIcon("16/color-stroke.png"));
00778        layout6->addWidget( StrokeIcon );
00779 
00780        strokeColor_ = new SMColorCombo(colorGroup, "TxStroke");
00781        layout6->addWidget( strokeColor_ );
00782 
00783        pixmapLabel3_19 = new QLabel( "", colorGroup, "pixmapLabel3_19" );
00784        pixmapLabel3_19->setMinimumSize( QSize( 22, 22 ) );
00785        pixmapLabel3_19->setMaximumSize( QSize( 22, 22 ) );
00786        pixmapLabel3_19->setPixmap( loadIcon("shade.png") );
00787        layout6->addWidget( pixmapLabel3_19 );
00788 
00789        strokeShade_ = new SMShadeButton(colorGroup);
00790        layout6->addWidget( strokeShade_ );
00791 
00792        spacer3 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00793        layout6->addItem( spacer3 );
00794        colorBoxLayout->addLayout( layout6 );
00795 
00796        fillColor_->clear();
00797        strokeColor_->clear();
00798        ColorList::Iterator it;
00799        QPixmap pm = QPixmap(15, 15);
00800        fillColor_->insertItem(CommonStrings::tr_NoneColor);
00801        strokeColor_->insertItem(CommonStrings::tr_NoneColor);
00802        StrokeIcon->setEnabled(false);
00803        strokeShade_->setEnabled(false);
00804        strokeColor_->setEnabled(false);
00805 
00806        connect(effects_, SIGNAL(State(int)), this, SLOT(slotColorChange()));
00807 }
00808 
00809 void SMCStylePage::languageChange()
00810 {
00811 /***********************************/
00812 /*      Begin Tooltips             */
00813 /***********************************/
00814 // These are for the character style page
00815 // as in character styles and in paragraph style's character style
00816 
00817        QToolTip::add(parentCombo,     tr("Parent style"));
00818        QToolTip::add(fontFace_,       tr("Font face"));
00819        QToolTip::add(fontSize_,       tr("Font size"));
00820        QToolTip::add(tracking_,       tr("Tracking"));
00821        QToolTip::add(baselineOffset_, tr("Baseline offset"));
00822        QToolTip::add(fontHScale_,     tr("Horizontal scaling"));
00823        QToolTip::add(fontVScale_,     tr("Vertical scaling"));
00824        QToolTip::add(language_,       tr("Language"));
00825        QToolTip::add(fillColor_,      tr("Fill color"));
00826        QToolTip::add(fillShade_,      tr("Fill shade"));
00827        QToolTip::add(strokeColor_,    tr("Stroke color"));
00828        QToolTip::add(strokeShade_,    tr("Stroke shade"));
00829 
00830 /***********************************/
00831 /*        End Tooltips             */
00832 /***********************************/
00833 
00834        parentLabel->setText( tr("Based On:"));
00835        languageLabel_->setText( tr("Language:"));
00836        fontVScale_->setSuffix( tr(" %"));
00837        fontHScale_->setSuffix( tr(" %"));
00838        baselineOffset_->setSuffix( tr(" %"));
00839        tracking_->setSuffix( tr(" %"));
00840        fontSize_->setSuffix(unitGetSuffixFromIndex(0));
00841 }
00842 
00843 void SMCStylePage::fillLangCombo(QMap<QString,QString> langMap)
00844 {
00845        QStringList sortList;
00846        QMap<QString,QString>::Iterator it;
00847 
00848        langMap_ = langMap;
00849 
00850        language_->clear();
00851 
00852        for (it = langMap.begin(); it != langMap.end(); ++it)
00853               sortList.push_back(it.data());
00854 
00855        language_->insertStringList(sortQStringList(sortList));
00856        language_->listBox()->setMinimumWidth(language_->listBox()->maxItemWidth() + 24);
00857 }
00858 
00859 void SMCStylePage::fillColorCombo(ColorList &colors)
00860 {
00861        fillColor_->clear();
00862        strokeColor_->clear();
00863 
00864        fillColor_->insertItem(CommonStrings::tr_NoneColor);
00865        strokeColor_->insertItem(CommonStrings::tr_NoneColor);
00866        ColorList::Iterator itend=colors.end();
00867        ScribusDoc* doc = colors.document();
00868        for (ColorList::Iterator it = colors.begin(); it != itend; ++it)
00869        {
00870               fillColor_->insertSmallItem(it.data(), doc, it.key());
00871               strokeColor_->insertSmallItem(it.data(), doc, it.key());
00872        }
00873        fillColor_->listBox()->setMinimumWidth(fillColor_->listBox()->maxItemWidth()+24);
00874        strokeColor_->listBox()->setMinimumWidth(strokeColor_->listBox()->maxItemWidth()+24);
00875 }
00876 
00877 void SMCStylePage::show(CharStyle *cstyle, QValueList<CharStyle> &cstyles, const QString &defLang, int unitIndex)
00878 {
00879        disconnect(effects_, SIGNAL(State(int)), this, SLOT(slotColorChange()));
00880        parentCombo->setEnabled(true);
00881        const CharStyle *parent = dynamic_cast<const CharStyle*>(cstyle->parentStyle());
00882        bool hasParent =  cstyle->hasParent() && parent != 0 && parent->hasName() && cstyle->parent() != "";
00883        if (hasParent)
00884        {
00885               fontSize_->setValue(cstyle->fontSize() / 10.0, cstyle->isInhFontSize());
00886               fontSize_->setParentValue(parent->fontSize() / 10.0);
00887 
00888               fontHScale_->setValue(cstyle->scaleH() / 10.0, cstyle->isInhScaleH());
00889               fontHScale_->setParentValue(parent->scaleH() / 10.0);
00890 
00891               fontVScale_->setValue(cstyle->scaleV() / 10.0, cstyle->isInhScaleV());
00892               fontVScale_->setParentValue(parent->scaleV() / 10.0);
00893 
00894               baselineOffset_->setValue(cstyle->baselineOffset() / 10.0, cstyle->isInhBaselineOffset());
00895               baselineOffset_->setParentValue(parent->baselineOffset() / 10.0);
00896 
00897               tracking_->setValue(cstyle->tracking() / 10.0, cstyle->isInhTracking());
00898               tracking_->setParentValue(parent->tracking() / 10.0);
00899 
00900               effects_->setStyle(static_cast<int>(cstyle->effects()), cstyle->isInhFeatures());
00901               effects_->setParentItem(static_cast<int>(parent->effects())); // FIXME
00902 
00903               fillShade_->setValue(cstyle->fillShade(), cstyle->isInhFillShade());
00904               fillShade_->setParentValue(parent->fillShade());
00905 
00906               strokeShade_->setValue(cstyle->strokeShade(), cstyle->isInhStrokeShade());
00907               strokeShade_->setParentValue(parent->strokeShade());
00908 
00909               fillColor_->setCurrentText(cstyle->fillColor(), cstyle->isInhFillColor());
00910               fillColor_->setParentText(parent->fillColor());
00911 
00912               strokeColor_->setCurrentText(cstyle->strokeColor(), cstyle->isInhStrokeColor());
00913               strokeColor_->setParentText(parent->strokeColor());
00914 
00915               fontFace_->setCurrentFont(cstyle->font().scName(), cstyle->isInhFont());
00916               fontFace_->setParentFont(parent->font().scName());
00917        }
00918        else
00919        {
00920               fontSize_->setValue(cstyle->fontSize() / 10.0);
00921               fontHScale_->setValue(cstyle->scaleH() / 10.0);
00922               fontVScale_->setValue(cstyle->scaleV() / 10.0);
00923               baselineOffset_->setValue(cstyle->baselineOffset() / 10.0);
00924               tracking_->setValue(cstyle->tracking() / 10.0);
00925               effects_->setStyle(static_cast<int>(cstyle->effects()));
00926               fillShade_->setValue(cstyle->fillShade());
00927               strokeShade_->setValue(cstyle->strokeShade());
00928               fillColor_->setCurrentText(cstyle->fillColor());
00929               strokeColor_->setCurrentText(cstyle->strokeColor());
00930               fontFace_->setCurrentFont(cstyle->font().scName());
00931        }
00932 
00933        effects_->ShadowVal->Xoffset->setValue(cstyle->shadowXOffset() / 10.0);
00934        effects_->ShadowVal->Yoffset->setValue(cstyle->shadowYOffset() / 10.0);
00935        effects_->OutlineVal->LWidth->setValue(cstyle->outlineWidth() / 10.0);
00936        effects_->StrikeVal->LPos->setValue(cstyle->strikethruOffset() / 10.0);
00937        effects_->StrikeVal->LWidth->setValue(cstyle->strikethruWidth() / 10.0);
00938        effects_->UnderlineVal->LPos->setValue(cstyle->underlineOffset() / 10.0);
00939        effects_->UnderlineVal->LWidth->setValue(cstyle->underlineWidth() / 10.0);
00940        slotColorChange();
00941 
00942        parentCombo->clear();
00943        parentCombo->insertItem("");
00944        for (uint i = 0; i < cstyles.count(); ++i)
00945        {
00946               if (cstyles[i].name() != cstyle->name())
00947                      parentCombo->insertItem(cstyles[i].name());
00948        }
00949 
00950        if (hasParent)
00951        {
00952               int index = 0;
00953               for (int i = 0; i < parentCombo->count(); ++i)
00954               {
00955                      if (parentCombo->text(i) == cstyle->parentStyle()->name())
00956                      {
00957                             index = i;
00958                             break;
00959                      }
00960               }
00961               parentCombo->setCurrentItem(index);
00962        }
00963        else
00964               parentCombo->setCurrentItem(0);
00965 
00966        QString clang = cstyle->language().isNull() || cstyle->language().isEmpty() ?
00967                                              defLang : cstyle->language();
00968        QString plang(QString::null);
00969        if (hasParent)
00970               plang = parent->language().isNull() || parent->language().isEmpty() ?
00971                                             defLang : parent->language();
00972 
00973        int ci = -1, pi = -1, di = -1;
00974        for (int i = 0; i < language_->count(); ++i)
00975        {
00976               if (language_->text(i) == langMap_[clang])
00977                      ci = i;
00978               
00979               if (hasParent && language_->text(i) == langMap_[plang])
00980                      pi = i;
00981 
00982               if (language_->text(i) == defLang || language_->text(i) == langMap_[defLang])
00983                      di = i;
00984        }
00985 
00986        Q_ASSERT(di != -1);
00987 
00988        if (hasParent)
00989        {
00990               if (ci == -1)
00991                      language_->setCurrentItem(di, cstyle->isInhLanguage());
00992               else
00993                      language_->setCurrentItem(ci, cstyle->isInhLanguage());
00994 
00995               language_->setParentItem(pi);
00996        }
00997        else
00998        {
00999               if (ci == -1)
01000                      language_->setCurrentItem(di);
01001               else
01002                      language_->setCurrentItem(ci);
01003        }
01004 
01005        connect(effects_, SIGNAL(State(int)), this, SLOT(slotColorChange()));
01006 }
01007 
01008 void SMCStylePage::show(QValueList<CharStyle*> &cstyles, QValueList<CharStyle> &cstylesAll, const QString &defLang, int unitIndex)
01009 {
01010 //     int decimals = unitGetDecimalsFromIndex(unitIndex);
01011 //     QString suffix = unitGetSuffixFromIndex(unitIndex);
01012 
01013        if (cstyles.count() == 1)
01014               show(cstyles[0], cstylesAll, defLang, unitIndex);
01015        else if (cstyles.count() > 1)
01016        {
01017               showSizeAndPosition(cstyles);
01018               showEffects(cstyles);
01019               showColors(cstyles);
01020               showLanguage(cstyles, defLang);
01021               showParent(cstyles);
01022        }
01023 }
01024 
01025 void SMCStylePage::showSizeAndPosition(const QValueList<CharStyle*> &cstyles)
01026 {
01027        int d = -30000;
01028        for (uint i = 0; i < cstyles.count(); ++i)
01029        {
01030               if (d != -30000 && cstyles[i]->fontSize() != d)
01031               {
01032                      d = -30000;
01033                      break;
01034               }
01035               else
01036                      d = cstyles[i]->fontSize();
01037        }
01038        if (d == -30000)
01039               fontSize_->clear();
01040        else
01041               fontSize_->setValue(d / 10.0);
01042 
01043        d = -30000;
01044        for (uint i = 0; i < cstyles.count(); ++i)
01045        {
01046               if (d != -30000 && cstyles[i]->scaleH() != d)
01047               {
01048                      d = -30000;
01049                      break;
01050               }
01051               else
01052                      d = cstyles[i]->scaleH();
01053        }
01054        if (d == -30000)
01055               fontHScale_->clear();
01056        else
01057               fontHScale_->setValue(d / 10.0);
01058 
01059        d = -30000;
01060        for (uint i = 0; i < cstyles.count(); ++i)
01061        {
01062               if (d != -30000 && cstyles[i]->scaleV() != d)
01063               {
01064                      d = -30000;
01065                      break;
01066               }
01067               else
01068                      d = cstyles[i]->scaleV();
01069        }
01070        if (d == -30000)
01071               fontVScale_->clear();
01072        else
01073               fontVScale_->setValue(d / 10.0);
01074 
01075        d = -30000;
01076        for (uint i = 0; i < cstyles.count(); ++i)
01077        {
01078               if (d != -30000 && cstyles[i]->baselineOffset() != d)
01079               {
01080                      d = -30000;
01081                      break;
01082               }
01083               else
01084                      d = cstyles[i]->baselineOffset();
01085        }
01086        if (d == -30000)
01087               baselineOffset_->clear();
01088        else
01089               baselineOffset_->setValue(d / 10.0);
01090 
01091        d = -30000;
01092        for (uint i = 0; i < cstyles.count(); ++i)
01093        {
01094               if (d != -30000 && cstyles[i]->tracking() != d)
01095               {
01096                      d = -30000;
01097                      break;
01098               }
01099               else
01100                      d = cstyles[i]->tracking();
01101        }
01102        if (d == -30000)
01103               tracking_->clear();
01104        else
01105               tracking_->setValue(d / 10.0);
01106 }
01107 
01108 void SMCStylePage::showEffects(const QValueList<CharStyle*> &cstyles)
01109 {
01110        int d = -30000;
01111        for (uint i = 0; i < cstyles.count(); ++i)
01112        {
01113               if (d != -30000 && static_cast<int>(cstyles[i]->effects()) != d)
01114               {
01115                      d = -30000;
01116                      break;
01117               }
01118               else
01119                      d = static_cast<int>(cstyles[i]->effects());
01120        }
01121        if (d == -30000)
01122               effects_->setStyle(0);
01123        else
01124               effects_->setStyle(d);
01125 
01126 //     TODO these things still missing:
01127 //            effects_->ShadowVal->Xoffset->setValue(cstyle->shadowXOffset() / 10.0);
01128 //            effects_->ShadowVal->Yoffset->setValue(cstyle->shadowYOffset() / 10.0);
01129 //            effects_->OutlineVal->LWidth->setValue(cstyle->outlineWidth() / 10.0);
01130 //            effects_->StrikeVal->LPos->setValue(cstyle->strikethruOffset() / 10.0);
01131 //            effects_->StrikeVal->LWidth->setValue(cstyle->strikethruWidth() / 10.0);
01132 //            effects_->UnderlineVal->LPos->setValue(cstyle->underlineOffset() / 10.0);
01133 //            effects_->UnderlineVal->LWidth->setValue(cstyle->underlineWidth() / 10.0);
01134 }
01135 
01136 void SMCStylePage::showColors(const QValueList<CharStyle*> &cstyles)
01137 {
01138        strokeShade_->setEnabled(true);
01139        strokeColor_->setEnabled(true);
01140 
01141        int d = -30000;
01142        for (uint i = 0; i < cstyles.count(); ++i)
01143        {
01144               if (d != -30000 && cstyles[i]->fillShade() != d)
01145               {
01146                      d = -30000;
01147                      break;
01148               }
01149               else
01150                      d = cstyles[i]->fillShade();
01151        }
01152        if (d == -30000)
01153               fillShade_->setText( tr("Shade"));
01154        else
01155               fillShade_->setValue(d);
01156 
01157        d = -30000;
01158        for (uint i = 0; i < cstyles.count(); ++i)
01159        {
01160               if (d != -30000 && cstyles[i]->strokeShade() != d)
01161               {
01162                      d = -30000;
01163                      break;
01164               }
01165               else
01166                      d = cstyles[i]->strokeShade();
01167        }
01168        if (d == -30000)
01169        {
01170               strokeShade_->setValue(21);
01171               strokeShade_->setText( tr("Shade"));
01172        }
01173        else
01174               strokeShade_->setValue(d);
01175 
01176        QString s(QString::null);
01177        for (uint i = 0; i < cstyles.count(); ++i)
01178        {
01179               if (!s.isNull() && s != cstyles[i]->fillColor())
01180               {
01181                      s = QString::null;
01182                      break;
01183               }
01184               else
01185                      s = cstyles[i]->fillColor();
01186        }
01187        if (s.isNull())
01188        {
01189               if (fillColor_->text(fillColor_->count() - 1) != "")
01190                      fillColor_->insertItem("");
01191               fillColor_->setCurrentItem(fillColor_->count() - 1);
01192        }
01193        else
01194               fillColor_->setCurrentText(s);
01195 
01196        s = QString::null;
01197        for (uint i = 0; i < cstyles.count(); ++i)
01198        {
01199               if (!s.isNull() && s != cstyles[i]->strokeColor())
01200               {
01201                      s = QString::null;
01202                      break;
01203               }
01204               else
01205                      s = cstyles[i]->strokeColor();
01206        }
01207        if (s.isNull())
01208        {
01209               if (strokeColor_->text(strokeColor_->count() - 1) != "")
01210                      strokeColor_->insertItem("");
01211               strokeColor_->setCurrentItem(fillColor_->count() - 1);
01212        }
01213        else
01214               strokeColor_->setCurrentText(s);
01215 }
01216 
01217 void SMCStylePage::showLanguage(const QValueList<CharStyle*> &cstyles, const QString &defLang)
01218 {
01219        QString s(cstyles[0]->language());
01220        for (uint i = 0; i < cstyles.count(); ++i)
01221        {
01222               if (s != cstyles[i]->language())
01223               {
01224                      s = QString::null;
01225                      break;
01226               }
01227               else
01228                      s = cstyles[i]->language();
01229        }
01230 
01231        if (s.isNull())
01232        {
01233               if (language_->text(language_->count() - 1) != "")
01234                      language_->insertItem("");
01235               language_->setCurrentItem(language_->count() - 1);
01236        }
01237        else
01238        {
01239               Q_ASSERT(langMap_.contains(s));
01240               language_->setCurrentText(langMap_[s]);
01241        }
01242 }
01243 
01244 void SMCStylePage::showParent(const QValueList<CharStyle*> &cstyles)
01245 {
01246        parentCombo->setEnabled(false);
01247 }
01248 
01249 void SMCStylePage::clearAll()
01250 {
01251        
01252 }
01253 
01254 void SMCStylePage::slotColorChange()
01255 {
01256        int s = effects_->getStyle();
01257        bool enabled;
01258        if ((s & 4) || (s & 256))
01259               enabled = true;
01260        else
01261               enabled = false;
01262        StrokeIcon->setEnabled(enabled);
01263        strokeShade_->setEnabled(enabled);
01264        strokeColor_->setEnabled(enabled);
01265 }
01266 
01267 
01268 SMCStylePage::~SMCStylePage()
01269 {
01270        
01271 }
01272 
01273 /******************************************************************************/
01274 /******************************************************************************/