kword

KWConfigFootNoteDia.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2002 Montel Laurent <lmontel@mandrakesoft.com>
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 "KWDocument.h"
21#include "KWConfigFootNoteDia.h"
22#include "KWConfigFootNoteDia.moc"
23#include "KWVariable.h"
24#include "KWCommand.h"
25#include "KWFrameSet.h"
26
27#include <KoParagDia.h>
28#include <KoUnitWidgets.h>
29
30#include <tdelocale.h>
31#include <knuminput.h>
32
33#include <tqradiobutton.h>
34#include <tqwhatsthis.h>
35#include <tqvbuttongroup.h>
36#include <tqlabel.h>
37#include <tqvbox.h>
38#include <tqlayout.h>
39#include <tqcombobox.h>
40
41
42KWConfigFootNoteDia::KWConfigFootNoteDia( TQWidget *parent, const char *name, KWDocument *doc )
43 : KDialogBase(Tabbed, TQString(), Ok | Cancel , Ok, parent, name, true)
44{
45 setCaption( i18n("Configure Endnote/Footnote") );
46 m_doc = doc;
47
48 resize( 510, 310 );
49 setupTab1();
50 setupTab2();
51 setupTab3();
52}
53
54void KWConfigFootNoteDia::setupTab1()
55{
56 TQVBox * page = addVBoxPage( i18n( "Footnotes" ) );
57 m_footNoteConfig = new KoCounterStyleWidget( false, true, false, page );
58 //m_footNoteConfig->numTypeChanged( KoParagCounter::NUM_LIST );
59 m_footNoteConfig->setCounter (static_cast<KWVariableSettings*>(m_doc->variableCollection()->variableSetting())->footNoteCounter() );
60}
61
62void KWConfigFootNoteDia::setupTab2()
63{
64 TQVBox * page = addVBoxPage( i18n( "Endnotes" ) );
65 m_endNoteConfig = new KoCounterStyleWidget( false, true/*onlyStyleLetter*/,false, page );
66 //m_endNoteConfig->numTypeChanged( KoParagCounter::NUM_LIST );
67 m_endNoteConfig->setCounter (static_cast<KWVariableSettings*>(m_doc->variableCollection()->variableSetting())->endNoteCounter() );
68}
69
70
71void KWConfigFootNoteDia::setupTab3()
72{
73 TQFrame * page = addPage( i18n( "Separator Line" ) );
74 TQString comment= i18n ("Configure the separator line. The separator line "
75 "is drawn directly above the frame for the footnotes.");
76 TQWhatsThis::add(page, comment);
77 TQVBoxLayout *pageLayout= new TQVBoxLayout( page, 0, KDialog::spacingHint());
78
79 TQButtonGroup *positionGroupBox = new TQButtonGroup( i18n( "Position"), page );
80 comment= i18n ("The separator can be positioned horizontally by picking one "
81 "of the three alignments.");
82 TQWhatsThis::add(positionGroupBox, comment);
83 positionGroupBox->setColumnLayout(0, TQt::Vertical );
84 TQVBoxLayout *positionLayout = new TQVBoxLayout( positionGroupBox->layout() );
85 positionLayout->setAlignment( TQt::AlignTop );
86
87 // i18n context information necessary for gender considerations (e.g. in Polish)
88 rbPosLeft = new TQRadioButton( i18n("Position", "Left"), positionGroupBox, "rbPosLeft" );
89 positionLayout->addWidget( rbPosLeft );
90
91 rbPosCentered = new TQRadioButton( i18n("Position", "Centered"), positionGroupBox, "rbPosCentered" );
92 positionLayout->addWidget( rbPosCentered );
93
94 rbPosRight = new TQRadioButton( i18n("Position", "Right"), positionGroupBox, "rbPosRight" );
95 positionLayout->addWidget( rbPosRight );
96 pageLayout->addWidget( positionGroupBox );
97 switch( m_doc->footNoteSeparatorLinePosition() ) {
98 case SLP_LEFT:
99 rbPosLeft->setChecked( true);
100 break;
101 case SLP_CENTERED:
102 rbPosCentered->setChecked( true);
103 break;
104 case SLP_RIGHT:
105 rbPosRight->setChecked( true);
106 break;
107 }
108
109 TQGridLayout *layout = new TQGridLayout( 0, 1, 1, 0, KDialog::spacingHint());
110
111 spWidth = new KoUnitDoubleSpinBox(page, 0, 5, 0.5, m_doc->footNoteSeparatorLineWidth(), m_doc->unit(), 1);
112
113 layout->addWidget( spWidth, 1, 1 );
114
115 spLength = new KIntNumInput( page, "spLength" );
116 spLength->setRange( 1, 100, 1,false );
117 spLength->setValue( m_doc->footNoteSeparatorLineLength());
118 spLength->setSuffix(i18n(" %"));
119 layout->addWidget( spLength, 0, 1 );
120
121 TQLabel *lSize = new TQLabel( i18n( "&Width:"), page );
122 lSize->setBuddy( spWidth );
123 comment= i18n ("The width is the thickness of the separator line, set to 0 for no separator line.");
124 TQWhatsThis::add(lSize, comment);
125 TQWhatsThis::add(spWidth, comment);
126 layout->addWidget( lSize, 1, 0 );
127
128 TQSpacerItem* spacer = new TQSpacerItem( 0, 0, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
129 layout->addMultiCell( spacer, 0, 1, 2, 2 );
130
131 TQLabel *lWidth = new TQLabel( i18n("&Size on page:"), page, "lWidth" );
132 lWidth->setBuddy( spLength );
133 comment= i18n ("The size of the separator line can be defined as a percentage of the width of the page.");
134 TQWhatsThis::add(spLength, comment);
135 TQWhatsThis::add(lWidth, comment);
136 layout->addWidget( lWidth, 0, 0 );
137 pageLayout->addLayout( layout );
138
139 TQHBoxLayout *styleLayout = new TQHBoxLayout( 0, 0, KDialog::spacingHint(), "styleLayout");
140
141 TQLabel *styleLabel = new TQLabel( i18n("Style:"), page );
142 styleLayout->addWidget( styleLabel );
143
144 m_cbLineType = new TQComboBox( page );
145 TQStringList lst;
146 lst <<i18n("Solid");
147 lst <<i18n("Dash Line");
148 lst <<i18n("Dot Line");
149 lst <<i18n("Dash Dot Line");
150 lst <<i18n("Dash Dot Dot Line");
151 m_cbLineType->insertStringList( lst );
152 m_cbLineType->setCurrentItem( static_cast<int>(m_doc->footNoteSeparatorLineType()));
153 comment= i18n ("The separator line can be drawn as a solid line or as a line which has a "
154 "pattern; the pattern can be set in the style-type.");
155 TQWhatsThis::add(styleLabel, comment);
156 TQWhatsThis::add(m_cbLineType, comment);
157 styleLayout->addWidget( m_cbLineType );
158
159 TQSpacerItem* spacer_2 = new TQSpacerItem( 0, 0, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
160 styleLayout->addItem( spacer_2 );
161 pageLayout->addLayout( styleLayout );
162 TQSpacerItem* spacer_3 = new TQSpacerItem( 0, 0, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
163 pageLayout->addItem( spacer_3 );
164}
165
166
167void KWConfigFootNoteDia::slotOk()
168{
169 KMacroCommand * macro = 0L;
170 KCommand *cmd = 0L;
171 KoParagCounter counter =static_cast<KWVariableSettings*>(m_doc->variableCollection()->variableSetting())->footNoteCounter();
172 if (counter != m_footNoteConfig->counter() )
173 {
174 macro = new KMacroCommand(i18n("Change End-/Footnote Variable Settings"));
175 cmd= new KWChangeFootEndNoteSettingsCommand( i18n("Change End-/Footnote Variable Settings") , counter, m_footNoteConfig->counter() ,true ,m_doc);
176 macro->addCommand(cmd );
177 }
178 counter = static_cast<KWVariableSettings*>(m_doc->variableCollection()->variableSetting())->endNoteCounter();
179 if (counter != m_endNoteConfig->counter() )
180 {
181 if ( !macro )
182 macro = new KMacroCommand(i18n("Change End-/Footnote Variable Settings"));
183 cmd= new KWChangeFootEndNoteSettingsCommand( i18n("Change End-/Footnote Variable Settings") , counter, m_endNoteConfig->counter() ,false ,m_doc);
184 macro->addCommand(cmd );
185 }
186
187 int val =spLength->value();
188 double width = spWidth->value();
189 SeparatorLinePos tmp = SLP_LEFT;
190 SeparatorLineLineType type = static_cast<SeparatorLineLineType>(m_cbLineType->currentItem());
191 if ( rbPosRight->isChecked())
192 tmp = SLP_RIGHT;
193 else if ( rbPosCentered->isChecked())
194 tmp = SLP_CENTERED;
195 else if ( rbPosLeft->isChecked())
196 tmp = SLP_LEFT;
197
198 if ( (val != m_doc->footNoteSeparatorLineLength())||
199 tmp != m_doc->footNoteSeparatorLinePosition()||
200 width!= m_doc->footNoteSeparatorLineWidth() ||
201 type != m_doc->footNoteSeparatorLineType())
202 {
203 if ( !macro )
204 macro = new KMacroCommand(i18n("Change Footnote Line Separator Settings"));
205 cmd = new KWChangeFootNoteLineSeparatorParametersCommand( i18n("Change Footnote Line Separator Settings") , m_doc->footNoteSeparatorLinePosition(), tmp, m_doc->footNoteSeparatorLineLength(), val,m_doc->footNoteSeparatorLineWidth(), width, m_doc->footNoteSeparatorLineType(), type, m_doc);
206 macro->addCommand( cmd );
207 }
208
209 if ( macro )
210 {
211 macro->execute();
212 m_doc->addCommand( macro );
213 }
214
215 KDialogBase::slotOk();
216}