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 <kpushbutton.h>
44#include <tqcheckbox.h>
45#include <tqcombobox.h>
46#include <tqhbuttongroup.h>
48#include <tqradiobutton.h>
53#include <tqapplication.h>
54#include <tqwidgetstack.h>
56KoCounterStyleWidget::KoCounterStyleWidget(
bool displayDepth,
bool onlyStyleTypeLetter,
bool disableAll, TQWidget * parent,
const char* name )
57 :TQWidget( parent,
name ),
62 TQVBoxLayout *vbox =
new TQVBoxLayout(
this,0, 0 );
63 gStyle =
new TQGroupBox( i18n(
"St&yle" ),
this,
"styleLayout" );
64 vbox->addWidget( gStyle);
66 grid->addRowSpacing(0, fontMetrics().height()/2);
68 makeCounterRepresenterList( stylesList, onlyStyleTypeLetter );
70 lstStyle =
new TQListBox( gStyle,
"styleListBox" );
71 grid->addMultiCellWidget( lstStyle, 1, 11, 0, 0);
73 connect( lstStyle, TQ_SIGNAL( selectionChanged() ),
this, TQ_SLOT( numStyleChanged() ) );
76 TQLabel *lPrefix =
new TQLabel( gStyle,
"lPrefix" );
77 lPrefix->setText( i18n(
"Pre&fix text:" ) );
78 grid->addWidget( lPrefix, 1, 1);
80 sPrefix =
new TQLineEdit( gStyle,
"sPrefix" );
81 lPrefix->setBuddy( sPrefix );
82 grid->addWidget( sPrefix, 1, 2);
84 TQLabel *lSuffix =
new TQLabel( gStyle,
"lSuffix" );
85 lSuffix->setText( i18n(
"Suffi&x text:" ) );
86 grid->addWidget( lSuffix, 1, 3);
88 sSuffix =
new TQLineEdit( gStyle,
"sSuffix" );
89 lSuffix->setBuddy( sSuffix );
90 grid->addWidget( sSuffix, 1, 4 );
92 lStart =
new TQLabel( gStyle,
"lStart" );
93 lStart->setText( i18n(
"&Start at:" ) );
94 grid->addWidget( lStart, 2, 1 );
97 spnDepth =
new TQSpinBox( 0, 15, 1, gStyle );
99 grid->addWidget( spnDepth, 3, 2 );
103 spnDisplayLevels =
new TQSpinBox( 0, 15, 1, gStyle );
104 spnDisplayLevels->setMinValue( 1 );
106 grid->addWidget( spnDisplayLevels, 3, 4 );
108 spnDisplayLevels->hide();
111 TQHBoxLayout *customCharBox =
new TQHBoxLayout(0, 0, 6);
112 lCustom =
new TQLabel( i18n(
"Custo&m character:" ), gStyle,
"custom char label" );
113 customCharBox->addWidget( lCustom );
115 bCustom =
new TQPushButton(
"", gStyle,
"bCustom" );
116 lCustom->setBuddy( bCustom );
117 customCharBox->addWidget( bCustom );
118 connect( bCustom, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( selectCustomBullet() ) );
120 TQSpacerItem* spacer_2 =
new TQSpacerItem( 0, 0, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
121 customCharBox->addItem( spacer_2 );
123 grid->addMultiCellLayout(customCharBox, 4, 4, 1, 4, TQt::AlignLeft);
125 spnStart =
new KoSpinBox( gStyle );
126 spnStart->setMinValue ( 1);
127 lStart->setBuddy( spnStart );
128 grid->addWidget( spnStart, 2, 2);
130 lAlignment =
new TQLabel( gStyle,
"lAlignment" );
131 lAlignment->setText( i18n(
"Counter alignment:" ) );
132 grid->addWidget( lAlignment, 2, 3 );
134 cbAlignment =
new KComboBox( gStyle,
"cbAlignment" );
135 cbAlignment->insertItem(i18n(
"Align Auto"));
136 cbAlignment->insertItem(i18n(
"Align Left"));
137 cbAlignment->insertItem(i18n(
"Align Right"));
138 cbAlignment->setCurrentItem(0);
139 grid->addWidget( cbAlignment, 2, 4 );
141 TQLabel *lDepth =
new TQLabel( gStyle,
"lDepth" );
142 lDepth->setText( i18n(
"&Depth:" ) );
143 lDepth->setBuddy( spnDepth );
145 grid->addWidget( lDepth, 3, 1 );
149 TQLabel *lDisplayLevels =
new TQLabel( gStyle );
150 lDisplayLevels->setText( i18n(
"Display le&vels:" ) );
151 lDisplayLevels->setBuddy( spnDisplayLevels );
153 grid->addWidget( lDisplayLevels, 3, 3 );
155 lDisplayLevels->hide();
157 cbRestart =
new TQCheckBox( i18n(
"&Restart numbering at this paragraph" ), gStyle );
158 grid->addMultiCellWidget( cbRestart, 5, 5, 1, 3 );
160 if ( onlyStyleTypeLetter )
168 connect( cbRestart, TQ_SIGNAL( toggled(
bool) ),
this, TQ_SLOT( restartChanged(
bool) ) );
170 connect( sSuffix, TQ_SIGNAL( textChanged (
const TQString &) ),
this, TQ_SLOT( suffixChanged(
const TQString &) ) );
171 connect( sPrefix, TQ_SIGNAL( textChanged (
const TQString &) ),
this, TQ_SLOT( prefixChanged(
const TQString &) ) );
172 connect( spnStart, TQ_SIGNAL( valueChanged (
int) ),
this, TQ_SLOT( startChanged(
int) ) );
173 connect( spnDepth, TQ_SIGNAL( valueChanged (
int) ),
this, TQ_SLOT( depthChanged(
int) ) );
174 connect( spnDisplayLevels, TQ_SIGNAL( valueChanged (
int) ),
this, TQ_SLOT( displayLevelsChanged(
int) ) );
175 connect( cbAlignment, TQ_SIGNAL( activated (
const TQString&) ),
this, TQ_SLOT( alignmentChanged(
const TQString&) ) );
179 gStyle->setEnabled(
false );
180 lstStyle->setEnabled(
false );
181 sSuffix->setEnabled(
false );
182 sPrefix->setEnabled(
false );
183 bCustom->setEnabled(
false );
184 spnStart->setEnabled(
false );
185 spnDepth->setEnabled(
false );
186 spnDisplayLevels->setEnabled(
false );
187 lStart->setEnabled(
false );
188 lCustom->setEnabled(
false );
189 cbRestart->setEnabled(
false );
190 cbAlignment->setEnabled(
false );
194void KoCounterStyleWidget::alignmentChanged(
const TQString& s)
197 if(s==i18n(
"Align Left"))
199 else if(s==i18n(
"Align Right"))
201 else if(s==i18n(
"Align Auto"))
204 kdError()<<
"Not Implemented"<<endl;
207 m_counter.setAlignment(a);
208 emit sig_alignmentChanged(a);
211void KoCounterStyleWidget::setCounter(
const KoParagCounter& counter )
214 KoParagCounter::Style st = counter.style();
218 changeKWSpinboxType( st);
223void KoCounterStyleWidget::changeKWSpinboxType(KoParagCounter::Style st) {
226 case KoParagCounter::STYLE_NONE:
227 spnStart->setCounterType(KoSpinBox::NONE);
229 case KoParagCounter::STYLE_NUM:
230 spnStart->setCounterType(KoSpinBox::NUM);
232 case KoParagCounter::STYLE_ALPHAB_L:
233 spnStart->setCounterType(KoSpinBox::ALPHAB_L);
235 case KoParagCounter::STYLE_ALPHAB_U:
236 spnStart->setCounterType(KoSpinBox::ALPHAB_U);
238 case KoParagCounter::STYLE_ROM_NUM_L:
239 spnStart->setCounterType(KoSpinBox::ROM_NUM_L);
241 case KoParagCounter::STYLE_ROM_NUM_U:
242 spnStart->setCounterType(KoSpinBox::ROM_NUM_U);
245 spnStart->setCounterType(KoSpinBox::NONE);
250void KoCounterStyleWidget::fillStyleCombo(KoParagCounter::Numbering type) {
251 if(lstStyle==NULL)
return;
253 unsigned int cur = lstStyle->currentItem();
255 TQPtrListIterator<StyleRepresenter> style( stylesList );
256 while ( style.current() ) {
257 if(style.current()->style() == KoParagCounter::STYLE_NONE) {
258 if(type == KoParagCounter::NUM_NONE)
259 lstStyle->insertItem( style.current()->name() );
261 else if(type == KoParagCounter::NUM_LIST || !style.current()->isBullet())
262 if(type != KoParagCounter::NUM_NONE)
263 lstStyle->insertItem( style.current()->name() );
267 if(styleBuffer <= lstStyle->count())
268 lstStyle->setCurrentItem(styleBuffer);
270 if(cur <= lstStyle->count())
271 lstStyle->setCurrentItem(cur);
273 if(cur > lstStyle->count()) {
279void KoCounterStyleWidget::displayStyle( KoParagCounter::Style style )
282 while ( stylesList.count() > i && stylesList.at(i)->style() != style )
284 lstStyle->setCurrentItem(i);
286 bCustom->setText( m_counter.customBulletCharacter() );
287 if ( !m_counter.customBulletFont().isEmpty() )
288 bCustom->setFont( TQFont( m_counter.customBulletFont() ) );
290 sPrefix->setText( m_counter.prefix() );
291 sSuffix->setText( m_counter.suffix() );
293 spnDepth->setValue( m_counter.depth() );
294 spnDisplayLevels->setValue( m_counter.displayLevels() );
295 spnStart->setValue( m_counter.startNumber() );
297 cbRestart->setChecked( m_counter.restartCounter() );
298 if(m_counter.alignment()==TQt::AlignLeft)
299 cbAlignment->setCurrentText(i18n(
"Align Left"));
300 else if(m_counter.alignment()==TQt::AlignRight)
301 cbAlignment->setCurrentText(i18n(
"Align Right"));
302 else if(m_counter.alignment()==TQt::AlignAuto)
303 cbAlignment->setCurrentText(i18n(
"Align Auto"));
305 kdError()<<
"Not Implemented"<<endl;
308void KoCounterStyleWidget::display(
const KoParagLayout & lay ) {
309 KoParagCounter::Style style = KoParagCounter::STYLE_NONE;
317 m_counter = KoParagCounter();
321 numTypeChanged( m_counter.numbering() );
322 emit sig_numTypeChanged( m_counter.numbering() );
324 displayStyle( style );
328void KoCounterStyleWidget::numTypeChanged(
int nType ) {
329 m_counter.setNumbering(
static_cast<KoParagCounter::Numbering
>( nType ) );
330 gStyle->setEnabled( m_counter.numbering() != KoParagCounter::NUM_NONE );
331 fillStyleCombo(m_counter.numbering());
332 bool state=m_counter.numbering()==KoParagCounter::NUM_LIST;
333 bCustom->setEnabled(state);
334 lCustom->setEnabled(state);
338void KoCounterStyleWidget::makeCounterRepresenterList( TQPtrList<StyleRepresenter>& stylesList,
bool onlyStyleTypeLetter )
340 stylesList.setAutoDelete(
true );
341 stylesList.append(
new StyleRepresenter(i18n(
"Arabic Numbers" )
342 , KoParagCounter::STYLE_NUM));
343 stylesList.append(
new StyleRepresenter(i18n(
"Lower Alphabetical" )
344 , KoParagCounter::STYLE_ALPHAB_L ));
345 stylesList.append(
new StyleRepresenter(i18n(
"Upper Alphabetical" )
346 , KoParagCounter::STYLE_ALPHAB_U ));
347 stylesList.append(
new StyleRepresenter(i18n(
"Lower Roman Numbers" )
348 , KoParagCounter::STYLE_ROM_NUM_L ));
349 stylesList.append(
new StyleRepresenter(i18n(
"Upper Roman Numbers" )
350 , KoParagCounter::STYLE_ROM_NUM_U ));
351 if ( !onlyStyleTypeLetter )
353 stylesList.append(
new StyleRepresenter(i18n(
"Disc Bullet" )
354 , KoParagCounter::STYLE_DISCBULLET ,
true));
355 stylesList.append(
new StyleRepresenter(i18n(
"Square Bullet" )
356 , KoParagCounter::STYLE_SQUAREBULLET ,
true));
357 stylesList.append(
new StyleRepresenter(i18n(
"Box Bullet" )
358 , KoParagCounter::STYLE_BOXBULLET ,
true));
359 stylesList.append(
new StyleRepresenter(i18n(
"Circle Bullet" )
360 , KoParagCounter::STYLE_CIRCLEBULLET ,
true));
361 stylesList.append(
new StyleRepresenter(i18n(
"Custom Bullet" )
362 , KoParagCounter::STYLE_CUSTOMBULLET ,
true));
364 stylesList.append(
new StyleRepresenter(i18n(
"None" ), KoParagCounter::STYLE_NONE));
368void KoCounterStyleWidget::selectCustomBullet() {
370 while ( stylesList.count() > i && stylesList.at(i)->style() != KoParagCounter::STYLE_CUSTOMBULLET )
372 lstStyle->setCurrentItem(i);
374 TQString f = m_counter.customBulletFont();
377 TQChar c = m_counter.customBulletCharacter();
379 if ( KoCharSelectDia::selectChar( f, c ) ) {
380 emit changeCustomBullet( f, c );
381 m_counter.setCustomBulletFont( f );
382 m_counter.setCustomBulletCharacter( c );
384 bCustom->setFont( TQFont( f ) );
385 bCustom->setText( c );
389void KoCounterStyleWidget::numStyleChanged() {
394 StyleRepresenter *sr = stylesList.at(lstStyle->currentItem());
395 emit changeStyle( sr->style() );
396 m_counter.setStyle( sr->style() );
397 bool isNumbered = !sr->isBullet() && !sr->style() == KoParagCounter::STYLE_NONE;
398 lStart->setEnabled( isNumbered );
399 spnStart->setEnabled( isNumbered );
400 cbRestart->setEnabled( isNumbered );
401 spnDisplayLevels->setEnabled( isNumbered );
402 changeKWSpinboxType(sr->style() );
407KoSpinBox::KoSpinBox( TQWidget * parent,
const char * name )
408 : TQSpinBox(parent,
name)
412 setMaxValue ( 3999 );
414KoSpinBox::~KoSpinBox( )
418KoSpinBox::KoSpinBox(
int minValue,
int maxValue,
int step ,
419 TQWidget * parent ,
const char * name )
420 : TQSpinBox(minValue, maxValue,step ,
426void KoSpinBox::setCounterType(counterType _type)
429 editor()->setText(mapValueToText(value()));
433TQString KoSpinBox::mapValueToText(
int value )
435 if(value==0 && m_Etype==NUM)
436 return TQString(
"0");
437 else if(value==0 && m_Etype!=NUM)
442 return TQString::number(value);
444 return KoParagCounter::makeAlphaLowerNumber( value );
446 return KoParagCounter::makeAlphaUpperNumber( value );
448 return KoParagCounter::makeRomanNumber( value );
450 return KoParagCounter::makeRomanNumber( value ).upper();
459int KoSpinBox::mapTextToValue(
bool * ok )
462 TQString txt = text();
468 ret = txt.toInt ( ok );
471 ret = KoParagCounter::fromAlphaLowerNumber( txt.lower() );
474 ret = KoParagCounter::fromAlphaUpperNumber( txt.upper() );
477 ret = KoParagCounter::fromRomanNumber( txt.lower() );
480 ret = KoParagCounter::fromRomanNumber( txt.lower() );
499KPagePreview::KPagePreview( TQWidget* parent,
const char* name )
500 : TQGroupBox( i18n(
"Preview" ), parent,
name )
510void KPagePreview::drawContents( TQPainter* p )
514 int _x = ( width() - wid ) / 5;
515 int _y = ( height() - hei ) / 5;
517 int dl = convert(left);
518 int dr = convert(right);
521 int df = convert(first + left);
523 int spc = convert(spacing);
526 p->setPen( TQPen( black ) );
527 p->setBrush( TQBrush( black ) );
529 p->drawRect( _x + 1, _y + 1, wid, hei );
531 p->setBrush( TQBrush( white ) );
532 p->drawRect( _x, _y, wid, hei );
536 p->setBrush( TQBrush( lightGray ) );
538 for (
int i = 1; i <= 4; i++ )
539 p->drawRect( _x + 6, _y + 6 + ( i - 1 ) * 12 + 2, wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ), 6 );
541 p->setBrush( TQBrush( darkGray ) );
543 for (
int i = 5; i <= 8; i++ )
545 TQRect rect( ( i == 5 ? df : dl ) + _x + 6, _y + 6 + ( i - 1 ) * 12 + 2 + ( i - 5 ) * spc +
static_cast<int>( before / 2 ),
546 wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ) - ( ( i == 12 ? 0 : dr ) + ( i == 5 ? df : dl ) ), 6);
551 p->setBrush( TQBrush( lightGray ) );
553 for (
int i = 9; i <= 12; i++ )
554 p->drawRect( _x + 6, _y + 6 + ( i - 1 ) * 12 + 2 + 3 * spc +
555 static_cast<int>( before / 2 ) +
static_cast<int>( after / 2 ),
556 wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ), 6 );
560int KPagePreview::convert(
double input) {
561 if(input < 1)
return 0;
562 if(input <= 5)
return 3;
563 if(input <= 10)
return 4 +
static_cast<int>( (input-5) / 2.5 );
564 if(input <= 20)
return 6 +
static_cast<int>( (input-10) / 4 );
565 if(input <= 100)
return 10 +
static_cast<int>( (input-20) / 8 );
566 return static_cast<int>( input / 5);
573KPagePreview2::KPagePreview2( TQWidget* parent,
const char* name )
574 : TQGroupBox( i18n(
"Preview" ), parent,
name )
576 align = TQt::AlignLeft;
579void KPagePreview2::drawContents( TQPainter* p )
583 int _x = ( width() - wid ) / 2;
584 int _y = ( height() - hei ) / 2;
587 p->setPen( TQPen( black ) );
588 p->setBrush( TQBrush( black ) );
590 p->drawRect( _x + 1, _y + 1, wid, hei );
592 p->setBrush( TQBrush( white ) );
593 p->drawRect( _x, _y, wid, hei );
597 p->setBrush( TQBrush( lightGray ) );
599 for (
int i = 1; i <= 4; i++ )
600 p->drawRect( _x + 6, _y + 6 + ( i - 1 ) * 12 + 2, wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ), 6 );
602 p->setBrush( TQBrush( darkGray ) );
604 int __x = 0, __w = 0;
605 for (
int i = 5; i <= 8; i++ ) {
607 case 5: __w = wid - 12;
609 case 6: __w = wid - 52;
611 case 7: __w = wid - 33;
613 case 8: __w = wid - 62;
622 case TQt::AlignHCenter:
623 __x = _x + ( wid - __w ) / 2;
625 case TQt::AlignRight:
626 __x = _x + ( wid - __w ) - 6;
628 case TQt::AlignJustify:
630 if ( i < 8 ) __w = wid - 12;
635 p->drawRect( __x, _y + 6 + ( i - 1 ) * 12 + 2 + ( i - 5 ), __w, 6 );
638 p->setBrush( TQBrush( lightGray ) );
640 for (
int i = 9; i <= 12; i++ )
641 p->drawRect( _x + 6, _y + 6 + ( i - 1 ) * 12 + 2 + 3, wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ), 6 );
650KoBorderPreview::KoBorderPreview( TQWidget* parent,
const char* name )
651 :TQFrame(parent,
name)
655void KoBorderPreview::mousePressEvent( TQMouseEvent *_ev )
657 emit choosearea(_ev);
660void KoBorderPreview::setBorder( KoBorder::BorderType which,
const KoBorder& border)
663 case KoBorder::TopBorder:
664 setTopBorder( border );
666 case KoBorder::BottomBorder:
667 setBottomBorder( border );
669 case KoBorder::LeftBorder:
670 setLeftBorder( border );
672 case KoBorder::RightBorder:
673 setRightBorder( border );
676 kdError() <<
"KoBorderPreview: unknown border type" << endl;
680void KoBorderPreview::drawContents( TQPainter* painter )
682 TQRect r = contentsRect();
683 TQFontMetrics fm( font() );
685 painter->fillRect( r.x() + fm.width(
'W' ), r.y() + fm.height(), r.width() - 2 * fm.width(
'W' ),
686 r.height() - 2 * fm.height(), white );
687 painter->setClipRect( r.x() + fm.width(
'W' ), r.y() + fm.height(), r.width() - 2 * fm.width(
'W' ),
688 r.height() - 2 * fm.height() );
690 bool leftdouble = m_leftBorder.width() > 0 && m_leftBorder.getStyle() == KoBorder::DOUBLE_LINE;
691 bool rightdouble = m_rightBorder.width() > 0 && m_rightBorder.getStyle() == KoBorder::DOUBLE_LINE;
692 bool topdouble = m_topBorder.width() > 0 && m_topBorder.getStyle() == KoBorder::DOUBLE_LINE;
693 bool bottomdouble = m_bottomBorder.width() > 0 && m_bottomBorder.getStyle() == KoBorder::DOUBLE_LINE;
695 if ( m_topBorder.width() > 0 ) {
696 painter->setPen( setBorderPen( m_topBorder ) );
697 painter->drawLine( r.x() + 20, r.y() + 30, r.right() - 19, r.y() + 30 );
698 if ( m_topBorder.getStyle()==KoBorder::DOUBLE_LINE)
699 painter->drawLine(
int(r.x() + 20 + ( leftdouble ? m_leftBorder.width() + 1 : 0) ),
700 int(r.y() + 30 + m_topBorder.width()+1),
701 int(r.right() - 19 - ( rightdouble ? m_rightBorder.width() + 1 : 0) ),
702 int(r.y() + 30 + m_topBorder.width()+1)
706 if ( m_bottomBorder.width() > 0 ) {
707 painter->setPen( setBorderPen( m_bottomBorder ) );
708 painter->drawLine( r.x() + 20, r.bottom() - 30, r.right() - 19, r.bottom() - 30 );
709 if ( m_bottomBorder.getStyle()==KoBorder::DOUBLE_LINE)
710 painter->drawLine(
int(r.x() + 20 + ( leftdouble ? m_leftBorder.width() + 1 : 0) ),
711 int(r.bottom() - 30 - m_bottomBorder.width()-1),
712 int(r.right() - 19 - ( rightdouble ? m_rightBorder.width() + 1 : 0) ),
713 int(r.bottom() - 30 - m_bottomBorder.width() - 1)
717 if ( m_leftBorder.width() > 0 ) {
718 painter->setPen( setBorderPen( m_leftBorder ) );
719 painter->drawLine( r.x() + 20, r.y() + 30, r.x() + 20, r.bottom() - 29 );
720 if ( m_leftBorder.getStyle()==KoBorder::DOUBLE_LINE)
721 painter->drawLine(
int(r.x() + 20 + m_leftBorder.width() +1),
722 int(r.y() + 30 + ( topdouble ? m_topBorder.width() + 1 : 0) ),
723 int(r.x() + 20 + m_leftBorder.width() +1),
724 int(r.bottom() - 29 - ( bottomdouble ? m_bottomBorder.width() + 1 : 0) )
728 if ( m_rightBorder.width() > 0 ) {
729 painter->setPen( setBorderPen( m_rightBorder ) );
730 painter->drawLine( r.right() - 20, r.y() + 30, r.right() - 20, r.bottom() - 29 );
731 if ( m_rightBorder.getStyle()==KoBorder::DOUBLE_LINE)
732 painter->drawLine(
int(r.right() - 20 - m_rightBorder.width() - 1 ),
733 int(r.y() + 30 + ( topdouble ? m_topBorder.width() + 1 : 0) ),
734 int(r.right() - 20 - m_rightBorder.width() - 1),
735 int(r.bottom() - 29 - ( bottomdouble ? m_bottomBorder.width() + 1 : 0) )
740TQPen KoBorderPreview::setBorderPen(
KoBorder _brd )
742 TQPen pen( black, 1, SolidLine );
744 pen.setWidth(
static_cast<int>( _brd.penWidth() ) );
745 pen.setColor( _brd.color );
747 switch ( _brd.getStyle() ) {
748 case KoBorder::SOLID:
749 pen.setStyle( TQt::SolidLine );
752 pen.setStyle( TQt::DashLine );
755 pen.setStyle( TQt::DotLine );
757 case KoBorder::DASH_DOT:
758 pen.setStyle( TQt::DashDotLine );
760 case KoBorder::DASH_DOT_DOT:
761 pen.setStyle( TQt::DashDotDotLine );
763 case KoBorder::DOUBLE_LINE:
764 pen.setStyle( TQt::SolidLine );
774class MyFlow :
public KoTextFlow {
776 MyFlow(TQWidget *parent, KoTextZoomHandler *zoom) {
778 m_zoomHandler =
zoom;
780 int availableHeight()
const {
781 return m_zoomHandler->pixelToLayoutUnitY(m_parent->height());
785 KoTextZoomHandler *m_zoomHandler;
788KoStylePreview::KoStylePreview(
const TQString& title,
const TQString& text, TQWidget* parent,
const char* name )
789 : TQGroupBox( title, parent,
name )
791 setMinimumHeight(80);
793 TQFont font = KoGlobal::defaultFont();
794 m_textdoc =
new KoTextDocument( m_zoomHandler,
new KoTextFormatCollection( font, TQColor(), TDEGlobal::locale()->language(),
false ) );
796 m_textdoc->setFlow(
new MyFlow(
this, m_zoomHandler) );
798 KoTextParag * parag = m_textdoc->firstParag();
799 parag->insert( 0, text );
802KoStylePreview::~KoStylePreview()
805 delete m_zoomHandler;
810 KoTextParag * parag = m_textdoc->firstParag();
811 parag->setCounter( counter );
817 KoTextParag * parag = m_textdoc->firstParag();
818 parag->applyStyle( style );
822void KoStylePreview::drawContents( TQPainter *painter )
825 TQRect r = contentsRect();
828 TQRect whiteRect( r.x() + 10, r.y() + 10,
829 r.width() - 20, r.height() - 20 );
830 TQColorGroup cg = TQApplication::palette().active();
831 painter->fillRect( whiteRect, cg.brush( TQColorGroup::Base ) );
833 KoTextParag * parag = m_textdoc->firstParag();
835 if ( m_textdoc->width() != widthLU )
838 m_textdoc->setWidth( widthLU );
839 parag->invalidate(0);
843 TQRect textRect = parag->pixelRect( m_zoomHandler );
846 textRect.moveTopLeft( TQPoint( whiteRect.x(),
847 whiteRect.y() + ( whiteRect.height() - textRect.height() ) / 2 ) );
849 textRect.rLeft() += 4;
850 textRect.rRight() += 4;
853 painter->setClipRect( textRect.intersect( whiteRect ) );
854 painter->translate( textRect.x(), textRect.y() );
856 m_textdoc->drawWYSIWYG( painter, 0, 0, textRect.width(), textRect.height(), cg, m_zoomHandler );
860KoIndentSpacingWidget::KoIndentSpacingWidget(
KoUnit::Unit unit,
double _frameWidth,TQWidget * parent,
const char * name )
873 double frameWidth=_frameWidth;
878 length=i18n(
"Frame width: %1 %2")
884 TQGroupBox * indentFrame =
new TQGroupBox( i18n(
"Indent" ),
this );
887 TQLabel * lLimit =
new TQLabel(length , indentFrame );
890 lLimit->setAlignment( AlignRight );
891 indentGrid->addWidget( lLimit, 1,0 );
894 TQLabel * lLeft =
new TQLabel( i18n(
"&Left:"), indentFrame );
895 lLeft->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
896 indentGrid->addWidget( lLeft, 1, 0 );
898 eLeft =
new KoUnitDoubleSpinBox( indentFrame, 0, 9999, 1, 0.0, m_unit );
899 lLeft->setBuddy( eLeft );
900 indentGrid->addWidget( eLeft, 1, 1 );
901 connect( eLeft, TQ_SIGNAL( valueChangedPt(
double ) ),
this, TQ_SLOT( leftChanged(
double ) ) );
903 TQLabel * lRight =
new TQLabel( i18n(
"&Right:"), indentFrame );
904 lRight->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
905 indentGrid->addWidget( lRight, 2, 0 );
907 eRight =
new KoUnitDoubleSpinBox( indentFrame, 0, 9999, 1, 0.0, m_unit );
908 lRight->setBuddy( eRight );
909 indentGrid->addWidget( eRight, 2, 1 );
910 connect( eRight, TQ_SIGNAL( valueChangedPt(
double ) ),
this, TQ_SLOT( rightChanged(
double ) ) );
912 TQLabel * lFirstLine =
new TQLabel( i18n(
"&First line:"), indentFrame );
913 lFirstLine->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
914 indentGrid->addWidget( lFirstLine, 3, 0 );
916 eFirstLine =
new KoUnitDoubleSpinBox( indentFrame, -9999, 9999, 1, 0.0, m_unit );
917 lFirstLine->setBuddy( eFirstLine );
918 connect( eFirstLine, TQ_SIGNAL( valueChangedPt(
double ) ),
this, TQ_SLOT( firstChanged(
double ) ) );
919 indentGrid->addWidget( eFirstLine, 3, 1 );
922 indentGrid->addRowSpacing( 0, fontMetrics().height() / 2 );
923 for (
int i = 1 ; i < indentGrid->numRows() ; ++i )
924 indentGrid->setRowStretch( i, 1 );
925 mainGrid->addWidget( indentFrame, 0, 0 );
928 TQGroupBox * spacingFrame =
new TQGroupBox( i18n(
"Line &Spacing" ),
this,
"spacingFrame" );
929 TQGridLayout * spacingGrid =
new TQGridLayout( spacingFrame, 2, 1,
932 cSpacing =
new TQComboBox(
false, spacingFrame,
"" );
934 cSpacing->insertItem( i18n(
"Line spacing value",
"Single" ) );
935 cSpacing->insertItem( i18n(
"Line spacing value",
"1.5 Lines" ) );
936 cSpacing->insertItem( i18n(
"Line spacing value",
"Double" ) );
937 cSpacing->insertItem( i18n(
"Proportional") );
938 cSpacing->insertItem( i18n(
"Line Distance (%1)" ).arg(unitName) );
939 cSpacing->insertItem( i18n(
"At Least (%1)" ).arg(unitName) );
940 cSpacing->insertItem( i18n(
"Fixed (%1)").arg(unitName) );
942 connect( cSpacing, TQ_SIGNAL( activated(
int ) ),
this, TQ_SLOT( spacingActivated(
int ) ) );
943 spacingGrid->addWidget( cSpacing, 1, 0 );
945 sSpacingStack =
new TQWidgetStack( spacingFrame );
947 eSpacing =
new KoUnitDoubleSpinBox( spacingFrame, 0, 9999, CM_TO_POINT(1),
949 eSpacing->setRange( 0, 9999, 1,
false);
950 connect( eSpacing, TQ_SIGNAL( valueChanged(
double ) ),
this, TQ_SLOT( spacingChanged(
double ) ) );
951 eSpacingPercent =
new KIntNumInput( 100, spacingFrame );
952 eSpacingPercent->setRange( 0, 1000, 10,
false );
953 eSpacingPercent->setSuffix(
" %" );
954 connect( eSpacingPercent, TQ_SIGNAL( valueChanged(
int ) ),
this, TQ_SLOT( spacingChanged(
int ) ) );
956 sSpacingStack->addWidget( eSpacing );
957 sSpacingStack->addWidget( eSpacingPercent );
958 spacingGrid->addWidget( sSpacingStack, 1, 1 );
961 spacingGrid->addRowSpacing( 0, fontMetrics().height() / 2 );
962 for (
int i = 1 ; i < spacingGrid->numRows() ; ++i )
963 spacingGrid->setRowStretch( i, 1 );
964 mainGrid->addWidget( spacingFrame, 1, 0 );
966 eSpacing->setEnabled(
true );
969 TQGroupBox * pSpaceFrame =
new TQGroupBox( i18n(
"Para&graph Space" ),
this,
"pSpaceFrame" );
970 TQGridLayout * pSpaceGrid =
new TQGridLayout( pSpaceFrame, 3, 2,
973 TQLabel * lBefore =
new TQLabel( i18n(
"Before:"), pSpaceFrame );
974 lBefore->setAlignment( AlignRight );
975 pSpaceGrid->addWidget( lBefore, 1, 0 );
977 eBefore =
new KoUnitDoubleSpinBox( pSpaceFrame, 0, 9999, CM_TO_POINT(1), 0.0, m_unit );
978 eBefore->setRange( 0 , 9999, 1,
false);
979 connect( eBefore, TQ_SIGNAL( valueChanged(
double ) ),
this, TQ_SLOT( beforeChanged(
double ) ) );
980 pSpaceGrid->addWidget( eBefore, 1, 1 );
982 TQLabel * lAfter =
new TQLabel( i18n(
"After:"), pSpaceFrame );
983 lAfter->setAlignment( AlignRight );
984 pSpaceGrid->addWidget( lAfter, 2, 0 );
986 eAfter =
new KoUnitDoubleSpinBox( pSpaceFrame, 0, 9999, 1, 0.0, m_unit );
987 eAfter->setRange( 0, 9999, 1,
false);
988 connect( eAfter, TQ_SIGNAL( valueChanged(
double ) ),
this, TQ_SLOT( afterChanged(
double ) ) );
989 pSpaceGrid->addWidget( eAfter, 2, 1 );
992 pSpaceGrid->addRowSpacing( 0, fontMetrics().height() / 2 );
993 for (
int i = 1 ; i < pSpaceGrid->numRows() ; ++i )
994 pSpaceGrid->setRowStretch( i, 1 );
995 mainGrid->addWidget( pSpaceFrame, 2, 0 );
998 prev1 =
new KPagePreview(
this,
"KPagePreview" );
999 mainGrid->addMultiCellWidget( prev1, 0, mainGrid->numRows()-1, 1, 1 );
1001 mainGrid->setColStretch( 1, 1 );
1005double KoIndentSpacingWidget::leftIndent()
const
1007 return TQMAX(0, eLeft->value() );
1010double KoIndentSpacingWidget::rightIndent()
const
1012 return TQMAX(0,eRight->value() );
1015double KoIndentSpacingWidget::firstLineIndent()
const
1017 return eFirstLine->value();
1020double KoIndentSpacingWidget::spaceBeforeParag()
const
1022 return TQMAX(0, eBefore->value() );
1025double KoIndentSpacingWidget::spaceAfterParag()
const
1027 return TQMAX(0, eAfter->value() );
1032 int index = cSpacing->currentItem();
1035 return KoParagLayout::LS_SINGLE;
1037 return KoParagLayout::LS_ONEANDHALF;
1039 return KoParagLayout::LS_DOUBLE;
1041 return KoParagLayout::LS_MULTIPLE;
1043 return KoParagLayout::LS_CUSTOM;
1045 return KoParagLayout::LS_AT_LEAST;
1047 return KoParagLayout::LS_FIXED;
1049 kdError(32500) <<
"Error in KoIndentSpacingWidget::lineSpacingType" << endl;
1050 return KoParagLayout::LS_SINGLE;
1054double KoIndentSpacingWidget::lineSpacing()
const
1056 return (lineSpacingType() == KoParagLayout::LS_MULTIPLE)
1057 ? TQMAX( 1, eSpacingPercent->value() ) / 100.0
1058 : TQMAX( 0, eSpacing->value() );
1062void KoIndentSpacingWidget::display(
const KoParagLayout & lay )
1064 double _left = lay.
margins[TQStyleSheetItem::MarginLeft];
1065 eLeft->changeValue( _left );
1067 leftChanged( _left );
1069 double _right = lay.
margins[TQStyleSheetItem::MarginRight];
1070 eRight->changeValue( _right );
1071 prev1->setRight( _right );
1073 double _first = lay.
margins[TQStyleSheetItem::MarginFirstLine];
1074 eFirstLine->changeValue( _first );
1075 prev1->setFirst( _first );
1077 double _before = lay.
margins[TQStyleSheetItem::MarginTop];
1078 eBefore->changeValue( _before );
1079 prev1->setBefore( _before );
1081 double _after = lay.
margins[TQStyleSheetItem::MarginBottom];
1082 eAfter->changeValue( _after );
1083 prev1->setAfter( _after );
1085 double _spacing = lay.lineSpacingValue();
1088 case KoParagLayout::LS_SINGLE:
1089 cSpacing->setCurrentItem( 0 );
1091 case KoParagLayout::LS_ONEANDHALF:
1092 cSpacing->setCurrentItem( 1 );
1094 case KoParagLayout::LS_DOUBLE:
1095 cSpacing->setCurrentItem( 2 );
1097 case KoParagLayout::LS_MULTIPLE:
1098 cSpacing->setCurrentItem( 3 );
1100 case KoParagLayout::LS_CUSTOM:
1101 cSpacing->setCurrentItem( 4 );
1103 case KoParagLayout::LS_AT_LEAST:
1104 cSpacing->setCurrentItem( 5 );
1106 case KoParagLayout::LS_FIXED:
1107 cSpacing->setCurrentItem( 6 );
1110 cSpacing->setCurrentItem( 0 );
1114 updateLineSpacing( _type );
1115 eSpacing->setValue( (_type == KoParagLayout::LS_MULTIPLE) ? TQMAX( 1, _spacing )
1117 eSpacingPercent->setValue( ( _type == KoParagLayout::LS_MULTIPLE ) ? tqRound( _spacing * 100 ) : 100 );
1122 lay.setLineSpacingValue(lineSpacing());
1123 lay.lineSpacingType = lineSpacingType();
1124 lay.
margins[TQStyleSheetItem::MarginLeft] = leftIndent();
1125 lay.
margins[TQStyleSheetItem::MarginRight] = rightIndent();
1126 lay.
margins[TQStyleSheetItem::MarginFirstLine] = firstLineIndent();
1127 lay.
margins[TQStyleSheetItem::MarginTop] = spaceBeforeParag();
1128 lay.
margins[TQStyleSheetItem::MarginBottom] = spaceAfterParag();
1133 return i18n(
"Indent && S&pacing" );
1136void KoIndentSpacingWidget::leftChanged(
double val )
1138 prev1->setLeft( val );
1143void KoIndentSpacingWidget::rightChanged(
double val )
1145 prev1->setRight( val );
1148void KoIndentSpacingWidget::firstChanged(
double val )
1150 prev1->setFirst( val );
1155 bool needsValue = (_type != KoParagLayout::LS_SINGLE &&
1156 _type != KoParagLayout::LS_ONEANDHALF &&
1157 _type != KoParagLayout::LS_DOUBLE);
1159 if ( _type == KoParagLayout::LS_MULTIPLE )
1161 sSpacingStack->raiseWidget( eSpacingPercent );
1165 sSpacingStack->raiseWidget( eSpacing );
1167 eSpacing->setEnabled( needsValue );
1169 prev1->setSpacing( eSpacing->value() );
1172 prev1->setSpacing( _type == KoParagLayout::LS_ONEANDHALF ? 8 :
1173 _type == KoParagLayout::LS_DOUBLE ? 16 :0 );
1177void KoIndentSpacingWidget::spacingActivated(
int )
1179 updateLineSpacing( lineSpacingType() );
1180 if ( eSpacing->isEnabled() )
1181 eSpacing->setFocus();
1184void KoIndentSpacingWidget::spacingChanged(
double _val )
1186 prev1->setSpacing( _val );
1189void KoIndentSpacingWidget::spacingChanged(
int _val )
1191 prev1->setSpacing( _val / 100.0 );
1194void KoIndentSpacingWidget::beforeChanged(
double _val )
1199void KoIndentSpacingWidget::afterChanged(
double _val )
1205KoParagAlignWidget::KoParagAlignWidget(
bool breakLine, TQWidget * parent,
const char * name )
1210 TQVGroupBox * AlignGroup =
new TQVGroupBox( i18n(
"Alignment" ),
this );
1212 rLeft =
new TQRadioButton( i18n(
"&Left" ), AlignGroup );
1213 connect( rLeft, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( alignLeft() ) );
1215 rCenter =
new TQRadioButton( i18n(
"C&enter" ), AlignGroup );
1216 connect( rCenter, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( alignCenter() ) );
1218 rRight =
new TQRadioButton( i18n(
"&Right" ), AlignGroup );
1219 connect( rRight, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( alignRight() ) );
1221 rJustify =
new TQRadioButton( i18n(
"&Justify" ), AlignGroup );
1222 connect( rJustify, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( alignJustify() ) );
1225 rLeft->setChecked(
true );
1227 grid->addWidget(AlignGroup, 0, 0);
1230 TQGroupBox * endFramePage =
new TQGroupBox( i18n(
"Behavior at &End of Frame/Page" ),
this );
1231 TQGridLayout * endFramePageGrid =
new TQGridLayout( endFramePage, 4, 1,
1234 cKeepLinesTogether =
new TQCheckBox( i18n(
"&Keep lines together"),endFramePage);
1235 endFramePageGrid->addWidget( cKeepLinesTogether, 1, 0 );
1236 cHardBreakBefore =
new TQCheckBox( i18n(
"Insert break before paragraph"),endFramePage);
1237 endFramePageGrid->addWidget( cHardBreakBefore, 2, 0 );
1238 cHardBreakAfter =
new TQCheckBox( i18n(
"Insert break after paragraph"),endFramePage);
1239 endFramePageGrid->addWidget( cHardBreakAfter, 3, 0 );
1241 endFramePageGrid->addRowSpacing( 0, fontMetrics().height() / 2 );
1242 for (
int i = 0 ; i < endFramePageGrid->numRows()-1 ; ++i )
1243 endFramePageGrid->setRowStretch( 0, 0 );
1244 endFramePageGrid->setRowStretch( endFramePageGrid->numRows()-1, 1 );
1245 grid->addWidget( endFramePage, 2, 0 );
1247 endFramePage->setEnabled(breakLine);
1250 prev2 =
new KPagePreview2(
this,
"KPagePreview2" );
1251 grid->addMultiCellWidget( prev2, 0, 2, 1, 1 );
1254 grid->setColStretch( 1, 1 );
1255 grid->setRowStretch( 1, 1 );
1258int KoParagAlignWidget::pageBreaking()
const
1261 if ( cKeepLinesTogether->isChecked() )
1262 pb |= KoParagLayout::KeepLinesTogether;
1263 if ( cHardBreakBefore->isChecked() )
1264 pb |= KoParagLayout::HardFrameBreakBefore;
1265 if ( cHardBreakAfter->isChecked() )
1266 pb |= KoParagLayout::HardFrameBreakAfter;
1271void KoParagAlignWidget::display(
const KoParagLayout & lay )
1274 prev2->setAlign( align );
1278 case TQt::AlignAuto:
1279 case TQt::AlignLeft:
1280 rLeft->setChecked(
true );
1282 case TQt::AlignHCenter:
1283 rCenter->setChecked(
true );
1285 case TQt::AlignRight:
1286 rRight->setChecked(
true );
1288 case TQt::AlignJustify:
1289 rJustify->setChecked(
true );
1292 cKeepLinesTogether->setChecked( lay.pageBreaking & KoParagLayout::KeepLinesTogether );
1293 cHardBreakBefore->setChecked( lay.pageBreaking & KoParagLayout::HardFrameBreakBefore );
1294 cHardBreakAfter->setChecked( lay.pageBreaking & KoParagLayout::HardFrameBreakAfter );
1301 lay.pageBreaking = pageBreaking();
1304int KoParagAlignWidget::align()
const
1306 if ( rLeft->isChecked() )
return TQt::AlignLeft;
1307 else if ( rCenter->isChecked() )
return TQt::AlignHCenter;
1308 else if ( rRight->isChecked() )
return TQt::AlignRight;
1309 else if ( rJustify->isChecked() )
return TQt::AlignJustify;
1311 return TQt::AlignLeft;
1316 return i18n(
"General &Layout" );
1319void KoParagAlignWidget::alignLeft()
1321 prev2->setAlign( TQt::AlignLeft );
1323 rLeft->setChecked(
true );
1326void KoParagAlignWidget::alignCenter()
1328 prev2->setAlign( TQt::AlignHCenter );
1330 rCenter->setChecked(
true );
1333void KoParagAlignWidget::alignRight()
1335 prev2->setAlign( TQt::AlignRight );
1337 rRight->setChecked(
true );
1340void KoParagAlignWidget::alignJustify()
1342 prev2->setAlign( TQt::AlignJustify );
1344 rJustify->setChecked(
true );
1347void KoParagAlignWidget::clearAligns()
1349 rLeft->setChecked(
false );
1350 rCenter->setChecked(
false );
1351 rRight->setChecked(
false );
1352 rJustify->setChecked(
false );
1357KoParagDecorationWidget::KoParagDecorationWidget( TQWidget * parent,
1361 TQVBoxLayout *tabLayout =
new TQVBoxLayout(
this );
1362 wDeco =
new KoParagDecorationTab(
this );
1363 tabLayout->add( wDeco );
1366 wDeco->cbBorderStyle->insertItem( KoBorder::getStyle( KoBorder::SOLID ) );
1367 wDeco->cbBorderStyle->insertItem( KoBorder::getStyle( KoBorder::DASH ) );
1368 wDeco->cbBorderStyle->insertItem( KoBorder::getStyle( KoBorder::DOT ) );
1369 wDeco->cbBorderStyle->insertItem( KoBorder::getStyle( KoBorder::DASH_DOT ) );
1370 wDeco->cbBorderStyle->insertItem( KoBorder::getStyle( KoBorder::DASH_DOT_DOT ) );
1371 wDeco->cbBorderStyle->insertItem( KoBorder::getStyle( KoBorder::DOUBLE_LINE ) );
1374 for(
unsigned int i = 1; i <= 10; i++ )
1375 wDeco->cbBorderWidth->insertItem(TQString::number(i));
1378 connect( wDeco->bBorderLeft, TQ_SIGNAL( toggled(
bool ) ),
1379 this, TQ_SLOT( brdLeftToggled(
bool ) ) );
1380 connect( wDeco->bBorderRight, TQ_SIGNAL( toggled(
bool ) ),
1381 this, TQ_SLOT( brdRightToggled(
bool ) ) );
1382 connect( wDeco->bBorderTop, TQ_SIGNAL( toggled(
bool ) ),
1383 this, TQ_SLOT( brdTopToggled(
bool ) ) );
1384 connect( wDeco->bBorderBottom, TQ_SIGNAL( toggled(
bool ) ),
1385 this, TQ_SLOT( brdBottomToggled(
bool ) ) );
1386 connect( wDeco->cbJoinBorder, TQ_SIGNAL( toggled(
bool ) ),
1387 this, TQ_SLOT( brdJoinToggled(
bool ) ) );
1390 wPreview =
new KoBorderPreview( wDeco->borderPreview );
1391 TQVBoxLayout *previewLayout =
new TQVBoxLayout( wDeco->borderPreview );
1392 previewLayout->addWidget( wPreview );
1393 connect( wPreview, TQ_SIGNAL( choosearea(TQMouseEvent * ) ),
1394 this, TQ_SLOT( slotPressEvent(TQMouseEvent *) ) );
1399KoBorder::BorderStyle KoParagDecorationWidget::curBorderStyle()
const
1401 TQString selection = wDeco->cbBorderStyle->currentText();
1402 return KoBorder::getStyle( selection );
1405unsigned int KoParagDecorationWidget::curBorderWidth()
const {
1406 return wDeco->cbBorderWidth->currentText().toUInt();
1409TQColor KoParagDecorationWidget::curBorderColor()
const {
1410 return wDeco->bBorderColor->color();
1415bool KoParagDecorationWidget::borderChanged(
const KoBorder& border ) {
1416 return (
unsigned int)border.penWidth() != curBorderWidth() ||
1417 border.color != curBorderColor() ||
1418 border.getStyle() != curBorderStyle();
1422void KoParagDecorationWidget::updateBorder(
KoBorder& border )
1424 border.setPenWidth( curBorderWidth() );
1425 border.color = curBorderColor();
1426 border.setStyle( curBorderStyle () );
1429void KoParagDecorationWidget::clickedBorderPreview(
KoBorder& border,
1430 KoBorder::BorderType position,
1433 if ( borderChanged( border ) && corresponding->isOn() ) {
1434 updateBorder( border );
1435 wPreview->setBorder( position, border );
1438 corresponding->setOn( !corresponding->isOn() );
1443void KoParagDecorationWidget::slotPressEvent(TQMouseEvent *_ev)
1445 const int OFFSETX = 15;
1446 const int OFFSETY = 7;
1447 const int Ko_SPACE = 30;
1449 TQRect r = wPreview->contentsRect();
1450 TQRect rect(r.x() + OFFSETX, r.y() + OFFSETY,
1451 r.width() - OFFSETX, r.y() + OFFSETY + Ko_SPACE);
1452 if(rect.contains(TQPoint(_ev->x(),_ev->y())))
1454 clickedBorderPreview( m_topBorder, KoBorder::TopBorder,
1455 wDeco->bBorderTop );
1458 rect.setCoords(r.x() + OFFSETX, r.height() - OFFSETY - Ko_SPACE,
1459 r.width() - OFFSETX, r.height() - OFFSETY);
1460 if(rect.contains(TQPoint(_ev->x(),_ev->y())))
1462 clickedBorderPreview( m_bottomBorder, KoBorder::BottomBorder,
1463 wDeco->bBorderBottom );
1466 rect.setCoords(r.x() + OFFSETX, r.y() + OFFSETY,
1467 r.x() + Ko_SPACE + OFFSETX, r.height() - OFFSETY);
1468 if(rect.contains(TQPoint(_ev->x(),_ev->y())))
1470 clickedBorderPreview( m_leftBorder, KoBorder::LeftBorder,
1471 wDeco->bBorderLeft );
1474 rect.setCoords(r.width() - OFFSETX - Ko_SPACE, r.y() + OFFSETY,
1475 r.width() - OFFSETX, r.height() - OFFSETY);
1476 if(rect.contains(TQPoint(_ev->x(),_ev->y())))
1478 clickedBorderPreview( m_rightBorder, KoBorder::RightBorder,
1479 wDeco->bBorderRight );
1483void KoParagDecorationWidget::display(
const KoParagLayout & lay )
1487 m_leftBorder = lay.leftBorder;
1488 m_rightBorder = lay.rightBorder;
1489 m_topBorder = lay.topBorder;
1490 m_bottomBorder = lay.bottomBorder;
1491 m_joinBorder = lay.joinBorder;
1493 wDeco->bBorderLeft->blockSignals(
true );
1494 wDeco->bBorderRight->blockSignals(
true );
1495 wDeco->bBorderTop->blockSignals(
true );
1496 wDeco->bBorderBottom->blockSignals(
true );
1498 wDeco->bBorderLeft->blockSignals(
false );
1499 wDeco->bBorderRight->blockSignals(
false );
1500 wDeco->bBorderTop->blockSignals(
false );
1501 wDeco->bBorderBottom->blockSignals(
false );
1504void KoParagDecorationWidget::updateBorders()
1506 wDeco->bBorderLeft->setOn( m_leftBorder.penWidth() > 0 );
1507 wDeco->bBorderRight->setOn( m_rightBorder.penWidth() > 0 );
1508 wDeco->bBorderTop->setOn( m_topBorder.penWidth() > 0 );
1509 wDeco->bBorderBottom->setOn( m_bottomBorder.penWidth() > 0 );
1510 wDeco->cbJoinBorder->setChecked( m_joinBorder );
1511 wPreview->setLeftBorder( m_leftBorder );
1512 wPreview->setRightBorder( m_rightBorder );
1513 wPreview->setTopBorder( m_topBorder );
1514 wPreview->setBottomBorder( m_bottomBorder );
1521 lay.topBorder = m_topBorder;
1522 lay.bottomBorder = m_bottomBorder;
1523 lay.leftBorder = m_leftBorder;
1524 lay.rightBorder = m_rightBorder;
1525 lay.joinBorder = m_joinBorder;
1528TQColor KoParagDecorationWidget::backgroundColor()
const {
1529 return wDeco->bBackgroundColor->color();
1535 return i18n(
"D&ecorations" );
1538void KoParagDecorationWidget::brdLeftToggled(
bool _on )
1541 m_leftBorder.setPenWidth(0);
1543 m_leftBorder.setPenWidth( curBorderWidth() );
1544 m_leftBorder.color = curBorderColor();
1545 m_leftBorder.setStyle( curBorderStyle() );
1547 wPreview->setLeftBorder( m_leftBorder );
1550void KoParagDecorationWidget::brdRightToggled(
bool _on )
1553 m_rightBorder.setPenWidth(0);
1555 m_rightBorder.setPenWidth( curBorderWidth() );
1556 m_rightBorder.color = curBorderColor();
1557 m_rightBorder.setStyle( curBorderStyle() );
1559 wPreview->setRightBorder( m_rightBorder );
1562void KoParagDecorationWidget::brdTopToggled(
bool _on )
1565 m_topBorder.setPenWidth(0);
1567 m_topBorder.setPenWidth( curBorderWidth() );
1568 m_topBorder.color = curBorderColor();
1569 m_topBorder.setStyle( curBorderStyle() );
1571 wPreview->setTopBorder( m_topBorder );
1574void KoParagDecorationWidget::brdBottomToggled(
bool _on )
1577 m_bottomBorder.setPenWidth ( 0 );
1579 m_bottomBorder.setPenWidth( curBorderWidth() );
1580 m_bottomBorder.color = curBorderColor();
1581 m_bottomBorder.setStyle( curBorderStyle() );
1583 wPreview->setBottomBorder( m_bottomBorder );
1586void KoParagDecorationWidget::brdJoinToggled(
bool _on ) {
1592KoParagCounterWidget::KoParagCounterWidget(
bool disableAll, TQWidget * parent,
const char * name )
1596 TQVBoxLayout *Form1Layout =
new TQVBoxLayout(
this );
1600 gNumbering =
new TQButtonGroup(
this,
"numberingGroup" );
1601 gNumbering->setTitle( i18n(
"Numbering" ) );
1602 gNumbering->setColumnLayout(0, TQt::Vertical );
1603 gNumbering->layout()->setSpacing( 0 );
1604 gNumbering->layout()->setMargin( 0 );
1605 TQHBoxLayout *numberingGroupLayout =
new TQHBoxLayout( gNumbering->layout() );
1606 numberingGroupLayout->setAlignment( TQt::AlignTop );
1611 TQRadioButton *rNone =
new TQRadioButton( gNumbering,
"rNone" );
1612 rNone->setText( i18n(
"&None" ) );
1613 numberingGroupLayout->addWidget( rNone );
1615 gNumbering->insert( rNone , KoParagCounter::NUM_NONE);
1617 TQRadioButton *rList =
new TQRadioButton( gNumbering,
"rList" );
1618 rList->setText( i18n(
"&List" ) );
1619 gNumbering->insert( rList , KoParagCounter::NUM_LIST);
1620 numberingGroupLayout->addWidget( rList );
1622 TQRadioButton *rChapter =
new TQRadioButton( gNumbering,
"rChapter" );
1623 rChapter->setText( i18n(
"Chapt&er" ) );
1624 gNumbering->insert( rChapter , KoParagCounter::NUM_CHAPTER);
1625 numberingGroupLayout->addWidget( rChapter );
1626 Form1Layout->addWidget( gNumbering );
1627 connect( gNumbering, TQ_SIGNAL( clicked(
int ) ),
this, TQ_SLOT( numTypeChanged(
int ) ) );
1629 m_styleWidget =
new KoCounterStyleWidget(
true,
false, disableAll,
this );
1631 connect( m_styleWidget, TQ_SIGNAL( sig_suffixChanged (
const TQString &) ),
this, TQ_SLOT( suffixChanged(
const TQString &) ) );
1632 connect( m_styleWidget, TQ_SIGNAL( sig_prefixChanged (
const TQString &) ),
this, TQ_SLOT( prefixChanged(
const TQString &) ) );
1633 connect( m_styleWidget, TQ_SIGNAL( sig_startChanged(
int) ),
this, TQ_SLOT( startChanged(
int) ) );
1634 connect( m_styleWidget, TQ_SIGNAL( sig_restartChanged(
bool) ),
this, TQ_SLOT( restartChanged(
bool) ) );
1635 connect( m_styleWidget, TQ_SIGNAL( sig_depthChanged (
int) ),
this, TQ_SLOT( depthChanged(
int) ) );
1636 connect( m_styleWidget, TQ_SIGNAL( sig_displayLevelsChanged (
int) ),
this, TQ_SLOT( displayLevelsChanged(
int) ) );
1637 connect( m_styleWidget, TQ_SIGNAL( sig_alignmentChanged (
int) ),
this, TQ_SLOT( alignmentChanged(
int) ) );
1638 connect( m_styleWidget, TQ_SIGNAL( changeCustomBullet(
const TQString & , TQChar ) ),
this, TQ_SLOT( slotChangeCustomBullet(
const TQString & , TQChar ) ) );
1640 connect( m_styleWidget, TQ_SIGNAL( sig_numTypeChanged(
int ) ),
this, TQ_SLOT( numTypeChanged(
int ) ) );
1641 connect( m_styleWidget, TQ_SIGNAL( changeStyle( KoParagCounter::Style ) ),
this, TQ_SLOT( styleChanged (KoParagCounter::Style ) ) );
1643 Form1Layout->addWidget( m_styleWidget );
1646 preview =
new KoStylePreview( i18n(
"Preview" ), i18n(
"Normal paragraph text"),
this,
"counter preview" );
1647 Form1Layout->addWidget( preview );
1650 gNumbering->setEnabled(
false);
1651 preview->setEnabled(
false );
1654 TQSpacerItem* spacer =
new TQSpacerItem( 0, 0, TQSizePolicy::Minimum, TQSizePolicy::Expanding);
1655 Form1Layout->addItem( spacer );
1658void KoParagCounterWidget::styleChanged( KoParagCounter::Style st )
1660 m_counter.setStyle( st );
1664void KoParagCounterWidget::slotChangeCustomBullet(
const TQString & f, TQChar c)
1666 m_counter.setCustomBulletFont( f );
1667 m_counter.setCustomBulletCharacter( c );
1668 preview->setCounter( m_counter );
1672 return i18n(
"B&ullets/Numbers" );
1675void KoParagCounterWidget::numTypeChanged(
int nType ) {
1677 m_counter.setNumbering(
static_cast<KoParagCounter::Numbering
>( nType ) );
1678 preview->setEnabled( m_counter.
numbering() != KoParagCounter::NUM_NONE );
1679 m_styleWidget->numTypeChanged( nType );
1684void KoParagCounterWidget::display(
const KoParagLayout & lay ) {
1685 KoParagCounter::Style style = KoParagCounter::STYLE_NONE;
1693 m_counter = KoParagCounter();
1695 gNumbering->setButton( m_counter.numbering() );
1696 preview->setStyle( lay.style );
1697 preview->setCounter( m_counter );
1698 m_styleWidget->display( lay );
1701void KoParagCounterWidget::updatePreview() {
1702 preview->setCounter(m_counter);
1703 preview->repaint(
true);
1715 lay.
counter =
new KoParagCounter( m_counter );
1718KoTabulatorsLineEdit::KoTabulatorsLineEdit( TQWidget *parent,
double lower,
double upper,
double step,
double value ,
KoUnit::Unit unit ,
unsigned int precision ,
const char *name )
1721 setRange( 0, 9999, 1,
false);
1724void KoTabulatorsLineEdit::keyPressEvent ( TQKeyEvent *ke )
1726 if( ke->key() == TQt::Key_Return ||
1727 ke->key() == TQt::Key_Enter )
1729 emit keyReturnPressed();
1732 KoUnitDoubleSpinBox::keyPressEvent (ke);
1735KoParagTabulatorsWidget::KoParagTabulatorsWidget(
KoUnit::Unit unit,
double frameWidth,TQWidget * parent,
const char * name )
1738 if(frameWidth==-1) {
1742 m_toplimit=frameWidth;
1743 length=i18n(
"Frame width: %1 %2")
1748 TQVBoxLayout* Form1Layout =
new TQVBoxLayout(
this );
1752 TQHBoxLayout* Layout13 =
new TQHBoxLayout;
1754 Layout13->setMargin( 0 );
1756 lstTabs =
new TQListBox(
this);
1757 lstTabs->insertItem(
"mytabvalue" );
1758 lstTabs->setMaximumSize( TQSize( 300, 32767 ) );
1759 Layout13->addWidget( lstTabs );
1761 editLayout =
new TQVBoxLayout;
1763 editLayout->setMargin( 0 );
1765 gPosition =
new TQGroupBox(
this,
"gPosition" );
1766 gPosition->setTitle( i18n(
"Po&sition" ) );
1767 gPosition->setColumnLayout(0, TQt::Vertical );
1768 gPosition->layout()->setSpacing( 0 );
1769 gPosition->layout()->setMargin( 0 );
1770 TQVBoxLayout* GroupBox2Layout =
new TQVBoxLayout( gPosition->layout() );
1771 GroupBox2Layout->setAlignment( TQt::AlignTop );
1775 TQHBoxLayout* Layout5 =
new TQHBoxLayout;
1777 Layout5->setMargin( 0 );
1779 sTabPos =
new KoTabulatorsLineEdit( gPosition, 0, 9999, 1, 0.0, m_unit );
1780 sTabPos->setRange( 0, 9999, 1 );
1781 sTabPos->setMaximumSize( TQSize( 100, 32767 ) );
1782 Layout5->addWidget( sTabPos );
1783 TQSpacerItem* spacer =
new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
1784 Layout5->addItem( spacer );
1785 GroupBox2Layout->addLayout( Layout5 );
1786 editLayout->addWidget( gPosition );
1788 TQLabel* TextLabel1 =
new TQLabel( gPosition );
1790 TextLabel1->setText( length );
1791 GroupBox2Layout->addWidget( TextLabel1 );
1793 bgAlign =
new TQButtonGroup(
this );
1794 bgAlign->setTitle( i18n(
"Alignment" ) );
1795 bgAlign->setColumnLayout(0, TQt::Vertical );
1796 bgAlign->layout()->setSpacing( 0 );
1797 bgAlign->layout()->setMargin( 0 );
1798 TQVBoxLayout* ButtonGroup1Layout =
new TQVBoxLayout( bgAlign->layout() );
1799 ButtonGroup1Layout->setAlignment( TQt::AlignTop );
1803 rAlignLeft =
new TQRadioButton( bgAlign );
1804 rAlignLeft->setText( i18n(
"&Left" ) );
1805 ButtonGroup1Layout->addWidget( rAlignLeft );
1807 rAlignCentre =
new TQRadioButton( bgAlign );
1808 rAlignCentre->setText( i18n(
"C&enter" ) );
1809 ButtonGroup1Layout->addWidget( rAlignCentre );
1811 rAlignRight =
new TQRadioButton( bgAlign );
1812 rAlignRight->setText( i18n(
"&Right" ) );
1813 ButtonGroup1Layout->addWidget( rAlignRight );
1815 TQHBoxLayout* Layout8 =
new TQHBoxLayout;
1817 Layout8->setMargin( 0 );
1819 rAlignVar =
new TQRadioButton( bgAlign );
1820 rAlignVar->setText( i18n(
"On followin&g character: " ) );
1821 Layout8->addWidget( rAlignVar );
1823 sAlignChar =
new TQLineEdit( bgAlign);
1824 sAlignChar->setMaximumSize( TQSize( 60, 32767 ) );
1825 sAlignChar->setText(TQString(TDEGlobal::locale()->decimalSymbol()[0]));
1826 Layout8->addWidget( sAlignChar );
1827 TQSpacerItem* spacer_2 =
new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
1828 Layout8->addItem( spacer_2 );
1829 ButtonGroup1Layout->addLayout( Layout8 );
1830 editLayout->addWidget( bgAlign );
1832 gTabLeader =
new TQGroupBox(
this,
"gTabLeader" );
1833 gTabLeader->setTitle( i18n(
"Tab Leader" ) );
1834 TQVBoxLayout* GroupBox5Layout =
new TQVBoxLayout( gTabLeader );
1835 GroupBox5Layout->setAlignment( TQt::AlignTop );
1838 GroupBox5Layout->addSpacing( fontMetrics().height() / 2 );
1840 TQLabel* TextLabel1_2 =
new TQLabel( gTabLeader );
1841 TextLabel1_2->setText( i18n(
"The space a tab uses can be filled with a pattern." ) );
1842 GroupBox5Layout->addWidget( TextLabel1_2 );
1846 TQLabel* TextLabel2 =
new TQLabel( gTabLeader);
1847 TextLabel2->setText( i18n(
"&Filling:" ) );
1848 TextLabel2->setAlignment( AlignRight );
1849 fillingGrid->addWidget( TextLabel2, 0, 0 );
1851 cFilling =
new TQComboBox(
false, gTabLeader);
1852 cFilling->insertItem( i18n(
"Blank" ) );
1853 cFilling->insertItem(
"_ _ _ _ _ _");
1854 cFilling->insertItem(
"_________");
1855 cFilling->insertItem(
"___ ___ __");
1856 cFilling->insertItem(
"___ _ ___ _");
1857 cFilling->insertItem(
"___ _ _ ___");
1858 TextLabel2->setBuddy( cFilling );
1859 fillingGrid->addWidget( cFilling, 0, 1 );
1861 TQLabel * TextLabel3 =
new TQLabel( i18n(
"&Width:"), gTabLeader );
1862 TextLabel3->setAlignment( AlignRight );
1863 fillingGrid->addWidget( TextLabel3, 1, 0 );
1865 eWidth =
new KoUnitDoubleSpinBox( gTabLeader );
1866 eWidth->setMinValue(0.01);
1867 eWidth->setUnit( m_unit );
1868 TextLabel3->setBuddy( eWidth );
1869 fillingGrid->addWidget( eWidth, 1, 1 );
1871 GroupBox5Layout->addLayout( fillingGrid );
1872 editLayout->addWidget( gTabLeader );
1873 TQSpacerItem* spacer_4 =
new TQSpacerItem( 20, 20, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
1874 editLayout->addItem( spacer_4 );
1875 Layout13->addLayout( editLayout );
1876 Form1Layout->addLayout( Layout13 );
1878 TQHBoxLayout* Layout4 =
new TQHBoxLayout;
1880 Layout4->setMargin( 0 );
1882 bNew =
new TQPushButton(
this);
1883 bNew->setText( i18n(
"&New" ) );
1884 Layout4->addWidget( bNew );
1886 bDelete =
new TQPushButton(
this);
1887 bDelete->setText( i18n(
"&Delete" ) );
1888 Layout4->addWidget( bDelete );
1890 bDeleteAll =
new TQPushButton(
this);
1891 bDeleteAll->setText( i18n(
"Delete All" ) );
1892 Layout4->addWidget( bDeleteAll );
1894 TQSpacerItem* spacer_5 =
new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
1895 Layout4->addItem( spacer_5 );
1896 Form1Layout->addLayout( Layout4 );
1900 connect(sTabPos,TQ_SIGNAL(valueChanged(
double)),
this, TQ_SLOT(slotTabValueChanged(
double )));
1901 connect(sTabPos,TQ_SIGNAL( keyReturnPressed()),
this,TQ_SLOT(newClicked()));
1902 connect(sAlignChar,TQ_SIGNAL(textChanged(
const TQString & )),
this, TQ_SLOT(slotAlignCharChanged(
const TQString & )));
1903 connect(bNew,TQ_SIGNAL(clicked ()),
this,TQ_SLOT(newClicked()));
1904 connect(bDelete,TQ_SIGNAL(clicked ()),
this,TQ_SLOT(deleteClicked()));
1905 connect(bDeleteAll,TQ_SIGNAL(clicked ()),
this,TQ_SLOT(deleteAllClicked()));
1906 connect(bgAlign,TQ_SIGNAL(clicked (
int)),
this,TQ_SLOT(updateAlign(
int)));
1907 connect(cFilling,TQ_SIGNAL(activated (
int)),
this,TQ_SLOT(updateFilling(
int)));
1908 connect(eWidth,TQ_SIGNAL(valueChangedPt(
double ) ),
this,TQ_SLOT(updateWidth()));
1909 connect(lstTabs,TQ_SIGNAL(highlighted (
int)),
this,TQ_SLOT(setActiveItem(
int)));
1913void KoParagTabulatorsWidget::slotTabValueChanged(
double val ) {
1914 if(noSignals)
return;
1919 lstTabs->changeItem(tabToString(m_tabList[lstTabs->currentItem()]), lstTabs->currentItem());
1925void KoParagTabulatorsWidget::slotAlignCharChanged(
const TQString & ) {
1927 bgAlign->setButton(3);
1928 m_tabList[lstTabs->currentItem()].alignChar=sAlignChar->text()[0];
1929 m_tabList[lstTabs->currentItem()].type=T_DEC_PNT;
1932void KoParagTabulatorsWidget::newClicked() {
1933 int selected=lstTabs->currentItem();
1940 m_tabList.append(newTab);
1941 lstTabs->insertItem(tabToString(newTab));
1942 lstTabs->setCurrentItem(0);
1944 double pos = m_tabList[selected].ptPos;
1946 if(m_unit==KoUnit::U_INCH)
1953 newTab.
type=m_tabList[selected].type;
1954 newTab.
filling=m_tabList[selected].filling;
1955 newTab.
ptWidth=m_tabList[selected].ptWidth;
1956 m_tabList.insert(m_tabList.at(selected), newTab);
1957 lstTabs->insertItem( tabToString(newTab), selected);
1958 lstTabs->setCurrentItem(lstTabs->findItem(tabToString(newTab)));
1964void KoParagTabulatorsWidget::deleteClicked() {
1965 int selected = lstTabs->currentItem();
1966 if (selected < 0)
return;
1968 sTabPos->changeValue(0.0);
1970 lstTabs->removeItem(selected);
1971 m_tabList.remove(m_tabList[selected]);
1972 if(lstTabs->count() >0) {
1973 lstTabs->setCurrentItem(TQMIN(
static_cast<unsigned int>(selected), lstTabs->count()-1 ));
1975 bDeleteAll->setEnabled(
false);
1976 bDelete->setEnabled(
false);
1977 gPosition->setEnabled(
false);
1978 bgAlign->setEnabled(
false);
1979 gTabLeader->setEnabled(
false);
1983void KoParagTabulatorsWidget::deleteAllClicked()
1986 sTabPos->changeValue(0.0);
1990 bDeleteAll->setEnabled(
false);
1991 bDelete->setEnabled(
false);
1992 gPosition->setEnabled(
false);
1993 bgAlign->setEnabled(
false);
1994 gTabLeader->setEnabled(
false);
1997void KoParagTabulatorsWidget::setActiveItem(
int selected) {
1998 if(noSignals)
return;
1999 if(selected < 0)
return;
2001 KoTabulator *selectedTab = &m_tabList[selected];
2002 switch( selectedTab->
type) {
2004 bgAlign->setButton(1);
break;
2006 bgAlign->setButton(2);
break;
2008 bgAlign->setButton(3);
2009 sAlignChar->setText(TQString(selectedTab->
alignChar));
2013 bgAlign->setButton(0);
2015 switch( selectedTab->
filling) {
2017 cFilling->setCurrentItem(1);
break;
2019 cFilling->setCurrentItem(2);
break;
2021 cFilling->setCurrentItem(3);
break;
2023 cFilling->setCurrentItem(4);
break;
2024 case TF_DASH_DOT_DOT:
2025 cFilling->setCurrentItem(5);
break;
2028 cFilling->setCurrentItem(0);
2030 eWidth->changeValue( selectedTab->
ptWidth );
2032 bDelete->setEnabled(
true);
2033 bDeleteAll->setEnabled(
true);
2034 gPosition->setEnabled(
true);
2035 bgAlign->setEnabled(
true);
2036 gTabLeader->setEnabled(
true);
2040void KoParagTabulatorsWidget::setCurrentTab(
double tabPos ) {
2041 KoTabulatorList::ConstIterator it = m_tabList.begin();
2042 for (
int i = 0; it != m_tabList.end(); ++it, ++i )
2043 if ( (*it).ptPos == tabPos ) {
2044 lstTabs->setCurrentItem(i);
2048 kdWarning() <<
"KoParagTabulatorsWidget::setCurrentTab: no tab found at pos=" << tabPos << endl;
2051TQString KoParagTabulatorsWidget::tabToString(
const KoTabulator &tab) {
2055void KoParagTabulatorsWidget::updateAlign(
int selected) {
2056 KoTabulator *selectedTab = &m_tabList[lstTabs->currentItem()];
2060 selectedTab->
type=T_CENTER;
break;
2062 selectedTab->
type=T_RIGHT;
break;
2064 selectedTab->
type=T_DEC_PNT;
2065 selectedTab->
alignChar=sAlignChar->text()[0];
2069 selectedTab->
type=T_LEFT;
2073void KoParagTabulatorsWidget::updateFilling(
int selected) {
2074 KoTabulator *selectedTab = &m_tabList[lstTabs->currentItem()];
2078 selectedTab->
filling=TF_DOTS;
break;
2080 selectedTab->
filling=TF_LINE;
break;
2082 selectedTab->
filling=TF_DASH;
break;
2084 selectedTab->
filling=TF_DASH_DOT;
break;
2086 selectedTab->
filling=TF_DASH_DOT_DOT;
break;
2089 selectedTab->
filling=TF_BLANK;
2093void KoParagTabulatorsWidget::updateWidth() {
2094 KoTabulator *selectedTab = &m_tabList[lstTabs->currentItem()];
2095 selectedTab->
ptWidth = TQMAX( 0, eWidth->value() );
2098void KoParagTabulatorsWidget::sortLists() {
2101 qHeapSort( m_tabList );
2105 TQString curValue=lstTabs->currentText();
2107 KoTabulatorList::ConstIterator it = m_tabList.begin();
2108 for ( ; it != m_tabList.end(); ++it )
2111 lstTabs->setCurrentItem(lstTabs->findItem(curValue));
2115void KoParagTabulatorsWidget::display(
const KoParagLayout &lay ) {
2118 m_tabList = lay.tabList();
2119 KoTabulatorList::ConstIterator it = m_tabList.begin();
2120 for ( ; it != m_tabList.end(); ++it )
2123 if(lstTabs->count() > 0)
2124 lstTabs->setCurrentItem(0);
2126 bDelete->setEnabled(
false);
2127 bDeleteAll->setEnabled(
false);
2128 gPosition->setEnabled(
false);
2129 bgAlign->setEnabled(
false);
2130 gTabLeader->setEnabled(
false);
2135 lay.setTabList( m_tabList );
2139 return i18n(
"&Tabulators" );
2146 int flags,
KoUnit::Unit unit,
double _frameWidth,
bool breakLine,
bool disableAll )
2149 m_decorationsWidget = 0;
2153 if ( m_flags & PD_SPACING )
2155 TQVBox * page =
addVBoxPage( i18n(
"Indent && S&pacing" ) );
2157 m_indentSpacingWidget->layout()->setMargin(0);
2159 if ( m_flags & PD_ALIGN )
2161 TQVBox * page =
addVBoxPage( i18n(
"General &Layout" ) );
2163 m_alignWidget->layout()->setMargin(0);
2165 if ( m_flags & PD_DECORATION )
2167 TQVBox * page =
addVBoxPage( i18n(
"D&ecorations" ) );
2169 m_decorationsWidget->layout()->setMargin(0);
2171 if ( m_flags & PD_NUMBERING )
2173 TQVBox * page =
addVBoxPage( i18n(
"B&ullets/Numbers" ) );
2175 m_counterWidget->layout()->setMargin(0);
2177 if ( m_flags & PD_TABS )
2179 TQVBox * page =
addVBoxPage( i18n(
"&Tabulators" ) );
2181 m_tabulatorsWidget->layout()->setMargin(0);
2184 connect(
this, TQ_SIGNAL(
user1Clicked() ),
this, TQ_SLOT(slotReset()));
2188KoParagDia::~KoParagDia()
2194 emit applyParagStyle();
2229 m_indentSpacingWidget->display( lay );
2230 m_alignWidget->display( lay );
2231 m_decorationsWidget->display( lay );
2232 m_counterWidget->display( lay );
2233 m_tabulatorsWidget->display( lay );
2237void KoParagDia::slotReset()
2239 if( m_indentSpacingWidget )
2240 m_indentSpacingWidget->display( oldLayout );
2242 m_alignWidget->display( oldLayout );
2243 if ( m_decorationsWidget )
2244 m_decorationsWidget->display( oldLayout );
2245 if( m_counterWidget )
2246 m_counterWidget->display( oldLayout );
2247 if( m_tabulatorsWidget )
2248 m_tabulatorsWidget->display( oldLayout );
2251bool KoParagDia::isCounterChanged()
const
2253 if ( oldLayout.counter )
2254 return ! ( *oldLayout.counter == counter() );
2256 return counter().numbering() != KoParagCounter::NUM_NONE;
2261 return paragLayout().compare( oldLayout );
2267 newLayout.setLineSpacingValue( lineSpacing() );
2268 newLayout.lineSpacingType = lineSpacingType();
2269 newLayout.setTabList( tabListTabulator() );
2271 newLayout.
margins[TQStyleSheetItem::MarginFirstLine] = firstLineIndent();
2272 newLayout.
margins[TQStyleSheetItem::MarginLeft] = leftIndent();
2273 newLayout.
margins[TQStyleSheetItem::MarginRight] = rightIndent();
2274 newLayout.
margins[TQStyleSheetItem::MarginTop] = spaceBeforeParag();
2275 newLayout.
margins[TQStyleSheetItem::MarginBottom] = spaceAfterParag();
2276 newLayout.pageBreaking = pageBreaking();
2277 newLayout.leftBorder = leftBorder();
2278 newLayout.rightBorder = rightBorder();
2279 newLayout.topBorder = topBorder();
2280 newLayout.bottomBorder = bottomBorder();
2281 newLayout.joinBorder = joinBorder();
2287#include "KoParagDia.moc"
2288#include "KoParagDia_p.moc"
TQVBox * addVBoxPage(const TQString &itemName, const TQString &header=TQString::null, const TQPixmap &pixmap=TQPixmap())
KDialogBase(TQWidget *parent=0, const char *name=0, bool modal=true, const TQString &caption=TQString::null, int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok, bool separator=false, const KGuiItem &user1=KGuiItem(), const KGuiItem &user2=KGuiItem(), const KGuiItem &user3=KGuiItem())
void setInitialSize(const TQSize &s, bool noResize=false)
int pageIndex(TQWidget *widget) const
void setButtonText(ButtonCode id, const TQString &text)
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.
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.
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.