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