]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormTabular.C
Fixed small problem in InsetText and start for a better tabular layout
[lyx.git] / src / frontends / xforms / FormTabular.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1995 Matthias Ettrich
7  *          Copyright 1995-2001 The LyX Team.
8  *
9  *======================================================*/
10 /* FormTabular.C
11  * FormTabular Interface Class Implementation
12  */
13
14 #include <config.h>
15
16 #ifdef __GNUG__
17 #pragma implementation
18 #endif
19
20 #include "FormTabular.h"
21 #include "form_tabular.h"
22 #include "LyXView.h"
23 #include "Dialogs.h"
24 #include "insets/insettabular.h"
25 #include "buffer.h"
26 #include "xforms_helpers.h"
27 #include "helper_funcs.h"
28 #include "input_validators.h"
29 #include "support/lstrings.h"
30
31 using SigC::slot;
32
33 FormTabular::FormTabular(LyXView * lv, Dialogs * d)
34         : FormInset(lv, d, _("Tabular Layout")),
35           inset_(0), actCell_(-1)
36 {
37         // let the dialog be shown
38         // This is a permanent connection so we won't bother
39         // storing a copy because we won't be disconnecting.
40         d->showTabular.connect(slot(this, &FormTabular::showInset));
41         d->updateTabular.connect(slot(this, &FormTabular::updateInset));
42 }
43
44
45 void FormTabular::redraw()
46 {
47         if(form() && form()->visible)
48                 fl_redraw_form(form());
49         else
50                 return;
51
52         FL_FORM * outer_form = fl_get_active_folder(dialog_->tabFolder);
53         if (outer_form && outer_form->visible)
54                 fl_redraw_form(outer_form);
55 }
56
57
58 FL_FORM * FormTabular::form() const
59 {
60         if (dialog_.get())
61                 return dialog_->form;
62         return 0;
63 }
64
65
66 void FormTabular::disconnect()
67 {
68         inset_ = 0;
69         FormInset::disconnect();
70 }
71
72
73 void FormTabular::showInset(InsetTabular * inset)
74 {
75         if (inset == 0) return;
76
77         // If connected to another inset, disconnect from it.
78         if (inset_ != inset) {
79                 ih_.disconnect();
80                 ih_ = inset->hideDialog.connect(slot(this, &FormTabular::hide));
81                 inset_ = inset;
82         }
83
84         show();
85 }
86
87
88 void FormTabular::updateInset(InsetTabular * inset)
89 {
90         if (inset == 0 || inset_ == 0) return;
91
92         // If connected to another inset, disconnect from it.
93         if (inset_ != inset) {
94                 ih_.disconnect();
95                 ih_ = inset->hideDialog.connect(slot(this, &FormTabular::hide));
96                 inset_ = inset;
97         }
98
99         update();
100 }
101
102
103 void FormTabular::build()
104 {
105         dialog_.reset(build_tabular());
106         tabular_options_.reset(build_tabular_options());
107         column_options_.reset(build_column_options());
108         cell_options_.reset(build_cell_options());
109         longtable_options_.reset(build_longtable_options());
110
111         fl_set_input_return(column_options_->input_column_width,
112                             FL_RETURN_END);
113         fl_set_input_return(column_options_->input_special_alignment,
114                             FL_RETURN_END);
115         fl_set_input_return(cell_options_->input_mcolumn_width,
116                             FL_RETURN_END);
117         fl_set_input_return(cell_options_->input_special_multialign,
118                             FL_RETURN_END);
119
120         fl_addto_tabfolder(dialog_->tabFolder, _("Tabular"),
121                            tabular_options_->form);
122         fl_addto_tabfolder(dialog_->tabFolder, _("Column/Row"),
123                            column_options_->form);
124         fl_addto_tabfolder(dialog_->tabFolder, _("Cell"),
125                            cell_options_->form);
126         fl_addto_tabfolder(dialog_->tabFolder, _("LongTable"),
127                            longtable_options_->form);
128
129         // We should set these input filters on width fields to make them accept
130         // only unsigned numbers.
131         // But this leeds to trouble with the current apply behaviour (JSpitzm).
132         // fl_set_input_filter(column_options_->input_column_width,
133         //                  fl_unsigned_float_filter);
134         // fl_set_input_filter(cell_options_->input_mcolumn_width,
135         //                  fl_unsigned_float_filter);
136
137         // Create the contents of the unit choices
138         // Don't include the "%" terms...
139         std::vector<string> units_vec = getLatexUnits();
140         for (std::vector<string>::iterator it = units_vec.begin();
141              it != units_vec.end(); ++it) {
142                 if (contains(*it, "%"))
143                         it = units_vec.erase(it, it + 1) - 1;
144         }
145         string units = getStringFromVector(units_vec, "|");
146
147         fl_addto_choice(column_options_->choice_value_column_width,
148                         units.c_str());
149         fl_addto_choice(cell_options_->choice_value_mcolumn_width,
150                         units.c_str());
151 }
152
153
154 void FormTabular::update()
155 {
156         if (!inset_ || !inset_->tabular.get())
157                 return;
158
159         LyXTabular * tabular = inset_->tabular.get();
160         int align;
161         char buf[12];
162         LyXLength pwidth;
163         string special;
164
165         int cell = inset_->getActCell();
166         actCell_ = cell;
167         int column = tabular->column_of_cell(cell) + 1;
168         fl_set_object_label(dialog_->text_warning, "");
169         fl_activate_object(column_options_->input_special_alignment);
170         fl_activate_object(cell_options_->input_special_multialign);
171         fl_activate_object(column_options_->input_column_width);
172         fl_activate_object(column_options_->choice_value_column_width);
173         sprintf(buf, "%d", column);
174         fl_set_input(dialog_->input_tabular_column, buf);
175         fl_deactivate_object(dialog_->input_tabular_column);
176         int row = tabular->row_of_cell(cell);
177         sprintf(buf, "%d", row + 1);
178         fl_set_input(dialog_->input_tabular_row, buf);
179         fl_deactivate_object(dialog_->input_tabular_row);
180         if (tabular->IsMultiColumn(cell)) {
181                 fl_set_button(cell_options_->radio_multicolumn, 1);
182                 fl_set_button(cell_options_->radio_border_top,
183                               tabular->TopLine(cell)?1:0);
184                 setEnabled(cell_options_->radio_border_top, true);
185                 fl_set_button(cell_options_->radio_border_bottom,
186                               tabular->BottomLine(cell)?1:0);
187                 setEnabled(cell_options_->radio_border_bottom, true);
188                 fl_set_button(cell_options_->radio_border_left,
189                               tabular->LeftLine(cell)?1:0);
190                 setEnabled(cell_options_->radio_border_left, true);
191                 fl_set_button(cell_options_->radio_border_right,
192                               tabular->RightLine(cell)?1:0);
193                 setEnabled(cell_options_->radio_border_right, true);
194                 pwidth = tabular->GetMColumnPWidth(cell);
195                 align = tabular->GetAlignment(cell);
196                 if (!pwidth.zero() || (align == LYX_ALIGN_LEFT))
197                         fl_set_button(cell_options_->radio_align_left, 1);
198                 else if (align == LYX_ALIGN_RIGHT)
199                         fl_set_button(cell_options_->radio_align_right, 1);
200                 else
201                         fl_set_button(cell_options_->radio_align_center, 1);
202                 setEnabled(cell_options_->radio_align_left,   true);
203                 setEnabled(cell_options_->radio_align_right,  true);
204                 setEnabled(cell_options_->radio_align_center, true);
205                 align = tabular->GetVAlignment(cell);
206                 fl_set_button(cell_options_->radio_valign_top, 0);
207                 fl_set_button(cell_options_->radio_valign_bottom, 0);
208                 fl_set_button(cell_options_->radio_valign_center, 0);
209                 if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_CENTER))
210                         fl_set_button(cell_options_->radio_valign_center, 1);
211                 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
212                         fl_set_button(cell_options_->radio_valign_bottom, 1);
213                 else
214                         fl_set_button(cell_options_->radio_valign_top, 1);
215                 setEnabled(cell_options_->radio_valign_top,    true);
216                 setEnabled(cell_options_->radio_valign_bottom, true);
217                 setEnabled(cell_options_->radio_valign_center, true);
218                 special = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
219                 fl_set_input(cell_options_->input_special_multialign, special.c_str());
220                 string const default_unit = "cm";
221                 updateWidgetsFromLength(cell_options_->input_mcolumn_width,
222                                         cell_options_->choice_value_mcolumn_width,
223                                         pwidth, default_unit);
224
225                 if (!lv_->buffer()->isReadonly()) {
226                         setEnabled(cell_options_->input_special_multialign, true);
227                         setEnabled(cell_options_->input_mcolumn_width, true);
228                         setEnabled(cell_options_->choice_value_mcolumn_width, true);
229                 }
230
231                 setEnabled(cell_options_->radio_valign_top,    !pwidth.zero());
232                 setEnabled(cell_options_->radio_valign_bottom, !pwidth.zero());
233                 setEnabled(cell_options_->radio_valign_center, !pwidth.zero());
234                 
235                 setEnabled(cell_options_->radio_align_left,   pwidth.zero());
236                 setEnabled(cell_options_->radio_align_right,  pwidth.zero());
237                 setEnabled(cell_options_->radio_align_center, pwidth.zero());
238         } else {
239                 fl_set_button(cell_options_->radio_multicolumn, 0);
240
241                 fl_set_button(cell_options_->radio_border_top, 0);
242                 setEnabled(cell_options_->radio_border_top, false);
243
244                 fl_set_button(cell_options_->radio_border_bottom, 0);
245                 setEnabled(cell_options_->radio_border_bottom, false);
246
247                 fl_set_button(cell_options_->radio_border_left, 0);
248                 setEnabled(cell_options_->radio_border_left, false);
249
250                 fl_set_button(cell_options_->radio_border_right, 0);
251                 setEnabled(cell_options_->radio_border_right, false);
252
253                 fl_set_button(cell_options_->radio_align_left, 0);
254                 setEnabled(cell_options_->radio_align_left, false);
255
256                 fl_set_button(cell_options_->radio_align_right, 0);
257                 setEnabled(cell_options_->radio_align_right, false);
258
259                 fl_set_button(cell_options_->radio_align_center, 0);
260                 setEnabled(cell_options_->radio_align_center, false);
261
262                 fl_set_button(cell_options_->radio_valign_top, 0);
263                 setEnabled(cell_options_->radio_valign_top, false);
264
265                 fl_set_button(cell_options_->radio_valign_bottom, 0);
266                 setEnabled(cell_options_->radio_valign_bottom, false);
267
268                 fl_set_button(cell_options_->radio_valign_center, 0);
269                 setEnabled(cell_options_->radio_valign_center, false);
270
271                 fl_set_input(cell_options_->input_special_multialign, "");
272                 setEnabled(cell_options_->input_special_multialign, false);
273
274                 fl_set_input(cell_options_->input_mcolumn_width, "");
275                 setEnabled(cell_options_->input_mcolumn_width, false);
276                 setEnabled(cell_options_->choice_value_mcolumn_width, false);
277         }
278         if (tabular->GetRotateCell(cell))
279                 fl_set_button(cell_options_->radio_rotate_cell, 1);
280         else
281                 fl_set_button(cell_options_->radio_rotate_cell, 0);
282         if (tabular->TopLine(cell, true))
283                 fl_set_button(column_options_->radio_border_top, 1);
284         else
285                 fl_set_button(column_options_->radio_border_top, 0);
286         if (tabular->BottomLine(cell, true))
287                 fl_set_button(column_options_->radio_border_bottom, 1);
288         else
289                 fl_set_button(column_options_->radio_border_bottom, 0);
290         if (tabular->LeftLine(cell, true))
291                 fl_set_button(column_options_->radio_border_left, 1);
292         else
293                 fl_set_button(column_options_->radio_border_left, 0);
294         if (tabular->RightLine(cell, true))
295                 fl_set_button(column_options_->radio_border_right, 1);
296         else
297                 fl_set_button(column_options_->radio_border_right, 0);
298         special = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
299         fl_set_input(column_options_->input_special_alignment, special.c_str());
300
301         bool const isReadonly = lv_->buffer()->isReadonly();
302         setEnabled(column_options_->input_special_alignment, !isReadonly);
303
304         pwidth = tabular->GetColumnPWidth(cell);
305         string const default_unit = "cm";
306         updateWidgetsFromLength(column_options_->input_column_width,
307                                 column_options_->choice_value_column_width,
308                                 pwidth, default_unit);
309         setEnabled(column_options_->input_column_width, !isReadonly);
310         setEnabled(column_options_->choice_value_column_width, !isReadonly);
311
312         setEnabled(cell_options_->radio_useminipage, !pwidth.zero());
313         if (!pwidth.zero()) {
314                 if (tabular->GetUsebox(cell) == 2)
315                         fl_set_button(cell_options_->radio_useminipage, 1);
316                 else
317                         fl_set_button(cell_options_->radio_useminipage, 0);
318         } else {
319                 fl_set_button(cell_options_->radio_useminipage, 0);
320         }
321         align = tabular->GetAlignment(cell, true);
322         fl_set_button(column_options_->radio_align_left, 0);
323         fl_set_button(column_options_->radio_align_right, 0);
324         fl_set_button(column_options_->radio_align_center, 0);
325         if (!pwidth.zero() || (align == LYX_ALIGN_LEFT))
326                 fl_set_button(column_options_->radio_align_left, 1);
327         else if (align == LYX_ALIGN_RIGHT)
328                 fl_set_button(column_options_->radio_align_right, 1);
329         else
330                 fl_set_button(column_options_->radio_align_center, 1);
331         align = tabular->GetVAlignment(cell, true);
332         fl_set_button(column_options_->radio_valign_top, 0);
333         fl_set_button(column_options_->radio_valign_bottom, 0);
334         fl_set_button(column_options_->radio_valign_center, 0);
335         if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_CENTER))
336                 fl_set_button(column_options_->radio_valign_center, 1);
337         else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
338                 fl_set_button(column_options_->radio_valign_bottom, 1);
339         else
340                 fl_set_button(column_options_->radio_valign_top, 1);
341
342         setEnabled(column_options_->radio_align_left,   pwidth.zero());
343         setEnabled(column_options_->radio_align_right,  pwidth.zero());
344         setEnabled(column_options_->radio_align_center, pwidth.zero());
345         
346         setEnabled(column_options_->radio_valign_top,    !pwidth.zero());
347         setEnabled(column_options_->radio_valign_bottom, !pwidth.zero());
348         setEnabled(column_options_->radio_valign_center, !pwidth.zero());
349
350         fl_set_button(tabular_options_->radio_longtable,
351                       tabular->IsLongTabular());
352
353         bool const enable = tabular->IsLongTabular();
354             
355         setEnabled(longtable_options_->radio_lt_firsthead, enable);
356         setEnabled(longtable_options_->check_1head_2border_above, enable);
357         setEnabled(longtable_options_->check_1head_2border_below, enable);
358         setEnabled(longtable_options_->check_1head_empty, enable);
359         setEnabled(longtable_options_->radio_lt_head, enable);
360         setEnabled(longtable_options_->check_head_2border_above, enable);
361         setEnabled(longtable_options_->check_head_2border_below, enable);
362         setEnabled(longtable_options_->radio_lt_foot, enable);
363         setEnabled(longtable_options_->check_foot_2border_above, enable);
364         setEnabled(longtable_options_->check_foot_2border_below, enable);
365         setEnabled(longtable_options_->radio_lt_lastfoot, enable);
366         setEnabled(longtable_options_->check_lastfoot_2border_above, enable);
367         setEnabled(longtable_options_->check_lastfoot_2border_below, enable);
368         setEnabled(longtable_options_->check_lastfoot_empty, enable);
369         setEnabled(longtable_options_->radio_lt_newpage, enable);
370
371         if (enable) {
372                 LyXTabular::ltType ltt;
373                 fl_set_button(longtable_options_->radio_lt_firsthead,
374                                           tabular->GetRowOfLTFirstHead(row, ltt));
375                 if (ltt.row && !ltt.empty) {
376                         fl_set_button(longtable_options_->check_1head_2border_above,
377                                       ltt.topDL);
378                         fl_set_button(longtable_options_->check_1head_2border_above,
379                                           ltt.topDL);
380                 } else {
381                         setEnabled(longtable_options_->check_1head_2border_above, 0);
382                         setEnabled(longtable_options_->check_1head_2border_below, 0);
383                         fl_set_button(longtable_options_->check_1head_2border_above,0);
384                         fl_set_button(longtable_options_->check_1head_2border_above,0);
385                         fl_set_button(longtable_options_->check_1head_empty,ltt.empty);
386                         if (ltt.empty)
387                                 setEnabled(longtable_options_->radio_lt_firsthead, 0);
388                 }
389                 fl_set_button(longtable_options_->radio_lt_head,
390                               tabular->GetRowOfLTHead(row, ltt));
391                 if (ltt.row) {
392                         fl_set_button(longtable_options_->check_head_2border_above,
393                                           ltt.topDL);
394                         fl_set_button(longtable_options_->check_head_2border_above,
395                                       ltt.topDL);
396                 } else {
397                         setEnabled(longtable_options_->check_head_2border_above, 0);
398                         setEnabled(longtable_options_->check_head_2border_below, 0);
399                         fl_set_button(longtable_options_->check_head_2border_above,0);
400                         fl_set_button(longtable_options_->check_head_2border_above,0);
401                 }
402                 fl_set_button(longtable_options_->radio_lt_foot,
403                               tabular->GetRowOfLTFoot(row, ltt));
404                 if (ltt.row) {
405                         fl_set_button(longtable_options_->check_foot_2border_above,
406                                       ltt.topDL);
407                         fl_set_button(longtable_options_->check_foot_2border_above,
408                                       ltt.topDL);
409                 } else {
410                         setEnabled(longtable_options_->check_foot_2border_above, 0);
411                         setEnabled(longtable_options_->check_foot_2border_below, 0);
412                         fl_set_button(longtable_options_->check_foot_2border_above,0);
413                         fl_set_button(longtable_options_->check_foot_2border_above,0);
414                 }
415                 fl_set_button(longtable_options_->radio_lt_lastfoot,
416                               tabular->GetRowOfLTLastFoot(row, ltt));
417                 if (ltt.row && !ltt.empty) {
418                         fl_set_button(longtable_options_->check_lastfoot_2border_above,
419                                       ltt.topDL);
420                         fl_set_button(longtable_options_->check_lastfoot_2border_above,
421                                       ltt.topDL);
422                 } else {
423                         setEnabled(longtable_options_->check_lastfoot_2border_above,0);
424                         setEnabled(longtable_options_->check_lastfoot_2border_below,0);
425                         fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
426                         fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
427                         fl_set_button(longtable_options_->check_lastfoot_empty, ltt.empty);
428                         if (ltt.empty)
429                                 setEnabled(longtable_options_->radio_lt_lastfoot, 0);
430                 }
431                 fl_set_button(longtable_options_->radio_lt_newpage,
432                               tabular->GetLTNewPage(row));
433         } else {
434                 fl_set_button(longtable_options_->radio_lt_firsthead, 0);
435                 fl_set_button(longtable_options_->check_1head_2border_above, 0);
436                 fl_set_button(longtable_options_->check_1head_2border_above, 0);
437                 fl_set_button(longtable_options_->check_1head_empty, 0);
438                 fl_set_button(longtable_options_->radio_lt_head, 0);
439                 fl_set_button(longtable_options_->check_head_2border_above, 0);
440                 fl_set_button(longtable_options_->check_head_2border_above, 0);
441                 fl_set_button(longtable_options_->radio_lt_foot, 0);
442                 fl_set_button(longtable_options_->check_foot_2border_above, 0);
443                 fl_set_button(longtable_options_->check_foot_2border_above, 0);
444                 fl_set_button(longtable_options_->radio_lt_lastfoot, 0);
445                 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
446                 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
447                 fl_set_button(longtable_options_->check_lastfoot_empty, 0);
448                 fl_set_button(longtable_options_->radio_lt_newpage, 0);
449         }
450         fl_set_button(tabular_options_->radio_rotate_tabular,
451                       tabular->GetRotateTabular());
452 }
453
454
455 bool FormTabular::input(FL_OBJECT * ob, long)
456 {
457     if (!inset_)
458         return false;
459
460     int s;
461     LyXTabular::Feature num = LyXTabular::LAST_ACTION;
462     string special;;
463
464     int cell = inset_->getActCell();
465         
466     if (actCell_ != cell) {
467         update();
468         fl_set_object_label(dialog_->text_warning,
469                      _("Warning: Wrong Cursor position, updated window"));
470         fl_show_object(dialog_->text_warning);
471         return false;
472     }
473     // No point in processing directives that you can't do anything with
474     // anyhow, so exit now if the buffer is read-only.
475     if (lv_->buffer()->isReadonly()) {
476       update();
477       return false;
478     }
479     if ((ob == column_options_->input_column_width) ||
480                 (ob == column_options_->choice_value_column_width))
481         {
482             string const str =
483                     getLengthFromWidgets(column_options_->input_column_width,
484                                          column_options_->choice_value_column_width);
485         inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH, str);
486         update(); // update for alignment
487         return true;
488     }
489     if ((ob == cell_options_->input_mcolumn_width) ||
490                 (ob == cell_options_->choice_value_mcolumn_width))
491         {
492             string const str =
493                     getLengthFromWidgets(cell_options_->input_mcolumn_width,
494                                          cell_options_->choice_value_mcolumn_width);
495         inset_->tabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH, str);
496         update(); // update for alignment
497         return true;
498     }
499
500     if (ob == tabular_options_->button_append_row)
501         num = LyXTabular::APPEND_ROW;
502     else if (ob == tabular_options_->button_append_column)
503         num = LyXTabular::APPEND_COLUMN;
504     else if (ob == tabular_options_->button_delete_row)
505         num = LyXTabular::DELETE_ROW;
506     else if (ob == tabular_options_->button_delete_column)
507         num = LyXTabular::DELETE_COLUMN;
508     else if (ob == tabular_options_->button_set_borders)
509         num = LyXTabular::SET_ALL_LINES;
510     else if (ob == tabular_options_->button_unset_borders)
511         num = LyXTabular::UNSET_ALL_LINES;
512     else if (ob == column_options_->radio_border_top)
513         num = LyXTabular::TOGGLE_LINE_TOP;
514     else if (ob == column_options_->radio_border_bottom)
515         num = LyXTabular::TOGGLE_LINE_BOTTOM;
516     else if (ob == column_options_->radio_border_left)
517         num = LyXTabular::TOGGLE_LINE_LEFT;
518     else if (ob == column_options_->radio_border_right)
519         num = LyXTabular::TOGGLE_LINE_RIGHT;
520     else if (ob == column_options_->radio_align_left)
521         num = LyXTabular::ALIGN_LEFT;
522     else if (ob == column_options_->radio_align_right)
523         num = LyXTabular::ALIGN_RIGHT;
524     else if (ob == column_options_->radio_align_center)
525         num = LyXTabular::ALIGN_CENTER;
526     else if (ob == column_options_->radio_valign_top)
527         num = LyXTabular::VALIGN_TOP;
528     else if (ob == column_options_->radio_valign_bottom)
529         num = LyXTabular::VALIGN_BOTTOM;
530     else if (ob == column_options_->radio_valign_center)
531         num = LyXTabular::VALIGN_CENTER;
532     else if (ob == cell_options_->radio_multicolumn)
533         num = LyXTabular::MULTICOLUMN;
534     else if (ob == tabular_options_->radio_longtable) {
535             if (fl_get_button(tabular_options_->radio_longtable))
536                     num = LyXTabular::SET_LONGTABULAR;
537                 else
538                         num = LyXTabular::UNSET_LONGTABULAR;
539     } else if (ob == tabular_options_->radio_rotate_tabular) {
540                 s = fl_get_button(tabular_options_->radio_rotate_tabular);
541                 if (s)
542                         num = LyXTabular::SET_ROTATE_TABULAR;
543                 else
544                         num = LyXTabular::UNSET_ROTATE_TABULAR;
545     } else if (ob == cell_options_->radio_rotate_cell) {
546                 s = fl_get_button(cell_options_->radio_rotate_cell);
547                 if (s)
548                         num = LyXTabular::SET_ROTATE_CELL;
549                 else
550                         num = LyXTabular::UNSET_ROTATE_CELL;
551     } else if (ob == cell_options_->radio_useminipage) {
552                 num = LyXTabular::SET_USEBOX;
553                 special = "2";
554     } else if ((ob == longtable_options_->radio_lt_firsthead) ||
555                            (ob == longtable_options_->check_1head_2border_above) ||
556                            (ob == longtable_options_->check_1head_2border_below) ||
557                            (ob == longtable_options_->check_1head_empty) ||
558                            (ob == longtable_options_->radio_lt_head) ||
559                            (ob == longtable_options_->check_head_2border_above) ||
560                            (ob == longtable_options_->check_head_2border_below) ||
561                            (ob == longtable_options_->radio_lt_foot) ||
562                            (ob == longtable_options_->check_foot_2border_above) ||
563                            (ob == longtable_options_->check_foot_2border_below) ||
564                            (ob == longtable_options_->radio_lt_lastfoot) ||
565                            (ob == longtable_options_->check_lastfoot_2border_above) ||
566                            (ob == longtable_options_->check_lastfoot_2border_below) ||
567                            (ob == longtable_options_->check_lastfoot_empty))
568         {
569                 num = static_cast<LyXTabular::Feature>(checkLongtableOptions(ob, special));
570     } else if (ob == longtable_options_->radio_lt_newpage) {
571         num = LyXTabular::SET_LTNEWPAGE;
572     } else if (ob == column_options_->input_special_alignment) {
573         special = fl_get_input(column_options_->input_special_alignment);
574         num = LyXTabular::SET_SPECIAL_COLUMN;
575     } else if (ob == cell_options_->input_special_multialign) {
576         special = fl_get_input(cell_options_->input_special_multialign);
577         num = LyXTabular::SET_SPECIAL_MULTI;
578     } else if (ob == cell_options_->radio_border_top)
579         num = LyXTabular::M_TOGGLE_LINE_TOP;
580     else if (ob == cell_options_->radio_border_bottom)
581         num = LyXTabular::M_TOGGLE_LINE_BOTTOM;
582     else if (ob == cell_options_->radio_border_left)
583         num = LyXTabular::M_TOGGLE_LINE_LEFT;
584     else if (ob == cell_options_->radio_border_right)
585         num = LyXTabular::M_TOGGLE_LINE_RIGHT;
586     else if (ob == cell_options_->radio_align_left)
587         num = LyXTabular::M_ALIGN_LEFT;
588     else if (ob == cell_options_->radio_align_right)
589         num = LyXTabular::M_ALIGN_RIGHT;
590     else if (ob == cell_options_->radio_align_center)
591         num = LyXTabular::M_ALIGN_CENTER;
592     else if (ob == cell_options_->radio_valign_top)
593         num = LyXTabular::M_VALIGN_TOP;
594     else if (ob == cell_options_->radio_valign_bottom)
595         num = LyXTabular::M_VALIGN_BOTTOM;
596     else if (ob == cell_options_->radio_valign_center)
597         num = LyXTabular::M_VALIGN_CENTER;
598     else
599         return false;
600     
601     inset_->tabularFeatures(lv_->view(), num, special);
602     update();
603
604     return true;
605 }
606
607 int FormTabular::checkLongtableOptions(FL_OBJECT * ob, string & special)
608 {
609         bool flag = fl_get_button(ob);
610         if ((ob == longtable_options_->check_1head_2border_above) ||
611                 (ob == longtable_options_->check_head_2border_above) ||
612                 (ob == longtable_options_->check_foot_2border_above) ||
613                 (ob == longtable_options_->check_lastfoot_2border_above))
614         {
615                 special = "dl_above";
616         } else if ((ob == longtable_options_->check_1head_2border_below) ||
617                            (ob == longtable_options_->check_head_2border_below) ||
618                            (ob == longtable_options_->check_foot_2border_below) ||
619                            (ob == longtable_options_->check_lastfoot_2border_below))
620         {
621                 special = "dl_below";
622         } else if ((ob == longtable_options_->check_1head_empty) ||
623                            (ob == longtable_options_->check_lastfoot_empty))
624         {
625                 special = "empty";
626         } else {
627                 special = "";
628         }
629         if ((ob == longtable_options_->radio_lt_firsthead) ||
630                 (ob == longtable_options_->check_1head_2border_above) ||
631                 (ob == longtable_options_->check_1head_2border_below) ||
632                 (ob == longtable_options_->check_1head_empty))
633         {
634                 return (flag ? LyXTabular::SET_LTFIRSTHEAD :
635                                 LyXTabular::UNSET_LTFIRSTHEAD);
636     } else if ((ob == longtable_options_->radio_lt_head) ||
637                            (ob == longtable_options_->check_head_2border_above) ||
638                            (ob == longtable_options_->check_head_2border_below))
639         {
640                 return (flag ? LyXTabular::SET_LTHEAD : LyXTabular::UNSET_LTHEAD);
641     } else if ((ob == longtable_options_->radio_lt_foot) ||
642                            (ob == longtable_options_->check_foot_2border_above) ||
643                            (ob == longtable_options_->check_foot_2border_below))
644         {
645                 return (flag ? LyXTabular::SET_LTFOOT : LyXTabular::UNSET_LTFOOT);
646     } else if ((ob == longtable_options_->radio_lt_lastfoot) ||
647                            (ob == longtable_options_->check_lastfoot_2border_above) ||
648                            (ob == longtable_options_->check_lastfoot_2border_below) ||
649                            (ob == longtable_options_->check_lastfoot_empty))
650         {
651                 return (flag ? LyXTabular::SET_LTLASTFOOT :
652                                 LyXTabular::UNSET_LTLASTFOOT);
653         }
654         return LyXTabular::LAST_ACTION;
655 }