00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "KWSplitCellDia.h"
00021 #include "KWSplitCellDia.moc"
00022 #include "KWTableDia.h"
00023
00024 #include <qlayout.h>
00025 #include <qlabel.h>
00026 #include <qspinbox.h>
00027
00028 #include <klocale.h>
00029
00030 KWSplitCellDia::KWSplitCellDia( QWidget* parent, const char* name, unsigned int columns, unsigned int rows)
00031 : KDialogBase( Plain, i18n("Split Cell"), Ok | Cancel, Ok, parent, name, true)
00032 {
00033 m_cols = columns;
00034 m_rows = rows;
00035
00036 setInitialSize( QSize(400, 300) );
00037
00038 QWidget *page = plainPage();
00039 QGridLayout *grid = new QGridLayout( page, 4, 2, KDialog::marginHint(), KDialog::spacingHint() );
00040
00041 QLabel *lRows = new QLabel( i18n( "Number of rows:" ), page );
00042 grid->addWidget( lRows, 0, 0 );
00043
00044 nRows = new QSpinBox( 1, 128, 1, page );
00045 nRows->setValue( m_rows );
00046 grid->addWidget( nRows, 1, 0 );
00047
00048 QLabel *lCols = new QLabel( i18n( "Number of columns:" ), page );
00049 grid->addWidget( lCols, 2, 0 );
00050
00051 nCols = new QSpinBox( 1, 128, 1, page );
00052 nCols->setValue( m_cols );
00053 grid->addWidget( nCols, 3, 0 );
00054
00055 preview = new KWTablePreview( page, m_rows, m_cols );
00056 preview->setBackgroundColor( white );
00057 grid->addMultiCellWidget( preview, 0, 4, 1, 1 );
00058
00059 grid->addRowSpacing( 0, lRows->height() );
00060 grid->addRowSpacing( 1, nRows->height() );
00061 grid->addRowSpacing( 2, lCols->height() );
00062 grid->addRowSpacing( 3, nCols->height() );
00063 grid->addRowSpacing( 4, 150 - ( lRows->height() + nRows->height() + lCols->height() + nCols->height() ) );
00064 grid->setRowStretch( 0, 0 );
00065 grid->setRowStretch( 1, 0 );
00066 grid->setRowStretch( 2, 0 );
00067 grid->setRowStretch( 3, 0 );
00068 grid->setRowStretch( 4, 1 );
00069
00070 grid->addColSpacing( 0, lRows->width() );
00071 grid->addColSpacing( 0, nRows->width() );
00072 grid->addColSpacing( 0, lCols->width() );
00073 grid->addColSpacing( 0, nCols->width() );
00074 grid->addColSpacing( 1, 150 );
00075 grid->setColStretch( 0, 0 );
00076 grid->setColStretch( 1, 1 );
00077
00078 grid->activate();
00079 enableButtonOK( !(m_rows==1 && m_cols==1) );
00080
00081 connect( nRows, SIGNAL( valueChanged( int ) ), this, SLOT( rowsChanged( int ) ) );
00082 connect( nCols, SIGNAL( valueChanged( int ) ), this, SLOT( colsChanged( int ) ) );
00083 setFocus();
00084 }
00085
00086 void KWSplitCellDia::rowsChanged( int rows ) {
00087 m_rows=rows;
00088 preview->setRows( m_rows );
00089 enableButtonOK( !(m_rows==1 && m_cols==1) );
00090 }
00091
00092 void KWSplitCellDia::colsChanged( int cols ) {
00093 m_cols=cols;
00094 preview->setCols( m_cols );
00095 enableButtonOK( !(m_rows==1 && m_cols==1) );
00096 }
00097