]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QTabularDialog.C
namespace grfx -> lyx::graphics
[lyx.git] / src / frontends / qt2 / QTabularDialog.C
1 /**
2  * \file QTabularDialog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  * \author Juergen Spitzmueller
8  * \author Herbert Voss
9  *
10  * Full author contact details are available in file CREDITS
11  */
12
13 #include <config.h>
14
15
16 #include "ControlTabular.h"
17
18 #include "QTabular.h"
19 #include "QTabularDialog.h"
20 #include "tabular.h"
21 #include "lengthcombo.h"
22 #include "qsetborder.h"
23 #include "qt_helpers.h"
24 #include "debug.h"
25
26 #include <qcheckbox.h>
27 #include <qpushbutton.h>
28 #include <qlineedit.h>
29
30 using std::endl;
31
32 QTabularDialog::QTabularDialog(QTabular * form)
33         : QTabularDialogBase(0, 0, false, 0),
34         form_(form)
35 {
36         connect(closePB, SIGNAL(clicked()),
37                 form, SLOT(slotClose()));
38 }
39
40
41 void QTabularDialog::change_adaptor()
42 {
43         form_->changed();
44 }
45
46
47 void QTabularDialog::closeEvent(QCloseEvent * e)
48 {
49         form_->slotWMHide();
50         e->accept();
51 }
52
53
54 void QTabularDialog::close_clicked()
55 {
56         form_->closeGUI();
57 }
58
59
60 void QTabularDialog::borderSet_clicked()
61 {
62         form_->controller().set(LyXTabular::SET_ALL_LINES);
63         form_->update_borders();
64         form_->changed();
65 }
66
67
68 void QTabularDialog::borderUnset_clicked()
69 {
70         form_->controller().set(LyXTabular::UNSET_ALL_LINES);
71         form_->update_borders();
72         form_->changed();
73 }
74
75
76 void QTabularDialog::leftBorder_changed()
77 {
78         form_->controller().toggleLeftLine();
79         form_->changed();
80 }
81
82
83 void QTabularDialog::rightBorder_changed()
84 {
85         form_->controller().toggleRightLine();
86         form_->changed();
87 }
88
89
90 void QTabularDialog::topBorder_changed()
91 {
92         form_->controller().toggleTopLine();
93         form_->changed();
94 }
95
96
97 void QTabularDialog::bottomBorder_changed()
98 {
99         form_->controller().toggleBottomLine();
100         form_->changed();
101 }
102
103
104 void QTabularDialog::specialAlignment_changed()
105 {
106         string special = fromqstr(specialAlignmentED->text());
107         form_->controller().setSpecial(special);
108         form_->changed();
109 }
110
111
112 void QTabularDialog::width_changed()
113 {
114         form_->changed();
115         string const width =
116                 LyXLength(widthED->text().toDouble(),
117                         widthUnit->currentLengthItem()).asString();
118         form_->controller().setWidth(width);
119 }
120
121
122 void QTabularDialog::multicolumn_clicked()
123 {
124         form_->controller().toggleMultiColumn();
125         form_->changed();
126 }
127
128
129 void QTabularDialog::rotateTabular()
130 {
131         form_->controller().rotateTabular(rotateTabularCB->isChecked());
132         form_->changed();
133 }
134
135
136 void QTabularDialog::rotateCell()
137 {
138         form_->controller().rotateCell(rotateCellCB->isChecked());
139         form_->changed();
140 }
141
142
143 void QTabularDialog::hAlign_changed(int align)
144 {
145         ControlTabular::HALIGN h;
146
147         switch (align) {
148                 case 0: h = ControlTabular::LEFT; break;
149                 case 1: h = ControlTabular::CENTER; break;
150                 case 2: h = ControlTabular::RIGHT; break;
151                 case 3: h = ControlTabular::BLOCK; break;
152         }
153
154         form_->controller().halign(h);
155 }
156
157
158 void QTabularDialog::vAlign_changed(int align)
159 {
160         ControlTabular::VALIGN v;
161
162         switch (align) {
163                 case 0: v = ControlTabular::TOP; break;
164                 case 1: v = ControlTabular::VCENTER; break;
165                 case 2: v = ControlTabular::BOTTOM; break;
166         }
167
168         form_->controller().valign(v);
169 }
170
171
172 void QTabularDialog::longTabular()
173 {
174         form_->controller().longTabular(longTabularCB->isChecked());
175         form_->changed();
176 }
177
178
179 void QTabularDialog::ltNewpage_clicked()
180 {
181         form_->controller().set(LyXTabular::SET_LTNEWPAGE);
182         form_->changed();
183 }
184
185
186 void QTabularDialog::ltHeaderStatus_clicked()
187 {
188         bool enable(headerStatusCB->isChecked());
189         if (enable)
190                 form_->controller().set(LyXTabular::SET_LTHEAD, "");
191         else
192                 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
193         headerBorderAboveCB->setEnabled(enable);
194         headerBorderBelowCB->setEnabled(enable);
195         firstheaderNoContentsCB->setEnabled(enable);
196         form_->changed();
197 }
198
199
200 void QTabularDialog::ltHeaderBorderAbove_clicked()
201 {
202         if (headerBorderAboveCB->isChecked())
203                 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
204         else
205                 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
206         form_->changed();
207 }
208
209
210 void QTabularDialog::ltHeaderBorderBelow_clicked()
211 {
212         if (headerBorderBelowCB->isChecked())
213                 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
214         else
215                 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
216         form_->changed();
217 }
218
219
220 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
221 {
222         if (firstheaderBorderAboveCB->isChecked())
223                 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
224         else
225                 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
226         form_->changed();
227 }
228
229
230 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
231 {
232         if (firstheaderBorderBelowCB->isChecked())
233                 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
234         else
235                 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
236         form_->changed();
237 }
238
239
240 void QTabularDialog::ltFirstHeaderStatus_clicked()
241 {
242         bool enable(firstheaderStatusCB->isChecked());
243         if (enable)
244                 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
245         else
246                 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
247         firstheaderBorderAboveCB->setEnabled(enable);
248         firstheaderBorderBelowCB->setEnabled(enable);
249         form_->changed();
250 }
251
252
253 void QTabularDialog::ltFirstHeaderEmpty_clicked()
254 {
255         bool enable(firstheaderNoContentsCB->isChecked());
256         if (enable)
257                 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
258         else {
259                 ltFirstHeaderBorderBelow_clicked();
260                 ltFirstHeaderBorderAbove_clicked();
261         }
262         firstheaderStatusCB->setEnabled(!enable);
263         firstheaderBorderAboveCB->setEnabled(!enable);
264         firstheaderBorderBelowCB->setEnabled(!enable);
265         form_->changed();
266 }
267
268
269 void QTabularDialog::ltFooterStatus_clicked()
270 {
271         bool enable(footerStatusCB->isChecked());
272         if (enable)
273                 form_->controller().set(LyXTabular::SET_LTFOOT, "");
274         else
275                 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
276         footerBorderAboveCB->setEnabled(enable);
277         footerBorderBelowCB->setEnabled(enable);
278         lastfooterNoContentsCB->setEnabled(enable);
279         form_->changed();
280 }
281
282
283 void QTabularDialog::ltFooterBorderAbove_clicked()
284 {
285         if (footerBorderAboveCB->isChecked())
286                 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
287         else
288                 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
289         form_->changed();
290 }
291
292
293 void QTabularDialog::ltFooterBorderBelow_clicked()
294 {
295         if (footerBorderBelowCB->isChecked())
296                 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
297         else
298                 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
299         form_->changed();
300 }
301
302
303 void QTabularDialog::ltLastFooterStatus_clicked()
304 {
305         bool enable(lastfooterStatusCB->isChecked());
306         if (enable)
307                 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
308         else
309                 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
310         lastfooterBorderAboveCB->setEnabled(enable);
311         lastfooterBorderBelowCB->setEnabled(enable);
312         form_->changed();
313 }
314
315
316 void QTabularDialog::ltLastFooterBorderAbove_clicked()
317 {
318         if (lastfooterBorderAboveCB->isChecked())
319                 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
320         else
321                 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
322         form_->changed();
323 }
324
325
326 void QTabularDialog::ltLastFooterBorderBelow_clicked()
327 {
328         if (lastfooterBorderBelowCB->isChecked())
329                 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
330         else
331                 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
332         form_->changed();
333 }
334
335
336 void QTabularDialog::ltLastFooterEmpty_clicked()
337 {
338         bool enable(lastfooterNoContentsCB->isChecked());
339         if (enable)
340                 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
341         else {
342                 ltLastFooterBorderBelow_clicked();
343                 ltLastFooterBorderAbove_clicked();
344         }
345         lastfooterStatusCB->setEnabled(!enable);
346         lastfooterBorderAboveCB->setEnabled(!enable);
347         lastfooterBorderBelowCB->setEnabled(!enable);
348         form_->changed();
349 }