kword

KWInsertDia.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3 Copyright (C) 2005 Thomas Zander <zander@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include "KWInsertDia.h"
22#include "KWTableFrameSet.h"
23#include "KWView.h"
24
25#include <tdelocale.h>
26
27#include <tqlabel.h>
28#include <tqspinbox.h>
29#include <tqradiobutton.h>
30#include <tqbuttongroup.h>
31#include <tqlayout.h>
32
33KWInsertDia::KWInsertDia( KWView *parent, KWTableFrameSet *table, InsertType type, int insertHint)
34 : KDialogBase( Plain, (type==insertRow?i18n("Insert Row") : i18n("Insert Column")), Ok | Cancel, Ok, parent, "Insert Table items dialog", true )
35{
36 m_type = type;
37 m_table = table;
38 m_view = parent;
39
40 setupTab1(insertHint);
41}
42
43void KWInsertDia::setupTab1(int insertHint)
44{
45 TQWidget *tab1 = plainPage();
46 TQGridLayout *grid1 = new TQGridLayout( tab1, 2, 2, 0, KDialog::spacingHint() );
47
48 TQButtonGroup *grp = new TQButtonGroup( m_type == insertRow ? i18n( "Insert New Row" ) : i18n( "Insert New Column" ), tab1 );
49
50 TQGridLayout *grid2 = new TQGridLayout( grp, 3, 1, KDialog::marginHint(), KDialog::spacingHint() );
51
52 m_rBefore = new TQRadioButton( i18n( "Before" ), grp, "before_radio_button" );
53 grp->insert( m_rBefore );
54 grid2->addWidget( m_rBefore, 1, 0 );
55
56 TQRadioButton *rAfter = new TQRadioButton( i18n( "After" ), grp, "after_radio_button");
57 grp->insert( rAfter );
58 grid2->addWidget( rAfter, 2, 0 );
59 rAfter->setChecked( true );
60
61 grid2->addRowSpacing( 0, 7 );
62
63 grid1->addMultiCellWidget ( grp, 0, 0, 0, 1 );
64
65 TQLabel *rc = new TQLabel( m_type == insertRow ? i18n( "Row:" ) : i18n( "Column:" ), tab1 );
66 grid1->addWidget( rc, 1, 0 );
67
68 m_value = new TQSpinBox( 1, m_type == insertRow ? m_table->getRows() : m_table->getColumns(),
69 1, tab1, "row_col_spinbox" );
70 m_value->setValue( insertHint + 1 ); // +1 due to the fact that humans count starting at 1
71
72 grid1->addWidget( m_value, 1, 1 );
73}
74
75void KWInsertDia::slotOk()
76{
77 unsigned int insert = m_value->value() - ( m_rBefore->isChecked() ? 1 : 0 );
78 if ( m_type == insertRow )
79 m_view->tableInsertRow(insert, m_table);
80 else
81 m_view->tableInsertCol(insert, m_table);
82 KDialogBase::slotOk();
83}
84
85#include "KWInsertDia.moc"
This class implements tables by acting as the manager for the frame(set)s which make up the table cel...