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