00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "KoStyleCollection.h"
00022 #include "KoStyleManager.h"
00023 #include "KoStyleManager.moc"
00024 #include <KoFontDia.h>
00025 #include <KoGlobal.h>
00026
00027 #include <klocale.h>
00028 #include <kiconloader.h>
00029 #include <kdebug.h>
00030
00031 #include <qtabwidget.h>
00032 #include <qpushbutton.h>
00033 #include <qlabel.h>
00034 #include <qcombobox.h>
00035 #include <qcheckbox.h>
00036 #include <qlayout.h>
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 class KoStyleManagerPrivate
00055 {
00056 public:
00057 KoStylePreview* preview;
00058 QCheckBox* cbIncludeInTOC;
00059 };
00060
00061 KoStyleManager::KoStyleManager( QWidget *_parent, KoUnit::Unit unit,
00062 const KoStyleCollection& styles, const QString & activeStyleName,
00063 int flags )
00064 : KDialogBase( _parent, "Stylist", true,
00065 i18n("Style Manager"),
00066 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply )
00067 {
00068 d = new KoStyleManagerPrivate;
00069
00070 m_currentStyle =0L;
00071 noSignals=true;
00072 m_origStyles.setAutoDelete(false);
00073 m_changedStyles.setAutoDelete(false);
00074 setupWidget(styles);
00075 addGeneralTab( flags );
00076 KoStyleFontTab * fontTab = new KoStyleFontTab( m_tabs );
00077 addTab( fontTab );
00078
00079 KoStyleParagTab *newTab = new KoStyleParagTab( m_tabs );
00080 newTab->setWidget( new KoIndentSpacingWidget( unit, -1,newTab ) );
00081 addTab( newTab );
00082
00083 newTab = new KoStyleParagTab( m_tabs );
00084 newTab->setWidget( new KoParagAlignWidget( true, newTab ) );
00085 addTab( newTab );
00086
00087 newTab = new KoStyleParagTab( m_tabs );
00088 KoParagLayoutWidget *decorations = new KoParagDecorationWidget( newTab );
00089 decorations->layout()->setMargin(KDialog::marginHint());
00090 newTab->setWidget( decorations );
00091 addTab( newTab );
00092
00093 newTab = new KoStyleParagTab( m_tabs );
00094 newTab->setWidget( new KoParagCounterWidget( false , newTab ) );
00095 addTab( newTab );
00096
00097 newTab = new KoStyleParagTab( m_tabs );
00098 newTab->setWidget( new KoParagTabulatorsWidget( unit, -1, newTab ) );
00099 addTab( newTab );
00100
00101 QListBoxItem * item = m_stylesList->findItem( activeStyleName );
00102 m_stylesList->setCurrentItem( item ? m_stylesList->index(item) : 0 );
00103
00104 noSignals=false;
00105 switchStyle();
00106 setInitialSize( QSize( 600, 570 ) );
00107 }
00108
00109 KoStyleManager::~KoStyleManager()
00110 {
00111 for (unsigned int i =0 ; m_origStyles.count() > i ; i++) {
00112 KoParagStyle *orig = m_origStyles.at(i);
00113 KoParagStyle *changed = m_changedStyles.at(i);
00114 if( orig && changed && orig != changed )
00115 delete changed;
00116 }
00117
00118 delete d;
00119 }
00120
00121 void KoStyleManager::addTab( KoStyleManagerTab * tab )
00122 {
00123 m_tabsList.append( tab );
00124 m_tabs->insertTab( tab, tab->tabName() );
00125 tab->layout()->activate();
00126 }
00127
00128 void KoStyleManager::setupWidget(const KoStyleCollection& styleCollection)
00129 {
00130 QFrame * frame1 = makeMainWidget();
00131 QGridLayout *frame1Layout = new QGridLayout( frame1, 0, 0,
00132 0, KDialog::spacingHint() );
00133 numStyles = styleCollection.count();
00134 m_stylesList = new QListBox( frame1, "stylesList" );
00135 m_stylesList->insertStringList( styleCollection.displayNameList() );
00136
00137 const QValueList<KoUserStyle*> styleList = styleCollection.styleList();
00138 for ( QValueList<KoUserStyle *>::const_iterator it = styleList.begin(), end = styleList.end();
00139 it != end ; ++it )
00140 {
00141 KoParagStyle* style = static_cast<KoParagStyle *>( *it );
00142 m_origStyles.append( style );
00143 m_changedStyles.append( style );
00144 m_styleOrder<< style->name();
00145 }
00146
00147 frame1Layout->addMultiCellWidget( m_stylesList, 0, 0, 0, 1 );
00148
00149
00150 m_moveUpButton = new QPushButton( frame1, "moveUpButton" );
00151 m_moveUpButton->setIconSet( SmallIconSet( "up" ) );
00152 connect( m_moveUpButton, SIGNAL( clicked() ), this, SLOT( moveUpStyle() ) );
00153 frame1Layout->addWidget( m_moveUpButton, 1, 1 );
00154
00155 m_moveDownButton = new QPushButton( frame1, "moveDownButton" );
00156 m_moveDownButton->setIconSet( SmallIconSet( "down" ) );
00157 connect( m_moveDownButton, SIGNAL( clicked() ), this, SLOT( moveDownStyle() ) );
00158 frame1Layout->addWidget( m_moveDownButton, 1, 0 );
00159
00160
00161 m_deleteButton = new QPushButton( frame1, "deleteButton" );
00162 m_deleteButton->setText( i18n( "&Delete" ) );
00163 connect( m_deleteButton, SIGNAL( clicked() ), this, SLOT( deleteStyle() ) );
00164
00165 frame1Layout->addWidget( m_deleteButton, 2, 1 );
00166
00167 m_newButton = new QPushButton( frame1, "newButton" );
00168 m_newButton->setText( i18n( "New" ) );
00169 connect( m_newButton, SIGNAL( clicked() ), this, SLOT( addStyle() ) );
00170
00171 frame1Layout->addWidget( m_newButton, 2, 0 );
00172
00173 m_tabs = new QTabWidget( frame1 );
00174 frame1Layout->addMultiCellWidget( m_tabs, 0, 2, 2, 2 );
00175
00176 connect( m_stylesList, SIGNAL( selectionChanged() ), this, SLOT( switchStyle() ) );
00177 connect( m_tabs, SIGNAL( currentChanged ( QWidget * ) ), this, SLOT( switchTabs() ) );
00178 }
00179
00180 void KoStyleManager::addGeneralTab( int flags ) {
00181 QWidget *tab = new QWidget( m_tabs );
00182
00183 QGridLayout *tabLayout = new QGridLayout( tab );
00184 tabLayout->setSpacing( KDialog::spacingHint() );
00185 tabLayout->setMargin( KDialog::marginHint() );
00186
00187 m_nameString = new QLineEdit( tab );
00188 m_nameString->resize(m_nameString->sizeHint() );
00189 connect( m_nameString, SIGNAL( textChanged( const QString &) ), this, SLOT( renameStyle(const QString &) ) );
00190
00191 tabLayout->addWidget( m_nameString, 0, 1 );
00192
00193 QLabel *nameLabel = new QLabel( tab );
00194 nameLabel->setText( i18n( "Name:" ) );
00195 nameLabel->resize(nameLabel->sizeHint());
00196 nameLabel->setAlignment( AlignRight | AlignVCenter );
00197
00198 tabLayout->addWidget( nameLabel, 0, 0 );
00199
00200 m_styleCombo = new QComboBox( FALSE, tab, "styleCombo" );
00201
00202 tabLayout->addWidget( m_styleCombo, 1, 1 );
00203
00204 QLabel *nextStyleLabel = new QLabel( tab );
00205 nextStyleLabel->setText( i18n( "Next style:" ) );
00206 nextStyleLabel->setAlignment( AlignRight | AlignVCenter );
00207
00208 tabLayout->addWidget( nextStyleLabel, 1, 0 );
00209
00210 m_inheritCombo = new QComboBox( FALSE, tab, "inheritCombo" );
00211 tabLayout->addWidget( m_inheritCombo, 2, 1 );
00212
00213 QLabel *inheritStyleLabel = new QLabel( tab );
00214 inheritStyleLabel->setText( i18n( "Inherit style:" ) );
00215 inheritStyleLabel->setAlignment( AlignRight | AlignVCenter );
00216
00217 tabLayout->addWidget( inheritStyleLabel, 2, 0 );
00218
00219 int row = 3;
00220
00221 if ( flags & ShowIncludeInToc ) {
00222 d->cbIncludeInTOC = new QCheckBox( i18n("Include in table of contents"), tab );
00223 tabLayout->addMultiCellWidget( d->cbIncludeInTOC, row, row, 0, 1 );
00224 ++row;
00225 } else {
00226 d->cbIncludeInTOC = 0;
00227 }
00228
00229 d->preview = new KoStylePreview( i18n( "Preview" ), i18n( "The quick brown fox jumps over the lazy dog. And, what about the cat, one may ask? Well, the cat is playing cards with the mouse, the bird and the fish. It is, to say the least a hell of a party!" ), tab, "stylepreview" );
00230
00231 tabLayout->addMultiCellWidget( d->preview, row, row, 0, 1 );
00232
00233 m_tabs->insertTab( tab, i18n( "General" ) );
00234
00235 m_inheritCombo->insertItem( i18n("<None>"));
00236
00237 for ( unsigned int i = 0; i < m_stylesList->count(); i++ ) {
00238 m_styleCombo->insertItem( m_stylesList->text(i));
00239 m_inheritCombo->insertItem( m_stylesList->text(i));
00240 }
00241
00242 }
00243
00244 void KoStyleManager::switchStyle() {
00245 kdDebug(32500) << "KoStyleManager::switchStyle noSignals=" << noSignals << endl;
00246 if(noSignals) return;
00247 noSignals=true;
00248
00249 if(m_currentStyle !=0L)
00250 save();
00251
00252 m_currentStyle = 0L;
00253 int num = styleIndex( m_stylesList->currentItem() );
00254 kdDebug(32500) << "KoStyleManager::switchStyle switching to " << num << endl;
00255 if(m_origStyles.at(num) == m_changedStyles.at(num)) {
00256 m_currentStyle = new KoParagStyle( *m_origStyles.at(num) );
00257 m_changedStyles.take(num);
00258 m_changedStyles.insert(num, m_currentStyle);
00259 } else {
00260 m_currentStyle = m_changedStyles.at(num);
00261 }
00262 updateGUI();
00263
00264 noSignals=false;
00265 }
00266
00267 void KoStyleManager::switchTabs()
00268 {
00269
00270
00271 save();
00272 updatePreview();
00273 }
00274
00275
00276
00277
00278
00279
00280 int KoStyleManager::styleIndex( int pos ) {
00281 int p = 0;
00282 for(unsigned int i=0; i < m_changedStyles.count(); i++) {
00283
00284 KoParagStyle * style = m_changedStyles.at(i);
00285 if ( !style ) continue;
00286 if ( p == pos )
00287 return i;
00288 ++p;
00289 }
00290 kdWarning() << "KoStyleManager::styleIndex no style found at pos " << pos << endl;
00291
00292 #ifdef __GNUC_
00293 #warning implement undo/redo
00294 #endif
00295
00296 return 0;
00297 }
00298
00299
00300 void KoStyleManager::updateGUI() {
00301 kdDebug(32500) << "KoStyleManager::updateGUI m_currentStyle=" << m_currentStyle << " " << m_currentStyle->name() << endl;
00302 QPtrListIterator<KoStyleManagerTab> it( m_tabsList );
00303 for ( ; it.current() ; ++it )
00304 {
00305 it.current()->setStyle( m_currentStyle );
00306 it.current()->update();
00307 }
00308
00309 m_nameString->setText(m_currentStyle->displayName());
00310
00311 QString followingName = m_currentStyle->followingStyle() ? m_currentStyle->followingStyle()->displayName() : QString::null;
00312 kdDebug(32500) << "KoStyleManager::updateGUI updating combo to " << followingName << endl;
00313 for ( int i = 0; i < m_styleCombo->count(); i++ ) {
00314 if ( m_styleCombo->text( i ) == followingName ) {
00315 m_styleCombo->setCurrentItem( i );
00316 kdDebug(32500) << "found at " << i << endl;
00317 break;
00318 }
00319 }
00320
00321 QString inheritName = m_currentStyle->parentStyle() ? m_currentStyle->parentStyle()->displayName() : QString::null;
00322 kdDebug(32500) << "KoStyleManager::updateGUI updating combo to " << inheritName << endl;
00323 for ( int i = 0; i < m_inheritCombo->count(); i++ ) {
00324 if ( m_inheritCombo->text( i ) == inheritName ) {
00325 m_inheritCombo->setCurrentItem( i );
00326 kdDebug(32500) << "found at " << i << endl;
00327 break;
00328 }
00329 else
00330 m_inheritCombo->setCurrentItem( 0 );
00331 }
00332
00333 if ( d->cbIncludeInTOC )
00334 d->cbIncludeInTOC->setChecked( m_currentStyle->isOutline() );
00335
00336
00337 m_deleteButton->setEnabled(m_stylesList->currentItem() != 0);
00338
00339 m_moveUpButton->setEnabled(m_stylesList->currentItem() != 0);
00340 m_moveDownButton->setEnabled(m_stylesList->currentItem()!=(int)m_stylesList->count()-1);
00341
00342 updatePreview();
00343 }
00344
00345 void KoStyleManager::updatePreview()
00346 {
00347 d->preview->setStyle(m_currentStyle);
00348 d->preview->repaint(true);
00349 }
00350
00351 void KoStyleManager::save() {
00352 if(m_currentStyle) {
00353
00354 QPtrListIterator<KoStyleManagerTab> it( m_tabsList );
00355 for ( ; it.current() ; ++it )
00356 it.current()->save();
00357
00358
00359 if ( m_currentStyle->name() != m_nameString->text() &&
00360 m_currentStyle->displayName() != m_nameString->text() )
00361 {
00362 m_currentStyle->setDisplayName( m_nameString->text() );
00363 }
00364
00365 int indexNextStyle = styleIndex( m_styleCombo->currentItem() );
00366 m_currentStyle->setFollowingStyle( m_origStyles.at( indexNextStyle ) );
00367 m_currentStyle->setParentStyle( style( m_inheritCombo->currentText() ) );
00368 if ( d->cbIncludeInTOC )
00369 m_currentStyle->setOutline( d->cbIncludeInTOC->isChecked() );
00370 }
00371 }
00372
00373 KoParagStyle * KoStyleManager::style( const QString & _name )
00374 {
00375 for(unsigned int i=0; i < m_changedStyles.count(); i++) {
00376
00377 KoParagStyle * style = m_changedStyles.at(i);
00378 if ( !style ) continue;
00379 if ( style->name() == _name)
00380 return style;
00381 }
00382 return 0;
00383 }
00384
00385 QString KoStyleManager::generateUniqueName()
00386 {
00387 int count = 1;
00388 QString name;
00389 do {
00390 name = "new" + QString::number( count++ );
00391 } while ( style( name ) );
00392 return name;
00393 }
00394
00395
00396 void KoStyleManager::addStyle() {
00397 save();
00398
00399 QString str = i18n( "New Style Template (%1)" ).arg(numStyles++);
00400 if ( m_currentStyle )
00401 {
00402 m_currentStyle = new KoParagStyle( *m_currentStyle );
00403 m_currentStyle->setDisplayName( str );
00404 m_currentStyle->setName( generateUniqueName() );
00405 }
00406 else
00407 m_currentStyle = new KoParagStyle( str );
00408 m_currentStyle->setFollowingStyle( m_currentStyle );
00409
00410 noSignals=true;
00411 m_origStyles.append(0L);
00412 m_changedStyles.append(m_currentStyle);
00413 m_stylesList->insertItem( str );
00414 m_styleCombo->insertItem( str );
00415 m_inheritCombo->insertItem( str );
00416 m_stylesList->setCurrentItem( m_stylesList->count() - 1 );
00417 noSignals=false;
00418 m_styleOrder << m_currentStyle->name();
00419
00420 updateGUI();
00421 }
00422
00423 void KoStyleManager::updateFollowingStyle( KoParagStyle *s )
00424 {
00425 for ( KoParagStyle* p = m_changedStyles.first(); p != 0L; p = m_changedStyles.next() )
00426 {
00427 if ( p->followingStyle() == s)
00428 p->setFollowingStyle(p);
00429 }
00430
00431 }
00432
00433 void KoStyleManager::updateInheritStyle( KoParagStyle *s )
00434 {
00435 for ( KoParagStyle* p = m_changedStyles.first(); p != 0L; p = m_changedStyles.next() )
00436 {
00437
00438
00439
00440 if ( p->parentStyle() == s)
00441 p->setParentStyle(0L);
00442 }
00443
00444 }
00445
00446 void KoStyleManager::deleteStyle() {
00447
00448 unsigned int cur = styleIndex( m_stylesList->currentItem() );
00449 unsigned int curItem = m_stylesList->currentItem();
00450 QString name = m_stylesList->currentText();
00451 KoParagStyle *s = m_changedStyles.at(cur);
00452 m_styleOrder.remove( s->name());
00453 updateFollowingStyle( s );
00454 updateInheritStyle( s );
00455 Q_ASSERT( s == m_currentStyle );
00456 delete s;
00457 m_currentStyle = 0L;
00458 m_changedStyles.remove(cur);
00459 m_changedStyles.insert(cur,0L);
00460
00461
00462
00463 m_stylesList->removeItem(curItem);
00464 m_styleCombo->removeItem(curItem);
00465
00466 m_inheritCombo->listBox()->removeItem( m_inheritCombo->listBox()->index(m_inheritCombo->listBox()->findItem(name )));
00467
00468 numStyles--;
00469 m_stylesList->setSelected( m_stylesList->currentItem(), true );
00470 }
00471
00472 void KoStyleManager::moveUpStyle()
00473 {
00474 Q_ASSERT( m_currentStyle );
00475 if ( m_currentStyle )
00476 save();
00477 const QString currentStyleName = m_currentStyle->name();
00478 const QString currentStyleDisplayName = m_stylesList->currentText();
00479 int pos2 = m_styleOrder.findIndex( currentStyleName );
00480 if ( pos2 != -1 )
00481 {
00482 m_styleOrder.remove( m_styleOrder.at(pos2));
00483 m_styleOrder.insert( m_styleOrder.at(pos2-1), currentStyleName);
00484 }
00485
00486 int pos = m_stylesList->currentItem();
00487 noSignals=true;
00488 m_stylesList->changeItem( m_stylesList->text( pos-1 ), pos );
00489 m_styleCombo->changeItem( m_stylesList->text( pos-1 ), pos );
00490
00491 m_stylesList->changeItem( currentStyleDisplayName, pos-1 );
00492 m_styleCombo->changeItem( currentStyleDisplayName, pos-1 );
00493
00494 m_stylesList->setCurrentItem( m_stylesList->currentItem() );
00495 noSignals=false;
00496
00497 updateGUI();
00498 }
00499
00500 void KoStyleManager::moveDownStyle()
00501 {
00502 Q_ASSERT( m_currentStyle );
00503 if ( m_currentStyle )
00504 save();
00505 const QString currentStyleName = m_currentStyle->name();
00506 const QString currentStyleDisplayName = m_stylesList->currentText();
00507 int pos2 = m_styleOrder.findIndex( currentStyleName );
00508 if ( pos2 != -1 )
00509 {
00510 m_styleOrder.remove( m_styleOrder.at(pos2));
00511 m_styleOrder.insert( m_styleOrder.at(pos2+1), currentStyleName);
00512 }
00513
00514 int pos = m_stylesList->currentItem();
00515 noSignals=true;
00516 m_stylesList->changeItem( m_stylesList->text( pos+1 ), pos );
00517 m_styleCombo->changeItem( m_stylesList->text( pos+1 ), pos );
00518 m_stylesList->changeItem( currentStyleDisplayName, pos+1 );
00519 m_styleCombo->changeItem( currentStyleDisplayName, pos+1 );
00520 m_stylesList->setCurrentItem( m_stylesList->currentItem() );
00521 noSignals=false;
00522
00523 updateGUI();
00524 }
00525
00526 void KoStyleManager::slotOk() {
00527 save();
00528 apply();
00529 KDialogBase::slotOk();
00530 }
00531
00532 void KoStyleManager::slotApply() {
00533 save();
00534 apply();
00535 KDialogBase::slotApply();
00536 }
00537
00538 void KoStyleManager::apply() {
00539 noSignals=true;
00540 KoStyleChangeDefMap styleChanged;
00541 QPtrList<KoParagStyle> removeStyle;
00542 for (unsigned int i =0 ; m_origStyles.count() > i ; i++) {
00543 if(m_origStyles.at(i) == 0L && m_changedStyles.at(i)!=0L) {
00544 kdDebug(32500) << "adding new " << m_changedStyles.at(i)->name() << " (" << i << ")" << endl;
00545 KoParagStyle *tmp = addStyleTemplate(m_changedStyles.take(i));
00546 m_changedStyles.insert(i, tmp);
00547 } else if(m_changedStyles.at(i) == 0L && m_origStyles.at(i) != 0L) {
00548 kdDebug(32500) << "deleting orig " << m_origStyles.at(i)->name() << " (" << i << ")" << endl;
00549
00550 KoParagStyle *orig = m_origStyles.at(i);
00551
00552 KoStyleChangeDef tmp( -1,-1);
00553 styleChanged.insert( orig, tmp);
00554
00555 removeStyle.append( orig );
00556
00557
00558 } else if(m_changedStyles.at(i) != 0L && m_origStyles.at(i)!=0L) {
00559 kdDebug(32500) << "update style " << m_changedStyles.at(i)->name() << " (" << i << ")" << endl;
00560 KoParagStyle *orig = m_origStyles.at(i);
00561 KoParagStyle *changed = m_changedStyles.at(i);
00562 if ( orig != changed )
00563 {
00564 int paragLayoutChanged = orig->paragLayout().compare( changed->paragLayout() );
00565 int formatChanged = orig->format().compare( changed->format() );
00566
00567
00568
00569
00570 *orig = *changed;
00571
00572
00573
00574 if ( formatChanged != 0 || paragLayoutChanged != 0 ) {
00575 KoStyleChangeDef tmp(paragLayoutChanged, formatChanged);
00576 styleChanged.insert( orig, tmp );
00577 }
00578
00579 }
00580
00581 }
00582
00583 }
00584
00585 applyStyleChange( styleChanged );
00586
00587 KoParagStyle *tmp = 0L;
00588 for ( tmp = removeStyle.first(); tmp ;tmp = removeStyle.next() )
00589 removeStyleTemplate( tmp );
00590
00591 updateStyleListOrder( m_styleOrder );
00592 updateAllStyleLists();
00593 noSignals=false;
00594 }
00595
00596 void KoStyleManager::renameStyle(const QString &theText) {
00597 if(noSignals) return;
00598 noSignals=true;
00599
00600 int index = m_stylesList->currentItem();
00601 kdDebug(32500) << "KoStyleManager::renameStyle " << index << " to " << theText << endl;
00602
00603
00604 kdDebug(32500) << "KoStyleManager::renameStyle before " << m_styleCombo->currentText() << endl;
00605 m_styleCombo->changeItem( theText, index );
00606 m_inheritCombo->changeItem( theText, index+1 );
00607
00608 kdDebug(32500) << "KoStyleManager::renameStyle after " << m_styleCombo->currentText() << endl;
00609 m_stylesList->changeItem( theText, index );
00610
00611
00612 int synonyms = 0;
00613 for ( int i = 0; i < m_styleCombo->count(); i++ ) {
00614 if ( m_styleCombo->text( i ) == m_stylesList->currentText() )
00615 ++synonyms;
00616 }
00617 Q_ASSERT( synonyms > 0 );
00618 noSignals=false;
00619
00620 bool state=!theText.isEmpty() && (synonyms == 1);
00621 enableButtonOK(state );
00622 enableButtonApply(state);
00623 m_deleteButton->setEnabled(state&&(m_stylesList->currentItem() != 0));
00624 m_newButton->setEnabled(state);
00625 m_stylesList->setEnabled( state );
00626 if ( state )
00627 {
00628 m_moveUpButton->setEnabled(m_stylesList->currentItem() != 0);
00629 m_moveDownButton->setEnabled(m_stylesList->currentItem()!=(int)m_stylesList->count()-1);
00630 }
00631 else
00632 {
00633 m_moveUpButton->setEnabled(false);
00634 m_moveDownButton->setEnabled(false);
00635 }
00636 }
00637
00639
00640 KoStyleParagTab::KoStyleParagTab( QWidget * parent )
00641 : KoStyleManagerTab( parent )
00642 {
00643 ( new QVBoxLayout( this ) )->setAutoAdd( true );
00644 m_widget = 0L;
00645 }
00646
00647 void KoStyleParagTab::update()
00648 {
00649 m_widget->display( m_style->paragLayout() );
00650 }
00651
00652 void KoStyleParagTab::save()
00653 {
00654 m_widget->save( m_style->paragLayout() );
00655 }
00656
00657 void KoStyleParagTab::setWidget( KoParagLayoutWidget * widget )
00658 {
00659 m_widget = widget;
00660 }
00661
00662 void KoStyleParagTab::resizeEvent( QResizeEvent *e )
00663 {
00664 QWidget::resizeEvent( e );
00665 if ( m_widget ) m_widget->resize( size() );
00666 }
00667
00668 KoStyleFontTab::KoStyleFontTab( QWidget * parent )
00669 : KoStyleManagerTab( parent )
00670 {
00671 ( new QVBoxLayout( this ) )->setAutoAdd( true );
00672 QTabWidget *fontTabContainer = new QTabWidget( this );
00673
00674 m_fontTab = new KoFontTab( KFontChooser::SmoothScalableFonts, this );
00675 m_decorationTab = new KoDecorationTab( this );
00676 m_highlightingTab = new KoHighlightingTab( this );
00677 m_layoutTab = new KoLayoutTab( true, this );
00678 m_languageTab = new KoLanguageTab( 0, this );
00679
00680 fontTabContainer->addTab( m_fontTab, i18n( "Font" ) );
00681 fontTabContainer->addTab( m_decorationTab, i18n( "Decoration" ) );
00682 fontTabContainer->addTab( m_highlightingTab, i18n( "Highlighting" ) );
00683 fontTabContainer->addTab( m_layoutTab, i18n( "Layout" ) );
00684 fontTabContainer->addTab( m_languageTab, i18n( "Language" ) );
00685 }
00686
00687 KoStyleFontTab::~KoStyleFontTab()
00688 {
00689 }
00690
00691 void KoStyleFontTab::update()
00692 {
00693 m_fontTab->setSelection( m_style->format().font() );
00694 m_highlightingTab->setUnderline( m_style->format().underlineType() );
00695 m_highlightingTab->setUnderlineStyle( m_style->format().underlineStyle() );
00696 m_highlightingTab->setUnderlineColor( m_style->format().textUnderlineColor() );
00697 m_highlightingTab->setStrikethrough( m_style->format().strikeOutType() );
00698 m_highlightingTab->setStrikethroughStyle( m_style->format().strikeOutStyle() );
00699 m_highlightingTab->setWordByWord( m_style->format().wordByWord() );
00700 m_highlightingTab->setCapitalisation( m_style->format().attributeFont() );
00701 m_decorationTab->setTextColor( m_style->format().color() );
00702 m_decorationTab->setBackgroundColor( m_style->format().textBackgroundColor() );
00703 m_decorationTab->setShadow( m_style->format().shadowDistanceX(), m_style->format().shadowDistanceY(), m_style->format().shadowColor() );
00704 m_layoutTab->setSubSuperScript( m_style->format().vAlign(), m_style->format().offsetFromBaseLine(), m_style->format().relativeTextSize() );
00705 m_layoutTab->setAutoHyphenation( m_style->format().hyphenation() );
00706 m_languageTab->setLanguage( m_style->format().language() );
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734 }
00735
00736 void KoStyleFontTab::save()
00737 {
00738 m_style->format() = KoTextFormat( m_fontTab->getSelection(),
00739 m_layoutTab->getSubSuperScript(),
00740 m_decorationTab->getTextColor(),
00741 m_decorationTab->getBackgroundColor(),
00742 m_highlightingTab->getUnderlineColor(),
00743 m_highlightingTab->getUnderline(),
00744 m_highlightingTab->getUnderlineStyle(),
00745 m_highlightingTab->getStrikethrough(),
00746 m_highlightingTab->getStrikethroughStyle(),
00747 m_highlightingTab->getCapitalisation(),
00748 m_languageTab->getLanguage(),
00749 m_layoutTab->getRelativeTextSize(),
00750 m_layoutTab->getOffsetFromBaseline(),
00751 m_highlightingTab->getWordByWord(),
00752 m_layoutTab->getAutoHyphenation(),
00753 m_decorationTab->getShadowDistanceX(),
00754 m_decorationTab->getShadowDistanceY(),
00755 m_decorationTab->getShadowColor()
00756 );
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777 }
00778
00779 QString KoStyleFontTab::tabName()
00780 {
00781 return i18n("Font");
00782 }