00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <stdlib.h>
00033 #include <math.h>
00034
00035 #include <qbitmap.h>
00036 #include <qcheckbox.h>
00037 #include <qframe.h>
00038 #include <qlabel.h>
00039 #include <qlayout.h>
00040 #include <qlistbox.h>
00041 #include <qfontdatabase.h>
00042 #include <qradiobutton.h>
00043 #include <qslider.h>
00044 #include <qwhatsthis.h>
00045
00046 #include <kcolorbutton.h>
00047 #include <kcombobox.h>
00048 #include <kdebug.h>
00049 #include <kdialog.h>
00050 #include <klineedit.h>
00051 #include <kmessagebox.h>
00052 #include <knumvalidator.h>
00053
00054 #include <KoUnitWidgets.h>
00055
00056 #include "kspread_canvas.h"
00057 #include "kspread_dlg_layout.h"
00058 #include "kspread_locale.h"
00059 #include "kspread_sheet.h"
00060 #include "kspread_style.h"
00061 #include "kspread_style_manager.h"
00062 #include "kspread_undo.h"
00063 #include "kspread_util.h"
00064 #include "manipulator.h"
00065 #include "selection.h"
00066 #include "valueformatter.h"
00067
00068 using namespace KSpread;
00069
00070
00071
00072
00073
00074
00075
00076 PatternSelect::PatternSelect( QWidget *parent, const char * )
00077 : QFrame( parent )
00078 {
00079 penStyle = NoPen;
00080 penWidth = 1;
00081 penColor = colorGroup().text();
00082 selected = false;
00083 undefined = false;
00084 }
00085
00086 void PatternSelect::setPattern( const QColor &_color, int _width, PenStyle _style )
00087 {
00088 penStyle = _style;
00089 penColor = _color;
00090 penWidth = _width;
00091 repaint();
00092 }
00093
00094 void PatternSelect::setUndefined()
00095 {
00096 undefined = true;
00097 }
00098
00099 void PatternSelect::paintEvent( QPaintEvent *_ev )
00100 {
00101 QFrame::paintEvent( _ev );
00102
00103 QPainter painter( this );
00104
00105 if ( !undefined )
00106 {
00107 QPen pen( penColor, penWidth, penStyle);
00108 painter.setPen( pen );
00109 painter.drawLine( 6, height()/2, width() - 6,height()/2 );
00110 }
00111 else
00112 {
00113 painter.fillRect( 2, 2, width() - 4, height() - 4, BDiagPattern );
00114 }
00115 }
00116
00117 void PatternSelect::mousePressEvent( QMouseEvent * )
00118 {
00119 slotSelect();
00120
00121 emit clicked( this );
00122 }
00123
00124 void PatternSelect::slotUnselect()
00125 {
00126 selected = false;
00127
00128 setLineWidth( 1 );
00129 setFrameStyle( QFrame::Panel | QFrame::Sunken );
00130 repaint();
00131 }
00132
00133 void PatternSelect::slotSelect()
00134 {
00135 selected = true;
00136
00137 setLineWidth( 2 );
00138 setFrameStyle( QFrame::Panel | QFrame::Plain );
00139 repaint();
00140 }
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 GeneralTab::GeneralTab( QWidget* parent, CellFormatDialog * dlg )
00151 : QWidget( parent ),
00152 m_dlg( dlg )
00153 {
00154 QGridLayout * layout = new QGridLayout( this, 1, 1, KDialog::marginHint(), KDialog::spacingHint(), "layout");
00155
00156 QGroupBox * groupBox = new QGroupBox( this, "groupBox1" );
00157 groupBox->setColumnLayout(0, Qt::Vertical );
00158 groupBox->setTitle( i18n( "Style" ) );
00159 groupBox->layout()->setSpacing( KDialog::spacingHint() );
00160 groupBox->layout()->setMargin( KDialog::marginHint() );
00161
00162 QGridLayout * groupBoxLayout = new QGridLayout( groupBox->layout() );
00163 groupBoxLayout->setAlignment( Qt::AlignTop );
00164
00165 QLabel * label1 = new QLabel( groupBox, "label1" );
00166 label1->setText( i18n( "Name:" ) );
00167 groupBoxLayout->addWidget( label1, 0, 0 );
00168
00169 m_nameEdit = new KLineEdit( groupBox, "m_nameEdit" );
00170 m_nameEdit->setText( m_dlg->styleName );
00171 groupBoxLayout->addWidget( m_nameEdit, 0, 1 );
00172
00173 QLabel * label2 = new QLabel( groupBox, "label2" );
00174 label2->setText( i18n( "Inherit style:" ) );
00175 groupBoxLayout->addWidget( label2, 1, 0 );
00176
00177 m_parentBox = new KComboBox( false, groupBox, "m_parentBox" );
00178 m_parentBox->clear();
00179 m_parentBox->insertItem( i18n( "<None>" ) );
00180 QStringList tmp = m_dlg->getStyleManager()->styleNames();
00181 tmp.remove( m_dlg->styleName );
00182 m_parentBox->insertStringList( tmp );
00183
00184 if ( m_dlg->getStyle()->parent() )
00185 m_parentBox->setCurrentText( m_dlg->getStyle()->parentName() );
00186 else
00187 {
00188 m_parentBox->setCurrentText( i18n( "<None>" ) );
00189
00190 if ( m_dlg->getStyle()->definesAll() )
00191 m_parentBox->setEnabled( false );
00192 }
00193
00194 connect( m_parentBox, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotNewParent( const QString & ) ) );
00195 connect( m_nameEdit, SIGNAL( lostFocus() ), this, SLOT( slotNameChanged() ) );
00196
00197 groupBoxLayout->addWidget( m_parentBox, 1, 1 );
00198
00199 QSpacerItem * spacer = new QSpacerItem( 20, 260, QSizePolicy::Minimum, QSizePolicy::Expanding );
00200
00201 layout->addWidget( groupBox, 0, 0 );
00202 layout->addItem( spacer, 1, 0 );
00203
00204 if ( m_dlg->getStyle()->type() == Style::BUILTIN )
00205 {
00206 m_nameEdit->setEnabled( false );
00207 m_parentBox->setEnabled( false );
00208 }
00209
00210 resize( QSize( 534, 447 ).expandedTo(minimumSizeHint()) );
00211 }
00212
00213 GeneralTab::~GeneralTab()
00214 {
00215 }
00216
00217 void GeneralTab::slotNameChanged()
00218 {
00219 checkName();
00220 }
00221
00222 void GeneralTab::slotNewParent( const QString & parentName )
00223 {
00224 kdDebug() << "New Parent" << endl;
00225 if ( !checkParent( parentName ) )
00226 return;
00227
00228 if ( parentName.isEmpty() || parentName == i18n( "<None>" ) )
00229 m_dlg->getStyle()->setParent( 0 );
00230 else
00231 m_dlg->getStyle()->setParent( m_dlg->getStyleManager()->style( parentName ) );
00232
00233
00234
00235 }
00236
00237 bool GeneralTab::checkName()
00238 {
00239 if ( m_nameEdit->isEnabled() )
00240 {
00241 if ( !m_dlg->getStyleManager()->validateStyleName( m_nameEdit->text(), m_dlg->getStyle() ) )
00242 {
00243 KMessageBox::sorry( this, i18n( "A style with this name already exists." ) );
00244 return false;
00245 }
00246 }
00247
00248 return true;
00249 }
00250
00251 bool GeneralTab::checkParent( const QString & parentName )
00252 {
00253 if ( m_dlg->getStyle()->parentName() != parentName
00254 && m_parentBox->isEnabled() && parentName != i18n( "<None>" ) && !parentName.isEmpty() )
00255 {
00256 if ( m_nameEdit->text() == parentName )
00257 {
00258 KMessageBox::sorry( this, i18n( "A style cannot inherit from itself." ) );
00259 return false;
00260 }
00261 if ( !m_dlg->checkCircle( m_nameEdit->text(), parentName ) )
00262 {
00263 KMessageBox::sorry( this,
00264 i18n( "The style cannot inherit from '%1' because of recursive references." )
00265 .arg( m_parentBox->currentText() ) );
00266 return false;
00267 }
00268
00269 CustomStyle * p = m_dlg->getStyleManager()->style( parentName );
00270
00271 if ( !p )
00272 {
00273 KMessageBox::sorry( this, i18n( "The parent style does not exist." ) );
00274 return false;
00275 }
00276 }
00277
00278 return true;
00279 }
00280
00281 bool GeneralTab::apply( CustomStyle * style )
00282 {
00283 if ( !checkParent( m_parentBox->currentText() ) )
00284 return false;
00285
00286 if ( !checkName() )
00287 return false;
00288
00289 if ( m_nameEdit->isEnabled() )
00290 {
00291 if ( style->type() != Style::BUILTIN )
00292 {
00293 QString name( style->name() );
00294 style->setName( m_nameEdit->text() );
00295 if ( m_parentBox->isEnabled() )
00296 {
00297 if ( m_parentBox->currentText() == i18n( "None" ) || m_parentBox->currentText().isEmpty() )
00298 style->setParent( 0 );
00299 else
00300 style->setParent( m_dlg->getStyleManager()->style( m_parentBox->currentText() ) );
00301 }
00302 m_dlg->getStyleManager()->changeName( name, m_nameEdit->text() );
00303 }
00304 }
00305
00306 if ( style->type() == Style::TENTATIVE )
00307 style->setType( Style::CUSTOM );
00308
00309 return true;
00310 }
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320 CellFormatDialog::CellFormatDialog( View * _view, Sheet * _sheet )
00321 : QObject(),
00322 m_doc( _sheet->doc() ),
00323 m_sheet( _sheet ),
00324 m_pView( _view ),
00325 m_style( 0 )
00326 {
00327 initMembers();
00328
00329
00330 isRowSelected = _view->selectionInfo()->isRowSelected();
00331 isColumnSelected = _view->selectionInfo()->isColumnSelected();
00332
00333 QRect range = _view->selectionInfo()->selection();
00334 left = range.left();
00335 top = range.top();
00336 right = range.right();
00337 bottom = range.bottom();
00338
00339 if ( left == right )
00340 oneCol = true;
00341 else
00342 oneCol = false;
00343
00344 if ( top == bottom )
00345 oneRow = true;
00346 else
00347 oneRow = false;
00348
00349 Cell* obj = m_sheet->cellAt( left, top );
00350 oneCell = (left == right && top == bottom &&
00351 !obj->doesMergeCells());
00352
00353 isMerged = ((obj->doesMergeCells() &&
00354 left + obj->extraXCells() >= right &&
00355 top + obj->extraYCells() >= bottom));
00356
00357
00358 borders[BorderType_Left].style = obj->format()->leftBorderStyle( left, top );
00359 borders[BorderType_Left].width = obj->format()->leftBorderWidth( left, top );
00360 borders[BorderType_Left].color = obj->format()->leftBorderColor( left, top );
00361 borders[BorderType_Top].style = obj->format()->topBorderStyle( left, top );
00362 borders[BorderType_Top].width = obj->format()->topBorderWidth( left, top );
00363 borders[BorderType_Top].color = obj->format()->topBorderColor( left, top );
00364 borders[BorderType_FallingDiagonal].style =
00365 obj->format()->fallDiagonalStyle( left, top );
00366 borders[BorderType_FallingDiagonal].width =
00367 obj->format()->fallDiagonalWidth( left, top );
00368 borders[BorderType_FallingDiagonal].color =
00369 obj->format()->fallDiagonalColor( left, top );
00370 borders[BorderType_RisingDiagonal].style =
00371 obj->format()->goUpDiagonalStyle( left, top );
00372 borders[BorderType_RisingDiagonal].width =
00373 obj->format()->goUpDiagonalWidth( left, top );
00374 borders[BorderType_RisingDiagonal].color =
00375 obj->format()->goUpDiagonalColor( left, top );
00376
00377
00378 obj = m_sheet->cellAt( right, top );
00379 borders[BorderType_Right].style = obj->format()->rightBorderStyle( right, top );
00380 borders[BorderType_Right].width = obj->format()->rightBorderWidth( right, top );
00381 borders[BorderType_Right].color = obj->format()->rightBorderColor( right, top );
00382
00383
00384 obj = m_sheet->cellAt( left, bottom );
00385 borders[BorderType_Bottom].style = obj->format()->bottomBorderStyle( left, bottom );
00386 borders[BorderType_Bottom].width = obj->format()->bottomBorderWidth( left, bottom );
00387 borders[BorderType_Bottom].color = obj->format()->bottomBorderColor( left, bottom );
00388
00389
00390 obj = m_sheet->cellAt( right, top );
00391 if ( obj->isPartOfMerged() )
00392 {
00393 obj = obj->obscuringCells().first();
00394 int moveX = obj->column();
00395 int moveY = top;
00396 int moveX2 = right;
00397 int moveY2 = obj->row();
00398 borders[BorderType_Vertical].style = obj->format()->leftBorderStyle( moveX, moveY );
00399 borders[BorderType_Vertical].width = obj->format()->leftBorderWidth( moveX, moveY );
00400 borders[BorderType_Vertical].color = obj->format()->leftBorderColor( moveX, moveY );
00401
00402 obj = m_sheet->cellAt( moveX2, moveY2 );
00403 borders[BorderType_Horizontal].style = obj->format()->topBorderStyle( moveX2, moveY2 );
00404 borders[BorderType_Horizontal].width = obj->format()->topBorderWidth( moveX2, moveY2 );
00405 borders[BorderType_Horizontal].color = obj->format()->topBorderColor( moveX2, moveY2 );
00406 }
00407 else
00408 {
00409 borders[BorderType_Vertical].style = obj->format()->leftBorderStyle( right, top );
00410 borders[BorderType_Vertical].width = obj->format()->leftBorderWidth( right, top );
00411 borders[BorderType_Vertical].color = obj->format()->leftBorderColor( right, top );
00412 borders[BorderType_Horizontal].style = obj->format()->topBorderStyle(right, bottom);
00413 borders[BorderType_Horizontal].width = obj->format()->topBorderWidth(right, bottom);
00414 borders[BorderType_Horizontal].color = obj->format()->topBorderColor(right, bottom);
00415 }
00416
00417 obj = m_sheet->cellAt( left, top );
00418 prefix = obj->format()->prefix( left, top );
00419 postfix = obj->format()->postfix( left, top );
00420 precision = obj->format()->precision( left, top );
00421 floatFormat = obj->format()->floatFormat( left, top );
00422 floatColor = obj->format()->floatColor( left, top );
00423 alignX = obj->format()->align( left, top );
00424 alignY = obj->format()->alignY( left, top );
00425 textColor = obj->format()->textColor( left, top );
00426 bgColor = obj->bgColor( left, top );
00427 textFontSize = obj->format()->textFontSize( left, top );
00428 textFontFamily = obj->format()->textFontFamily( left, top );
00429 textFontBold = obj->format()->textFontBold( left, top );
00430 textFontItalic = obj->format()->textFontItalic( left, top );
00431 strike=obj->format()->textFontStrike( left, top );
00432 underline = obj->format()->textFontUnderline( left, top );
00433
00434 textFont = obj->format()->textFont( left, top );
00435 obj->format()->currencyInfo( cCurrency );
00436
00437 brushColor = obj->format()->backGroundBrushColor( left, top );
00438 brushStyle = obj->format()->backGroundBrushStyle( left,top );
00439
00440 bMultiRow = obj->format()->multiRow( left, top );
00441 bVerticalText = obj->format()->verticalText( left, top );
00442 textRotation = obj->format()->getAngle(left, top);
00443 formatType = obj->format()->getFormatType(left, top);
00444
00445 bDontPrintText = obj->format()->getDontprintText( left, top );
00446 bHideFormula = obj->format()->isHideFormula( left, top );
00447 bHideAll = obj->format()->isHideAll( left, top );
00448 bIsProtected = !obj->format()->notProtected( left, top );
00449
00450 indent = obj->format()->getIndent(left, top);
00451
00452 value = obj->value();
00453
00454 RowFormat *rl;
00455 ColumnFormat *cl;
00456 widthSize = 0.0;
00457 heightSize = 0.0;
00458
00459 if ( !isRowSelected )
00460 {
00461 for ( int x = left; x <= right; x++ )
00462 {
00463 cl = m_pView->activeSheet()->columnFormat( x );
00464 widthSize = QMAX( cl->dblWidth(), widthSize );
00465 }
00466 }
00467
00468 if ( !isColumnSelected )
00469 {
00470 for ( int y = top; y <= bottom; y++ )
00471 {
00472 rl = m_pView->activeSheet()->rowFormat(y);
00473 heightSize = QMAX( rl->dblHeight(), heightSize );
00474 }
00475 }
00476
00477
00478 if ( isColumnSelected )
00479 {
00480 int y = 1;
00481 Cell* cell = NULL;
00482 for (int x = left;x <= right; x++)
00483 {
00484 ColumnFormat *obj = m_sheet->nonDefaultColumnFormat(x);
00485 initParameters( obj,x,y);
00486
00487 for (cell = m_sheet->getFirstCellColumn(x); cell != NULL;
00488 cell = m_sheet->getNextCellDown(cell->column(), cell->row()))
00489 {
00490 initParameters( cell->format(), x, cell->row());
00491 }
00492 }
00493
00494 }
00495 else if ( isRowSelected )
00496 {
00497 int x = 1;
00498 Cell* c = NULL;
00499 for ( int y = top;y<=bottom;y++)
00500 {
00501 RowFormat *obj = m_sheet->nonDefaultRowFormat(y);
00502 initParameters( obj,x,y);
00503
00504 for (c = m_sheet->getFirstCellRow(y); c != NULL;
00505 c = m_sheet->getNextCellRight(c->column(), c->row()) )
00506 {
00507 initParameters( c->format(), c->column(), c->row());
00508 }
00509 }
00510 }
00511 else
00512 {
00513
00514 for ( int x = left; x <= right; x++ )
00515 {
00516 for ( int y = top; y <= bottom; y++ )
00517 {
00518 Cell *obj = m_sheet->cellAt( x, y );
00519
00520 if ( obj->isPartOfMerged() )
00521 continue;
00522
00523 initParameters( obj->format(),x,y);
00524 }
00525 }
00526 }
00527 if ( !bTextRotation )
00528 textRotation = 0;
00529
00530 if ( isColumnSelected )
00531 {
00532 int y=1;
00533 ColumnFormat *obj=m_sheet->nonDefaultColumnFormat(left);
00534 checkBorderLeft( obj,left, y);
00535
00536 Cell* c = NULL;
00537 for (c = m_sheet->getFirstCellColumn(left); c != NULL;
00538 c = m_sheet->getNextCellDown(c->column(), c->row()) )
00539 {
00540 checkBorderLeft(c->format(), c->column(), c->row());
00541 }
00542
00543
00544 obj=m_sheet->nonDefaultColumnFormat(right);
00545 checkBorderRight(obj,right,y);
00546 c = NULL;
00547 for (c = m_sheet->getFirstCellColumn(right); c != NULL;
00548 c = m_sheet->getNextCellDown(c->column(), c->row()) )
00549 {
00550 checkBorderRight(c->format(), c->column(), c->row());
00551 }
00552
00553 for ( int x = left; x <= right; x++ )
00554 {
00555 Cell *obj = m_sheet->cellAt( x, top );
00556 checkBorderTop(obj->format(),x, top);
00557 obj = m_sheet->cellAt( x, bottom );
00558 checkBorderBottom(obj->format(),x, bottom);
00559 if ( x > left )
00560 {
00561 ColumnFormat *obj = m_sheet->nonDefaultColumnFormat(x);
00562 checkBorderHorizontal(obj,x, y);
00563 checkBorderVertical(obj,x, y);
00564 }
00565 }
00566 }
00567 else if ( isRowSelected )
00568 {
00569 int x=1;
00570 for ( int y = top; y <= bottom; y++ )
00571 {
00572 Cell *obj = m_sheet->cellAt( right, y );
00573 checkBorderRight(obj->format(),right,y);
00574 obj = m_sheet->cellAt( left, y );
00575 checkBorderLeft( obj->format(),left, y);
00576 if ( y > top )
00577 {
00578 RowFormat* obj = m_sheet->nonDefaultRowFormat(y);
00579 checkBorderHorizontal(obj,x, y);
00580 checkBorderVertical(obj,x, y);
00581 }
00582 }
00583
00584 RowFormat *obj=m_sheet->nonDefaultRowFormat(top);
00585 checkBorderTop(obj,x, top);
00586 obj=m_sheet->nonDefaultRowFormat(bottom);
00587 checkBorderBottom(obj,x, bottom);
00588 }
00589 else
00590 {
00591 for ( int y = top; y <= bottom; y++ )
00592 {
00593 Cell *obj = m_sheet->cellAt( left, y );
00594 checkBorderLeft( obj->format(),left, y);
00595 obj = m_sheet->cellAt( right, y );
00596 checkBorderRight(obj->format(),right,y);
00597 }
00598
00599 for ( int x = left; x <= right; x++ )
00600 {
00601 Cell *obj = m_sheet->cellAt( x, top );
00602 checkBorderTop( obj->format(), x, top );
00603 obj = m_sheet->cellAt( x, bottom );
00604 checkBorderBottom( obj->format(), x, bottom );
00605 }
00606
00607
00608 for ( int x = left; x <= right; x++ )
00609 {
00610 for ( int y = top+1; y <= bottom; y++ )
00611 {
00612 Cell *obj = m_sheet->cellAt( x, y );
00613 checkBorderHorizontal(obj->format(),x, y);
00614 }
00615 }
00616
00617 for ( int x = left+1; x <= right; x++ )
00618 {
00619 for ( int y = top; y <= bottom; y++ )
00620 {
00621 Cell *obj = m_sheet->cellAt( x, y );
00622 checkBorderVertical(obj->format(),x,y);
00623 }
00624 }
00625 }
00626
00627 init();
00628 }
00629
00630 CellFormatDialog::CellFormatDialog( View * _view, CustomStyle * _style,
00631 StyleManager * _manager, Doc * doc )
00632 : QObject(),
00633 m_doc( doc ),
00634 m_sheet( 0 ),
00635 m_pView( _view ),
00636 m_style( _style ),
00637 m_styleManager( _manager )
00638 {
00639 initMembers();
00640 initGUI();
00641 init();
00642 }
00643
00644 void CellFormatDialog::initGUI()
00645 {
00646 isRowSelected = false;
00647 isColumnSelected = false;
00648 styleName = m_style->name();
00649
00650 borders[BorderType_Left].style = m_style->leftBorderPen().style();
00651 borders[BorderType_Left].width = m_style->leftBorderPen().width();
00652 borders[BorderType_Left].color = m_style->leftBorderPen().color();
00653
00654 borders[BorderType_Top].style = m_style->topBorderPen().style();
00655 borders[BorderType_Top].width = m_style->topBorderPen().width();
00656 borders[BorderType_Top].color = m_style->topBorderPen().color();
00657
00658 borders[BorderType_Right].style = m_style->rightBorderPen().style();
00659 borders[BorderType_Right].width = m_style->rightBorderPen().width();
00660 borders[BorderType_Right].color = m_style->rightBorderPen().color();
00661
00662 borders[BorderType_Bottom].style = m_style->bottomBorderPen().style();
00663 borders[BorderType_Bottom].width = m_style->bottomBorderPen().width();
00664 borders[BorderType_Bottom].color = m_style->bottomBorderPen().color();
00665
00666 borders[BorderType_FallingDiagonal].style = m_style->fallDiagonalPen().style();
00667 borders[BorderType_FallingDiagonal].width = m_style->fallDiagonalPen().width();
00668 borders[BorderType_FallingDiagonal].color = m_style->fallDiagonalPen().color();
00669
00670 borders[BorderType_RisingDiagonal].style = m_style->goUpDiagonalPen().style();
00671 borders[BorderType_RisingDiagonal].width = m_style->goUpDiagonalPen().width();
00672 borders[BorderType_RisingDiagonal].color = m_style->goUpDiagonalPen().color();
00673
00674 borders[BorderType_Vertical].style = m_style->leftBorderPen().style();
00675 borders[BorderType_Vertical].width = m_style->leftBorderPen().width();
00676 borders[BorderType_Vertical].color = m_style->leftBorderPen().color();
00677 borders[BorderType_Horizontal].style = m_style->topBorderPen().style();
00678 borders[BorderType_Horizontal].width = m_style->topBorderPen().width();
00679 borders[BorderType_Horizontal].color = m_style->topBorderPen().color();
00680
00681 prefix = m_style->prefix();
00682 postfix = m_style->postfix();
00683 precision = m_style->precision();
00684 floatFormat = m_style->floatFormat();
00685 floatColor = m_style->floatColor();
00686 alignX = m_style->alignX();
00687 alignY = m_style->alignY();
00688 textColor = m_style->pen().color();
00689 bgColor = m_style->bgColor();
00690 textFontSize = m_style->fontSize();
00691 textFontFamily = m_style->fontFamily();
00692
00693 uint flags = m_style->fontFlags();
00694 textFontBold = ( flags & (uint) Style::FBold );
00695 textFontItalic = ( flags & (uint) Style::FItalic );
00696 strike = ( flags & (uint) Style::FStrike );
00697 underline = ( flags & (uint) Style::FUnderline );
00698
00699
00700 textFont = m_style->font();
00701 cCurrency = m_style->currency();
00702 brushColor = m_style->backGroundBrush().color();
00703 brushStyle = m_style->backGroundBrush().style();
00704
00705 bMultiRow = m_style->hasProperty( Style::PMultiRow );
00706 bVerticalText = m_style->hasProperty( Style::PVerticalText );
00707 textRotation = m_style->rotateAngle();
00708 formatType = m_style->formatType();
00709 indent = m_style->indent();
00710
00711 bDontPrintText = m_style->hasProperty( Style::PDontPrintText );
00712 bHideFormula = m_style->hasProperty( Style::PHideFormula );
00713 bHideAll = m_style->hasProperty( Style::PHideAll );
00714 bIsProtected = !m_style->hasProperty( Style::PNotProtected );
00715
00716 widthSize = defaultWidthSize;
00717 heightSize = defaultHeightSize;
00718 }
00719
00720 CellFormatDialog::~CellFormatDialog()
00721 {
00722 delete formatOnlyNegSignedPixmap;
00723 delete formatRedOnlyNegSignedPixmap;
00724 delete formatRedNeverSignedPixmap;
00725 delete formatAlwaysSignedPixmap;
00726 delete formatRedAlwaysSignedPixmap;
00727 }
00728
00729 void CellFormatDialog::initMembers()
00730 {
00731 formatOnlyNegSignedPixmap = 0L;
00732 formatRedOnlyNegSignedPixmap = 0L;
00733 formatRedNeverSignedPixmap = 0L;
00734 formatAlwaysSignedPixmap = 0L;
00735 formatRedAlwaysSignedPixmap = 0L;
00736
00737
00738 for ( int i = 0; i < BorderType_END; ++i )
00739 {
00740 borders[i].bStyle = true;
00741 borders[i].bColor = true;
00742 }
00743 bFloatFormat = true;
00744 bFloatColor = true;
00745 bTextColor = true;
00746 bBgColor = true;
00747 bTextFontFamily = true;
00748 bTextFontSize = true;
00749 bTextFontBold = true;
00750 bTextFontItalic = true;
00751 bStrike = true;
00752 bUnderline = true;
00753 bTextRotation = true;
00754 bFormatType = true;
00755 bCurrency = true;
00756 bDontPrintText = false;
00757 bHideFormula = false;
00758 bHideAll = false;
00759 bIsProtected = true;
00760
00761 cCurrency.symbol = locale()->currencySymbol();
00762 cCurrency.type = 0;
00763
00764 Sheet* sheet = m_pView->activeSheet();
00765 defaultWidthSize = sheet ? sheet->columnFormat(0)->dblWidth() : 0;
00766 defaultHeightSize = sheet ? sheet->rowFormat(0)->dblHeight() : 0;
00767 }
00768
00769 bool CellFormatDialog::checkCircle( QString const & name, QString const & parent )
00770 {
00771 return m_styleManager->checkCircle( name, parent );
00772 }
00773
00774 void CellFormatDialog::checkBorderRight(Format *obj,int x,int y)
00775 {
00776 if ( borders[BorderType_Right].style != obj->rightBorderStyle( x, y ) ||
00777 borders[BorderType_Right].width != obj->rightBorderWidth( x, y ) )
00778 borders[BorderType_Right].bStyle = false;
00779 if ( borders[BorderType_Right].color != obj->rightBorderColor( x, y ) )
00780 borders[BorderType_Right].bColor = false;
00781 }
00782
00783 void CellFormatDialog::checkBorderLeft(Format *obj,int x,int y)
00784 {
00785 if ( borders[BorderType_Left].style != obj->leftBorderStyle( x, y ) ||
00786 borders[BorderType_Left].width != obj->leftBorderWidth( x, y ) )
00787 borders[BorderType_Left].bStyle = false;
00788 if ( borders[BorderType_Left].color != obj->leftBorderColor( x, y ) )
00789 borders[BorderType_Left].bColor = false;
00790 }
00791
00792 void CellFormatDialog::checkBorderTop(Format *obj,int x,int y)
00793 {
00794 if ( borders[BorderType_Top].style != obj->topBorderStyle( x, y ) ||
00795 borders[BorderType_Top].width != obj->topBorderWidth( x, y ) )
00796 borders[BorderType_Top].bStyle = false;
00797 if ( borders[BorderType_Top].color != obj->topBorderColor( x, y ) )
00798 borders[BorderType_Top].bColor = false;
00799 }
00800
00801 void CellFormatDialog::checkBorderBottom(Format *obj,int x,int y)
00802 {
00803 if ( borders[BorderType_Bottom].style != obj->bottomBorderStyle( x, y ) ||
00804 borders[BorderType_Bottom].width != obj->bottomBorderWidth( x, y ) )
00805 borders[BorderType_Bottom].bStyle = false;
00806 if ( borders[BorderType_Bottom].color != obj->bottomBorderColor( x, y ) )
00807 borders[BorderType_Bottom].bColor = false;
00808 }
00809
00810 void CellFormatDialog::checkBorderVertical(Format *obj,int x,int y)
00811 {
00812 if (borders[BorderType_Vertical].style != obj->leftBorderStyle( x, y ) ||
00813 borders[BorderType_Vertical].width != obj->leftBorderWidth( x, y ))
00814 borders[BorderType_Vertical].bStyle = false;
00815 if ( borders[BorderType_Vertical].color != obj->leftBorderColor( x, y ) )
00816 borders[BorderType_Vertical].bColor = false;
00817 }
00818
00819 void CellFormatDialog::checkBorderHorizontal(Format *obj,int x,int y)
00820 {
00821 if ( borders[BorderType_Horizontal].style != obj->topBorderStyle( x, y ) ||
00822 borders[BorderType_Horizontal].width != obj->topBorderWidth( x, y ) )
00823 borders[BorderType_Horizontal].bStyle = false;
00824 if ( borders[BorderType_Horizontal].color != obj->topBorderColor( x, y ) )
00825 borders[BorderType_Horizontal].bColor = false;
00826 }
00827
00828
00829 void CellFormatDialog::initParameters(Format *obj,int x,int y)
00830 {
00831 if (borders[BorderType_FallingDiagonal].style != obj->fallDiagonalStyle( x, y ))
00832 borders[BorderType_FallingDiagonal].bStyle = false;
00833 if (borders[BorderType_FallingDiagonal].width != obj->fallDiagonalWidth( x, y ))
00834 borders[BorderType_FallingDiagonal].bStyle = false;
00835 if (borders[BorderType_FallingDiagonal].color != obj->fallDiagonalColor( x, y ))
00836 borders[BorderType_FallingDiagonal].bColor = false;
00837
00838 if (borders[BorderType_RisingDiagonal].style != obj->goUpDiagonalStyle( x, y ))
00839 borders[BorderType_RisingDiagonal].bStyle = false;
00840 if (borders[BorderType_RisingDiagonal].width != obj->goUpDiagonalWidth( x, y ))
00841 borders[BorderType_RisingDiagonal].bStyle = false;
00842 if (borders[BorderType_RisingDiagonal].color != obj->goUpDiagonalColor( x, y ))
00843 borders[BorderType_RisingDiagonal].bColor = false;
00844 if ( strike != obj->textFontStrike( x, y ) )
00845 bStrike = false;
00846 if ( underline != obj->textFontUnderline( x, y ) )
00847 bUnderline = false;
00848 if ( prefix != obj->prefix( x, y ) )
00849 prefix = QString::null;
00850 if ( postfix != obj->postfix( x, y ) )
00851 postfix = QString::null;
00852 if ( floatFormat != obj->floatFormat( x, y ) )
00853 bFloatFormat = false;
00854 if ( floatColor != obj->floatColor( x, y ) )
00855 bFloatColor = false;
00856 if ( textColor != obj->textColor( x, y ) )
00857 bTextColor = false;
00858 if ( textFontFamily != obj->textFontFamily( x, y ) )
00859 bTextFontFamily = false;
00860 if ( textFontSize != obj->textFontSize( x, y ) )
00861 bTextFontSize = false;
00862 if ( textFontBold != obj->textFontBold( x, y ) )
00863 bTextFontBold = false;
00864 if ( textFontItalic != obj->textFontItalic( x, y ) )
00865 bTextFontItalic = false;
00866 if ( bgColor != obj->bgColor( x, y ) )
00867 bBgColor = false;
00868 if ( textRotation != obj->getAngle(left, top) )
00869 bTextRotation = false;
00870 if ( formatType != obj->getFormatType(left, top) )
00871 bFormatType = false;
00872 if ( bMultiRow != obj->multiRow( left, top ) )
00873 bMultiRow = false;
00874 if ( bVerticalText!=obj->verticalText( left, top ) )
00875 bVerticalText = false;
00876 if ( bDontPrintText!=obj->getDontprintText( left, top ) )
00877 bDontPrintText= false;
00878
00879 Format::Currency cur;
00880 if (!obj->currencyInfo(cur))
00881 bCurrency = false;
00882 else
00883 if (cur.symbol != cCurrency.symbol)
00884 bCurrency = false;
00885 }
00886
00887 void CellFormatDialog::init()
00888 {
00889 QColorGroup colorGroup = QApplication::palette().active();
00890
00891
00892 if ( formatOnlyNegSignedPixmap == 0L )
00893 {
00894 QColor black = colorGroup.text();
00895 formatOnlyNegSignedPixmap = paintFormatPixmap( "123.456", black, "-123.456", black );
00896 formatRedOnlyNegSignedPixmap = paintFormatPixmap( "123.456", black, "-123.456", Qt::red );
00897 formatRedNeverSignedPixmap = paintFormatPixmap( "123.456", black, "123.456", Qt::red );
00898 formatAlwaysSignedPixmap = paintFormatPixmap( "+123.456", black, "-123.456", black );
00899 formatRedAlwaysSignedPixmap = paintFormatPixmap( "+123.456", black, "-123.456", Qt::red );
00900 }
00901
00902 tab = new QTabDialog( (QWidget*)m_pView, 0L, true );
00903
00904
00905 if ( m_style )
00906 {
00907 generalPage = new GeneralTab( tab, this );
00908 tab->addTab( generalPage, i18n( "&General" ) );
00909 }
00910
00911 floatPage = new CellFormatPageFloat( tab, this );
00912 tab->addTab( floatPage, i18n("&Data Format") );
00913
00914 fontPage = new CellFormatPageFont( tab, this );
00915 tab->addTab( fontPage, i18n("&Font") );
00916
00917
00918
00919
00920 positionPage = new CellFormatPagePosition( tab, this);
00921 tab->addTab( positionPage, i18n("&Position") );
00922
00923 borderPage = new CellFormatPageBorder( tab, this );
00924 tab->addTab( borderPage, i18n("&Border") );
00925
00926 patternPage=new CellFormatPagePattern(tab,this);
00927 tab->addTab( patternPage,i18n("Back&ground"));
00928
00929 protectPage = new CellFormatPageProtection( tab, this );
00930 tab->addTab( protectPage, i18n("&Cell Protection") );
00931
00932 tab->setCancelButton( i18n( "&Cancel" ) );
00933 tab->setOkButton( i18n( "&OK" ) );
00934
00935 tab->setCaption( i18n( "Cell Format" ) );
00936
00937 tab->adjustSize();
00938
00939 connect( tab, SIGNAL( applyButtonPressed() ), this, SLOT( slotApply() ) );
00940
00941 tab->exec();
00942 }
00943
00944 QPixmap * CellFormatDialog::paintFormatPixmap( const char * _string1, const QColor & _color1,
00945 const char *_string2, const QColor & _color2 )
00946 {
00947 QPixmap * pixmap = new QPixmap( 150, 14 );
00948
00949 QPainter painter;
00950 painter.begin( pixmap );
00951 painter.fillRect( 0, 0, 150, 14, QApplication::palette().active().base() );
00952 painter.setPen( _color1 );
00953 painter.drawText( 2, 11, _string1 );
00954 painter.setPen( _color2 );
00955 painter.drawText( 75, 11, _string2 );
00956 painter.end();
00957
00958 QBitmap bm( pixmap->size() );
00959 bm.fill( color0 );
00960 painter.begin( &bm );
00961 painter.setPen( color1 );
00962 painter.drawText( 2, 11, _string1 );
00963 painter.drawText( 75, 11, _string2 );
00964 painter.end();
00965 pixmap->setMask( bm );
00966
00967 return pixmap;
00968 }
00969
00970 int CellFormatDialog::exec()
00971 {
00972 return ( tab->exec() );
00973 }
00974
00975 void CellFormatDialog::applyStyle()
00976 {
00977 generalPage->apply( m_style );
00978
00979 borderPage->apply(0);
00980 floatPage->apply( m_style );
00981
00982 fontPage->apply( m_style );
00983 positionPage->apply( m_style );
00984 patternPage->apply( m_style );
00985 protectPage->apply( m_style );
00986 m_pView->refreshView();
00987 }
00988
00989 void CellFormatDialog::slotApply()
00990 {
00991 if ( m_style )
00992 {
00993 applyStyle();
00994 return;
00995 }
00996
00997
00998
00999
01000
01001 KMacroCommand* macroCommand = new KMacroCommand( i18n("Change Format") );
01002
01003 if ( isMerged != positionPage->getMergedCellState() )
01004 {
01005 if ( positionPage->getMergedCellState() )
01006 {
01007 Manipulator* manipulator = new MergeManipulator();
01008 manipulator->setSheet(m_pView->activeSheet());
01009 manipulator->setRegisterUndo(false);
01010 manipulator->add(*m_pView->selectionInfo());
01011 macroCommand->addCommand( manipulator );
01012 }
01013 else
01014 {
01015
01016 Manipulator* manipulator = new MergeManipulator();
01017 manipulator->setSheet(m_pView->activeSheet());
01018 manipulator->setReverse(true);
01019 manipulator->setRegisterUndo(false);
01020 manipulator->add(*m_pView->selectionInfo());
01021 macroCommand->addCommand( manipulator );
01022 }
01023 }
01024
01025 FormatManipulator* manipulator = new FormatManipulator();
01026 manipulator->setSheet(m_pView->activeSheet());
01027 manipulator->setRegisterUndo(false);
01028 manipulator->add(*m_pView->selectionInfo());
01029 borderPage->apply(manipulator);
01030 floatPage->apply(manipulator);
01031 fontPage->apply(manipulator);
01032 positionPage->apply(manipulator);
01033 patternPage->apply(manipulator);
01034 protectPage->apply(manipulator);
01035
01036 if (!manipulator->isEmpty())
01037 {
01038 macroCommand->addCommand( manipulator );
01039 }
01040 else
01041 {
01042 delete manipulator;
01043 }
01044
01045 if ( int( positionPage->getSizeHeight() ) != int( heightSize ) )
01046 {
01047 ResizeRowManipulator* manipulator = new ResizeRowManipulator();
01048 manipulator->setSheet(m_pView->activeSheet());
01049 manipulator->setSize(positionPage->getSizeHeight());
01050
01051 manipulator->setOldSize(heightSize);
01052 manipulator->add(*m_pView->selectionInfo());
01053 macroCommand->addCommand( manipulator );
01054 }
01055 if ( int( positionPage->getSizeWidth() ) != int( widthSize ) )
01056 {
01057 ResizeColumnManipulator* manipulator = new ResizeColumnManipulator();
01058 manipulator->setSheet(m_pView->activeSheet());
01059 manipulator->setSize(positionPage->getSizeWidth());
01060
01061 manipulator->setOldSize(widthSize);
01062 manipulator->add(*m_pView->selectionInfo());
01063 macroCommand->addCommand( manipulator );
01064 }
01065
01066 macroCommand->execute();
01067 m_doc->addCommand( macroCommand );
01068
01069
01070 m_pView->updateEditWidget();
01071 }
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081 CellFormatPageFloat::CellFormatPageFloat( QWidget* parent, CellFormatDialog *_dlg )
01082 : QWidget ( parent ),
01083 dlg( _dlg )
01084 {
01085 QVBoxLayout* layout = new QVBoxLayout( this, 6,10 );
01086
01087 QButtonGroup *grp = new QButtonGroup( i18n("Format"),this);
01088 QGridLayout *grid = new QGridLayout(grp,11,2,KDialog::marginHint(), KDialog::spacingHint());
01089
01090 int fHeight = grp->fontMetrics().height();
01091 grid->addRowSpacing( 0, fHeight/2 );
01092
01093 grp->setRadioButtonExclusive( true );
01094 generic=new QRadioButton(i18n("Generic"),grp);
01095 QWhatsThis::add(generic, i18n( "This is the default format and KSpread autodetects the actual data type depending on the current cell data. By default, KSpread right justifies numbers, dates and times within a cell and left justifies anything else." ) );
01096 grid->addWidget(generic,1,0);
01097
01098 number=new QRadioButton(i18n("Number"),grp);
01099 QWhatsThis::add(number, i18n( "The number notation uses the notation you globally choose in KControl -> Regional & Accessibility -> Numbers tab. Numbers are right justified by default." ) );
01100 grid->addWidget(number,2,0);
01101
01102 percent=new QRadioButton(i18n("Percent"),grp);
01103 QWhatsThis::add(percent, i18n( "When you have a number in the current cell and you switch from the dcell format from Generic to Percent, the current cell number will be multiplied by 100%.\nFor example if you enter 12 and set the cell format to Percent, the number will then be 1,200 %. Switching back to Generic cell format will bring it back to 12.\nYou can also use the Percent icon in the Format Toolbar." ) );
01104 grid->addWidget(percent,3,0);
01105
01106 money=new QRadioButton(i18n("Money"),grp);
01107 QWhatsThis::add(money, i18n( "The Money format converts your number into money notation using the settings globally fixed in KControl in Regional & Accessibility -> Money. The currency symbol will be displayed and the precision will be the one set in KControl.\nYou can also use the Currency icon in the Format Toolbar to set the cell formatting to look like your current currency." ) );
01108 grid->addWidget(money,4,0);
01109
01110 scientific=new QRadioButton(i18n("Scientific"),grp);
01111 QWhatsThis::add(scientific, i18n( "The scientific format changes your number using the scientific notation. For example, 0.0012 will be changed to 1.2E-03. Going back using Generic cell format will display 0.0012 again." ) );
01112 grid->addWidget(scientific,5,0);
01113
01114 fraction=new QRadioButton(i18n("Fraction"),grp);
01115 QWhatsThis::add(fraction, i18n( "The fraction format changes your number into a fraction. For example, 0.1 can be changed to 1/8, 2/16, 1/10, etc. You define the type of fraction by choosing it in the field on the right. If the exact fraction is not possible in the fraction mode you choose, the nearest closest match is chosen.\n For example: when we have 1.5 as number, we choose Fraction and Sixteenths 1/16 the text displayed into cell is \"1 8/16\" which is an exact fraction. If you have 1.4 as number in your cell and you choose Fraction and Sixteenths 1/16 then the cell will display \"1 6/16\" which is the nearest closest Sixteenth fraction." ) );
01116 grid->addWidget(fraction,6,0);
01117
01118 date=new QRadioButton(i18n("Date format"),grp);
01119 QWhatsThis::add(date, i18n( "To enter a date, you should enter it in one of the formats set in KControl in Regional & Accessibility ->Time & Dates. There are two formats set here: the date format and the short date format.\nJust like you can drag down numbers you can also drag down dates and the next cells will also get dates." ) );
01120 grid->addWidget(date,7,0);
01121
01122 time=new QRadioButton(i18n("Time format"),grp);
01123 QWhatsThis::add(time, i18n( "This formats your cell content as a time. To enter a time, you should enter it in the Time format set in KControl in Regional & Accessibility ->Time & Dates. In the Cell Format dialog box you can set how the time should be displayed by choosing one of the available time format options. The default format is the system format set in KControl. When the number in the cell does not make sense as a time, KSpread will display 00:00 in the global format you have in KControl." ) );
01124 grid->addWidget(time,8,0);
01125
01126 textFormat=new QRadioButton(i18n("Text"),grp);
01127 QWhatsThis::add(textFormat, i18n( "This formats your cell content as text. This can be useful if you want a number treated as text instead as a number, for example for a ZIP code. Setting a number as text format will left justify it. When numbers are formatted as text, they cannot be used in calculations or formulas. It also change the way the cell is justified." ) );
01128 grid->addWidget(textFormat,9,0);
01129
01130 customFormat=new QRadioButton(i18n("Custom"),grp);
01131 QWhatsThis::add(customFormat, i18n( "The custom format does not work yet. To be enabled in the next release." ) );
01132 grid->addWidget(customFormat,10,0);
01133 customFormat->setEnabled( false );
01134
01135 QGroupBox *box2 = new QGroupBox( grp, "Box");
01136 box2->setTitle(i18n("Preview"));
01137 QGridLayout *grid3 = new QGridLayout(box2,1,3,KDialog::marginHint(), KDialog::spacingHint());
01138
01139 exampleLabel=new QLabel(box2);
01140 QWhatsThis::add(exampleLabel, i18n( "This will display a preview of your choice so you can know what it does before clicking the OK button to validate it." ) );
01141 grid3->addWidget(exampleLabel,0,1);
01142
01143 grid->addMultiCellWidget(box2,9,10,1,1);
01144
01145 customFormatEdit = new QLineEdit( grp );
01146 grid->addMultiCellWidget( customFormatEdit, 1, 1, 1, 1 );
01147 customFormatEdit->setHidden( true );
01148
01149 listFormat=new QListBox(grp);
01150 grid->addMultiCellWidget(listFormat,2,7,1,1);
01151 QWhatsThis::add(listFormat, i18n( "Displays choices of format for the fraction, date or time formats." ) );
01152 layout->addWidget(grp);
01153
01154
01155
01156 QGroupBox *box = new QGroupBox( this, "Box");
01157
01158 grid = new QGridLayout(box,3,4,KDialog::marginHint(), KDialog::spacingHint());
01159
01160 postfix = new QLineEdit( box, "LineEdit_1" );
01161 QWhatsThis::add(postfix, i18n( "You can add here a Postfix such as a $HK symbol to the end of each cell content in the checked format." ) );
01162 grid->addWidget(postfix,2,1);
01163 precision = new KIntNumInput( dlg->precision, box, 10 );
01164 precision->setSpecialValueText(i18n("variable"));
01165 precision->setRange(-1,10,1,false);
01166 QWhatsThis::add(precision, i18n( "You can control how many digits are displayed after the decimal point for numeric values. This can also be changed using the Increase precision or Decrease precision icons in the Format toolbar. " ) );
01167 grid->addWidget(precision,1,1);
01168
01169 prefix = new QLineEdit( box, "LineEdit_3" );
01170 QWhatsThis::add(prefix, i18n( "You can add here a Prefix such as a $ symbol at the start of each cell content in the checked format." ) );
01171 grid->addWidget(prefix,0,1);
01172
01173 format = new QComboBox( box, "ListBox_1" );
01174 QWhatsThis::add(format, i18n( "You can choose whether positive values are displayed with a leading + sign and whether negative values are shown in red." ) );
01175 grid->addWidget(format,0,3);
01176
01177 QLabel* tmpQLabel;
01178 tmpQLabel = new QLabel( box, "Label_1" );
01179 grid->addWidget(tmpQLabel,2,0);
01180 tmpQLabel->setText( i18n("Postfix:") );
01181
01182 postfix->setText( dlg->postfix );
01183
01184 tmpQLabel = new QLabel( box, "Label_2" );
01185 grid->addWidget(tmpQLabel,0,0);
01186
01187 tmpQLabel->setText( i18n("Prefix:") );
01188 tmpQLabel = new QLabel( box, "Label_3" );
01189 grid->addWidget(tmpQLabel,1,0);
01190 tmpQLabel->setText( i18n("Precision:") );
01191
01192 prefix->setText( dlg->prefix );
01193
01194 format->insertItem( *_dlg->formatOnlyNegSignedPixmap, 0 );
01195 format->insertItem( *_dlg->formatRedOnlyNegSignedPixmap, 1 );
01196 format->insertItem( *_dlg->formatRedNeverSignedPixmap, 2 );
01197 format->insertItem( *_dlg->formatAlwaysSignedPixmap, 3 );
01198 format->insertItem( *_dlg->formatRedAlwaysSignedPixmap, 4 );
01199
01200 tmpQLabel = new QLabel( box, "Label_4" );
01201 grid->addWidget(tmpQLabel, 0, 2);
01202 tmpQLabel->setText( i18n("Format:") );
01203
01204 currencyLabel = new QLabel( box, "LabelCurrency" );
01205 grid->addWidget(currencyLabel, 1, 2);
01206 currencyLabel->setText( i18n("Currency:") );
01207
01208 currency = new QComboBox( box, "ComboCurrency" );
01209 grid->addWidget(currency, 1, 3);
01210
01211 currency->insertItem( i18n("Automatic") );
01212
01213 int index = 2;
01214 bool ok = true;
01215 QString text;
01216
01217 while ( ok )
01218 {
01219 text = Currency::getChooseString( index, ok );
01220 if ( ok )
01221 {
01222 currency->insertItem( text );
01223 }
01224 else
01225 {
01226 break;
01227 }
01228
01229 ++index;
01230 }
01231
01232 currency->setCurrentItem( 0 );
01233 currency->hide();
01234 currencyLabel->hide();
01235
01236 if ( !dlg->bFloatFormat || !dlg->bFloatColor )
01237 format->setCurrentItem( 5 );
01238 else if ( dlg->floatFormat == Format::OnlyNegSigned && dlg->floatColor == Format::AllBlack )
01239 format->setCurrentItem( 0 );
01240 else if ( dlg->floatFormat == Format::OnlyNegSigned && dlg->floatColor == Format::NegRed )
01241 format->setCurrentItem( 1 );
01242 else if ( dlg->floatFormat == Format::AlwaysUnsigned && dlg->floatColor == Format::NegRed )
01243 format->setCurrentItem( 2 );
01244 else if ( dlg->floatFormat == Format::AlwaysSigned && dlg->floatColor == Format::AllBlack )
01245 format->setCurrentItem( 3 );
01246 else if ( dlg->floatFormat == Format::AlwaysSigned && dlg->floatColor == Format::NegRed )
01247 format->setCurrentItem( 4 );
01248 layout->addWidget(box);
01249
01250 cellFormatType=dlg->formatType;
01251 newFormatType = cellFormatType;
01252
01253 if (!cellFormatType)
01254 generic->setChecked(true);
01255 else
01256 {
01257 if (cellFormatType==Number_format)
01258 number->setChecked(true);
01259 else if (cellFormatType==Percentage_format)
01260 percent->setChecked(true);
01261 else if (cellFormatType==Money_format)
01262 {
01263 money->setChecked(true);
01264 currencyLabel->show();
01265 currency->show();
01266 if (dlg->bCurrency)
01267 {
01268 QString tmp;
01269 if (dlg->cCurrency.type != 1)
01270 {
01271 Currency curr(dlg->cCurrency.type);
01272 bool ok = true;
01273 tmp = Currency::getChooseString(dlg->cCurrency.type, ok);
01274 if ( !ok )
01275 tmp = dlg->cCurrency.symbol;
01276 }
01277 else
01278 tmp = dlg->cCurrency.symbol;
01279 currency->setCurrentText( tmp );
01280 }
01281 }
01282 else if ( cellFormatType == Scientific_format )
01283 scientific->setChecked(true);
01284 else if ( formatIsDate (cellFormatType) )
01285 date->setChecked(true);
01286 else if ( formatIsTime (cellFormatType) )
01287 time->setChecked(true);
01288 else if ( formatIsFraction (cellFormatType) )
01289 fraction->setChecked(true);
01290 else if (cellFormatType == Text_format)
01291 textFormat->setChecked(true);
01292 else if (cellFormatType == Custom_format)
01293 customFormat->setChecked(true);
01294 }
01295
01296 connect(generic,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01297 connect(fraction,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01298 connect(money,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01299 connect(date,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01300 connect(scientific,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01301 connect(number,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01302 connect(percent,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01303 connect(time,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01304 connect(textFormat,SIGNAL(clicked()),this,SLOT(slotChangeState()));
01305 connect(customFormat,SIGNAL(clicked()),this,SLOT(slotChangeState()));
01306
01307 connect(listFormat,SIGNAL(selectionChanged ()),this,SLOT(makeformat()));
01308 connect(precision,SIGNAL(valueChanged(int)),this,SLOT(slotChangeValue(int)));
01309 connect(prefix,SIGNAL(textChanged ( const QString & ) ),this,SLOT(makeformat()));
01310 connect(postfix,SIGNAL(textChanged ( const QString & ) ),this,SLOT(makeformat()));
01311 connect(currency,SIGNAL(activated ( const QString & ) ),this, SLOT(currencyChanged(const QString &)));
01312 connect(format,SIGNAL(activated ( int ) ),this,SLOT(formatChanged(int)));
01313 connect(format, SIGNAL(activated(int)), this, SLOT(makeformat()));
01314 slotChangeState();
01315 m_bFormatColorChanged=false;
01316 m_bFormatTypeChanged=false;
01317 this->resize( 400, 400 );
01318 }
01319
01320 void CellFormatPageFloat::formatChanged(int)
01321 {
01322 m_bFormatColorChanged=true;
01323 }
01324
01325 void CellFormatPageFloat::slotChangeValue(int)
01326 {
01327 makeformat();
01328 }
01329 void CellFormatPageFloat::slotChangeState()
01330 {
01331 QStringList list;
01332 listFormat->clear();
01333 currency->hide();
01334 currencyLabel->hide();
01335
01336
01337 precision->setEnabled(true);
01338 prefix->setEnabled(true);
01339 postfix->setEnabled(true);
01340 format->setEnabled(true);
01341
01342 if (generic->isChecked() || number->isChecked() || percent->isChecked() ||
01343 scientific->isChecked() || textFormat->isChecked())
01344 listFormat->setEnabled(false);
01345 else if (money->isChecked())
01346 {
01347 listFormat->setEnabled(false);
01348 precision->setValue(2);
01349 currency->show();
01350 currencyLabel->show();
01351 }
01352 else if (date->isChecked())
01353 {
01354 format->setEnabled(false);
01355 precision->setEnabled(false);
01356 prefix->setEnabled(false);
01357 postfix->setEnabled(false);
01358 listFormat->setEnabled(true);
01359 init();
01360 }
01361 else if (fraction->isChecked())
01362 {
01363 precision->setEnabled(false);
01364 listFormat->setEnabled(true);
01365 list+=i18n("Halves 1/2");
01366 list+=i18n("Quarters 1/4");
01367 list+=i18n("Eighths 1/8");
01368 list+=i18n("Sixteenths 1/16");
01369 list+=i18n("Tenths 1/10");
01370 list+=i18n("Hundredths 1/100");
01371 list+=i18n("One digit 5/9");
01372 list+=i18n("Two digits 15/22");
01373 list+=i18n("Three digits 153/652");
01374 listFormat->insertStringList(list);
01375 if (cellFormatType == fraction_half)
01376 listFormat->setCurrentItem(0);
01377 else if (cellFormatType == fraction_quarter)
01378 listFormat->setCurrentItem(1);
01379 else if (cellFormatType == fraction_eighth )
01380 listFormat->setCurrentItem(2);
01381 else if (cellFormatType == fraction_sixteenth )
01382 listFormat->setCurrentItem(3);
01383 else if (cellFormatType == fraction_tenth )
01384 listFormat->setCurrentItem(4);
01385 else if (cellFormatType == fraction_hundredth )
01386 listFormat->setCurrentItem(5);
01387 else if (cellFormatType == fraction_one_digit )
01388 listFormat->setCurrentItem(6);
01389 else if (cellFormatType == fraction_two_digits )
01390 listFormat->setCurrentItem(7);
01391 else if (cellFormatType == fraction_three_digits )
01392 listFormat->setCurrentItem(8);
01393 else
01394 listFormat->setCurrentItem(0);
01395 }
01396 else if (time->isChecked())
01397 {
01398 precision->setEnabled(false);
01399 prefix->setEnabled(false);
01400 postfix->setEnabled(false);
01401 format->setEnabled(false);
01402 listFormat->setEnabled(true);
01403
01404
01405 list+=i18n("System: ")+dlg->locale()->formatTime(QTime::currentTime(),false);
01406 list+=i18n("System: ")+dlg->locale()->formatTime(QTime::currentTime(),true);
01407 QDateTime tmpTime (QDate (1, 1, 1900), QTime (10, 35, 25));
01408
01409
01410 ValueFormatter *fmt = dlg->getDoc()->formatter();
01411 list+= fmt->timeFormat(tmpTime, Time_format1);
01412 list+= fmt->timeFormat(tmpTime, Time_format2);
01413 list+= fmt->timeFormat(tmpTime, Time_format3);
01414 list+= fmt->timeFormat(tmpTime, Time_format4);
01415 list+= fmt->timeFormat(tmpTime, Time_format5);
01416 list+= ( fmt->timeFormat(tmpTime, Time_format6) + i18n(" (=[mm]::ss)") );
01417 list+= ( fmt->timeFormat(tmpTime, Time_format7) + i18n(" (=[hh]::mm::ss)") );
01418 list+= ( fmt->timeFormat(tmpTime, Time_format8) + i18n(" (=[hh]::mm)") );
01419 listFormat->insertStringList(list);
01420
01421 if ( cellFormatType == Time_format )
01422 listFormat->setCurrentItem(0);
01423 else if (cellFormatType == SecondeTime_format)
01424 listFormat->setCurrentItem(1);
01425 else if (cellFormatType == Time_format1)
01426 listFormat->setCurrentItem(2);
01427 else if (cellFormatType == Time_format2)
01428 listFormat->setCurrentItem(3);
01429 else if (cellFormatType == Time_format3)
01430 listFormat->setCurrentItem(4);
01431 else if (cellFormatType == Time_format4)
01432 listFormat->setCurrentItem(5);
01433 else if (cellFormatType == Time_format5)
01434 listFormat->setCurrentItem(6);
01435 else if (cellFormatType == Time_format6)
01436 listFormat->setCurrentItem(7);
01437 else if (cellFormatType == Time_format7)
01438 listFormat->setCurrentItem(8);
01439 else if (cellFormatType == Time_format8)
01440 listFormat->setCurrentItem(9);
01441 else
01442 listFormat->setCurrentItem(0);
01443 }
01444
01445 if (customFormat->isChecked())
01446 {
01447 customFormatEdit->setHidden( false );
01448 precision->setEnabled(false);
01449 prefix->setEnabled(false);
01450 postfix->setEnabled(false);
01451 format->setEnabled(false);
01452 listFormat->setEnabled(true);
01453 }
01454 else
01455 customFormatEdit->setHidden( true );
01456
01457 m_bFormatTypeChanged=true;
01458
01459 makeformat();
01460 }
01461
01462 void CellFormatPageFloat::init()
01463 {
01464 QStringList list;
01465 QString tmp;
01466 QString tmp2;
01467 QDate tmpDate( 2000,2,18);
01468 list+=i18n("System: ")+dlg->locale()->formatDate (QDate::currentDate(), true);
01469 list+=i18n("System: ")+dlg->locale()->formatDate (QDate::currentDate(), false);
01470
01471 ValueFormatter *fmt = dlg->getDoc()->formatter();
01472
01473
01474 list+=fmt->dateFormat( tmpDate, date_format1);
01475
01476 list+=fmt->dateFormat( tmpDate, date_format2);
01477
01478 list+=fmt->dateFormat( tmpDate, date_format3);
01479
01480 list+=fmt->dateFormat( tmpDate, date_format4);
01481
01482 list+=fmt->dateFormat( tmpDate, date_format5);
01483
01484 list+=fmt->dateFormat( tmpDate, date_format6);
01485
01486 list+=fmt->dateFormat( tmpDate, date_format7);
01487
01488 list+=fmt->dateFormat( tmpDate, date_format8);
01489
01490 list+=fmt->dateFormat( tmpDate, date_format9);
01491
01492 list+=fmt->dateFormat( tmpDate, date_format10);
01493
01494 list+=fmt->dateFormat( tmpDate, date_format11);
01495
01496 list+=fmt->dateFormat( tmpDate, date_format12);
01497
01498 list+=fmt->dateFormat( tmpDate, date_format13);
01499
01500 list+=fmt->dateFormat( tmpDate, date_format14);
01501
01502 list+=fmt->dateFormat( tmpDate, date_format15);
01503
01504 list+=fmt->dateFormat( tmpDate, date_format16);
01505
01506 list+=fmt->dateFormat( tmpDate, date_format17);
01507 list+=fmt->dateFormat( tmpDate, date_format18);
01508 list+=fmt->dateFormat( tmpDate, date_format19);
01509 list+=fmt->dateFormat( tmpDate, date_format20);
01510 list+=fmt->dateFormat( tmpDate, date_format21);
01511 list+=fmt->dateFormat( tmpDate, date_format22);
01512 list+=fmt->dateFormat( tmpDate, date_format23);
01513 list+=fmt->dateFormat( tmpDate, date_format24);
01514 list+=fmt->dateFormat( tmpDate, date_format25);
01515 list+=fmt->dateFormat( tmpDate, date_format26);
01516
01517 listFormat->insertStringList(list);
01518 if ( cellFormatType == ShortDate_format )
01519 listFormat->setCurrentItem(0);
01520 else if (cellFormatType == TextDate_format)
01521 listFormat->setCurrentItem(1);
01522 else if (cellFormatType == date_format1)
01523 listFormat->setCurrentItem(2);
01524 else if (cellFormatType == date_format2)
01525 listFormat->setCurrentItem(3);
01526 else if (cellFormatType == date_format3)
01527 listFormat->setCurrentItem(4);
01528 else if (cellFormatType == date_format4)
01529 listFormat->setCurrentItem(5);
01530 else if (cellFormatType == date_format5)
01531 listFormat->setCurrentItem(6);
01532 else if (cellFormatType == date_format6)
01533 listFormat->setCurrentItem(7);
01534 else if (cellFormatType == date_format7)
01535 listFormat->setCurrentItem(8);
01536 else if (cellFormatType == date_format8)
01537 listFormat->setCurrentItem(9);
01538 else if (cellFormatType == date_format9)
01539 listFormat->setCurrentItem(10);
01540 else if (cellFormatType == date_format10)
01541 listFormat->setCurrentItem(11);
01542 else if (cellFormatType == date_format11)
01543 listFormat->setCurrentItem(12);
01544 else if (cellFormatType == date_format12)
01545 listFormat->setCurrentItem(13);
01546 else if (cellFormatType == date_format13)
01547 listFormat->setCurrentItem(14);
01548 else if (cellFormatType == date_format14)
01549 listFormat->setCurrentItem(15);
01550 else if (cellFormatType == date_format15)
01551 listFormat->setCurrentItem(16);
01552 else if (cellFormatType == date_format16)
01553 listFormat->setCurrentItem(17);
01554 else if (cellFormatType == date_format17)
01555 listFormat->setCurrentItem(18);
01556 else if (cellFormatType == date_format18)
01557 listFormat->setCurrentItem(19);
01558 else if (cellFormatType == date_format19)
01559 listFormat->setCurrentItem(20);
01560 else if (cellFormatType == date_format20)
01561 listFormat->setCurrentItem(21);
01562 else if (cellFormatType == date_format21)
01563 listFormat->setCurrentItem(22);
01564 else if (cellFormatType == date_format22)
01565 listFormat->setCurrentItem(23);
01566 else if (cellFormatType == date_format23)
01567 listFormat->setCurrentItem(24);
01568 else if (cellFormatType == date_format24)
01569 listFormat->setCurrentItem(25);
01570 else if (cellFormatType == date_format25)
01571 listFormat->setCurrentItem(26);
01572 else if (cellFormatType == date_format26)
01573 listFormat->setCurrentItem(27);
01574 else
01575 listFormat->setCurrentItem(0);
01576
01577 }
01578
01579 void CellFormatPageFloat::currencyChanged(const QString &)
01580 {
01581 int index = currency->currentItem();
01582 if (index > 0)
01583 ++index;
01584 dlg->cCurrency.symbol = Currency::getDisplaySymbol(index);
01585 dlg->cCurrency.type = index;
01586
01587 makeformat();
01588 }
01589
01590 void CellFormatPageFloat::updateFormatType ()
01591 {
01592 if (generic->isChecked())
01593 newFormatType = Generic_format;
01594 else if (number->isChecked())
01595 newFormatType = Number_format;
01596 else if (percent->isChecked())
01597 newFormatType = Percentage_format;
01598 else if (date->isChecked())
01599 {
01600 newFormatType=ShortDate_format;
01601 switch (listFormat->currentItem())
01602 {
01603 case 0: newFormatType=ShortDate_format; break;
01604 case 1: newFormatType=TextDate_format; break;
01605 case 2: newFormatType=date_format1; break;
01606 case 3: newFormatType=date_format2; break;
01607 case 4: newFormatType=date_format3; break;
01608 case 5: newFormatType=date_format4; break;
01609 case 6: newFormatType=date_format5; break;
01610 case 7: newFormatType=date_format6; break;
01611 case 8: newFormatType=date_format7; break;
01612 case 9: newFormatType=date_format8; break;
01613 case 10: newFormatType=date_format9; break;
01614 case 11: newFormatType=date_format10; break;
01615 case 12: newFormatType=date_format11; break;
01616 case 13: newFormatType=date_format12; break;
01617 case 14: newFormatType=date_format13; break;
01618 case 15: newFormatType=date_format14; break;
01619 case 16: newFormatType=date_format15; break;
01620 case 17: newFormatType=date_format16; break;
01621 case 18: newFormatType=date_format17; break;
01622 case 19: newFormatType=date_format18; break;
01623 case 20: newFormatType=date_format19; break;
01624 case 21: newFormatType=date_format20; break;
01625 case 22: newFormatType=date_format21; break;
01626 case 23: newFormatType=date_format22; break;
01627 case 24: newFormatType=date_format23; break;
01628 case 25: newFormatType=date_format24; break;
01629 case 26: newFormatType=date_format25; break;
01630 case 27: newFormatType=date_format26; break;
01631 }
01632 }
01633 else if (money->isChecked())
01634 newFormatType = Money_format;
01635 else if (scientific->isChecked())
01636 newFormatType = Scientific_format;
01637 else if (fraction->isChecked())
01638 {
01639 newFormatType=fraction_half;
01640 switch (listFormat->currentItem())
01641 {
01642 case 0: newFormatType=fraction_half; break;
01643 case 1: newFormatType=fraction_quarter; break;
01644 case 2: newFormatType=fraction_eighth; break;
01645 case 3: newFormatType=fraction_sixteenth; break;
01646 case 4: newFormatType=fraction_tenth; break;
01647 case 5: newFormatType=fraction_hundredth; break;
01648 case 6: newFormatType=fraction_one_digit; break;
01649 case 7: newFormatType=fraction_two_digits; break;
01650 case 8: newFormatType=fraction_three_digits; break;
01651 }
01652 }
01653 else if (time->isChecked())
01654 {
01655 newFormatType=Time_format;
01656 switch (listFormat->currentItem())
01657 {
01658 case 0: newFormatType=Time_format; break;
01659 case 1: newFormatType=SecondeTime_format; break;
01660 case 2: newFormatType=Time_format1; break;
01661 case 3: newFormatType=Time_format2; break;
01662 case 4: newFormatType=Time_format3; break;
01663 case 5: newFormatType=Time_format4; break;
01664 case 6: newFormatType=Time_format5; break;
01665 case 7: newFormatType=Time_format6; break;
01666 case 8: newFormatType=Time_format7; break;
01667 case 9: newFormatType=Time_format8; break;
01668 }
01669 }
01670 else if (textFormat->isChecked())
01671 newFormatType = Text_format;
01672 else if (customFormat->isChecked())
01673 newFormatType = Custom_format;
01674 }
01675
01676 void CellFormatPageFloat::makeformat()
01677 {
01678 m_bFormatTypeChanged=true;
01679 QString tmp;
01680
01681 updateFormatType();
01682 QColor color;
01683 Format::FloatFormat floatFormat = Format::OnlyNegSigned;
01684 switch( format->currentItem() )
01685 {
01686 case 0:
01687 floatFormat = Format::OnlyNegSigned;
01688 color = black;
01689 break;
01690 case 1:
01691 floatFormat = Format::OnlyNegSigned;
01692 color = Qt::red;
01693 break;
01694 case 2:
01695 floatFormat = Format::AlwaysUnsigned;
01696 color = Qt::red;
01697 break;
01698 case 3:
01699 floatFormat = Format::AlwaysSigned;
01700 color = black;
01701 break;
01702 case 4:
01703 floatFormat = Format::AlwaysSigned;
01704 color = Qt::red;
01705 break;
01706 }
01707 if (!dlg->value.isNumber() || dlg->value.asFloat() >= 0 || !format->isEnabled())
01708 {
01709 color = black;
01710 }
01711 ValueFormatter *fmt = dlg->getDoc()->formatter();
01712 tmp = fmt->formatText(dlg->value, newFormatType, precision->value(),
01713 floatFormat,
01714 prefix->isEnabled() ? prefix->text() : QString::null,
01715 postfix->isEnabled() ? postfix->text() : QString::null,
01716 newFormatType == Money_format ? dlg->cCurrency.symbol : QString::null);
01717 if (tmp.length() > 50)
01718 tmp = tmp.left (50);
01719 exampleLabel->setText(tmp.prepend("<font color=" + color.name() + ">").append("</font>"));
01720 }
01721
01722 void CellFormatPageFloat::apply( CustomStyle * style )
01723 {
01724 if ( postfix->text() != dlg->postfix )
01725 {
01726 if ( postfix->isEnabled())
01727 style->changePostfix( postfix->text() );
01728 else
01729 style->changePostfix( "" );
01730 }
01731 if ( prefix->text() != dlg->prefix )
01732 {
01733 if (prefix->isEnabled())
01734 style->changePrefix( prefix->text() );
01735 else
01736 style->changePrefix( "" );
01737 }
01738
01739 if ( dlg->precision != precision->value() )
01740 style->changePrecision( precision->value() );
01741
01742 if ( m_bFormatColorChanged )
01743 {
01744 switch( format->currentItem() )
01745 {
01746 case 0:
01747 style->changeFloatFormat( Format::OnlyNegSigned );
01748 style->changeFloatColor( Format::AllBlack );
01749 break;
01750 case 1:
01751 style->changeFloatFormat( Format::OnlyNegSigned );
01752 style->changeFloatColor( Format::NegRed );
01753 break;
01754 case 2:
01755 style->changeFloatFormat( Format::AlwaysUnsigned );
01756 style->changeFloatColor( Format::NegRed );
01757 break;
01758 case 3:
01759 style->changeFloatFormat( Format::AlwaysSigned );
01760 style->changeFloatColor( Format::AllBlack );
01761 break;
01762 case 4:
01763 style->changeFloatFormat( Format::AlwaysSigned );
01764 style->changeFloatColor( Format::NegRed );
01765 break;
01766 }
01767 }
01768 if ( m_bFormatTypeChanged )
01769 {
01770 style->changeFormatType (newFormatType);
01771 if ( money->isChecked() )
01772 {
01773 Format::Currency cur;
01774 int index = currency->currentItem();
01775 if (index == 0)
01776 {
01777 if ( currency->currentText() == i18n( "Automatic" ) )
01778 {
01779 cur.symbol = dlg->locale()->currencySymbol();
01780 cur.type = 0;
01781 }
01782 else
01783 {
01784 cur.type = 1;
01785 cur.symbol = currency->currentText();
01786 }
01787 }
01788 else
01789 {
01790 cur.type = ++index;
01791 cur.symbol = Currency::getDisplaySymbol( index );
01792 }
01793
01794 style->changeCurrency( cur );
01795 }
01796 }
01797 }
01798
01799 void CellFormatPageFloat::apply(FormatManipulator* _obj)
01800 {
01801 if ( postfix->text() != dlg->postfix )
01802 if ( postfix->isEnabled())
01803 {
01804
01805 if ( postfix->isEnabled())
01806 _obj->setPostfix( postfix->text() );
01807 else
01808 _obj->setPostfix( "" );
01809 }
01810 if ( prefix->text() != dlg->prefix )
01811 if (prefix->isEnabled())
01812 _obj->setPrefix( prefix->text() );
01813 else
01814 _obj->setPrefix( "" );
01815
01816 if ( dlg->precision != precision->value() )
01817 _obj->setPrecision( precision->value() );
01818
01819 if (m_bFormatColorChanged)
01820 {
01821 switch( format->currentItem() )
01822 {
01823 case 0:
01824 _obj->setFloatFormat( Format::OnlyNegSigned );
01825 _obj->setFloatColor( Format::AllBlack );
01826 break;
01827 case 1:
01828 _obj->setFloatFormat( Format::OnlyNegSigned );
01829 _obj->setFloatColor( Format::NegRed );
01830 break;
01831 case 2:
01832 _obj->setFloatFormat( Format::AlwaysUnsigned );
01833 _obj->setFloatColor( Format::NegRed );
01834 break;
01835 case 3:
01836 _obj->setFloatFormat( Format::AlwaysSigned );
01837 _obj->setFloatColor( Format::AllBlack );
01838 break;
01839 case 4:
01840 _obj->setFloatFormat( Format::AlwaysSigned );
01841 _obj->setFloatColor( Format::NegRed );
01842 break;
01843 }
01844 }
01845 if (m_bFormatTypeChanged)
01846 {
01847 _obj->setFormatType (newFormatType);
01848 if (money->isChecked())
01849 {
01850 Format::Currency cur;
01851 int index = currency->currentItem();
01852 if (index == 0)
01853 {
01854 if ( currency->currentText() == i18n( "Automatic" ) )
01855 {
01856 cur.symbol = dlg->locale()->currencySymbol();
01857 cur.type = 0;
01858 }
01859 else
01860 {
01861 cur.type = 1;
01862 cur.symbol = currency->currentText();
01863 }
01864 }
01865 else
01866 {
01867 cur.type = ++index;
01868 cur.symbol = Currency::getDisplaySymbol( index );
01869 }
01870
01871 _obj->setCurrency( cur.type, cur.symbol );
01872 }
01873 }
01874 }
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884 CellFormatPageProtection::CellFormatPageProtection( QWidget* parent, CellFormatDialog * _dlg )
01885 : ProtectionTab( parent ),
01886 m_dlg( _dlg )
01887 {
01888 m_bDontPrint->setChecked( m_dlg->bDontPrintText );
01889 m_bHideAll->setChecked( m_dlg->bHideAll );
01890 m_bHideFormula->setChecked( m_dlg->bHideFormula );
01891 m_bIsProtected->setChecked( m_dlg->bIsProtected );
01892 }
01893
01894 CellFormatPageProtection::~CellFormatPageProtection()
01895 {
01896 }
01897
01898 void CellFormatPageProtection::apply( CustomStyle * style )
01899 {
01900 if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked() )
01901 {
01902 if ( m_bDontPrint->isChecked() )
01903 style->addProperty( Style::PDontPrintText );
01904 else
01905 style->removeProperty( Style::PDontPrintText );
01906 }
01907
01908 if ( m_dlg->bIsProtected != m_bIsProtected->isChecked() )
01909 {
01910 if ( !m_bIsProtected->isChecked() )
01911 style->addProperty( Style::PNotProtected );
01912 else
01913 style->removeProperty( Style::PNotProtected );
01914 }
01915
01916 if ( m_dlg->bHideAll != m_bHideAll->isChecked() )
01917 {
01918 if ( m_bHideAll->isChecked() )
01919 style->addProperty( Style::PHideAll );
01920 else
01921 style->removeProperty( Style::PHideAll );
01922 }
01923
01924 if ( m_dlg->bHideFormula != m_bHideFormula->isChecked() )
01925 {
01926 if ( m_bHideFormula->isChecked() )
01927 style->addProperty( Style::PHideFormula );
01928 else
01929 style->removeProperty( Style::PHideFormula );
01930 }
01931 }
01932
01933 void CellFormatPageProtection::apply(FormatManipulator* _obj)
01934 {
01935 if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked())
01936 _obj->setDontPrintText( m_bDontPrint->isChecked() );
01937
01938 if ( m_dlg->bIsProtected != m_bIsProtected->isChecked())
01939 _obj->setNotProtected( !m_bIsProtected->isChecked() );
01940
01941 if ( m_dlg->bHideAll != m_bHideAll->isChecked())
01942 _obj->setHideAll( m_bHideAll->isChecked() );
01943
01944 if ( m_dlg->bHideFormula != m_bHideFormula->isChecked())
01945 _obj->setHideFormula( m_bHideFormula->isChecked() );
01946 }
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956 CellFormatPageFont::CellFormatPageFont( QWidget* parent, CellFormatDialog *_dlg ) : FontTab( parent )
01957 {
01958 dlg = _dlg;
01959
01960 bTextColorUndefined = !dlg->bTextColor;
01961
01962 connect( textColorButton, SIGNAL( changed( const QColor & ) ),
01963 this, SLOT( slotSetTextColor( const QColor & ) ) );
01964
01965
01966 QStringList tmpListFont;
01967 QFontDatabase *fontDataBase = new QFontDatabase();
01968 tmpListFont = fontDataBase->families();
01969 delete fontDataBase;
01970
01971 family_combo->insertStringList( tmpListFont);
01972 selFont = dlg->textFont;
01973
01974 if ( dlg->bTextFontFamily )
01975 {
01976 selFont.setFamily( dlg->textFontFamily );
01977 kdDebug(36001) << "Family = " << dlg->textFontFamily << endl;
01978
01979 if ( !family_combo->findItem(dlg->textFontFamily))
01980 {
01981 family_combo->insertItem("",0);
01982 family_combo->setCurrentItem(0);
01983 }
01984 else
01985 family_combo->setCurrentItem(family_combo->index(family_combo->findItem(dlg->textFontFamily)));
01986 }
01987 else
01988 {
01989 family_combo->insertItem("",0);
01990 family_combo->setCurrentItem(0);
01991 }
01992
01993 connect( family_combo, SIGNAL(highlighted(const QString &)),
01994 SLOT(family_chosen_slot(const QString &)) );
01995
01996 QStringList lst;
01997 lst.append("");
01998 for ( unsigned int i = 1; i < 100; ++i )
01999 lst.append( QString( "%1" ).arg( i ) );
02000
02001 size_combo->insertStringList( lst );
02002
02003
02004 size_combo->setInsertionPolicy(QComboBox::NoInsertion);
02005
02006 connect( size_combo, SIGNAL(activated(const QString &)),
02007 SLOT(size_chosen_slot(const QString &)) );
02008 connect( size_combo ,SIGNAL( textChanged(const QString &)),
02009 this,SLOT(size_chosen_slot(const QString &)));
02010
02011 connect( weight_combo, SIGNAL(activated(const QString &)),
02012 SLOT(weight_chosen_slot(const QString &)) );
02013
02014 connect( style_combo, SIGNAL(activated(const QString &)),
02015 SLOT(style_chosen_slot(const QString &)) );
02016
02017 strike->setChecked(dlg->strike);
02018 connect( strike, SIGNAL( clicked()),
02019 SLOT(strike_chosen_slot()) );
02020
02021 underline->setChecked(dlg->underline);
02022 connect( underline, SIGNAL( clicked()),
02023 SLOT(underline_chosen_slot()) );
02024
02025 example_label->setText(i18n("Dolor Ipse"));
02026
02027 connect(this,SIGNAL(fontSelected( const QFont& )),
02028 this,SLOT(display_example( const QFont&)));
02029
02030 setCombos();
02031 display_example( selFont );
02032 fontChanged=false;
02033 this->resize( 400, 400 );
02034 }
02035
02036 void CellFormatPageFont::slotSetTextColor( const QColor &_color )
02037 {
02038 textColor = _color;
02039 bTextColorUndefined = false;
02040 }
02041
02042 void CellFormatPageFont::apply( CustomStyle * style )
02043 {
02044 if ( !bTextColorUndefined && textColor != dlg->textColor )
02045 style->changeTextColor( textColor );
02046
02047 if ( ( size_combo->currentItem() != 0 )
02048 && ( dlg->textFontSize != selFont.pointSize() ) )
02049 style->changeFontSize( selFont.pointSize() );
02050
02051 if ( ( selFont.family() != dlg->textFontFamily )
02052 && !family_combo->currentText().isEmpty() )
02053 style->changeFontFamily( selFont.family() );
02054
02055 uint flags = 0;
02056
02057 if ( weight_combo->currentItem() != 0 && selFont.bold() )
02058 flags |= Style::FBold;
02059 else
02060 flags &= ~(uint) Style::FBold;
02061
02062 if ( style_combo->currentItem() != 0 && selFont.italic() )
02063 flags |= Style::FItalic;
02064 else
02065 flags &= ~(uint) Style::FItalic;
02066
02067 if ( strike->isChecked() )
02068 flags |= Style::FStrike;
02069 else
02070 flags &= ~(uint) Style::FStrike;
02071
02072 if ( underline->isChecked() )
02073 flags |= Style::FUnderline;
02074 else
02075 flags &= ~(uint) Style::FUnderline;
02076
02077 style->changeFontFlags( flags );
02078 }
02079
02080 void CellFormatPageFont::apply(FormatManipulator* _obj)
02081 {
02082 if ( !bTextColorUndefined && textColor != dlg->textColor )
02083 _obj->setTextColor( textColor );
02084 if (fontChanged)
02085 {
02086 if ( ( size_combo->currentItem() != 0 )
02087 && ( dlg->textFontSize != selFont.pointSize() ) )
02088 _obj->setFontSize( selFont.pointSize() );
02089 if ( ( selFont.family() != dlg->textFontFamily ) && ( !family_combo->currentText().isEmpty() ) )
02090 _obj->setFontFamily( selFont.family() );
02091 if ( weight_combo->currentItem() != 0 )
02092 _obj->setFontBold( selFont.bold() );
02093 if ( style_combo->currentItem() != 0 )
02094 _obj->setFontItalic( selFont.italic() );
02095 _obj->setFontStrike( strike->isChecked() );
02096 _obj->setFontUnderline(underline->isChecked() );
02097 }
02098 }
02099
02100 void CellFormatPageFont::underline_chosen_slot()
02101 {
02102 selFont.setUnderline( underline->isChecked() );
02103 emit fontSelected(selFont);
02104 }
02105
02106 void CellFormatPageFont::strike_chosen_slot()
02107 {
02108 selFont.setStrikeOut( strike->isChecked() );
02109 emit fontSelected(selFont);
02110 }
02111
02112 void CellFormatPageFont::family_chosen_slot(const QString & family)
02113 {
02114 selFont.setFamily(family);
02115 emit fontSelected(selFont);
02116 }
02117
02118 void CellFormatPageFont::size_chosen_slot(const QString & size)
02119 {
02120 QString size_string = size;
02121
02122 selFont.setPointSize(size_string.toInt());
02123 emit fontSelected(selFont);
02124 }
02125
02126 void CellFormatPageFont::weight_chosen_slot(const QString & weight)
02127 {
02128 QString weight_string = weight;
02129
02130 if ( weight_string == i18n("Normal"))
02131 selFont.setBold(false);
02132 if ( weight_string == i18n("Bold"))
02133 selFont.setBold(true);
02134 emit fontSelected(selFont);
02135 }
02136
02137 void CellFormatPageFont::style_chosen_slot(const QString & style)
02138 {
02139 QString style_string = style;
02140
02141 if ( style_string == i18n("Roman"))
02142 selFont.setItalic(false);
02143 if ( style_string == i18n("Italic"))
02144 selFont.setItalic(true);
02145 emit fontSelected(selFont);
02146 }
02147
02148
02149 void CellFormatPageFont::display_example(const QFont& font)
02150 {
02151 QString string;
02152 fontChanged=true;
02153 example_label->setFont(font);
02154 example_label->repaint();
02155 }
02156
02157 void CellFormatPageFont::setCombos()
02158 {
02159 QString string;
02160 QComboBox* combo;
02161 int number_of_entries;
02162 bool found;
02163
02164 if ( dlg->bTextColor )
02165 textColor = dlg->textColor;
02166 else
02167 textColor = colorGroup().text();
02168
02169 if ( !textColor.isValid() )
02170 textColor =colorGroup().text();
02171
02172 textColorButton->setColor( textColor );
02173
02174
02175 combo = size_combo;
02176 if ( dlg->bTextFontSize )
02177 {
02178 kdDebug(36001) << "SIZE=" << dlg->textFontSize << endl;
02179 selFont.setPointSize( dlg->textFontSize );
02180 number_of_entries = size_combo->count();
02181 string.setNum( dlg->textFontSize );
02182 found = false;
02183
02184 for (int i = 0; i < number_of_entries ; i++){
02185 if ( string == (QString) combo->text(i)){
02186 combo->setCurrentItem(i);
02187 found = true;
02188
02189 break;
02190 }
02191 }
02192 }
02193 else
02194 combo->setCurrentItem( 0 );
02195
02196 if ( !dlg->bTextFontBold )
02197 weight_combo->setCurrentItem(0);
02198 else if ( dlg->textFontBold )
02199 {
02200 selFont.setBold( dlg->textFontBold );
02201 weight_combo->setCurrentItem(2);
02202 }
02203 else
02204 {
02205 selFont.setBold( dlg->textFontBold );
02206 weight_combo->setCurrentItem(1);
02207 }
02208
02209 if ( !dlg->bTextFontItalic )
02210 weight_combo->setCurrentItem(0);
02211 else if ( dlg->textFontItalic )
02212 {
02213 selFont.setItalic( dlg->textFontItalic );
02214 style_combo->setCurrentItem(2);
02215 }
02216 else
02217 {
02218 selFont.setItalic( dlg->textFontItalic );
02219 style_combo->setCurrentItem(1);
02220 }
02221 }
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231 CellFormatPagePosition::CellFormatPagePosition( QWidget* parent, CellFormatDialog *_dlg )
02232 : PositionTab(parent ),
02233 dlg( _dlg )
02234 {
02235 if ( dlg->alignX == Format::Left )
02236 left->setChecked( true );
02237 else if ( dlg->alignX == Format::Center )
02238 center->setChecked( true );
02239 else if ( dlg->alignX == Format::Right )
02240 right->setChecked( true );
02241 else if ( dlg->alignX == Format::Undefined )
02242 standard->setChecked( true );
02243
02244 connect(horizontalGroup, SIGNAL(clicked(int)), this, SLOT(slotStateChanged(int)));
02245
02246 if ( dlg->alignY ==Format::Top )
02247 top->setChecked( true );
02248 else if ( dlg->alignY ==Format::Middle )
02249 middle->setChecked(true );
02250 else if ( dlg->alignY ==Format::Bottom )
02251 bottom->setChecked( true );
02252
02253 multi->setChecked(dlg->bMultiRow);
02254
02255 vertical->setChecked(dlg->bVerticalText);
02256
02257 angleRotation->setValue(-dlg->textRotation);
02258 spinBox3->setValue(-dlg->textRotation);
02259 if ( dlg->textRotation != 0 )
02260 {
02261 multi->setEnabled(false );
02262 vertical->setEnabled(false);
02263 }
02264
02265 mergeCell->setChecked(dlg->isMerged);
02266 mergeCell->setEnabled(!dlg->oneCell && ((!dlg->isRowSelected) && (!dlg->isColumnSelected)));
02267
02268 QGridLayout *grid2 = new QGridLayout(indentGroup, 1, 1, KDialog::marginHint(), KDialog::spacingHint());
02269 grid2->addRowSpacing( 0, indentGroup->fontMetrics().height()/8 );
02270 m_indent = new KoUnitDoubleSpinBox( indentGroup, 0.0, 400.0, 10.0,dlg->indent,dlg->getDoc()->unit() );
02271 grid2->addWidget(m_indent, 0, 0);
02272
02273 width = new KoUnitDoubleSpinBox( m_widthPanel );
02274 QGridLayout *gridWidth = new QGridLayout(m_widthPanel, 1, 1, 0, 0);
02275 gridWidth->addWidget(width, 0, 0);
02276 width->setValue ( dlg->widthSize );
02277 width->setUnit( dlg->getDoc()->unit() );
02278
02279 dlg->widthSize = width->value();
02280
02281 if ( dlg->isRowSelected )
02282 width->setEnabled(false);
02283
02284 defaultWidth->setText(i18n("Default width (%1 %2)").arg(KoUnit::toUserValue(dlg->defaultWidthSize, dlg->getDoc()->unit()), 0, 'f', 2).arg(dlg->getDoc()->unitName()));
02285 if ( dlg->isRowSelected )
02286 defaultWidth->setEnabled(false);
02287
02288 height=new KoUnitDoubleSpinBox( m_heightPanel );
02289 QGridLayout *gridHeight = new QGridLayout(m_heightPanel, 1, 1, 0, 0);
02290 gridHeight->addWidget(height, 0, 0);
02291 height->setValue( dlg->heightSize );
02292 height->setUnit( dlg->getDoc()->unit() );
02293
02294 dlg->heightSize = height->value();
02295
02296 if ( dlg->isColumnSelected )
02297 height->setEnabled(false);
02298
02299 defaultHeight->setText(i18n("Default height (%1 %2)").arg(KoUnit::toUserValue(dlg->defaultHeightSize, dlg->getDoc()->unit()), 0, 'f', 2).arg(dlg->getDoc()->unitName()));
02300 if ( dlg->isColumnSelected )
02301 defaultHeight->setEnabled(false);
02302
02303
02304 if (dlg->getStyle())
02305 {
02306 defaultHeight->setEnabled(false);
02307 defaultWidth->setEnabled(false);
02308 }
02309
02310 connect(defaultWidth , SIGNAL(clicked() ),this, SLOT(slotChangeWidthState()));
02311 connect(defaultHeight , SIGNAL(clicked() ),this, SLOT(slotChangeHeightState()));
02312 connect(vertical , SIGNAL(clicked() ),this, SLOT(slotChangeVerticalState()));
02313 connect(multi , SIGNAL(clicked() ), this, SLOT(slotChangeMultiState()));
02314 connect(angleRotation, SIGNAL(valueChanged(int)), this, SLOT(slotChangeAngle(int)));
02315
02316 slotStateChanged( 0 );
02317 m_bOptionText = false;
02318 this->resize( 400, 400 );
02319 }
02320
02321 void CellFormatPagePosition::slotChangeMultiState()
02322 {
02323 m_bOptionText = true;
02324 if (vertical->isChecked())
02325 {
02326 vertical->setChecked(false);
02327 }
02328 }
02329
02330 void CellFormatPagePosition::slotChangeVerticalState()
02331 {
02332 m_bOptionText=true;
02333 if (multi->isChecked())
02334 {
02335 multi->setChecked(false);
02336 }
02337
02338 }
02339
02340 void CellFormatPagePosition::slotStateChanged(int)
02341 {
02342 if (right->isChecked() || center->isChecked())
02343 m_indent->setEnabled(false);
02344 else
02345 m_indent->setEnabled(true);
02346 }
02347
02348 bool CellFormatPagePosition::getMergedCellState() const
02349 {
02350 return mergeCell->isChecked();
02351 }
02352
02353 void CellFormatPagePosition::slotChangeWidthState()
02354 {
02355 if ( defaultWidth->isChecked())
02356 width->setEnabled(false);
02357 else
02358 width->setEnabled(true);
02359 }
02360
02361 void CellFormatPagePosition::slotChangeHeightState()
02362 {
02363 if ( defaultHeight->isChecked())
02364 height->setEnabled(false);
02365 else
02366 height->setEnabled(true);
02367 }
02368
02369 void CellFormatPagePosition::slotChangeAngle(int _angle)
02370 {
02371 if ( _angle == 0 )
02372 {
02373 multi->setEnabled( true );
02374 vertical->setEnabled( true );
02375 }
02376 else
02377 {
02378 multi->setEnabled( false );
02379 vertical->setEnabled( false );
02380 }
02381 }
02382
02383 void CellFormatPagePosition::apply( CustomStyle * style )
02384 {
02385 if ( top->isChecked() && dlg->alignY != Format::Top )
02386 style->changeAlignY( Format::Top );
02387 else if ( bottom->isChecked() && dlg->alignY != Format::Bottom )
02388 style->changeAlignY( Format::Bottom );
02389 else if ( middle->isChecked() && dlg->alignY != Format::Middle )
02390 style->changeAlignY( Format::Middle );
02391
02392 if ( left->isChecked() && dlg->alignX != Format::Left )
02393 style->changeAlignX( Format::Left );
02394 else if ( right->isChecked() && dlg->alignX != Format::Right )
02395 style->changeAlignX( Format::Right );
02396 else if ( center->isChecked() && dlg->alignX != Format::Center )
02397 style->changeAlignX( Format::Center );
02398 else if ( standard->isChecked() && dlg->alignX != Format::Undefined )
02399 style->changeAlignX( Format::Undefined );
02400
02401 if ( m_bOptionText )
02402 {
02403 if ( multi->isEnabled() )
02404 {
02405 if ( multi->isChecked() )
02406 style->addProperty( Style::PMultiRow );
02407 else
02408 style->removeProperty( Style::PMultiRow );
02409 }
02410 }
02411
02412 if ( m_bOptionText )
02413 {
02414 if ( vertical->isEnabled() )
02415 {
02416 if ( vertical->isChecked() )
02417 style->addProperty( Style::PVerticalText );
02418 else
02419 style->removeProperty( Style::PVerticalText );
02420 }
02421 }
02422
02423 if ( dlg->textRotation != angleRotation->value() )
02424 style->changeRotateAngle( (-angleRotation->value()) );
02425
02426 if ( m_indent->isEnabled()
02427 && dlg->indent != m_indent->value() )
02428 style->changeIndent( m_indent->value() );
02429
02430
02431 if ( dlg->getStyle()->type() == Style::BUILTIN && dlg->getStyle()->name() == "Default" )
02432 {
02433 if ( (int) height->value() != (int) dlg->heightSize )
02434 {
02435 Format::setGlobalRowHeight( height->value() );
02436 }
02437 if ( (int) width->value() != (int) dlg->widthSize )
02438 {
02439 Format::setGlobalColWidth( width->value() );
02440 }
02441 }
02442 }
02443
02444 void CellFormatPagePosition::apply(FormatManipulator* _obj)
02445 {
02446 Format::Align ax;
02447 Format::AlignY ay;
02448
02449 if ( top->isChecked() )
02450 ay = Format::Top;
02451 else if ( bottom->isChecked() )
02452 ay = Format::Bottom;
02453 else if ( middle->isChecked() )
02454 ay = Format::Middle;
02455 else
02456 ay = Format::Middle;
02457
02458 if ( left->isChecked() )
02459 ax = Format::Left;
02460 else if ( right->isChecked() )
02461 ax = Format::Right;
02462 else if ( center->isChecked() )
02463 ax = Format::Center;
02464 else if ( standard->isChecked() )
02465 ax = Format::Undefined;
02466 else
02467 ax = Format::Undefined;
02468
02469 if ( top->isChecked() && ay != dlg->alignY )
02470 _obj->setVerticalAlignment( Format::Top );
02471 else if ( bottom->isChecked() && ay != dlg->alignY )
02472 _obj->setVerticalAlignment( Format::Bottom );
02473 else if ( middle->isChecked() && ay != dlg->alignY )
02474 _obj->setVerticalAlignment( Format::Middle );
02475
02476 if ( left->isChecked() && ax != dlg->alignX )
02477 _obj->setHorizontalAlignment( Format::Left );
02478 else if ( right->isChecked() && ax != dlg->alignX )
02479 _obj->setHorizontalAlignment( Format::Right );
02480 else if ( center->isChecked() && ax != dlg->alignX )
02481 _obj->setHorizontalAlignment( Format::Center );
02482 else if ( standard->isChecked() && ax != dlg->alignX )
02483 _obj->setHorizontalAlignment( Format::Undefined );
02484
02485 if ( m_bOptionText )
02486 {
02487 if ( multi->isEnabled() )
02488 _obj->setMultiRow( multi->isChecked() );
02489 else
02490 _obj->setMultiRow( false );
02491 }
02492
02493 if ( m_bOptionText )
02494 {
02495 if ( vertical->isEnabled() )
02496 _obj->setVerticalText( vertical->isChecked() );
02497 else
02498 _obj->setVerticalText( false );
02499 }
02500
02501 if ( dlg->textRotation!=angleRotation->value() )
02502 _obj->setAngle( (-angleRotation->value() ) );
02503 if ( m_indent->isEnabled()
02504 && dlg->indent != m_indent->value() )
02505 _obj->setIndent( m_indent->value() );
02506 }
02507
02508 double CellFormatPagePosition::getSizeHeight() const
02509 {
02510 if ( defaultHeight->isChecked() )
02511 return dlg->defaultHeightSize;
02512 else
02513 return height->value();
02514 }
02515
02516 double CellFormatPagePosition::getSizeWidth() const
02517 {
02518 if ( defaultWidth->isChecked() )
02519 return dlg->defaultWidthSize;
02520 else
02521 return width->value();
02522 }
02523
02524
02525
02526
02527
02528
02529
02530
02531
02532 BorderButton::BorderButton( QWidget *parent, const char *_name ) : QPushButton(parent,_name)
02533 {
02534 penStyle = Qt::NoPen;
02535 penWidth = 1;
02536 penColor = colorGroup().text();
02537 setToggleButton( true );
02538 setOn( false);
02539 setChanged(false);
02540 }
02541 void BorderButton::mousePressEvent( QMouseEvent * )
02542 {
02543
02544 this->setOn(!isOn());
02545 emit clicked( this );
02546 }
02547
02548 void BorderButton::setUndefined()
02549 {
02550 setPenStyle(SolidLine );
02551 setPenWidth(1);
02552 setColor(colorGroup().midlight());
02553 }
02554
02555
02556 void BorderButton::unselect()
02557 {
02558 setOn(false);
02559 setPenWidth(1);
02560 setPenStyle(Qt::NoPen);
02561 setColor( colorGroup().text() );
02562 setChanged(true);
02563 }
02564
02565
02566
02567
02568
02569
02570
02571
02572
02573 Border::Border( QWidget *parent, const char *_name,bool _oneCol, bool _oneRow )
02574 : QFrame( parent, _name )
02575 {
02576 oneCol=_oneCol;
02577 oneRow=_oneRow;
02578 }
02579
02580
02581 #define OFFSETX 5
02582 #define OFFSETY 5
02583 void Border::paintEvent( QPaintEvent *_ev )
02584 {
02585 QFrame::paintEvent( _ev );
02586 QPen pen;
02587 QPainter painter;
02588 painter.begin( this );
02589 pen=QPen( colorGroup().midlight(),2,SolidLine);
02590 painter.setPen( pen );
02591
02592 painter.drawLine( OFFSETX-5, OFFSETY, OFFSETX , OFFSETY );
02593 painter.drawLine( OFFSETX, OFFSETY-5, OFFSETX , OFFSETY );
02594 painter.drawLine( width()-OFFSETX, OFFSETY, width() , OFFSETY );
02595 painter.drawLine( width()-OFFSETX, OFFSETY-5, width()-OFFSETX , OFFSETY );
02596
02597 painter.drawLine( OFFSETX, height()-OFFSETY, OFFSETX , height() );
02598 painter.drawLine( OFFSETX-5, height()-OFFSETY, OFFSETX , height()-OFFSETY );
02599
02600 painter.drawLine( width()-OFFSETX, height()-OFFSETY, width() , height()-OFFSETY );
02601 painter.drawLine( width()-OFFSETX, height()-OFFSETY, width()-OFFSETX , height() );
02602 if (oneCol==false)
02603 {
02604 painter.drawLine( width()/2, OFFSETY-5, width()/2 , OFFSETY );
02605 painter.drawLine( width()/2-5, OFFSETY, width()/2+5 , OFFSETY );
02606 painter.drawLine( width()/2, height()-OFFSETY, width()/2 , height() );
02607 painter.drawLine( width()/2-5, height()-OFFSETY, width()/2+5 , height()-OFFSETY );
02608 }
02609 if (oneRow==false)
02610 {
02611 painter.drawLine( OFFSETX-5, height()/2, OFFSETX , height()/2 );
02612 painter.drawLine( OFFSETX, height()/2-5, OFFSETX , height()/2+5 );
02613 painter.drawLine( width()-OFFSETX, height()/2, width(), height()/2 );
02614 painter.drawLine( width()-OFFSETX, height()/2-5, width()-OFFSETX , height()/2+5 );
02615 }
02616 painter.end();
02617 emit redraw();
02618 }
02619
02620 void Border::mousePressEvent( QMouseEvent* _ev )
02621 {
02622 emit choosearea(_ev);
02623 }
02624
02625
02626
02627
02628
02629
02630
02631
02632
02633 CellFormatPageBorder::CellFormatPageBorder( QWidget* parent, CellFormatDialog *_dlg )
02634 : QWidget( parent ),
02635 dlg( _dlg )
02636 {
02637 sheet = dlg->getSheet();
02638
02639 InitializeGrids();
02640 InitializeBorderButtons();
02641 InitializePatterns();
02642 SetConnections();
02643
02644 preview->slotSelect();
02645 pattern[2]->slotSelect();
02646
02647 style->setEnabled(false);
02648 size->setEnabled(false);
02649 preview->setPattern( black , 1, SolidLine );
02650 this->resize( 400, 400 );
02651 }
02652
02653 void CellFormatPageBorder::InitializeGrids()
02654 {
02655 QGridLayout *grid = new QGridLayout(this,5,2,KDialog::marginHint(), KDialog::spacingHint());
02656 QGridLayout *grid2 = NULL;
02657 QGroupBox* tmpQGroupBox = NULL;
02658
02659
02660
02661 const char borderButtonNames[BorderType_END][20] =
02662 {"top", "bottom", "left", "right", "vertical", "fall", "go", "horizontal"};
02663
02664 const char shortcutButtonNames[BorderShortcutType_END][20] =
02665 {"remove", "all", "outline"};
02666
02667 QString borderButtonIconNames[BorderType_END] =
02668 {"border_top", "border_bottom", "border_left", "border_right",
02669 "border_vertical", "border_horizontal", "border_fall", "border_up"};
02670
02671 QString shortcutButtonIconNames[BorderShortcutType_END] =
02672 { "border_remove", "", "border_outline"};
02673
02674 int borderButtonPositions[BorderType_END][2] =
02675 {{0,2}, {4,2}, {2,0}, {2,4}, {4,4}, {4,0}, {0,0}, {0,4}};
02676
02677 int shortcutButtonPositions[BorderShortcutType_END][2] =
02678 { {0,0}, {0,1},{0,2} };
02679
02680
02681
02682 tmpQGroupBox = new QGroupBox( this, "GroupBox_1" );
02683 tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
02684 tmpQGroupBox->setTitle( i18n("Border") );
02685 tmpQGroupBox->setAlignment( AlignLeft );
02686 grid2 = new QGridLayout(tmpQGroupBox,6,5,KDialog::marginHint(), KDialog::spacingHint());
02687 int fHeight = tmpQGroupBox->fontMetrics().height();
02688 grid2->addRowSpacing( 0, fHeight/2 );
02689
02690 area=new Border(tmpQGroupBox,"area",dlg->oneCol,dlg->oneRow);
02691 grid2->addMultiCellWidget(area,2,4,1,3);
02692 area->setBackgroundColor( colorGroup().base() );
02693
02694
02695 for (int i=BorderType_Top; i < BorderType_END; i++)
02696 {
02697 borderButtons[i] = new BorderButton(tmpQGroupBox,
02698 borderButtonNames[i]);
02699 loadIcon(borderButtonIconNames[i], borderButtons[i]);
02700 grid2->addWidget(borderButtons[i], borderButtonPositions[i][0] + 1,
02701 borderButtonPositions[i][1]);
02702 }
02703
02704 grid->addMultiCellWidget(tmpQGroupBox,0,2,0,0);
02705
02706
02707
02708
02709 tmpQGroupBox = new QGroupBox( this, "GroupBox_3" );
02710 tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
02711 tmpQGroupBox->setTitle( i18n("Preselect") );
02712 tmpQGroupBox->setAlignment( AlignLeft );
02713
02714 grid2 = new QGridLayout(tmpQGroupBox,1,3,KDialog::marginHint(), KDialog::spacingHint());
02715
02716
02717
02718 if ((dlg->oneRow==true)&&(dlg->oneCol==false))
02719 {
02720 shortcutButtonIconNames[BorderShortcutType_All] = "border_vertical";
02721 }
02722 else if ((dlg->oneRow==false)&&(dlg->oneCol==true))
02723 {
02724 shortcutButtonIconNames[BorderShortcutType_All] = "border_horizontal";
02725 }
02726 else
02727 {
02728 shortcutButtonIconNames[BorderShortcutType_All] = "border_inside";
02729 }
02730
02731 for (int i=BorderShortcutType_Remove; i < BorderShortcutType_END; i++)
02732 {
02733 shortcutButtons[i] = new BorderButton(tmpQGroupBox,
02734 shortcutButtonNames[i]);
02735 loadIcon(shortcutButtonIconNames[i], shortcutButtons[i]);
02736 grid2->addWidget(shortcutButtons[i], shortcutButtonPositions[i][0],
02737 shortcutButtonPositions[i][1]);
02738 }
02739
02740 if (dlg->oneRow && dlg->oneCol)
02741 {
02742 shortcutButtons[BorderShortcutType_All]->setEnabled(false);
02743 }
02744
02745 grid->addMultiCellWidget(tmpQGroupBox,3,4,0,0);
02746
02747
02748 tmpQGroupBox = new QGroupBox( this, "GroupBox_10" );
02749 tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
02750 tmpQGroupBox->setTitle( i18n("Pattern") );
02751 tmpQGroupBox->setAlignment( AlignLeft );
02752
02753 grid2 = new QGridLayout(tmpQGroupBox,7,2,KDialog::marginHint(), KDialog::spacingHint());
02754 fHeight = tmpQGroupBox->fontMetrics().height();
02755 grid2->addRowSpacing( 0, fHeight/2 );
02756
02757 char name[] = "PatternXX";
02758 Q_ASSERT(NUM_BORDER_PATTERNS < 100);
02759
02760 for (int i=0; i < NUM_BORDER_PATTERNS; i++)
02761 {
02762 name[7] = '0' + (i+1) / 10;
02763 name[8] = '0' + (i+1) % 10;
02764 pattern[i] = new PatternSelect( tmpQGroupBox, name );
02765 pattern[i]->setFrameStyle( QFrame::Panel | QFrame::Sunken );
02766 grid2->addWidget(pattern[i], i % 5 + 1, i / 5);
02767
02768
02769
02770
02771
02772
02773
02774 }
02775
02776 color = new KColorButton (tmpQGroupBox, "PushButton_1" );
02777 grid2->addWidget(color,7,1);
02778
02779 QLabel *tmpQLabel = new QLabel( tmpQGroupBox, "Label_6" );
02780 tmpQLabel->setText( i18n("Color:") );
02781 grid2->addWidget(tmpQLabel,7,0);
02782
02783
02784 QGridLayout *grid3 = new QGridLayout( this, 2, 2, KDialog::marginHint(), KDialog::spacingHint() );
02785 customize = new QCheckBox(i18n("Customize"),tmpQGroupBox);
02786 grid3->addWidget(customize,0,0);
02787 connect( customize, SIGNAL( clicked()), SLOT(cutomize_chosen_slot()) );
02788
02789 size=new QComboBox(true,tmpQGroupBox);
02790 grid3->addWidget(size,1,1);
02791 size->setValidator(new KIntValidator( size ));
02792 QString tmp;
02793 for ( int i=0;i<10;i++)
02794 {
02795 tmp=tmp.setNum(i);
02796 size->insertItem(tmp);
02797 }
02798 size->setCurrentItem(1);
02799
02800 style=new QComboBox(tmpQGroupBox);
02801 grid3->addWidget(style,1,0);
02802 style->insertItem(paintFormatPixmap(DotLine),0 );
02803 style->insertItem(paintFormatPixmap(DashLine) ,1);
02804 style->insertItem(paintFormatPixmap(DashDotLine),2 );
02805 style->insertItem(paintFormatPixmap(DashDotDotLine),3 );
02806 style->insertItem(paintFormatPixmap(SolidLine),4);
02807 style->setBackgroundColor( colorGroup().background() );
02808
02809 grid2->addMultiCell(grid3,6,6,0,1);
02810 grid->addMultiCellWidget(tmpQGroupBox,0,3,1,1);
02811
02812
02813 tmpQGroupBox = new QGroupBox(this, "GroupBox_4" );
02814 tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
02815 tmpQGroupBox->setTitle( i18n("Preview") );
02816 tmpQGroupBox->setAlignment( AlignLeft );
02817
02818 grid2 = new QGridLayout(tmpQGroupBox,1,1,KDialog::marginHint(), KDialog::spacingHint());
02819 fHeight = tmpQGroupBox->fontMetrics().height();
02820 grid2->addRowSpacing( 0, fHeight/2 );
02821
02822 preview = new PatternSelect( tmpQGroupBox, "Pattern_preview" );
02823 preview->setFrameStyle( QFrame::Panel | QFrame::Sunken );
02824 grid2->addWidget(preview,1,0);
02825
02826 grid->addWidget(tmpQGroupBox,4,1);
02827 }
02828
02829 void CellFormatPageBorder::InitializeBorderButtons()
02830 {
02831 for (int i=BorderType_Top; i < BorderType_END; i++)
02832 {
02833 if (dlg->borders[i].style != Qt::NoPen ||
02834 !dlg->borders[i].bStyle )
02835 {
02836
02837
02838 if ((dlg->oneRow == true && i == BorderType_Horizontal) ||
02839 (dlg->oneCol == true && i == BorderType_Vertical))
02840 {
02841 borderButtons[i]->setEnabled(false);
02842 }
02843 else if ( dlg->borders[i].bColor && dlg->borders[i].bStyle )
02844 {
02845 borderButtons[i]->setPenStyle(dlg->borders[i].style );
02846 borderButtons[i]->setPenWidth(dlg->borders[i].width);
02847 borderButtons[i]->setColor(dlg->borders[i].color);
02848 borderButtons[i]->setOn(true);
02849 }
02850 else
02851 {
02852 borderButtons[i]->setUndefined();
02853 }
02854 }
02855 }
02856
02857
02858 }
02859
02860 void CellFormatPageBorder::InitializePatterns()
02861 {
02862 pattern[0]->setPattern( black, 1, DotLine );
02863 pattern[1]->setPattern( black, 1, DashLine );
02864 pattern[2]->setPattern( black, 1, SolidLine );
02865 pattern[3]->setPattern( black, 1, DashDotLine );
02866 pattern[4]->setPattern( black, 1, DashDotDotLine );
02867 pattern[5]->setPattern( black, 2, SolidLine );
02868 pattern[6]->setPattern( black, 3, SolidLine );
02869 pattern[7]->setPattern( black, 4, SolidLine );
02870 pattern[8]->setPattern( black, 5, SolidLine );
02871 pattern[9]->setPattern( black, 1, NoPen );
02872
02873 slotSetColorButton( black );
02874 }
02875
02876 void CellFormatPageBorder::SetConnections()
02877 {
02878 connect( color, SIGNAL( changed( const QColor & ) ),
02879 this, SLOT( slotSetColorButton( const QColor & ) ) );
02880
02881 for (int i=0; i < NUM_BORDER_PATTERNS; i++)
02882 {
02883 connect( pattern[i], SIGNAL( clicked( PatternSelect* ) ),
02884 this, SLOT( slotUnselect2( PatternSelect* ) ) );
02885 }
02886
02887 for (int i = BorderType_Top; i < BorderType_END; i++)
02888 {
02889 connect( borderButtons[i], SIGNAL( clicked (BorderButton *) ),
02890 this, SLOT( changeState( BorderButton *) ) );
02891 }
02892
02893 for (int i = BorderShortcutType_Remove; i < BorderShortcutType_END; i++)
02894 {
02895 connect( shortcutButtons[i], SIGNAL( clicked(BorderButton *) ),
02896 this, SLOT( preselect(BorderButton *) ) );
02897 }
02898
02899 connect( area ,SIGNAL( redraw()),this,SLOT(draw()));
02900 connect( area ,SIGNAL( choosearea(QMouseEvent * )),
02901 this,SLOT( slotPressEvent(QMouseEvent *)));
02902
02903 connect( style, SIGNAL( activated(int)), this, SLOT(slotChangeStyle(int)));
02904 connect( size, SIGNAL( textChanged(const QString &)),
02905 this, SLOT(slotChangeStyle(const QString &)));
02906 connect( size ,SIGNAL( activated(int)), this, SLOT(slotChangeStyle(int)));
02907 }
02908
02909 void CellFormatPageBorder::cutomize_chosen_slot()
02910 {
02911 if ( customize->isChecked() )
02912 {
02913 style->setEnabled( true );
02914 size->setEnabled( true );
02915 slotUnselect2( preview );
02916 }
02917 else
02918 {
02919 style->setEnabled( false );
02920 size->setEnabled( false );
02921 pattern[2]->slotSelect();
02922 preview->setPattern( black , 1, SolidLine );
02923 }
02924 }
02925
02926 void CellFormatPageBorder::slotChangeStyle(const QString &)
02927 {
02928
02929 slotChangeStyle(0);
02930 }
02931
02932 void CellFormatPageBorder::slotChangeStyle(int)
02933 {
02934 int index = style->currentItem();
02935 QString tmp;
02936 int penSize = size->currentText().toInt();
02937 if ( !penSize)
02938 {
02939 preview->setPattern( preview->getColor(), penSize, NoPen );
02940 }
02941 else
02942 {
02943 switch(index)
02944 {
02945 case 0:
02946 preview->setPattern( preview->getColor(), penSize, DotLine );
02947 break;
02948 case 1:
02949 preview->setPattern( preview->getColor(), penSize, DashLine );
02950 break;
02951 case 2:
02952 preview->setPattern( preview->getColor(), penSize, DashDotLine );
02953 break;
02954 case 3:
02955 preview->setPattern( preview->getColor(), penSize, DashDotDotLine );
02956 break;
02957 case 4:
02958 preview->setPattern( preview->getColor(), penSize, SolidLine );
02959 break;
02960 default:
02961 kdDebug(36001)<<"Error in combobox\n";
02962 break;
02963 }
02964 }
02965 slotUnselect2(preview);
02966 }
02967
02968 QPixmap CellFormatPageBorder::paintFormatPixmap(PenStyle _style)
02969 {
02970 QPixmap pixmap( style->width(), 14 );
02971 QPainter painter;
02972 QPen pen;
02973 pen=QPen( colorGroup().text(),1,_style);
02974 painter.begin( &pixmap );
02975 painter.fillRect( 0, 0, style->width(), 14, colorGroup().background() );
02976 painter.setPen( pen );
02977 painter.drawLine( 0, 7, style->width(), 7 );
02978 painter.end();
02979 return pixmap;
02980 }
02981
02982 void CellFormatPageBorder::loadIcon( QString _pix, BorderButton *_button)
02983 {
02984 _button->setPixmap( QPixmap( BarIcon(_pix, Factory::global()) ) );
02985 }
02986
02987 void CellFormatPageBorder::apply(FormatManipulator* obj)
02988 {
02989 if (borderButtons[BorderType_Horizontal]->isChanged())
02990 applyHorizontalOutline(obj);
02991
02992 if (borderButtons[BorderType_Vertical]->isChanged())
02993 applyVerticalOutline(obj);
02994
02995 if ( borderButtons[BorderType_Left]->isChanged() )
02996 applyLeftOutline(obj);
02997
02998 if ( borderButtons[BorderType_Right]->isChanged() )
02999 applyRightOutline(obj);
03000
03001 if ( borderButtons[BorderType_Top]->isChanged() )
03002 applyTopOutline(obj);
03003
03004 if ( borderButtons[BorderType_Bottom]->isChanged() )
03005 applyBottomOutline(obj);
03006
03007 if ( borderButtons[BorderType_RisingDiagonal]->isChanged() ||
03008 borderButtons[BorderType_FallingDiagonal]->isChanged() )
03009 applyDiagonalOutline(obj);
03010 }
03011
03012 void CellFormatPageBorder::applyTopOutline(FormatManipulator* obj)
03013 {
03014 BorderButton * top = borderButtons[BorderType_Top];
03015
03016 QPen tmpPen( top->getColor(), top->getPenWidth(), top->getPenStyle());
03017
03018 if ( dlg->getStyle() )
03019 {
03020 dlg->getStyle()->changeTopBorderPen( tmpPen );
03021 }
03022 else
03023 {
03024 if (borderButtons[BorderType_Top]->isChanged())
03025 obj->setTopBorderPen( tmpPen );
03026 }
03027 }
03028
03029 void CellFormatPageBorder::applyBottomOutline(FormatManipulator* obj)
03030 {
03031 BorderButton * bottom = borderButtons[BorderType_Bottom];
03032
03033 QPen tmpPen( bottom->getColor(), bottom->getPenWidth(), bottom->getPenStyle() );
03034
03035 if ( dlg->getStyle() )
03036 {
03037 dlg->getStyle()->changeBottomBorderPen( tmpPen );
03038 }
03039 else
03040 {
03041 if (borderButtons[BorderType_Bottom]->isChanged())
03042 obj->setBottomBorderPen( tmpPen );
03043 }
03044 }
03045
03046 void CellFormatPageBorder::applyLeftOutline(FormatManipulator* obj)
03047 {
03048 BorderButton * left = borderButtons[BorderType_Left];
03049 QPen tmpPen( left->getColor(), left->getPenWidth(), left->getPenStyle() );
03050
03051 if ( dlg->getStyle() )
03052 {
03053 dlg->getStyle()->changeLeftBorderPen( tmpPen );
03054 }
03055 else
03056 {
03057 if (borderButtons[BorderType_Left]->isChanged())
03058 obj->setLeftBorderPen( tmpPen );
03059 }
03060 }
03061
03062 void CellFormatPageBorder::applyRightOutline(FormatManipulator* obj)
03063 {
03064 BorderButton* right = borderButtons[BorderType_Right];
03065 QPen tmpPen( right->getColor(), right->getPenWidth(), right->getPenStyle() );
03066
03067 if ( dlg->getStyle() )
03068 {
03069 dlg->getStyle()->changeRightBorderPen( tmpPen );
03070 }
03071 else
03072 {
03073 if (borderButtons[BorderType_Right]->isChanged())
03074 obj->setRightBorderPen( tmpPen );
03075 }
03076 }
03077
03078 void CellFormatPageBorder::applyDiagonalOutline(FormatManipulator* obj)
03079 {
03080 BorderButton * fallDiagonal = borderButtons[BorderType_FallingDiagonal];
03081 BorderButton * goUpDiagonal = borderButtons[BorderType_RisingDiagonal];
03082 QPen tmpPenFall( fallDiagonal->getColor(), fallDiagonal->getPenWidth(),
03083 fallDiagonal->getPenStyle());
03084 QPen tmpPenGoUp( goUpDiagonal->getColor(), goUpDiagonal->getPenWidth(),
03085 goUpDiagonal->getPenStyle());
03086
03087 if ( dlg->getStyle() )
03088 {
03089 if ( fallDiagonal->isChanged() )
03090 dlg->getStyle()->changeFallBorderPen( tmpPenFall );
03091 if ( goUpDiagonal->isChanged() )
03092 dlg->getStyle()->changeGoUpBorderPen( tmpPenGoUp );
03093 }
03094 else
03095 {
03096 if ( fallDiagonal->isChanged() )
03097 obj->setFallDiagonalPen( tmpPenFall );
03098 if ( goUpDiagonal->isChanged() )
03099 obj->setGoUpDiagonalPen( tmpPenGoUp );
03100 }
03101 }
03102
03103 void CellFormatPageBorder::applyHorizontalOutline(FormatManipulator* obj)
03104 {
03105 QPen tmpPen( borderButtons[BorderType_Horizontal]->getColor(),
03106 borderButtons[BorderType_Horizontal]->getPenWidth(),
03107 borderButtons[BorderType_Horizontal]->getPenStyle());
03108
03109 if ( dlg->getStyle() )
03110 {
03111 dlg->getStyle()->changeTopBorderPen( tmpPen );
03112 }
03113 else
03114 {
03115 if (borderButtons[BorderType_Horizontal]->isChanged())
03116 obj->setHorizontalPen( tmpPen );
03117 }
03118 }
03119
03120 void CellFormatPageBorder::applyVerticalOutline(FormatManipulator* obj)
03121 {
03122 BorderButton* vertical = borderButtons[BorderType_Vertical];
03123 QPen tmpPen( vertical->getColor(), vertical->getPenWidth(),
03124 vertical->getPenStyle());
03125
03126 if ( dlg->getStyle() )
03127 {
03128 dlg->getStyle()->changeLeftBorderPen( tmpPen );
03129 }
03130 else
03131 {
03132 if (borderButtons[BorderType_Vertical]->isChanged())
03133 obj->setVerticalPen( tmpPen );
03134 }
03135 }
03136
03137
03138 void CellFormatPageBorder::slotSetColorButton( const QColor &_color )
03139 {
03140 currentColor = _color;
03141
03142 for ( int i = 0; i < NUM_BORDER_PATTERNS; ++i )
03143 {
03144 pattern[i]->setColor( currentColor );
03145 }
03146 preview->setColor( currentColor );
03147 }
03148
03149 void CellFormatPageBorder::slotUnselect2( PatternSelect *_p )
03150 {
03151 for ( int i = 0; i < NUM_BORDER_PATTERNS; ++i )
03152 {
03153 if ( pattern[i] != _p )
03154 {
03155 pattern[i]->slotUnselect();
03156 }
03157 }
03158 preview->setPattern( _p->getColor(), _p->getPenWidth(), _p->getPenStyle() );
03159 }
03160
03161 void CellFormatPageBorder::preselect( BorderButton *_p )
03162 {
03163 BorderButton* top = borderButtons[BorderType_Top];
03164 BorderButton* bottom = borderButtons[BorderType_Bottom];
03165 BorderButton* left = borderButtons[BorderType_Left];
03166 BorderButton* right = borderButtons[BorderType_Right];
03167 BorderButton* vertical = borderButtons[BorderType_Vertical];
03168 BorderButton* horizontal = borderButtons[BorderType_Horizontal];
03169 BorderButton* remove = shortcutButtons[BorderShortcutType_Remove];
03170 BorderButton* outline = shortcutButtons[BorderShortcutType_Outline];
03171 BorderButton* all = shortcutButtons[BorderShortcutType_All];
03172
03173 _p->setOn(false);
03174 if (_p == remove)
03175 {
03176 for (int i=BorderType_Top; i < BorderType_END; i++)
03177 {
03178 if (borderButtons[i]->isOn())
03179 {
03180 borderButtons[i]->unselect();
03181 }
03182 }
03183 }
03184 if (_p==outline)
03185 {
03186 top->setOn(true);
03187 top->setPenWidth(preview->getPenWidth());
03188 top->setPenStyle(preview->getPenStyle());
03189 top->setColor( currentColor );
03190 top->setChanged(true);
03191 bottom->setOn(true);
03192 bottom->setPenWidth(preview->getPenWidth());
03193 bottom->setPenStyle(preview->getPenStyle());
03194 bottom->setColor( currentColor );
03195 bottom->setChanged(true);
03196 left->setOn(true);
03197 left->setPenWidth(preview->getPenWidth());
03198 left->setPenStyle(preview->getPenStyle());
03199 left->setColor( currentColor );
03200 left->setChanged(true);
03201 right->setOn(true);
03202 right->setPenWidth(preview->getPenWidth());
03203 right->setPenStyle(preview->getPenStyle());
03204 right->setColor( currentColor );
03205 right->setChanged(true);
03206 }
03207 if (_p==all)
03208 {
03209 if (dlg->oneRow==false)
03210 {
03211 horizontal->setOn(true);
03212 horizontal->setPenWidth(preview->getPenWidth());
03213 horizontal->setPenStyle(preview->getPenStyle());
03214 horizontal->setColor( currentColor );
03215 horizontal->setChanged(true);
03216 }
03217 if (dlg->oneCol==false)
03218 {
03219 vertical->setOn(true);
03220 vertical->setPenWidth(preview->getPenWidth());
03221 vertical->setPenStyle(preview->getPenStyle());
03222 vertical->setColor( currentColor );
03223 vertical->setChanged(true);
03224 }
03225 }
03226 area->repaint();
03227 }
03228
03229 void CellFormatPageBorder::changeState( BorderButton *_p)
03230 {
03231 _p->setChanged(true);
03232
03233 if (_p->isOn())
03234 {
03235 _p->setPenWidth(preview->getPenWidth());
03236 _p->setPenStyle(preview->getPenStyle());
03237 _p->setColor( currentColor );
03238 }
03239 else
03240 {
03241 _p->setPenWidth(1);
03242 _p->setPenStyle(Qt::NoPen);
03243 _p->setColor( colorGroup().text() );
03244 }
03245
03246 area->repaint();
03247 }
03248
03249 void CellFormatPageBorder::draw()
03250 {
03251 BorderButton* top = borderButtons[BorderType_Top];
03252 BorderButton* bottom = borderButtons[BorderType_Bottom];
03253 BorderButton* left = borderButtons[BorderType_Left];
03254 BorderButton* right = borderButtons[BorderType_Right];
03255 BorderButton* risingDiagonal = borderButtons[BorderType_RisingDiagonal];
03256 BorderButton* fallingDiagonal = borderButtons[BorderType_FallingDiagonal];
03257 BorderButton* vertical = borderButtons[BorderType_Vertical];
03258 BorderButton* horizontal = borderButtons[BorderType_Horizontal];
03259 QPen pen;
03260 QPainter painter;
03261 painter.begin( area );
03262
03263 if ((bottom->getPenStyle())!=Qt::NoPen)
03264 {
03265 pen=QPen( bottom->getColor(), bottom->getPenWidth(),bottom->getPenStyle());
03266 painter.setPen( pen );
03267 painter.drawLine( OFFSETX, area->height()-OFFSETY, area->width()-OFFSETX , area->height()-OFFSETY );
03268 }
03269 if ((top->getPenStyle())!=Qt::NoPen)
03270 {
03271 pen=QPen( top->getColor(), top->getPenWidth(),top->getPenStyle());
03272 painter.setPen( pen );
03273 painter.drawLine( OFFSETX, OFFSETY, area->width() -OFFSETX, OFFSETY );
03274 }
03275 if ((left->getPenStyle())!=Qt::NoPen)
03276 {
03277 pen=QPen( left->getColor(), left->getPenWidth(),left->getPenStyle());
03278 painter.setPen( pen );
03279 painter.drawLine( OFFSETX, OFFSETY, OFFSETX , area->height()-OFFSETY );
03280 }
03281 if ((right->getPenStyle())!=Qt::NoPen)
03282 {
03283 pen=QPen( right->getColor(), right->getPenWidth(),right->getPenStyle());
03284 painter.setPen( pen );
03285 painter.drawLine( area->width()-OFFSETX, OFFSETY, area->width()-OFFSETX,
03286 area->height()-OFFSETY );
03287
03288 }
03289 if ((fallingDiagonal->getPenStyle())!=Qt::NoPen)
03290 {
03291 pen=QPen( fallingDiagonal->getColor(), fallingDiagonal->getPenWidth(),
03292 fallingDiagonal->getPenStyle());
03293 painter.setPen( pen );
03294 painter.drawLine( OFFSETX, OFFSETY, area->width()-OFFSETX,
03295 area->height()-OFFSETY );
03296 if (dlg->oneCol==false&& dlg->oneRow==false)
03297 {
03298 painter.drawLine( area->width()/2, OFFSETY, area->width()-OFFSETX,
03299 area->height()/2 );
03300 painter.drawLine( OFFSETX,area->height()/2 , area->width()/2,
03301 area->height()-OFFSETY );
03302 }
03303 }
03304 if ((risingDiagonal->getPenStyle())!=Qt::NoPen)
03305 {
03306 pen=QPen( risingDiagonal->getColor(), risingDiagonal->getPenWidth(),
03307 risingDiagonal->getPenStyle());
03308 painter.setPen( pen );
03309 painter.drawLine( OFFSETX, area->height()-OFFSETY , area->width()-OFFSETX ,
03310 OFFSETY );
03311 if (dlg->oneCol==false&& dlg->oneRow==false)
03312 {
03313 painter.drawLine( area->width()/2, OFFSETY, OFFSETX, area->height()/2 );
03314 painter.drawLine( area->width()/2,area->height()-OFFSETY ,
03315 area->width()-OFFSETX, area->height()/2 );
03316 }
03317
03318 }
03319 if ((vertical->getPenStyle())!=Qt::NoPen)
03320 {
03321 pen=QPen( vertical->getColor(), vertical->getPenWidth(),
03322 vertical->getPenStyle());
03323 painter.setPen( pen );
03324 painter.drawLine( area->width()/2, 5 , area->width()/2 , area->height()-5 );
03325 }
03326 if ((horizontal->getPenStyle())!=Qt::NoPen)
03327 {
03328 pen=QPen( horizontal->getColor(), horizontal->getPenWidth(),
03329 horizontal->getPenStyle());
03330 painter.setPen( pen );
03331 painter.drawLine( OFFSETX,area->height()/2,area->width()-OFFSETX,
03332 area->height()/2 );
03333 }
03334 painter.end();
03335 }
03336
03337 void CellFormatPageBorder::invertState(BorderButton *_p)
03338 {
03339 if (_p->isOn())
03340 {
03341 _p->unselect();
03342 }
03343 else
03344 {
03345 _p->setOn(true);
03346 _p->setPenWidth(preview->getPenWidth());
03347 _p->setPenStyle(preview->getPenStyle());
03348 _p->setColor( currentColor );
03349 _p->setChanged(true);
03350 }
03351 }
03352
03353 void CellFormatPageBorder::slotPressEvent(QMouseEvent *_ev)
03354 {
03355 BorderButton* top = borderButtons[BorderType_Top];
03356 BorderButton* bottom = borderButtons[BorderType_Bottom];
03357 BorderButton* left = borderButtons[BorderType_Left];
03358 BorderButton* right = borderButtons[BorderType_Right];
03359 BorderButton* vertical = borderButtons[BorderType_Vertical];
03360 BorderButton* horizontal = borderButtons[BorderType_Horizontal];
03361
03362
03363 QRect rect(OFFSETX,OFFSETY-8,area->width()-OFFSETX,OFFSETY+8);
03364 if (rect.contains(QPoint(_ev->x(),_ev->y())))
03365 {
03366 if (((top->getPenWidth()!=preview->getPenWidth()) ||
03367 (top->getColor()!=currentColor) ||
03368 (top->getPenStyle()!=preview->getPenStyle()))
03369 && top->isOn())
03370 {
03371 top->setPenWidth(preview->getPenWidth());
03372 top->setPenStyle(preview->getPenStyle());
03373 top->setColor( currentColor );
03374 top->setChanged(true);
03375 }
03376 else
03377 invertState(top);
03378 }
03379 rect.setCoords(OFFSETX,area->height()-OFFSETY-8,area->width()-OFFSETX,
03380 area->height()-OFFSETY+8);
03381 if (rect.contains(QPoint(_ev->x(),_ev->y())))
03382 {
03383 if (((bottom->getPenWidth()!=preview->getPenWidth()) ||
03384 (bottom->getColor()!=currentColor) ||
03385 (bottom->getPenStyle()!=preview->getPenStyle()))
03386 && bottom->isOn())
03387 {
03388 bottom->setPenWidth(preview->getPenWidth());
03389 bottom->setPenStyle(preview->getPenStyle());
03390 bottom->setColor( currentColor );
03391 bottom->setChanged(true);
03392 }
03393 else
03394 invertState(bottom);
03395 }
03396
03397 rect.setCoords(OFFSETX-8,OFFSETY,OFFSETX+8,area->height()-OFFSETY);
03398 if (rect.contains(QPoint(_ev->x(),_ev->y())))
03399 {
03400 if (((left->getPenWidth()!=preview->getPenWidth()) ||
03401 (left->getColor()!=currentColor) ||
03402 (left->getPenStyle()!=preview->getPenStyle()))
03403 && left->isOn())
03404 {
03405 left->setPenWidth(preview->getPenWidth());
03406 left->setPenStyle(preview->getPenStyle());
03407 left->setColor( currentColor );
03408 left->setChanged(true);
03409 }
03410 else
03411 invertState(left);
03412 }
03413 rect.setCoords(area->width()-OFFSETX-8,OFFSETY,area->width()-OFFSETX+8,
03414 area->height()-OFFSETY);
03415 if (rect.contains(QPoint(_ev->x(),_ev->y())))
03416 {
03417 if (((right->getPenWidth()!=preview->getPenWidth()) ||
03418 (right->getColor()!=currentColor) ||
03419 (right->getPenStyle()!=preview->getPenStyle()))
03420 && right->isOn())
03421 {
03422 right->setPenWidth(preview->getPenWidth());
03423 right->setPenStyle(preview->getPenStyle());
03424 right->setColor( currentColor );
03425 right->setChanged(true);
03426 }
03427 else
03428 invertState(right);
03429 }
03430
03431
03432
03433
03434
03435
03436
03437
03438
03439
03440
03441
03442
03443
03444 if (dlg->oneCol==false)
03445 {
03446 rect.setCoords(area->width()/2-8,OFFSETY,area->width()/2+8,
03447 area->height()-OFFSETY);
03448
03449 if (rect.contains(QPoint(_ev->x(),_ev->y())))
03450 {
03451 if (((vertical->getPenWidth()!=preview->getPenWidth()) ||
03452 (vertical->getColor()!=currentColor) ||
03453 (vertical->getPenStyle()!=preview->getPenStyle()))
03454 && vertical->isOn())
03455 {
03456 vertical->setPenWidth(preview->getPenWidth());
03457 vertical->setPenStyle(preview->getPenStyle());
03458 vertical->setColor( currentColor );
03459 vertical->setChanged(true);
03460 }
03461 else
03462 invertState(vertical);
03463 }
03464 }
03465 if (dlg->oneRow==false)
03466 {
03467 rect.setCoords(OFFSETX,area->height()/2-8,area->width()-OFFSETX,
03468 area->height()/2+8);
03469 if (rect.contains(QPoint(_ev->x(),_ev->y())))
03470 {
03471 if (((horizontal->getPenWidth()!=preview->getPenWidth()) ||
03472 (horizontal->getColor()!=currentColor) ||
03473 (horizontal->getPenStyle()!=preview->getPenStyle()))
03474 && horizontal->isOn())
03475 {
03476 horizontal->setPenWidth(preview->getPenWidth());
03477 horizontal->setPenStyle(preview->getPenStyle());
03478 horizontal->setColor( currentColor );
03479 horizontal->setChanged(true);
03480 }
03481 else
03482 invertState(horizontal);
03483 }
03484 }
03485
03486 area->repaint();
03487 }
03488
03489
03490
03491
03492
03493
03494
03495
03496
03497 BrushSelect::BrushSelect( QWidget *parent, const char * ) : QFrame( parent )
03498 {
03499 brushStyle = Qt::NoBrush;
03500 brushColor = Qt::red;
03501 selected = false;
03502 }
03503
03504 void BrushSelect::setPattern( const QColor &_color,BrushStyle _style )
03505 {
03506 brushStyle = _style;
03507 brushColor = _color;
03508 repaint();
03509 }
03510
03511
03512 void BrushSelect::paintEvent( QPaintEvent *_ev )
03513 {
03514 QFrame::paintEvent( _ev );
03515
03516 QPainter painter;
03517 QBrush brush(brushColor,brushStyle);
03518 painter.begin( this );
03519 painter.setPen( Qt::NoPen );
03520 painter.setBrush( brush);
03521 painter.drawRect( 2, 2, width()-4, height()-4);
03522 painter.end();
03523 }
03524
03525 void BrushSelect::mousePressEvent( QMouseEvent * )
03526 {
03527 slotSelect();
03528
03529 emit clicked( this );
03530 }
03531
03532 void BrushSelect::slotUnselect()
03533 {
03534 selected = false;
03535
03536 setLineWidth( 1 );
03537 setFrameStyle( QFrame::Panel | QFrame::Sunken );
03538 repaint();
03539 }
03540
03541 void BrushSelect::slotSelect()
03542 {
03543 selected = true;
03544
03545 setLineWidth( 2 );
03546 setFrameStyle( QFrame::Panel | QFrame::Plain );
03547 repaint();
03548 }
03549
03550
03551
03552
03553
03554
03555
03556
03557
03558 CellFormatPagePattern::CellFormatPagePattern( QWidget* parent, CellFormatDialog *_dlg ) : QWidget( parent )
03559 {
03560 dlg = _dlg;
03561
03562 bBgColorUndefined = !dlg->bBgColor;
03563
03564 QGridLayout *grid = new QGridLayout(this,5,2,KDialog::marginHint(), KDialog::spacingHint());
03565
03566 QGroupBox* tmpQGroupBox;
03567 tmpQGroupBox = new QGroupBox( this, "GroupBox_20" );
03568 tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
03569 tmpQGroupBox->setTitle( i18n("Pattern") );
03570 tmpQGroupBox->setAlignment( AlignLeft );
03571
03572 QGridLayout *grid2 = new QGridLayout(tmpQGroupBox,8,3,KDialog::marginHint(), KDialog::spacingHint());
03573 int fHeight = tmpQGroupBox->fontMetrics().height();
03574 grid2->addRowSpacing( 0, fHeight/2 );
03575
03576
03577 brush1 = new BrushSelect( tmpQGroupBox, "Frame_1" );
03578 brush1->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03579 grid2->addWidget(brush1,1,0);
03580
03581 brush2 = new BrushSelect( tmpQGroupBox, "Frame_2" );
03582 brush2->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03583 grid2->addWidget(brush2,1,1);
03584
03585 brush3 = new BrushSelect( tmpQGroupBox, "Frame_3" );
03586 brush3->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03587 grid2->addWidget(brush3,1,2);
03588
03589 brush4 = new BrushSelect( tmpQGroupBox, "Frame_4" );
03590 brush4->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03591 grid2->addWidget(brush4,2,0);
03592
03593 brush5 = new BrushSelect( tmpQGroupBox, "Frame_5" );
03594 brush5->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03595 grid2->addWidget(brush5,2,1);
03596
03597 brush6 = new BrushSelect( tmpQGroupBox, "Frame_6" );
03598 brush6->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03599 grid2->addWidget(brush6,2,2);
03600
03601 brush7 = new BrushSelect( tmpQGroupBox, "Frame_7" );
03602 brush7->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03603 grid2->addWidget(brush7,3,0);
03604
03605 brush8 = new BrushSelect( tmpQGroupBox, "Frame_8" );
03606 brush8->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03607 grid2->addWidget(brush8,3,1);
03608
03609 brush9 = new BrushSelect( tmpQGroupBox, "Frame_9" );
03610 brush9->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03611 grid2->addWidget(brush9,3,2);
03612
03613 brush10 = new BrushSelect( tmpQGroupBox, "Frame_10" );
03614 brush10->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03615 grid2->addWidget(brush10,4,0);
03616
03617 brush11 = new BrushSelect( tmpQGroupBox, "Frame_11" );
03618 brush11->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03619 grid2->addWidget(brush11,4,1);
03620
03621 brush12 = new BrushSelect( tmpQGroupBox, "Frame_12" );
03622 brush12->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03623 grid2->addWidget(brush12,4,2);
03624
03625 brush13 = new BrushSelect( tmpQGroupBox, "Frame_13" );
03626 brush13->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03627 grid2->addWidget(brush13,5,0);
03628
03629 brush14 = new BrushSelect( tmpQGroupBox, "Frame_14" );
03630 brush14->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03631 grid2->addWidget(brush14,5,1);
03632
03633 brush15 = new BrushSelect( tmpQGroupBox, "Frame_15" );
03634 brush15->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03635 grid2->addWidget(brush15,5,2);
03636
03637 QGridLayout *grid3 = new QGridLayout( 1, 2 );
03638 color = new KColorButton (tmpQGroupBox, "ColorButton_1" );
03639 grid3->addWidget(color,0,1);
03640
03641 QLabel *tmpQLabel = new QLabel( tmpQGroupBox, "Label_1" );
03642 tmpQLabel->setText( i18n("Color:") );
03643 grid3->addWidget(tmpQLabel,0,0);
03644
03645 grid2->addMultiCell(grid3,6,6,0,2);
03646
03647 grid3 = new QGridLayout( 1, 3 );
03648 grid3->setSpacing(KDialog::spacingHint());
03649
03650 tmpQLabel = new QLabel( tmpQGroupBox, "Label_2" );
03651 grid3->addWidget(tmpQLabel,0,0);
03652 tmpQLabel->setText( i18n("Background color:") );
03653
03654 bgColorButton = new KColorButton( tmpQGroupBox, "ColorButton" );
03655 grid3->addWidget(bgColorButton,0,1);
03656 if ( dlg->bBgColor )
03657 bgColor = dlg->bgColor;
03658 else
03659 bgColor = colorGroup().base();
03660
03661 if (!bgColor.isValid())
03662 bgColor = colorGroup().base();
03663
03664 bgColorButton->setColor( bgColor );
03665 connect( bgColorButton, SIGNAL( changed( const QColor & ) ),
03666 this, SLOT( slotSetBackgroundColor( const QColor & ) ) );
03667
03668 notAnyColor=new QPushButton(i18n("No Color"),tmpQGroupBox);
03669 grid3->addWidget(notAnyColor,0,2);
03670 connect( notAnyColor, SIGNAL( clicked( ) ),
03671 this, SLOT( slotNotAnyColor( ) ) );
03672 b_notAnyColor=false;
03673
03674 grid2->addMultiCell(grid3,7,7,0,2);
03675
03676 grid->addMultiCellWidget(tmpQGroupBox,0,3,0,0);
03677
03678 tmpQGroupBox = new QGroupBox( this, "GroupBox1" );
03679 tmpQGroupBox->setTitle( i18n("Preview") );
03680 tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
03681 tmpQGroupBox->setAlignment( AlignLeft );
03682
03683 grid2 = new QGridLayout(tmpQGroupBox,2,1,KDialog::marginHint(), KDialog::spacingHint());
03684 fHeight = tmpQGroupBox->fontMetrics().height();
03685 grid2->addRowSpacing( 0, fHeight/2 );
03686
03687 current = new BrushSelect( tmpQGroupBox, "Current" );
03688 current->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03689 grid2->addWidget(current,1,0);
03690 grid->addWidget( tmpQGroupBox,4,0);
03691
03692 connect( brush1, SIGNAL( clicked( BrushSelect* ) ),
03693 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03694 connect( brush2, SIGNAL( clicked( BrushSelect* ) ),
03695 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03696 connect( brush3, SIGNAL( clicked( BrushSelect* ) ),
03697 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03698 connect( brush4, SIGNAL( clicked( BrushSelect* ) ),
03699 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03700 connect( brush5, SIGNAL( clicked( BrushSelect* ) ),
03701 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03702 connect( brush6, SIGNAL( clicked( BrushSelect* ) ),
03703 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03704 connect( brush7, SIGNAL( clicked( BrushSelect* ) ),
03705 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03706 connect( brush8, SIGNAL( clicked( BrushSelect* ) ),
03707 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03708 connect( brush9, SIGNAL( clicked( BrushSelect* ) ),
03709 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03710 connect( brush10, SIGNAL( clicked( BrushSelect* ) ),
03711 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03712 connect( brush11, SIGNAL( clicked( BrushSelect* ) ),
03713 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03714 connect( brush12, SIGNAL( clicked( BrushSelect* ) ),
03715 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03716 connect( brush13, SIGNAL( clicked( BrushSelect* ) ),
03717 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03718 connect( brush14, SIGNAL( clicked( BrushSelect* ) ),
03719 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03720 connect( brush15, SIGNAL( clicked( BrushSelect* ) ),
03721 this, SLOT( slotUnselect2( BrushSelect* ) ) );
03722
03723 brush1->setPattern( Qt::red, Qt::VerPattern );
03724 brush2->setPattern( Qt::red,Qt::HorPattern );
03725 brush3->setPattern( Qt::red,Qt::Dense1Pattern );
03726 brush4->setPattern( Qt::red,Qt::Dense2Pattern );
03727 brush5->setPattern( Qt::red,Qt::Dense3Pattern );
03728 brush6->setPattern( Qt::red,Qt::Dense4Pattern );
03729 brush7->setPattern( Qt::red,Qt::Dense5Pattern );
03730 brush8->setPattern( Qt::red,Qt::Dense6Pattern );
03731 brush9->setPattern( Qt::red,Qt::Dense7Pattern );
03732 brush10->setPattern( Qt::red,Qt::CrossPattern );
03733 brush11->setPattern( Qt::red,Qt::BDiagPattern );
03734 brush12->setPattern( Qt::red,Qt::FDiagPattern );
03735 brush13->setPattern( Qt::red,Qt::VerPattern );
03736 brush14->setPattern( Qt::red,Qt::DiagCrossPattern );
03737 brush15->setPattern( Qt::red,Qt::NoBrush );
03738
03739 current->setPattern(dlg->brushColor,dlg->brushStyle);
03740 current->slotSelect();
03741 selectedBrush=current;
03742 color->setColor(dlg->brushColor);
03743 current->setBackgroundColor( bgColor );
03744
03745 connect( color, SIGNAL( changed( const QColor & ) ),
03746 this, SLOT( slotSetColorButton( const QColor & ) ) );
03747
03748 slotSetColorButton( dlg->brushColor );
03749 init();
03750 this->resize( 400, 400 );
03751 }
03752
03753 void CellFormatPagePattern::slotNotAnyColor()
03754 {
03755 b_notAnyColor = true;
03756 bgColorButton->setColor( colorGroup().base() );
03757 current->setBackgroundColor( colorGroup().base() );
03758 }
03759
03760 void CellFormatPagePattern::slotSetBackgroundColor( const QColor &_color )
03761 {
03762 bgColor =_color;
03763 current->setBackgroundColor( bgColor );
03764 bBgColorUndefined = false;
03765 b_notAnyColor = false;
03766 }
03767
03768 void CellFormatPagePattern::init()
03769 {
03770 if (dlg->brushStyle == Qt::VerPattern)
03771 {
03772 brush1->slotSelect();
03773 }
03774 else if (dlg->brushStyle == Qt::HorPattern)
03775 {
03776 brush2->slotSelect();
03777 }
03778 else if (dlg->brushStyle == Qt::Dense1Pattern)
03779 {
03780 brush3->slotSelect();
03781 }
03782 else if (dlg->brushStyle == Qt::Dense2Pattern)
03783 {
03784 brush4->slotSelect();
03785 }
03786 else if (dlg->brushStyle == Qt::Dense3Pattern)
03787 {
03788 brush5->slotSelect();
03789 }
03790 else if (dlg->brushStyle == Qt::Dense4Pattern)
03791 {
03792 brush6->slotSelect();
03793 }
03794 else if (dlg->brushStyle == Qt::Dense5Pattern)
03795 {
03796 brush7->slotSelect();
03797 }
03798 else if (dlg->brushStyle == Qt::Dense6Pattern)
03799 {
03800 brush8->slotSelect();
03801 }
03802 else if (dlg->brushStyle == Qt::Dense7Pattern)
03803 {
03804 brush9->slotSelect();
03805 }
03806 else if (dlg->brushStyle == Qt::CrossPattern)
03807 {
03808 brush10->slotSelect();
03809 }
03810 else if (dlg->brushStyle == Qt::BDiagPattern)
03811 {
03812 brush11->slotSelect();
03813 }
03814 else if (dlg->brushStyle == Qt::FDiagPattern)
03815 {
03816 brush12->slotSelect();
03817 }
03818 else if (dlg->brushStyle == Qt::VerPattern)
03819 {
03820 brush13->slotSelect();
03821 }
03822 else if (dlg->brushStyle == Qt::DiagCrossPattern)
03823 {
03824 brush14->slotSelect();
03825 }
03826 else if (dlg->brushStyle == Qt::NoBrush)
03827 {
03828 brush15->slotSelect();
03829 }
03830 else
03831 kdDebug(36001) << "Error in brushStyle" << endl;
03832 }
03833
03834 void CellFormatPagePattern::slotSetColorButton( const QColor &_color )
03835 {
03836 currentColor = _color;
03837
03838 brush1->setBrushColor( currentColor );
03839 brush2->setBrushColor( currentColor );
03840 brush3->setBrushColor( currentColor );
03841 brush4->setBrushColor( currentColor );
03842 brush5->setBrushColor( currentColor );
03843 brush6->setBrushColor( currentColor );
03844 brush7->setBrushColor( currentColor );
03845 brush8->setBrushColor( currentColor );
03846 brush9->setBrushColor( currentColor );
03847 brush10->setBrushColor( currentColor );
03848 brush11->setBrushColor( currentColor );
03849 brush12->setBrushColor( currentColor );
03850 brush13->setBrushColor( currentColor );
03851 brush14->setBrushColor( currentColor );
03852 brush15->setBrushColor( currentColor );
03853 current->setBrushColor( currentColor );
03854 }
03855
03856 void CellFormatPagePattern::slotUnselect2( BrushSelect *_p )
03857 {
03858 selectedBrush = _p;
03859
03860 if ( brush1 != _p )
03861 brush1->slotUnselect();
03862 if ( brush2 != _p )
03863 brush2->slotUnselect();
03864 if ( brush3 != _p )
03865 brush3->slotUnselect();
03866 if ( brush4 != _p )
03867 brush4->slotUnselect();
03868 if ( brush5 != _p )
03869 brush5->slotUnselect();
03870 if ( brush6 != _p )
03871 brush6->slotUnselect();
03872 if ( brush7 != _p )
03873 brush7->slotUnselect();
03874 if ( brush8 != _p )
03875 brush8->slotUnselect();
03876 if ( brush9 != _p )
03877 brush9->slotUnselect();
03878 if ( brush10 != _p )
03879 brush10->slotUnselect();
03880 if ( brush11 != _p )
03881 brush11->slotUnselect();
03882 if ( brush12 != _p )
03883 brush12->slotUnselect();
03884 if ( brush13 != _p )
03885 brush13->slotUnselect();
03886 if ( brush14 != _p )
03887 brush14->slotUnselect();
03888 if ( brush15 != _p )
03889 brush15->slotUnselect();
03890
03891 current->setBrushStyle( selectedBrush->getBrushStyle() );
03892 }
03893
03894 void CellFormatPagePattern::apply( CustomStyle * style )
03895 {
03896 if ( selectedBrush != 0L
03897 && ( dlg->brushStyle != selectedBrush->getBrushStyle()
03898 || dlg->brushColor != selectedBrush->getBrushColor() ) )
03899 style->changeBackGroundBrush( QBrush( selectedBrush->getBrushColor(), selectedBrush->getBrushStyle() ) );
03900
03901
03902
03903
03904
03905
03906
03907 if ( bgColor != dlg->getStyle()->bgColor() )
03908 style->changeBgColor( bgColor );
03909 }
03910
03911 void CellFormatPagePattern::apply(FormatManipulator *_obj)
03912 {
03913 if ( selectedBrush != 0L
03914 && ( dlg->brushStyle != selectedBrush->getBrushStyle()
03915 || dlg->brushColor != selectedBrush->getBrushColor() ) )
03916 _obj->setBackgroundBrush( QBrush( selectedBrush->getBrushColor(), selectedBrush->getBrushStyle() ) );
03917
03918 if ( bgColor == dlg->bgColor )
03919 return;
03920
03921 if ( b_notAnyColor)
03922 _obj->setBackgroundColor( QColor() );
03923 else if ( !bBgColorUndefined )
03924 _obj->setBackgroundColor( bgColor );
03925 }
03926
03927 #include "kspread_dlg_layout.moc"
03928