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