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
13 #include "ControlTabular.h"
15 #include "ButtonController.h"
16 #include "insets/insettabular.h"
18 #include "FormTabular.h"
19 #include "forms/form_tabular.h"
21 #include "xforms_helpers.h"
24 #include "helper_funcs.h"
25 #include "input_validators.h"
26 #include "support/lstrings.h"
28 #include "lyx_forms.h"
33 using namespace lyx::support;
41 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
42 bool const scalableTabfolders = false;
44 bool const scalableTabfolders = true;
50 typedef FormController<ControlTabular, FormView<FD_tabular> > base_class;
52 FormTabular::FormTabular(Dialog & parent)
53 : base_class(parent, _("Table Settings"), scalableTabfolders),
54 closing_(false), actCell_(-1)
59 void FormTabular::redraw()
61 if (form() && form()->visible)
62 fl_redraw_form(form());
66 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
67 if (outer_form && outer_form->visible)
68 fl_redraw_form(outer_form);
72 void FormTabular::build()
74 dialog_.reset(build_tabular(this));
76 // Allow the base class to control messages
77 setMessageWidget(dialog_->text_warning);
79 // trigger an input event for cut&paste with middle mouse button.
80 setPrehandler(dialog_->input_tabular_column);
81 setPrehandler(dialog_->input_tabular_row);
83 // Create the contents of the unit choices; don't include the "%" terms.
84 vector<string> units_vec = getLatexUnits();
85 vector<string>::iterator ret =
86 remove_if(units_vec.begin(), units_vec.end(),
87 bind2nd(contains_functor(), "%"));
88 units_vec.erase(ret, units_vec.end());
89 string const units = getStringFromVector(units_vec, "|");
91 // tabular options form
92 tabular_options_.reset(build_tabular_options(this));
94 // column options form
95 column_options_.reset(build_tabular_column(this));
97 fl_set_input_return(column_options_->input_column_width,
99 fl_set_input_return(column_options_->input_special_alignment,
102 // trigger an input event for cut&paste with middle mouse button.
103 setPrehandler(column_options_->input_column_width);
104 setPrehandler(column_options_->input_special_alignment);
106 fl_addto_choice(column_options_->choice_value_column_width,
110 cell_options_.reset(build_tabular_cell(this));
112 fl_set_input_return(cell_options_->input_mcolumn_width,
114 fl_set_input_return(cell_options_->input_special_multialign,
117 // trigger an input event for cut&paste with middle mouse button.
118 setPrehandler(cell_options_->input_mcolumn_width);
119 setPrehandler(cell_options_->input_special_multialign);
121 fl_addto_choice(cell_options_->choice_value_mcolumn_width,
124 longtable_options_.reset(build_tabular_longtable(this));
126 // Enable the tabfolder to be rescaled correctly.
127 if (scalableTabfolders)
128 fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
131 fl_addto_tabfolder(dialog_->tabfolder, _("Table").c_str(),
132 tabular_options_->form);
133 fl_addto_tabfolder(dialog_->tabfolder, _("Column/Row").c_str(),
134 column_options_->form);
135 fl_addto_tabfolder(dialog_->tabfolder, _("Cell").c_str(),
136 cell_options_->form);
137 fl_addto_tabfolder(dialog_->tabfolder, _("LongTable").c_str(),
138 longtable_options_->form);
140 // FIXME: addReadOnly everything
144 void FormTabular::update()
149 LyXTabular const & tabular = controller().tabular();
156 int const cell = controller().getActiveCell();
158 int column = tabular.column_of_cell(cell) + 1;
160 fl_activate_object(column_options_->input_special_alignment);
161 fl_activate_object(cell_options_->input_special_multialign);
162 fl_activate_object(column_options_->input_column_width);
163 fl_activate_object(column_options_->choice_value_column_width);
164 sprintf(buf, "%d", column);
165 fl_set_input(dialog_->input_tabular_column, buf);
166 fl_deactivate_object(dialog_->input_tabular_column);
167 int row = tabular.row_of_cell(cell);
168 sprintf(buf, "%d", row + 1);
169 fl_set_input(dialog_->input_tabular_row, buf);
170 fl_deactivate_object(dialog_->input_tabular_row);
171 if (tabular.isMultiColumn(cell)) {
172 fl_set_button(cell_options_->check_multicolumn, 1);
173 fl_set_button(cell_options_->check_border_top,
174 tabular.topLine(cell)?1:0);
175 setEnabled(cell_options_->check_border_top, true);
176 fl_set_button(cell_options_->check_border_bottom,
177 tabular.bottomLine(cell)?1:0);
178 setEnabled(cell_options_->check_border_bottom, true);
179 // pay attention to left/right lines they are only allowed
180 // to set if we are in first/last cell of row or if the left/right
181 // cell is also a multicolumn.
182 if (tabular.isFirstCellInRow(cell) ||
183 tabular.isMultiColumn(cell-1)) {
184 fl_set_button(cell_options_->check_border_left,
185 tabular.leftLine(cell)?1:0);
186 setEnabled(cell_options_->check_border_left, true);
188 fl_set_button(cell_options_->check_border_left, 0);
189 setEnabled(cell_options_->check_border_left, false);
191 if (tabular.isLastCellInRow(cell) ||
192 tabular.isMultiColumn(cell+1)) {
193 fl_set_button(cell_options_->check_border_right,
194 tabular.rightLine(cell)?1:0);
195 setEnabled(cell_options_->check_border_right, true);
197 fl_set_button(cell_options_->check_border_right, 0);
198 setEnabled(cell_options_->check_border_right, false);
200 pwidth = tabular.getMColumnPWidth(cell);
201 align = tabular.getAlignment(cell);
202 // set the horiz. alignment, default is left here
203 fl_set_button(cell_options_->radio_align_left, 0);
204 fl_set_button(cell_options_->radio_align_right, 0);
205 fl_set_button(cell_options_->radio_align_center, 0);
206 if (align == LYX_ALIGN_RIGHT)
207 fl_set_button(cell_options_->radio_align_right, 1);
208 else if (align == LYX_ALIGN_CENTER)
209 fl_set_button(cell_options_->radio_align_center, 1);
211 fl_set_button(cell_options_->radio_align_left, 1);
213 align = tabular.getVAlignment(cell);
214 fl_set_button(cell_options_->radio_valign_top, 0);
215 fl_set_button(cell_options_->radio_valign_bottom, 0);
216 fl_set_button(cell_options_->radio_valign_middle, 0);
217 if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_MIDDLE))
218 fl_set_button(cell_options_->radio_valign_middle, 1);
219 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
220 fl_set_button(cell_options_->radio_valign_bottom, 1);
222 fl_set_button(cell_options_->radio_valign_top, 1);
224 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
225 fl_set_input(cell_options_->input_special_multialign, special.c_str());
226 bool const metric(controller().useMetricUnits());
227 string const default_unit = metric ? "cm" : "in";
228 updateWidgetsFromLength(cell_options_->input_mcolumn_width,
229 cell_options_->choice_value_mcolumn_width,
230 pwidth, default_unit);
232 if (!bc().bp().isReadOnly()) {
233 setEnabled(cell_options_->input_special_multialign, true);
234 setEnabled(cell_options_->input_mcolumn_width, true);
235 setEnabled(cell_options_->choice_value_mcolumn_width, true);
238 setEnabled(cell_options_->radio_valign_top, !pwidth.zero());
239 setEnabled(cell_options_->radio_valign_bottom, !pwidth.zero());
240 setEnabled(cell_options_->radio_valign_middle, !pwidth.zero());
242 setEnabled(cell_options_->radio_align_left, true);
243 setEnabled(cell_options_->radio_align_right, true);
244 setEnabled(cell_options_->radio_align_center, true);
246 fl_set_button(cell_options_->check_multicolumn, 0);
248 fl_set_button(cell_options_->check_border_top, 0);
249 setEnabled(cell_options_->check_border_top, false);
251 fl_set_button(cell_options_->check_border_bottom, 0);
252 setEnabled(cell_options_->check_border_bottom, false);
254 fl_set_button(cell_options_->check_border_left, 0);
255 setEnabled(cell_options_->check_border_left, false);
257 fl_set_button(cell_options_->check_border_right, 0);
258 setEnabled(cell_options_->check_border_right, false);
260 fl_set_button(cell_options_->radio_align_left, 0);
261 setEnabled(cell_options_->radio_align_left, false);
263 fl_set_button(cell_options_->radio_align_right, 0);
264 setEnabled(cell_options_->radio_align_right, false);
266 fl_set_button(cell_options_->radio_align_center, 0);
267 setEnabled(cell_options_->radio_align_center, false);
269 fl_set_button(cell_options_->radio_valign_top, 0);
270 setEnabled(cell_options_->radio_valign_top, false);
272 fl_set_button(cell_options_->radio_valign_bottom, 0);
273 setEnabled(cell_options_->radio_valign_bottom, false);
275 fl_set_button(cell_options_->radio_valign_middle, 0);
276 setEnabled(cell_options_->radio_valign_middle, false);
278 fl_set_input(cell_options_->input_special_multialign, "");
279 setEnabled(cell_options_->input_special_multialign, false);
281 fl_set_input(cell_options_->input_mcolumn_width, "");
282 setEnabled(cell_options_->input_mcolumn_width, false);
283 setEnabled(cell_options_->choice_value_mcolumn_width, false);
285 if (tabular.getRotateCell(cell))
286 fl_set_button(cell_options_->check_rotate_cell, 1);
288 fl_set_button(cell_options_->check_rotate_cell, 0);
289 if (tabular.topLine(cell, true))
290 fl_set_button(column_options_->check_border_top, 1);
292 fl_set_button(column_options_->check_border_top, 0);
293 if (tabular.bottomLine(cell, true))
294 fl_set_button(column_options_->check_border_bottom, 1);
296 fl_set_button(column_options_->check_border_bottom, 0);
297 if (tabular.leftLine(cell, true))
298 fl_set_button(column_options_->check_border_left, 1);
300 fl_set_button(column_options_->check_border_left, 0);
301 if (tabular.rightLine(cell, true))
302 fl_set_button(column_options_->check_border_right, 1);
304 fl_set_button(column_options_->check_border_right, 0);
305 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
306 fl_set_input(column_options_->input_special_alignment, special.c_str());
308 bool const isReadonly = bc().bp().isReadOnly();
309 setEnabled(column_options_->input_special_alignment, !isReadonly);
311 pwidth = tabular.getColumnPWidth(cell);
312 bool const metric = controller().useMetricUnits();
313 string const default_unit = metric ? "cm" : "in";
314 updateWidgetsFromLength(column_options_->input_column_width,
315 column_options_->choice_value_column_width,
316 pwidth, default_unit);
317 setEnabled(column_options_->input_column_width, !isReadonly);
318 setEnabled(column_options_->choice_value_column_width, !isReadonly);
320 setEnabled(cell_options_->check_useminipage, !pwidth.zero());
321 if (!pwidth.zero()) {
322 if (tabular.getUsebox(cell) == 2)
323 fl_set_button(cell_options_->check_useminipage, 1);
325 fl_set_button(cell_options_->check_useminipage, 0);
327 fl_set_button(cell_options_->check_useminipage, 0);
329 align = tabular.getAlignment(cell, true);
330 fl_set_button(column_options_->radio_align_left, 0);
331 fl_set_button(column_options_->radio_align_right, 0);
332 fl_set_button(column_options_->radio_align_center, 0);
333 fl_set_button(column_options_->radio_align_block, 0);
334 if (align == LYX_ALIGN_LEFT)
335 fl_set_button(column_options_->radio_align_left, 1);
336 else if (align == LYX_ALIGN_RIGHT)
337 fl_set_button(column_options_->radio_align_right, 1);
338 else if (align == LYX_ALIGN_CENTER)
339 fl_set_button(column_options_->radio_align_center, 1);
341 fl_set_button(column_options_->radio_align_block, 1);
342 align = tabular.getVAlignment(cell, true);
343 fl_set_button(column_options_->radio_valign_top, 0);
344 fl_set_button(column_options_->radio_valign_bottom, 0);
345 fl_set_button(column_options_->radio_valign_middle, 0);
346 if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_MIDDLE))
347 fl_set_button(column_options_->radio_valign_middle, 1);
348 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
349 fl_set_button(column_options_->radio_valign_bottom, 1);
351 fl_set_button(column_options_->radio_valign_top, 1);
353 setEnabled(column_options_->radio_align_left, true);
354 setEnabled(column_options_->radio_align_right, true);
355 setEnabled(column_options_->radio_align_center, true);
356 setEnabled(column_options_->radio_align_block, !pwidth.zero());
357 setEnabled(column_options_->radio_valign_top, !pwidth.zero());
358 setEnabled(column_options_->radio_valign_bottom, !pwidth.zero());
359 setEnabled(column_options_->radio_valign_middle, !pwidth.zero());
361 fl_set_button(tabular_options_->check_longtable,
362 tabular.isLongTabular());
364 bool const enable = tabular.isLongTabular();
366 setEnabled(longtable_options_->check_lt_firsthead, enable);
367 setEnabled(longtable_options_->check_1head_2border_above, enable);
368 setEnabled(longtable_options_->check_1head_2border_below, enable);
369 setEnabled(longtable_options_->check_1head_empty, enable);
370 setEnabled(longtable_options_->check_lt_head, enable);
371 setEnabled(longtable_options_->check_head_2border_above, enable);
372 setEnabled(longtable_options_->check_head_2border_below, enable);
373 setEnabled(longtable_options_->check_lt_foot, enable);
374 setEnabled(longtable_options_->check_foot_2border_above, enable);
375 setEnabled(longtable_options_->check_foot_2border_below, enable);
376 setEnabled(longtable_options_->check_lt_lastfoot, enable);
377 setEnabled(longtable_options_->check_lastfoot_2border_above, enable);
378 setEnabled(longtable_options_->check_lastfoot_2border_below, enable);
379 setEnabled(longtable_options_->check_lastfoot_empty, enable);
380 setEnabled(longtable_options_->check_lt_newpage, enable);
383 LyXTabular::ltType ltt;
385 bool row_set = tabular.getRowOfLTHead(row, ltt);
386 fl_set_button(longtable_options_->check_lt_head, row_set);
388 fl_set_button(longtable_options_->check_head_2border_above,
390 fl_set_button(longtable_options_->check_head_2border_below,
394 setEnabled(longtable_options_->check_head_2border_above, 0);
395 setEnabled(longtable_options_->check_head_2border_below, 0);
396 fl_set_button(longtable_options_->check_head_2border_above,0);
397 fl_set_button(longtable_options_->check_head_2border_below,0);
398 fl_set_button(longtable_options_->check_1head_empty,0);
399 setEnabled(longtable_options_->check_1head_empty, 0);
403 row_set = tabular.getRowOfLTFirstHead(row, ltt);
404 fl_set_button(longtable_options_->check_lt_firsthead, row_set);
405 if (ltt.set && (!ltt.empty || !use_empty)) {
406 fl_set_button(longtable_options_->check_1head_2border_above,
408 fl_set_button(longtable_options_->check_1head_2border_below,
411 setEnabled(longtable_options_->check_1head_2border_above, 0);
412 setEnabled(longtable_options_->check_1head_2border_below, 0);
413 fl_set_button(longtable_options_->check_1head_2border_above,0);
414 fl_set_button(longtable_options_->check_1head_2border_below,0);
416 fl_set_button(longtable_options_->check_1head_empty,ltt.empty);
418 setEnabled(longtable_options_->check_lt_firsthead, 0);
422 row_set = tabular.getRowOfLTFoot(row, ltt);
423 fl_set_button(longtable_options_->check_lt_foot, row_set);
425 fl_set_button(longtable_options_->check_foot_2border_above,
427 fl_set_button(longtable_options_->check_foot_2border_below,
431 setEnabled(longtable_options_->check_foot_2border_above, 0);
432 setEnabled(longtable_options_->check_foot_2border_below, 0);
433 fl_set_button(longtable_options_->check_foot_2border_above,0);
434 fl_set_button(longtable_options_->check_foot_2border_below,0);
435 fl_set_button(longtable_options_->check_lastfoot_empty, 0);
436 setEnabled(longtable_options_->check_lastfoot_empty, 0);
440 row_set = tabular.getRowOfLTLastFoot(row, ltt);
441 fl_set_button(longtable_options_->check_lt_lastfoot, row_set);
442 if (ltt.set && (!ltt.empty || !use_empty)) {
443 fl_set_button(longtable_options_->check_lastfoot_2border_above,
445 fl_set_button(longtable_options_->check_lastfoot_2border_below,
448 setEnabled(longtable_options_->check_lastfoot_2border_above,0);
449 setEnabled(longtable_options_->check_lastfoot_2border_below,0);
450 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
451 fl_set_button(longtable_options_->check_lastfoot_2border_below, 0);
453 fl_set_button(longtable_options_->check_lastfoot_empty,
456 setEnabled(longtable_options_->check_lt_lastfoot, 0);
459 fl_set_button(longtable_options_->check_lt_newpage,
460 tabular.getLTNewPage(row));
462 fl_set_button(longtable_options_->check_lt_firsthead, 0);
463 fl_set_button(longtable_options_->check_1head_2border_above, 0);
464 fl_set_button(longtable_options_->check_1head_2border_below, 0);
465 fl_set_button(longtable_options_->check_1head_empty, 0);
466 fl_set_button(longtable_options_->check_lt_head, 0);
467 fl_set_button(longtable_options_->check_head_2border_above, 0);
468 fl_set_button(longtable_options_->check_head_2border_below, 0);
469 fl_set_button(longtable_options_->check_lt_foot, 0);
470 fl_set_button(longtable_options_->check_foot_2border_above, 0);
471 fl_set_button(longtable_options_->check_foot_2border_below, 0);
472 fl_set_button(longtable_options_->check_lt_lastfoot, 0);
473 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
474 fl_set_button(longtable_options_->check_lastfoot_2border_below, 0);
475 fl_set_button(longtable_options_->check_lastfoot_empty, 0);
476 fl_set_button(longtable_options_->check_lt_newpage, 0);
478 fl_set_button(tabular_options_->check_rotate_tabular,
479 tabular.getRotateTabular());
483 ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long)
486 LyXTabular::Feature num = LyXTabular::LAST_ACTION;
489 LyXTabular const & tabular = controller().tabular();
491 int const cell = controller().getActiveCell();
493 // ugly hack to auto-apply the stuff that hasn't been
494 // yet. don't let this continue to exist ...
495 if (ob == dialog_->button_close) {
498 getLengthFromWidgets(column_options_->input_column_width,
499 column_options_->choice_value_column_width);
501 LyXLength llen = tabular.getColumnPWidth(cell);
503 w2 = llen.asString();
505 string mw1 = getLengthFromWidgets(cell_options_->input_mcolumn_width,
506 cell_options_->choice_value_mcolumn_width);
507 llen = tabular.getMColumnPWidth(cell);
512 mw2 = llen.asString();
514 string al1 = getString(column_options_->input_special_alignment);
515 string al2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
516 string mal1 = getString(cell_options_->input_special_multialign);
517 string mal2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
519 // we must do these all at the end
521 input(column_options_->input_column_width, 0);
523 input(cell_options_->input_mcolumn_width, 0);
525 input(column_options_->input_special_alignment, 0);
527 input(cell_options_->input_special_multialign, 0);
530 return ButtonPolicy::SMI_VALID;
533 if (actCell_ != cell) {
535 postWarning(_("Wrong Cursor position, updated window"));
536 return ButtonPolicy::SMI_VALID;
539 // No point in processing directives that you can't do anything with
540 // anyhow, so exit now if the buffer is read-only.
541 if (bc().bp().isReadOnly()) {
543 return ButtonPolicy::SMI_VALID;
546 if ((ob == column_options_->input_column_width) ||
547 (ob == column_options_->choice_value_column_width)) {
549 getLengthFromWidgets(column_options_->input_column_width,
550 column_options_->choice_value_column_width);
551 controller().set(LyXTabular::SET_PWIDTH, str);
553 //check if the input is valid
554 string const input = getString(column_options_->input_column_width);
555 if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
556 postWarning(_("Invalid Length (valid example: 10mm)"));
557 return ButtonPolicy::SMI_INVALID;
560 update(); // update for alignment
561 return ButtonPolicy::SMI_VALID;
564 if ((ob == cell_options_->input_mcolumn_width) ||
565 (ob == cell_options_->choice_value_mcolumn_width)) {
567 getLengthFromWidgets(cell_options_->input_mcolumn_width,
568 cell_options_->choice_value_mcolumn_width);
569 controller().set(LyXTabular::SET_MPWIDTH, str);
571 //check if the input is valid
572 string const input = getString(cell_options_->input_mcolumn_width);
573 if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
574 postWarning(_("Invalid Length (valid example: 10mm)"));
575 return ButtonPolicy::SMI_INVALID;
577 update(); // update for alignment
578 return ButtonPolicy::SMI_VALID;
581 if (ob == tabular_options_->button_append_row)
582 num = LyXTabular::APPEND_ROW;
583 else if (ob == tabular_options_->button_append_column)
584 num = LyXTabular::APPEND_COLUMN;
585 else if (ob == tabular_options_->button_delete_row)
586 num = LyXTabular::DELETE_ROW;
587 else if (ob == tabular_options_->button_delete_column)
588 num = LyXTabular::DELETE_COLUMN;
589 else if (ob == tabular_options_->button_set_borders)
590 num = LyXTabular::SET_ALL_LINES;
591 else if (ob == tabular_options_->button_unset_borders)
592 num = LyXTabular::UNSET_ALL_LINES;
593 else if (ob == column_options_->check_border_top)
594 num = LyXTabular::TOGGLE_LINE_TOP;
595 else if (ob == column_options_->check_border_bottom)
596 num = LyXTabular::TOGGLE_LINE_BOTTOM;
597 else if (ob == column_options_->check_border_left)
598 num = LyXTabular::TOGGLE_LINE_LEFT;
599 else if (ob == column_options_->check_border_right)
600 num = LyXTabular::TOGGLE_LINE_RIGHT;
601 else if (ob == column_options_->radio_align_left)
602 num = LyXTabular::ALIGN_LEFT;
603 else if (ob == column_options_->radio_align_right)
604 num = LyXTabular::ALIGN_RIGHT;
605 else if (ob == column_options_->radio_align_center)
606 num = LyXTabular::ALIGN_CENTER;
607 else if (ob == column_options_->radio_align_block)
608 num = LyXTabular::ALIGN_BLOCK;
609 else if (ob == column_options_->radio_valign_top)
610 num = LyXTabular::VALIGN_TOP;
611 else if (ob == column_options_->radio_valign_bottom)
612 num = LyXTabular::VALIGN_BOTTOM;
613 else if (ob == column_options_->radio_valign_middle)
614 num = LyXTabular::VALIGN_MIDDLE;
615 else if (ob == cell_options_->check_multicolumn)
616 num = LyXTabular::MULTICOLUMN;
617 else if (ob == tabular_options_->check_longtable) {
618 if (fl_get_button(tabular_options_->check_longtable))
619 num = LyXTabular::SET_LONGTABULAR;
621 num = LyXTabular::UNSET_LONGTABULAR;
622 } else if (ob == tabular_options_->check_rotate_tabular) {
623 s = fl_get_button(tabular_options_->check_rotate_tabular);
625 num = LyXTabular::SET_ROTATE_TABULAR;
627 num = LyXTabular::UNSET_ROTATE_TABULAR;
628 } else if (ob == cell_options_->check_rotate_cell) {
629 s = fl_get_button(cell_options_->check_rotate_cell);
631 num = LyXTabular::SET_ROTATE_CELL;
633 num = LyXTabular::UNSET_ROTATE_CELL;
634 } else if (ob == cell_options_->check_useminipage) {
635 num = LyXTabular::SET_USEBOX;
637 } else if ((ob == longtable_options_->check_lt_firsthead) ||
638 (ob == longtable_options_->check_1head_2border_above) ||
639 (ob == longtable_options_->check_1head_2border_below) ||
640 (ob == longtable_options_->check_1head_empty) ||
641 (ob == longtable_options_->check_lt_head) ||
642 (ob == longtable_options_->check_head_2border_above) ||
643 (ob == longtable_options_->check_head_2border_below) ||
644 (ob == longtable_options_->check_lt_foot) ||
645 (ob == longtable_options_->check_foot_2border_above) ||
646 (ob == longtable_options_->check_foot_2border_below) ||
647 (ob == longtable_options_->check_lt_lastfoot) ||
648 (ob == longtable_options_->check_lastfoot_2border_above) ||
649 (ob == longtable_options_->check_lastfoot_2border_below) ||
650 (ob == longtable_options_->check_lastfoot_empty)) {
651 num = static_cast<LyXTabular::Feature>(checkLongtableOptions(ob, special));
652 } else if (ob == longtable_options_->check_lt_newpage) {
653 num = LyXTabular::SET_LTNEWPAGE;
654 } else if (ob == column_options_->input_special_alignment) {
655 special = getString(column_options_->input_special_alignment);
656 num = LyXTabular::SET_SPECIAL_COLUMN;
657 } else if (ob == cell_options_->input_special_multialign) {
658 special = getString(cell_options_->input_special_multialign);
659 num = LyXTabular::SET_SPECIAL_MULTI;
660 } else if (ob == cell_options_->check_border_top)
661 num = LyXTabular::M_TOGGLE_LINE_TOP;
662 else if (ob == cell_options_->check_border_bottom)
663 num = LyXTabular::M_TOGGLE_LINE_BOTTOM;
664 else if (ob == cell_options_->check_border_left)
665 num = LyXTabular::M_TOGGLE_LINE_LEFT;
666 else if (ob == cell_options_->check_border_right)
667 num = LyXTabular::M_TOGGLE_LINE_RIGHT;
668 else if (ob == cell_options_->radio_align_left)
669 num = LyXTabular::M_ALIGN_LEFT;
670 else if (ob == cell_options_->radio_align_right)
671 num = LyXTabular::M_ALIGN_RIGHT;
672 else if (ob == cell_options_->radio_align_center)
673 num = LyXTabular::M_ALIGN_CENTER;
674 else if (ob == cell_options_->radio_valign_top)
675 num = LyXTabular::M_VALIGN_TOP;
676 else if (ob == cell_options_->radio_valign_bottom)
677 num = LyXTabular::M_VALIGN_BOTTOM;
678 else if (ob == cell_options_->radio_valign_middle)
679 num = LyXTabular::M_VALIGN_MIDDLE;
681 return ButtonPolicy::SMI_VALID;
683 controller().set(num, special);
686 return ButtonPolicy::SMI_VALID;
690 int FormTabular::checkLongtableOptions(FL_OBJECT * ob, string & special)
692 bool flag = fl_get_button(ob);
693 if ((ob == longtable_options_->check_1head_2border_above) ||
694 (ob == longtable_options_->check_head_2border_above) ||
695 (ob == longtable_options_->check_foot_2border_above) ||
696 (ob == longtable_options_->check_lastfoot_2border_above)) {
697 special = "dl_above";
698 } else if ((ob == longtable_options_->check_1head_2border_below) ||
699 (ob == longtable_options_->check_head_2border_below) ||
700 (ob == longtable_options_->check_foot_2border_below) ||
701 (ob == longtable_options_->check_lastfoot_2border_below)) {
702 special = "dl_below";
703 } else if ((ob == longtable_options_->check_1head_empty) ||
704 (ob == longtable_options_->check_lastfoot_empty)) {
709 if ((ob == longtable_options_->check_lt_firsthead) ||
710 (ob == longtable_options_->check_1head_2border_above) ||
711 (ob == longtable_options_->check_1head_2border_below) ||
712 (ob == longtable_options_->check_1head_empty)) {
713 return (flag ? LyXTabular::SET_LTFIRSTHEAD :
714 LyXTabular::UNSET_LTFIRSTHEAD);
715 } else if ((ob == longtable_options_->check_lt_head) ||
716 (ob == longtable_options_->check_head_2border_above) ||
717 (ob == longtable_options_->check_head_2border_below)) {
718 return (flag ? LyXTabular::SET_LTHEAD : LyXTabular::UNSET_LTHEAD);
719 } else if ((ob == longtable_options_->check_lt_foot) ||
720 (ob == longtable_options_->check_foot_2border_above) ||
721 (ob == longtable_options_->check_foot_2border_below)) {
722 return (flag ? LyXTabular::SET_LTFOOT : LyXTabular::UNSET_LTFOOT);
723 } else if ((ob == longtable_options_->check_lt_lastfoot) ||
724 (ob == longtable_options_->check_lastfoot_2border_above) ||
725 (ob == longtable_options_->check_lastfoot_2border_below) ||
726 (ob == longtable_options_->check_lastfoot_empty)) {
727 return (flag ? LyXTabular::SET_LTLASTFOOT :
728 LyXTabular::UNSET_LTLASTFOOT);
731 return LyXTabular::LAST_ACTION;