]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormTabular.C
More fixes for longtable options, still more to come.
[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                 bool use_empty;
374                 bool row_set = tabular->GetRowOfLTHead(row, ltt);
375                 fl_set_button(longtable_options_->radio_lt_head, row_set);
376                 if (row_set) {
377                         fl_set_button(longtable_options_->check_head_2border_above,
378                                           ltt.topDL);
379                         fl_set_button(longtable_options_->check_head_2border_above,
380                                       ltt.topDL);
381                         use_empty = true;
382                 } else {
383                         setEnabled(longtable_options_->check_head_2border_above, 0);
384                         setEnabled(longtable_options_->check_head_2border_below, 0);
385                         fl_set_button(longtable_options_->check_head_2border_above,0);
386                         fl_set_button(longtable_options_->check_head_2border_above,0);
387                         fl_set_button(longtable_options_->check_1head_empty,0);
388                         setEnabled(longtable_options_->check_1head_empty, 0);
389                         use_empty = false;
390                 }
391                 //
392                 row_set = tabular->GetRowOfLTFirstHead(row, ltt);
393                 fl_set_button(longtable_options_->radio_lt_firsthead, row_set);
394                 if (row_set && (!ltt.empty || !use_empty)) {
395                         fl_set_button(longtable_options_->check_1head_2border_above,
396                                       ltt.topDL);
397                         fl_set_button(longtable_options_->check_1head_2border_above,
398                                           ltt.topDL);
399                 } else {
400                         setEnabled(longtable_options_->check_1head_2border_above, 0);
401                         setEnabled(longtable_options_->check_1head_2border_below, 0);
402                         fl_set_button(longtable_options_->check_1head_2border_above,0);
403                         fl_set_button(longtable_options_->check_1head_2border_above,0);
404                         if (use_empty) {
405                                 fl_set_button(longtable_options_->check_1head_empty,ltt.empty);
406                                 if (ltt.empty)
407                                         setEnabled(longtable_options_->radio_lt_firsthead, 0);
408                         }
409                 }
410                 //
411                 row_set = tabular->GetRowOfLTFoot(row, ltt);
412                 fl_set_button(longtable_options_->radio_lt_foot, row_set);
413                 if (row_set) {
414                         fl_set_button(longtable_options_->check_foot_2border_above,
415                                       ltt.topDL);
416                         fl_set_button(longtable_options_->check_foot_2border_above,
417                                       ltt.topDL);
418                         use_empty = true;
419                 } else {
420                         setEnabled(longtable_options_->check_foot_2border_above, 0);
421                         setEnabled(longtable_options_->check_foot_2border_below, 0);
422                         fl_set_button(longtable_options_->check_foot_2border_above,0);
423                         fl_set_button(longtable_options_->check_foot_2border_above,0);
424                         fl_set_button(longtable_options_->check_lastfoot_empty, 0);
425                         setEnabled(longtable_options_->check_lastfoot_empty, 0);
426                         use_empty = false;
427                 }
428                 //
429                 row_set = tabular->GetRowOfLTLastFoot(row, ltt);
430                 fl_set_button(longtable_options_->radio_lt_lastfoot, row_set);
431                 if (row_set && (!ltt.empty || !use_empty)) {
432                         fl_set_button(longtable_options_->check_lastfoot_2border_above,
433                                       ltt.topDL);
434                         fl_set_button(longtable_options_->check_lastfoot_2border_above,
435                                       ltt.topDL);
436                 } else {
437                         setEnabled(longtable_options_->check_lastfoot_2border_above,0);
438                         setEnabled(longtable_options_->check_lastfoot_2border_below,0);
439                         fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
440                         fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
441                         if (use_empty) {
442                                 fl_set_button(longtable_options_->check_lastfoot_empty,
443                                               ltt.empty);
444                                 if (ltt.empty)
445                                         setEnabled(longtable_options_->radio_lt_lastfoot, 0);
446                         }
447                 }
448                 fl_set_button(longtable_options_->radio_lt_newpage,
449                               tabular->GetLTNewPage(row));
450         } else {
451                 fl_set_button(longtable_options_->radio_lt_firsthead, 0);
452                 fl_set_button(longtable_options_->check_1head_2border_above, 0);
453                 fl_set_button(longtable_options_->check_1head_2border_above, 0);
454                 fl_set_button(longtable_options_->check_1head_empty, 0);
455                 fl_set_button(longtable_options_->radio_lt_head, 0);
456                 fl_set_button(longtable_options_->check_head_2border_above, 0);
457                 fl_set_button(longtable_options_->check_head_2border_above, 0);
458                 fl_set_button(longtable_options_->radio_lt_foot, 0);
459                 fl_set_button(longtable_options_->check_foot_2border_above, 0);
460                 fl_set_button(longtable_options_->check_foot_2border_above, 0);
461                 fl_set_button(longtable_options_->radio_lt_lastfoot, 0);
462                 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
463                 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
464                 fl_set_button(longtable_options_->check_lastfoot_empty, 0);
465                 fl_set_button(longtable_options_->radio_lt_newpage, 0);
466         }
467         fl_set_button(tabular_options_->radio_rotate_tabular,
468                       tabular->GetRotateTabular());
469 }
470
471
472 bool FormTabular::input(FL_OBJECT * ob, long)
473 {
474     if (!inset_)
475         return false;
476
477     int s;
478     LyXTabular::Feature num = LyXTabular::LAST_ACTION;
479     string special;;
480
481     int cell = inset_->getActCell();
482         
483     if (actCell_ != cell) {
484         update();
485         fl_set_object_label(dialog_->text_warning,
486                      _("Warning: Wrong Cursor position, updated window"));
487         fl_show_object(dialog_->text_warning);
488         return false;
489     }
490     // No point in processing directives that you can't do anything with
491     // anyhow, so exit now if the buffer is read-only.
492     if (lv_->buffer()->isReadonly()) {
493       update();
494       return false;
495     }
496     if ((ob == column_options_->input_column_width) ||
497                 (ob == column_options_->choice_value_column_width))
498         {
499             string const str =
500                     getLengthFromWidgets(column_options_->input_column_width,
501                                          column_options_->choice_value_column_width);
502         inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH, str);
503         update(); // update for alignment
504         return true;
505     }
506     if ((ob == cell_options_->input_mcolumn_width) ||
507                 (ob == cell_options_->choice_value_mcolumn_width))
508         {
509             string const str =
510                     getLengthFromWidgets(cell_options_->input_mcolumn_width,
511                                          cell_options_->choice_value_mcolumn_width);
512         inset_->tabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH, str);
513         update(); // update for alignment
514         return true;
515     }
516
517     if (ob == tabular_options_->button_append_row)
518         num = LyXTabular::APPEND_ROW;
519     else if (ob == tabular_options_->button_append_column)
520         num = LyXTabular::APPEND_COLUMN;
521     else if (ob == tabular_options_->button_delete_row)
522         num = LyXTabular::DELETE_ROW;
523     else if (ob == tabular_options_->button_delete_column)
524         num = LyXTabular::DELETE_COLUMN;
525     else if (ob == tabular_options_->button_set_borders)
526         num = LyXTabular::SET_ALL_LINES;
527     else if (ob == tabular_options_->button_unset_borders)
528         num = LyXTabular::UNSET_ALL_LINES;
529     else if (ob == column_options_->radio_border_top)
530         num = LyXTabular::TOGGLE_LINE_TOP;
531     else if (ob == column_options_->radio_border_bottom)
532         num = LyXTabular::TOGGLE_LINE_BOTTOM;
533     else if (ob == column_options_->radio_border_left)
534         num = LyXTabular::TOGGLE_LINE_LEFT;
535     else if (ob == column_options_->radio_border_right)
536         num = LyXTabular::TOGGLE_LINE_RIGHT;
537     else if (ob == column_options_->radio_align_left)
538         num = LyXTabular::ALIGN_LEFT;
539     else if (ob == column_options_->radio_align_right)
540         num = LyXTabular::ALIGN_RIGHT;
541     else if (ob == column_options_->radio_align_center)
542         num = LyXTabular::ALIGN_CENTER;
543     else if (ob == column_options_->radio_valign_top)
544         num = LyXTabular::VALIGN_TOP;
545     else if (ob == column_options_->radio_valign_bottom)
546         num = LyXTabular::VALIGN_BOTTOM;
547     else if (ob == column_options_->radio_valign_center)
548         num = LyXTabular::VALIGN_CENTER;
549     else if (ob == cell_options_->radio_multicolumn)
550         num = LyXTabular::MULTICOLUMN;
551     else if (ob == tabular_options_->radio_longtable) {
552             if (fl_get_button(tabular_options_->radio_longtable))
553                     num = LyXTabular::SET_LONGTABULAR;
554                 else
555                         num = LyXTabular::UNSET_LONGTABULAR;
556     } else if (ob == tabular_options_->radio_rotate_tabular) {
557                 s = fl_get_button(tabular_options_->radio_rotate_tabular);
558                 if (s)
559                         num = LyXTabular::SET_ROTATE_TABULAR;
560                 else
561                         num = LyXTabular::UNSET_ROTATE_TABULAR;
562     } else if (ob == cell_options_->radio_rotate_cell) {
563                 s = fl_get_button(cell_options_->radio_rotate_cell);
564                 if (s)
565                         num = LyXTabular::SET_ROTATE_CELL;
566                 else
567                         num = LyXTabular::UNSET_ROTATE_CELL;
568     } else if (ob == cell_options_->radio_useminipage) {
569                 num = LyXTabular::SET_USEBOX;
570                 special = "2";
571     } else if ((ob == longtable_options_->radio_lt_firsthead) ||
572                            (ob == longtable_options_->check_1head_2border_above) ||
573                            (ob == longtable_options_->check_1head_2border_below) ||
574                            (ob == longtable_options_->check_1head_empty) ||
575                            (ob == longtable_options_->radio_lt_head) ||
576                            (ob == longtable_options_->check_head_2border_above) ||
577                            (ob == longtable_options_->check_head_2border_below) ||
578                            (ob == longtable_options_->radio_lt_foot) ||
579                            (ob == longtable_options_->check_foot_2border_above) ||
580                            (ob == longtable_options_->check_foot_2border_below) ||
581                            (ob == longtable_options_->radio_lt_lastfoot) ||
582                            (ob == longtable_options_->check_lastfoot_2border_above) ||
583                            (ob == longtable_options_->check_lastfoot_2border_below) ||
584                            (ob == longtable_options_->check_lastfoot_empty))
585         {
586                 num = static_cast<LyXTabular::Feature>(checkLongtableOptions(ob, special));
587     } else if (ob == longtable_options_->radio_lt_newpage) {
588         num = LyXTabular::SET_LTNEWPAGE;
589     } else if (ob == column_options_->input_special_alignment) {
590         special = fl_get_input(column_options_->input_special_alignment);
591         num = LyXTabular::SET_SPECIAL_COLUMN;
592     } else if (ob == cell_options_->input_special_multialign) {
593         special = fl_get_input(cell_options_->input_special_multialign);
594         num = LyXTabular::SET_SPECIAL_MULTI;
595     } else if (ob == cell_options_->radio_border_top)
596         num = LyXTabular::M_TOGGLE_LINE_TOP;
597     else if (ob == cell_options_->radio_border_bottom)
598         num = LyXTabular::M_TOGGLE_LINE_BOTTOM;
599     else if (ob == cell_options_->radio_border_left)
600         num = LyXTabular::M_TOGGLE_LINE_LEFT;
601     else if (ob == cell_options_->radio_border_right)
602         num = LyXTabular::M_TOGGLE_LINE_RIGHT;
603     else if (ob == cell_options_->radio_align_left)
604         num = LyXTabular::M_ALIGN_LEFT;
605     else if (ob == cell_options_->radio_align_right)
606         num = LyXTabular::M_ALIGN_RIGHT;
607     else if (ob == cell_options_->radio_align_center)
608         num = LyXTabular::M_ALIGN_CENTER;
609     else if (ob == cell_options_->radio_valign_top)
610         num = LyXTabular::M_VALIGN_TOP;
611     else if (ob == cell_options_->radio_valign_bottom)
612         num = LyXTabular::M_VALIGN_BOTTOM;
613     else if (ob == cell_options_->radio_valign_center)
614         num = LyXTabular::M_VALIGN_CENTER;
615     else
616         return false;
617     
618     inset_->tabularFeatures(lv_->view(), num, special);
619     update();
620
621     return true;
622 }
623
624 int FormTabular::checkLongtableOptions(FL_OBJECT * ob, string & special)
625 {
626         bool flag = fl_get_button(ob);
627         if ((ob == longtable_options_->check_1head_2border_above) ||
628                 (ob == longtable_options_->check_head_2border_above) ||
629                 (ob == longtable_options_->check_foot_2border_above) ||
630                 (ob == longtable_options_->check_lastfoot_2border_above))
631         {
632                 special = "dl_above";
633         } else if ((ob == longtable_options_->check_1head_2border_below) ||
634                            (ob == longtable_options_->check_head_2border_below) ||
635                            (ob == longtable_options_->check_foot_2border_below) ||
636                            (ob == longtable_options_->check_lastfoot_2border_below))
637         {
638                 special = "dl_below";
639         } else if ((ob == longtable_options_->check_1head_empty) ||
640                            (ob == longtable_options_->check_lastfoot_empty))
641         {
642                 special = "empty";
643         } else {
644                 special = "";
645         }
646         if ((ob == longtable_options_->radio_lt_firsthead) ||
647                 (ob == longtable_options_->check_1head_2border_above) ||
648                 (ob == longtable_options_->check_1head_2border_below) ||
649                 (ob == longtable_options_->check_1head_empty))
650         {
651                 return (flag ? LyXTabular::SET_LTFIRSTHEAD :
652                                 LyXTabular::UNSET_LTFIRSTHEAD);
653     } else if ((ob == longtable_options_->radio_lt_head) ||
654                            (ob == longtable_options_->check_head_2border_above) ||
655                            (ob == longtable_options_->check_head_2border_below))
656         {
657                 return (flag ? LyXTabular::SET_LTHEAD : LyXTabular::UNSET_LTHEAD);
658     } else if ((ob == longtable_options_->radio_lt_foot) ||
659                            (ob == longtable_options_->check_foot_2border_above) ||
660                            (ob == longtable_options_->check_foot_2border_below))
661         {
662                 return (flag ? LyXTabular::SET_LTFOOT : LyXTabular::UNSET_LTFOOT);
663     } else if ((ob == longtable_options_->radio_lt_lastfoot) ||
664                            (ob == longtable_options_->check_lastfoot_2border_above) ||
665                            (ob == longtable_options_->check_lastfoot_2border_below) ||
666                            (ob == longtable_options_->check_lastfoot_empty))
667         {
668                 return (flag ? LyXTabular::SET_LTLASTFOOT :
669                                 LyXTabular::UNSET_LTLASTFOOT);
670         }
671         return LyXTabular::LAST_ACTION;
672 }