22#include "KoParagDia.h"
23#include "KoParagDia_p.h"
24#include "KoDocument.h"
25#include "KoTextFormat.h"
26#include "KoTextParag.h"
27#include "KoTextDocument.h"
28#include "KoTextZoomHandler.h"
29#include "KoParagDecorationTab.h"
31#include <KoCharSelectDia.h>
32#include <KoUnitWidgets.h>
33#include <kcolorbutton.h>
35#include <kiconloader.h>
37#include <knumvalidator.h>
39#include <tqgroupbox.h>
41#include <tdeversion.h>
42#include <kpushbutton.h>
45#include <tqcheckbox.h>
46#include <tqcombobox.h>
47#include <tqhbuttongroup.h>
49#include <tqradiobutton.h>
54#include <tqapplication.h>
55#include <tqwidgetstack.h>
57KoCounterStyleWidget::KoCounterStyleWidget(
bool displayDepth,
bool onlyStyleTypeLetter,
bool disableAll, TQWidget * parent,
const char* name )
58 :TQWidget( parent,
name ),
63 TQVBoxLayout *vbox =
new TQVBoxLayout(
this,0, 0 );
64 gStyle =
new TQGroupBox( i18n(
"St&yle" ),
this,
"styleLayout" );
65 vbox->addWidget( gStyle);
67 grid->addRowSpacing(0, fontMetrics().height()/2);
69 makeCounterRepresenterList( stylesList, onlyStyleTypeLetter );
71 lstStyle =
new TQListBox( gStyle,
"styleListBox" );
72 grid->addMultiCellWidget( lstStyle, 1, 11, 0, 0);
74 connect( lstStyle, TQ_SIGNAL( selectionChanged() ),
this, TQ_SLOT( numStyleChanged() ) );
77 TQLabel *lPrefix =
new TQLabel( gStyle,
"lPrefix" );
78 lPrefix->setText( i18n(
"Pre&fix text:" ) );
79 grid->addWidget( lPrefix, 1, 1);
81 sPrefix =
new TQLineEdit( gStyle,
"sPrefix" );
82 lPrefix->setBuddy( sPrefix );
83 grid->addWidget( sPrefix, 1, 2);
85 TQLabel *lSuffix =
new TQLabel( gStyle,
"lSuffix" );
86 lSuffix->setText( i18n(
"Suffi&x text:" ) );
87 grid->addWidget( lSuffix, 1, 3);
89 sSuffix =
new TQLineEdit( gStyle,
"sSuffix" );
90 lSuffix->setBuddy( sSuffix );
91 grid->addWidget( sSuffix, 1, 4 );
93 lStart =
new TQLabel( gStyle,
"lStart" );
94 lStart->setText( i18n(
"&Start at:" ) );
95 grid->addWidget( lStart, 2, 1 );
98 spnDepth =
new TQSpinBox( 0, 15, 1, gStyle );
100 grid->addWidget( spnDepth, 3, 2 );
104 spnDisplayLevels =
new TQSpinBox( 0, 15, 1, gStyle );
105 spnDisplayLevels->setMinValue( 1 );
107 grid->addWidget( spnDisplayLevels, 3, 4 );
109 spnDisplayLevels->hide();
112 TQHBoxLayout *customCharBox =
new TQHBoxLayout(0, 0, 6);
113 lCustom =
new TQLabel( i18n(
"Custo&m character:" ), gStyle,
"custom char label" );
114 customCharBox->addWidget( lCustom );
116 bCustom =
new TQPushButton(
"", gStyle,
"bCustom" );
117 lCustom->setBuddy( bCustom );
118 customCharBox->addWidget( bCustom );
119 connect( bCustom, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( selectCustomBullet() ) );
121 TQSpacerItem* spacer_2 =
new TQSpacerItem( 0, 0, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
122 customCharBox->addItem( spacer_2 );
124 grid->addMultiCellLayout(customCharBox, 4, 4, 1, 4, TQt::AlignLeft);
126 spnStart =
new KoSpinBox( gStyle );
127 spnStart->setMinValue ( 1);
128 lStart->setBuddy( spnStart );
129 grid->addWidget( spnStart, 2, 2);
131 lAlignment =
new TQLabel( gStyle,
"lAlignment" );
132 lAlignment->setText( i18n(
"Counter alignment:" ) );
133 grid->addWidget( lAlignment, 2, 3 );
135 cbAlignment =
new KComboBox( gStyle,
"cbAlignment" );
136 cbAlignment->insertItem(i18n(
"Align Auto"));
137 cbAlignment->insertItem(i18n(
"Align Left"));
138 cbAlignment->insertItem(i18n(
"Align Right"));
139 cbAlignment->setCurrentItem(0);
140 grid->addWidget( cbAlignment, 2, 4 );
142 TQLabel *lDepth =
new TQLabel( gStyle,
"lDepth" );
143 lDepth->setText( i18n(
"&Depth:" ) );
144 lDepth->setBuddy( spnDepth );
146 grid->addWidget( lDepth, 3, 1 );
150 TQLabel *lDisplayLevels =
new TQLabel( gStyle );
151 lDisplayLevels->setText( i18n(
"Display le&vels:" ) );
152 lDisplayLevels->setBuddy( spnDisplayLevels );
154 grid->addWidget( lDisplayLevels, 3, 3 );
156 lDisplayLevels->hide();
158 cbRestart =
new TQCheckBox( i18n(
"&Restart numbering at this paragraph" ), gStyle );
159 grid->addMultiCellWidget( cbRestart, 5, 5, 1, 3 );
161 if ( onlyStyleTypeLetter )
169 connect( cbRestart, TQ_SIGNAL( toggled(
bool) ),
this, TQ_SLOT( restartChanged(
bool) ) );
171 connect( sSuffix, TQ_SIGNAL( textChanged (
const TQString &) ),
this, TQ_SLOT( suffixChanged(
const TQString &) ) );
172 connect( sPrefix, TQ_SIGNAL( textChanged (
const TQString &) ),
this, TQ_SLOT( prefixChanged(
const TQString &) ) );
173 connect( spnStart, TQ_SIGNAL( valueChanged (
int) ),
this, TQ_SLOT( startChanged(
int) ) );
174 connect( spnDepth, TQ_SIGNAL( valueChanged (
int) ),
this, TQ_SLOT( depthChanged(
int) ) );
175 connect( spnDisplayLevels, TQ_SIGNAL( valueChanged (
int) ),
this, TQ_SLOT( displayLevelsChanged(
int) ) );
176 connect( cbAlignment, TQ_SIGNAL( activated (
const TQString&) ),
this, TQ_SLOT( alignmentChanged(
const TQString&) ) );
180 gStyle->setEnabled(
false );
181 lstStyle->setEnabled(
false );
182 sSuffix->setEnabled(
false );
183 sPrefix->setEnabled(
false );
184 bCustom->setEnabled(
false );
185 spnStart->setEnabled(
false );
186 spnDepth->setEnabled(
false );
187 spnDisplayLevels->setEnabled(
false );
188 lStart->setEnabled(
false );
189 lCustom->setEnabled(
false );
190 cbRestart->setEnabled(
false );
191 cbAlignment->setEnabled(
false );
195void KoCounterStyleWidget::alignmentChanged(
const TQString& s)
198 if(s==i18n(
"Align Left"))
200 else if(s==i18n(
"Align Right"))
202 else if(s==i18n(
"Align Auto"))
205 kdError()<<
"Not Implemented"<<endl;
208 m_counter.setAlignment(a);
209 emit sig_alignmentChanged(a);
212void KoCounterStyleWidget::setCounter(
const KoParagCounter& counter )
215 KoParagCounter::Style st = counter.style();
219 changeKWSpinboxType( st);
224void KoCounterStyleWidget::changeKWSpinboxType(KoParagCounter::Style st) {
227 case KoParagCounter::STYLE_NONE:
228 spnStart->setCounterType(KoSpinBox::NONE);
230 case KoParagCounter::STYLE_NUM:
231 spnStart->setCounterType(KoSpinBox::NUM);
233 case KoParagCounter::STYLE_ALPHAB_L:
234 spnStart->setCounterType(KoSpinBox::ALPHAB_L);
236 case KoParagCounter::STYLE_ALPHAB_U:
237 spnStart->setCounterType(KoSpinBox::ALPHAB_U);
239 case KoParagCounter::STYLE_ROM_NUM_L:
240 spnStart->setCounterType(KoSpinBox::ROM_NUM_L);
242 case KoParagCounter::STYLE_ROM_NUM_U:
243 spnStart->setCounterType(KoSpinBox::ROM_NUM_U);
246 spnStart->setCounterType(KoSpinBox::NONE);
251void KoCounterStyleWidget::fillStyleCombo(KoParagCounter::Numbering type) {
252 if(lstStyle==NULL)
return;
254 unsigned int cur = lstStyle->currentItem();
256 TQPtrListIterator<StyleRepresenter> style( stylesList );
257 while ( style.current() ) {
258 if(style.current()->style() == KoParagCounter::STYLE_NONE) {
259 if(type == KoParagCounter::NUM_NONE)
260 lstStyle->insertItem( style.current()->name() );
262 else if(type == KoParagCounter::NUM_LIST || !style.current()->isBullet())
263 if(type != KoParagCounter::NUM_NONE)
264 lstStyle->insertItem( style.current()->name() );
268 if(styleBuffer <= lstStyle->count())
269 lstStyle->setCurrentItem(styleBuffer);
271 if(cur <= lstStyle->count())
272 lstStyle->setCurrentItem(cur);
274 if(cur > lstStyle->count()) {
280void KoCounterStyleWidget::displayStyle( KoParagCounter::Style style )
283 while ( stylesList.count() > i && stylesList.at(i)->style() != style )
285 lstStyle->setCurrentItem(i);
287 bCustom->setText( m_counter.customBulletCharacter() );
288 if ( !m_counter.customBulletFont().isEmpty() )
289 bCustom->setFont( TQFont( m_counter.customBulletFont() ) );
291 sPrefix->setText( m_counter.prefix() );
292 sSuffix->setText( m_counter.suffix() );
294 spnDepth->setValue( m_counter.depth() );
295 spnDisplayLevels->setValue( m_counter.displayLevels() );
296 spnStart->setValue( m_counter.startNumber() );
298 cbRestart->setChecked( m_counter.restartCounter() );
299 if(m_counter.alignment()==TQt::AlignLeft)
300 cbAlignment->setCurrentText(i18n(
"Align Left"));
301 else if(m_counter.alignment()==TQt::AlignRight)
302 cbAlignment->setCurrentText(i18n(
"Align Right"));
303 else if(m_counter.alignment()==TQt::AlignAuto)
304 cbAlignment->setCurrentText(i18n(
"Align Auto"));
306 kdError()<<
"Not Implemented"<<endl;
309void KoCounterStyleWidget::display(
const KoParagLayout & lay ) {
310 KoParagCounter::Style style = KoParagCounter::STYLE_NONE;
322 numTypeChanged( m_counter.numbering() );
323 emit sig_numTypeChanged( m_counter.numbering() );
325 displayStyle( style );
329void KoCounterStyleWidget::numTypeChanged(
int nType ) {
330 m_counter.setNumbering(
static_cast<KoParagCounter::Numbering
>( nType ) );
331 gStyle->setEnabled( m_counter.numbering() != KoParagCounter::NUM_NONE );
332 fillStyleCombo(m_counter.numbering());
333 bool state=m_counter.numbering()==KoParagCounter::NUM_LIST;
334 bCustom->setEnabled(state);
335 lCustom->setEnabled(state);
339void KoCounterStyleWidget::makeCounterRepresenterList( TQPtrList<StyleRepresenter>& stylesList,
bool onlyStyleTypeLetter )
341 stylesList.setAutoDelete(
true );
342 stylesList.append(
new StyleRepresenter(i18n(
"Arabic Numbers" )
343 , KoParagCounter::STYLE_NUM));
344 stylesList.append(
new StyleRepresenter(i18n(
"Lower Alphabetical" )
345 , KoParagCounter::STYLE_ALPHAB_L ));
346 stylesList.append(
new StyleRepresenter(i18n(
"Upper Alphabetical" )
347 , KoParagCounter::STYLE_ALPHAB_U ));
348 stylesList.append(
new StyleRepresenter(i18n(
"Lower Roman Numbers" )
349 , KoParagCounter::STYLE_ROM_NUM_L ));
350 stylesList.append(
new StyleRepresenter(i18n(
"Upper Roman Numbers" )
351 , KoParagCounter::STYLE_ROM_NUM_U ));
352 if ( !onlyStyleTypeLetter )
354 stylesList.append(
new StyleRepresenter(i18n(
"Disc Bullet" )
355 , KoParagCounter::STYLE_DISCBULLET ,
true));
356 stylesList.append(
new StyleRepresenter(i18n(
"Square Bullet" )
357 , KoParagCounter::STYLE_SQUAREBULLET ,
true));
358 stylesList.append(
new StyleRepresenter(i18n(
"Box Bullet" )
359 , KoParagCounter::STYLE_BOXBULLET ,
true));
360 stylesList.append(
new StyleRepresenter(i18n(
"Circle Bullet" )
361 , KoParagCounter::STYLE_CIRCLEBULLET ,
true));
362 stylesList.append(
new StyleRepresenter(i18n(
"Custom Bullet" )
363 , KoParagCounter::STYLE_CUSTOMBULLET ,
true));
365 stylesList.append(
new StyleRepresenter(i18n(
"None" ), KoParagCounter::STYLE_NONE));
369void KoCounterStyleWidget::selectCustomBullet() {
371 while ( stylesList.count() > i && stylesList.at(i)->style() != KoParagCounter::STYLE_CUSTOMBULLET )
373 lstStyle->setCurrentItem(i);
375 TQString f = m_counter.customBulletFont();
378 TQChar c = m_counter.customBulletCharacter();
380 if ( KoCharSelectDia::selectChar( f, c ) ) {
381 emit changeCustomBullet( f, c );
382 m_counter.setCustomBulletFont( f );
383 m_counter.setCustomBulletCharacter( c );
385 bCustom->setFont( TQFont( f ) );
386 bCustom->setText( c );
390void KoCounterStyleWidget::numStyleChanged() {
395 StyleRepresenter *sr = stylesList.at(lstStyle->currentItem());
396 emit changeStyle( sr->style() );
397 m_counter.setStyle( sr->style() );
398 bool isNumbered = !sr->isBullet() && !sr->style() == KoParagCounter::STYLE_NONE;
399 lStart->setEnabled( isNumbered );
400 spnStart->setEnabled( isNumbered );
401 cbRestart->setEnabled( isNumbered );
402 spnDisplayLevels->setEnabled( isNumbered );
403 changeKWSpinboxType(sr->style() );
408KoSpinBox::KoSpinBox( TQWidget * parent,
const char * name )
409 : TQSpinBox(parent,
name)
413 setMaxValue ( 3999 );
415KoSpinBox::~KoSpinBox( )
419KoSpinBox::KoSpinBox(
int minValue,
int maxValue,
int step ,
420 TQWidget * parent ,
const char * name )
421 : TQSpinBox(minValue, maxValue,step ,
427void KoSpinBox::setCounterType(counterType _type)
430 editor()->setText(mapValueToText(value()));
434TQString KoSpinBox::mapValueToText(
int value )
436 if(value==0 && m_Etype==NUM)
437 return TQString(
"0");
438 else if(value==0 && m_Etype!=NUM)
443 return TQString::number(value);
445 return KoParagCounter::makeAlphaLowerNumber( value );
447 return KoParagCounter::makeAlphaUpperNumber( value );
449 return KoParagCounter::makeRomanNumber( value );
451 return KoParagCounter::makeRomanNumber( value ).upper();
460int KoSpinBox::mapTextToValue(
bool * ok )
463 TQString txt = text();
469 ret = txt.toInt ( ok );
472 ret = KoParagCounter::fromAlphaLowerNumber( txt.lower() );
475 ret = KoParagCounter::fromAlphaUpperNumber( txt.upper() );
478 ret = KoParagCounter::fromRomanNumber( txt.lower() );
481 ret = KoParagCounter::fromRomanNumber( txt.lower() );
500KPagePreview::KPagePreview( TQWidget* parent,
const char* name )
501 : TQGroupBox( i18n(
"Preview" ), parent,
name )
511void KPagePreview::drawContents( TQPainter* p )
515 int _x = ( width() - wid ) / 5;
516 int _y = ( height() - hei ) / 5;
518 int dl = convert(left);
519 int dr = convert(right);
522 int df = convert(first + left);
524 int spc = convert(spacing);
527 p->setPen( TQPen( black ) );
528 p->setBrush( TQBrush( black ) );
530 p->drawRect( _x + 1, _y + 1, wid, hei );
532 p->setBrush( TQBrush( white ) );
533 p->drawRect( _x, _y, wid, hei );
537 p->setBrush( TQBrush( lightGray ) );
539 for (
int i = 1; i <= 4; i++ )
540 p->drawRect( _x + 6, _y + 6 + ( i - 1 ) * 12 + 2, wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ), 6 );
542 p->setBrush( TQBrush( darkGray ) );
544 for (
int i = 5; i <= 8; i++ )
546 TQRect rect( ( i == 5 ? df : dl ) + _x + 6, _y + 6 + ( i - 1 ) * 12 + 2 + ( i - 5 ) * spc + static_cast<int>( before / 2 ),
547 wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ) - ( ( i == 12 ? 0 : dr ) + ( i == 5 ? df : dl ) ), 6);
552 p->setBrush( TQBrush( lightGray ) );
554 for (
int i = 9; i <= 12; i++ )
555 p->drawRect( _x + 6, _y + 6 + ( i - 1 ) * 12 + 2 + 3 * spc +
556 static_cast<int>( before / 2 ) +
static_cast<int>( after / 2 ),
557 wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ), 6 );
561int KPagePreview::convert(
double input) {
562 if(input < 1)
return 0;
563 if(input <= 5)
return 3;
564 if(input <= 10)
return 4 +
static_cast<int>( (input-5) / 2.5 );
565 if(input <= 20)
return 6 +
static_cast<int>( (input-10) / 4 );
566 if(input <= 100)
return 10 +
static_cast<int>( (input-20) / 8 );
567 return static_cast<int>( input / 5);
574KPagePreview2::KPagePreview2( TQWidget* parent,
const char* name )
575 : TQGroupBox( i18n(
"Preview" ), parent,
name )
577 align = TQt::AlignLeft;
580void KPagePreview2::drawContents( TQPainter* p )
584 int _x = ( width() - wid ) / 2;
585 int _y = ( height() - hei ) / 2;
588 p->setPen( TQPen( black ) );
589 p->setBrush( TQBrush( black ) );
591 p->drawRect( _x + 1, _y + 1, wid, hei );
593 p->setBrush( TQBrush( white ) );
594 p->drawRect( _x, _y, wid, hei );
598 p->setBrush( TQBrush( lightGray ) );
600 for (
int i = 1; i <= 4; i++ )
601 p->drawRect( _x + 6, _y + 6 + ( i - 1 ) * 12 + 2, wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ), 6 );
603 p->setBrush( TQBrush( darkGray ) );
605 int __x = 0, __w = 0;
606 for (
int i = 5; i <= 8; i++ ) {
608 case 5: __w = wid - 12;
610 case 6: __w = wid - 52;
612 case 7: __w = wid - 33;
614 case 8: __w = wid - 62;
623 case TQt::AlignHCenter:
624 __x = _x + ( wid - __w ) / 2;
626 case TQt::AlignRight:
627 __x = _x + ( wid - __w ) - 6;
629 case TQt::AlignJustify:
631 if ( i < 8 ) __w = wid - 12;
636 p->drawRect( __x, _y + 6 + ( i - 1 ) * 12 + 2 + ( i - 5 ), __w, 6 );
639 p->setBrush( TQBrush( lightGray ) );
641 for (
int i = 9; i <= 12; i++ )
642 p->drawRect( _x + 6, _y + 6 + ( i - 1 ) * 12 + 2 + 3, wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ), 6 );
651KoBorderPreview::KoBorderPreview( TQWidget* parent,
const char* name )
652 :TQFrame(parent,
name)
656void KoBorderPreview::mousePressEvent( TQMouseEvent *_ev )
658 emit choosearea(_ev);
661void KoBorderPreview::setBorder( KoBorder::BorderType which,
const KoBorder& border)
664 case KoBorder::TopBorder:
665 setTopBorder( border );
667 case KoBorder::BottomBorder:
668 setBottomBorder( border );
670 case KoBorder::LeftBorder:
671 setLeftBorder( border );
673 case KoBorder::RightBorder:
674 setRightBorder( border );
677 kdError() <<
"KoBorderPreview: unknown border type" << endl;
681void KoBorderPreview::drawContents( TQPainter* painter )
683 TQRect r = contentsRect();
684 TQFontMetrics fm( font() );
686 painter->fillRect( r.x() + fm.width(
'W' ), r.y() + fm.height(), r.width() - 2 * fm.width(
'W' ),
687 r.height() - 2 * fm.height(), white );
688 painter->setClipRect( r.x() + fm.width(
'W' ), r.y() + fm.height(), r.width() - 2 * fm.width(
'W' ),
689 r.height() - 2 * fm.height() );
691 bool leftdouble = m_leftBorder.width() > 0 && m_leftBorder.getStyle() == KoBorder::DOUBLE_LINE;
692 bool rightdouble = m_rightBorder.width() > 0 && m_rightBorder.getStyle() == KoBorder::DOUBLE_LINE;
693 bool topdouble = m_topBorder.width() > 0 && m_topBorder.getStyle() == KoBorder::DOUBLE_LINE;
694 bool bottomdouble = m_bottomBorder.width() > 0 && m_bottomBorder.getStyle() == KoBorder::DOUBLE_LINE;
696 if ( m_topBorder.width() > 0 ) {
697 painter->setPen( setBorderPen( m_topBorder ) );
698 painter->drawLine( r.x() + 20, r.y() + 30, r.right() - 19, r.y() + 30 );
699 if ( m_topBorder.getStyle()==KoBorder::DOUBLE_LINE)
700 painter->drawLine(
int(r.x() + 20 + ( leftdouble ? m_leftBorder.width() + 1 : 0) ),
701 int(r.y() + 30 + m_topBorder.width()+1),
702 int(r.right() - 19 - ( rightdouble ? m_rightBorder.width() + 1 : 0) ),
703 int(r.y() + 30 + m_topBorder.width()+1)
707 if ( m_bottomBorder.width() > 0 ) {
708 painter->setPen( setBorderPen( m_bottomBorder ) );
709 painter->drawLine( r.x() + 20, r.bottom() - 30, r.right() - 19, r.bottom() - 30 );
710 if ( m_bottomBorder.getStyle()==KoBorder::DOUBLE_LINE)
711 painter->drawLine(
int(r.x() + 20 + ( leftdouble ? m_leftBorder.width() + 1 : 0) ),
712 int(r.bottom() - 30 - m_bottomBorder.width()-1),
713 int(r.right() - 19 - ( rightdouble ? m_rightBorder.width() + 1 : 0) ),
714 int(r.bottom() - 30 - m_bottomBorder.width() - 1)
718 if ( m_leftBorder.width() > 0 ) {
719 painter->setPen( setBorderPen( m_leftBorder ) );
720 painter->drawLine( r.x() + 20, r.y() + 30, r.x() + 20, r.bottom() - 29 );
721 if ( m_leftBorder.getStyle()==KoBorder::DOUBLE_LINE)
722 painter->drawLine(
int(r.x() + 20 + m_leftBorder.width() +1),
723 int(r.y() + 30 + ( topdouble ? m_topBorder.width() + 1 : 0) ),
724 int(r.x() + 20 + m_leftBorder.width() +1),
725 int(r.bottom() - 29 - ( bottomdouble ? m_bottomBorder.width() + 1 : 0) )
729 if ( m_rightBorder.width() > 0 ) {
730 painter->setPen( setBorderPen( m_rightBorder ) );
731 painter->drawLine( r.right() - 20, r.y() + 30, r.right() - 20, r.bottom() - 29 );
732 if ( m_rightBorder.getStyle()==KoBorder::DOUBLE_LINE)
733 painter->drawLine(
int(r.right() - 20 - m_rightBorder.width() - 1 ),
734 int(r.y() + 30 + ( topdouble ? m_topBorder.width() + 1 : 0) ),
735 int(r.right() - 20 - m_rightBorder.width() - 1),
736 int(r.bottom() - 29 - ( bottomdouble ? m_bottomBorder.width() + 1 : 0) )
741TQPen KoBorderPreview::setBorderPen(
KoBorder _brd )
743 TQPen pen( black, 1, SolidLine );
745 pen.setWidth(
static_cast<int>( _brd.penWidth() ) );
746 pen.setColor( _brd.color );
748 switch ( _brd.getStyle() ) {
749 case KoBorder::SOLID:
750 pen.setStyle( TQt::SolidLine );
753 pen.setStyle( TQt::DashLine );
756 pen.setStyle( TQt::DotLine );
758 case KoBorder::DASH_DOT:
759 pen.setStyle( TQt::DashDotLine );
761 case KoBorder::DASH_DOT_DOT:
762 pen.setStyle( TQt::DashDotDotLine );
764 case KoBorder::DOUBLE_LINE:
765 pen.setStyle( TQt::SolidLine );
775class MyFlow :
public KoTextFlow {
779 m_zoomHandler =
zoom;
781 int availableHeight()
const {
782 return m_zoomHandler->pixelToLayoutUnitY(m_parent->height());
789KoStylePreview::KoStylePreview(
const TQString& title,
const TQString& text, TQWidget* parent,
const char* name )
790 : TQGroupBox( title, parent,
name )
792 setMinimumHeight(80);
794 TQFont font = KoGlobal::defaultFont();
795 m_textdoc =
new KoTextDocument( m_zoomHandler,
new KoTextFormatCollection( font, TQColor(), TDEGlobal::locale()->language(),
false ) );
797 m_textdoc->setFlow(
new MyFlow(
this, m_zoomHandler) );
799 KoTextParag * parag = m_textdoc->firstParag();
800 parag->insert( 0, text );
803KoStylePreview::~KoStylePreview()
806 delete m_zoomHandler;
811 KoTextParag * parag = m_textdoc->firstParag();
812 parag->setCounter( counter );
818 KoTextParag * parag = m_textdoc->firstParag();
819 parag->applyStyle( style );
823void KoStylePreview::drawContents( TQPainter *painter )
826 TQRect r = contentsRect();
829 TQRect whiteRect( r.x() + 10, r.y() + 10,
830 r.width() - 20, r.height() - 20 );
831 TQColorGroup cg = TQApplication::palette().active();
832 painter->fillRect( whiteRect, cg.brush( TQColorGroup::Base ) );
834 KoTextParag * parag = m_textdoc->firstParag();
836 if ( m_textdoc->width() != widthLU )
839 m_textdoc->setWidth( widthLU );
840 parag->invalidate(0);
844 TQRect textRect = parag->pixelRect( m_zoomHandler );
847 textRect.moveTopLeft( TQPoint( whiteRect.x(),
848 whiteRect.y() + ( whiteRect.height() - textRect.height() ) / 2 ) );
850 textRect.rLeft() += 4;
851 textRect.rRight() += 4;
854 painter->setClipRect( textRect.intersect( whiteRect ) );
855 painter->translate( textRect.x(), textRect.y() );
857 m_textdoc->drawWYSIWYG( painter, 0, 0, textRect.width(), textRect.height(), cg, m_zoomHandler );
861KoIndentSpacingWidget::KoIndentSpacingWidget(
KoUnit::Unit unit,
double _frameWidth,TQWidget * parent,
const char * name )
874 double frameWidth=_frameWidth;
879 length=i18n(
"Frame width: %1 %2")
885 TQGroupBox * indentFrame =
new TQGroupBox( i18n(
"Indent" ),
this );
888 TQLabel * lLimit =
new TQLabel(length , indentFrame );
891 lLimit->setAlignment( AlignRight );
892 indentGrid->addWidget( lLimit, 1,0 );
895 TQLabel * lLeft =
new TQLabel( i18n(
"&Left:"), indentFrame );
896 lLeft->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
897 indentGrid->addWidget( lLeft, 1, 0 );
900 lLeft->setBuddy( eLeft );
901 indentGrid->addWidget( eLeft, 1, 1 );
902 connect( eLeft, TQ_SIGNAL( valueChangedPt(
double ) ),
this, TQ_SLOT( leftChanged(
double ) ) );
904 TQLabel * lRight =
new TQLabel( i18n(
"&Right:"), indentFrame );
905 lRight->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
906 indentGrid->addWidget( lRight, 2, 0 );
909 lRight->setBuddy( eRight );
910 indentGrid->addWidget( eRight, 2, 1 );
911 connect( eRight, TQ_SIGNAL( valueChangedPt(
double ) ),
this, TQ_SLOT( rightChanged(
double ) ) );
913 TQLabel * lFirstLine =
new TQLabel( i18n(
"&First line:"), indentFrame );
914 lFirstLine->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
915 indentGrid->addWidget( lFirstLine, 3, 0 );
918 lFirstLine->setBuddy( eFirstLine );
919 connect( eFirstLine, TQ_SIGNAL( valueChangedPt(
double ) ),
this, TQ_SLOT( firstChanged(
double ) ) );
920 indentGrid->addWidget( eFirstLine, 3, 1 );
923 indentGrid->addRowSpacing( 0, fontMetrics().height() / 2 );
924 for (
int i = 1 ; i < indentGrid->numRows() ; ++i )
925 indentGrid->setRowStretch( i, 1 );
926 mainGrid->addWidget( indentFrame, 0, 0 );
929 TQGroupBox * spacingFrame =
new TQGroupBox( i18n(
"Line &Spacing" ),
this,
"spacingFrame" );
930 TQGridLayout * spacingGrid =
new TQGridLayout( spacingFrame, 2, 1,
933 cSpacing =
new TQComboBox(
false, spacingFrame,
"" );
935 cSpacing->insertItem( i18n(
"Line spacing value",
"Single" ) );
936 cSpacing->insertItem( i18n(
"Line spacing value",
"1.5 Lines" ) );
937 cSpacing->insertItem( i18n(
"Line spacing value",
"Double" ) );
938 cSpacing->insertItem( i18n(
"Proportional") );
939 cSpacing->insertItem( i18n(
"Line Distance (%1)" ).arg(unitName) );
940 cSpacing->insertItem( i18n(
"At Least (%1)" ).arg(unitName) );
941 cSpacing->insertItem( i18n(
"Fixed (%1)").arg(unitName) );
943 connect( cSpacing, TQ_SIGNAL( activated(
int ) ),
this, TQ_SLOT( spacingActivated(
int ) ) );
944 spacingGrid->addWidget( cSpacing, 1, 0 );
946 sSpacingStack =
new TQWidgetStack( spacingFrame );
950 eSpacing->setRange( 0, 9999, 1,
false);
951 connect( eSpacing, TQ_SIGNAL( valueChanged(
double ) ),
this, TQ_SLOT( spacingChanged(
double ) ) );
952 eSpacingPercent =
new KIntNumInput( 100, spacingFrame );
953 eSpacingPercent->setRange( 0, 1000, 10,
false );
954 eSpacingPercent->setSuffix(
" %" );
955 connect( eSpacingPercent, TQ_SIGNAL( valueChanged(
int ) ),
this, TQ_SLOT( spacingChanged(
int ) ) );
957 sSpacingStack->addWidget( eSpacing );
958 sSpacingStack->addWidget( eSpacingPercent );
959 spacingGrid->addWidget( sSpacingStack, 1, 1 );
962 spacingGrid->addRowSpacing( 0, fontMetrics().height() / 2 );
963 for (
int i = 1 ; i < spacingGrid->numRows() ; ++i )
964 spacingGrid->setRowStretch( i, 1 );
965 mainGrid->addWidget( spacingFrame, 1, 0 );
967 eSpacing->setEnabled(
true );
970 TQGroupBox * pSpaceFrame =
new TQGroupBox( i18n(
"Para&graph Space" ),
this,
"pSpaceFrame" );
971 TQGridLayout * pSpaceGrid =
new TQGridLayout( pSpaceFrame, 3, 2,
974 TQLabel * lBefore =
new TQLabel( i18n(
"Before:"), pSpaceFrame );
975 lBefore->setAlignment( AlignRight );
976 pSpaceGrid->addWidget( lBefore, 1, 0 );
979 eBefore->setRange( 0 , 9999, 1,
false);
980 connect( eBefore, TQ_SIGNAL( valueChanged(
double ) ),
this, TQ_SLOT( beforeChanged(
double ) ) );
981 pSpaceGrid->addWidget( eBefore, 1, 1 );
983 TQLabel * lAfter =
new TQLabel( i18n(
"After:"), pSpaceFrame );
984 lAfter->setAlignment( AlignRight );
985 pSpaceGrid->addWidget( lAfter, 2, 0 );
988 eAfter->setRange( 0, 9999, 1,
false);
989 connect( eAfter, TQ_SIGNAL( valueChanged(
double ) ),
this, TQ_SLOT( afterChanged(
double ) ) );
990 pSpaceGrid->addWidget( eAfter, 2, 1 );
993 pSpaceGrid->addRowSpacing( 0, fontMetrics().height() / 2 );
994 for (
int i = 1 ; i < pSpaceGrid->numRows() ; ++i )
995 pSpaceGrid->setRowStretch( i, 1 );
996 mainGrid->addWidget( pSpaceFrame, 2, 0 );
999 prev1 =
new KPagePreview(
this,
"KPagePreview" );
1000 mainGrid->addMultiCellWidget( prev1, 0, mainGrid->numRows()-1, 1, 1 );
1002 mainGrid->setColStretch( 1, 1 );
1006double KoIndentSpacingWidget::leftIndent()
const
1008 return TQMAX(0, eLeft->
value() );
1011double KoIndentSpacingWidget::rightIndent()
const
1013 return TQMAX(0,eRight->
value() );
1016double KoIndentSpacingWidget::firstLineIndent()
const
1018 return eFirstLine->
value();
1021double KoIndentSpacingWidget::spaceBeforeParag()
const
1023 return TQMAX(0, eBefore->
value() );
1026double KoIndentSpacingWidget::spaceAfterParag()
const
1028 return TQMAX(0, eAfter->
value() );
1033 int index = cSpacing->currentItem();
1036 return KoParagLayout::LS_SINGLE;
1038 return KoParagLayout::LS_ONEANDHALF;
1040 return KoParagLayout::LS_DOUBLE;
1042 return KoParagLayout::LS_MULTIPLE;
1044 return KoParagLayout::LS_CUSTOM;
1046 return KoParagLayout::LS_AT_LEAST;
1048 return KoParagLayout::LS_FIXED;
1050 kdError(32500) <<
"Error in KoIndentSpacingWidget::lineSpacingType" << endl;
1051 return KoParagLayout::LS_SINGLE;
1055double KoIndentSpacingWidget::lineSpacing()
const
1057 return (lineSpacingType() == KoParagLayout::LS_MULTIPLE)
1058 ? TQMAX( 1, eSpacingPercent->
value() ) / 100.0
1059 : TQMAX( 0, eSpacing->
value() );
1063void KoIndentSpacingWidget::display(
const KoParagLayout & lay )
1065 double _left = lay.
margins[TQStyleSheetItem::MarginLeft];
1066 eLeft->changeValue( _left );
1068 leftChanged( _left );
1070 double _right = lay.
margins[TQStyleSheetItem::MarginRight];
1071 eRight->changeValue( _right );
1072 prev1->setRight( _right );
1074 double _first = lay.
margins[TQStyleSheetItem::MarginFirstLine];
1075 eFirstLine->changeValue( _first );
1076 prev1->setFirst( _first );
1078 double _before = lay.
margins[TQStyleSheetItem::MarginTop];
1079 eBefore->changeValue( _before );
1080 prev1->setBefore( _before );
1082 double _after = lay.
margins[TQStyleSheetItem::MarginBottom];
1083 eAfter->changeValue( _after );
1084 prev1->setAfter( _after );
1086 double _spacing = lay.lineSpacingValue();
1089 case KoParagLayout::LS_SINGLE:
1090 cSpacing->setCurrentItem( 0 );
1092 case KoParagLayout::LS_ONEANDHALF:
1093 cSpacing->setCurrentItem( 1 );
1095 case KoParagLayout::LS_DOUBLE:
1096 cSpacing->setCurrentItem( 2 );
1098 case KoParagLayout::LS_MULTIPLE:
1099 cSpacing->setCurrentItem( 3 );
1101 case KoParagLayout::LS_CUSTOM:
1102 cSpacing->setCurrentItem( 4 );
1104 case KoParagLayout::LS_AT_LEAST:
1105 cSpacing->setCurrentItem( 5 );
1107 case KoParagLayout::LS_FIXED:
1108 cSpacing->setCurrentItem( 6 );
1111 cSpacing->setCurrentItem( 0 );
1115 updateLineSpacing( _type );
1116 eSpacing->
setValue( (_type == KoParagLayout::LS_MULTIPLE) ? TQMAX( 1, _spacing )
1117 :
KoUnit::toUserValue( _spacing, m_unit ) );
1118 eSpacingPercent->
setValue( ( _type == KoParagLayout::LS_MULTIPLE ) ? tqRound( _spacing * 100 ) : 100 );
1123 lay.setLineSpacingValue(lineSpacing());
1124 lay.lineSpacingType = lineSpacingType();
1125 lay.
margins[TQStyleSheetItem::MarginLeft] = leftIndent();
1126 lay.
margins[TQStyleSheetItem::MarginRight] = rightIndent();
1127 lay.
margins[TQStyleSheetItem::MarginFirstLine] = firstLineIndent();
1128 lay.
margins[TQStyleSheetItem::MarginTop] = spaceBeforeParag();
1129 lay.
margins[TQStyleSheetItem::MarginBottom] = spaceAfterParag();
1134 return i18n(
"Indent && S&pacing" );
1137void KoIndentSpacingWidget::leftChanged(
double val )
1139 prev1->setLeft( val );
1144void KoIndentSpacingWidget::rightChanged(
double val )
1146 prev1->setRight( val );
1149void KoIndentSpacingWidget::firstChanged(
double val )
1151 prev1->setFirst( val );
1156 bool needsValue = (_type != KoParagLayout::LS_SINGLE &&
1157 _type != KoParagLayout::LS_ONEANDHALF &&
1158 _type != KoParagLayout::LS_DOUBLE);
1160 if ( _type == KoParagLayout::LS_MULTIPLE )
1162 sSpacingStack->raiseWidget( eSpacingPercent );
1166 sSpacingStack->raiseWidget( eSpacing );
1168 eSpacing->setEnabled( needsValue );
1170 prev1->setSpacing( eSpacing->
value() );
1173 prev1->setSpacing( _type == KoParagLayout::LS_ONEANDHALF ? 8 :
1178void KoIndentSpacingWidget::spacingActivated(
int )
1180 updateLineSpacing( lineSpacingType() );
1181 if ( eSpacing->isEnabled() )
1182 eSpacing->setFocus();
1185void KoIndentSpacingWidget::spacingChanged(
double _val )
1187 prev1->setSpacing( _val );
1190void KoIndentSpacingWidget::spacingChanged(
int _val )
1192 prev1->setSpacing( _val / 100.0 );
1195void KoIndentSpacingWidget::beforeChanged(
double _val )
1200void KoIndentSpacingWidget::afterChanged(
double _val )
1206KoParagAlignWidget::KoParagAlignWidget(
bool breakLine, TQWidget * parent,
const char * name )
1211 TQVGroupBox * AlignGroup =
new TQVGroupBox( i18n(
"Alignment" ),
this );
1213 rLeft =
new TQRadioButton( i18n(
"&Left" ), AlignGroup );
1214 connect( rLeft, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( alignLeft() ) );
1216 rCenter =
new TQRadioButton( i18n(
"C&enter" ), AlignGroup );
1217 connect( rCenter, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( alignCenter() ) );
1219 rRight =
new TQRadioButton( i18n(
"&Right" ), AlignGroup );
1220 connect( rRight, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( alignRight() ) );
1222 rJustify =
new TQRadioButton( i18n(
"&Justify" ), AlignGroup );
1223 connect( rJustify, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( alignJustify() ) );
1226 rLeft->setChecked(
true );
1228 grid->addWidget(AlignGroup, 0, 0);
1231 TQGroupBox * endFramePage =
new TQGroupBox( i18n(
"Behavior at &End of Frame/Page" ),
this );
1232 TQGridLayout * endFramePageGrid =
new TQGridLayout( endFramePage, 4, 1,
1235 cKeepLinesTogether =
new TQCheckBox( i18n(
"&Keep lines together"),endFramePage);
1236 endFramePageGrid->addWidget( cKeepLinesTogether, 1, 0 );
1237 cHardBreakBefore =
new TQCheckBox( i18n(
"Insert break before paragraph"),endFramePage);
1238 endFramePageGrid->addWidget( cHardBreakBefore, 2, 0 );
1239 cHardBreakAfter =
new TQCheckBox( i18n(
"Insert break after paragraph"),endFramePage);
1240 endFramePageGrid->addWidget( cHardBreakAfter, 3, 0 );
1242 endFramePageGrid->addRowSpacing( 0, fontMetrics().height() / 2 );
1243 for (
int i = 0 ; i < endFramePageGrid->numRows()-1 ; ++i )
1244 endFramePageGrid->setRowStretch( 0, 0 );
1245 endFramePageGrid->setRowStretch( endFramePageGrid->numRows()-1, 1 );
1246 grid->addWidget( endFramePage, 2, 0 );
1248 endFramePage->setEnabled(breakLine);
1251 prev2 =
new KPagePreview2(
this,
"KPagePreview2" );
1252 grid->addMultiCellWidget( prev2, 0, 2, 1, 1 );
1255 grid->setColStretch( 1, 1 );
1256 grid->setRowStretch( 1, 1 );
1259int KoParagAlignWidget::pageBreaking()
const
1262 if ( cKeepLinesTogether->isChecked() )
1263 pb |= KoParagLayout::KeepLinesTogether;
1264 if ( cHardBreakBefore->isChecked() )
1265 pb |= KoParagLayout::HardFrameBreakBefore;
1266 if ( cHardBreakAfter->isChecked() )
1267 pb |= KoParagLayout::HardFrameBreakAfter;
1272void KoParagAlignWidget::display(
const KoParagLayout & lay )
1275 prev2->setAlign( align );
1279 case TQt::AlignAuto:
1280 case TQt::AlignLeft:
1281 rLeft->setChecked(
true );
1283 case TQt::AlignHCenter:
1284 rCenter->setChecked(
true );
1286 case TQt::AlignRight:
1287 rRight->setChecked(
true );
1289 case TQt::AlignJustify:
1290 rJustify->setChecked(
true );
1293 cKeepLinesTogether->setChecked( lay.pageBreaking & KoParagLayout::KeepLinesTogether );
1294 cHardBreakBefore->setChecked( lay.pageBreaking & KoParagLayout::HardFrameBreakBefore );
1295 cHardBreakAfter->setChecked( lay.pageBreaking & KoParagLayout::HardFrameBreakAfter );
1302 lay.pageBreaking = pageBreaking();
1305int KoParagAlignWidget::align()
const
1307 if ( rLeft->isChecked() )
return TQt::AlignLeft;
1308 else if ( rCenter->isChecked() )
return TQt::AlignHCenter;
1309 else if ( rRight->isChecked() )
return TQt::AlignRight;
1310 else if ( rJustify->isChecked() )
return TQt::AlignJustify;
1312 return TQt::AlignLeft;
1317 return i18n(
"General &Layout" );
1320void KoParagAlignWidget::alignLeft()
1322 prev2->setAlign( TQt::AlignLeft );
1324 rLeft->setChecked(
true );
1327void KoParagAlignWidget::alignCenter()
1329 prev2->setAlign( TQt::AlignHCenter );
1331 rCenter->setChecked(
true );
1334void KoParagAlignWidget::alignRight()
1336 prev2->setAlign( TQt::AlignRight );
1338 rRight->setChecked(
true );
1341void KoParagAlignWidget::alignJustify()
1343 prev2->setAlign( TQt::AlignJustify );
1345 rJustify->setChecked(
true );
1348void KoParagAlignWidget::clearAligns()
1350 rLeft->setChecked(
false );
1351 rCenter->setChecked(
false );
1352 rRight->setChecked(
false );
1353 rJustify->setChecked(
false );
1358KoParagDecorationWidget::KoParagDecorationWidget( TQWidget * parent,
1362 TQVBoxLayout *tabLayout =
new TQVBoxLayout(
this );
1363 wDeco =
new KoParagDecorationTab(
this );
1364 tabLayout->add( wDeco );
1367 wDeco->cbBorderStyle->insertItem( KoBorder::getStyle( KoBorder::SOLID ) );
1368 wDeco->cbBorderStyle->insertItem( KoBorder::getStyle( KoBorder::DASH ) );
1369 wDeco->cbBorderStyle->insertItem( KoBorder::getStyle( KoBorder::DOT ) );
1370 wDeco->cbBorderStyle->insertItem( KoBorder::getStyle( KoBorder::DASH_DOT ) );
1371 wDeco->cbBorderStyle->insertItem( KoBorder::getStyle( KoBorder::DASH_DOT_DOT ) );
1372 wDeco->cbBorderStyle->insertItem( KoBorder::getStyle( KoBorder::DOUBLE_LINE ) );
1375 for(
unsigned int i = 1; i <= 10; i++ )
1376 wDeco->cbBorderWidth->insertItem(TQString::number(i));
1379 connect( wDeco->bBorderLeft, TQ_SIGNAL( toggled(
bool ) ),
1380 this, TQ_SLOT( brdLeftToggled(
bool ) ) );
1381 connect( wDeco->bBorderRight, TQ_SIGNAL( toggled(
bool ) ),
1382 this, TQ_SLOT( brdRightToggled(
bool ) ) );
1383 connect( wDeco->bBorderTop, TQ_SIGNAL( toggled(
bool ) ),
1384 this, TQ_SLOT( brdTopToggled(
bool ) ) );
1385 connect( wDeco->bBorderBottom, TQ_SIGNAL( toggled(
bool ) ),
1386 this, TQ_SLOT( brdBottomToggled(
bool ) ) );
1387 connect( wDeco->cbJoinBorder, TQ_SIGNAL( toggled(
bool ) ),
1388 this, TQ_SLOT( brdJoinToggled(
bool ) ) );
1391 wPreview =
new KoBorderPreview( wDeco->borderPreview );
1392 TQVBoxLayout *previewLayout =
new TQVBoxLayout( wDeco->borderPreview );
1393 previewLayout->addWidget( wPreview );
1394 connect( wPreview, TQ_SIGNAL( choosearea(TQMouseEvent * ) ),
1395 this, TQ_SLOT( slotPressEvent(TQMouseEvent *) ) );
1400KoBorder::BorderStyle KoParagDecorationWidget::curBorderStyle()
const
1402 TQString selection = wDeco->cbBorderStyle->currentText();
1403 return KoBorder::getStyle( selection );
1406unsigned int KoParagDecorationWidget::curBorderWidth()
const {
1407 return wDeco->cbBorderWidth->currentText().toUInt();
1410TQColor KoParagDecorationWidget::curBorderColor()
const {
1411 return wDeco->bBorderColor->color();
1416bool KoParagDecorationWidget::borderChanged(
const KoBorder& border ) {
1417 return (
unsigned int)border.penWidth() != curBorderWidth() ||
1418 border.color != curBorderColor() ||
1419 border.getStyle() != curBorderStyle();
1423void KoParagDecorationWidget::updateBorder(
KoBorder& border )
1425 border.setPenWidth( curBorderWidth() );
1426 border.color = curBorderColor();
1427 border.setStyle( curBorderStyle () );
1430void KoParagDecorationWidget::clickedBorderPreview(
KoBorder& border,
1431 KoBorder::BorderType position,
1434 if ( borderChanged( border ) && corresponding->isOn() ) {
1435 updateBorder( border );
1436 wPreview->setBorder( position, border );
1439 corresponding->setOn( !corresponding->isOn() );
1444void KoParagDecorationWidget::slotPressEvent(TQMouseEvent *_ev)
1446 const int OFFSETX = 15;
1447 const int OFFSETY = 7;
1448 const int Ko_SPACE = 30;
1450 TQRect r = wPreview->contentsRect();
1451 TQRect rect(r.x() + OFFSETX, r.y() + OFFSETY,
1452 r.width() - OFFSETX, r.y() + OFFSETY + Ko_SPACE);
1453 if(rect.contains(TQPoint(_ev->x(),_ev->y())))
1455 clickedBorderPreview( m_topBorder, KoBorder::TopBorder,
1456 wDeco->bBorderTop );
1459 rect.setCoords(r.x() + OFFSETX, r.height() - OFFSETY - Ko_SPACE,
1460 r.width() - OFFSETX, r.height() - OFFSETY);
1461 if(rect.contains(TQPoint(_ev->x(),_ev->y())))
1463 clickedBorderPreview( m_bottomBorder, KoBorder::BottomBorder,
1464 wDeco->bBorderBottom );
1467 rect.setCoords(r.x() + OFFSETX, r.y() + OFFSETY,
1468 r.x() + Ko_SPACE + OFFSETX, r.height() - OFFSETY);
1469 if(rect.contains(TQPoint(_ev->x(),_ev->y())))
1471 clickedBorderPreview( m_leftBorder, KoBorder::LeftBorder,
1472 wDeco->bBorderLeft );
1475 rect.setCoords(r.width() - OFFSETX - Ko_SPACE, r.y() + OFFSETY,
1476 r.width() - OFFSETX, r.height() - OFFSETY);
1477 if(rect.contains(TQPoint(_ev->x(),_ev->y())))
1479 clickedBorderPreview( m_rightBorder, KoBorder::RightBorder,
1480 wDeco->bBorderRight );
1484void KoParagDecorationWidget::display(
const KoParagLayout & lay )
1488 m_leftBorder = lay.leftBorder;
1489 m_rightBorder = lay.rightBorder;
1490 m_topBorder = lay.topBorder;
1491 m_bottomBorder = lay.bottomBorder;
1492 m_joinBorder = lay.joinBorder;
1494 wDeco->bBorderLeft->blockSignals(
true );
1495 wDeco->bBorderRight->blockSignals(
true );
1496 wDeco->bBorderTop->blockSignals(
true );
1497 wDeco->bBorderBottom->blockSignals(
true );
1499 wDeco->bBorderLeft->blockSignals(
false );
1500 wDeco->bBorderRight->blockSignals(
false );
1501 wDeco->bBorderTop->blockSignals(
false );
1502 wDeco->bBorderBottom->blockSignals(
false );
1505void KoParagDecorationWidget::updateBorders()
1507 wDeco->bBorderLeft->setOn( m_leftBorder.penWidth() > 0 );
1508 wDeco->bBorderRight->setOn( m_rightBorder.penWidth() > 0 );
1509 wDeco->bBorderTop->setOn( m_topBorder.penWidth() > 0 );
1510 wDeco->bBorderBottom->setOn( m_bottomBorder.penWidth() > 0 );
1511 wDeco->cbJoinBorder->setChecked( m_joinBorder );
1512 wPreview->setLeftBorder( m_leftBorder );
1513 wPreview->setRightBorder( m_rightBorder );
1514 wPreview->setTopBorder( m_topBorder );
1515 wPreview->setBottomBorder( m_bottomBorder );
1522 lay.topBorder = m_topBorder;
1523 lay.bottomBorder = m_bottomBorder;
1524 lay.leftBorder = m_leftBorder;
1525 lay.rightBorder = m_rightBorder;
1526 lay.joinBorder = m_joinBorder;
1529TQColor KoParagDecorationWidget::backgroundColor()
const {
1530 return wDeco->bBackgroundColor->color();
1536 return i18n(
"D&ecorations" );
1539void KoParagDecorationWidget::brdLeftToggled(
bool _on )
1542 m_leftBorder.setPenWidth(0);
1544 m_leftBorder.setPenWidth( curBorderWidth() );
1545 m_leftBorder.color = curBorderColor();
1546 m_leftBorder.setStyle( curBorderStyle() );
1548 wPreview->setLeftBorder( m_leftBorder );
1551void KoParagDecorationWidget::brdRightToggled(
bool _on )
1554 m_rightBorder.setPenWidth(0);
1556 m_rightBorder.setPenWidth( curBorderWidth() );
1557 m_rightBorder.color = curBorderColor();
1558 m_rightBorder.setStyle( curBorderStyle() );
1560 wPreview->setRightBorder( m_rightBorder );
1563void KoParagDecorationWidget::brdTopToggled(
bool _on )
1566 m_topBorder.setPenWidth(0);
1568 m_topBorder.setPenWidth( curBorderWidth() );
1569 m_topBorder.color = curBorderColor();
1570 m_topBorder.setStyle( curBorderStyle() );
1572 wPreview->setTopBorder( m_topBorder );
1575void KoParagDecorationWidget::brdBottomToggled(
bool _on )
1578 m_bottomBorder.setPenWidth ( 0 );
1580 m_bottomBorder.setPenWidth( curBorderWidth() );
1581 m_bottomBorder.color = curBorderColor();
1582 m_bottomBorder.setStyle( curBorderStyle() );
1584 wPreview->setBottomBorder( m_bottomBorder );
1587void KoParagDecorationWidget::brdJoinToggled(
bool _on ) {
1593KoParagCounterWidget::KoParagCounterWidget(
bool disableAll, TQWidget * parent,
const char * name )
1597 TQVBoxLayout *Form1Layout =
new TQVBoxLayout(
this );
1601 gNumbering =
new TQButtonGroup(
this,
"numberingGroup" );
1602 gNumbering->setTitle( i18n(
"Numbering" ) );
1603 gNumbering->setColumnLayout(0, TQt::Vertical );
1604 gNumbering->layout()->setSpacing( 0 );
1605 gNumbering->layout()->setMargin( 0 );
1606 TQHBoxLayout *numberingGroupLayout =
new TQHBoxLayout( gNumbering->layout() );
1607 numberingGroupLayout->setAlignment( TQt::AlignTop );
1612 TQRadioButton *rNone =
new TQRadioButton( gNumbering,
"rNone" );
1613 rNone->setText( i18n(
"&None" ) );
1614 numberingGroupLayout->addWidget( rNone );
1616 gNumbering->insert( rNone , KoParagCounter::NUM_NONE);
1618 TQRadioButton *rList =
new TQRadioButton( gNumbering,
"rList" );
1619 rList->setText( i18n(
"&List" ) );
1620 gNumbering->insert( rList , KoParagCounter::NUM_LIST);
1621 numberingGroupLayout->addWidget( rList );
1623 TQRadioButton *rChapter =
new TQRadioButton( gNumbering,
"rChapter" );
1624 rChapter->setText( i18n(
"Chapt&er" ) );
1625 gNumbering->insert( rChapter , KoParagCounter::NUM_CHAPTER);
1626 numberingGroupLayout->addWidget( rChapter );
1627 Form1Layout->addWidget( gNumbering );
1628 connect( gNumbering, TQ_SIGNAL( clicked(
int ) ),
this, TQ_SLOT( numTypeChanged(
int ) ) );
1630 m_styleWidget =
new KoCounterStyleWidget(
true,
false, disableAll,
this );
1632 connect( m_styleWidget, TQ_SIGNAL( sig_suffixChanged (
const TQString &) ),
this, TQ_SLOT( suffixChanged(
const TQString &) ) );
1633 connect( m_styleWidget, TQ_SIGNAL( sig_prefixChanged (
const TQString &) ),
this, TQ_SLOT( prefixChanged(
const TQString &) ) );
1634 connect( m_styleWidget, TQ_SIGNAL( sig_startChanged(
int) ),
this, TQ_SLOT( startChanged(
int) ) );
1635 connect( m_styleWidget, TQ_SIGNAL( sig_restartChanged(
bool) ),
this, TQ_SLOT( restartChanged(
bool) ) );
1636 connect( m_styleWidget, TQ_SIGNAL( sig_depthChanged (
int) ),
this, TQ_SLOT( depthChanged(
int) ) );
1637 connect( m_styleWidget, TQ_SIGNAL( sig_displayLevelsChanged (
int) ),
this, TQ_SLOT( displayLevelsChanged(
int) ) );
1638 connect( m_styleWidget, TQ_SIGNAL( sig_alignmentChanged (
int) ),
this, TQ_SLOT( alignmentChanged(
int) ) );
1639 connect( m_styleWidget, TQ_SIGNAL( changeCustomBullet(
const TQString & , TQChar ) ),
this, TQ_SLOT( slotChangeCustomBullet(
const TQString & , TQChar ) ) );
1641 connect( m_styleWidget, TQ_SIGNAL( sig_numTypeChanged(
int ) ),
this, TQ_SLOT( numTypeChanged(
int ) ) );
1642 connect( m_styleWidget, TQ_SIGNAL( changeStyle( KoParagCounter::Style ) ),
this, TQ_SLOT( styleChanged (KoParagCounter::Style ) ) );
1644 Form1Layout->addWidget( m_styleWidget );
1647 preview =
new KoStylePreview( i18n(
"Preview" ), i18n(
"Normal paragraph text"),
this,
"counter preview" );
1648 Form1Layout->addWidget( preview );
1651 gNumbering->setEnabled(
false);
1652 preview->setEnabled(
false );
1655 TQSpacerItem* spacer =
new TQSpacerItem( 0, 0, TQSizePolicy::Minimum, TQSizePolicy::Expanding);
1656 Form1Layout->addItem( spacer );
1659void KoParagCounterWidget::styleChanged( KoParagCounter::Style st )
1661 m_counter.setStyle( st );
1665void KoParagCounterWidget::slotChangeCustomBullet(
const TQString & f, TQChar c)
1667 m_counter.setCustomBulletFont( f );
1668 m_counter.setCustomBulletCharacter( c );
1673 return i18n(
"B&ullets/Numbers" );
1676void KoParagCounterWidget::numTypeChanged(
int nType ) {
1678 m_counter.setNumbering(
static_cast<KoParagCounter::Numbering
>( nType ) );
1679 preview->setEnabled( m_counter.
numbering() != KoParagCounter::NUM_NONE );
1680 m_styleWidget->numTypeChanged( nType );
1685void KoParagCounterWidget::display(
const KoParagLayout & lay ) {
1686 KoParagCounter::Style style = KoParagCounter::STYLE_NONE;
1696 gNumbering->setButton( m_counter.
numbering() );
1699 m_styleWidget->display( lay );
1702void KoParagCounterWidget::updatePreview() {
1704 preview->repaint(
true);
1719KoTabulatorsLineEdit::KoTabulatorsLineEdit( TQWidget *parent,
double lower,
double upper,
double step,
double value ,
KoUnit::Unit unit ,
unsigned int precision ,
const char *name )
1722 setRange( 0, 9999, 1,
false);
1725void KoTabulatorsLineEdit::keyPressEvent ( TQKeyEvent *ke )
1727 if( ke->key() == TQt::Key_Return ||
1728 ke->key() == TQt::Key_Enter )
1730 emit keyReturnPressed();
1733 KoUnitDoubleSpinBox::keyPressEvent (ke);
1736KoParagTabulatorsWidget::KoParagTabulatorsWidget(
KoUnit::Unit unit,
double frameWidth,TQWidget * parent,
const char * name )
1739 if(frameWidth==-1) {
1743 m_toplimit=frameWidth;
1744 length=i18n(
"Frame width: %1 %2")
1749 TQVBoxLayout* Form1Layout =
new TQVBoxLayout(
this );
1753 TQHBoxLayout* Layout13 =
new TQHBoxLayout;
1755 Layout13->setMargin( 0 );
1757 lstTabs =
new TQListBox(
this);
1758 lstTabs->insertItem(
"mytabvalue" );
1759 lstTabs->setMaximumSize( TQSize( 300, 32767 ) );
1760 Layout13->addWidget( lstTabs );
1762 editLayout =
new TQVBoxLayout;
1764 editLayout->setMargin( 0 );
1766 gPosition =
new TQGroupBox(
this,
"gPosition" );
1767 gPosition->setTitle( i18n(
"Po&sition" ) );
1768 gPosition->setColumnLayout(0, TQt::Vertical );
1769 gPosition->layout()->setSpacing( 0 );
1770 gPosition->layout()->setMargin( 0 );
1771 TQVBoxLayout* GroupBox2Layout =
new TQVBoxLayout( gPosition->layout() );
1772 GroupBox2Layout->setAlignment( TQt::AlignTop );
1776 TQHBoxLayout* Layout5 =
new TQHBoxLayout;
1778 Layout5->setMargin( 0 );
1780 sTabPos =
new KoTabulatorsLineEdit( gPosition, 0, 9999, 1, 0.0, m_unit );
1781 sTabPos->setRange( 0, 9999, 1 );
1782 sTabPos->setMaximumSize( TQSize( 100, 32767 ) );
1783 Layout5->addWidget( sTabPos );
1784 TQSpacerItem* spacer =
new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
1785 Layout5->addItem( spacer );
1786 GroupBox2Layout->addLayout( Layout5 );
1787 editLayout->addWidget( gPosition );
1789 TQLabel* TextLabel1 =
new TQLabel( gPosition );
1791 TextLabel1->setText( length );
1792 GroupBox2Layout->addWidget( TextLabel1 );
1794 bgAlign =
new TQButtonGroup(
this );
1795 bgAlign->setTitle( i18n(
"Alignment" ) );
1796 bgAlign->setColumnLayout(0, TQt::Vertical );
1797 bgAlign->layout()->setSpacing( 0 );
1798 bgAlign->layout()->setMargin( 0 );
1799 TQVBoxLayout* ButtonGroup1Layout =
new TQVBoxLayout( bgAlign->layout() );
1800 ButtonGroup1Layout->setAlignment( TQt::AlignTop );
1804 rAlignLeft =
new TQRadioButton( bgAlign );
1805 rAlignLeft->setText( i18n(
"&Left" ) );
1806 ButtonGroup1Layout->addWidget( rAlignLeft );
1808 rAlignCentre =
new TQRadioButton( bgAlign );
1809 rAlignCentre->setText( i18n(
"C&enter" ) );
1810 ButtonGroup1Layout->addWidget( rAlignCentre );
1812 rAlignRight =
new TQRadioButton( bgAlign );
1813 rAlignRight->setText( i18n(
"&Right" ) );
1814 ButtonGroup1Layout->addWidget( rAlignRight );
1816 TQHBoxLayout* Layout8 =
new TQHBoxLayout;
1818 Layout8->setMargin( 0 );
1820 rAlignVar =
new TQRadioButton( bgAlign );
1821 rAlignVar->setText( i18n(
"On followin&g character: " ) );
1822 Layout8->addWidget( rAlignVar );
1824 sAlignChar =
new TQLineEdit( bgAlign);
1825 sAlignChar->setMaximumSize( TQSize( 60, 32767 ) );
1826 sAlignChar->setText(TQString(TDEGlobal::locale()->decimalSymbol()[0]));
1827 Layout8->addWidget( sAlignChar );
1828 TQSpacerItem* spacer_2 =
new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
1829 Layout8->addItem( spacer_2 );
1830 ButtonGroup1Layout->addLayout( Layout8 );
1831 editLayout->addWidget( bgAlign );
1833 gTabLeader =
new TQGroupBox(
this,
"gTabLeader" );
1834 gTabLeader->setTitle( i18n(
"Tab Leader" ) );
1835 TQVBoxLayout* GroupBox5Layout =
new TQVBoxLayout( gTabLeader );
1836 GroupBox5Layout->setAlignment( TQt::AlignTop );
1839 GroupBox5Layout->addSpacing( fontMetrics().height() / 2 );
1841 TQLabel* TextLabel1_2 =
new TQLabel( gTabLeader );
1842 TextLabel1_2->setText( i18n(
"The space a tab uses can be filled with a pattern." ) );
1843 GroupBox5Layout->addWidget( TextLabel1_2 );
1847 TQLabel* TextLabel2 =
new TQLabel( gTabLeader);
1848 TextLabel2->setText( i18n(
"&Filling:" ) );
1849 TextLabel2->setAlignment( AlignRight );
1850 fillingGrid->addWidget( TextLabel2, 0, 0 );
1852 cFilling =
new TQComboBox(
false, gTabLeader);
1853 cFilling->insertItem( i18n(
"Blank" ) );
1854 cFilling->insertItem(
"_ _ _ _ _ _");
1855 cFilling->insertItem(
"_________");
1856 cFilling->insertItem(
"___ ___ __");
1857 cFilling->insertItem(
"___ _ ___ _");
1858 cFilling->insertItem(
"___ _ _ ___");
1859 TextLabel2->setBuddy( cFilling );
1860 fillingGrid->addWidget( cFilling, 0, 1 );
1862 TQLabel * TextLabel3 =
new TQLabel( i18n(
"&Width:"), gTabLeader );
1863 TextLabel3->setAlignment( AlignRight );
1864 fillingGrid->addWidget( TextLabel3, 1, 0 );
1867 eWidth->setMinValue(0.01);
1868 eWidth->setUnit( m_unit );
1869 TextLabel3->setBuddy( eWidth );
1870 fillingGrid->addWidget( eWidth, 1, 1 );
1872 GroupBox5Layout->addLayout( fillingGrid );
1873 editLayout->addWidget( gTabLeader );
1874 TQSpacerItem* spacer_4 =
new TQSpacerItem( 20, 20, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
1875 editLayout->addItem( spacer_4 );
1876 Layout13->addLayout( editLayout );
1877 Form1Layout->addLayout( Layout13 );
1879 TQHBoxLayout* Layout4 =
new TQHBoxLayout;
1881 Layout4->setMargin( 0 );
1883 bNew =
new TQPushButton(
this);
1884 bNew->setText( i18n(
"&New" ) );
1885 Layout4->addWidget( bNew );
1887 bDelete =
new TQPushButton(
this);
1888 bDelete->setText( i18n(
"&Delete" ) );
1889 Layout4->addWidget( bDelete );
1891 bDeleteAll =
new TQPushButton(
this);
1892 bDeleteAll->setText( i18n(
"Delete All" ) );
1893 Layout4->addWidget( bDeleteAll );
1895 TQSpacerItem* spacer_5 =
new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
1896 Layout4->addItem( spacer_5 );
1897 Form1Layout->addLayout( Layout4 );
1901 connect(sTabPos,TQ_SIGNAL(valueChanged(
double)),
this, TQ_SLOT(slotTabValueChanged(
double )));
1902 connect(sTabPos,TQ_SIGNAL( keyReturnPressed()),
this,TQ_SLOT(newClicked()));
1903 connect(sAlignChar,TQ_SIGNAL(textChanged(
const TQString & )),
this, TQ_SLOT(slotAlignCharChanged(
const TQString & )));
1904 connect(bNew,TQ_SIGNAL(clicked ()),
this,TQ_SLOT(newClicked()));
1905 connect(bDelete,TQ_SIGNAL(clicked ()),
this,TQ_SLOT(deleteClicked()));
1906 connect(bDeleteAll,TQ_SIGNAL(clicked ()),
this,TQ_SLOT(deleteAllClicked()));
1907 connect(bgAlign,TQ_SIGNAL(clicked (
int)),
this,TQ_SLOT(updateAlign(
int)));
1908 connect(cFilling,TQ_SIGNAL(activated (
int)),
this,TQ_SLOT(updateFilling(
int)));
1909 connect(eWidth,TQ_SIGNAL(valueChangedPt(
double ) ),
this,TQ_SLOT(updateWidth()));
1910 connect(lstTabs,TQ_SIGNAL(highlighted (
int)),
this,TQ_SLOT(setActiveItem(
int)));
1914void KoParagTabulatorsWidget::slotTabValueChanged(
double val ) {
1915 if(noSignals)
return;
1920 lstTabs->changeItem(tabToString(m_tabList[lstTabs->currentItem()]), lstTabs->currentItem());
1926void KoParagTabulatorsWidget::slotAlignCharChanged(
const TQString & ) {
1928 bgAlign->setButton(3);
1929 m_tabList[lstTabs->currentItem()].alignChar=sAlignChar->text()[0];
1930 m_tabList[lstTabs->currentItem()].type=T_DEC_PNT;
1933void KoParagTabulatorsWidget::newClicked() {
1934 int selected=lstTabs->currentItem();
1941 m_tabList.append(newTab);
1942 lstTabs->insertItem(tabToString(newTab));
1943 lstTabs->setCurrentItem(0);
1945 double pos = m_tabList[selected].ptPos;
1947 if(m_unit==KoUnit::U_INCH)
1954 newTab.
type=m_tabList[selected].type;
1955 newTab.
filling=m_tabList[selected].filling;
1956 newTab.
ptWidth=m_tabList[selected].ptWidth;
1957 m_tabList.insert(m_tabList.at(selected), newTab);
1958 lstTabs->insertItem( tabToString(newTab), selected);
1959 lstTabs->setCurrentItem(lstTabs->findItem(tabToString(newTab)));
1965void KoParagTabulatorsWidget::deleteClicked() {
1966 int selected = lstTabs->currentItem();
1967 if (selected < 0)
return;
1969 sTabPos->changeValue(0.0);
1971 lstTabs->removeItem(selected);
1972 m_tabList.remove(m_tabList[selected]);
1973 if(lstTabs->count() >0) {
1974 lstTabs->setCurrentItem(TQMIN(
static_cast<unsigned int>(selected), lstTabs->count()-1 ));
1976 bDeleteAll->setEnabled(
false);
1977 bDelete->setEnabled(
false);
1978 gPosition->setEnabled(
false);
1979 bgAlign->setEnabled(
false);
1980 gTabLeader->setEnabled(
false);
1984void KoParagTabulatorsWidget::deleteAllClicked()
1987 sTabPos->changeValue(0.0);
1991 bDeleteAll->setEnabled(
false);
1992 bDelete->setEnabled(
false);
1993 gPosition->setEnabled(
false);
1994 bgAlign->setEnabled(
false);
1995 gTabLeader->setEnabled(
false);
1998void KoParagTabulatorsWidget::setActiveItem(
int selected) {
1999 if(noSignals)
return;
2000 if(selected < 0)
return;
2003 switch( selectedTab->
type) {
2005 bgAlign->setButton(1);
break;
2007 bgAlign->setButton(2);
break;
2009 bgAlign->setButton(3);
2010 sAlignChar->setText(TQString(selectedTab->
alignChar));
2014 bgAlign->setButton(0);
2016 switch( selectedTab->
filling) {
2018 cFilling->setCurrentItem(1);
break;
2020 cFilling->setCurrentItem(2);
break;
2022 cFilling->setCurrentItem(3);
break;
2024 cFilling->setCurrentItem(4);
break;
2025 case TF_DASH_DOT_DOT:
2026 cFilling->setCurrentItem(5);
break;
2029 cFilling->setCurrentItem(0);
2031 eWidth->changeValue( selectedTab->
ptWidth );
2033 bDelete->setEnabled(
true);
2034 bDeleteAll->setEnabled(
true);
2035 gPosition->setEnabled(
true);
2036 bgAlign->setEnabled(
true);
2037 gTabLeader->setEnabled(
true);
2041void KoParagTabulatorsWidget::setCurrentTab(
double tabPos ) {
2042 KoTabulatorList::ConstIterator it = m_tabList.begin();
2043 for (
int i = 0; it != m_tabList.end(); ++it, ++i )
2044 if ( (*it).ptPos == tabPos ) {
2045 lstTabs->setCurrentItem(i);
2049 kdWarning() <<
"KoParagTabulatorsWidget::setCurrentTab: no tab found at pos=" << tabPos << endl;
2052TQString KoParagTabulatorsWidget::tabToString(
const KoTabulator &tab) {
2056void KoParagTabulatorsWidget::updateAlign(
int selected) {
2057 KoTabulator *selectedTab = &m_tabList[lstTabs->currentItem()];
2061 selectedTab->
type=T_CENTER;
break;
2063 selectedTab->
type=T_RIGHT;
break;
2065 selectedTab->
type=T_DEC_PNT;
2066 selectedTab->
alignChar=sAlignChar->text()[0];
2070 selectedTab->
type=T_LEFT;
2074void KoParagTabulatorsWidget::updateFilling(
int selected) {
2075 KoTabulator *selectedTab = &m_tabList[lstTabs->currentItem()];
2079 selectedTab->
filling=TF_DOTS;
break;
2081 selectedTab->
filling=TF_LINE;
break;
2083 selectedTab->
filling=TF_DASH;
break;
2085 selectedTab->
filling=TF_DASH_DOT;
break;
2087 selectedTab->
filling=TF_DASH_DOT_DOT;
break;
2090 selectedTab->
filling=TF_BLANK;
2094void KoParagTabulatorsWidget::updateWidth() {
2095 KoTabulator *selectedTab = &m_tabList[lstTabs->currentItem()];
2099void KoParagTabulatorsWidget::sortLists() {
2102 qHeapSort( m_tabList );
2106 TQString curValue=lstTabs->currentText();
2108 KoTabulatorList::ConstIterator it = m_tabList.begin();
2109 for ( ; it != m_tabList.end(); ++it )
2112 lstTabs->setCurrentItem(lstTabs->findItem(curValue));
2116void KoParagTabulatorsWidget::display(
const KoParagLayout &lay ) {
2119 m_tabList = lay.tabList();
2120 KoTabulatorList::ConstIterator it = m_tabList.begin();
2121 for ( ; it != m_tabList.end(); ++it )
2124 if(lstTabs->count() > 0)
2125 lstTabs->setCurrentItem(0);
2127 bDelete->setEnabled(
false);
2128 bDeleteAll->setEnabled(
false);
2129 gPosition->setEnabled(
false);
2130 bgAlign->setEnabled(
false);
2131 gTabLeader->setEnabled(
false);
2136 lay.setTabList( m_tabList );
2140 return i18n(
"&Tabulators" );
2147 int flags,
KoUnit::Unit unit,
double _frameWidth,
bool breakLine,
bool disableAll )
2148 :
KDialogBase(Tabbed, TQString(), Ok | Cancel | User1 | Apply, Ok, parent, name, true )
2150 m_decorationsWidget = 0;
2154 if ( m_flags & PD_SPACING )
2156 TQVBox * page =
addVBoxPage( i18n(
"Indent && S&pacing" ) );
2158 m_indentSpacingWidget->layout()->setMargin(0);
2160 if ( m_flags & PD_ALIGN )
2162 TQVBox * page =
addVBoxPage( i18n(
"General &Layout" ) );
2164 m_alignWidget->layout()->setMargin(0);
2166 if ( m_flags & PD_DECORATION )
2168 TQVBox * page =
addVBoxPage( i18n(
"D&ecorations" ) );
2170 m_decorationsWidget->layout()->setMargin(0);
2172 if ( m_flags & PD_NUMBERING )
2174 TQVBox * page =
addVBoxPage( i18n(
"B&ullets/Numbers" ) );
2176 m_counterWidget->layout()->setMargin(0);
2178 if ( m_flags & PD_TABS )
2180 TQVBox * page =
addVBoxPage( i18n(
"&Tabulators" ) );
2182 m_tabulatorsWidget->layout()->setMargin(0);
2185 connect(
this, TQ_SIGNAL(
user1Clicked() ),
this, TQ_SLOT(slotReset()));
2189KoParagDia::~KoParagDia()
2193void KoParagDia::slotApply()
2195 emit applyParagStyle();
2198void KoParagDia::slotOk()
2230 m_indentSpacingWidget->display( lay );
2231 m_alignWidget->display( lay );
2232 m_decorationsWidget->display( lay );
2233 m_counterWidget->display( lay );
2234 m_tabulatorsWidget->display( lay );
2238void KoParagDia::slotReset()
2240 if( m_indentSpacingWidget )
2241 m_indentSpacingWidget->display( oldLayout );
2243 m_alignWidget->display( oldLayout );
2244 if ( m_decorationsWidget )
2245 m_decorationsWidget->display( oldLayout );
2246 if( m_counterWidget )
2247 m_counterWidget->display( oldLayout );
2248 if( m_tabulatorsWidget )
2249 m_tabulatorsWidget->display( oldLayout );
2252bool KoParagDia::isCounterChanged()
const
2255 return ! ( *oldLayout.
counter == counter() );
2257 return counter().
numbering() != KoParagCounter::NUM_NONE;
2262 return paragLayout().
compare( oldLayout );
2268 newLayout.setLineSpacingValue( lineSpacing() );
2269 newLayout.lineSpacingType = lineSpacingType();
2270 newLayout.setTabList( tabListTabulator() );
2272 newLayout.
margins[TQStyleSheetItem::MarginFirstLine] = firstLineIndent();
2273 newLayout.
margins[TQStyleSheetItem::MarginLeft] = leftIndent();
2274 newLayout.
margins[TQStyleSheetItem::MarginRight] = rightIndent();
2275 newLayout.
margins[TQStyleSheetItem::MarginTop] = spaceBeforeParag();
2276 newLayout.
margins[TQStyleSheetItem::MarginBottom] = spaceAfterParag();
2277 newLayout.pageBreaking = pageBreaking();
2278 newLayout.leftBorder = leftBorder();
2279 newLayout.rightBorder = rightBorder();
2280 newLayout.topBorder = topBorder();
2281 newLayout.bottomBorder = bottomBorder();
2282 newLayout.joinBorder = joinBorder();
2288#include "KoParagDia.moc"
2289#include "KoParagDia_p.moc"
TQVBox * addVBoxPage(const TQString &itemName, const TQString &header=TQString::null, const TQPixmap &pixmap=TQPixmap())
void setInitialSize(const TQSize &s, bool noResize=false)
int pageIndex(TQWidget *widget) const
void setButtonText(ButtonCode id, const TQString &text)
virtual void setValue(double value)
This class represents a border - for anything, like paragraph, or frame.
This is the structure associated with a paragraph (KoTextParag), to define the bullet or numbering of...
Numbering numbering() const
Numbering type and style.
The complete(*) dialog for changing attributes of a paragraph.
void setCurrentPage(int page)
Make a given page the current one - page is a flag (PD_something) value.
void setParagLayout(const KoParagLayout &lay)
Set the values to be displayed.
KoParagDia(TQWidget *, const char *, int flags, KoUnit::Unit unit, double _frameWidth=-1, bool breakLine=true, bool disableAll=false)
breakLine : kpresenter didn't used this attibute, kword use it.
This class holds the paragraph-specific formatting information It's separated from KoTextParag so tha...
SpacingType
Line spacing values Assuming h is the height of the biggest char in the line, and v is the linespacin...
TQColor backgroundColor
The background color of the paragraph.
int compare(const KoParagLayout &layout) const
Return a set of flags showing the differences between this and 'layout'.
double margins[5]
left, right, top, bottom, firstLineSpacing - in pt
KoParagCounter * counter
can be 0 if no counter set
char alignment
Alignment flag (AlignAuto/AlignLeft/AlignRight/AlignJustify)
A paragraph style is a combination of a character style and paragraph-layout attributes,...
void setCounter(const KoParagCounter &counter)
Set the given counter to the preview.
void setStyle(KoParagStyle *style)
Apply the given style to the preview.
This class extends KoZoomHandler to add support for WYSIWYG text layouting.
int pixelToLayoutUnitX(int x) const
The "[zoomed] view pixel" -> "layout unit pixel" conversions.
Spin box for double precision numbers with unit display.
void setMinValue(double min)
Set minimum value in points.
KOffice stores everything in pt (using "double") internally.
static double toUserValue(double ptValue, Unit unit)
This method is the one to use to display a value in a dialog.
static double fromUserValue(double value, Unit unit)
This method is the one to use to read a value from a dialog.
static TQString unitDescription(Unit _unit)
Get the full (translated) description of a unit.
static TQString toUserStringValue(double ptValue, Unit unit)
This method is the one to use to display a value in a dialog.
Unit
Length units supported by KOffice.
static TQString unitName(Unit _unit)
Get the name of a unit.
TDEAction * zoom(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
const char * name(StdAction id)
Struct: KoTabulator Defines the position of a tabulation (in pt), and its type.
KoTabulators type
Type of tab (left/center/right/decimalpoint)
KoTabulatorFilling filling
Type of tab filling.
double ptPos
Position of the tab in pt.
TQChar alignChar
Alignment character.
double ptWidth
Width of the tab filling line.