3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
17 #include "ControlTabular.h"
19 #include "ButtonController.h"
20 #include "insets/insettabular.h"
22 #include "FormTabular.h"
23 #include "forms/form_tabular.h"
25 #include "xforms_helpers.h"
28 #include "helper_funcs.h"
29 #include "input_validators.h"
30 #include "support/lstrings.h"
32 #include "lyx_forms.h"
40 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
41 bool const scalableTabfolders = false;
43 bool const scalableTabfolders = true;
49 typedef FormController<ControlTabular, FormView<FD_tabular> > base_class;
51 FormTabular::FormTabular(Dialog & parent)
52 : base_class(parent, _("Table Settings"), scalableTabfolders),
53 closing_(false), actCell_(-1)
58 void FormTabular::redraw()
60 if (form() && form()->visible)
61 fl_redraw_form(form());
65 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
66 if (outer_form && outer_form->visible)
67 fl_redraw_form(outer_form);
71 void FormTabular::build()
73 dialog_.reset(build_tabular(this));
75 // Allow the base class to control messages
76 setMessageWidget(dialog_->text_warning);
78 // trigger an input event for cut&paste with middle mouse button.
79 setPrehandler(dialog_->input_tabular_column);
80 setPrehandler(dialog_->input_tabular_row);
82 // Create the contents of the unit choices; don't include the "%" terms.
83 vector<string> units_vec = getLatexUnits();
84 vector<string>::iterator ret =
85 remove_if(units_vec.begin(), units_vec.end(),
86 bind2nd(contains_functor(), "%"));
87 units_vec.erase(ret, units_vec.end());
88 string const units = getStringFromVector(units_vec, "|");
90 // tabular options form
91 tabular_options_.reset(build_tabular_options(this));
93 // column options form
94 column_options_.reset(build_tabular_column(this));
96 fl_set_input_return(column_options_->input_column_width,
98 fl_set_input_return(column_options_->input_special_alignment,
101 // trigger an input event for cut&paste with middle mouse button.
102 setPrehandler(column_options_->input_column_width);
103 setPrehandler(column_options_->input_special_alignment);
105 fl_addto_choice(column_options_->choice_value_column_width,
109 cell_options_.reset(build_tabular_cell(this));
111 fl_set_input_return(cell_options_->input_mcolumn_width,
113 fl_set_input_return(cell_options_->input_special_multialign,
116 // trigger an input event for cut&paste with middle mouse button.
117 setPrehandler(cell_options_->input_mcolumn_width);
118 setPrehandler(cell_options_->input_special_multialign);
120 fl_addto_choice(cell_options_->choice_value_mcolumn_width,
123 longtable_options_.reset(build_tabular_longtable(this));
125 // Enable the tabfolder to be rescaled correctly.
126 if (scalableTabfolders)
127 fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
130 fl_addto_tabfolder(dialog_->tabfolder, _("Table").c_str(),
131 tabular_options_->form);
132 fl_addto_tabfolder(dialog_->tabfolder, _("Column/Row").c_str(),
133 column_options_->form);
134 fl_addto_tabfolder(dialog_->tabfolder, _("Cell").c_str(),
135 cell_options_->form);
136 fl_addto_tabfolder(dialog_->tabfolder, _("LongTable").c_str(),
137 longtable_options_->form);
139 // FIXME: addReadOnly everything
143 void FormTabular::update()
148 LyXTabular const & tabular = controller().tabular();
155 int const cell = controller().getActiveCell();
157 int column = tabular.column_of_cell(cell) + 1;
159 fl_activate_object(column_options_->input_special_alignment);
160 fl_activate_object(cell_options_->input_special_multialign);
161 fl_activate_object(column_options_->input_column_width);
162 fl_activate_object(column_options_->choice_value_column_width);
163 sprintf(buf, "%d", column);
164 fl_set_input(dialog_->input_tabular_column, buf);
165 fl_deactivate_object(dialog_->input_tabular_column);
166 int row = tabular.row_of_cell(cell);
167 sprintf(buf, "%d", row + 1);
168 fl_set_input(dialog_->input_tabular_row, buf);
169 fl_deactivate_object(dialog_->input_tabular_row);
170 if (tabular.isMultiColumn(cell)) {
171 fl_set_button(cell_options_->check_multicolumn, 1);
172 fl_set_button(cell_options_->check_border_top,
173 tabular.topLine(cell)?1:0);
174 setEnabled(cell_options_->check_border_top, true);
175 fl_set_button(cell_options_->check_border_bottom,
176 tabular.bottomLine(cell)?1:0);
177 setEnabled(cell_options_->check_border_bottom, true);
178 // pay attention to left/right lines they are only allowed
179 // to set if we are in first/last cell of row or if the left/right
180 // cell is also a multicolumn.
181 if (tabular.isFirstCellInRow(cell) ||
182 tabular.isMultiColumn(cell-1)) {
183 fl_set_button(cell_options_->check_border_left,
184 tabular.leftLine(cell)?1:0);
185 setEnabled(cell_options_->check_border_left, true);
187 fl_set_button(cell_options_->check_border_left, 0);
188 setEnabled(cell_options_->check_border_left, false);
190 if (tabular.isLastCellInRow(cell) ||
191 tabular.isMultiColumn(cell+1)) {
192 fl_set_button(cell_options_->check_border_right,
193 tabular.rightLine(cell)?1:0);
194 setEnabled(cell_options_->check_border_right, true);
196 fl_set_button(cell_options_->check_border_right, 0);
197 setEnabled(cell_options_->check_border_right, false);
199 pwidth = tabular.getMColumnPWidth(cell);
200 align = tabular.getAlignment(cell);
201 // set the horiz. alignment, default is left here
202 fl_set_button(cell_options_->radio_align_left, 0);
203 fl_set_button(cell_options_->radio_align_right, 0);
204 fl_set_button(cell_options_->radio_align_center, 0);
205 if (align == LYX_ALIGN_RIGHT)
206 fl_set_button(cell_options_->radio_align_right, 1);
207 else if (align == LYX_ALIGN_CENTER)
208 fl_set_button(cell_options_->radio_align_center, 1);
210 fl_set_button(cell_options_->radio_align_left, 1);
212 align = tabular.getVAlignment(cell);
213 fl_set_button(cell_options_->radio_valign_top, 0);
214 fl_set_button(cell_options_->radio_valign_bottom, 0);
215 fl_set_button(cell_options_->radio_valign_center, 0);
216 if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_CENTER))
217 fl_set_button(cell_options_->radio_valign_center, 1);
218 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
219 fl_set_button(cell_options_->radio_valign_bottom, 1);
221 fl_set_button(cell_options_->radio_valign_top, 1);
223 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
224 fl_set_input(cell_options_->input_special_multialign, special.c_str());
225 bool const metric(controller().useMetricUnits());
226 string const default_unit = metric ? "cm" : "in";
227 updateWidgetsFromLength(cell_options_->input_mcolumn_width,
228 cell_options_->choice_value_mcolumn_width,
229 pwidth, default_unit);
231 if (!bc().bp().isReadOnly()) {
232 setEnabled(cell_options_->input_special_multialign, true);
233 setEnabled(cell_options_->input_mcolumn_width, true);
234 setEnabled(cell_options_->choice_value_mcolumn_width, true);
237 setEnabled(cell_options_->radio_valign_top, !pwidth.zero());
238 setEnabled(cell_options_->radio_valign_bottom, !pwidth.zero());
239 setEnabled(cell_options_->radio_valign_center, !pwidth.zero());
241 setEnabled(cell_options_->radio_align_left, true);
242 setEnabled(cell_options_->radio_align_right, true);
243 setEnabled(cell_options_->radio_align_center, true);
245 fl_set_button(cell_options_->check_multicolumn, 0);
247 fl_set_button(cell_options_->check_border_top, 0);
248 setEnabled(cell_options_->check_border_top, false);
250 fl_set_button(cell_options_->check_border_bottom, 0);
251 setEnabled(cell_options_->check_border_bottom, false);
253 fl_set_button(cell_options_->check_border_left, 0);
254 setEnabled(cell_options_->check_border_left, false);
256 fl_set_button(cell_options_->check_border_right, 0);
257 setEnabled(cell_options_->check_border_right, false);
259 fl_set_button(cell_options_->radio_align_left, 0);
260 setEnabled(cell_options_->radio_align_left, false);
262 fl_set_button(cell_options_->radio_align_right, 0);
263 setEnabled(cell_options_->radio_align_right, false);
265 fl_set_button(cell_options_->radio_align_center, 0);
266 setEnabled(cell_options_->radio_align_center, false);
268 fl_set_button(cell_options_->radio_valign_top, 0);
269 setEnabled(cell_options_->radio_valign_top, false);
271 fl_set_button(cell_options_->radio_valign_bottom, 0);
272 setEnabled(cell_options_->radio_valign_bottom, false);
274 fl_set_button(cell_options_->radio_valign_center, 0);
275 setEnabled(cell_options_->radio_valign_center, false);
277 fl_set_input(cell_options_->input_special_multialign, "");
278 setEnabled(cell_options_->input_special_multialign, false);
280 fl_set_input(cell_options_->input_mcolumn_width, "");
281 setEnabled(cell_options_->input_mcolumn_width, false);
282 setEnabled(cell_options_->choice_value_mcolumn_width, false);
284 if (tabular.getRotateCell(cell))
285 fl_set_button(cell_options_->check_rotate_cell, 1);
287 fl_set_button(cell_options_->check_rotate_cell, 0);
288 if (tabular.topLine(cell, true))
289 fl_set_button(column_options_->check_border_top, 1);
291 fl_set_button(column_options_->check_border_top, 0);
292 if (tabular.bottomLine(cell, true))
293 fl_set_button(column_options_->check_border_bottom, 1);
295 fl_set_button(column_options_->check_border_bottom, 0);
296 if (tabular.leftLine(cell, true))
297 fl_set_button(column_options_->check_border_left, 1);
299 fl_set_button(column_options_->check_border_left, 0);
300 if (tabular.rightLine(cell, true))
301 fl_set_button(column_options_->check_border_right, 1);
303 fl_set_button(column_options_->check_border_right, 0);
304 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
305 fl_set_input(column_options_->input_special_alignment, special.c_str());
307 bool const isReadonly = bc().bp().isReadOnly();
308 setEnabled(column_options_->input_special_alignment, !isReadonly);
310 pwidth = tabular.getColumnPWidth(cell);
311 bool const metric = controller().useMetricUnits();
312 string const default_unit = metric ? "cm" : "in";
313 updateWidgetsFromLength(column_options_->input_column_width,
314 column_options_->choice_value_column_width,
315 pwidth, default_unit);
316 setEnabled(column_options_->input_column_width, !isReadonly);
317 setEnabled(column_options_->choice_value_column_width, !isReadonly);
319 setEnabled(cell_options_->check_useminipage, !pwidth.zero());
320 if (!pwidth.zero()) {
321 if (tabular.getUsebox(cell) == 2)
322 fl_set_button(cell_options_->check_useminipage, 1);
324 fl_set_button(cell_options_->check_useminipage, 0);
326 fl_set_button(cell_options_->check_useminipage, 0);
328 align = tabular.getAlignment(cell, true);
329 fl_set_button(column_options_->radio_align_left, 0);
330 fl_set_button(column_options_->radio_align_right, 0);
331 fl_set_button(column_options_->radio_align_center, 0);
332 fl_set_button(column_options_->radio_align_block, 0);
333 if (align == LYX_ALIGN_LEFT)
334 fl_set_button(column_options_->radio_align_left, 1);
335 else if (align == LYX_ALIGN_RIGHT)
336 fl_set_button(column_options_->radio_align_right, 1);
337 else if (align == LYX_ALIGN_CENTER)
338 fl_set_button(column_options_->radio_align_center, 1);
340 fl_set_button(column_options_->radio_align_block, 1);
341 align = tabular.getVAlignment(cell, true);
342 fl_set_button(column_options_->radio_valign_top, 0);
343 fl_set_button(column_options_->radio_valign_bottom, 0);
344 fl_set_button(column_options_->radio_valign_center, 0);
345 if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_CENTER))
346 fl_set_button(column_options_->radio_valign_center, 1);
347 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
348 fl_set_button(column_options_->radio_valign_bottom, 1);
350 fl_set_button(column_options_->radio_valign_top, 1);
352 setEnabled(column_options_->radio_align_left, true);
353 setEnabled(column_options_->radio_align_right, true);
354 setEnabled(column_options_->radio_align_center, true);
355 setEnabled(column_options_->radio_align_block, !pwidth.zero());
356 setEnabled(column_options_->radio_valign_top, !pwidth.zero());
357 setEnabled(column_options_->radio_valign_bottom, !pwidth.zero());
358 setEnabled(column_options_->radio_valign_center, !pwidth.zero());
360 fl_set_button(tabular_options_->check_longtable,
361 tabular.isLongTabular());
363 bool const enable = tabular.isLongTabular();
365 setEnabled(longtable_options_->check_lt_firsthead, enable);
366 setEnabled(longtable_options_->check_1head_2border_above, enable);
367 setEnabled(longtable_options_->check_1head_2border_below, enable);
368 setEnabled(longtable_options_->check_1head_empty, enable);
369 setEnabled(longtable_options_->check_lt_head, enable);
370 setEnabled(longtable_options_->check_head_2border_above, enable);
371 setEnabled(longtable_options_->check_head_2border_below, enable);
372 setEnabled(longtable_options_->check_lt_foot, enable);
373 setEnabled(longtable_options_->check_foot_2border_above, enable);
374 setEnabled(longtable_options_->check_foot_2border_below, enable);
375 setEnabled(longtable_options_->check_lt_lastfoot, enable);
376 setEnabled(longtable_options_->check_lastfoot_2border_above, enable);
377 setEnabled(longtable_options_->check_lastfoot_2border_below, enable);
378 setEnabled(longtable_options_->check_lastfoot_empty, enable);
379 setEnabled(longtable_options_->check_lt_newpage, enable);
382 LyXTabular::ltType ltt;
384 bool row_set = tabular.getRowOfLTHead(row, ltt);
385 fl_set_button(longtable_options_->check_lt_head, row_set);
387 fl_set_button(longtable_options_->check_head_2border_above,
389 fl_set_button(longtable_options_->check_head_2border_below,
393 setEnabled(longtable_options_->check_head_2border_above, 0);
394 setEnabled(longtable_options_->check_head_2border_below, 0);
395 fl_set_button(longtable_options_->check_head_2border_above,0);
396 fl_set_button(longtable_options_->check_head_2border_below,0);
397 fl_set_button(longtable_options_->check_1head_empty,0);
398 setEnabled(longtable_options_->check_1head_empty, 0);
402 row_set = tabular.getRowOfLTFirstHead(row, ltt);
403 fl_set_button(longtable_options_->check_lt_firsthead, row_set);
404 if (ltt.set && (!ltt.empty || !use_empty)) {
405 fl_set_button(longtable_options_->check_1head_2border_above,
407 fl_set_button(longtable_options_->check_1head_2border_below,
410 setEnabled(longtable_options_->check_1head_2border_above, 0);
411 setEnabled(longtable_options_->check_1head_2border_below, 0);
412 fl_set_button(longtable_options_->check_1head_2border_above,0);
413 fl_set_button(longtable_options_->check_1head_2border_below,0);
415 fl_set_button(longtable_options_->check_1head_empty,ltt.empty);
417 setEnabled(longtable_options_->check_lt_firsthead, 0);
421 row_set = tabular.getRowOfLTFoot(row, ltt);
422 fl_set_button(longtable_options_->check_lt_foot, row_set);
424 fl_set_button(longtable_options_->check_foot_2border_above,
426 fl_set_button(longtable_options_->check_foot_2border_below,
430 setEnabled(longtable_options_->check_foot_2border_above, 0);
431 setEnabled(longtable_options_->check_foot_2border_below, 0);
432 fl_set_button(longtable_options_->check_foot_2border_above,0);
433 fl_set_button(longtable_options_->check_foot_2border_below,0);
434 fl_set_button(longtable_options_->check_lastfoot_empty, 0);
435 setEnabled(longtable_options_->check_lastfoot_empty, 0);
439 row_set = tabular.getRowOfLTLastFoot(row, ltt);
440 fl_set_button(longtable_options_->check_lt_lastfoot, row_set);
441 if (ltt.set && (!ltt.empty || !use_empty)) {
442 fl_set_button(longtable_options_->check_lastfoot_2border_above,
444 fl_set_button(longtable_options_->check_lastfoot_2border_below,
447 setEnabled(longtable_options_->check_lastfoot_2border_above,0);
448 setEnabled(longtable_options_->check_lastfoot_2border_below,0);
449 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
450 fl_set_button(longtable_options_->check_lastfoot_2border_below, 0);
452 fl_set_button(longtable_options_->check_lastfoot_empty,
455 setEnabled(longtable_options_->check_lt_lastfoot, 0);
458 fl_set_button(longtable_options_->check_lt_newpage,
459 tabular.getLTNewPage(row));
461 fl_set_button(longtable_options_->check_lt_firsthead, 0);
462 fl_set_button(longtable_options_->check_1head_2border_above, 0);
463 fl_set_button(longtable_options_->check_1head_2border_below, 0);
464 fl_set_button(longtable_options_->check_1head_empty, 0);
465 fl_set_button(longtable_options_->check_lt_head, 0);
466 fl_set_button(longtable_options_->check_head_2border_above, 0);
467 fl_set_button(longtable_options_->check_head_2border_below, 0);
468 fl_set_button(longtable_options_->check_lt_foot, 0);
469 fl_set_button(longtable_options_->check_foot_2border_above, 0);
470 fl_set_button(longtable_options_->check_foot_2border_below, 0);
471 fl_set_button(longtable_options_->check_lt_lastfoot, 0);
472 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
473 fl_set_button(longtable_options_->check_lastfoot_2border_below, 0);
474 fl_set_button(longtable_options_->check_lastfoot_empty, 0);
475 fl_set_button(longtable_options_->check_lt_newpage, 0);
477 fl_set_button(tabular_options_->check_rotate_tabular,
478 tabular.getRotateTabular());
482 ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long)
485 LyXTabular::Feature num = LyXTabular::LAST_ACTION;
488 LyXTabular const & tabular = controller().tabular();
490 int const cell = controller().getActiveCell();
492 // ugly hack to auto-apply the stuff that hasn't been
493 // yet. don't let this continue to exist ...
494 if (ob == dialog_->button_close) {
497 getLengthFromWidgets(column_options_->input_column_width,
498 column_options_->choice_value_column_width);
500 LyXLength llen = tabular.getColumnPWidth(cell);
502 w2 = llen.asString();
504 string mw1 = getLengthFromWidgets(cell_options_->input_mcolumn_width,
505 cell_options_->choice_value_mcolumn_width);
506 llen = tabular.getMColumnPWidth(cell);
511 mw2 = llen.asString();
513 string al1 = getString(column_options_->input_special_alignment);
514 string al2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
515 string mal1 = getString(cell_options_->input_special_multialign);
516 string mal2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
518 // we must do these all at the end
520 input(column_options_->input_column_width, 0);
522 input(cell_options_->input_mcolumn_width, 0);
524 input(column_options_->input_special_alignment, 0);
526 input(cell_options_->input_special_multialign, 0);
529 return ButtonPolicy::SMI_VALID;
532 if (actCell_ != cell) {
534 postWarning(_("Wrong Cursor position, updated window"));
535 return ButtonPolicy::SMI_VALID;
538 // No point in processing directives that you can't do anything with
539 // anyhow, so exit now if the buffer is read-only.
540 if (bc().bp().isReadOnly()) {
542 return ButtonPolicy::SMI_VALID;
545 if ((ob == column_options_->input_column_width) ||
546 (ob == column_options_->choice_value_column_width)) {
548 getLengthFromWidgets(column_options_->input_column_width,
549 column_options_->choice_value_column_width);
550 controller().set(LyXTabular::SET_PWIDTH, str);
552 //check if the input is valid
553 string const input = getString(column_options_->input_column_width);
554 if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
555 postWarning(_("Invalid Length (valid example: 10mm)"));
556 return ButtonPolicy::SMI_INVALID;
559 update(); // update for alignment
560 return ButtonPolicy::SMI_VALID;
563 if ((ob == cell_options_->input_mcolumn_width) ||
564 (ob == cell_options_->choice_value_mcolumn_width)) {
566 getLengthFromWidgets(cell_options_->input_mcolumn_width,
567 cell_options_->choice_value_mcolumn_width);
568 controller().set(LyXTabular::SET_MPWIDTH, str);
570 //check if the input is valid
571 string const input = getString(cell_options_->input_mcolumn_width);
572 if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
573 postWarning(_("Invalid Length (valid example: 10mm)"));
574 return ButtonPolicy::SMI_INVALID;
576 update(); // update for alignment
577 return ButtonPolicy::SMI_VALID;
580 if (ob == tabular_options_->button_append_row)
581 num = LyXTabular::APPEND_ROW;
582 else if (ob == tabular_options_->button_append_column)
583 num = LyXTabular::APPEND_COLUMN;
584 else if (ob == tabular_options_->button_delete_row)
585 num = LyXTabular::DELETE_ROW;
586 else if (ob == tabular_options_->button_delete_column)
587 num = LyXTabular::DELETE_COLUMN;
588 else if (ob == tabular_options_->button_set_borders)
589 num = LyXTabular::SET_ALL_LINES;
590 else if (ob == tabular_options_->button_unset_borders)
591 num = LyXTabular::UNSET_ALL_LINES;
592 else if (ob == column_options_->check_border_top)
593 num = LyXTabular::TOGGLE_LINE_TOP;
594 else if (ob == column_options_->check_border_bottom)
595 num = LyXTabular::TOGGLE_LINE_BOTTOM;
596 else if (ob == column_options_->check_border_left)
597 num = LyXTabular::TOGGLE_LINE_LEFT;
598 else if (ob == column_options_->check_border_right)
599 num = LyXTabular::TOGGLE_LINE_RIGHT;
600 else if (ob == column_options_->radio_align_left)
601 num = LyXTabular::ALIGN_LEFT;
602 else if (ob == column_options_->radio_align_right)
603 num = LyXTabular::ALIGN_RIGHT;
604 else if (ob == column_options_->radio_align_center)
605 num = LyXTabular::ALIGN_CENTER;
606 else if (ob == column_options_->radio_align_block)
607 num = LyXTabular::ALIGN_BLOCK;
608 else if (ob == column_options_->radio_valign_top)
609 num = LyXTabular::VALIGN_TOP;
610 else if (ob == column_options_->radio_valign_bottom)
611 num = LyXTabular::VALIGN_BOTTOM;
612 else if (ob == column_options_->radio_valign_center)
613 num = LyXTabular::VALIGN_CENTER;
614 else if (ob == cell_options_->check_multicolumn)
615 num = LyXTabular::MULTICOLUMN;
616 else if (ob == tabular_options_->check_longtable) {
617 if (fl_get_button(tabular_options_->check_longtable))
618 num = LyXTabular::SET_LONGTABULAR;
620 num = LyXTabular::UNSET_LONGTABULAR;
621 } else if (ob == tabular_options_->check_rotate_tabular) {
622 s = fl_get_button(tabular_options_->check_rotate_tabular);
624 num = LyXTabular::SET_ROTATE_TABULAR;
626 num = LyXTabular::UNSET_ROTATE_TABULAR;
627 } else if (ob == cell_options_->check_rotate_cell) {
628 s = fl_get_button(cell_options_->check_rotate_cell);
630 num = LyXTabular::SET_ROTATE_CELL;
632 num = LyXTabular::UNSET_ROTATE_CELL;
633 } else if (ob == cell_options_->check_useminipage) {
634 num = LyXTabular::SET_USEBOX;
636 } else if ((ob == longtable_options_->check_lt_firsthead) ||
637 (ob == longtable_options_->check_1head_2border_above) ||
638 (ob == longtable_options_->check_1head_2border_below) ||
639 (ob == longtable_options_->check_1head_empty) ||
640 (ob == longtable_options_->check_lt_head) ||
641 (ob == longtable_options_->check_head_2border_above) ||
642 (ob == longtable_options_->check_head_2border_below) ||
643 (ob == longtable_options_->check_lt_foot) ||
644 (ob == longtable_options_->check_foot_2border_above) ||
645 (ob == longtable_options_->check_foot_2border_below) ||
646 (ob == longtable_options_->check_lt_lastfoot) ||
647 (ob == longtable_options_->check_lastfoot_2border_above) ||
648 (ob == longtable_options_->check_lastfoot_2border_below) ||
649 (ob == longtable_options_->check_lastfoot_empty)) {
650 num = static_cast<LyXTabular::Feature>(checkLongtableOptions(ob, special));
651 } else if (ob == longtable_options_->check_lt_newpage) {
652 num = LyXTabular::SET_LTNEWPAGE;
653 } else if (ob == column_options_->input_special_alignment) {
654 special = getString(column_options_->input_special_alignment);
655 num = LyXTabular::SET_SPECIAL_COLUMN;
656 } else if (ob == cell_options_->input_special_multialign) {
657 special = getString(cell_options_->input_special_multialign);
658 num = LyXTabular::SET_SPECIAL_MULTI;
659 } else if (ob == cell_options_->check_border_top)
660 num = LyXTabular::M_TOGGLE_LINE_TOP;
661 else if (ob == cell_options_->check_border_bottom)
662 num = LyXTabular::M_TOGGLE_LINE_BOTTOM;
663 else if (ob == cell_options_->check_border_left)
664 num = LyXTabular::M_TOGGLE_LINE_LEFT;
665 else if (ob == cell_options_->check_border_right)
666 num = LyXTabular::M_TOGGLE_LINE_RIGHT;
667 else if (ob == cell_options_->radio_align_left)
668 num = LyXTabular::M_ALIGN_LEFT;
669 else if (ob == cell_options_->radio_align_right)
670 num = LyXTabular::M_ALIGN_RIGHT;
671 else if (ob == cell_options_->radio_align_center)
672 num = LyXTabular::M_ALIGN_CENTER;
673 else if (ob == cell_options_->radio_valign_top)
674 num = LyXTabular::M_VALIGN_TOP;
675 else if (ob == cell_options_->radio_valign_bottom)
676 num = LyXTabular::M_VALIGN_BOTTOM;
677 else if (ob == cell_options_->radio_valign_center)
678 num = LyXTabular::M_VALIGN_CENTER;
680 return ButtonPolicy::SMI_VALID;
682 controller().set(num, special);
685 return ButtonPolicy::SMI_VALID;
689 int FormTabular::checkLongtableOptions(FL_OBJECT * ob, string & special)
691 bool flag = fl_get_button(ob);
692 if ((ob == longtable_options_->check_1head_2border_above) ||
693 (ob == longtable_options_->check_head_2border_above) ||
694 (ob == longtable_options_->check_foot_2border_above) ||
695 (ob == longtable_options_->check_lastfoot_2border_above)) {
696 special = "dl_above";
697 } else if ((ob == longtable_options_->check_1head_2border_below) ||
698 (ob == longtable_options_->check_head_2border_below) ||
699 (ob == longtable_options_->check_foot_2border_below) ||
700 (ob == longtable_options_->check_lastfoot_2border_below)) {
701 special = "dl_below";
702 } else if ((ob == longtable_options_->check_1head_empty) ||
703 (ob == longtable_options_->check_lastfoot_empty)) {
708 if ((ob == longtable_options_->check_lt_firsthead) ||
709 (ob == longtable_options_->check_1head_2border_above) ||
710 (ob == longtable_options_->check_1head_2border_below) ||
711 (ob == longtable_options_->check_1head_empty)) {
712 return (flag ? LyXTabular::SET_LTFIRSTHEAD :
713 LyXTabular::UNSET_LTFIRSTHEAD);
714 } else if ((ob == longtable_options_->check_lt_head) ||
715 (ob == longtable_options_->check_head_2border_above) ||
716 (ob == longtable_options_->check_head_2border_below)) {
717 return (flag ? LyXTabular::SET_LTHEAD : LyXTabular::UNSET_LTHEAD);
718 } else if ((ob == longtable_options_->check_lt_foot) ||
719 (ob == longtable_options_->check_foot_2border_above) ||
720 (ob == longtable_options_->check_foot_2border_below)) {
721 return (flag ? LyXTabular::SET_LTFOOT : LyXTabular::UNSET_LTFOOT);
722 } else if ((ob == longtable_options_->check_lt_lastfoot) ||
723 (ob == longtable_options_->check_lastfoot_2border_above) ||
724 (ob == longtable_options_->check_lastfoot_2border_below) ||
725 (ob == longtable_options_->check_lastfoot_empty)) {
726 return (flag ? LyXTabular::SET_LTLASTFOOT :
727 LyXTabular::UNSET_LTLASTFOOT);
730 return LyXTabular::LAST_ACTION;