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.
koffice/kword/KWSplitCellDia.cpp

98 lines
3.3 KiB

/* This file is part of the KDE project
Copyright (C) 2001 Thomas Zander <zander@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 "KWSplitCellDia.h"
#include "KWSplitCellDia.moc"
#include "KWTableDia.h"
#include <tqlayout.h>
#include <tqlabel.h>
#include <tqspinbox.h>
#include <klocale.h>
KWSplitCellDia::KWSplitCellDia( TQWidget* parent, const char* name, unsigned int columns, unsigned int rows)
: KDialogBase( Plain, i18n("Split Cell"), Ok | Cancel, Ok, parent, name, true)
{
m_cols = columns;
m_rows = rows;
setInitialSize( TQSize(400, 300) );
TQWidget *page = plainPage();
TQGridLayout *grid = new TQGridLayout( page, 4, 2, KDialog::marginHint(), KDialog::spacingHint() );
TQLabel *lRows = new TQLabel( i18n( "Number of rows:" ), page );
grid->addWidget( lRows, 0, 0 );
nRows = new TQSpinBox( 1, 128, 1, page );
nRows->setValue( m_rows );
grid->addWidget( nRows, 1, 0 );
TQLabel *lCols = new TQLabel( i18n( "Number of columns:" ), page );
grid->addWidget( lCols, 2, 0 );
nCols = new TQSpinBox( 1, 128, 1, page );
nCols->setValue( m_cols );
grid->addWidget( nCols, 3, 0 );
preview = new KWTablePreview( page, m_rows, m_cols );
preview->setBackgroundColor( white );
grid->addMultiCellWidget( preview, 0, 4, 1, 1 );
grid->addRowSpacing( 0, lRows->height() );
grid->addRowSpacing( 1, nRows->height() );
grid->addRowSpacing( 2, lCols->height() );
grid->addRowSpacing( 3, nCols->height() );
grid->addRowSpacing( 4, 150 - ( lRows->height() + nRows->height() + lCols->height() + nCols->height() ) );
grid->setRowStretch( 0, 0 );
grid->setRowStretch( 1, 0 );
grid->setRowStretch( 2, 0 );
grid->setRowStretch( 3, 0 );
grid->setRowStretch( 4, 1 );
grid->addColSpacing( 0, lRows->width() );
grid->addColSpacing( 0, nRows->width() );
grid->addColSpacing( 0, lCols->width() );
grid->addColSpacing( 0, nCols->width() );
grid->addColSpacing( 1, 150 );
grid->setColStretch( 0, 0 );
grid->setColStretch( 1, 1 );
grid->activate();
enableButtonOK( !(m_rows==1 && m_cols==1) );
connect( nRows, TQT_SIGNAL( valueChanged( int ) ), this, TQT_SLOT( rowsChanged( int ) ) );
connect( nCols, TQT_SIGNAL( valueChanged( int ) ), this, TQT_SLOT( colsChanged( int ) ) );
setFocus();
}
void KWSplitCellDia::rowsChanged( int rows ) {
m_rows=rows;
preview->setRows( m_rows );
enableButtonOK( !(m_rows==1 && m_cols==1) );
}
void KWSplitCellDia::colsChanged( int cols ) {
m_cols=cols;
preview->setCols( m_cols );
enableButtonOK( !(m_rows==1 && m_cols==1) );
}