You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3929 lines
126 KiB
3929 lines
126 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2006 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
|
||
|
(C) 2004 Tomas Mecir <mecirt@gmail.com>
|
||
|
(C) 2002-2004 Ariya Hidayat <ariya@kde.org>
|
||
|
(C) 2002-2003 Norbert Andres <nandres@web.de>
|
||
|
(C) 2001-2003 Philipp Mueller <philipp.mueller@gmx.de>
|
||
|
(C) 2002 John Dailey <dailey@vt.edu>
|
||
|
(C) 1999-2002 Laurent Montel <montel@kde.org>
|
||
|
(C) 1999-2002 Harri Porten <porten@kde.org>
|
||
|
(C) 2000-2001 David Faure <faure@kde.org>
|
||
|
(C) 1998-2000 Torben Weis <weis@kde.org>
|
||
|
(C) 2000 Werner Trobin <trobin@kde.org>
|
||
|
(C) 1999 Reginald Stadlbauer <reggie@kde.org>
|
||
|
(C) 1998-1999 Stephan Kulow <coolo@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include <stdlib.h>
|
||
|
#include <math.h>
|
||
|
|
||
14 years ago
|
#include <tqbitmap.h>
|
||
|
#include <tqcheckbox.h>
|
||
|
#include <tqframe.h>
|
||
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
14 years ago
|
#include <tqlistbox.h>
|
||
|
#include <tqfontdatabase.h>
|
||
|
#include <tqradiobutton.h>
|
||
|
#include <tqslider.h>
|
||
|
#include <tqwhatsthis.h>
|
||
15 years ago
|
|
||
|
#include <kcolorbutton.h>
|
||
|
#include <kcombobox.h>
|
||
|
#include <kdebug.h>
|
||
|
#include <kdialog.h>
|
||
|
#include <klineedit.h>
|
||
12 years ago
|
#include <tdemessagebox.h>
|
||
15 years ago
|
#include <knumvalidator.h>
|
||
|
|
||
|
#include <KoUnitWidgets.h>
|
||
|
|
||
|
#include "kspread_canvas.h"
|
||
|
#include "kspread_dlg_layout.h"
|
||
|
#include "kspread_locale.h"
|
||
|
#include "kspread_sheet.h"
|
||
|
#include "kspread_style.h"
|
||
|
#include "kspread_style_manager.h"
|
||
|
#include "kspread_undo.h"
|
||
|
#include "kspread_util.h"
|
||
|
#include "manipulator.h"
|
||
|
#include "selection.h"
|
||
|
#include "valueformatter.h"
|
||
|
|
||
|
using namespace KSpread;
|
||
|
|
||
|
/***************************************************************************
|
||
|
*
|
||
|
* PatternSelect
|
||
|
*
|
||
|
***************************************************************************/
|
||
|
|
||
13 years ago
|
PatternSelect::PatternSelect( TQWidget *parent, const char * )
|
||
|
: TQFrame( parent )
|
||
15 years ago
|
{
|
||
14 years ago
|
penStyle = Qt::NoPen;
|
||
15 years ago
|
penWidth = 1;
|
||
13 years ago
|
penColor = colorGroup().text();
|
||
15 years ago
|
selected = false;
|
||
|
undefined = false;
|
||
|
}
|
||
|
|
||
14 years ago
|
void PatternSelect::setPattern( const TQColor &_color, int _width, Qt::PenStyle _style )
|
||
15 years ago
|
{
|
||
|
penStyle = _style;
|
||
|
penColor = _color;
|
||
|
penWidth = _width;
|
||
13 years ago
|
repaint();
|
||
15 years ago
|
}
|
||
|
|
||
|
void PatternSelect::setUndefined()
|
||
|
{
|
||
|
undefined = true;
|
||
|
}
|
||
|
|
||
14 years ago
|
void PatternSelect::paintEvent( TQPaintEvent *_ev )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQFrame::paintEvent( _ev );
|
||
15 years ago
|
|
||
14 years ago
|
TQPainter painter( this );
|
||
15 years ago
|
|
||
|
if ( !undefined )
|
||
|
{
|
||
14 years ago
|
TQPen pen( penColor, penWidth, penStyle);
|
||
15 years ago
|
painter.setPen( pen );
|
||
|
painter.drawLine( 6, height()/2, width() - 6,height()/2 );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
painter.fillRect( 2, 2, width() - 4, height() - 4, BDiagPattern );
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void PatternSelect::mousePressEvent( TQMouseEvent * )
|
||
15 years ago
|
{
|
||
|
slotSelect();
|
||
|
|
||
|
emit clicked( this );
|
||
|
}
|
||
|
|
||
|
void PatternSelect::slotUnselect()
|
||
|
{
|
||
|
selected = false;
|
||
|
|
||
|
setLineWidth( 1 );
|
||
14 years ago
|
setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
13 years ago
|
repaint();
|
||
15 years ago
|
}
|
||
|
|
||
|
void PatternSelect::slotSelect()
|
||
|
{
|
||
|
selected = true;
|
||
|
|
||
|
setLineWidth( 2 );
|
||
14 years ago
|
setFrameStyle( TQFrame::Panel | TQFrame::Plain );
|
||
13 years ago
|
repaint();
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
*
|
||
|
* GeneralTab
|
||
|
*
|
||
|
***************************************************************************/
|
||
|
|
||
13 years ago
|
GeneralTab::GeneralTab( TQWidget* parent, CellFormatDialog * dlg )
|
||
|
: TQWidget( parent ),
|
||
15 years ago
|
m_dlg( dlg )
|
||
|
{
|
||
13 years ago
|
TQGridLayout * layout = new TQGridLayout( this, 1, 1, KDialog::marginHint(), KDialog::spacingHint(), "layout");
|
||
15 years ago
|
|
||
14 years ago
|
TQGroupBox * groupBox = new TQGroupBox( this, "groupBox1" );
|
||
15 years ago
|
groupBox->setColumnLayout(0, Qt::Vertical );
|
||
|
groupBox->setTitle( i18n( "Style" ) );
|
||
13 years ago
|
groupBox->layout()->setSpacing( KDialog::spacingHint() );
|
||
|
groupBox->layout()->setMargin( KDialog::marginHint() );
|
||
15 years ago
|
|
||
13 years ago
|
TQGridLayout * groupBoxLayout = new TQGridLayout( groupBox->layout() );
|
||
13 years ago
|
groupBoxLayout->setAlignment( TQt::AlignTop );
|
||
15 years ago
|
|
||
14 years ago
|
TQLabel * label1 = new TQLabel( groupBox, "label1" );
|
||
15 years ago
|
label1->setText( i18n( "Name:" ) );
|
||
|
groupBoxLayout->addWidget( label1, 0, 0 );
|
||
|
|
||
|
m_nameEdit = new KLineEdit( groupBox, "m_nameEdit" );
|
||
|
m_nameEdit->setText( m_dlg->styleName );
|
||
|
groupBoxLayout->addWidget( m_nameEdit, 0, 1 );
|
||
|
|
||
14 years ago
|
TQLabel * label2 = new TQLabel( groupBox, "label2" );
|
||
15 years ago
|
label2->setText( i18n( "Inherit style:" ) );
|
||
|
groupBoxLayout->addWidget( label2, 1, 0 );
|
||
|
|
||
|
m_parentBox = new KComboBox( false, groupBox, "m_parentBox" );
|
||
|
m_parentBox->clear();
|
||
|
m_parentBox->insertItem( i18n( "<None>" ) );
|
||
14 years ago
|
TQStringList tmp = m_dlg->getStyleManager()->styleNames();
|
||
15 years ago
|
tmp.remove( m_dlg->styleName );
|
||
|
m_parentBox->insertStringList( tmp );
|
||
|
|
||
13 years ago
|
if ( m_dlg->getStyle()->parent() )
|
||
14 years ago
|
m_parentBox->setCurrentText( m_dlg->getStyle()->parentName() );
|
||
15 years ago
|
else
|
||
|
{
|
||
|
m_parentBox->setCurrentText( i18n( "<None>" ) );
|
||
|
|
||
|
if ( m_dlg->getStyle()->definesAll() )
|
||
|
m_parentBox->setEnabled( false );
|
||
|
}
|
||
|
|
||
14 years ago
|
connect( m_parentBox, TQT_SIGNAL( textChanged( const TQString & ) ), this, TQT_SLOT( slotNewParent( const TQString & ) ) );
|
||
|
connect( m_nameEdit, TQT_SIGNAL( lostFocus() ), this, TQT_SLOT( slotNameChanged() ) );
|
||
15 years ago
|
|
||
|
groupBoxLayout->addWidget( m_parentBox, 1, 1 );
|
||
|
|
||
14 years ago
|
TQSpacerItem * spacer = new TQSpacerItem( 20, 260, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
|
||
15 years ago
|
|
||
13 years ago
|
layout->addWidget( groupBox, 0, 0 );
|
||
|
layout->addItem( spacer, 1, 0 );
|
||
15 years ago
|
|
||
|
if ( m_dlg->getStyle()->type() == Style::BUILTIN )
|
||
|
{
|
||
|
m_nameEdit->setEnabled( false );
|
||
|
m_parentBox->setEnabled( false );
|
||
|
}
|
||
|
|
||
13 years ago
|
resize( TQSize( 534, 447 ).expandedTo(minimumSizeHint()) );
|
||
15 years ago
|
}
|
||
|
|
||
|
GeneralTab::~GeneralTab()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void GeneralTab::slotNameChanged()
|
||
|
{
|
||
|
checkName();
|
||
|
}
|
||
|
|
||
14 years ago
|
void GeneralTab::slotNewParent( const TQString & parentName )
|
||
15 years ago
|
{
|
||
|
kdDebug() << "New Parent" << endl;
|
||
14 years ago
|
if ( !checkParent( parentName ) )
|
||
15 years ago
|
return;
|
||
|
|
||
14 years ago
|
if ( parentName.isEmpty() || parentName == i18n( "<None>" ) )
|
||
15 years ago
|
m_dlg->getStyle()->setParent( 0 );
|
||
|
else
|
||
14 years ago
|
m_dlg->getStyle()->setParent( m_dlg->getStyleManager()->style( parentName ) );
|
||
15 years ago
|
|
||
13 years ago
|
// Set difference to new parent, set GUI to parent values, add changes made before
|
||
15 years ago
|
// m_dlg->initGUI();
|
||
|
}
|
||
|
|
||
|
bool GeneralTab::checkName()
|
||
|
{
|
||
|
if ( m_nameEdit->isEnabled() )
|
||
|
{
|
||
|
if ( !m_dlg->getStyleManager()->validateStyleName( m_nameEdit->text(), m_dlg->getStyle() ) )
|
||
|
{
|
||
|
KMessageBox::sorry( this, i18n( "A style with this name already exists." ) );
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
14 years ago
|
bool GeneralTab::checkParent( const TQString & parentName )
|
||
15 years ago
|
{
|
||
14 years ago
|
if ( m_dlg->getStyle()->parentName() != parentName
|
||
|
&& m_parentBox->isEnabled() && parentName != i18n( "<None>" ) && !parentName.isEmpty() )
|
||
15 years ago
|
{
|
||
14 years ago
|
if ( m_nameEdit->text() == parentName )
|
||
15 years ago
|
{
|
||
|
KMessageBox::sorry( this, i18n( "A style cannot inherit from itself." ) );
|
||
|
return false;
|
||
|
}
|
||
14 years ago
|
if ( !m_dlg->checkCircle( m_nameEdit->text(), parentName ) )
|
||
15 years ago
|
{
|
||
|
KMessageBox::sorry( this,
|
||
|
i18n( "The style cannot inherit from '%1' because of recursive references." )
|
||
13 years ago
|
.arg( m_parentBox->currentText() ) );
|
||
15 years ago
|
return false;
|
||
|
}
|
||
|
|
||
14 years ago
|
CustomStyle * p = m_dlg->getStyleManager()->style( parentName );
|
||
15 years ago
|
|
||
|
if ( !p )
|
||
|
{
|
||
13 years ago
|
KMessageBox::sorry( this, i18n( "The parent style does not exist." ) );
|
||
15 years ago
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
bool GeneralTab::apply( CustomStyle * style )
|
||
|
{
|
||
|
if ( !checkParent( m_parentBox->currentText() ) )
|
||
|
return false;
|
||
|
|
||
|
if ( !checkName() )
|
||
|
return false;
|
||
|
|
||
|
if ( m_nameEdit->isEnabled() )
|
||
|
{
|
||
|
if ( style->type() != Style::BUILTIN )
|
||
|
{
|
||
14 years ago
|
TQString name( style->name() );
|
||
15 years ago
|
style->setName( m_nameEdit->text() );
|
||
|
if ( m_parentBox->isEnabled() )
|
||
|
{
|
||
|
if ( m_parentBox->currentText() == i18n( "None" ) || m_parentBox->currentText().isEmpty() )
|
||
|
style->setParent( 0 );
|
||
|
else
|
||
|
style->setParent( m_dlg->getStyleManager()->style( m_parentBox->currentText() ) );
|
||
|
}
|
||
|
m_dlg->getStyleManager()->changeName( name, m_nameEdit->text() );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( style->type() == Style::TENTATIVE )
|
||
|
style->setType( Style::CUSTOM );
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
*
|
||
|
* CellFormatDialog
|
||
|
*
|
||
|
***************************************************************************/
|
||
|
|
||
|
CellFormatDialog::CellFormatDialog( View * _view, Sheet * _sheet )
|
||
14 years ago
|
: TQObject(),
|
||
15 years ago
|
m_doc( _sheet->doc() ),
|
||
|
m_sheet( _sheet ),
|
||
|
m_pView( _view ),
|
||
|
m_style( 0 )
|
||
|
{
|
||
|
initMembers();
|
||
|
|
||
|
//We need both conditions quite often, so store the condition here too
|
||
|
isRowSelected = _view->selectionInfo()->isRowSelected();
|
||
|
isColumnSelected = _view->selectionInfo()->isColumnSelected();
|
||
|
|
||
14 years ago
|
TQRect range = _view->selectionInfo()->selection();
|
||
15 years ago
|
left = range.left();
|
||
|
top = range.top();
|
||
|
right = range.right();
|
||
|
bottom = range.bottom();
|
||
|
|
||
|
if ( left == right )
|
||
|
oneCol = true;
|
||
|
else
|
||
|
oneCol = false;
|
||
|
|
||
|
if ( top == bottom )
|
||
|
oneRow = true;
|
||
|
else
|
||
|
oneRow = false;
|
||
|
|
||
|
Cell* obj = m_sheet->cellAt( left, top );
|
||
|
oneCell = (left == right && top == bottom &&
|
||
|
!obj->doesMergeCells());
|
||
|
|
||
|
isMerged = ((obj->doesMergeCells() &&
|
||
|
left + obj->extraXCells() >= right &&
|
||
|
top + obj->extraYCells() >= bottom));
|
||
|
|
||
|
// Initialize with the upper left object.
|
||
|
borders[BorderType_Left].style = obj->format()->leftBorderStyle( left, top );
|
||
|
borders[BorderType_Left].width = obj->format()->leftBorderWidth( left, top );
|
||
|
borders[BorderType_Left].color = obj->format()->leftBorderColor( left, top );
|
||
|
borders[BorderType_Top].style = obj->format()->topBorderStyle( left, top );
|
||
|
borders[BorderType_Top].width = obj->format()->topBorderWidth( left, top );
|
||
|
borders[BorderType_Top].color = obj->format()->topBorderColor( left, top );
|
||
|
borders[BorderType_FallingDiagonal].style =
|
||
|
obj->format()->fallDiagonalStyle( left, top );
|
||
|
borders[BorderType_FallingDiagonal].width =
|
||
|
obj->format()->fallDiagonalWidth( left, top );
|
||
|
borders[BorderType_FallingDiagonal].color =
|
||
|
obj->format()->fallDiagonalColor( left, top );
|
||
|
borders[BorderType_RisingDiagonal].style =
|
||
|
obj->format()->goUpDiagonalStyle( left, top );
|
||
|
borders[BorderType_RisingDiagonal].width =
|
||
|
obj->format()->goUpDiagonalWidth( left, top );
|
||
|
borders[BorderType_RisingDiagonal].color =
|
||
|
obj->format()->goUpDiagonalColor( left, top );
|
||
|
|
||
|
// Look at the upper right one for the right border.
|
||
|
obj = m_sheet->cellAt( right, top );
|
||
|
borders[BorderType_Right].style = obj->format()->rightBorderStyle( right, top );
|
||
|
borders[BorderType_Right].width = obj->format()->rightBorderWidth( right, top );
|
||
|
borders[BorderType_Right].color = obj->format()->rightBorderColor( right, top );
|
||
|
|
||
|
// Look at the bottom left cell for the bottom border.
|
||
|
obj = m_sheet->cellAt( left, bottom );
|
||
|
borders[BorderType_Bottom].style = obj->format()->bottomBorderStyle( left, bottom );
|
||
|
borders[BorderType_Bottom].width = obj->format()->bottomBorderWidth( left, bottom );
|
||
|
borders[BorderType_Bottom].color = obj->format()->bottomBorderColor( left, bottom );
|
||
|
|
||
|
// Just an assumption
|
||
|
obj = m_sheet->cellAt( right, top );
|
||
|
if ( obj->isPartOfMerged() )
|
||
|
{
|
||
|
obj = obj->obscuringCells().first();
|
||
|
int moveX = obj->column();
|
||
|
int moveY = top;
|
||
|
int moveX2 = right;
|
||
|
int moveY2 = obj->row();
|
||
|
borders[BorderType_Vertical].style = obj->format()->leftBorderStyle( moveX, moveY );
|
||
|
borders[BorderType_Vertical].width = obj->format()->leftBorderWidth( moveX, moveY );
|
||
|
borders[BorderType_Vertical].color = obj->format()->leftBorderColor( moveX, moveY );
|
||
|
|
||
|
obj = m_sheet->cellAt( moveX2, moveY2 );
|
||
|
borders[BorderType_Horizontal].style = obj->format()->topBorderStyle( moveX2, moveY2 );
|
||
|
borders[BorderType_Horizontal].width = obj->format()->topBorderWidth( moveX2, moveY2 );
|
||
|
borders[BorderType_Horizontal].color = obj->format()->topBorderColor( moveX2, moveY2 );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
borders[BorderType_Vertical].style = obj->format()->leftBorderStyle( right, top );
|
||
|
borders[BorderType_Vertical].width = obj->format()->leftBorderWidth( right, top );
|
||
|
borders[BorderType_Vertical].color = obj->format()->leftBorderColor( right, top );
|
||
|
borders[BorderType_Horizontal].style = obj->format()->topBorderStyle(right, bottom);
|
||
|
borders[BorderType_Horizontal].width = obj->format()->topBorderWidth(right, bottom);
|
||
|
borders[BorderType_Horizontal].color = obj->format()->topBorderColor(right, bottom);
|
||
|
}
|
||
|
|
||
|
obj = m_sheet->cellAt( left, top );
|
||
|
prefix = obj->format()->prefix( left, top );
|
||
|
postfix = obj->format()->postfix( left, top );
|
||
|
precision = obj->format()->precision( left, top );
|
||
|
floatFormat = obj->format()->floatFormat( left, top );
|
||
|
floatColor = obj->format()->floatColor( left, top );
|
||
|
alignX = obj->format()->align( left, top );
|
||
|
alignY = obj->format()->alignY( left, top );
|
||
|
textColor = obj->format()->textColor( left, top );
|
||
|
bgColor = obj->bgColor( left, top );
|
||
|
textFontSize = obj->format()->textFontSize( left, top );
|
||
|
textFontFamily = obj->format()->textFontFamily( left, top );
|
||
|
textFontBold = obj->format()->textFontBold( left, top );
|
||
|
textFontItalic = obj->format()->textFontItalic( left, top );
|
||
|
strike=obj->format()->textFontStrike( left, top );
|
||
|
underline = obj->format()->textFontUnderline( left, top );
|
||
14 years ago
|
// Needed to initialize the font correctly ( bug in TQt )
|
||
15 years ago
|
textFont = obj->format()->textFont( left, top );
|
||
|
obj->format()->currencyInfo( cCurrency );
|
||
|
|
||
|
brushColor = obj->format()->backGroundBrushColor( left, top );
|
||
|
brushStyle = obj->format()->backGroundBrushStyle( left,top );
|
||
|
|
||
|
bMultiRow = obj->format()->multiRow( left, top );
|
||
|
bVerticalText = obj->format()->verticalText( left, top );
|
||
|
textRotation = obj->format()->getAngle(left, top);
|
||
|
formatType = obj->format()->getFormatType(left, top);
|
||
|
|
||
|
bDontPrintText = obj->format()->getDontprintText( left, top );
|
||
|
bHideFormula = obj->format()->isHideFormula( left, top );
|
||
|
bHideAll = obj->format()->isHideAll( left, top );
|
||
|
bIsProtected = !obj->format()->notProtected( left, top );
|
||
|
|
||
|
indent = obj->format()->getIndent(left, top);
|
||
|
|
||
|
value = obj->value();
|
||
|
|
||
|
RowFormat *rl;
|
||
|
ColumnFormat *cl;
|
||
|
widthSize = 0.0;
|
||
|
heightSize = 0.0;
|
||
|
|
||
|
if ( !isRowSelected )
|
||
|
{
|
||
|
for ( int x = left; x <= right; x++ )
|
||
|
{
|
||
|
cl = m_pView->activeSheet()->columnFormat( x );
|
||
14 years ago
|
widthSize = TQMAX( cl->dblWidth(), widthSize );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
if ( !isColumnSelected )
|
||
|
{
|
||
|
for ( int y = top; y <= bottom; y++ )
|
||
|
{
|
||
|
rl = m_pView->activeSheet()->rowFormat(y);
|
||
14 years ago
|
heightSize = TQMAX( rl->dblHeight(), heightSize );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
//select column(s)
|
||
|
if ( isColumnSelected )
|
||
|
{
|
||
|
int y = 1;
|
||
|
Cell* cell = NULL;
|
||
|
for (int x = left;x <= right; x++)
|
||
|
{
|
||
|
ColumnFormat *obj = m_sheet->nonDefaultColumnFormat(x);
|
||
|
initParameters( obj,x,y);
|
||
|
|
||
|
for (cell = m_sheet->getFirstCellColumn(x); cell != NULL;
|
||
|
cell = m_sheet->getNextCellDown(cell->column(), cell->row()))
|
||
|
{
|
||
|
initParameters( cell->format(), x, cell->row());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if ( isRowSelected )
|
||
|
{
|
||
|
int x = 1;
|
||
|
Cell* c = NULL;
|
||
|
for ( int y = top;y<=bottom;y++)
|
||
|
{
|
||
|
RowFormat *obj = m_sheet->nonDefaultRowFormat(y);
|
||
|
initParameters( obj,x,y);
|
||
|
|
||
|
for (c = m_sheet->getFirstCellRow(y); c != NULL;
|
||
|
c = m_sheet->getNextCellRight(c->column(), c->row()) )
|
||
|
{
|
||
|
initParameters( c->format(), c->column(), c->row());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// Do the other objects have the same values ?
|
||
|
for ( int x = left; x <= right; x++ )
|
||
|
{
|
||
|
for ( int y = top; y <= bottom; y++ )
|
||
|
{
|
||
|
Cell *obj = m_sheet->cellAt( x, y );
|
||
|
|
||
|
if ( obj->isPartOfMerged() )
|
||
|
continue;
|
||
|
|
||
|
initParameters( obj->format(),x,y);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if ( !bTextRotation )
|
||
|
textRotation = 0;
|
||
|
|
||
|
if ( isColumnSelected )
|
||
|
{
|
||
|
int y=1;
|
||
|
ColumnFormat *obj=m_sheet->nonDefaultColumnFormat(left);
|
||
|
checkBorderLeft( obj,left, y);
|
||
|
|
||
|
Cell* c = NULL;
|
||
|
for (c = m_sheet->getFirstCellColumn(left); c != NULL;
|
||
|
c = m_sheet->getNextCellDown(c->column(), c->row()) )
|
||
|
{
|
||
|
checkBorderLeft(c->format(), c->column(), c->row());
|
||
|
}
|
||
|
|
||
|
|
||
|
obj=m_sheet->nonDefaultColumnFormat(right);
|
||
|
checkBorderRight(obj,right,y);
|
||
|
c = NULL;
|
||
|
for (c = m_sheet->getFirstCellColumn(right); c != NULL;
|
||
|
c = m_sheet->getNextCellDown(c->column(), c->row()) )
|
||
|
{
|
||
|
checkBorderRight(c->format(), c->column(), c->row());
|
||
|
}
|
||
|
|
||
|
for ( int x = left; x <= right; x++ )
|
||
|
{
|
||
|
Cell *obj = m_sheet->cellAt( x, top );
|
||
|
checkBorderTop(obj->format(),x, top);
|
||
|
obj = m_sheet->cellAt( x, bottom );
|
||
|
checkBorderBottom(obj->format(),x, bottom);
|
||
|
if ( x > left )
|
||
|
{
|
||
|
ColumnFormat *obj = m_sheet->nonDefaultColumnFormat(x);
|
||
|
checkBorderHorizontal(obj,x, y);
|
||
|
checkBorderVertical(obj,x, y);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if ( isRowSelected )
|
||
|
{
|
||
|
int x=1;
|
||
|
for ( int y = top; y <= bottom; y++ )
|
||
|
{
|
||
|
Cell *obj = m_sheet->cellAt( right, y );
|
||
|
checkBorderRight(obj->format(),right,y);
|
||
|
obj = m_sheet->cellAt( left, y );
|
||
|
checkBorderLeft( obj->format(),left, y);
|
||
|
if ( y > top )
|
||
|
{
|
||
|
RowFormat* obj = m_sheet->nonDefaultRowFormat(y);
|
||
|
checkBorderHorizontal(obj,x, y);
|
||
|
checkBorderVertical(obj,x, y);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
RowFormat *obj=m_sheet->nonDefaultRowFormat(top);
|
||
|
checkBorderTop(obj,x, top);
|
||
|
obj=m_sheet->nonDefaultRowFormat(bottom);
|
||
|
checkBorderBottom(obj,x, bottom);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
for ( int y = top; y <= bottom; y++ )
|
||
|
{
|
||
|
Cell *obj = m_sheet->cellAt( left, y );
|
||
|
checkBorderLeft( obj->format(),left, y);
|
||
|
obj = m_sheet->cellAt( right, y );
|
||
|
checkBorderRight(obj->format(),right,y);
|
||
|
}
|
||
|
|
||
|
for ( int x = left; x <= right; x++ )
|
||
|
{
|
||
|
Cell *obj = m_sheet->cellAt( x, top );
|
||
|
checkBorderTop( obj->format(), x, top );
|
||
|
obj = m_sheet->cellAt( x, bottom );
|
||
|
checkBorderBottom( obj->format(), x, bottom );
|
||
|
}
|
||
|
|
||
|
// Look for the Outline
|
||
|
for ( int x = left; x <= right; x++ )
|
||
|
{
|
||
|
for ( int y = top+1; y <= bottom; y++ )
|
||
|
{
|
||
|
Cell *obj = m_sheet->cellAt( x, y );
|
||
|
checkBorderHorizontal(obj->format(),x, y);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
for ( int x = left+1; x <= right; x++ )
|
||
|
{
|
||
|
for ( int y = top; y <= bottom; y++ )
|
||
|
{
|
||
|
Cell *obj = m_sheet->cellAt( x, y );
|
||
|
checkBorderVertical(obj->format(),x,y);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
CellFormatDialog::CellFormatDialog( View * _view, CustomStyle * _style,
|
||
|
StyleManager * _manager, Doc * doc )
|
||
14 years ago
|
: TQObject(),
|
||
15 years ago
|
m_doc( doc ),
|
||
|
m_sheet( 0 ),
|
||
|
m_pView( _view ),
|
||
|
m_style( _style ),
|
||
|
m_styleManager( _manager )
|
||
|
{
|
||
|
initMembers();
|
||
|
initGUI();
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
void CellFormatDialog::initGUI()
|
||
|
{
|
||
|
isRowSelected = false;
|
||
|
isColumnSelected = false;
|
||
|
styleName = m_style->name();
|
||
|
|
||
|
borders[BorderType_Left].style = m_style->leftBorderPen().style();
|
||
|
borders[BorderType_Left].width = m_style->leftBorderPen().width();
|
||
|
borders[BorderType_Left].color = m_style->leftBorderPen().color();
|
||
|
|
||
|
borders[BorderType_Top].style = m_style->topBorderPen().style();
|
||
|
borders[BorderType_Top].width = m_style->topBorderPen().width();
|
||
|
borders[BorderType_Top].color = m_style->topBorderPen().color();
|
||
|
|
||
|
borders[BorderType_Right].style = m_style->rightBorderPen().style();
|
||
|
borders[BorderType_Right].width = m_style->rightBorderPen().width();
|
||
|
borders[BorderType_Right].color = m_style->rightBorderPen().color();
|
||
|
|
||
|
borders[BorderType_Bottom].style = m_style->bottomBorderPen().style();
|
||
|
borders[BorderType_Bottom].width = m_style->bottomBorderPen().width();
|
||
|
borders[BorderType_Bottom].color = m_style->bottomBorderPen().color();
|
||
|
|
||
|
borders[BorderType_FallingDiagonal].style = m_style->fallDiagonalPen().style();
|
||
|
borders[BorderType_FallingDiagonal].width = m_style->fallDiagonalPen().width();
|
||
|
borders[BorderType_FallingDiagonal].color = m_style->fallDiagonalPen().color();
|
||
|
|
||
|
borders[BorderType_RisingDiagonal].style = m_style->goUpDiagonalPen().style();
|
||
|
borders[BorderType_RisingDiagonal].width = m_style->goUpDiagonalPen().width();
|
||
|
borders[BorderType_RisingDiagonal].color = m_style->goUpDiagonalPen().color();
|
||
|
|
||
|
borders[BorderType_Vertical].style = m_style->leftBorderPen().style();
|
||
|
borders[BorderType_Vertical].width = m_style->leftBorderPen().width();
|
||
|
borders[BorderType_Vertical].color = m_style->leftBorderPen().color();
|
||
|
borders[BorderType_Horizontal].style = m_style->topBorderPen().style();
|
||
|
borders[BorderType_Horizontal].width = m_style->topBorderPen().width();
|
||
|
borders[BorderType_Horizontal].color = m_style->topBorderPen().color();
|
||
|
|
||
|
prefix = m_style->prefix();
|
||
|
postfix = m_style->postfix();
|
||
|
precision = m_style->precision();
|
||
|
floatFormat = m_style->floatFormat();
|
||
|
floatColor = m_style->floatColor();
|
||
|
alignX = m_style->alignX();
|
||
|
alignY = m_style->alignY();
|
||
|
textColor = m_style->pen().color();
|
||
|
bgColor = m_style->bgColor();
|
||
|
textFontSize = m_style->fontSize();
|
||
|
textFontFamily = m_style->fontFamily();
|
||
|
|
||
|
uint flags = m_style->fontFlags();
|
||
|
textFontBold = ( flags & (uint) Style::FBold );
|
||
|
textFontItalic = ( flags & (uint) Style::FItalic );
|
||
|
strike = ( flags & (uint) Style::FStrike );
|
||
|
underline = ( flags & (uint) Style::FUnderline );
|
||
|
|
||
14 years ago
|
// Needed to initialize the font correctly ( bug in TQt )
|
||
15 years ago
|
textFont = m_style->font();
|
||
|
cCurrency = m_style->currency();
|
||
|
brushColor = m_style->backGroundBrush().color();
|
||
|
brushStyle = m_style->backGroundBrush().style();
|
||
|
|
||
|
bMultiRow = m_style->hasProperty( Style::PMultiRow );
|
||
|
bVerticalText = m_style->hasProperty( Style::PVerticalText );
|
||
|
textRotation = m_style->rotateAngle();
|
||
|
formatType = m_style->formatType();
|
||
|
indent = m_style->indent();
|
||
|
|
||
|
bDontPrintText = m_style->hasProperty( Style::PDontPrintText );
|
||
|
bHideFormula = m_style->hasProperty( Style::PHideFormula );
|
||
|
bHideAll = m_style->hasProperty( Style::PHideAll );
|
||
|
bIsProtected = !m_style->hasProperty( Style::PNotProtected );
|
||
|
|
||
|
widthSize = defaultWidthSize;
|
||
|
heightSize = defaultHeightSize;
|
||
|
}
|
||
|
|
||
|
CellFormatDialog::~CellFormatDialog()
|
||
|
{
|
||
|
delete formatOnlyNegSignedPixmap;
|
||
|
delete formatRedOnlyNegSignedPixmap;
|
||
|
delete formatRedNeverSignedPixmap;
|
||
|
delete formatAlwaysSignedPixmap;
|
||
|
delete formatRedAlwaysSignedPixmap;
|
||
|
}
|
||
|
|
||
|
void CellFormatDialog::initMembers()
|
||
|
{
|
||
|
formatOnlyNegSignedPixmap = 0L;
|
||
|
formatRedOnlyNegSignedPixmap = 0L;
|
||
|
formatRedNeverSignedPixmap = 0L;
|
||
|
formatAlwaysSignedPixmap = 0L;
|
||
|
formatRedAlwaysSignedPixmap = 0L;
|
||
|
|
||
|
// We assume, that all other objects have the same values
|
||
|
for ( int i = 0; i < BorderType_END; ++i )
|
||
|
{
|
||
|
borders[i].bStyle = true;
|
||
|
borders[i].bColor = true;
|
||
|
}
|
||
|
bFloatFormat = true;
|
||
|
bFloatColor = true;
|
||
|
bTextColor = true;
|
||
|
bBgColor = true;
|
||
|
bTextFontFamily = true;
|
||
|
bTextFontSize = true;
|
||
|
bTextFontBold = true;
|
||
|
bTextFontItalic = true;
|
||
|
bStrike = true;
|
||
|
bUnderline = true;
|
||
|
bTextRotation = true;
|
||
|
bFormatType = true;
|
||
|
bCurrency = true;
|
||
|
bDontPrintText = false;
|
||
|
bHideFormula = false;
|
||
|
bHideAll = false;
|
||
|
bIsProtected = true;
|
||
|
|
||
|
cCurrency.symbol = locale()->currencySymbol();
|
||
|
cCurrency.type = 0;
|
||
|
|
||
|
Sheet* sheet = m_pView->activeSheet();
|
||
|
defaultWidthSize = sheet ? sheet->columnFormat(0)->dblWidth() : 0;
|
||
|
defaultHeightSize = sheet ? sheet->rowFormat(0)->dblHeight() : 0;
|
||
|
}
|
||
|
|
||
13 years ago
|
bool CellFormatDialog::checkCircle( TQString const & name, TQString const & parent )
|
||
15 years ago
|
{
|
||
13 years ago
|
return m_styleManager->checkCircle( name, parent );
|
||
15 years ago
|
}
|
||
|
|
||
|
void CellFormatDialog::checkBorderRight(Format *obj,int x,int y)
|
||
|
{
|
||
|
if ( borders[BorderType_Right].style != obj->rightBorderStyle( x, y ) ||
|
||
|
borders[BorderType_Right].width != obj->rightBorderWidth( x, y ) )
|
||
|
borders[BorderType_Right].bStyle = false;
|
||
|
if ( borders[BorderType_Right].color != obj->rightBorderColor( x, y ) )
|
||
|
borders[BorderType_Right].bColor = false;
|
||
|
}
|
||
|
|
||
|
void CellFormatDialog::checkBorderLeft(Format *obj,int x,int y)
|
||
|
{
|
||
|
if ( borders[BorderType_Left].style != obj->leftBorderStyle( x, y ) ||
|
||
|
borders[BorderType_Left].width != obj->leftBorderWidth( x, y ) )
|
||
|
borders[BorderType_Left].bStyle = false;
|
||
|
if ( borders[BorderType_Left].color != obj->leftBorderColor( x, y ) )
|
||
|
borders[BorderType_Left].bColor = false;
|
||
|
}
|
||
|
|
||
|
void CellFormatDialog::checkBorderTop(Format *obj,int x,int y)
|
||
|
{
|
||
|
if ( borders[BorderType_Top].style != obj->topBorderStyle( x, y ) ||
|
||
|
borders[BorderType_Top].width != obj->topBorderWidth( x, y ) )
|
||
|
borders[BorderType_Top].bStyle = false;
|
||
|
if ( borders[BorderType_Top].color != obj->topBorderColor( x, y ) )
|
||
|
borders[BorderType_Top].bColor = false;
|
||
|
}
|
||
|
|
||
|
void CellFormatDialog::checkBorderBottom(Format *obj,int x,int y)
|
||
|
{
|
||
|
if ( borders[BorderType_Bottom].style != obj->bottomBorderStyle( x, y ) ||
|
||
|
borders[BorderType_Bottom].width != obj->bottomBorderWidth( x, y ) )
|
||
|
borders[BorderType_Bottom].bStyle = false;
|
||
|
if ( borders[BorderType_Bottom].color != obj->bottomBorderColor( x, y ) )
|
||
|
borders[BorderType_Bottom].bColor = false;
|
||
|
}
|
||
|
|
||
|
void CellFormatDialog::checkBorderVertical(Format *obj,int x,int y)
|
||
|
{
|
||
|
if (borders[BorderType_Vertical].style != obj->leftBorderStyle( x, y ) ||
|
||
|
borders[BorderType_Vertical].width != obj->leftBorderWidth( x, y ))
|
||
|
borders[BorderType_Vertical].bStyle = false;
|
||
|
if ( borders[BorderType_Vertical].color != obj->leftBorderColor( x, y ) )
|
||
|
borders[BorderType_Vertical].bColor = false;
|
||
|
}
|
||
|
|
||
|
void CellFormatDialog::checkBorderHorizontal(Format *obj,int x,int y)
|
||
|
{
|
||
|
if ( borders[BorderType_Horizontal].style != obj->topBorderStyle( x, y ) ||
|
||
|
borders[BorderType_Horizontal].width != obj->topBorderWidth( x, y ) )
|
||
|
borders[BorderType_Horizontal].bStyle = false;
|
||
|
if ( borders[BorderType_Horizontal].color != obj->topBorderColor( x, y ) )
|
||
|
borders[BorderType_Horizontal].bColor = false;
|
||
|
}
|
||
|
|
||
|
|
||
|
void CellFormatDialog::initParameters(Format *obj,int x,int y)
|
||
|
{
|
||
|
if (borders[BorderType_FallingDiagonal].style != obj->fallDiagonalStyle( x, y ))
|
||
|
borders[BorderType_FallingDiagonal].bStyle = false;
|
||
|
if (borders[BorderType_FallingDiagonal].width != obj->fallDiagonalWidth( x, y ))
|
||
|
borders[BorderType_FallingDiagonal].bStyle = false;
|
||
|
if (borders[BorderType_FallingDiagonal].color != obj->fallDiagonalColor( x, y ))
|
||
|
borders[BorderType_FallingDiagonal].bColor = false;
|
||
|
|
||
|
if (borders[BorderType_RisingDiagonal].style != obj->goUpDiagonalStyle( x, y ))
|
||
|
borders[BorderType_RisingDiagonal].bStyle = false;
|
||
|
if (borders[BorderType_RisingDiagonal].width != obj->goUpDiagonalWidth( x, y ))
|
||
|
borders[BorderType_RisingDiagonal].bStyle = false;
|
||
|
if (borders[BorderType_RisingDiagonal].color != obj->goUpDiagonalColor( x, y ))
|
||
|
borders[BorderType_RisingDiagonal].bColor = false;
|
||
|
if ( strike != obj->textFontStrike( x, y ) )
|
||
|
bStrike = false;
|
||
|
if ( underline != obj->textFontUnderline( x, y ) )
|
||
|
bUnderline = false;
|
||
|
if ( prefix != obj->prefix( x, y ) )
|
||
14 years ago
|
prefix = TQString();
|
||
15 years ago
|
if ( postfix != obj->postfix( x, y ) )
|
||
14 years ago
|
postfix = TQString();
|
||
15 years ago
|
if ( floatFormat != obj->floatFormat( x, y ) )
|
||
|
bFloatFormat = false;
|
||
|
if ( floatColor != obj->floatColor( x, y ) )
|
||
|
bFloatColor = false;
|
||
|
if ( textColor != obj->textColor( x, y ) )
|
||
|
bTextColor = false;
|
||
|
if ( textFontFamily != obj->textFontFamily( x, y ) )
|
||
|
bTextFontFamily = false;
|
||
|
if ( textFontSize != obj->textFontSize( x, y ) )
|
||
|
bTextFontSize = false;
|
||
|
if ( textFontBold != obj->textFontBold( x, y ) )
|
||
|
bTextFontBold = false;
|
||
|
if ( textFontItalic != obj->textFontItalic( x, y ) )
|
||
|
bTextFontItalic = false;
|
||
|
if ( bgColor != obj->bgColor( x, y ) )
|
||
|
bBgColor = false;
|
||
|
if ( textRotation != obj->getAngle(left, top) )
|
||
|
bTextRotation = false;
|
||
|
if ( formatType != obj->getFormatType(left, top) )
|
||
|
bFormatType = false;
|
||
|
if ( bMultiRow != obj->multiRow( left, top ) )
|
||
|
bMultiRow = false;
|
||
|
if ( bVerticalText!=obj->verticalText( left, top ) )
|
||
|
bVerticalText = false;
|
||
|
if ( bDontPrintText!=obj->getDontprintText( left, top ) )
|
||
|
bDontPrintText= false;
|
||
|
|
||
|
Format::Currency cur;
|
||
|
if (!obj->currencyInfo(cur))
|
||
|
bCurrency = false;
|
||
|
else
|
||
|
if (cur.symbol != cCurrency.symbol)
|
||
|
bCurrency = false;
|
||
|
}
|
||
|
|
||
|
void CellFormatDialog::init()
|
||
|
{
|
||
13 years ago
|
TQColorGroup colorGroup = TQApplication::palette().active();
|
||
15 years ago
|
|
||
|
// Did we initialize the bitmaps ?
|
||
|
if ( formatOnlyNegSignedPixmap == 0L )
|
||
|
{
|
||
13 years ago
|
TQColor black = colorGroup.text(); // not necessarily black :)
|
||
15 years ago
|
formatOnlyNegSignedPixmap = paintFormatPixmap( "123.456", black, "-123.456", black );
|
||
14 years ago
|
formatRedOnlyNegSignedPixmap = paintFormatPixmap( "123.456", black, "-123.456", TQt::red );
|
||
|
formatRedNeverSignedPixmap = paintFormatPixmap( "123.456", black, "123.456", TQt::red );
|
||
15 years ago
|
formatAlwaysSignedPixmap = paintFormatPixmap( "+123.456", black, "-123.456", black );
|
||
14 years ago
|
formatRedAlwaysSignedPixmap = paintFormatPixmap( "+123.456", black, "-123.456", TQt::red );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
tab = new TQTabDialog( (TQWidget*)m_pView, 0L, true );
|
||
15 years ago
|
//tab->setGeometry( tab->x(), tab->y(), 420, 400 );
|
||
|
|
||
|
if ( m_style )
|
||
|
{
|
||
|
generalPage = new GeneralTab( tab, this );
|
||
|
tab->addTab( generalPage, i18n( "&General" ) );
|
||
|
}
|
||
|
|
||
|
floatPage = new CellFormatPageFloat( tab, this );
|
||
|
tab->addTab( floatPage, i18n("&Data Format") );
|
||
|
|
||
|
fontPage = new CellFormatPageFont( tab, this );
|
||
|
tab->addTab( fontPage, i18n("&Font") );
|
||
|
|
||
|
// miscPage = new CellFormatPageMisc( tab, this );
|
||
|
// tab->addTab( miscPage, i18n("&Misc") );
|
||
|
|
||
|
positionPage = new CellFormatPagePosition( tab, this);
|
||
|
tab->addTab( positionPage, i18n("&Position") );
|
||
|
|
||
|
borderPage = new CellFormatPageBorder( tab, this );
|
||
|
tab->addTab( borderPage, i18n("&Border") );
|
||
|
|
||
|
patternPage=new CellFormatPagePattern(tab,this);
|
||
|
tab->addTab( patternPage,i18n("Back&ground"));
|
||
|
|
||
|
protectPage = new CellFormatPageProtection( tab, this );
|
||
|
tab->addTab( protectPage, i18n("&Cell Protection") );
|
||
|
|
||
|
tab->setCancelButton( i18n( "&Cancel" ) );
|
||
|
tab->setOkButton( i18n( "&OK" ) );
|
||
|
|
||
|
tab->setCaption( i18n( "Cell Format" ) );
|
||
|
|
||
|
tab->adjustSize();
|
||
|
|
||
14 years ago
|
connect( tab, TQT_SIGNAL( applyButtonPressed() ), this, TQT_SLOT( slotApply() ) );
|
||
15 years ago
|
|
||
|
tab->exec();
|
||
|
}
|
||
|
|
||
14 years ago
|
TQPixmap * CellFormatDialog::paintFormatPixmap( const char * _string1, const TQColor & _color1,
|
||
|
const char *_string2, const TQColor & _color2 )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQPixmap * pixmap = new TQPixmap( 150, 14 );
|
||
15 years ago
|
|
||
14 years ago
|
TQPainter painter;
|
||
15 years ago
|
painter.begin( pixmap );
|
||
13 years ago
|
painter.fillRect( 0, 0, 150, 14, TQApplication::palette().active().base() );
|
||
15 years ago
|
painter.setPen( _color1 );
|
||
14 years ago
|
painter.drawText( 2, 11, TQString(_string1) );
|
||
15 years ago
|
painter.setPen( _color2 );
|
||
14 years ago
|
painter.drawText( 75, 11, TQString(_string2) );
|
||
15 years ago
|
painter.end();
|
||
|
|
||
14 years ago
|
TQBitmap bm( pixmap->size() );
|
||
15 years ago
|
bm.fill( color0 );
|
||
|
painter.begin( &bm );
|
||
|
painter.setPen( color1 );
|
||
14 years ago
|
painter.drawText( 2, 11, TQString(_string1) );
|
||
|
painter.drawText( 75, 11, TQString(_string2) );
|
||
15 years ago
|
painter.end();
|
||
|
pixmap->setMask( bm );
|
||
|
|
||
|
return pixmap;
|
||
|
}
|
||
|
|
||
|
int CellFormatDialog::exec()
|
||
|
{
|
||
|
return ( tab->exec() );
|
||
|
}
|
||
|
|
||
|
void CellFormatDialog::applyStyle()
|
||
|
{
|
||
|
generalPage->apply( m_style );
|
||
|
|
||
|
borderPage->apply(0);
|
||
|
floatPage->apply( m_style );
|
||
|
// miscPage->apply( m_style );
|
||
|
fontPage->apply( m_style );
|
||
|
positionPage->apply( m_style );
|
||
|
patternPage->apply( m_style );
|
||
|
protectPage->apply( m_style );
|
||
|
m_pView->refreshView();
|
||
|
}
|
||
|
|
||
|
void CellFormatDialog::slotApply()
|
||
|
{
|
||
|
if ( m_style )
|
||
|
{
|
||
|
applyStyle();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// (Tomas) TODO: this will be slow !!!
|
||
|
// We need to create a manipulator that would act as KMacroCommand,
|
||
|
// but which would also ensure that updates are not painted until everything
|
||
|
// is updated properly ...
|
||
|
KMacroCommand* macroCommand = new KMacroCommand( i18n("Change Format") );
|
||
|
|
||
|
if ( isMerged != positionPage->getMergedCellState() )
|
||
|
{
|
||
|
if ( positionPage->getMergedCellState() )
|
||
|
{
|
||
|
Manipulator* manipulator = new MergeManipulator();
|
||
|
manipulator->setSheet(m_pView->activeSheet());
|
||
|
manipulator->setRegisterUndo(false);
|
||
|
manipulator->add(*m_pView->selectionInfo());
|
||
|
macroCommand->addCommand( manipulator );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//dissociate cells
|
||
|
Manipulator* manipulator = new MergeManipulator();
|
||
|
manipulator->setSheet(m_pView->activeSheet());
|
||
|
manipulator->setReverse(true);
|
||
|
manipulator->setRegisterUndo(false);
|
||
|
manipulator->add(*m_pView->selectionInfo());
|
||
|
macroCommand->addCommand( manipulator );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
FormatManipulator* manipulator = new FormatManipulator();
|
||
|
manipulator->setSheet(m_pView->activeSheet());
|
||
|
manipulator->setRegisterUndo(false);
|
||
|
manipulator->add(*m_pView->selectionInfo());
|
||
|
borderPage->apply(manipulator);
|
||
|
floatPage->apply(manipulator);
|
||
|
fontPage->apply(manipulator);
|
||
|
positionPage->apply(manipulator);
|
||
|
patternPage->apply(manipulator);
|
||
|
protectPage->apply(manipulator);
|
||
|
|
||
|
if (!manipulator->isEmpty())
|
||
|
{
|
||
|
macroCommand->addCommand( manipulator );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
delete manipulator;
|
||
|
}
|
||
|
|
||
|
if ( int( positionPage->getSizeHeight() ) != int( heightSize ) )
|
||
|
{
|
||
|
ResizeRowManipulator* manipulator = new ResizeRowManipulator();
|
||
|
manipulator->setSheet(m_pView->activeSheet());
|
||
|
manipulator->setSize(positionPage->getSizeHeight());
|
||
|
// TODO Stefan:
|
||
|
manipulator->setOldSize(heightSize);
|
||
|
manipulator->add(*m_pView->selectionInfo());
|
||
|
macroCommand->addCommand( manipulator );
|
||
|
}
|
||
|
if ( int( positionPage->getSizeWidth() ) != int( widthSize ) )
|
||
|
{
|
||
|
ResizeColumnManipulator* manipulator = new ResizeColumnManipulator();
|
||
|
manipulator->setSheet(m_pView->activeSheet());
|
||
|
manipulator->setSize(positionPage->getSizeWidth());
|
||
|
// TODO Stefan:
|
||
|
manipulator->setOldSize(widthSize);
|
||
|
manipulator->add(*m_pView->selectionInfo());
|
||
|
macroCommand->addCommand( manipulator );
|
||
|
}
|
||
|
|
||
|
macroCommand->execute();
|
||
|
m_doc->addCommand( macroCommand );
|
||
|
|
||
|
// Update the toolbar (bold/italic/font...)
|
||
|
m_pView->updateEditWidget();
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
*
|
||
|
* CellFormatPageFloat
|
||
|
*
|
||
|
***************************************************************************/
|
||
|
|
||
13 years ago
|
CellFormatPageFloat::CellFormatPageFloat( TQWidget* parent, CellFormatDialog *_dlg )
|
||
|
: TQWidget ( parent ),
|
||
15 years ago
|
dlg( _dlg )
|
||
|
{
|
||
13 years ago
|
TQVBoxLayout* layout = new TQVBoxLayout( this, 6,10 );
|
||
15 years ago
|
|
||
14 years ago
|
TQButtonGroup *grp = new TQButtonGroup( i18n("Format"),this);
|
||
|
TQGridLayout *grid = new TQGridLayout(grp,11,2,KDialog::marginHint(), KDialog::spacingHint());
|
||
15 years ago
|
|
||
|
int fHeight = grp->fontMetrics().height();
|
||
|
grid->addRowSpacing( 0, fHeight/2 ); // groupbox title
|
||
|
|
||
|
grp->setRadioButtonExclusive( true );
|
||
14 years ago
|
generic=new TQRadioButton(i18n("Generic"),grp);
|
||
|
TQWhatsThis::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." ) );
|
||
15 years ago
|
grid->addWidget(generic,1,0);
|
||
|
|
||
14 years ago
|
number=new TQRadioButton(i18n("Number"),grp);
|
||
|
TQWhatsThis::add(number, i18n( "The number notation uses the notation you globally choose in KControl -> Regional & Accessibility -> Numbers tab. Numbers are right justified by default." ) );
|
||
15 years ago
|
grid->addWidget(number,2,0);
|
||
|
|
||
14 years ago
|
percent=new TQRadioButton(i18n("Percent"),grp);
|
||
|
TQWhatsThis::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." ) );
|
||
15 years ago
|
grid->addWidget(percent,3,0);
|
||
|
|
||
14 years ago
|
money=new TQRadioButton(i18n("Money"),grp);
|
||
|
TQWhatsThis::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." ) );
|
||
15 years ago
|
grid->addWidget(money,4,0);
|
||
|
|
||
14 years ago
|
scientific=new TQRadioButton(i18n("Scientific"),grp);
|
||
|
TQWhatsThis::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." ) );
|
||
15 years ago
|
grid->addWidget(scientific,5,0);
|
||
|
|
||
14 years ago
|
fraction=new TQRadioButton(i18n("Fraction"),grp);
|
||
|
TQWhatsThis::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." ) );
|
||
15 years ago
|
grid->addWidget(fraction,6,0);
|
||
|
|
||
14 years ago
|
date=new TQRadioButton(i18n("Date format"),grp);
|
||
|
TQWhatsThis::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." ) );
|
||
15 years ago
|
grid->addWidget(date,7,0);
|
||
|
|
||
14 years ago
|
time=new TQRadioButton(i18n("Time format"),grp);
|
||
|
TQWhatsThis::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." ) );
|
||
15 years ago
|
grid->addWidget(time,8,0);
|
||
|
|
||
14 years ago
|
textFormat=new TQRadioButton(i18n("Text"),grp);
|
||
|
TQWhatsThis::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." ) );
|
||
15 years ago
|
grid->addWidget(textFormat,9,0);
|
||
|
|
||
14 years ago
|
customFormat=new TQRadioButton(i18n("Custom"),grp);
|
||
|
TQWhatsThis::add(customFormat, i18n( "The custom format does not work yet. To be enabled in the next release." ) );
|
||
15 years ago
|
grid->addWidget(customFormat,10,0);
|
||
|
customFormat->setEnabled( false );
|
||
|
|
||
14 years ago
|
TQGroupBox *box2 = new TQGroupBox( grp, "Box");
|
||
15 years ago
|
box2->setTitle(i18n("Preview"));
|
||
14 years ago
|
TQGridLayout *grid3 = new TQGridLayout(box2,1,3,KDialog::marginHint(), KDialog::spacingHint());
|
||
15 years ago
|
|
||
14 years ago
|
exampleLabel=new TQLabel(box2);
|
||
|
TQWhatsThis::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." ) );
|
||
15 years ago
|
grid3->addWidget(exampleLabel,0,1);
|
||
|
|
||
|
grid->addMultiCellWidget(box2,9,10,1,1);
|
||
|
|
||
14 years ago
|
customFormatEdit = new TQLineEdit( grp );
|
||
15 years ago
|
grid->addMultiCellWidget( customFormatEdit, 1, 1, 1, 1 );
|
||
|
customFormatEdit->setHidden( true );
|
||
|
|
||
14 years ago
|
listFormat=new TQListBox(grp);
|
||
15 years ago
|
grid->addMultiCellWidget(listFormat,2,7,1,1);
|
||
14 years ago
|
TQWhatsThis::add(listFormat, i18n( "Displays choices of format for the fraction, date or time formats." ) );
|
||
13 years ago
|
layout->addWidget(grp);
|
||
15 years ago
|
|
||
|
/* *** */
|
||
|
|
||
14 years ago
|
TQGroupBox *box = new TQGroupBox( this, "Box");
|
||
15 years ago
|
|
||
14 years ago
|
grid = new TQGridLayout(box,3,4,KDialog::marginHint(), KDialog::spacingHint());
|
||
15 years ago
|
|
||
14 years ago
|
postfix = new TQLineEdit( box, "LineEdit_1" );
|
||
|
TQWhatsThis::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." ) );
|
||
15 years ago
|
grid->addWidget(postfix,2,1);
|
||
|
precision = new KIntNumInput( dlg->precision, box, 10 );
|
||
|
precision->setSpecialValueText(i18n("variable"));
|
||
|
precision->setRange(-1,10,1,false);
|
||
14 years ago
|
TQWhatsThis::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. " ) );
|
||
15 years ago
|
grid->addWidget(precision,1,1);
|
||
|
|
||
14 years ago
|
prefix = new TQLineEdit( box, "LineEdit_3" );
|
||
|
TQWhatsThis::add(prefix, i18n( "You can add here a Prefix such as a $ symbol at the start of each cell content in the checked format." ) );
|
||
15 years ago
|
grid->addWidget(prefix,0,1);
|
||
|
|
||
14 years ago
|
format = new TQComboBox( box, "ListBox_1" );
|
||
|
TQWhatsThis::add(format, i18n( "You can choose whether positive values are displayed with a leading + sign and whether negative values are shown in red." ) );
|
||
15 years ago
|
grid->addWidget(format,0,3);
|
||
|
|
||
14 years ago
|
TQLabel* tmpTQLabel;
|
||
|
tmpTQLabel = new TQLabel( box, "Label_1" );
|
||
|
grid->addWidget(tmpTQLabel,2,0);
|
||
|
tmpTQLabel->setText( i18n("Postfix:") );
|
||
15 years ago
|
|
||
|
postfix->setText( dlg->postfix );
|
||
|
|
||
14 years ago
|
tmpTQLabel = new TQLabel( box, "Label_2" );
|
||
|
grid->addWidget(tmpTQLabel,0,0);
|
||
15 years ago
|
|
||
14 years ago
|
tmpTQLabel->setText( i18n("Prefix:") );
|
||
|
tmpTQLabel = new TQLabel( box, "Label_3" );
|
||
|
grid->addWidget(tmpTQLabel,1,0);
|
||
|
tmpTQLabel->setText( i18n("Precision:") );
|
||
15 years ago
|
|
||
|
prefix->setText( dlg->prefix );
|
||
|
|
||
|
format->insertItem( *_dlg->formatOnlyNegSignedPixmap, 0 );
|
||
|
format->insertItem( *_dlg->formatRedOnlyNegSignedPixmap, 1 );
|
||
|
format->insertItem( *_dlg->formatRedNeverSignedPixmap, 2 );
|
||
|
format->insertItem( *_dlg->formatAlwaysSignedPixmap, 3 );
|
||
|
format->insertItem( *_dlg->formatRedAlwaysSignedPixmap, 4 );
|
||
|
|
||
14 years ago
|
tmpTQLabel = new TQLabel( box, "Label_4" );
|
||
|
grid->addWidget(tmpTQLabel, 0, 2);
|
||
|
tmpTQLabel->setText( i18n("Format:") );
|
||
15 years ago
|
|
||
14 years ago
|
currencyLabel = new TQLabel( box, "LabelCurrency" );
|
||
15 years ago
|
grid->addWidget(currencyLabel, 1, 2);
|
||
|
currencyLabel->setText( i18n("Currency:") );
|
||
|
|
||
14 years ago
|
currency = new TQComboBox( box, "ComboCurrency" );
|
||
15 years ago
|
grid->addWidget(currency, 1, 3);
|
||
|
|
||
|
currency->insertItem( i18n("Automatic") );
|
||
|
|
||
|
int index = 2; //ignore first two in the list
|
||
|
bool ok = true;
|
||
14 years ago
|
TQString text;
|
||
15 years ago
|
|
||
|
while ( ok )
|
||
|
{
|
||
|
text = Currency::getChooseString( index, ok );
|
||
|
if ( ok )
|
||
|
{
|
||
|
currency->insertItem( text );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
++index;
|
||
|
}
|
||
|
|
||
|
currency->setCurrentItem( 0 );
|
||
|
currency->hide();
|
||
|
currencyLabel->hide();
|
||
|
|
||
|
if ( !dlg->bFloatFormat || !dlg->bFloatColor )
|
||
|
format->setCurrentItem( 5 );
|
||
|
else if ( dlg->floatFormat == Format::OnlyNegSigned && dlg->floatColor == Format::AllBlack )
|
||
|
format->setCurrentItem( 0 );
|
||
|
else if ( dlg->floatFormat == Format::OnlyNegSigned && dlg->floatColor == Format::NegRed )
|
||
|
format->setCurrentItem( 1 );
|
||
|
else if ( dlg->floatFormat == Format::AlwaysUnsigned && dlg->floatColor == Format::NegRed )
|
||
|
format->setCurrentItem( 2 );
|
||
|
else if ( dlg->floatFormat == Format::AlwaysSigned && dlg->floatColor == Format::AllBlack )
|
||
|
format->setCurrentItem( 3 );
|
||
|
else if ( dlg->floatFormat == Format::AlwaysSigned && dlg->floatColor == Format::NegRed )
|
||
|
format->setCurrentItem( 4 );
|
||
13 years ago
|
layout->addWidget(box);
|
||
15 years ago
|
|
||
|
cellFormatType=dlg->formatType;
|
||
|
newFormatType = cellFormatType;
|
||
|
|
||
|
if (!cellFormatType)
|
||
|
generic->setChecked(true);
|
||
|
else
|
||
|
{
|
||
|
if (cellFormatType==Number_format)
|
||
|
number->setChecked(true);
|
||
|
else if (cellFormatType==Percentage_format)
|
||
|
percent->setChecked(true);
|
||
|
else if (cellFormatType==Money_format)
|
||
|
{
|
||
|
money->setChecked(true);
|
||
|
currencyLabel->show();
|
||
|
currency->show();
|
||
|
if (dlg->bCurrency)
|
||
|
{
|
||
14 years ago
|
TQString tmp;
|
||
15 years ago
|
if (dlg->cCurrency.type != 1)
|
||
|
{
|
||
|
Currency curr(dlg->cCurrency.type);
|
||
|
bool ok = true;
|
||
|
tmp = Currency::getChooseString(dlg->cCurrency.type, ok);
|
||
|
if ( !ok )
|
||
|
tmp = dlg->cCurrency.symbol;
|
||
|
}
|
||
|
else
|
||
|
tmp = dlg->cCurrency.symbol;
|
||
|
currency->setCurrentText( tmp );
|
||
|
}
|
||
|
}
|
||
|
else if ( cellFormatType == Scientific_format )
|
||
|
scientific->setChecked(true);
|
||
|
else if ( formatIsDate (cellFormatType) )
|
||
|
date->setChecked(true);
|
||
|
else if ( formatIsTime (cellFormatType) )
|
||
|
time->setChecked(true);
|
||
|
else if ( formatIsFraction (cellFormatType) )
|
||
|
fraction->setChecked(true);
|
||
|
else if (cellFormatType == Text_format)
|
||
|
textFormat->setChecked(true);
|
||
|
else if (cellFormatType == Custom_format)
|
||
|
customFormat->setChecked(true);
|
||
|
}
|
||
|
|
||
14 years ago
|
connect(generic,TQT_SIGNAL(clicked ()),this,TQT_SLOT(slotChangeState()));
|
||
|
connect(fraction,TQT_SIGNAL(clicked ()),this,TQT_SLOT(slotChangeState()));
|
||
|
connect(money,TQT_SIGNAL(clicked ()),this,TQT_SLOT(slotChangeState()));
|
||
|
connect(date,TQT_SIGNAL(clicked ()),this,TQT_SLOT(slotChangeState()));
|
||
|
connect(scientific,TQT_SIGNAL(clicked ()),this,TQT_SLOT(slotChangeState()));
|
||
|
connect(number,TQT_SIGNAL(clicked ()),this,TQT_SLOT(slotChangeState()));
|
||
|
connect(percent,TQT_SIGNAL(clicked ()),this,TQT_SLOT(slotChangeState()));
|
||
|
connect(time,TQT_SIGNAL(clicked ()),this,TQT_SLOT(slotChangeState()));
|
||
|
connect(textFormat,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotChangeState()));
|
||
|
connect(customFormat,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotChangeState()));
|
||
|
|
||
|
connect(listFormat,TQT_SIGNAL(selectionChanged ()),this,TQT_SLOT(makeformat()));
|
||
|
connect(precision,TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(slotChangeValue(int)));
|
||
|
connect(prefix,TQT_SIGNAL(textChanged ( const TQString & ) ),this,TQT_SLOT(makeformat()));
|
||
|
connect(postfix,TQT_SIGNAL(textChanged ( const TQString & ) ),this,TQT_SLOT(makeformat()));
|
||
|
connect(currency,TQT_SIGNAL(activated ( const TQString & ) ),this, TQT_SLOT(currencyChanged(const TQString &)));
|
||
|
connect(format,TQT_SIGNAL(activated ( int ) ),this,TQT_SLOT(formatChanged(int)));
|
||
|
connect(format, TQT_SIGNAL(activated(int)), this, TQT_SLOT(makeformat()));
|
||
15 years ago
|
slotChangeState();
|
||
|
m_bFormatColorChanged=false;
|
||
|
m_bFormatTypeChanged=false;
|
||
|
this->resize( 400, 400 );
|
||
|
}
|
||
|
|
||
|
void CellFormatPageFloat::formatChanged(int)
|
||
|
{
|
||
|
m_bFormatColorChanged=true;
|
||
|
}
|
||
|
|
||
|
void CellFormatPageFloat::slotChangeValue(int)
|
||
|
{
|
||
|
makeformat();
|
||
|
}
|
||
|
void CellFormatPageFloat::slotChangeState()
|
||
|
{
|
||
14 years ago
|
TQStringList list;
|
||
15 years ago
|
listFormat->clear();
|
||
|
currency->hide();
|
||
|
currencyLabel->hide();
|
||
|
|
||
|
// start with enabled, they get disabled when inappropriate further down
|
||
|
precision->setEnabled(true);
|
||
|
prefix->setEnabled(true);
|
||
|
postfix->setEnabled(true);
|
||
|
format->setEnabled(true);
|
||
|
|
||
|
if (generic->isChecked() || number->isChecked() || percent->isChecked() ||
|
||
|
scientific->isChecked() || textFormat->isChecked())
|
||
|
listFormat->setEnabled(false);
|
||
|
else if (money->isChecked())
|
||
|
{
|
||
|
listFormat->setEnabled(false);
|
||
|
precision->setValue(2);
|
||
|
currency->show();
|
||
|
currencyLabel->show();
|
||
|
}
|
||
|
else if (date->isChecked())
|
||
|
{
|
||
|
format->setEnabled(false);
|
||
|
precision->setEnabled(false);
|
||
|
prefix->setEnabled(false);
|
||
|
postfix->setEnabled(false);
|
||
|
listFormat->setEnabled(true);
|
||
|
init();
|
||
|
}
|
||
|
else if (fraction->isChecked())
|
||
|
{
|
||
|
precision->setEnabled(false);
|
||
|
listFormat->setEnabled(true);
|
||
|
list+=i18n("Halves 1/2");
|
||
|
list+=i18n("Quarters 1/4");
|
||
|
list+=i18n("Eighths 1/8");
|
||
|
list+=i18n("Sixteenths 1/16");
|
||
|
list+=i18n("Tenths 1/10");
|
||
|
list+=i18n("Hundredths 1/100");
|
||
|
list+=i18n("One digit 5/9");
|
||
|
list+=i18n("Two digits 15/22");
|
||
|
list+=i18n("Three digits 153/652");
|
||
|
listFormat->insertStringList(list);
|
||
|
if (cellFormatType == fraction_half)
|
||
|
listFormat->setCurrentItem(0);
|
||
|
else if (cellFormatType == fraction_quarter)
|
||
|
listFormat->setCurrentItem(1);
|
||
|
else if (cellFormatType == fraction_eighth )
|
||
|
listFormat->setCurrentItem(2);
|
||
|
else if (cellFormatType == fraction_sixteenth )
|
||
|
listFormat->setCurrentItem(3);
|
||
|
else if (cellFormatType == fraction_tenth )
|
||
|
listFormat->setCurrentItem(4);
|
||
|
else if (cellFormatType == fraction_hundredth )
|
||
|
listFormat->setCurrentItem(5);
|
||
|
else if (cellFormatType == fraction_one_digit )
|
||
|
listFormat->setCurrentItem(6);
|
||
|
else if (cellFormatType == fraction_two_digits )
|
||
|
listFormat->setCurrentItem(7);
|
||
|
else if (cellFormatType == fraction_three_digits )
|
||
|
listFormat->setCurrentItem(8);
|
||
|
else
|
||
|
listFormat->setCurrentItem(0);
|
||
|
}
|
||
|
else if (time->isChecked())
|
||
|
{
|
||
|
precision->setEnabled(false);
|
||
|
prefix->setEnabled(false);
|
||
|
postfix->setEnabled(false);
|
||
|
format->setEnabled(false);
|
||
|
listFormat->setEnabled(true);
|
||
|
|
||
|
|
||
14 years ago
|
list+=i18n("System: ")+dlg->locale()->formatTime(TQTime::currentTime(),false);
|
||
|
list+=i18n("System: ")+dlg->locale()->formatTime(TQTime::currentTime(),true);
|
||
|
TQDateTime tmpTime (TQDate (1, 1, 1900), TQTime (10, 35, 25));
|
||
15 years ago
|
|
||
|
|
||
|
ValueFormatter *fmt = dlg->getDoc()->formatter();
|
||
|
list+= fmt->timeFormat(tmpTime, Time_format1);
|
||
|
list+= fmt->timeFormat(tmpTime, Time_format2);
|
||
|
list+= fmt->timeFormat(tmpTime, Time_format3);
|
||
|
list+= fmt->timeFormat(tmpTime, Time_format4);
|
||
|
list+= fmt->timeFormat(tmpTime, Time_format5);
|
||
|
list+= ( fmt->timeFormat(tmpTime, Time_format6) + i18n(" (=[mm]::ss)") );
|
||
|
list+= ( fmt->timeFormat(tmpTime, Time_format7) + i18n(" (=[hh]::mm::ss)") );
|
||
|
list+= ( fmt->timeFormat(tmpTime, Time_format8) + i18n(" (=[hh]::mm)") );
|
||
|
listFormat->insertStringList(list);
|
||
|
|
||
|
if ( cellFormatType == Time_format )
|
||
|
listFormat->setCurrentItem(0);
|
||
|
else if (cellFormatType == SecondeTime_format)
|
||
|
listFormat->setCurrentItem(1);
|
||
|
else if (cellFormatType == Time_format1)
|
||
|
listFormat->setCurrentItem(2);
|
||
|
else if (cellFormatType == Time_format2)
|
||
|
listFormat->setCurrentItem(3);
|
||
|
else if (cellFormatType == Time_format3)
|
||
|
listFormat->setCurrentItem(4);
|
||
|
else if (cellFormatType == Time_format4)
|
||
|
listFormat->setCurrentItem(5);
|
||
|
else if (cellFormatType == Time_format5)
|
||
|
listFormat->setCurrentItem(6);
|
||
|
else if (cellFormatType == Time_format6)
|
||
|
listFormat->setCurrentItem(7);
|
||
|
else if (cellFormatType == Time_format7)
|
||
|
listFormat->setCurrentItem(8);
|
||
|
else if (cellFormatType == Time_format8)
|
||
|
listFormat->setCurrentItem(9);
|
||
|
else
|
||
|
listFormat->setCurrentItem(0);
|
||
|
}
|
||
|
|
||
|
if (customFormat->isChecked())
|
||
|
{
|
||
|
customFormatEdit->setHidden( false );
|
||
|
precision->setEnabled(false);
|
||
|
prefix->setEnabled(false);
|
||
|
postfix->setEnabled(false);
|
||
|
format->setEnabled(false);
|
||
|
listFormat->setEnabled(true);
|
||
|
}
|
||
|
else
|
||
|
customFormatEdit->setHidden( true );
|
||
|
|
||
|
m_bFormatTypeChanged=true;
|
||
|
|
||
|
makeformat();
|
||
|
}
|
||
|
|
||
|
void CellFormatPageFloat::init()
|
||
|
{
|
||
14 years ago
|
TQStringList list;
|
||
|
TQString tmp;
|
||
|
TQString tmp2;
|
||
|
TQDate tmpDate( 2000,2,18);
|
||
13 years ago
|
list+=i18n("System: ")+dlg->locale()->formatDate (TQDate::currentDate(), true);
|
||
|
list+=i18n("System: ")+dlg->locale()->formatDate (TQDate::currentDate(), false);
|
||
15 years ago
|
|
||
|
ValueFormatter *fmt = dlg->getDoc()->formatter();
|
||
|
|
||
|
/*18-Feb-00*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format1);
|
||
|
/*18-Feb-1999*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format2);
|
||
|
/*18-Feb*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format3);
|
||
|
/*18-2*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format4);
|
||
|
/*18/2/00*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format5);
|
||
|
/*18/5/1999*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format6);
|
||
|
/*Feb-99*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format7);
|
||
|
/*February-99*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format8);
|
||
|
/*February-1999*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format9);
|
||
|
/*F-99*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format10);
|
||
|
/*18/Feb*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format11);
|
||
|
/*18/2*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format12);
|
||
|
/*18/Feb/1999*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format13);
|
||
|
/*2000/Feb/18*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format14);
|
||
|
/*2000-Feb-18*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format15);
|
||
|
/*2000-2-18*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format16);
|
||
|
/*2 february 2000*/
|
||
|
list+=fmt->dateFormat( tmpDate, date_format17);
|
||
|
list+=fmt->dateFormat( tmpDate, date_format18);
|
||
|
list+=fmt->dateFormat( tmpDate, date_format19);
|
||
|
list+=fmt->dateFormat( tmpDate, date_format20);
|
||
|
list+=fmt->dateFormat( tmpDate, date_format21);
|
||
|
list+=fmt->dateFormat( tmpDate, date_format22);
|
||
|
list+=fmt->dateFormat( tmpDate, date_format23);
|
||
|
list+=fmt->dateFormat( tmpDate, date_format24);
|
||
|
list+=fmt->dateFormat( tmpDate, date_format25);
|
||
|
list+=fmt->dateFormat( tmpDate, date_format26);
|
||
|
|
||
|
listFormat->insertStringList(list);
|
||
|
if ( cellFormatType == ShortDate_format )
|
||
|
listFormat->setCurrentItem(0);
|
||
|
else if (cellFormatType == TextDate_format)
|
||
|
listFormat->setCurrentItem(1);
|
||
|
else if (cellFormatType == date_format1)
|
||
|
listFormat->setCurrentItem(2);
|
||
|
else if (cellFormatType == date_format2)
|
||
|
listFormat->setCurrentItem(3);
|
||
|
else if (cellFormatType == date_format3)
|
||
|
listFormat->setCurrentItem(4);
|
||
|
else if (cellFormatType == date_format4)
|
||
|
listFormat->setCurrentItem(5);
|
||
|
else if (cellFormatType == date_format5)
|
||
|
listFormat->setCurrentItem(6);
|
||
|
else if (cellFormatType == date_format6)
|
||
|
listFormat->setCurrentItem(7);
|
||
|
else if (cellFormatType == date_format7)
|
||
|
listFormat->setCurrentItem(8);
|
||
|
else if (cellFormatType == date_format8)
|
||
|
listFormat->setCurrentItem(9);
|
||
|
else if (cellFormatType == date_format9)
|
||
|
listFormat->setCurrentItem(10);
|
||
|
else if (cellFormatType == date_format10)
|
||
|
listFormat->setCurrentItem(11);
|
||
|
else if (cellFormatType == date_format11)
|
||
|
listFormat->setCurrentItem(12);
|
||
|
else if (cellFormatType == date_format12)
|
||
|
listFormat->setCurrentItem(13);
|
||
|
else if (cellFormatType == date_format13)
|
||
|
listFormat->setCurrentItem(14);
|
||
|
else if (cellFormatType == date_format14)
|
||
|
listFormat->setCurrentItem(15);
|
||
|
else if (cellFormatType == date_format15)
|
||
|
listFormat->setCurrentItem(16);
|
||
|
else if (cellFormatType == date_format16)
|
||
|
listFormat->setCurrentItem(17);
|
||
|
else if (cellFormatType == date_format17)
|
||
|
listFormat->setCurrentItem(18);
|
||
|
else if (cellFormatType == date_format18)
|
||
|
listFormat->setCurrentItem(19);
|
||
|
else if (cellFormatType == date_format19)
|
||
|
listFormat->setCurrentItem(20);
|
||
|
else if (cellFormatType == date_format20)
|
||
|
listFormat->setCurrentItem(21);
|
||
|
else if (cellFormatType == date_format21)
|
||
|
listFormat->setCurrentItem(22);
|
||
|
else if (cellFormatType == date_format22)
|
||
|
listFormat->setCurrentItem(23);
|
||
|
else if (cellFormatType == date_format23)
|
||
|
listFormat->setCurrentItem(24);
|
||
|
else if (cellFormatType == date_format24)
|
||
|
listFormat->setCurrentItem(25);
|
||
|
else if (cellFormatType == date_format25)
|
||
|
listFormat->setCurrentItem(26);
|
||
|
else if (cellFormatType == date_format26)
|
||
|
listFormat->setCurrentItem(27);
|
||
|
else
|
||
|
listFormat->setCurrentItem(0);
|
||
|
|
||
|
}
|
||
|
|
||
14 years ago
|
void CellFormatPageFloat::currencyChanged(const TQString &)
|
||
15 years ago
|
{
|
||
|
int index = currency->currentItem();
|
||
|
if (index > 0)
|
||
|
++index;
|
||
|
dlg->cCurrency.symbol = Currency::getDisplaySymbol(index);
|
||
|
dlg->cCurrency.type = index;
|
||
|
|
||
|
makeformat();
|
||
|
}
|
||
|
|
||
|
void CellFormatPageFloat::updateFormatType ()
|
||
|
{
|
||
|
if (generic->isChecked())
|
||
|
newFormatType = Generic_format;
|
||
|
else if (number->isChecked())
|
||
|
newFormatType = Number_format;
|
||
|
else if (percent->isChecked())
|
||
|
newFormatType = Percentage_format;
|
||
|
else if (date->isChecked())
|
||
|
{
|
||
|
newFormatType=ShortDate_format;
|
||
|
switch (listFormat->currentItem())
|
||
|
{
|
||
|
case 0: newFormatType=ShortDate_format; break;
|
||
|
case 1: newFormatType=TextDate_format; break;
|
||
|
case 2: newFormatType=date_format1; break; /*18-Feb-99*/
|
||
|
case 3: newFormatType=date_format2; break; /*18-Feb-1999*/
|
||
|
case 4: newFormatType=date_format3; break; /*18-Feb*/
|
||
|
case 5: newFormatType=date_format4; break; /*18-05*/
|
||
|
case 6: newFormatType=date_format5; break; /*18/05/00*/
|
||
|
case 7: newFormatType=date_format6; break; /*18/05/1999*/
|
||
|
case 8: newFormatType=date_format7; break;/*Feb-99*/
|
||
|
case 9: newFormatType=date_format8; break; /*February-99*/
|
||
|
case 10: newFormatType=date_format9; break; /*February-1999*/
|
||
|
case 11: newFormatType=date_format10; break; /*F-99*/
|
||
|
case 12: newFormatType=date_format11; break; /*18/Feb*/
|
||
|
case 13: newFormatType=date_format12; break; /*18/02*/
|
||
|
case 14: newFormatType=date_format13; break; /*18/Feb/1999*/
|
||
|
case 15: newFormatType=date_format14; break; /*2000/Feb/18*/
|
||
|
case 16: newFormatType=date_format15; break;/*2000-Feb-18*/
|
||
|
case 17: newFormatType=date_format16; break;/*2000-02-18*/
|
||
|
case 18: newFormatType=date_format17; break; /*2000-02-18*/
|
||
|
case 19: newFormatType=date_format18; break;
|
||
|
case 20: newFormatType=date_format19; break;
|
||
|
case 21: newFormatType=date_format20; break;
|
||
|
case 22: newFormatType=date_format21; break;
|
||
|
case 23: newFormatType=date_format22; break;
|
||
|
case 24: newFormatType=date_format23; break;
|
||
|
case 25: newFormatType=date_format24; break;
|
||
|
case 26: newFormatType=date_format25; break;
|
||
|
case 27: newFormatType=date_format26; break;
|
||
|
}
|
||
|
}
|
||
|
else if (money->isChecked())
|
||
|
newFormatType = Money_format;
|
||
|
else if (scientific->isChecked())
|
||
|
newFormatType = Scientific_format;
|
||
|
else if (fraction->isChecked())
|
||
|
{
|
||
|
newFormatType=fraction_half;
|
||
|
switch (listFormat->currentItem())
|
||
|
{
|
||
|
case 0: newFormatType=fraction_half; break;
|
||
|
case 1: newFormatType=fraction_quarter; break;
|
||
|
case 2: newFormatType=fraction_eighth; break;
|
||
|
case 3: newFormatType=fraction_sixteenth; break;
|
||
|
case 4: newFormatType=fraction_tenth; break;
|
||
|
case 5: newFormatType=fraction_hundredth; break;
|
||
|
case 6: newFormatType=fraction_one_digit; break;
|
||
|
case 7: newFormatType=fraction_two_digits; break;
|
||
|
case 8: newFormatType=fraction_three_digits; break;
|
||
|
}
|
||
|
}
|
||
|
else if (time->isChecked())
|
||
|
{
|
||
|
newFormatType=Time_format;
|
||
|
switch (listFormat->currentItem())
|
||
|
{
|
||
|
case 0: newFormatType=Time_format; break;
|
||
|
case 1: newFormatType=SecondeTime_format; break;
|
||
|
case 2: newFormatType=Time_format1; break;
|
||
|
case 3: newFormatType=Time_format2; break;
|
||
|
case 4: newFormatType=Time_format3; break;
|
||
|
case 5: newFormatType=Time_format4; break;
|
||
|
case 6: newFormatType=Time_format5; break;
|
||
|
case 7: newFormatType=Time_format6; break;
|
||
|
case 8: newFormatType=Time_format7; break;
|
||
|
case 9: newFormatType=Time_format8; break;
|
||
|
}
|
||
|
}
|
||
|
else if (textFormat->isChecked())
|
||
|
newFormatType = Text_format;
|
||
|
else if (customFormat->isChecked())
|
||
|
newFormatType = Custom_format;
|
||
|
}
|
||
|
|
||
|
void CellFormatPageFloat::makeformat()
|
||
|
{
|
||
|
m_bFormatTypeChanged=true;
|
||
14 years ago
|
TQString tmp;
|
||
15 years ago
|
|
||
|
updateFormatType();
|
||
14 years ago
|
TQColor color;
|
||
15 years ago
|
Format::FloatFormat floatFormat = Format::OnlyNegSigned;
|
||
|
switch( format->currentItem() )
|
||
|
{
|
||
|
case 0:
|
||
|
floatFormat = Format::OnlyNegSigned;
|
||
|
color = black;
|
||
|
break;
|
||
|
case 1:
|
||
|
floatFormat = Format::OnlyNegSigned;
|
||
14 years ago
|
color = TQt::red;
|
||
15 years ago
|
break;
|
||
|
case 2:
|
||
|
floatFormat = Format::AlwaysUnsigned;
|
||
14 years ago
|
color = TQt::red;
|
||
15 years ago
|
break;
|
||
|
case 3:
|
||
|
floatFormat = Format::AlwaysSigned;
|
||
|
color = black;
|
||
|
break;
|
||
|
case 4:
|
||
|
floatFormat = Format::AlwaysSigned;
|
||
14 years ago
|
color = TQt::red;
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
if (!dlg->value.isNumber() || dlg->value.asFloat() >= 0 || !format->isEnabled())
|
||
|
{
|
||
|
color = black;
|
||
|
}
|
||
|
ValueFormatter *fmt = dlg->getDoc()->formatter();
|
||
|
tmp = fmt->formatText(dlg->value, newFormatType, precision->value(),
|
||
|
floatFormat,
|
||
14 years ago
|
prefix->isEnabled() ? prefix->text() : TQString(),
|
||
|
postfix->isEnabled() ? postfix->text() : TQString(),
|
||
|
newFormatType == Money_format ? dlg->cCurrency.symbol : TQString());
|
||
15 years ago
|
if (tmp.length() > 50)
|
||
|
tmp = tmp.left (50);
|
||
|
exampleLabel->setText(tmp.prepend("<font color=" + color.name() + ">").append("</font>"));
|
||
|
}
|
||
|
|
||
|
void CellFormatPageFloat::apply( CustomStyle * style )
|
||
|
{
|
||
|
if ( postfix->text() != dlg->postfix )
|
||
|
{
|
||
|
if ( postfix->isEnabled())
|
||
|
style->changePostfix( postfix->text() );
|
||
|
else
|
||
|
style->changePostfix( "" );
|
||
|
}
|
||
|
if ( prefix->text() != dlg->prefix )
|
||
|
{
|
||
|
if (prefix->isEnabled())
|
||
|
style->changePrefix( prefix->text() );
|
||
|
else
|
||
|
style->changePrefix( "" );
|
||
|
}
|
||
|
|
||
|
if ( dlg->precision != precision->value() )
|
||
|
style->changePrecision( precision->value() );
|
||
|
|
||
|
if ( m_bFormatColorChanged )
|
||
|
{
|
||
|
switch( format->currentItem() )
|
||
|
{
|
||
|
case 0:
|
||
|
style->changeFloatFormat( Format::OnlyNegSigned );
|
||
|
style->changeFloatColor( Format::AllBlack );
|
||
|
break;
|
||
|
case 1:
|
||
|
style->changeFloatFormat( Format::OnlyNegSigned );
|
||
|
style->changeFloatColor( Format::NegRed );
|
||
|
break;
|
||
|
case 2:
|
||
|
style->changeFloatFormat( Format::AlwaysUnsigned );
|
||
|
style->changeFloatColor( Format::NegRed );
|
||
|
break;
|
||
|
case 3:
|
||
|
style->changeFloatFormat( Format::AlwaysSigned );
|
||
|
style->changeFloatColor( Format::AllBlack );
|
||
|
break;
|
||
|
case 4:
|
||
|
style->changeFloatFormat( Format::AlwaysSigned );
|
||
|
style->changeFloatColor( Format::NegRed );
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if ( m_bFormatTypeChanged )
|
||
|
{
|
||
|
style->changeFormatType (newFormatType);
|
||
|
if ( money->isChecked() )
|
||
|
{
|
||
|
Format::Currency cur;
|
||
|
int index = currency->currentItem();
|
||
|
if (index == 0)
|
||
|
{
|
||
|
if ( currency->currentText() == i18n( "Automatic" ) )
|
||
|
{
|
||
|
cur.symbol = dlg->locale()->currencySymbol();
|
||
|
cur.type = 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
cur.type = 1;
|
||
|
cur.symbol = currency->currentText();
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
cur.type = ++index;
|
||
|
cur.symbol = Currency::getDisplaySymbol( index );
|
||
|
}
|
||
|
|
||
|
style->changeCurrency( cur );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CellFormatPageFloat::apply(FormatManipulator* _obj)
|
||
|
{
|
||
|
if ( postfix->text() != dlg->postfix )
|
||
|
if ( postfix->isEnabled())
|
||
|
{
|
||
|
// If we are in here it *never* can be disabled - FIXME (Werner)!
|
||
|
if ( postfix->isEnabled())
|
||
|
_obj->setPostfix( postfix->text() );
|
||
|
else
|
||
|
_obj->setPostfix( "" );
|
||
|
}
|
||
|
if ( prefix->text() != dlg->prefix )
|
||
|
if (prefix->isEnabled())
|
||
|
_obj->setPrefix( prefix->text() );
|
||
|
else
|
||
|
_obj->setPrefix( "" );
|
||
|
|
||
|
if ( dlg->precision != precision->value() )
|
||
|
_obj->setPrecision( precision->value() );
|
||
|
|
||
|
if (m_bFormatColorChanged)
|
||
|
{
|
||
|
switch( format->currentItem() )
|
||
|
{
|
||
|
case 0:
|
||
|
_obj->setFloatFormat( Format::OnlyNegSigned );
|
||
|
_obj->setFloatColor( Format::AllBlack );
|
||
|
break;
|
||
|
case 1:
|
||
|
_obj->setFloatFormat( Format::OnlyNegSigned );
|
||
|
_obj->setFloatColor( Format::NegRed );
|
||
|
break;
|
||
|
case 2:
|
||
|
_obj->setFloatFormat( Format::AlwaysUnsigned );
|
||
|
_obj->setFloatColor( Format::NegRed );
|
||
|
break;
|
||
|
case 3:
|
||
|
_obj->setFloatFormat( Format::AlwaysSigned );
|
||
|
_obj->setFloatColor( Format::AllBlack );
|
||
|
break;
|
||
|
case 4:
|
||
|
_obj->setFloatFormat( Format::AlwaysSigned );
|
||
|
_obj->setFloatColor( Format::NegRed );
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (m_bFormatTypeChanged)
|
||
|
{
|
||
|
_obj->setFormatType (newFormatType);
|
||
|
if (money->isChecked())
|
||
|
{
|
||
|
Format::Currency cur;
|
||
|
int index = currency->currentItem();
|
||
|
if (index == 0)
|
||
|
{
|
||
|
if ( currency->currentText() == i18n( "Automatic" ) )
|
||
|
{
|
||
|
cur.symbol = dlg->locale()->currencySymbol();
|
||
|
cur.type = 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
cur.type = 1;
|
||
|
cur.symbol = currency->currentText();
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
cur.type = ++index;
|
||
|
cur.symbol = Currency::getDisplaySymbol( index );
|
||
|
}
|
||
|
|
||
|
_obj->setCurrency( cur.type, cur.symbol );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
*
|
||
|
* CellFormatPageProtection
|
||
|
*
|
||
|
***************************************************************************/
|
||
|
|
||
13 years ago
|
CellFormatPageProtection::CellFormatPageProtection( TQWidget* parent, CellFormatDialog * _dlg )
|
||
|
: ProtectionTab( parent ),
|
||
15 years ago
|
m_dlg( _dlg )
|
||
|
{
|
||
|
m_bDontPrint->setChecked( m_dlg->bDontPrintText );
|
||
|
m_bHideAll->setChecked( m_dlg->bHideAll );
|
||
|
m_bHideFormula->setChecked( m_dlg->bHideFormula );
|
||
|
m_bIsProtected->setChecked( m_dlg->bIsProtected );
|
||
|
}
|
||
|
|
||
|
CellFormatPageProtection::~CellFormatPageProtection()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void CellFormatPageProtection::apply( CustomStyle * style )
|
||
|
{
|
||
|
if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked() )
|
||
|
{
|
||
|
if ( m_bDontPrint->isChecked() )
|
||
|
style->addProperty( Style::PDontPrintText );
|
||
|
else
|
||
|
style->removeProperty( Style::PDontPrintText );
|
||
|
}
|
||
|
|
||
|
if ( m_dlg->bIsProtected != m_bIsProtected->isChecked() )
|
||
|
{
|
||
|
if ( !m_bIsProtected->isChecked() )
|
||
|
style->addProperty( Style::PNotProtected );
|
||
|
else
|
||
|
style->removeProperty( Style::PNotProtected );
|
||
|
}
|
||
|
|
||
|
if ( m_dlg->bHideAll != m_bHideAll->isChecked() )
|
||
|
{
|
||
|
if ( m_bHideAll->isChecked() )
|
||
|
style->addProperty( Style::PHideAll );
|
||
|
else
|
||
|
style->removeProperty( Style::PHideAll );
|
||
|
}
|
||
|
|
||
|
if ( m_dlg->bHideFormula != m_bHideFormula->isChecked() )
|
||
|
{
|
||
|
if ( m_bHideFormula->isChecked() )
|
||
|
style->addProperty( Style::PHideFormula );
|
||
|
else
|
||
|
style->removeProperty( Style::PHideFormula );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CellFormatPageProtection::apply(FormatManipulator* _obj)
|
||
|
{
|
||
|
if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked())
|
||
|
_obj->setDontPrintText( m_bDontPrint->isChecked() );
|
||
|
|
||
|
if ( m_dlg->bIsProtected != m_bIsProtected->isChecked())
|
||
|
_obj->setNotProtected( !m_bIsProtected->isChecked() );
|
||
|
|
||
|
if ( m_dlg->bHideAll != m_bHideAll->isChecked())
|
||
|
_obj->setHideAll( m_bHideAll->isChecked() );
|
||
|
|
||
|
if ( m_dlg->bHideFormula != m_bHideFormula->isChecked())
|
||
|
_obj->setHideFormula( m_bHideFormula->isChecked() );
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
*
|
||
|
* CellFormatPageFont
|
||
|
*
|
||
|
***************************************************************************/
|
||
|
|
||
13 years ago
|
CellFormatPageFont::CellFormatPageFont( TQWidget* parent, CellFormatDialog *_dlg ) : FontTab( parent )
|
||
15 years ago
|
{
|
||
|
dlg = _dlg;
|
||
|
|
||
|
bTextColorUndefined = !dlg->bTextColor;
|
||
|
|
||
14 years ago
|
connect( textColorButton, TQT_SIGNAL( changed( const TQColor & ) ),
|
||
|
this, TQT_SLOT( slotSetTextColor( const TQColor & ) ) );
|
||
15 years ago
|
|
||
|
|
||
14 years ago
|
TQStringList tmpListFont;
|
||
|
TQFontDatabase *fontDataBase = new TQFontDatabase();
|
||
13 years ago
|
tmpListFont = fontDataBase->families();
|
||
15 years ago
|
delete fontDataBase;
|
||
|
|
||
|
family_combo->insertStringList( tmpListFont);
|
||
|
selFont = dlg->textFont;
|
||
|
|
||
|
if ( dlg->bTextFontFamily )
|
||
|
{
|
||
|
selFont.setFamily( dlg->textFontFamily );
|
||
|
kdDebug(36001) << "Family = " << dlg->textFontFamily << endl;
|
||
|
|
||
13 years ago
|
if ( !family_combo->findItem(dlg->textFontFamily))
|
||
15 years ago
|
{
|
||
|
family_combo->insertItem("",0);
|
||
|
family_combo->setCurrentItem(0);
|
||
|
}
|
||
|
else
|
||
13 years ago
|
family_combo->setCurrentItem(family_combo->index(family_combo->findItem(dlg->textFontFamily)));
|
||
15 years ago
|
}
|
||
|
else
|
||
|
{
|
||
|
family_combo->insertItem("",0);
|
||
|
family_combo->setCurrentItem(0);
|
||
|
}
|
||
|
|
||
14 years ago
|
connect( family_combo, TQT_SIGNAL(highlighted(const TQString &)),
|
||
|
TQT_SLOT(family_chosen_slot(const TQString &)) );
|
||
15 years ago
|
|
||
14 years ago
|
TQStringList lst;
|
||
15 years ago
|
lst.append("");
|
||
|
for ( unsigned int i = 1; i < 100; ++i )
|
||
13 years ago
|
lst.append( TQString( "%1" ).arg( i ) );
|
||
15 years ago
|
|
||
|
size_combo->insertStringList( lst );
|
||
|
|
||
|
|
||
14 years ago
|
size_combo->setInsertionPolicy(TQComboBox::NoInsertion);
|
||
15 years ago
|
|
||
14 years ago
|
connect( size_combo, TQT_SIGNAL(activated(const TQString &)),
|
||
|
TQT_SLOT(size_chosen_slot(const TQString &)) );
|
||
|
connect( size_combo ,TQT_SIGNAL( textChanged(const TQString &)),
|
||
|
this,TQT_SLOT(size_chosen_slot(const TQString &)));
|
||
15 years ago
|
|
||
14 years ago
|
connect( weight_combo, TQT_SIGNAL(activated(const TQString &)),
|
||
|
TQT_SLOT(weight_chosen_slot(const TQString &)) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( style_combo, TQT_SIGNAL(activated(const TQString &)),
|
||
|
TQT_SLOT(style_chosen_slot(const TQString &)) );
|
||
15 years ago
|
|
||
|
strike->setChecked(dlg->strike);
|
||
14 years ago
|
connect( strike, TQT_SIGNAL( clicked()),
|
||
|
TQT_SLOT(strike_chosen_slot()) );
|
||
15 years ago
|
|
||
|
underline->setChecked(dlg->underline);
|
||
14 years ago
|
connect( underline, TQT_SIGNAL( clicked()),
|
||
|
TQT_SLOT(underline_chosen_slot()) );
|
||
15 years ago
|
|
||
|
example_label->setText(i18n("Dolor Ipse"));
|
||
|
|
||
14 years ago
|
connect(this,TQT_SIGNAL(fontSelected( const TQFont& )),
|
||
|
this,TQT_SLOT(display_example( const TQFont&)));
|
||
15 years ago
|
|
||
|
setCombos();
|
||
|
display_example( selFont );
|
||
|
fontChanged=false;
|
||
|
this->resize( 400, 400 );
|
||
|
}
|
||
|
|
||
14 years ago
|
void CellFormatPageFont::slotSetTextColor( const TQColor &_color )
|
||
15 years ago
|
{
|
||
|
textColor = _color;
|
||
|
bTextColorUndefined = false;
|
||
|
}
|
||
|
|
||
|
void CellFormatPageFont::apply( CustomStyle * style )
|
||
|
{
|
||
|
if ( !bTextColorUndefined && textColor != dlg->textColor )
|
||
|
style->changeTextColor( textColor );
|
||
|
|
||
|
if ( ( size_combo->currentItem() != 0 )
|
||
|
&& ( dlg->textFontSize != selFont.pointSize() ) )
|
||
|
style->changeFontSize( selFont.pointSize() );
|
||
|
|
||
|
if ( ( selFont.family() != dlg->textFontFamily )
|
||
|
&& !family_combo->currentText().isEmpty() )
|
||
|
style->changeFontFamily( selFont.family() );
|
||
|
|
||
|
uint flags = 0;
|
||
|
|
||
|
if ( weight_combo->currentItem() != 0 && selFont.bold() )
|
||
|
flags |= Style::FBold;
|
||
|
else
|
||
|
flags &= ~(uint) Style::FBold;
|
||
|
|
||
|
if ( style_combo->currentItem() != 0 && selFont.italic() )
|
||
|
flags |= Style::FItalic;
|
||
|
else
|
||
|
flags &= ~(uint) Style::FItalic;
|
||
|
|
||
|
if ( strike->isChecked() )
|
||
|
flags |= Style::FStrike;
|
||
|
else
|
||
|
flags &= ~(uint) Style::FStrike;
|
||
|
|
||
|
if ( underline->isChecked() )
|
||
|
flags |= Style::FUnderline;
|
||
|
else
|
||
|
flags &= ~(uint) Style::FUnderline;
|
||
|
|
||
|
style->changeFontFlags( flags );
|
||
|
}
|
||
|
|
||
|
void CellFormatPageFont::apply(FormatManipulator* _obj)
|
||
|
{
|
||
|
if ( !bTextColorUndefined && textColor != dlg->textColor )
|
||
|
_obj->setTextColor( textColor );
|
||
|
if (fontChanged)
|
||
|
{
|
||
|
if ( ( size_combo->currentItem() != 0 )
|
||
|
&& ( dlg->textFontSize != selFont.pointSize() ) )
|
||
|
_obj->setFontSize( selFont.pointSize() );
|
||
|
if ( ( selFont.family() != dlg->textFontFamily ) && ( !family_combo->currentText().isEmpty() ) )
|
||
|
_obj->setFontFamily( selFont.family() );
|
||
|
if ( weight_combo->currentItem() != 0 )
|
||
|
_obj->setFontBold( selFont.bold() );
|
||
|
if ( style_combo->currentItem() != 0 )
|
||
|
_obj->setFontItalic( selFont.italic() );
|
||
|
_obj->setFontStrike( strike->isChecked() );
|
||
|
_obj->setFontUnderline(underline->isChecked() );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CellFormatPageFont::underline_chosen_slot()
|
||
|
{
|
||
|
selFont.setUnderline( underline->isChecked() );
|
||
|
emit fontSelected(selFont);
|
||
|
}
|
||
|
|
||
|
void CellFormatPageFont::strike_chosen_slot()
|
||
|
{
|
||
|
selFont.setStrikeOut( strike->isChecked() );
|
||
|
emit fontSelected(selFont);
|
||
|
}
|
||
|
|
||
14 years ago
|
void CellFormatPageFont::family_chosen_slot(const TQString & family)
|
||
15 years ago
|
{
|
||
|
selFont.setFamily(family);
|
||
|
emit fontSelected(selFont);
|
||
|
}
|
||
|
|
||
14 years ago
|
void CellFormatPageFont::size_chosen_slot(const TQString & size)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQString size_string = size;
|
||
15 years ago
|
|
||
|
selFont.setPointSize(size_string.toInt());
|
||
|
emit fontSelected(selFont);
|
||
|
}
|
||
|
|
||
14 years ago
|
void CellFormatPageFont::weight_chosen_slot(const TQString & weight)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQString weight_string = weight;
|
||
15 years ago
|
|
||
|
if ( weight_string == i18n("Normal"))
|
||
|
selFont.setBold(false);
|
||
|
if ( weight_string == i18n("Bold"))
|
||
|
selFont.setBold(true);
|
||
|
emit fontSelected(selFont);
|
||
|
}
|
||
|
|
||
14 years ago
|
void CellFormatPageFont::style_chosen_slot(const TQString & style)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQString style_string = style;
|
||
15 years ago
|
|
||
|
if ( style_string == i18n("Roman"))
|
||
|
selFont.setItalic(false);
|
||
|
if ( style_string == i18n("Italic"))
|
||
|
selFont.setItalic(true);
|
||
|
emit fontSelected(selFont);
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
void CellFormatPageFont::display_example(const TQFont& font)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQString string;
|
||
15 years ago
|
fontChanged=true;
|
||
|
example_label->setFont(font);
|
||
13 years ago
|
example_label->repaint();
|
||
15 years ago
|
}
|
||
|
|
||
|
void CellFormatPageFont::setCombos()
|
||
|
{
|
||
14 years ago
|
TQString string;
|
||
|
TQComboBox* combo;
|
||
15 years ago
|
int number_of_entries;
|
||
|
bool found;
|
||
|
|
||
|
if ( dlg->bTextColor )
|
||
|
textColor = dlg->textColor;
|
||
|
else
|
||
13 years ago
|
textColor = colorGroup().text();
|
||
15 years ago
|
|
||
|
if ( !textColor.isValid() )
|
||
13 years ago
|
textColor =colorGroup().text();
|
||
15 years ago
|
|
||
|
textColorButton->setColor( textColor );
|
||
|
|
||
|
|
||
|
combo = size_combo;
|
||
|
if ( dlg->bTextFontSize )
|
||
|
{
|
||
|
kdDebug(36001) << "SIZE=" << dlg->textFontSize << endl;
|
||
|
selFont.setPointSize( dlg->textFontSize );
|
||
|
number_of_entries = size_combo->count();
|
||
|
string.setNum( dlg->textFontSize );
|
||
|
found = false;
|
||
|
|
||
|
for (int i = 0; i < number_of_entries ; i++){
|
||
14 years ago
|
if ( string == (TQString) combo->text(i)){
|
||
15 years ago
|
combo->setCurrentItem(i);
|
||
|
found = true;
|
||
|
// kdDebug(36001) << "Found Size " << string.data() << " setting to item " i << endl;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
combo->setCurrentItem( 0 );
|
||
|
|
||
|
if ( !dlg->bTextFontBold )
|
||
|
weight_combo->setCurrentItem(0);
|
||
|
else if ( dlg->textFontBold )
|
||
|
{
|
||
|
selFont.setBold( dlg->textFontBold );
|
||
|
weight_combo->setCurrentItem(2);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
selFont.setBold( dlg->textFontBold );
|
||
|
weight_combo->setCurrentItem(1);
|
||
|
}
|
||
|
|
||
|
if ( !dlg->bTextFontItalic )
|
||
|
weight_combo->setCurrentItem(0);
|
||
|
else if ( dlg->textFontItalic )
|
||
|
{
|
||
|
selFont.setItalic( dlg->textFontItalic );
|
||
|
style_combo->setCurrentItem(2);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
selFont.setItalic( dlg->textFontItalic );
|
||
|
style_combo->setCurrentItem(1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
*
|
||
|
* CellFormatPagePosition
|
||
|
*
|
||
|
***************************************************************************/
|
||
|
|
||
13 years ago
|
CellFormatPagePosition::CellFormatPagePosition( TQWidget* parent, CellFormatDialog *_dlg )
|
||
|
: PositionTab(parent ),
|
||
15 years ago
|
dlg( _dlg )
|
||
|
{
|
||
|
if ( dlg->alignX == Format::Left )
|
||
|
left->setChecked( true );
|
||
|
else if ( dlg->alignX == Format::Center )
|
||
|
center->setChecked( true );
|
||
|
else if ( dlg->alignX == Format::Right )
|
||
|
right->setChecked( true );
|
||
|
else if ( dlg->alignX == Format::Undefined )
|
||
|
standard->setChecked( true );
|
||
|
|
||
14 years ago
|
connect(horizontalGroup, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(slotStateChanged(int)));
|
||
15 years ago
|
|
||
|
if ( dlg->alignY ==Format::Top )
|
||
|
top->setChecked( true );
|
||
|
else if ( dlg->alignY ==Format::Middle )
|
||
|
middle->setChecked(true );
|
||
|
else if ( dlg->alignY ==Format::Bottom )
|
||
|
bottom->setChecked( true );
|
||
|
|
||
|
multi->setChecked(dlg->bMultiRow);
|
||
|
|
||
|
vertical->setChecked(dlg->bVerticalText);
|
||
|
|
||
|
angleRotation->setValue(-dlg->textRotation);//annma
|
||
|
spinBox3->setValue(-dlg->textRotation);
|
||
|
if ( dlg->textRotation != 0 )
|
||
|
{
|
||
|
multi->setEnabled(false );
|
||
|
vertical->setEnabled(false);
|
||
|
}
|
||
|
|
||
|
mergeCell->setChecked(dlg->isMerged);
|
||
|
mergeCell->setEnabled(!dlg->oneCell && ((!dlg->isRowSelected) && (!dlg->isColumnSelected)));
|
||
|
|
||
14 years ago
|
TQGridLayout *grid2 = new TQGridLayout(indentGroup, 1, 1, KDialog::marginHint(), KDialog::spacingHint());
|
||
15 years ago
|
grid2->addRowSpacing( 0, indentGroup->fontMetrics().height()/8 ); // groupbox title
|
||
|
m_indent = new KoUnitDoubleSpinBox( indentGroup, 0.0, 400.0, 10.0,dlg->indent,dlg->getDoc()->unit() );
|
||
|
grid2->addWidget(m_indent, 0, 0);
|
||
|
|
||
|
width = new KoUnitDoubleSpinBox( m_widthPanel );
|
||
14 years ago
|
TQGridLayout *gridWidth = new TQGridLayout(m_widthPanel, 1, 1, 0, 0);
|
||
15 years ago
|
gridWidth->addWidget(width, 0, 0);
|
||
|
width->setValue ( dlg->widthSize );
|
||
|
width->setUnit( dlg->getDoc()->unit() );
|
||
|
//to ensure, that we don't get rounding problems, we store the displayed value (for later check for changes)
|
||
|
dlg->widthSize = width->value();
|
||
|
|
||
|
if ( dlg->isRowSelected )
|
||
|
width->setEnabled(false);
|
||
|
|
||
13 years ago
|
defaultWidth->setText(i18n("Default width (%1 %2)").arg(KoUnit::toUserValue(dlg->defaultWidthSize, dlg->getDoc()->unit()), 0, 'f', 2).arg(dlg->getDoc()->unitName()));
|
||
15 years ago
|
if ( dlg->isRowSelected )
|
||
|
defaultWidth->setEnabled(false);
|
||
|
|
||
|
height=new KoUnitDoubleSpinBox( m_heightPanel );
|
||
14 years ago
|
TQGridLayout *gridHeight = new TQGridLayout(m_heightPanel, 1, 1, 0, 0);
|
||
15 years ago
|
gridHeight->addWidget(height, 0, 0);
|
||
|
height->setValue( dlg->heightSize );
|
||
|
height->setUnit( dlg->getDoc()->unit() );
|
||
|
//to ensure, that we don't get rounding problems, we store the displayed value (for later check for changes)
|
||
|
dlg->heightSize = height->value();
|
||
|
|
||
|
if ( dlg->isColumnSelected )
|
||
|
height->setEnabled(false);
|
||
|
|
||
13 years ago
|
defaultHeight->setText(i18n("Default height (%1 %2)").arg(KoUnit::toUserValue(dlg->defaultHeightSize, dlg->getDoc()->unit()), 0, 'f', 2).arg(dlg->getDoc()->unitName())); //annma
|
||
15 years ago
|
if ( dlg->isColumnSelected )
|
||
|
defaultHeight->setEnabled(false);
|
||
|
|
||
|
// in case we're editing a style, we disable the cell size settings
|
||
|
if (dlg->getStyle())
|
||
|
{
|
||
|
defaultHeight->setEnabled(false);
|
||
|
defaultWidth->setEnabled(false);
|
||
|
}
|
||
|
|
||
14 years ago
|
connect(defaultWidth , TQT_SIGNAL(clicked() ),this, TQT_SLOT(slotChangeWidthState()));
|
||
|
connect(defaultHeight , TQT_SIGNAL(clicked() ),this, TQT_SLOT(slotChangeHeightState()));
|
||
|
connect(vertical , TQT_SIGNAL(clicked() ),this, TQT_SLOT(slotChangeVerticalState()));
|
||
|
connect(multi , TQT_SIGNAL(clicked() ), this, TQT_SLOT(slotChangeMultiState()));
|
||
|
connect(angleRotation, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotChangeAngle(int)));
|
||
15 years ago
|
|
||
|
slotStateChanged( 0 );
|
||
|
m_bOptionText = false;
|
||
|
this->resize( 400, 400 );
|
||
|
}
|
||
|
|
||
|
void CellFormatPagePosition::slotChangeMultiState()
|
||
|
{
|
||
|
m_bOptionText = true;
|
||
|
if (vertical->isChecked())
|
||
|
{
|
||
|
vertical->setChecked(false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CellFormatPagePosition::slotChangeVerticalState()
|
||
|
{
|
||
|
m_bOptionText=true;
|
||
|
if (multi->isChecked())
|
||
|
{
|
||
|
multi->setChecked(false);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
void CellFormatPagePosition::slotStateChanged(int)
|
||
|
{
|
||
|
if (right->isChecked() || center->isChecked())
|
||
|
m_indent->setEnabled(false);
|
||
|
else
|
||
|
m_indent->setEnabled(true);
|
||
|
}
|
||
|
|
||
|
bool CellFormatPagePosition::getMergedCellState() const
|
||
|
{
|
||
|
return mergeCell->isChecked();
|
||
|
}
|
||
|
|
||
|
void CellFormatPagePosition::slotChangeWidthState()
|
||
|
{
|
||
|
if ( defaultWidth->isChecked())
|
||
|
width->setEnabled(false);
|
||
|
else
|
||
|
width->setEnabled(true);
|
||
|
}
|
||
|
|
||
|
void CellFormatPagePosition::slotChangeHeightState()
|
||
|
{
|
||
|
if ( defaultHeight->isChecked())
|
||
|
height->setEnabled(false);
|
||
|
else
|
||
|
height->setEnabled(true);
|
||
|
}
|
||
|
|
||
|
void CellFormatPagePosition::slotChangeAngle(int _angle)
|
||
|
{
|
||
|
if ( _angle == 0 )
|
||
|
{
|
||
|
multi->setEnabled( true );
|
||
|
vertical->setEnabled( true );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
multi->setEnabled( false );
|
||
|
vertical->setEnabled( false );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CellFormatPagePosition::apply( CustomStyle * style )
|
||
|
{
|
||
|
if ( top->isChecked() && dlg->alignY != Format::Top )
|
||
|
style->changeAlignY( Format::Top );
|
||
|
else if ( bottom->isChecked() && dlg->alignY != Format::Bottom )
|
||
|
style->changeAlignY( Format::Bottom );
|
||
|
else if ( middle->isChecked() && dlg->alignY != Format::Middle )
|
||
|
style->changeAlignY( Format::Middle );
|
||
|
|
||
|
if ( left->isChecked() && dlg->alignX != Format::Left )
|
||
|
style->changeAlignX( Format::Left );
|
||
|
else if ( right->isChecked() && dlg->alignX != Format::Right )
|
||
|
style->changeAlignX( Format::Right );
|
||
|
else if ( center->isChecked() && dlg->alignX != Format::Center )
|
||
|
style->changeAlignX( Format::Center );
|
||
|
else if ( standard->isChecked() && dlg->alignX != Format::Undefined )
|
||
|
style->changeAlignX( Format::Undefined );
|
||
|
|
||
|
if ( m_bOptionText )
|
||
|
{
|
||
|
if ( multi->isEnabled() )
|
||
|
{
|
||
|
if ( multi->isChecked() )
|
||
|
style->addProperty( Style::PMultiRow );
|
||
|
else
|
||
|
style->removeProperty( Style::PMultiRow );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( m_bOptionText )
|
||
|
{
|
||
|
if ( vertical->isEnabled() )
|
||
|
{
|
||
|
if ( vertical->isChecked() )
|
||
|
style->addProperty( Style::PVerticalText );
|
||
|
else
|
||
|
style->removeProperty( Style::PVerticalText );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( dlg->textRotation != angleRotation->value() )
|
||
|
style->changeRotateAngle( (-angleRotation->value()) );
|
||
|
|
||
|
if ( m_indent->isEnabled()
|
||
|
&& dlg->indent != m_indent->value() )
|
||
|
style->changeIndent( m_indent->value() );
|
||
|
|
||
|
// setting the default column width and row height
|
||
|
if ( dlg->getStyle()->type() == Style::BUILTIN && dlg->getStyle()->name() == "Default" )
|
||
|
{
|
||
|
if ( (int) height->value() != (int) dlg->heightSize )
|
||
|
{
|
||
|
Format::setGlobalRowHeight( height->value() );
|
||
|
}
|
||
|
if ( (int) width->value() != (int) dlg->widthSize )
|
||
|
{
|
||
|
Format::setGlobalColWidth( width->value() );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CellFormatPagePosition::apply(FormatManipulator* _obj)
|
||
|
{
|
||
|
Format::Align ax;
|
||
|
Format::AlignY ay;
|
||
|
|
||
|
if ( top->isChecked() )
|
||
|
ay = Format::Top;
|
||
|
else if ( bottom->isChecked() )
|
||
|
ay = Format::Bottom;
|
||
|
else if ( middle->isChecked() )
|
||
|
ay = Format::Middle;
|
||
|
else
|
||
|
ay = Format::Middle; // Default, just in case
|
||
|
|
||
|
if ( left->isChecked() )
|
||
|
ax = Format::Left;
|
||
|
else if ( right->isChecked() )
|
||
|
ax = Format::Right;
|
||
|
else if ( center->isChecked() )
|
||
|
ax = Format::Center;
|
||
|
else if ( standard->isChecked() )
|
||
|
ax = Format::Undefined;
|
||
|
else
|
||
|
ax = Format::Undefined; //Default, just in case
|
||
|
|
||
|
if ( top->isChecked() && ay != dlg->alignY )
|
||
|
_obj->setVerticalAlignment( Format::Top );
|
||
|
else if ( bottom->isChecked() && ay != dlg->alignY )
|
||
|
_obj->setVerticalAlignment( Format::Bottom );
|
||
|
else if ( middle->isChecked() && ay != dlg->alignY )
|
||
|
_obj->setVerticalAlignment( Format::Middle );
|
||
|
|
||
|
if ( left->isChecked() && ax != dlg->alignX )
|
||
|
_obj->setHorizontalAlignment( Format::Left );
|
||
|
else if ( right->isChecked() && ax != dlg->alignX )
|
||
|
_obj->setHorizontalAlignment( Format::Right );
|
||
|
else if ( center->isChecked() && ax != dlg->alignX )
|
||
|
_obj->setHorizontalAlignment( Format::Center );
|
||
|
else if ( standard->isChecked() && ax != dlg->alignX )
|
||
|
_obj->setHorizontalAlignment( Format::Undefined );
|
||
|
|
||
|
if ( m_bOptionText )
|
||
|
{
|
||
|
if ( multi->isEnabled() )
|
||
|
_obj->setMultiRow( multi->isChecked() );
|
||
|
else
|
||
|
_obj->setMultiRow( false );
|
||
|
}
|
||
|
|
||
|
if ( m_bOptionText )
|
||
|
{
|
||
|
if ( vertical->isEnabled() )
|
||
|
_obj->setVerticalText( vertical->isChecked() );
|
||
|
else
|
||
|
_obj->setVerticalText( false );
|
||
|
}
|
||
|
|
||
|
if ( dlg->textRotation!=angleRotation->value() )
|
||
|
_obj->setAngle( (-angleRotation->value() ) );
|
||
|
if ( m_indent->isEnabled()
|
||
|
&& dlg->indent != m_indent->value() )
|
||
|
_obj->setIndent( m_indent->value() );
|
||
|
}
|
||
|
|
||
|
double CellFormatPagePosition::getSizeHeight() const
|
||
|
{
|
||
|
if ( defaultHeight->isChecked() )
|
||
|
return dlg->defaultHeightSize; // guess who calls this!
|
||
|
else
|
||
|
return height->value();
|
||
|
}
|
||
|
|
||
|
double CellFormatPagePosition::getSizeWidth() const
|
||
|
{
|
||
|
if ( defaultWidth->isChecked() )
|
||
|
return dlg->defaultWidthSize; // guess who calls this!
|
||
|
else
|
||
|
return width->value();
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
*
|
||
|
* BorderButton
|
||
|
*
|
||
|
***************************************************************************/
|
||
|
|
||
13 years ago
|
BorderButton::BorderButton( TQWidget *parent, const char *_name ) : TQPushButton(parent,_name)
|
||
15 years ago
|
{
|
||
|
penStyle = Qt::NoPen;
|
||
|
penWidth = 1;
|
||
13 years ago
|
penColor = colorGroup().text();
|
||
15 years ago
|
setToggleButton( true );
|
||
|
setOn( false);
|
||
|
setChanged(false);
|
||
|
}
|
||
14 years ago
|
void BorderButton::mousePressEvent( TQMouseEvent * )
|
||
15 years ago
|
{
|
||
|
|
||
|
this->setOn(!isOn());
|
||
|
emit clicked( this );
|
||
|
}
|
||
|
|
||
|
void BorderButton::setUndefined()
|
||
|
{
|
||
14 years ago
|
setPenStyle(Qt::SolidLine );
|
||
15 years ago
|
setPenWidth(1);
|
||
13 years ago
|
setColor(colorGroup().midlight());
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
void BorderButton::unselect()
|
||
|
{
|
||
|
setOn(false);
|
||
|
setPenWidth(1);
|
||
|
setPenStyle(Qt::NoPen);
|
||
13 years ago
|
setColor( colorGroup().text() );
|
||
15 years ago
|
setChanged(true);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
*
|
||
|
* Border
|
||
|
*
|
||
|
***************************************************************************/
|
||
|
|
||
13 years ago
|
Border::Border( TQWidget *parent, const char *_name,bool _oneCol, bool _oneRow )
|
||
|
: TQFrame( parent, _name )
|
||
15 years ago
|
{
|
||
|
oneCol=_oneCol;
|
||
|
oneRow=_oneRow;
|
||
|
}
|
||
|
|
||
|
|
||
|
#define OFFSETX 5
|
||
|
#define OFFSETY 5
|
||
14 years ago
|
void Border::paintEvent( TQPaintEvent *_ev )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQFrame::paintEvent( _ev );
|
||
|
TQPen pen;
|
||
|
TQPainter painter;
|
||
15 years ago
|
painter.begin( this );
|
||
13 years ago
|
pen=TQPen( colorGroup().midlight(),2,SolidLine);
|
||
15 years ago
|
painter.setPen( pen );
|
||
|
|
||
|
painter.drawLine( OFFSETX-5, OFFSETY, OFFSETX , OFFSETY );
|
||
|
painter.drawLine( OFFSETX, OFFSETY-5, OFFSETX , OFFSETY );
|
||
|
painter.drawLine( width()-OFFSETX, OFFSETY, width() , OFFSETY );
|
||
|
painter.drawLine( width()-OFFSETX, OFFSETY-5, width()-OFFSETX , OFFSETY );
|
||
|
|
||
|
painter.drawLine( OFFSETX, height()-OFFSETY, OFFSETX , height() );
|
||
|
painter.drawLine( OFFSETX-5, height()-OFFSETY, OFFSETX , height()-OFFSETY );
|
||
|
|
||
|
painter.drawLine( width()-OFFSETX, height()-OFFSETY, width() , height()-OFFSETY );
|
||
|
painter.drawLine( width()-OFFSETX, height()-OFFSETY, width()-OFFSETX , height() );
|
||
|
if (oneCol==false)
|
||
|
{
|
||
|
painter.drawLine( width()/2, OFFSETY-5, width()/2 , OFFSETY );
|
||
|
painter.drawLine( width()/2-5, OFFSETY, width()/2+5 , OFFSETY );
|
||
|
painter.drawLine( width()/2, height()-OFFSETY, width()/2 , height() );
|
||
|
painter.drawLine( width()/2-5, height()-OFFSETY, width()/2+5 , height()-OFFSETY );
|
||
|
}
|
||
|
if (oneRow==false)
|
||
|
{
|
||
|
painter.drawLine( OFFSETX-5, height()/2, OFFSETX , height()/2 );
|
||
|
painter.drawLine( OFFSETX, height()/2-5, OFFSETX , height()/2+5 );
|
||
|
painter.drawLine( width()-OFFSETX, height()/2, width(), height()/2 );
|
||
|
painter.drawLine( width()-OFFSETX, height()/2-5, width()-OFFSETX , height()/2+5 );
|
||
|
}
|
||
|
painter.end();
|
||
|
emit redraw();
|
||
|
}
|
||
|
|
||
14 years ago
|
void Border::mousePressEvent( TQMouseEvent* _ev )
|
||
15 years ago
|
{
|
||
|
emit choosearea(_ev);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
*
|
||
|
* CellFormatPageBorder
|
||
|
*
|
||
|
***************************************************************************/
|
||
|
|
||
13 years ago
|
CellFormatPageBorder::CellFormatPageBorder( TQWidget* parent, CellFormatDialog *_dlg )
|
||
|
: TQWidget( parent ),
|
||
15 years ago
|
dlg( _dlg )
|
||
|
{
|
||
|
sheet = dlg->getSheet();
|
||
|
|
||
|
InitializeGrids();
|
||
|
InitializeBorderButtons();
|
||
|
InitializePatterns();
|
||
|
SetConnections();
|
||
|
|
||
|
preview->slotSelect();
|
||
|
pattern[2]->slotSelect();
|
||
|
|
||
|
style->setEnabled(false);
|
||
|
size->setEnabled(false);
|
||
14 years ago
|
preview->setPattern( black , 1, Qt::SolidLine );
|
||
15 years ago
|
this->resize( 400, 400 );
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::InitializeGrids()
|
||
|
{
|
||
14 years ago
|
TQGridLayout *grid = new TQGridLayout(this,5,2,KDialog::marginHint(), KDialog::spacingHint());
|
||
|
TQGridLayout *grid2 = NULL;
|
||
|
TQGroupBox* tmpTQGroupBox = NULL;
|
||
15 years ago
|
|
||
|
/***********************/
|
||
|
/* here is the data to initialize all the border buttons with */
|
||
|
const char borderButtonNames[BorderType_END][20] =
|
||
|
{"top", "bottom", "left", "right", "vertical", "fall", "go", "horizontal"};
|
||
|
|
||
|
const char shortcutButtonNames[BorderShortcutType_END][20] =
|
||
|
{"remove", "all", "outline"};
|
||
|
|
||
14 years ago
|
TQString borderButtonIconNames[BorderType_END] =
|
||
15 years ago
|
{"border_top", "border_bottom", "border_left", "border_right",
|
||
|
"border_vertical", "border_horizontal", "border_fall", "border_up"};
|
||
|
|
||
14 years ago
|
TQString shortcutButtonIconNames[BorderShortcutType_END] =
|
||
15 years ago
|
{ "border_remove", "", "border_outline"};
|
||
|
|
||
|
int borderButtonPositions[BorderType_END][2] =
|
||
|
{{0,2}, {4,2}, {2,0}, {2,4}, {4,4}, {4,0}, {0,0}, {0,4}};
|
||
|
|
||
|
int shortcutButtonPositions[BorderShortcutType_END][2] =
|
||
|
{ {0,0}, {0,1},{0,2} };
|
||
|
/***********************/
|
||
|
|
||
13 years ago
|
/* set up a layout box for most of the border setting buttons */
|
||
14 years ago
|
tmpTQGroupBox = new TQGroupBox( this, "GroupBox_1" );
|
||
|
tmpTQGroupBox->setFrameStyle( TQFrame::Box | TQFrame::Sunken );
|
||
|
tmpTQGroupBox->setTitle( i18n("Border") );
|
||
13 years ago
|
tmpTQGroupBox->setAlignment( AlignLeft );
|
||
14 years ago
|
grid2 = new TQGridLayout(tmpTQGroupBox,6,5,KDialog::marginHint(), KDialog::spacingHint());
|
||
|
int fHeight = tmpTQGroupBox->fontMetrics().height();
|
||
15 years ago
|
grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
|
||
|
|
||
14 years ago
|
area=new Border(tmpTQGroupBox,"area",dlg->oneCol,dlg->oneRow);
|
||
15 years ago
|
grid2->addMultiCellWidget(area,2,4,1,3);
|
||
13 years ago
|
area->setBackgroundColor( colorGroup().base() );
|
||
15 years ago
|
|
||
|
/* initailize the buttons that are in this box */
|
||
|
for (int i=BorderType_Top; i < BorderType_END; i++)
|
||
|
{
|
||
14 years ago
|
borderButtons[i] = new BorderButton(tmpTQGroupBox,
|
||
15 years ago
|
borderButtonNames[i]);
|
||
|
loadIcon(borderButtonIconNames[i], borderButtons[i]);
|
||
|
grid2->addWidget(borderButtons[i], borderButtonPositions[i][0] + 1,
|
||
|
borderButtonPositions[i][1]);
|
||
|
}
|
||
|
|
||
14 years ago
|
grid->addMultiCellWidget(tmpTQGroupBox,0,2,0,0);
|
||
15 years ago
|
|
||
|
/* the remove, all, and outline border buttons are in a second box down
|
||
|
below.*/
|
||
|
|
||
14 years ago
|
tmpTQGroupBox = new TQGroupBox( this, "GroupBox_3" );
|
||
|
tmpTQGroupBox->setFrameStyle( TQFrame::Box | TQFrame::Sunken );
|
||
|
tmpTQGroupBox->setTitle( i18n("Preselect") );
|
||
13 years ago
|
tmpTQGroupBox->setAlignment( AlignLeft );
|
||
15 years ago
|
|
||
14 years ago
|
grid2 = new TQGridLayout(tmpTQGroupBox,1,3,KDialog::marginHint(), KDialog::spacingHint());
|
||
15 years ago
|
|
||
|
/* the "all" button is different depending on what kind of region is currently
|
||
|
selected */
|
||
|
if ((dlg->oneRow==true)&&(dlg->oneCol==false))
|
||
|
{
|
||
|
shortcutButtonIconNames[BorderShortcutType_All] = "border_vertical";
|
||
|
}
|
||
|
else if ((dlg->oneRow==false)&&(dlg->oneCol==true))
|
||
|
{
|
||
|
shortcutButtonIconNames[BorderShortcutType_All] = "border_horizontal";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
shortcutButtonIconNames[BorderShortcutType_All] = "border_inside";
|
||
|
}
|
||
|
|
||
|
for (int i=BorderShortcutType_Remove; i < BorderShortcutType_END; i++)
|
||
|
{
|
||
14 years ago
|
shortcutButtons[i] = new BorderButton(tmpTQGroupBox,
|
||
15 years ago
|
shortcutButtonNames[i]);
|
||
|
loadIcon(shortcutButtonIconNames[i], shortcutButtons[i]);
|
||
|
grid2->addWidget(shortcutButtons[i], shortcutButtonPositions[i][0],
|
||
|
shortcutButtonPositions[i][1]);
|
||
|
}
|
||
|
|
||
|
if (dlg->oneRow && dlg->oneCol)
|
||
|
{
|
||
|
shortcutButtons[BorderShortcutType_All]->setEnabled(false);
|
||
|
}
|
||
|
|
||
14 years ago
|
grid->addMultiCellWidget(tmpTQGroupBox,3,4,0,0);
|
||
15 years ago
|
|
||
|
/* now set up the group box with the pattern selector */
|
||
14 years ago
|
tmpTQGroupBox = new TQGroupBox( this, "GroupBox_10" );
|
||
|
tmpTQGroupBox->setFrameStyle( TQFrame::Box | TQFrame::Sunken );
|
||
|
tmpTQGroupBox->setTitle( i18n("Pattern") );
|
||
13 years ago
|
tmpTQGroupBox->setAlignment( AlignLeft );
|
||
15 years ago
|
|
||
14 years ago
|
grid2 = new TQGridLayout(tmpTQGroupBox,7,2,KDialog::marginHint(), KDialog::spacingHint());
|
||
|
fHeight = tmpTQGroupBox->fontMetrics().height();
|
||
15 years ago
|
grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
|
||
|
|
||
|
char name[] = "PatternXX";
|
||
|
Q_ASSERT(NUM_BORDER_PATTERNS < 100);
|
||
|
|
||
|
for (int i=0; i < NUM_BORDER_PATTERNS; i++)
|
||
|
{
|
||
|
name[7] = '0' + (i+1) / 10;
|
||
|
name[8] = '0' + (i+1) % 10;
|
||
14 years ago
|
pattern[i] = new PatternSelect( tmpTQGroupBox, name );
|
||
|
pattern[i]->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(pattern[i], i % 5 + 1, i / 5);
|
||
|
/* this puts them in the pattern:
|
||
|
1 6
|
||
|
2 7
|
||
|
3 8
|
||
|
4 9
|
||
|
5 10
|
||
|
*/
|
||
|
}
|
||
|
|
||
14 years ago
|
color = new KColorButton (tmpTQGroupBox, "PushButton_1" );
|
||
15 years ago
|
grid2->addWidget(color,7,1);
|
||
|
|
||
14 years ago
|
TQLabel *tmpTQLabel = new TQLabel( tmpTQGroupBox, "Label_6" );
|
||
|
tmpTQLabel->setText( i18n("Color:") );
|
||
|
grid2->addWidget(tmpTQLabel,7,0);
|
||
15 years ago
|
|
||
|
/* tack on the 'customize' border pattern selector */
|
||
14 years ago
|
TQGridLayout *grid3 = new TQGridLayout( this, 2, 2, KDialog::marginHint(), KDialog::spacingHint() );
|
||
|
customize = new TQCheckBox(i18n("Customize"),tmpTQGroupBox);
|
||
15 years ago
|
grid3->addWidget(customize,0,0);
|
||
14 years ago
|
connect( customize, TQT_SIGNAL( clicked()), TQT_SLOT(cutomize_chosen_slot()) );
|
||
15 years ago
|
|
||
14 years ago
|
size=new TQComboBox(true,tmpTQGroupBox);
|
||
15 years ago
|
grid3->addWidget(size,1,1);
|
||
|
size->setValidator(new KIntValidator( size ));
|
||
14 years ago
|
TQString tmp;
|
||
15 years ago
|
for ( int i=0;i<10;i++)
|
||
|
{
|
||
|
tmp=tmp.setNum(i);
|
||
|
size->insertItem(tmp);
|
||
|
}
|
||
|
size->setCurrentItem(1);
|
||
|
|
||
14 years ago
|
style=new TQComboBox(tmpTQGroupBox);
|
||
15 years ago
|
grid3->addWidget(style,1,0);
|
||
|
style->insertItem(paintFormatPixmap(DotLine),0 );
|
||
|
style->insertItem(paintFormatPixmap(DashLine) ,1);
|
||
|
style->insertItem(paintFormatPixmap(DashDotLine),2 );
|
||
|
style->insertItem(paintFormatPixmap(DashDotDotLine),3 );
|
||
|
style->insertItem(paintFormatPixmap(SolidLine),4);
|
||
13 years ago
|
style->setBackgroundColor( colorGroup().background() );
|
||
15 years ago
|
|
||
|
grid2->addMultiCell(grid3,6,6,0,1);
|
||
14 years ago
|
grid->addMultiCellWidget(tmpTQGroupBox,0,3,1,1);
|
||
15 years ago
|
|
||
|
/* Now the preview box is put together */
|
||
14 years ago
|
tmpTQGroupBox = new TQGroupBox(this, "GroupBox_4" );
|
||
|
tmpTQGroupBox->setFrameStyle( TQFrame::Box | TQFrame::Sunken );
|
||
|
tmpTQGroupBox->setTitle( i18n("Preview") );
|
||
13 years ago
|
tmpTQGroupBox->setAlignment( AlignLeft );
|
||
15 years ago
|
|
||
14 years ago
|
grid2 = new TQGridLayout(tmpTQGroupBox,1,1,KDialog::marginHint(), KDialog::spacingHint());
|
||
|
fHeight = tmpTQGroupBox->fontMetrics().height();
|
||
15 years ago
|
grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
|
||
|
|
||
14 years ago
|
preview = new PatternSelect( tmpTQGroupBox, "Pattern_preview" );
|
||
|
preview->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(preview,1,0);
|
||
|
|
||
14 years ago
|
grid->addWidget(tmpTQGroupBox,4,1);
|
||
15 years ago
|
}
|
||
|
|
||
|
void CellFormatPageBorder::InitializeBorderButtons()
|
||
|
{
|
||
|
for (int i=BorderType_Top; i < BorderType_END; i++)
|
||
|
{
|
||
14 years ago
|
if (dlg->borders[i].style != TQt::NoPen ||
|
||
15 years ago
|
!dlg->borders[i].bStyle )
|
||
|
{
|
||
|
/* the horozontil and vertical buttons might be disabled depending on what
|
||
|
kind of area is selected so check that first. */
|
||
|
if ((dlg->oneRow == true && i == BorderType_Horizontal) ||
|
||
|
(dlg->oneCol == true && i == BorderType_Vertical))
|
||
|
{
|
||
|
borderButtons[i]->setEnabled(false);
|
||
|
}
|
||
|
else if ( dlg->borders[i].bColor && dlg->borders[i].bStyle )
|
||
|
{
|
||
|
borderButtons[i]->setPenStyle(dlg->borders[i].style );
|
||
|
borderButtons[i]->setPenWidth(dlg->borders[i].width);
|
||
|
borderButtons[i]->setColor(dlg->borders[i].color);
|
||
|
borderButtons[i]->setOn(true);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
borderButtons[i]->setUndefined();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::InitializePatterns()
|
||
|
{
|
||
14 years ago
|
pattern[0]->setPattern( black, 1, Qt::DotLine );
|
||
|
pattern[1]->setPattern( black, 1, Qt::DashLine );
|
||
|
pattern[2]->setPattern( black, 1, Qt::SolidLine );
|
||
|
pattern[3]->setPattern( black, 1, Qt::DashDotLine );
|
||
|
pattern[4]->setPattern( black, 1, Qt::DashDotDotLine );
|
||
|
pattern[5]->setPattern( black, 2, Qt::SolidLine );
|
||
|
pattern[6]->setPattern( black, 3, Qt::SolidLine );
|
||
|
pattern[7]->setPattern( black, 4, Qt::SolidLine );
|
||
|
pattern[8]->setPattern( black, 5, Qt::SolidLine );
|
||
|
pattern[9]->setPattern( black, 1, Qt::NoPen );
|
||
15 years ago
|
|
||
|
slotSetColorButton( black );
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::SetConnections()
|
||
|
{
|
||
14 years ago
|
connect( color, TQT_SIGNAL( changed( const TQColor & ) ),
|
||
|
this, TQT_SLOT( slotSetColorButton( const TQColor & ) ) );
|
||
15 years ago
|
|
||
|
for (int i=0; i < NUM_BORDER_PATTERNS; i++)
|
||
|
{
|
||
14 years ago
|
connect( pattern[i], TQT_SIGNAL( clicked( PatternSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( PatternSelect* ) ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
for (int i = BorderType_Top; i < BorderType_END; i++)
|
||
|
{
|
||
14 years ago
|
connect( borderButtons[i], TQT_SIGNAL( clicked (BorderButton *) ),
|
||
|
this, TQT_SLOT( changeState( BorderButton *) ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
for (int i = BorderShortcutType_Remove; i < BorderShortcutType_END; i++)
|
||
|
{
|
||
14 years ago
|
connect( shortcutButtons[i], TQT_SIGNAL( clicked(BorderButton *) ),
|
||
|
this, TQT_SLOT( preselect(BorderButton *) ) );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
connect( area ,TQT_SIGNAL( redraw()),this,TQT_SLOT(draw()));
|
||
|
connect( area ,TQT_SIGNAL( choosearea(TQMouseEvent * )),
|
||
|
this,TQT_SLOT( slotPressEvent(TQMouseEvent *)));
|
||
15 years ago
|
|
||
14 years ago
|
connect( style, TQT_SIGNAL( activated(int)), this, TQT_SLOT(slotChangeStyle(int)));
|
||
|
connect( size, TQT_SIGNAL( textChanged(const TQString &)),
|
||
|
this, TQT_SLOT(slotChangeStyle(const TQString &)));
|
||
|
connect( size ,TQT_SIGNAL( activated(int)), this, TQT_SLOT(slotChangeStyle(int)));
|
||
15 years ago
|
}
|
||
|
|
||
|
void CellFormatPageBorder::cutomize_chosen_slot()
|
||
|
{
|
||
|
if ( customize->isChecked() )
|
||
|
{
|
||
|
style->setEnabled( true );
|
||
|
size->setEnabled( true );
|
||
|
slotUnselect2( preview );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
style->setEnabled( false );
|
||
|
size->setEnabled( false );
|
||
|
pattern[2]->slotSelect();
|
||
14 years ago
|
preview->setPattern( black , 1, Qt::SolidLine );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void CellFormatPageBorder::slotChangeStyle(const TQString &)
|
||
15 years ago
|
{
|
||
|
/* if they try putting text in the size box, then erase the line */
|
||
|
slotChangeStyle(0);
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::slotChangeStyle(int)
|
||
|
{
|
||
|
int index = style->currentItem();
|
||
14 years ago
|
TQString tmp;
|
||
15 years ago
|
int penSize = size->currentText().toInt();
|
||
|
if ( !penSize)
|
||
|
{
|
||
14 years ago
|
preview->setPattern( preview->getColor(), penSize, Qt::NoPen );
|
||
15 years ago
|
}
|
||
|
else
|
||
|
{
|
||
|
switch(index)
|
||
|
{
|
||
|
case 0:
|
||
14 years ago
|
preview->setPattern( preview->getColor(), penSize, Qt::DotLine );
|
||
15 years ago
|
break;
|
||
|
case 1:
|
||
14 years ago
|
preview->setPattern( preview->getColor(), penSize, Qt::DashLine );
|
||
15 years ago
|
break;
|
||
|
case 2:
|
||
14 years ago
|
preview->setPattern( preview->getColor(), penSize, Qt::DashDotLine );
|
||
15 years ago
|
break;
|
||
|
case 3:
|
||
14 years ago
|
preview->setPattern( preview->getColor(), penSize, Qt::DashDotDotLine );
|
||
15 years ago
|
break;
|
||
|
case 4:
|
||
14 years ago
|
preview->setPattern( preview->getColor(), penSize, Qt::SolidLine );
|
||
15 years ago
|
break;
|
||
|
default:
|
||
|
kdDebug(36001)<<"Error in combobox\n";
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
slotUnselect2(preview);
|
||
|
}
|
||
|
|
||
14 years ago
|
TQPixmap CellFormatPageBorder::paintFormatPixmap(PenStyle _style)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQPixmap pixmap( style->width(), 14 );
|
||
|
TQPainter painter;
|
||
|
TQPen pen;
|
||
13 years ago
|
pen=TQPen( colorGroup().text(),1,_style);
|
||
15 years ago
|
painter.begin( &pixmap );
|
||
13 years ago
|
painter.fillRect( 0, 0, style->width(), 14, colorGroup().background() );
|
||
15 years ago
|
painter.setPen( pen );
|
||
|
painter.drawLine( 0, 7, style->width(), 7 );
|
||
|
painter.end();
|
||
|
return pixmap;
|
||
|
}
|
||
|
|
||
14 years ago
|
void CellFormatPageBorder::loadIcon( TQString _pix, BorderButton *_button)
|
||
15 years ago
|
{
|
||
14 years ago
|
_button->setPixmap( TQPixmap( BarIcon(_pix, Factory::global()) ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
void CellFormatPageBorder::apply(FormatManipulator* obj)
|
||
|
{
|
||
|
if (borderButtons[BorderType_Horizontal]->isChanged())
|
||
|
applyHorizontalOutline(obj);
|
||
|
|
||
|
if (borderButtons[BorderType_Vertical]->isChanged())
|
||
|
applyVerticalOutline(obj);
|
||
|
|
||
|
if ( borderButtons[BorderType_Left]->isChanged() )
|
||
|
applyLeftOutline(obj);
|
||
|
|
||
|
if ( borderButtons[BorderType_Right]->isChanged() )
|
||
|
applyRightOutline(obj);
|
||
|
|
||
|
if ( borderButtons[BorderType_Top]->isChanged() )
|
||
|
applyTopOutline(obj);
|
||
|
|
||
|
if ( borderButtons[BorderType_Bottom]->isChanged() )
|
||
|
applyBottomOutline(obj);
|
||
|
|
||
|
if ( borderButtons[BorderType_RisingDiagonal]->isChanged() ||
|
||
|
borderButtons[BorderType_FallingDiagonal]->isChanged() )
|
||
|
applyDiagonalOutline(obj);
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::applyTopOutline(FormatManipulator* obj)
|
||
|
{
|
||
|
BorderButton * top = borderButtons[BorderType_Top];
|
||
|
|
||
14 years ago
|
TQPen tmpPen( top->getColor(), top->getPenWidth(), top->getPenStyle());
|
||
15 years ago
|
|
||
|
if ( dlg->getStyle() )
|
||
|
{
|
||
|
dlg->getStyle()->changeTopBorderPen( tmpPen );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (borderButtons[BorderType_Top]->isChanged())
|
||
|
obj->setTopBorderPen( tmpPen );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::applyBottomOutline(FormatManipulator* obj)
|
||
|
{
|
||
|
BorderButton * bottom = borderButtons[BorderType_Bottom];
|
||
|
|
||
14 years ago
|
TQPen tmpPen( bottom->getColor(), bottom->getPenWidth(), bottom->getPenStyle() );
|
||
15 years ago
|
|
||
|
if ( dlg->getStyle() )
|
||
|
{
|
||
|
dlg->getStyle()->changeBottomBorderPen( tmpPen );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (borderButtons[BorderType_Bottom]->isChanged())
|
||
|
obj->setBottomBorderPen( tmpPen );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::applyLeftOutline(FormatManipulator* obj)
|
||
|
{
|
||
|
BorderButton * left = borderButtons[BorderType_Left];
|
||
14 years ago
|
TQPen tmpPen( left->getColor(), left->getPenWidth(), left->getPenStyle() );
|
||
15 years ago
|
|
||
|
if ( dlg->getStyle() )
|
||
|
{
|
||
|
dlg->getStyle()->changeLeftBorderPen( tmpPen );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (borderButtons[BorderType_Left]->isChanged())
|
||
|
obj->setLeftBorderPen( tmpPen );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::applyRightOutline(FormatManipulator* obj)
|
||
|
{
|
||
|
BorderButton* right = borderButtons[BorderType_Right];
|
||
14 years ago
|
TQPen tmpPen( right->getColor(), right->getPenWidth(), right->getPenStyle() );
|
||
15 years ago
|
|
||
|
if ( dlg->getStyle() )
|
||
|
{
|
||
|
dlg->getStyle()->changeRightBorderPen( tmpPen );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (borderButtons[BorderType_Right]->isChanged())
|
||
|
obj->setRightBorderPen( tmpPen );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::applyDiagonalOutline(FormatManipulator* obj)
|
||
|
{
|
||
|
BorderButton * fallDiagonal = borderButtons[BorderType_FallingDiagonal];
|
||
|
BorderButton * goUpDiagonal = borderButtons[BorderType_RisingDiagonal];
|
||
14 years ago
|
TQPen tmpPenFall( fallDiagonal->getColor(), fallDiagonal->getPenWidth(),
|
||
15 years ago
|
fallDiagonal->getPenStyle());
|
||
14 years ago
|
TQPen tmpPenGoUp( goUpDiagonal->getColor(), goUpDiagonal->getPenWidth(),
|
||
15 years ago
|
goUpDiagonal->getPenStyle());
|
||
|
|
||
|
if ( dlg->getStyle() )
|
||
|
{
|
||
|
if ( fallDiagonal->isChanged() )
|
||
|
dlg->getStyle()->changeFallBorderPen( tmpPenFall );
|
||
|
if ( goUpDiagonal->isChanged() )
|
||
|
dlg->getStyle()->changeGoUpBorderPen( tmpPenGoUp );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if ( fallDiagonal->isChanged() )
|
||
|
obj->setFallDiagonalPen( tmpPenFall );
|
||
|
if ( goUpDiagonal->isChanged() )
|
||
|
obj->setGoUpDiagonalPen( tmpPenGoUp );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::applyHorizontalOutline(FormatManipulator* obj)
|
||
|
{
|
||
14 years ago
|
TQPen tmpPen( borderButtons[BorderType_Horizontal]->getColor(),
|
||
15 years ago
|
borderButtons[BorderType_Horizontal]->getPenWidth(),
|
||
|
borderButtons[BorderType_Horizontal]->getPenStyle());
|
||
|
|
||
|
if ( dlg->getStyle() )
|
||
|
{
|
||
|
dlg->getStyle()->changeTopBorderPen( tmpPen );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (borderButtons[BorderType_Horizontal]->isChanged())
|
||
|
obj->setHorizontalPen( tmpPen );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::applyVerticalOutline(FormatManipulator* obj)
|
||
|
{
|
||
|
BorderButton* vertical = borderButtons[BorderType_Vertical];
|
||
14 years ago
|
TQPen tmpPen( vertical->getColor(), vertical->getPenWidth(),
|
||
15 years ago
|
vertical->getPenStyle());
|
||
|
|
||
|
if ( dlg->getStyle() )
|
||
|
{
|
||
|
dlg->getStyle()->changeLeftBorderPen( tmpPen );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (borderButtons[BorderType_Vertical]->isChanged())
|
||
|
obj->setVerticalPen( tmpPen );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
void CellFormatPageBorder::slotSetColorButton( const TQColor &_color )
|
||
15 years ago
|
{
|
||
|
currentColor = _color;
|
||
|
|
||
|
for ( int i = 0; i < NUM_BORDER_PATTERNS; ++i )
|
||
|
{
|
||
|
pattern[i]->setColor( currentColor );
|
||
|
}
|
||
|
preview->setColor( currentColor );
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::slotUnselect2( PatternSelect *_p )
|
||
|
{
|
||
|
for ( int i = 0; i < NUM_BORDER_PATTERNS; ++i )
|
||
|
{
|
||
|
if ( pattern[i] != _p )
|
||
|
{
|
||
|
pattern[i]->slotUnselect();
|
||
|
}
|
||
|
}
|
||
|
preview->setPattern( _p->getColor(), _p->getPenWidth(), _p->getPenStyle() );
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::preselect( BorderButton *_p )
|
||
|
{
|
||
|
BorderButton* top = borderButtons[BorderType_Top];
|
||
|
BorderButton* bottom = borderButtons[BorderType_Bottom];
|
||
|
BorderButton* left = borderButtons[BorderType_Left];
|
||
|
BorderButton* right = borderButtons[BorderType_Right];
|
||
|
BorderButton* vertical = borderButtons[BorderType_Vertical];
|
||
|
BorderButton* horizontal = borderButtons[BorderType_Horizontal];
|
||
|
BorderButton* remove = shortcutButtons[BorderShortcutType_Remove];
|
||
|
BorderButton* outline = shortcutButtons[BorderShortcutType_Outline];
|
||
|
BorderButton* all = shortcutButtons[BorderShortcutType_All];
|
||
|
|
||
|
_p->setOn(false);
|
||
|
if (_p == remove)
|
||
|
{
|
||
|
for (int i=BorderType_Top; i < BorderType_END; i++)
|
||
|
{
|
||
|
if (borderButtons[i]->isOn())
|
||
|
{
|
||
|
borderButtons[i]->unselect();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (_p==outline)
|
||
|
{
|
||
|
top->setOn(true);
|
||
|
top->setPenWidth(preview->getPenWidth());
|
||
|
top->setPenStyle(preview->getPenStyle());
|
||
|
top->setColor( currentColor );
|
||
|
top->setChanged(true);
|
||
|
bottom->setOn(true);
|
||
|
bottom->setPenWidth(preview->getPenWidth());
|
||
|
bottom->setPenStyle(preview->getPenStyle());
|
||
|
bottom->setColor( currentColor );
|
||
|
bottom->setChanged(true);
|
||
|
left->setOn(true);
|
||
|
left->setPenWidth(preview->getPenWidth());
|
||
|
left->setPenStyle(preview->getPenStyle());
|
||
|
left->setColor( currentColor );
|
||
|
left->setChanged(true);
|
||
|
right->setOn(true);
|
||
|
right->setPenWidth(preview->getPenWidth());
|
||
|
right->setPenStyle(preview->getPenStyle());
|
||
|
right->setColor( currentColor );
|
||
|
right->setChanged(true);
|
||
|
}
|
||
|
if (_p==all)
|
||
|
{
|
||
|
if (dlg->oneRow==false)
|
||
|
{
|
||
|
horizontal->setOn(true);
|
||
|
horizontal->setPenWidth(preview->getPenWidth());
|
||
|
horizontal->setPenStyle(preview->getPenStyle());
|
||
|
horizontal->setColor( currentColor );
|
||
|
horizontal->setChanged(true);
|
||
|
}
|
||
|
if (dlg->oneCol==false)
|
||
|
{
|
||
|
vertical->setOn(true);
|
||
|
vertical->setPenWidth(preview->getPenWidth());
|
||
|
vertical->setPenStyle(preview->getPenStyle());
|
||
|
vertical->setColor( currentColor );
|
||
|
vertical->setChanged(true);
|
||
|
}
|
||
|
}
|
||
13 years ago
|
area->repaint();
|
||
15 years ago
|
}
|
||
|
|
||
|
void CellFormatPageBorder::changeState( BorderButton *_p)
|
||
|
{
|
||
|
_p->setChanged(true);
|
||
|
|
||
|
if (_p->isOn())
|
||
|
{
|
||
|
_p->setPenWidth(preview->getPenWidth());
|
||
|
_p->setPenStyle(preview->getPenStyle());
|
||
|
_p->setColor( currentColor );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
_p->setPenWidth(1);
|
||
|
_p->setPenStyle(Qt::NoPen);
|
||
13 years ago
|
_p->setColor( colorGroup().text() );
|
||
15 years ago
|
}
|
||
|
|
||
13 years ago
|
area->repaint();
|
||
15 years ago
|
}
|
||
|
|
||
|
void CellFormatPageBorder::draw()
|
||
|
{
|
||
|
BorderButton* top = borderButtons[BorderType_Top];
|
||
|
BorderButton* bottom = borderButtons[BorderType_Bottom];
|
||
|
BorderButton* left = borderButtons[BorderType_Left];
|
||
|
BorderButton* right = borderButtons[BorderType_Right];
|
||
|
BorderButton* risingDiagonal = borderButtons[BorderType_RisingDiagonal];
|
||
|
BorderButton* fallingDiagonal = borderButtons[BorderType_FallingDiagonal];
|
||
|
BorderButton* vertical = borderButtons[BorderType_Vertical];
|
||
|
BorderButton* horizontal = borderButtons[BorderType_Horizontal];
|
||
14 years ago
|
TQPen pen;
|
||
|
TQPainter painter;
|
||
15 years ago
|
painter.begin( area );
|
||
|
|
||
14 years ago
|
if ((bottom->getPenStyle())!=TQt::NoPen)
|
||
15 years ago
|
{
|
||
14 years ago
|
pen=TQPen( bottom->getColor(), bottom->getPenWidth(),bottom->getPenStyle());
|
||
15 years ago
|
painter.setPen( pen );
|
||
|
painter.drawLine( OFFSETX, area->height()-OFFSETY, area->width()-OFFSETX , area->height()-OFFSETY );
|
||
|
}
|
||
14 years ago
|
if ((top->getPenStyle())!=TQt::NoPen)
|
||
15 years ago
|
{
|
||
14 years ago
|
pen=TQPen( top->getColor(), top->getPenWidth(),top->getPenStyle());
|
||
15 years ago
|
painter.setPen( pen );
|
||
|
painter.drawLine( OFFSETX, OFFSETY, area->width() -OFFSETX, OFFSETY );
|
||
|
}
|
||
14 years ago
|
if ((left->getPenStyle())!=TQt::NoPen)
|
||
15 years ago
|
{
|
||
14 years ago
|
pen=TQPen( left->getColor(), left->getPenWidth(),left->getPenStyle());
|
||
15 years ago
|
painter.setPen( pen );
|
||
|
painter.drawLine( OFFSETX, OFFSETY, OFFSETX , area->height()-OFFSETY );
|
||
|
}
|
||
14 years ago
|
if ((right->getPenStyle())!=TQt::NoPen)
|
||
15 years ago
|
{
|
||
14 years ago
|
pen=TQPen( right->getColor(), right->getPenWidth(),right->getPenStyle());
|
||
15 years ago
|
painter.setPen( pen );
|
||
|
painter.drawLine( area->width()-OFFSETX, OFFSETY, area->width()-OFFSETX,
|
||
|
area->height()-OFFSETY );
|
||
|
|
||
|
}
|
||
14 years ago
|
if ((fallingDiagonal->getPenStyle())!=TQt::NoPen)
|
||
15 years ago
|
{
|
||
14 years ago
|
pen=TQPen( fallingDiagonal->getColor(), fallingDiagonal->getPenWidth(),
|
||
15 years ago
|
fallingDiagonal->getPenStyle());
|
||
|
painter.setPen( pen );
|
||
|
painter.drawLine( OFFSETX, OFFSETY, area->width()-OFFSETX,
|
||
|
area->height()-OFFSETY );
|
||
|
if (dlg->oneCol==false&& dlg->oneRow==false)
|
||
|
{
|
||
|
painter.drawLine( area->width()/2, OFFSETY, area->width()-OFFSETX,
|
||
|
area->height()/2 );
|
||
|
painter.drawLine( OFFSETX,area->height()/2 , area->width()/2,
|
||
|
area->height()-OFFSETY );
|
||
|
}
|
||
|
}
|
||
14 years ago
|
if ((risingDiagonal->getPenStyle())!=TQt::NoPen)
|
||
15 years ago
|
{
|
||
14 years ago
|
pen=TQPen( risingDiagonal->getColor(), risingDiagonal->getPenWidth(),
|
||
15 years ago
|
risingDiagonal->getPenStyle());
|
||
|
painter.setPen( pen );
|
||
|
painter.drawLine( OFFSETX, area->height()-OFFSETY , area->width()-OFFSETX ,
|
||
|
OFFSETY );
|
||
|
if (dlg->oneCol==false&& dlg->oneRow==false)
|
||
|
{
|
||
|
painter.drawLine( area->width()/2, OFFSETY, OFFSETX, area->height()/2 );
|
||
|
painter.drawLine( area->width()/2,area->height()-OFFSETY ,
|
||
|
area->width()-OFFSETX, area->height()/2 );
|
||
|
}
|
||
|
|
||
|
}
|
||
14 years ago
|
if ((vertical->getPenStyle())!=TQt::NoPen)
|
||
15 years ago
|
{
|
||
14 years ago
|
pen=TQPen( vertical->getColor(), vertical->getPenWidth(),
|
||
15 years ago
|
vertical->getPenStyle());
|
||
|
painter.setPen( pen );
|
||
|
painter.drawLine( area->width()/2, 5 , area->width()/2 , area->height()-5 );
|
||
|
}
|
||
14 years ago
|
if ((horizontal->getPenStyle())!=TQt::NoPen)
|
||
15 years ago
|
{
|
||
14 years ago
|
pen=TQPen( horizontal->getColor(), horizontal->getPenWidth(),
|
||
15 years ago
|
horizontal->getPenStyle());
|
||
|
painter.setPen( pen );
|
||
|
painter.drawLine( OFFSETX,area->height()/2,area->width()-OFFSETX,
|
||
|
area->height()/2 );
|
||
|
}
|
||
|
painter.end();
|
||
|
}
|
||
|
|
||
|
void CellFormatPageBorder::invertState(BorderButton *_p)
|
||
|
{
|
||
|
if (_p->isOn())
|
||
|
{
|
||
|
_p->unselect();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
_p->setOn(true);
|
||
|
_p->setPenWidth(preview->getPenWidth());
|
||
|
_p->setPenStyle(preview->getPenStyle());
|
||
|
_p->setColor( currentColor );
|
||
|
_p->setChanged(true);
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void CellFormatPageBorder::slotPressEvent(TQMouseEvent *_ev)
|
||
15 years ago
|
{
|
||
|
BorderButton* top = borderButtons[BorderType_Top];
|
||
|
BorderButton* bottom = borderButtons[BorderType_Bottom];
|
||
|
BorderButton* left = borderButtons[BorderType_Left];
|
||
|
BorderButton* right = borderButtons[BorderType_Right];
|
||
|
BorderButton* vertical = borderButtons[BorderType_Vertical];
|
||
|
BorderButton* horizontal = borderButtons[BorderType_Horizontal];
|
||
|
|
||
|
|
||
14 years ago
|
TQRect rect(OFFSETX,OFFSETY-8,area->width()-OFFSETX,OFFSETY+8);
|
||
13 years ago
|
if (rect.contains(TQPoint(_ev->x(),_ev->y())))
|
||
15 years ago
|
{
|
||
|
if (((top->getPenWidth()!=preview->getPenWidth()) ||
|
||
|
(top->getColor()!=currentColor) ||
|
||
|
(top->getPenStyle()!=preview->getPenStyle()))
|
||
|
&& top->isOn())
|
||
|
{
|
||
|
top->setPenWidth(preview->getPenWidth());
|
||
|
top->setPenStyle(preview->getPenStyle());
|
||
|
top->setColor( currentColor );
|
||
|
top->setChanged(true);
|
||
|
}
|
||
|
else
|
||
|
invertState(top);
|
||
|
}
|
||
|
rect.setCoords(OFFSETX,area->height()-OFFSETY-8,area->width()-OFFSETX,
|
||
|
area->height()-OFFSETY+8);
|
||
13 years ago
|
if (rect.contains(TQPoint(_ev->x(),_ev->y())))
|
||
15 years ago
|
{
|
||
|
if (((bottom->getPenWidth()!=preview->getPenWidth()) ||
|
||
|
(bottom->getColor()!=currentColor) ||
|
||
|
(bottom->getPenStyle()!=preview->getPenStyle()))
|
||
|
&& bottom->isOn())
|
||
|
{
|
||
|
bottom->setPenWidth(preview->getPenWidth());
|
||
|
bottom->setPenStyle(preview->getPenStyle());
|
||
|
bottom->setColor( currentColor );
|
||
|
bottom->setChanged(true);
|
||
|
}
|
||
|
else
|
||
|
invertState(bottom);
|
||
|
}
|
||
|
|
||
|
rect.setCoords(OFFSETX-8,OFFSETY,OFFSETX+8,area->height()-OFFSETY);
|
||
13 years ago
|
if (rect.contains(TQPoint(_ev->x(),_ev->y())))
|
||
15 years ago
|
{
|
||
|
if (((left->getPenWidth()!=preview->getPenWidth()) ||
|
||
|
(left->getColor()!=currentColor) ||
|
||
|
(left->getPenStyle()!=preview->getPenStyle()))
|
||
|
&& left->isOn())
|
||
|
{
|
||
|
left->setPenWidth(preview->getPenWidth());
|
||
|
left->setPenStyle(preview->getPenStyle());
|
||
|
left->setColor( currentColor );
|
||
|
left->setChanged(true);
|
||
|
}
|
||
|
else
|
||
|
invertState(left);
|
||
|
}
|
||
|
rect.setCoords(area->width()-OFFSETX-8,OFFSETY,area->width()-OFFSETX+8,
|
||
|
area->height()-OFFSETY);
|
||
13 years ago
|
if (rect.contains(TQPoint(_ev->x(),_ev->y())))
|
||
15 years ago
|
{
|
||
|
if (((right->getPenWidth()!=preview->getPenWidth()) ||
|
||
|
(right->getColor()!=currentColor) ||
|
||
|
(right->getPenStyle()!=preview->getPenStyle()))
|
||
|
&& right->isOn())
|
||
|
{
|
||
|
right->setPenWidth(preview->getPenWidth());
|
||
|
right->setPenStyle(preview->getPenStyle());
|
||
|
right->setColor( currentColor );
|
||
|
right->setChanged(true);
|
||
|
}
|
||
|
else
|
||
|
invertState(right);
|
||
|
}
|
||
|
|
||
|
//don't work because I don't know how create a rectangle
|
||
|
//for diagonal
|
||
|
/*rect.setCoords(OFFSETX,OFFSETY,XLEN-OFFSETX,YHEI-OFFSETY);
|
||
13 years ago
|
if (rect.contains(TQPoint(_ev->x(),_ev->y())))
|
||
15 years ago
|
{
|
||
|
invertState(fallDiagonal);
|
||
|
}
|
||
|
rect.setCoords(OFFSETX,YHEI-OFFSETY,XLEN-OFFSETX,OFFSETY);
|
||
13 years ago
|
if (rect.contains(TQPoint(_ev->x(),_ev->y())))
|
||
15 years ago
|
{
|
||
|
invertState(goUpDiagonal);
|
||
|
} */
|
||
|
|
||
|
if (dlg->oneCol==false)
|
||
|
{
|
||
|
rect.setCoords(area->width()/2-8,OFFSETY,area->width()/2+8,
|
||
|
area->height()-OFFSETY);
|
||
|
|
||
13 years ago
|
if (rect.contains(TQPoint(_ev->x(),_ev->y())))
|
||
15 years ago
|
{
|
||
|
if (((vertical->getPenWidth()!=preview->getPenWidth()) ||
|
||
|
(vertical->getColor()!=currentColor) ||
|
||
|
(vertical->getPenStyle()!=preview->getPenStyle()))
|
||
|
&& vertical->isOn())
|
||
|
{
|
||
|
vertical->setPenWidth(preview->getPenWidth());
|
||
|
vertical->setPenStyle(preview->getPenStyle());
|
||
|
vertical->setColor( currentColor );
|
||
|
vertical->setChanged(true);
|
||
|
}
|
||
|
else
|
||
|
invertState(vertical);
|
||
|
}
|
||
|
}
|
||
|
if (dlg->oneRow==false)
|
||
|
{
|
||
|
rect.setCoords(OFFSETX,area->height()/2-8,area->width()-OFFSETX,
|
||
|
area->height()/2+8);
|
||
13 years ago
|
if (rect.contains(TQPoint(_ev->x(),_ev->y())))
|
||
15 years ago
|
{
|
||
|
if (((horizontal->getPenWidth()!=preview->getPenWidth()) ||
|
||
|
(horizontal->getColor()!=currentColor) ||
|
||
|
(horizontal->getPenStyle()!=preview->getPenStyle()))
|
||
|
&& horizontal->isOn())
|
||
|
{
|
||
|
horizontal->setPenWidth(preview->getPenWidth());
|
||
|
horizontal->setPenStyle(preview->getPenStyle());
|
||
|
horizontal->setColor( currentColor );
|
||
|
horizontal->setChanged(true);
|
||
|
}
|
||
|
else
|
||
|
invertState(horizontal);
|
||
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
area->repaint();
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
*
|
||
|
* BrushSelect
|
||
|
*
|
||
|
***************************************************************************/
|
||
|
|
||
13 years ago
|
BrushSelect::BrushSelect( TQWidget *parent, const char * ) : TQFrame( parent )
|
||
15 years ago
|
{
|
||
|
brushStyle = Qt::NoBrush;
|
||
14 years ago
|
brushColor = TQt::red;
|
||
15 years ago
|
selected = false;
|
||
|
}
|
||
|
|
||
14 years ago
|
void BrushSelect::setPattern( const TQColor &_color,Qt::BrushStyle _style )
|
||
15 years ago
|
{
|
||
|
brushStyle = _style;
|
||
|
brushColor = _color;
|
||
13 years ago
|
repaint();
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
14 years ago
|
void BrushSelect::paintEvent( TQPaintEvent *_ev )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQFrame::paintEvent( _ev );
|
||
15 years ago
|
|
||
14 years ago
|
TQPainter painter;
|
||
|
TQBrush brush(brushColor,brushStyle);
|
||
15 years ago
|
painter.begin( this );
|
||
14 years ago
|
painter.setPen( TQt::NoPen );
|
||
15 years ago
|
painter.setBrush( brush);
|
||
|
painter.drawRect( 2, 2, width()-4, height()-4);
|
||
|
painter.end();
|
||
|
}
|
||
|
|
||
14 years ago
|
void BrushSelect::mousePressEvent( TQMouseEvent * )
|
||
15 years ago
|
{
|
||
|
slotSelect();
|
||
|
|
||
|
emit clicked( this );
|
||
|
}
|
||
|
|
||
|
void BrushSelect::slotUnselect()
|
||
|
{
|
||
|
selected = false;
|
||
|
|
||
|
setLineWidth( 1 );
|
||
14 years ago
|
setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
13 years ago
|
repaint();
|
||
15 years ago
|
}
|
||
|
|
||
|
void BrushSelect::slotSelect()
|
||
|
{
|
||
|
selected = true;
|
||
|
|
||
|
setLineWidth( 2 );
|
||
14 years ago
|
setFrameStyle( TQFrame::Panel | TQFrame::Plain );
|
||
13 years ago
|
repaint();
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
*
|
||
|
* CellFormatPagePattern
|
||
|
*
|
||
|
***************************************************************************/
|
||
|
|
||
13 years ago
|
CellFormatPagePattern::CellFormatPagePattern( TQWidget* parent, CellFormatDialog *_dlg ) : TQWidget( parent )
|
||
15 years ago
|
{
|
||
|
dlg = _dlg;
|
||
|
|
||
|
bBgColorUndefined = !dlg->bBgColor;
|
||
|
|
||
14 years ago
|
TQGridLayout *grid = new TQGridLayout(this,5,2,KDialog::marginHint(), KDialog::spacingHint());
|
||
15 years ago
|
|
||
14 years ago
|
TQGroupBox* tmpTQGroupBox;
|
||
|
tmpTQGroupBox = new TQGroupBox( this, "GroupBox_20" );
|
||
|
tmpTQGroupBox->setFrameStyle( TQFrame::Box | TQFrame::Sunken );
|
||
|
tmpTQGroupBox->setTitle( i18n("Pattern") );
|
||
13 years ago
|
tmpTQGroupBox->setAlignment( AlignLeft );
|
||
15 years ago
|
|
||
14 years ago
|
TQGridLayout *grid2 = new TQGridLayout(tmpTQGroupBox,8,3,KDialog::marginHint(), KDialog::spacingHint());
|
||
|
int fHeight = tmpTQGroupBox->fontMetrics().height();
|
||
15 years ago
|
grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
|
||
|
|
||
|
|
||
14 years ago
|
brush1 = new BrushSelect( tmpTQGroupBox, "Frame_1" );
|
||
|
brush1->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush1,1,0);
|
||
|
|
||
14 years ago
|
brush2 = new BrushSelect( tmpTQGroupBox, "Frame_2" );
|
||
|
brush2->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush2,1,1);
|
||
|
|
||
14 years ago
|
brush3 = new BrushSelect( tmpTQGroupBox, "Frame_3" );
|
||
|
brush3->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush3,1,2);
|
||
|
|
||
14 years ago
|
brush4 = new BrushSelect( tmpTQGroupBox, "Frame_4" );
|
||
|
brush4->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush4,2,0);
|
||
|
|
||
14 years ago
|
brush5 = new BrushSelect( tmpTQGroupBox, "Frame_5" );
|
||
|
brush5->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush5,2,1);
|
||
|
|
||
14 years ago
|
brush6 = new BrushSelect( tmpTQGroupBox, "Frame_6" );
|
||
|
brush6->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush6,2,2);
|
||
|
|
||
14 years ago
|
brush7 = new BrushSelect( tmpTQGroupBox, "Frame_7" );
|
||
|
brush7->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush7,3,0);
|
||
|
|
||
14 years ago
|
brush8 = new BrushSelect( tmpTQGroupBox, "Frame_8" );
|
||
|
brush8->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush8,3,1);
|
||
|
|
||
14 years ago
|
brush9 = new BrushSelect( tmpTQGroupBox, "Frame_9" );
|
||
|
brush9->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush9,3,2);
|
||
|
|
||
14 years ago
|
brush10 = new BrushSelect( tmpTQGroupBox, "Frame_10" );
|
||
|
brush10->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush10,4,0);
|
||
|
|
||
14 years ago
|
brush11 = new BrushSelect( tmpTQGroupBox, "Frame_11" );
|
||
|
brush11->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush11,4,1);
|
||
|
|
||
14 years ago
|
brush12 = new BrushSelect( tmpTQGroupBox, "Frame_12" );
|
||
|
brush12->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush12,4,2);
|
||
|
|
||
14 years ago
|
brush13 = new BrushSelect( tmpTQGroupBox, "Frame_13" );
|
||
|
brush13->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush13,5,0);
|
||
|
|
||
14 years ago
|
brush14 = new BrushSelect( tmpTQGroupBox, "Frame_14" );
|
||
|
brush14->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush14,5,1);
|
||
|
|
||
14 years ago
|
brush15 = new BrushSelect( tmpTQGroupBox, "Frame_15" );
|
||
|
brush15->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(brush15,5,2);
|
||
|
|
||
14 years ago
|
TQGridLayout *grid3 = new TQGridLayout( 1, 2 );
|
||
|
color = new KColorButton (tmpTQGroupBox, "ColorButton_1" );
|
||
15 years ago
|
grid3->addWidget(color,0,1);
|
||
|
|
||
14 years ago
|
TQLabel *tmpTQLabel = new TQLabel( tmpTQGroupBox, "Label_1" );
|
||
|
tmpTQLabel->setText( i18n("Color:") );
|
||
|
grid3->addWidget(tmpTQLabel,0,0);
|
||
15 years ago
|
|
||
|
grid2->addMultiCell(grid3,6,6,0,2);
|
||
|
|
||
14 years ago
|
grid3 = new TQGridLayout( 1, 3 );
|
||
15 years ago
|
grid3->setSpacing(KDialog::spacingHint());
|
||
|
|
||
14 years ago
|
tmpTQLabel = new TQLabel( tmpTQGroupBox, "Label_2" );
|
||
|
grid3->addWidget(tmpTQLabel,0,0);
|
||
|
tmpTQLabel->setText( i18n("Background color:") );
|
||
15 years ago
|
|
||
14 years ago
|
bgColorButton = new KColorButton( tmpTQGroupBox, "ColorButton" );
|
||
15 years ago
|
grid3->addWidget(bgColorButton,0,1);
|
||
|
if ( dlg->bBgColor )
|
||
|
bgColor = dlg->bgColor;
|
||
|
else
|
||
13 years ago
|
bgColor = colorGroup().base();
|
||
15 years ago
|
|
||
|
if (!bgColor.isValid())
|
||
13 years ago
|
bgColor = colorGroup().base();
|
||
15 years ago
|
|
||
|
bgColorButton->setColor( bgColor );
|
||
14 years ago
|
connect( bgColorButton, TQT_SIGNAL( changed( const TQColor & ) ),
|
||
|
this, TQT_SLOT( slotSetBackgroundColor( const TQColor & ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
notAnyColor=new TQPushButton(i18n("No Color"),tmpTQGroupBox);
|
||
15 years ago
|
grid3->addWidget(notAnyColor,0,2);
|
||
14 years ago
|
connect( notAnyColor, TQT_SIGNAL( clicked( ) ),
|
||
|
this, TQT_SLOT( slotNotAnyColor( ) ) );
|
||
15 years ago
|
b_notAnyColor=false;
|
||
|
|
||
|
grid2->addMultiCell(grid3,7,7,0,2);
|
||
|
|
||
14 years ago
|
grid->addMultiCellWidget(tmpTQGroupBox,0,3,0,0);
|
||
15 years ago
|
|
||
14 years ago
|
tmpTQGroupBox = new TQGroupBox( this, "GroupBox1" );
|
||
|
tmpTQGroupBox->setTitle( i18n("Preview") );
|
||
|
tmpTQGroupBox->setFrameStyle( TQFrame::Box | TQFrame::Sunken );
|
||
13 years ago
|
tmpTQGroupBox->setAlignment( AlignLeft );
|
||
15 years ago
|
|
||
14 years ago
|
grid2 = new TQGridLayout(tmpTQGroupBox,2,1,KDialog::marginHint(), KDialog::spacingHint());
|
||
|
fHeight = tmpTQGroupBox->fontMetrics().height();
|
||
15 years ago
|
grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
|
||
|
|
||
14 years ago
|
current = new BrushSelect( tmpTQGroupBox, "Current" );
|
||
|
current->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
|
||
15 years ago
|
grid2->addWidget(current,1,0);
|
||
14 years ago
|
grid->addWidget( tmpTQGroupBox,4,0);
|
||
|
|
||
|
connect( brush1, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush2, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush3, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush4, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush5, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush6, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush7, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush8, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush9, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush10, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush11, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush12, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush13, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush14, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
connect( brush15, TQT_SIGNAL( clicked( BrushSelect* ) ),
|
||
|
this, TQT_SLOT( slotUnselect2( BrushSelect* ) ) );
|
||
|
|
||
|
brush1->setPattern( TQt::red,Qt::VerPattern );
|
||
|
brush2->setPattern( TQt::red,Qt::HorPattern );
|
||
|
brush3->setPattern( TQt::red,Qt::Dense1Pattern );
|
||
|
brush4->setPattern( TQt::red,Qt::Dense2Pattern );
|
||
|
brush5->setPattern( TQt::red,Qt::Dense3Pattern );
|
||
|
brush6->setPattern( TQt::red,Qt::Dense4Pattern );
|
||
|
brush7->setPattern( TQt::red,Qt::Dense5Pattern );
|
||
|
brush8->setPattern( TQt::red,Qt::Dense6Pattern );
|
||
|
brush9->setPattern( TQt::red,Qt::Dense7Pattern );
|
||
|
brush10->setPattern( TQt::red,Qt::CrossPattern );
|
||
|
brush11->setPattern( TQt::red,Qt::BDiagPattern );
|
||
|
brush12->setPattern( TQt::red,Qt::FDiagPattern );
|
||
|
brush13->setPattern( TQt::red,Qt::VerPattern );
|
||
|
brush14->setPattern( TQt::red,Qt::DiagCrossPattern );
|
||
|
brush15->setPattern( TQt::red,Qt::NoBrush );
|
||
15 years ago
|
|
||
|
current->setPattern(dlg->brushColor,dlg->brushStyle);
|
||
|
current->slotSelect();
|
||
|
selectedBrush=current;
|
||
|
color->setColor(dlg->brushColor);
|
||
|
current->setBackgroundColor( bgColor );
|
||
|
|
||
14 years ago
|
connect( color, TQT_SIGNAL( changed( const TQColor & ) ),
|
||
|
this, TQT_SLOT( slotSetColorButton( const TQColor & ) ) );
|
||
15 years ago
|
|
||
|
slotSetColorButton( dlg->brushColor );
|
||
|
init();
|
||
|
this->resize( 400, 400 );
|
||
|
}
|
||
|
|
||
|
void CellFormatPagePattern::slotNotAnyColor()
|
||
|
{
|
||
|
b_notAnyColor = true;
|
||
13 years ago
|
bgColorButton->setColor( colorGroup().base() );
|
||
|
current->setBackgroundColor( colorGroup().base() );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void CellFormatPagePattern::slotSetBackgroundColor( const TQColor &_color )
|
||
15 years ago
|
{
|
||
|
bgColor =_color;
|
||
|
current->setBackgroundColor( bgColor );
|
||
|
bBgColorUndefined = false;
|
||
|
b_notAnyColor = false;
|
||
|
}
|
||
|
|
||
|
void CellFormatPagePattern::init()
|
||
|
{
|
||
14 years ago
|
if (dlg->brushStyle == TQt::VerPattern)
|
||
15 years ago
|
{
|
||
|
brush1->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::HorPattern)
|
||
15 years ago
|
{
|
||
|
brush2->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::Dense1Pattern)
|
||
15 years ago
|
{
|
||
|
brush3->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::Dense2Pattern)
|
||
15 years ago
|
{
|
||
|
brush4->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::Dense3Pattern)
|
||
15 years ago
|
{
|
||
|
brush5->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::Dense4Pattern)
|
||
15 years ago
|
{
|
||
|
brush6->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::Dense5Pattern)
|
||
15 years ago
|
{
|
||
|
brush7->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::Dense6Pattern)
|
||
15 years ago
|
{
|
||
|
brush8->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::Dense7Pattern)
|
||
15 years ago
|
{
|
||
|
brush9->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::CrossPattern)
|
||
15 years ago
|
{
|
||
|
brush10->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::BDiagPattern)
|
||
15 years ago
|
{
|
||
|
brush11->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::FDiagPattern)
|
||
15 years ago
|
{
|
||
|
brush12->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::VerPattern)
|
||
15 years ago
|
{
|
||
|
brush13->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::DiagCrossPattern)
|
||
15 years ago
|
{
|
||
|
brush14->slotSelect();
|
||
|
}
|
||
14 years ago
|
else if (dlg->brushStyle == TQt::NoBrush)
|
||
15 years ago
|
{
|
||
|
brush15->slotSelect();
|
||
|
}
|
||
|
else
|
||
|
kdDebug(36001) << "Error in brushStyle" << endl;
|
||
|
}
|
||
|
|
||
14 years ago
|
void CellFormatPagePattern::slotSetColorButton( const TQColor &_color )
|
||
15 years ago
|
{
|
||
|
currentColor = _color;
|
||
|
|
||
|
brush1->setBrushColor( currentColor );
|
||
|
brush2->setBrushColor( currentColor );
|
||
|
brush3->setBrushColor( currentColor );
|
||
|
brush4->setBrushColor( currentColor );
|
||
|
brush5->setBrushColor( currentColor );
|
||
|
brush6->setBrushColor( currentColor );
|
||
|
brush7->setBrushColor( currentColor );
|
||
|
brush8->setBrushColor( currentColor );
|
||
|
brush9->setBrushColor( currentColor );
|
||
|
brush10->setBrushColor( currentColor );
|
||
|
brush11->setBrushColor( currentColor );
|
||
|
brush12->setBrushColor( currentColor );
|
||
|
brush13->setBrushColor( currentColor );
|
||
|
brush14->setBrushColor( currentColor );
|
||
|
brush15->setBrushColor( currentColor );
|
||
|
current->setBrushColor( currentColor );
|
||
|
}
|
||
|
|
||
|
void CellFormatPagePattern::slotUnselect2( BrushSelect *_p )
|
||
|
{
|
||
|
selectedBrush = _p;
|
||
|
|
||
|
if ( brush1 != _p )
|
||
|
brush1->slotUnselect();
|
||
|
if ( brush2 != _p )
|
||
|
brush2->slotUnselect();
|
||
|
if ( brush3 != _p )
|
||
|
brush3->slotUnselect();
|
||
|
if ( brush4 != _p )
|
||
|
brush4->slotUnselect();
|
||
|
if ( brush5 != _p )
|
||
|
brush5->slotUnselect();
|
||
|
if ( brush6 != _p )
|
||
|
brush6->slotUnselect();
|
||
|
if ( brush7 != _p )
|
||
|
brush7->slotUnselect();
|
||
|
if ( brush8 != _p )
|
||
|
brush8->slotUnselect();
|
||
|
if ( brush9 != _p )
|
||
|
brush9->slotUnselect();
|
||
|
if ( brush10 != _p )
|
||
|
brush10->slotUnselect();
|
||
|
if ( brush11 != _p )
|
||
|
brush11->slotUnselect();
|
||
|
if ( brush12 != _p )
|
||
|
brush12->slotUnselect();
|
||
|
if ( brush13 != _p )
|
||
|
brush13->slotUnselect();
|
||
|
if ( brush14 != _p )
|
||
|
brush14->slotUnselect();
|
||
|
if ( brush15 != _p )
|
||
|
brush15->slotUnselect();
|
||
|
|
||
|
current->setBrushStyle( selectedBrush->getBrushStyle() );
|
||
|
}
|
||
|
|
||
|
void CellFormatPagePattern::apply( CustomStyle * style )
|
||
|
{
|
||
|
if ( selectedBrush != 0L
|
||
|
&& ( dlg->brushStyle != selectedBrush->getBrushStyle()
|
||
|
|| dlg->brushColor != selectedBrush->getBrushColor() ) )
|
||
14 years ago
|
style->changeBackGroundBrush( TQBrush( selectedBrush->getBrushColor(), selectedBrush->getBrushStyle() ) );
|
||
15 years ago
|
|
||
|
/*
|
||
|
TODO: check...
|
||
|
if ( b_notAnyColor)
|
||
14 years ago
|
style->changeBgColor( TQColor() );
|
||
15 years ago
|
else
|
||
|
*/
|
||
|
if ( bgColor != dlg->getStyle()->bgColor() )
|
||
|
style->changeBgColor( bgColor );
|
||
|
}
|
||
|
|
||
|
void CellFormatPagePattern::apply(FormatManipulator *_obj)
|
||
|
{
|
||
|
if ( selectedBrush != 0L
|
||
|
&& ( dlg->brushStyle != selectedBrush->getBrushStyle()
|
||
|
|| dlg->brushColor != selectedBrush->getBrushColor() ) )
|
||
14 years ago
|
_obj->setBackgroundBrush( TQBrush( selectedBrush->getBrushColor(), selectedBrush->getBrushStyle() ) );
|
||
15 years ago
|
|
||
|
if ( bgColor == dlg->bgColor )
|
||
|
return;
|
||
|
|
||
|
if ( b_notAnyColor)
|
||
14 years ago
|
_obj->setBackgroundColor( TQColor() );
|
||
15 years ago
|
else if ( !bBgColorUndefined )
|
||
|
_obj->setBackgroundColor( bgColor );
|
||
|
}
|
||
|
|
||
|
#include "kspread_dlg_layout.moc"
|
||
|
|