]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QTabularDialog.C
8f3f668b7d5f71f1c095038c5aea45c9aa36aa58
[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 = widgetsToLength(widthED, widthUnit);
116         form_->controller().setWidth(width);
117 }
118
119
120 void QTabularDialog::multicolumn_clicked()
121 {
122         form_->controller().toggleMultiColumn();
123         form_->changed();
124 }
125
126
127 void QTabularDialog::rotateTabular()
128 {
129         form_->controller().rotateTabular(rotateTabularCB->isChecked());
130         form_->changed();
131 }
132
133
134 void QTabularDialog::rotateCell()
135 {
136         form_->controller().rotateCell(rotateCellCB->isChecked());
137         form_->changed();
138 }
139
140
141 void QTabularDialog::hAlign_changed(int align)
142 {
143         ControlTabular::HALIGN h;
144
145         switch (align) {
146                 case 0: h = ControlTabular::LEFT; break;
147                 case 1: h = ControlTabular::CENTER; break;
148                 case 2: h = ControlTabular::RIGHT; break;
149                 case 3: h = ControlTabular::BLOCK; break;
150         }
151
152         form_->controller().halign(h);
153 }
154
155
156 void QTabularDialog::vAlign_changed(int align)
157 {
158         ControlTabular::VALIGN v;
159
160         switch (align) {
161                 case 0: v = ControlTabular::TOP; break;
162                 case 1: v = ControlTabular::VCENTER; break;
163                 case 2: v = ControlTabular::BOTTOM; break;
164         }
165
166         form_->controller().valign(v);
167 }
168
169
170 void QTabularDialog::longTabular()
171 {
172         form_->controller().longTabular(longTabularCB->isChecked());
173         form_->changed();
174 }
175
176
177 void QTabularDialog::ltNewpage_clicked()
178 {
179         form_->controller().set(LyXTabular::SET_LTNEWPAGE);
180         form_->changed();
181 }
182
183
184 void QTabularDialog::ltHeaderStatus_clicked()
185 {
186         bool enable(headerStatusCB->isChecked());
187         if (enable)
188                 form_->controller().set(LyXTabular::SET_LTHEAD, "");
189         else
190                 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
191         headerBorderAboveCB->setEnabled(enable);
192         headerBorderBelowCB->setEnabled(enable);
193         firstheaderNoContentsCB->setEnabled(enable);
194         form_->changed();
195 }
196
197
198 void QTabularDialog::ltHeaderBorderAbove_clicked()
199 {
200         if (headerBorderAboveCB->isChecked())
201                 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
202         else
203                 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
204         form_->changed();
205 }
206
207
208 void QTabularDialog::ltHeaderBorderBelow_clicked()
209 {
210         if (headerBorderBelowCB->isChecked())
211                 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
212         else
213                 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
214         form_->changed();
215 }
216
217
218 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
219 {
220         if (firstheaderBorderAboveCB->isChecked())
221                 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
222         else
223                 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
224         form_->changed();
225 }
226
227
228 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
229 {
230         if (firstheaderBorderBelowCB->isChecked())
231                 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
232         else
233                 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
234         form_->changed();
235 }
236
237
238 void QTabularDialog::ltFirstHeaderStatus_clicked()
239 {
240         bool enable(firstheaderStatusCB->isChecked());
241         if (enable)
242                 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
243         else
244                 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
245         firstheaderBorderAboveCB->setEnabled(enable);
246         firstheaderBorderBelowCB->setEnabled(enable);
247         form_->changed();
248 }
249
250
251 void QTabularDialog::ltFirstHeaderEmpty_clicked()
252 {
253         bool enable(firstheaderNoContentsCB->isChecked());
254         if (enable)
255                 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
256         else {
257                 ltFirstHeaderBorderBelow_clicked();
258                 ltFirstHeaderBorderAbove_clicked();
259         }
260         firstheaderStatusCB->setEnabled(!enable);
261         firstheaderBorderAboveCB->setEnabled(!enable);
262         firstheaderBorderBelowCB->setEnabled(!enable);
263         form_->changed();
264 }
265
266
267 void QTabularDialog::ltFooterStatus_clicked()
268 {
269         bool enable(footerStatusCB->isChecked());
270         if (enable)
271                 form_->controller().set(LyXTabular::SET_LTFOOT, "");
272         else
273                 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
274         footerBorderAboveCB->setEnabled(enable);
275         footerBorderBelowCB->setEnabled(enable);
276         lastfooterNoContentsCB->setEnabled(enable);
277         form_->changed();
278 }
279
280
281 void QTabularDialog::ltFooterBorderAbove_clicked()
282 {
283         if (footerBorderAboveCB->isChecked())
284                 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
285         else
286                 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
287         form_->changed();
288 }
289
290
291 void QTabularDialog::ltFooterBorderBelow_clicked()
292 {
293         if (footerBorderBelowCB->isChecked())
294                 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
295         else
296                 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
297         form_->changed();
298 }
299
300
301 void QTabularDialog::ltLastFooterStatus_clicked()
302 {
303         bool enable(lastfooterStatusCB->isChecked());
304         if (enable)
305                 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
306         else
307                 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
308         lastfooterBorderAboveCB->setEnabled(enable);
309         lastfooterBorderBelowCB->setEnabled(enable);
310         form_->changed();
311 }
312
313
314 void QTabularDialog::ltLastFooterBorderAbove_clicked()
315 {
316         if (lastfooterBorderAboveCB->isChecked())
317                 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
318         else
319                 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
320         form_->changed();
321 }
322
323
324 void QTabularDialog::ltLastFooterBorderBelow_clicked()
325 {
326         if (lastfooterBorderBelowCB->isChecked())
327                 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
328         else
329                 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
330         form_->changed();
331 }
332
333
334 void QTabularDialog::ltLastFooterEmpty_clicked()
335 {
336         bool enable(lastfooterNoContentsCB->isChecked());
337         if (enable)
338                 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
339         else {
340                 ltLastFooterBorderBelow_clicked();
341                 ltLastFooterBorderAbove_clicked();
342         }
343         lastfooterStatusCB->setEnabled(!enable);
344         lastfooterBorderAboveCB->setEnabled(!enable);
345         lastfooterBorderBelowCB->setEnabled(!enable);
346         form_->changed();
347 }