]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormTabular.C
0848acfca01a4ffde7d59a86fe31eafce03f0ea6
[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                 setEnabled(cell_options_->radio_align_left,   true);
207                 setEnabled(cell_options_->radio_align_right,  true);
208                 setEnabled(cell_options_->radio_align_center, true);
209                 align = tabular->GetVAlignment(cell);
210                 fl_set_button(cell_options_->radio_valign_top, 0);
211                 fl_set_button(cell_options_->radio_valign_bottom, 0);
212                 fl_set_button(cell_options_->radio_valign_center, 0);
213                 if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_CENTER))
214                         fl_set_button(cell_options_->radio_valign_center, 1);
215                 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
216                         fl_set_button(cell_options_->radio_valign_bottom, 1);
217                 else
218                         fl_set_button(cell_options_->radio_valign_top, 1);
219                 setEnabled(cell_options_->radio_valign_top,    true);
220                 setEnabled(cell_options_->radio_valign_bottom, true);
221                 setEnabled(cell_options_->radio_valign_center, true);
222                 special = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
223                 fl_set_input(cell_options_->input_special_multialign, special.c_str());
224                 bool const metric = lyxrc.default_papersize > 3;
225                 string const default_unit = metric ? "cm" : "in";
226                 updateWidgetsFromLength(cell_options_->input_mcolumn_width,
227                                         cell_options_->choice_value_mcolumn_width,
228                                         pwidth, default_unit);
229
230                 if (!lv_->buffer()->isReadonly()) {
231                         setEnabled(cell_options_->input_special_multialign, true);
232                         setEnabled(cell_options_->input_mcolumn_width, true);
233                         setEnabled(cell_options_->choice_value_mcolumn_width, true);
234                 }
235
236                 setEnabled(cell_options_->radio_valign_top,    !pwidth.zero());
237                 setEnabled(cell_options_->radio_valign_bottom, !pwidth.zero());
238                 setEnabled(cell_options_->radio_valign_center, !pwidth.zero());
239                 
240                 setEnabled(cell_options_->radio_align_left,   pwidth.zero());
241                 setEnabled(cell_options_->radio_align_right,  pwidth.zero());
242                 setEnabled(cell_options_->radio_align_center, pwidth.zero());
243         } else {
244                 fl_set_button(cell_options_->radio_multicolumn, 0);
245
246                 fl_set_button(cell_options_->radio_border_top, 0);
247                 setEnabled(cell_options_->radio_border_top, false);
248
249                 fl_set_button(cell_options_->radio_border_bottom, 0);
250                 setEnabled(cell_options_->radio_border_bottom, false);
251
252                 fl_set_button(cell_options_->radio_border_left, 0);
253                 setEnabled(cell_options_->radio_border_left, false);
254
255                 fl_set_button(cell_options_->radio_border_right, 0);
256                 setEnabled(cell_options_->radio_border_right, false);
257
258                 fl_set_button(cell_options_->radio_align_left, 0);
259                 setEnabled(cell_options_->radio_align_left, false);
260
261                 fl_set_button(cell_options_->radio_align_right, 0);
262                 setEnabled(cell_options_->radio_align_right, false);
263
264                 fl_set_button(cell_options_->radio_align_center, 0);
265                 setEnabled(cell_options_->radio_align_center, false);
266
267                 fl_set_button(cell_options_->radio_valign_top, 0);
268                 setEnabled(cell_options_->radio_valign_top, false);
269
270                 fl_set_button(cell_options_->radio_valign_bottom, 0);
271                 setEnabled(cell_options_->radio_valign_bottom, false);
272
273                 fl_set_button(cell_options_->radio_valign_center, 0);
274                 setEnabled(cell_options_->radio_valign_center, false);
275
276                 fl_set_input(cell_options_->input_special_multialign, "");
277                 setEnabled(cell_options_->input_special_multialign, false);
278
279                 fl_set_input(cell_options_->input_mcolumn_width, "");
280                 setEnabled(cell_options_->input_mcolumn_width, false);
281                 setEnabled(cell_options_->choice_value_mcolumn_width, false);
282         }
283         if (tabular->GetRotateCell(cell))
284                 fl_set_button(cell_options_->radio_rotate_cell, 1);
285         else
286                 fl_set_button(cell_options_->radio_rotate_cell, 0);
287         if (tabular->TopLine(cell, true))
288                 fl_set_button(column_options_->radio_border_top, 1);
289         else
290                 fl_set_button(column_options_->radio_border_top, 0);
291         if (tabular->BottomLine(cell, true))
292                 fl_set_button(column_options_->radio_border_bottom, 1);
293         else
294                 fl_set_button(column_options_->radio_border_bottom, 0);
295         if (tabular->LeftLine(cell, true))
296                 fl_set_button(column_options_->radio_border_left, 1);
297         else
298                 fl_set_button(column_options_->radio_border_left, 0);
299         if (tabular->RightLine(cell, true))
300                 fl_set_button(column_options_->radio_border_right, 1);
301         else
302                 fl_set_button(column_options_->radio_border_right, 0);
303         special = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
304         fl_set_input(column_options_->input_special_alignment, special.c_str());
305
306         bool const isReadonly = lv_->buffer()->isReadonly();
307         setEnabled(column_options_->input_special_alignment, !isReadonly);
308
309         pwidth = tabular->GetColumnPWidth(cell);
310         bool const metric = lyxrc.default_papersize > 3;
311         string const default_unit = metric ? "cm" : "in";
312         updateWidgetsFromLength(column_options_->input_column_width,
313                                 column_options_->choice_value_column_width,
314                                 pwidth, default_unit);
315         setEnabled(column_options_->input_column_width, !isReadonly);
316         setEnabled(column_options_->choice_value_column_width, !isReadonly);
317
318         setEnabled(cell_options_->radio_useminipage, !pwidth.zero());
319         if (!pwidth.zero()) {
320                 if (tabular->GetUsebox(cell) == 2)
321                         fl_set_button(cell_options_->radio_useminipage, 1);
322                 else
323                         fl_set_button(cell_options_->radio_useminipage, 0);
324         } else {
325                 fl_set_button(cell_options_->radio_useminipage, 0);
326         }
327         align = tabular->GetAlignment(cell, true);
328         fl_set_button(column_options_->radio_align_left, 0);
329         fl_set_button(column_options_->radio_align_right, 0);
330         fl_set_button(column_options_->radio_align_center, 0);
331         if (!pwidth.zero() || (align == LYX_ALIGN_LEFT))
332                 fl_set_button(column_options_->radio_align_left, 1);
333         else if (align == LYX_ALIGN_RIGHT)
334                 fl_set_button(column_options_->radio_align_right, 1);
335         else
336                 fl_set_button(column_options_->radio_align_center, 1);
337         align = tabular->GetVAlignment(cell, true);
338         fl_set_button(column_options_->radio_valign_top, 0);
339         fl_set_button(column_options_->radio_valign_bottom, 0);
340         fl_set_button(column_options_->radio_valign_center, 0);
341         if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_CENTER))
342                 fl_set_button(column_options_->radio_valign_center, 1);
343         else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
344                 fl_set_button(column_options_->radio_valign_bottom, 1);
345         else
346                 fl_set_button(column_options_->radio_valign_top, 1);
347
348         setEnabled(column_options_->radio_align_left,   pwidth.zero());
349         setEnabled(column_options_->radio_align_right,  pwidth.zero());
350         setEnabled(column_options_->radio_align_center, pwidth.zero());
351         
352         setEnabled(column_options_->radio_valign_top,    !pwidth.zero());
353         setEnabled(column_options_->radio_valign_bottom, !pwidth.zero());
354         setEnabled(column_options_->radio_valign_center, !pwidth.zero());
355
356         fl_set_button(tabular_options_->radio_longtable,
357                       tabular->IsLongTabular());
358
359         bool const enable = tabular->IsLongTabular();
360             
361         setEnabled(longtable_options_->radio_lt_firsthead, enable);
362         setEnabled(longtable_options_->check_1head_2border_above, enable);
363         setEnabled(longtable_options_->check_1head_2border_below, enable);
364         setEnabled(longtable_options_->check_1head_empty, enable);
365         setEnabled(longtable_options_->radio_lt_head, enable);
366         setEnabled(longtable_options_->check_head_2border_above, enable);
367         setEnabled(longtable_options_->check_head_2border_below, enable);
368         setEnabled(longtable_options_->radio_lt_foot, enable);
369         setEnabled(longtable_options_->check_foot_2border_above, enable);
370         setEnabled(longtable_options_->check_foot_2border_below, enable);
371         setEnabled(longtable_options_->radio_lt_lastfoot, enable);
372         setEnabled(longtable_options_->check_lastfoot_2border_above, enable);
373         setEnabled(longtable_options_->check_lastfoot_2border_below, enable);
374         setEnabled(longtable_options_->check_lastfoot_empty, enable);
375         setEnabled(longtable_options_->radio_lt_newpage, enable);
376
377         if (enable) {
378                 LyXTabular::ltType ltt;
379                 bool use_empty;
380                 bool row_set = tabular->GetRowOfLTHead(row, ltt);
381                 fl_set_button(longtable_options_->radio_lt_head, row_set);
382                 if (ltt.set) {
383                         fl_set_button(longtable_options_->check_head_2border_above,
384                                           ltt.topDL);
385                         fl_set_button(longtable_options_->check_head_2border_above,
386                                       ltt.topDL);
387                         use_empty = true;
388                 } else {
389                         setEnabled(longtable_options_->check_head_2border_above, 0);
390                         setEnabled(longtable_options_->check_head_2border_below, 0);
391                         fl_set_button(longtable_options_->check_head_2border_above,0);
392                         fl_set_button(longtable_options_->check_head_2border_above,0);
393                         fl_set_button(longtable_options_->check_1head_empty,0);
394                         setEnabled(longtable_options_->check_1head_empty, 0);
395                         use_empty = false;
396                 }
397                 //
398                 row_set = tabular->GetRowOfLTFirstHead(row, ltt);
399                 fl_set_button(longtable_options_->radio_lt_firsthead, row_set);
400                 if (ltt.set && (!ltt.empty || !use_empty)) {
401                         fl_set_button(longtable_options_->check_1head_2border_above,
402                                       ltt.topDL);
403                         fl_set_button(longtable_options_->check_1head_2border_above,
404                                           ltt.topDL);
405                 } else {
406                         setEnabled(longtable_options_->check_1head_2border_above, 0);
407                         setEnabled(longtable_options_->check_1head_2border_below, 0);
408                         fl_set_button(longtable_options_->check_1head_2border_above,0);
409                         fl_set_button(longtable_options_->check_1head_2border_above,0);
410                         if (use_empty) {
411                                 fl_set_button(longtable_options_->check_1head_empty,ltt.empty);
412                                 if (ltt.empty)
413                                         setEnabled(longtable_options_->radio_lt_firsthead, 0);
414                         }
415                 }
416                 //
417                 row_set = tabular->GetRowOfLTFoot(row, ltt);
418                 fl_set_button(longtable_options_->radio_lt_foot, row_set);
419                 if (ltt.set) {
420                         fl_set_button(longtable_options_->check_foot_2border_above,
421                                       ltt.topDL);
422                         fl_set_button(longtable_options_->check_foot_2border_above,
423                                       ltt.topDL);
424                         use_empty = true;
425                 } else {
426                         setEnabled(longtable_options_->check_foot_2border_above, 0);
427                         setEnabled(longtable_options_->check_foot_2border_below, 0);
428                         fl_set_button(longtable_options_->check_foot_2border_above,0);
429                         fl_set_button(longtable_options_->check_foot_2border_above,0);
430                         fl_set_button(longtable_options_->check_lastfoot_empty, 0);
431                         setEnabled(longtable_options_->check_lastfoot_empty, 0);
432                         use_empty = false;
433                 }
434                 //
435                 row_set = tabular->GetRowOfLTLastFoot(row, ltt);
436                 fl_set_button(longtable_options_->radio_lt_lastfoot, row_set);
437                 if (ltt.set && (!ltt.empty || !use_empty)) {
438                         fl_set_button(longtable_options_->check_lastfoot_2border_above,
439                                       ltt.topDL);
440                         fl_set_button(longtable_options_->check_lastfoot_2border_above,
441                                       ltt.topDL);
442                 } else {
443                         setEnabled(longtable_options_->check_lastfoot_2border_above,0);
444                         setEnabled(longtable_options_->check_lastfoot_2border_below,0);
445                         fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
446                         fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
447                         if (use_empty) {
448                                 fl_set_button(longtable_options_->check_lastfoot_empty,
449                                               ltt.empty);
450                                 if (ltt.empty)
451                                         setEnabled(longtable_options_->radio_lt_lastfoot, 0);
452                         }
453                 }
454                 fl_set_button(longtable_options_->radio_lt_newpage,
455                               tabular->GetLTNewPage(row));
456         } else {
457                 fl_set_button(longtable_options_->radio_lt_firsthead, 0);
458                 fl_set_button(longtable_options_->check_1head_2border_above, 0);
459                 fl_set_button(longtable_options_->check_1head_2border_above, 0);
460                 fl_set_button(longtable_options_->check_1head_empty, 0);
461                 fl_set_button(longtable_options_->radio_lt_head, 0);
462                 fl_set_button(longtable_options_->check_head_2border_above, 0);
463                 fl_set_button(longtable_options_->check_head_2border_above, 0);
464                 fl_set_button(longtable_options_->radio_lt_foot, 0);
465                 fl_set_button(longtable_options_->check_foot_2border_above, 0);
466                 fl_set_button(longtable_options_->check_foot_2border_above, 0);
467                 fl_set_button(longtable_options_->radio_lt_lastfoot, 0);
468                 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
469                 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
470                 fl_set_button(longtable_options_->check_lastfoot_empty, 0);
471                 fl_set_button(longtable_options_->radio_lt_newpage, 0);
472         }
473         fl_set_button(tabular_options_->radio_rotate_tabular,
474                       tabular->GetRotateTabular());
475 }
476
477
478 bool FormTabular::input(FL_OBJECT * ob, long)
479 {
480     if (!inset_)
481         return false;
482
483     int s;
484     LyXTabular::Feature num = LyXTabular::LAST_ACTION;
485     string special;;
486
487     int cell = inset_->getActCell();
488
489     // ugly hack to auto-apply the stuff that hasn't been
490     // yet. don't let this continue to exist ...
491     if (ob == dialog_->button_close) {
492         closing_ = true;
493         input(column_options_->input_column_width, 0);
494         input(cell_options_->input_mcolumn_width, 0);
495         input(column_options_->input_special_alignment, 0);
496         input(cell_options_->input_special_multialign, 0);
497         closing_ = false;
498         ok();
499         return true;
500     }
501  
502     if (actCell_ != cell) {
503         update();
504         fl_set_object_label(dialog_->text_warning,
505                      _("Warning: Wrong Cursor position, updated window"));
506         fl_show_object(dialog_->text_warning);
507         return false;
508     }
509     // No point in processing directives that you can't do anything with
510     // anyhow, so exit now if the buffer is read-only.
511     if (lv_->buffer()->isReadonly()) {
512       update();
513       return false;
514     }
515     if ((ob == column_options_->input_column_width) ||
516                 (ob == column_options_->choice_value_column_width))
517         {
518         string const str =
519                 getLengthFromWidgets(column_options_->input_column_width,
520                                  column_options_->choice_value_column_width);
521         inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH, str);
522
523         //check if the input is valid
524         string const input =
525                         fl_get_input(column_options_->input_column_width);
526         if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
527                 fl_set_object_label(dialog_->text_warning,
528                         _("Warning: Invalid Length (valid example: 10mm)"));
529                 fl_show_object(dialog_->text_warning);
530                 return false;
531         }
532         update(); // update for alignment
533         return true;
534     }
535     if ((ob == cell_options_->input_mcolumn_width) ||
536                 (ob == cell_options_->choice_value_mcolumn_width))
537         {
538         string const str =
539                 getLengthFromWidgets(cell_options_->input_mcolumn_width,
540                                  cell_options_->choice_value_mcolumn_width);
541         inset_->tabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH, str);
542
543         //check if the input is valid
544         string const input =
545                 fl_get_input(cell_options_->input_mcolumn_width);
546         if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
547                 fl_set_object_label(dialog_->text_warning,
548                         _("Warning: Invalid Length (valid example: 10mm)"));
549                 fl_show_object(dialog_->text_warning);
550                 return false;
551         }
552         update(); // update for alignment
553         return true;
554     }
555
556     if (ob == tabular_options_->button_append_row)
557         num = LyXTabular::APPEND_ROW;
558     else if (ob == tabular_options_->button_append_column)
559         num = LyXTabular::APPEND_COLUMN;
560     else if (ob == tabular_options_->button_delete_row)
561         num = LyXTabular::DELETE_ROW;
562     else if (ob == tabular_options_->button_delete_column)
563         num = LyXTabular::DELETE_COLUMN;
564     else if (ob == tabular_options_->button_set_borders)
565         num = LyXTabular::SET_ALL_LINES;
566     else if (ob == tabular_options_->button_unset_borders)
567         num = LyXTabular::UNSET_ALL_LINES;
568     else if (ob == column_options_->radio_border_top)
569         num = LyXTabular::TOGGLE_LINE_TOP;
570     else if (ob == column_options_->radio_border_bottom)
571         num = LyXTabular::TOGGLE_LINE_BOTTOM;
572     else if (ob == column_options_->radio_border_left)
573         num = LyXTabular::TOGGLE_LINE_LEFT;
574     else if (ob == column_options_->radio_border_right)
575         num = LyXTabular::TOGGLE_LINE_RIGHT;
576     else if (ob == column_options_->radio_align_left)
577         num = LyXTabular::ALIGN_LEFT;
578     else if (ob == column_options_->radio_align_right)
579         num = LyXTabular::ALIGN_RIGHT;
580     else if (ob == column_options_->radio_align_center)
581         num = LyXTabular::ALIGN_CENTER;
582     else if (ob == column_options_->radio_valign_top)
583         num = LyXTabular::VALIGN_TOP;
584     else if (ob == column_options_->radio_valign_bottom)
585         num = LyXTabular::VALIGN_BOTTOM;
586     else if (ob == column_options_->radio_valign_center)
587         num = LyXTabular::VALIGN_CENTER;
588     else if (ob == cell_options_->radio_multicolumn)
589         num = LyXTabular::MULTICOLUMN;
590     else if (ob == tabular_options_->radio_longtable) {
591             if (fl_get_button(tabular_options_->radio_longtable))
592                     num = LyXTabular::SET_LONGTABULAR;
593                 else
594                         num = LyXTabular::UNSET_LONGTABULAR;
595     } else if (ob == tabular_options_->radio_rotate_tabular) {
596                 s = fl_get_button(tabular_options_->radio_rotate_tabular);
597                 if (s)
598                         num = LyXTabular::SET_ROTATE_TABULAR;
599                 else
600                         num = LyXTabular::UNSET_ROTATE_TABULAR;
601     } else if (ob == cell_options_->radio_rotate_cell) {
602                 s = fl_get_button(cell_options_->radio_rotate_cell);
603                 if (s)
604                         num = LyXTabular::SET_ROTATE_CELL;
605                 else
606                         num = LyXTabular::UNSET_ROTATE_CELL;
607     } else if (ob == cell_options_->radio_useminipage) {
608                 num = LyXTabular::SET_USEBOX;
609                 special = "2";
610     } else if ((ob == longtable_options_->radio_lt_firsthead) ||
611                            (ob == longtable_options_->check_1head_2border_above) ||
612                            (ob == longtable_options_->check_1head_2border_below) ||
613                            (ob == longtable_options_->check_1head_empty) ||
614                            (ob == longtable_options_->radio_lt_head) ||
615                            (ob == longtable_options_->check_head_2border_above) ||
616                            (ob == longtable_options_->check_head_2border_below) ||
617                            (ob == longtable_options_->radio_lt_foot) ||
618                            (ob == longtable_options_->check_foot_2border_above) ||
619                            (ob == longtable_options_->check_foot_2border_below) ||
620                            (ob == longtable_options_->radio_lt_lastfoot) ||
621                            (ob == longtable_options_->check_lastfoot_2border_above) ||
622                            (ob == longtable_options_->check_lastfoot_2border_below) ||
623                            (ob == longtable_options_->check_lastfoot_empty))
624         {
625                 num = static_cast<LyXTabular::Feature>(checkLongtableOptions(ob, special));
626     } else if (ob == longtable_options_->radio_lt_newpage) {
627         num = LyXTabular::SET_LTNEWPAGE;
628     } else if (ob == column_options_->input_special_alignment) {
629         special = fl_get_input(column_options_->input_special_alignment);
630         num = LyXTabular::SET_SPECIAL_COLUMN;
631     } else if (ob == cell_options_->input_special_multialign) {
632         special = fl_get_input(cell_options_->input_special_multialign);
633         num = LyXTabular::SET_SPECIAL_MULTI;
634     } else if (ob == cell_options_->radio_border_top)
635         num = LyXTabular::M_TOGGLE_LINE_TOP;
636     else if (ob == cell_options_->radio_border_bottom)
637         num = LyXTabular::M_TOGGLE_LINE_BOTTOM;
638     else if (ob == cell_options_->radio_border_left)
639         num = LyXTabular::M_TOGGLE_LINE_LEFT;
640     else if (ob == cell_options_->radio_border_right)
641         num = LyXTabular::M_TOGGLE_LINE_RIGHT;
642     else if (ob == cell_options_->radio_align_left)
643         num = LyXTabular::M_ALIGN_LEFT;
644     else if (ob == cell_options_->radio_align_right)
645         num = LyXTabular::M_ALIGN_RIGHT;
646     else if (ob == cell_options_->radio_align_center)
647         num = LyXTabular::M_ALIGN_CENTER;
648     else if (ob == cell_options_->radio_valign_top)
649         num = LyXTabular::M_VALIGN_TOP;
650     else if (ob == cell_options_->radio_valign_bottom)
651         num = LyXTabular::M_VALIGN_BOTTOM;
652     else if (ob == cell_options_->radio_valign_center)
653         num = LyXTabular::M_VALIGN_CENTER;
654     else
655         return false;
656     
657     inset_->tabularFeatures(lv_->view(), num, special);
658     update();
659
660     return true;
661 }
662
663 int FormTabular::checkLongtableOptions(FL_OBJECT * ob, string & special)
664 {
665         bool flag = fl_get_button(ob);
666         if ((ob == longtable_options_->check_1head_2border_above) ||
667                 (ob == longtable_options_->check_head_2border_above) ||
668                 (ob == longtable_options_->check_foot_2border_above) ||
669                 (ob == longtable_options_->check_lastfoot_2border_above))
670         {
671                 special = "dl_above";
672         } else if ((ob == longtable_options_->check_1head_2border_below) ||
673                            (ob == longtable_options_->check_head_2border_below) ||
674                            (ob == longtable_options_->check_foot_2border_below) ||
675                            (ob == longtable_options_->check_lastfoot_2border_below))
676         {
677                 special = "dl_below";
678         } else if ((ob == longtable_options_->check_1head_empty) ||
679                            (ob == longtable_options_->check_lastfoot_empty))
680         {
681                 special = "empty";
682         } else {
683                 special = "";
684         }
685         if ((ob == longtable_options_->radio_lt_firsthead) ||
686                 (ob == longtable_options_->check_1head_2border_above) ||
687                 (ob == longtable_options_->check_1head_2border_below) ||
688                 (ob == longtable_options_->check_1head_empty))
689         {
690                 return (flag ? LyXTabular::SET_LTFIRSTHEAD :
691                                 LyXTabular::UNSET_LTFIRSTHEAD);
692     } else if ((ob == longtable_options_->radio_lt_head) ||
693                            (ob == longtable_options_->check_head_2border_above) ||
694                            (ob == longtable_options_->check_head_2border_below))
695         {
696                 return (flag ? LyXTabular::SET_LTHEAD : LyXTabular::UNSET_LTHEAD);
697     } else if ((ob == longtable_options_->radio_lt_foot) ||
698                            (ob == longtable_options_->check_foot_2border_above) ||
699                            (ob == longtable_options_->check_foot_2border_below))
700         {
701                 return (flag ? LyXTabular::SET_LTFOOT : LyXTabular::UNSET_LTFOOT);
702     } else if ((ob == longtable_options_->radio_lt_lastfoot) ||
703                            (ob == longtable_options_->check_lastfoot_2border_above) ||
704                            (ob == longtable_options_->check_lastfoot_2border_below) ||
705                            (ob == longtable_options_->check_lastfoot_empty))
706         {
707                 return (flag ? LyXTabular::SET_LTLASTFOOT :
708                                 LyXTabular::UNSET_LTLASTFOOT);
709         }
710         return LyXTabular::LAST_ACTION;
711 }