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