kword

KWSplitCellDia.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001 Thomas Zander <zander@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "KWSplitCellDia.h"
21#include "KWSplitCellDia.moc"
22#include "KWTableDia.h"
23
24#include <tqlayout.h>
25#include <tqlabel.h>
26#include <tqspinbox.h>
27
28#include <tdelocale.h>
29
30KWSplitCellDia::KWSplitCellDia( TQWidget* parent, const char* name, unsigned int columns, unsigned int rows)
31 : KDialogBase( Plain, i18n("Split Cell"), Ok | Cancel, Ok, parent, name, true)
32{
33 m_cols = columns;
34 m_rows = rows;
35
36 setInitialSize( TQSize(400, 300) );
37
38 TQWidget *page = plainPage();
39 TQGridLayout *grid = new TQGridLayout( page, 4, 2, KDialog::marginHint(), KDialog::spacingHint() );
40
41 TQLabel *lRows = new TQLabel( i18n( "Number of rows:" ), page );
42 grid->addWidget( lRows, 0, 0 );
43
44 nRows = new TQSpinBox( 1, 128, 1, page );
45 nRows->setValue( m_rows );
46 grid->addWidget( nRows, 1, 0 );
47
48 TQLabel *lCols = new TQLabel( i18n( "Number of columns:" ), page );
49 grid->addWidget( lCols, 2, 0 );
50
51 nCols = new TQSpinBox( 1, 128, 1, page );
52 nCols->setValue( m_cols );
53 grid->addWidget( nCols, 3, 0 );
54
55 preview = new KWTablePreview( page, m_rows, m_cols );
56 preview->setBackgroundColor( white );
57 grid->addMultiCellWidget( preview, 0, 4, 1, 1 );
58
59 grid->addRowSpacing( 0, lRows->height() );
60 grid->addRowSpacing( 1, nRows->height() );
61 grid->addRowSpacing( 2, lCols->height() );
62 grid->addRowSpacing( 3, nCols->height() );
63 grid->addRowSpacing( 4, 150 - ( lRows->height() + nRows->height() + lCols->height() + nCols->height() ) );
64 grid->setRowStretch( 0, 0 );
65 grid->setRowStretch( 1, 0 );
66 grid->setRowStretch( 2, 0 );
67 grid->setRowStretch( 3, 0 );
68 grid->setRowStretch( 4, 1 );
69
70 grid->addColSpacing( 0, lRows->width() );
71 grid->addColSpacing( 0, nRows->width() );
72 grid->addColSpacing( 0, lCols->width() );
73 grid->addColSpacing( 0, nCols->width() );
74 grid->addColSpacing( 1, 150 );
75 grid->setColStretch( 0, 0 );
76 grid->setColStretch( 1, 1 );
77
78 grid->activate();
79 enableButtonOK( !(m_rows==1 && m_cols==1) );
80
81 connect( nRows, TQ_SIGNAL( valueChanged( int ) ), this, TQ_SLOT( rowsChanged( int ) ) );
82 connect( nCols, TQ_SIGNAL( valueChanged( int ) ), this, TQ_SLOT( colsChanged( int ) ) );
83 setFocus();
84}
85
86void KWSplitCellDia::rowsChanged( int rows ) {
87 m_rows=rows;
88 preview->setRows( m_rows );
89 enableButtonOK( !(m_rows==1 && m_cols==1) );
90}
91
92void KWSplitCellDia::colsChanged( int cols ) {
93 m_cols=cols;
94 preview->setCols( m_cols );
95 enableButtonOK( !(m_rows==1 && m_cols==1) );
96}
97